documentation.d.ts 3.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. /**
  94. * User defined information that will be sent to observers
  95. */
  96. userInfo?: any;
  97. }
  98. /**
  99. * Represent an Observer registered to a given Observable object.
  100. */
  101. export class Observer<T> {
  102. /**
  103. * Defines the callback to call when the observer is notified
  104. */
  105. callback: (eventData: T, eventState: EventState) => void;
  106. /**
  107. * Defines the mask of the observer (used to filter notifications)
  108. */
  109. mask: number;
  110. /**
  111. * Defines the current scope used to restore the JS context
  112. */
  113. scope: any;
  114. /** @hidden */
  115. _willBeUnregistered: boolean;
  116. /**
  117. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  118. */
  119. unregisterOnNextCall: boolean;
  120. /**
  121. * Creates a new observer
  122. * @param callback defines the callback to call when the observer is notified
  123. * @param mask defines the mask of the observer (used to filter notifications)
  124. * @param scope defines the current scope used to restore the JS context
  125. */
  126. constructor(
  127. /**
  128. * Defines the callback to call when the observer is notified
  129. */
  130. callback: (eventData: T, eventState: EventState) => void,
  131. /**
  132. * Defines the mask of the observer (used to filter notifications)
  133. */
  134. mask: number,
  135. /**
  136. * Defines the current scope used to restore the JS context
  137. */
  138. scope?: any);
  139. }
  140. /**
  141. * Represent a list of observers registered to multiple Observables object.
  142. */
  143. export class MultiObserver<T> {
  144. private _observers;
  145. private _observables;
  146. /**
  147. * Release associated resources
  148. */
  149. dispose(): void;
  150. /**
  151. * Raise a callback when one of the observable will notify
  152. * @param observables defines a list of observables to watch
  153. * @param callback defines the callback to call on notification
  154. * @param mask defines the mask used to filter notifications
  155. * @param scope defines the current scope used to restore the JS context
  156. * @returns the new MultiObserver
  157. */
  158. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  159. }
  160. /**
  161. * The Observable class is a simple implementation of the Observable pattern.
  162. *
  163. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  164. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  165. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  166. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  167. */
  168. export class Observable<T> {
  169. private _observers;
  170. private _eventState;
  171. private _onObserverAdded;
  172. /**
  173. * Gets the list of observers
  174. */
  175. get observers(): Array<Observer<T>>;
  176. /**
  177. * Creates a new observable
  178. * @param onObserverAdded defines a callback to call when a new observer is added
  179. */
  180. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  181. /**
  182. * Create a new Observer with the specified callback
  183. * @param callback the callback that will be executed for that Observer
  184. * @param mask the mask used to filter observers
  185. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  186. * @param scope optional scope for the callback to be called from
  187. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  188. * @returns the new observer created for the callback
  189. */
  190. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  191. /**
  192. * Create a new Observer with the specified callback and unregisters after the next notification
  193. * @param callback the callback that will be executed for that Observer
  194. * @returns the new observer created for the callback
  195. */
  196. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  197. /**
  198. * Remove an Observer from the Observable object
  199. * @param observer the instance of the Observer to remove
  200. * @returns false if it doesn't belong to this Observable
  201. */
  202. remove(observer: Nullable<Observer<T>>): boolean;
  203. /**
  204. * Remove a callback from the Observable object
  205. * @param callback the callback to remove
  206. * @param scope optional scope. If used only the callbacks with this scope will be removed
  207. * @returns false if it doesn't belong to this Observable
  208. */
  209. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  210. private _deferUnregister;
  211. private _remove;
  212. /**
  213. * Moves the observable to the top of the observer list making it get called first when notified
  214. * @param observer the observer to move
  215. */
  216. makeObserverTopPriority(observer: Observer<T>): void;
  217. /**
  218. * Moves the observable to the bottom of the observer list making it get called last when notified
  219. * @param observer the observer to move
  220. */
  221. makeObserverBottomPriority(observer: Observer<T>): void;
  222. /**
  223. * Notify all Observers by calling their respective callback with the given data
  224. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  225. * @param eventData defines the data to send to all observers
  226. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  227. * @param target defines the original target of the state
  228. * @param currentTarget defines the current target of the state
  229. * @param userInfo defines any user info to send to observers
  230. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  231. */
  232. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  233. /**
  234. * Calling this will execute each callback, expecting it to be a promise or return a value.
  235. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  236. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  237. * and it is crucial that all callbacks will be executed.
  238. * The order of the callbacks is kept, callbacks are not executed parallel.
  239. *
  240. * @param eventData The data to be sent to each callback
  241. * @param mask is used to filter observers defaults to -1
  242. * @param target defines the callback target (see EventState)
  243. * @param currentTarget defines he current object in the bubbling phase
  244. * @param userInfo defines any user info to send to observers
  245. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  246. */
  247. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  248. /**
  249. * Notify a specific observer
  250. * @param observer defines the observer to notify
  251. * @param eventData defines the data to be sent to each callback
  252. * @param mask is used to filter observers defaults to -1
  253. */
  254. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  255. /**
  256. * Gets a boolean indicating if the observable has at least one observer
  257. * @returns true is the Observable has at least one Observer registered
  258. */
  259. hasObservers(): boolean;
  260. /**
  261. * Clear the list of observers
  262. */
  263. clear(): void;
  264. /**
  265. * Clone the current observable
  266. * @returns a new observable
  267. */
  268. clone(): Observable<T>;
  269. /**
  270. * Does this observable handles observer registered with a given mask
  271. * @param mask defines the mask to be tested
  272. * @return whether or not one observer registered with the given mask is handeled
  273. **/
  274. hasSpecificMask(mask?: number): boolean;
  275. }
  276. }
  277. declare module BABYLON {
  278. /**
  279. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  280. * Babylon.js
  281. */
  282. export class DomManagement {
  283. /**
  284. * Checks if the window object exists
  285. * @returns true if the window object exists
  286. */
  287. static IsWindowObjectExist(): boolean;
  288. /**
  289. * Checks if the navigator object exists
  290. * @returns true if the navigator object exists
  291. */
  292. static IsNavigatorAvailable(): boolean;
  293. /**
  294. * Check if the document object exists
  295. * @returns true if the document object exists
  296. */
  297. static IsDocumentAvailable(): boolean;
  298. /**
  299. * Extracts text content from a DOM element hierarchy
  300. * @param element defines the root element
  301. * @returns a string
  302. */
  303. static GetDOMTextContent(element: HTMLElement): string;
  304. }
  305. }
  306. declare module BABYLON {
  307. /**
  308. * Logger used througouht the application to allow configuration of
  309. * the log level required for the messages.
  310. */
  311. export class Logger {
  312. /**
  313. * No log
  314. */
  315. static readonly NoneLogLevel: number;
  316. /**
  317. * Only message logs
  318. */
  319. static readonly MessageLogLevel: number;
  320. /**
  321. * Only warning logs
  322. */
  323. static readonly WarningLogLevel: number;
  324. /**
  325. * Only error logs
  326. */
  327. static readonly ErrorLogLevel: number;
  328. /**
  329. * All logs
  330. */
  331. static readonly AllLogLevel: number;
  332. private static _LogCache;
  333. /**
  334. * Gets a value indicating the number of loading errors
  335. * @ignorenaming
  336. */
  337. static errorsCount: number;
  338. /**
  339. * Callback called when a new log is added
  340. */
  341. static OnNewCacheEntry: (entry: string) => void;
  342. private static _AddLogEntry;
  343. private static _FormatMessage;
  344. private static _LogDisabled;
  345. private static _LogEnabled;
  346. private static _WarnDisabled;
  347. private static _WarnEnabled;
  348. private static _ErrorDisabled;
  349. private static _ErrorEnabled;
  350. /**
  351. * Log a message to the console
  352. */
  353. static Log: (message: string) => void;
  354. /**
  355. * Write a warning message to the console
  356. */
  357. static Warn: (message: string) => void;
  358. /**
  359. * Write an error message to the console
  360. */
  361. static Error: (message: string) => void;
  362. /**
  363. * Gets current log cache (list of logs)
  364. */
  365. static get LogCache(): string;
  366. /**
  367. * Clears the log cache
  368. */
  369. static ClearLogCache(): void;
  370. /**
  371. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  372. */
  373. static set LogLevels(level: number);
  374. }
  375. }
  376. declare module BABYLON {
  377. /** @hidden */
  378. export class _TypeStore {
  379. /** @hidden */
  380. static RegisteredTypes: {
  381. [key: string]: Object;
  382. };
  383. /** @hidden */
  384. static GetClass(fqdn: string): any;
  385. }
  386. }
  387. declare module BABYLON {
  388. /**
  389. * Helper to manipulate strings
  390. */
  391. export class StringTools {
  392. /**
  393. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  394. * @param str Source string
  395. * @param suffix Suffix to search for in the source string
  396. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  397. */
  398. static EndsWith(str: string, suffix: string): boolean;
  399. /**
  400. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  401. * @param str Source string
  402. * @param suffix Suffix to search for in the source string
  403. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  404. */
  405. static StartsWith(str: string, suffix: string): boolean;
  406. /**
  407. * Decodes a buffer into a string
  408. * @param buffer The buffer to decode
  409. * @returns The decoded string
  410. */
  411. static Decode(buffer: Uint8Array | Uint16Array): string;
  412. /**
  413. * Encode a buffer to a base64 string
  414. * @param buffer defines the buffer to encode
  415. * @returns the encoded string
  416. */
  417. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  418. /**
  419. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  420. * @param num the number to convert and pad
  421. * @param length the expected length of the string
  422. * @returns the padded string
  423. */
  424. static PadNumber(num: number, length: number): string;
  425. }
  426. }
  427. declare module BABYLON {
  428. /**
  429. * Class containing a set of static utilities functions for deep copy.
  430. */
  431. export class DeepCopier {
  432. /**
  433. * Tries to copy an object by duplicating every property
  434. * @param source defines the source object
  435. * @param destination defines the target object
  436. * @param doNotCopyList defines a list of properties to avoid
  437. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  438. */
  439. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  440. }
  441. }
  442. declare module BABYLON {
  443. /**
  444. * Class containing a set of static utilities functions for precision date
  445. */
  446. export class PrecisionDate {
  447. /**
  448. * Gets either window.performance.now() if supported or Date.now() else
  449. */
  450. static get Now(): number;
  451. }
  452. }
  453. declare module BABYLON {
  454. /** @hidden */
  455. export class _DevTools {
  456. static WarnImport(name: string): string;
  457. }
  458. }
  459. declare module BABYLON {
  460. /**
  461. * Interface used to define the mechanism to get data from the network
  462. */
  463. export interface IWebRequest {
  464. /**
  465. * Returns client's response url
  466. */
  467. responseURL: string;
  468. /**
  469. * Returns client's status
  470. */
  471. status: number;
  472. /**
  473. * Returns client's status as a text
  474. */
  475. statusText: string;
  476. }
  477. }
  478. declare module BABYLON {
  479. /**
  480. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  481. */
  482. export class WebRequest implements IWebRequest {
  483. private readonly _xhr;
  484. /**
  485. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  486. * i.e. when loading files, where the server/service expects an Authorization header
  487. */
  488. static CustomRequestHeaders: {
  489. [key: string]: string;
  490. };
  491. /**
  492. * Add callback functions in this array to update all the requests before they get sent to the network
  493. */
  494. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  495. private _injectCustomRequestHeaders;
  496. /**
  497. * Gets or sets a function to be called when loading progress changes
  498. */
  499. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  500. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  501. /**
  502. * Returns client's state
  503. */
  504. get readyState(): number;
  505. /**
  506. * Returns client's status
  507. */
  508. get status(): number;
  509. /**
  510. * Returns client's status as a text
  511. */
  512. get statusText(): string;
  513. /**
  514. * Returns client's response
  515. */
  516. get response(): any;
  517. /**
  518. * Returns client's response url
  519. */
  520. get responseURL(): string;
  521. /**
  522. * Returns client's response as text
  523. */
  524. get responseText(): string;
  525. /**
  526. * Gets or sets the expected response type
  527. */
  528. get responseType(): XMLHttpRequestResponseType;
  529. set responseType(value: XMLHttpRequestResponseType);
  530. /** @hidden */
  531. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  532. /** @hidden */
  533. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  534. /**
  535. * Cancels any network activity
  536. */
  537. abort(): void;
  538. /**
  539. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  540. * @param body defines an optional request body
  541. */
  542. send(body?: Document | BodyInit | null): void;
  543. /**
  544. * Sets the request method, request URL
  545. * @param method defines the method to use (GET, POST, etc..)
  546. * @param url defines the url to connect with
  547. */
  548. open(method: string, url: string): void;
  549. /**
  550. * Sets the value of a request header.
  551. * @param name The name of the header whose value is to be set
  552. * @param value The value to set as the body of the header
  553. */
  554. setRequestHeader(name: string, value: string): void;
  555. /**
  556. * Get the string containing the text of a particular header's value.
  557. * @param name The name of the header
  558. * @returns The string containing the text of the given header name
  559. */
  560. getResponseHeader(name: string): Nullable<string>;
  561. }
  562. }
  563. declare module BABYLON {
  564. /**
  565. * File request interface
  566. */
  567. export interface IFileRequest {
  568. /**
  569. * Raised when the request is complete (success or error).
  570. */
  571. onCompleteObservable: Observable<IFileRequest>;
  572. /**
  573. * Aborts the request for a file.
  574. */
  575. abort: () => void;
  576. }
  577. }
  578. declare module BABYLON {
  579. /**
  580. * Define options used to create a render target texture
  581. */
  582. export class RenderTargetCreationOptions {
  583. /**
  584. * Specifies is mipmaps must be generated
  585. */
  586. generateMipMaps?: boolean;
  587. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  588. generateDepthBuffer?: boolean;
  589. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  590. generateStencilBuffer?: boolean;
  591. /** Defines texture type (int by default) */
  592. type?: number;
  593. /** Defines sampling mode (trilinear by default) */
  594. samplingMode?: number;
  595. /** Defines format (RGBA by default) */
  596. format?: number;
  597. }
  598. }
  599. declare module BABYLON {
  600. /** Defines the cross module used constants to avoid circular dependncies */
  601. export class Constants {
  602. /** Defines that alpha blending is disabled */
  603. static readonly ALPHA_DISABLE: number;
  604. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  605. static readonly ALPHA_ADD: number;
  606. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  607. static readonly ALPHA_COMBINE: number;
  608. /** Defines that alpha blending is DEST - SRC * DEST */
  609. static readonly ALPHA_SUBTRACT: number;
  610. /** Defines that alpha blending is SRC * DEST */
  611. static readonly ALPHA_MULTIPLY: number;
  612. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  613. static readonly ALPHA_MAXIMIZED: number;
  614. /** Defines that alpha blending is SRC + DEST */
  615. static readonly ALPHA_ONEONE: number;
  616. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  617. static readonly ALPHA_PREMULTIPLIED: number;
  618. /**
  619. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  620. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  621. */
  622. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  623. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  624. static readonly ALPHA_INTERPOLATE: number;
  625. /**
  626. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  627. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  628. */
  629. static readonly ALPHA_SCREENMODE: number;
  630. /**
  631. * Defines that alpha blending is SRC + DST
  632. * Alpha will be set to SRC ALPHA + DST ALPHA
  633. */
  634. static readonly ALPHA_ONEONE_ONEONE: number;
  635. /**
  636. * Defines that alpha blending is SRC * DST ALPHA + DST
  637. * Alpha will be set to 0
  638. */
  639. static readonly ALPHA_ALPHATOCOLOR: number;
  640. /**
  641. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  642. */
  643. static readonly ALPHA_REVERSEONEMINUS: number;
  644. /**
  645. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  646. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  647. */
  648. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  649. /**
  650. * Defines that alpha blending is SRC + DST
  651. * Alpha will be set to SRC ALPHA
  652. */
  653. static readonly ALPHA_ONEONE_ONEZERO: number;
  654. /**
  655. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  656. * Alpha will be set to DST ALPHA
  657. */
  658. static readonly ALPHA_EXCLUSION: number;
  659. /** Defines that alpha blending equation a SUM */
  660. static readonly ALPHA_EQUATION_ADD: number;
  661. /** Defines that alpha blending equation a SUBSTRACTION */
  662. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  663. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  664. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  665. /** Defines that alpha blending equation a MAX operation */
  666. static readonly ALPHA_EQUATION_MAX: number;
  667. /** Defines that alpha blending equation a MIN operation */
  668. static readonly ALPHA_EQUATION_MIN: number;
  669. /**
  670. * Defines that alpha blending equation a DARKEN operation:
  671. * It takes the min of the src and sums the alpha channels.
  672. */
  673. static readonly ALPHA_EQUATION_DARKEN: number;
  674. /** Defines that the ressource is not delayed*/
  675. static readonly DELAYLOADSTATE_NONE: number;
  676. /** Defines that the ressource was successfully delay loaded */
  677. static readonly DELAYLOADSTATE_LOADED: number;
  678. /** Defines that the ressource is currently delay loading */
  679. static readonly DELAYLOADSTATE_LOADING: number;
  680. /** Defines that the ressource is delayed and has not started loading */
  681. static readonly DELAYLOADSTATE_NOTLOADED: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  683. static readonly NEVER: number;
  684. /** 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 */
  685. static readonly ALWAYS: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  687. static readonly LESS: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  689. static readonly EQUAL: number;
  690. /** 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 */
  691. static readonly LEQUAL: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  693. static readonly GREATER: number;
  694. /** 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 */
  695. static readonly GEQUAL: number;
  696. /** 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 */
  697. static readonly NOTEQUAL: number;
  698. /** Passed to stencilOperation to specify that stencil value must be kept */
  699. static readonly KEEP: number;
  700. /** Passed to stencilOperation to specify that stencil value must be replaced */
  701. static readonly REPLACE: number;
  702. /** Passed to stencilOperation to specify that stencil value must be incremented */
  703. static readonly INCR: number;
  704. /** Passed to stencilOperation to specify that stencil value must be decremented */
  705. static readonly DECR: number;
  706. /** Passed to stencilOperation to specify that stencil value must be inverted */
  707. static readonly INVERT: number;
  708. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  709. static readonly INCR_WRAP: number;
  710. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  711. static readonly DECR_WRAP: number;
  712. /** Texture is not repeating outside of 0..1 UVs */
  713. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  714. /** Texture is repeating outside of 0..1 UVs */
  715. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  716. /** Texture is repeating and mirrored */
  717. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  718. /** ALPHA */
  719. static readonly TEXTUREFORMAT_ALPHA: number;
  720. /** LUMINANCE */
  721. static readonly TEXTUREFORMAT_LUMINANCE: number;
  722. /** LUMINANCE_ALPHA */
  723. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  724. /** RGB */
  725. static readonly TEXTUREFORMAT_RGB: number;
  726. /** RGBA */
  727. static readonly TEXTUREFORMAT_RGBA: number;
  728. /** RED */
  729. static readonly TEXTUREFORMAT_RED: number;
  730. /** RED (2nd reference) */
  731. static readonly TEXTUREFORMAT_R: number;
  732. /** RG */
  733. static readonly TEXTUREFORMAT_RG: number;
  734. /** RED_INTEGER */
  735. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  736. /** RED_INTEGER (2nd reference) */
  737. static readonly TEXTUREFORMAT_R_INTEGER: number;
  738. /** RG_INTEGER */
  739. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  740. /** RGB_INTEGER */
  741. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  742. /** RGBA_INTEGER */
  743. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  744. /** UNSIGNED_BYTE */
  745. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  746. /** UNSIGNED_BYTE (2nd reference) */
  747. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  748. /** FLOAT */
  749. static readonly TEXTURETYPE_FLOAT: number;
  750. /** HALF_FLOAT */
  751. static readonly TEXTURETYPE_HALF_FLOAT: number;
  752. /** BYTE */
  753. static readonly TEXTURETYPE_BYTE: number;
  754. /** SHORT */
  755. static readonly TEXTURETYPE_SHORT: number;
  756. /** UNSIGNED_SHORT */
  757. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  758. /** INT */
  759. static readonly TEXTURETYPE_INT: number;
  760. /** UNSIGNED_INT */
  761. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  762. /** UNSIGNED_SHORT_4_4_4_4 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  764. /** UNSIGNED_SHORT_5_5_5_1 */
  765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  766. /** UNSIGNED_SHORT_5_6_5 */
  767. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  768. /** UNSIGNED_INT_2_10_10_10_REV */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  770. /** UNSIGNED_INT_24_8 */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  772. /** UNSIGNED_INT_10F_11F_11F_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  774. /** UNSIGNED_INT_5_9_9_9_REV */
  775. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  776. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  777. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  778. /** nearest is mag = nearest and min = nearest and no mip */
  779. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  780. /** mag = nearest and min = nearest and mip = none */
  781. static readonly TEXTURE_NEAREST_NEAREST: number;
  782. /** Bilinear is mag = linear and min = linear and no mip */
  783. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  784. /** mag = linear and min = linear and mip = none */
  785. static readonly TEXTURE_LINEAR_LINEAR: number;
  786. /** Trilinear is mag = linear and min = linear and mip = linear */
  787. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  788. /** Trilinear is mag = linear and min = linear and mip = linear */
  789. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  790. /** mag = nearest and min = nearest and mip = nearest */
  791. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  792. /** mag = nearest and min = linear and mip = nearest */
  793. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  794. /** mag = nearest and min = linear and mip = linear */
  795. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  796. /** mag = nearest and min = linear and mip = none */
  797. static readonly TEXTURE_NEAREST_LINEAR: number;
  798. /** nearest is mag = nearest and min = nearest and mip = linear */
  799. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  800. /** mag = linear and min = nearest and mip = nearest */
  801. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  802. /** mag = linear and min = nearest and mip = linear */
  803. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  804. /** Bilinear is mag = linear and min = linear and mip = nearest */
  805. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  806. /** mag = linear and min = nearest and mip = none */
  807. static readonly TEXTURE_LINEAR_NEAREST: number;
  808. /** Explicit coordinates mode */
  809. static readonly TEXTURE_EXPLICIT_MODE: number;
  810. /** Spherical coordinates mode */
  811. static readonly TEXTURE_SPHERICAL_MODE: number;
  812. /** Planar coordinates mode */
  813. static readonly TEXTURE_PLANAR_MODE: number;
  814. /** Cubic coordinates mode */
  815. static readonly TEXTURE_CUBIC_MODE: number;
  816. /** Projection coordinates mode */
  817. static readonly TEXTURE_PROJECTION_MODE: number;
  818. /** Skybox coordinates mode */
  819. static readonly TEXTURE_SKYBOX_MODE: number;
  820. /** Inverse Cubic coordinates mode */
  821. static readonly TEXTURE_INVCUBIC_MODE: number;
  822. /** Equirectangular coordinates mode */
  823. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  824. /** Equirectangular Fixed coordinates mode */
  825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  826. /** Equirectangular Fixed Mirrored coordinates mode */
  827. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  828. /** Offline (baking) quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  830. /** High quality for texture filtering */
  831. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  832. /** Medium quality for texture filtering */
  833. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  834. /** Low quality for texture filtering */
  835. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  836. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  837. static readonly SCALEMODE_FLOOR: number;
  838. /** Defines that texture rescaling will look for the nearest power of 2 size */
  839. static readonly SCALEMODE_NEAREST: number;
  840. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  841. static readonly SCALEMODE_CEILING: number;
  842. /**
  843. * The dirty texture flag value
  844. */
  845. static readonly MATERIAL_TextureDirtyFlag: number;
  846. /**
  847. * The dirty light flag value
  848. */
  849. static readonly MATERIAL_LightDirtyFlag: number;
  850. /**
  851. * The dirty fresnel flag value
  852. */
  853. static readonly MATERIAL_FresnelDirtyFlag: number;
  854. /**
  855. * The dirty attribute flag value
  856. */
  857. static readonly MATERIAL_AttributesDirtyFlag: number;
  858. /**
  859. * The dirty misc flag value
  860. */
  861. static readonly MATERIAL_MiscDirtyFlag: number;
  862. /**
  863. * The dirty prepass flag value
  864. */
  865. static readonly MATERIAL_PrePassDirtyFlag: number;
  866. /**
  867. * The all dirty flag value
  868. */
  869. static readonly MATERIAL_AllDirtyFlag: number;
  870. /**
  871. * Returns the triangle fill mode
  872. */
  873. static readonly MATERIAL_TriangleFillMode: number;
  874. /**
  875. * Returns the wireframe mode
  876. */
  877. static readonly MATERIAL_WireFrameFillMode: number;
  878. /**
  879. * Returns the point fill mode
  880. */
  881. static readonly MATERIAL_PointFillMode: number;
  882. /**
  883. * Returns the point list draw mode
  884. */
  885. static readonly MATERIAL_PointListDrawMode: number;
  886. /**
  887. * Returns the line list draw mode
  888. */
  889. static readonly MATERIAL_LineListDrawMode: number;
  890. /**
  891. * Returns the line loop draw mode
  892. */
  893. static readonly MATERIAL_LineLoopDrawMode: number;
  894. /**
  895. * Returns the line strip draw mode
  896. */
  897. static readonly MATERIAL_LineStripDrawMode: number;
  898. /**
  899. * Returns the triangle strip draw mode
  900. */
  901. static readonly MATERIAL_TriangleStripDrawMode: number;
  902. /**
  903. * Returns the triangle fan draw mode
  904. */
  905. static readonly MATERIAL_TriangleFanDrawMode: number;
  906. /**
  907. * Stores the clock-wise side orientation
  908. */
  909. static readonly MATERIAL_ClockWiseSideOrientation: number;
  910. /**
  911. * Stores the counter clock-wise side orientation
  912. */
  913. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  914. /**
  915. * Nothing
  916. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  917. */
  918. static readonly ACTION_NothingTrigger: number;
  919. /**
  920. * On pick
  921. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  922. */
  923. static readonly ACTION_OnPickTrigger: number;
  924. /**
  925. * On left pick
  926. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  927. */
  928. static readonly ACTION_OnLeftPickTrigger: number;
  929. /**
  930. * On right pick
  931. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnRightPickTrigger: number;
  934. /**
  935. * On center pick
  936. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnCenterPickTrigger: number;
  939. /**
  940. * On pick down
  941. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPickDownTrigger: number;
  944. /**
  945. * On double pick
  946. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  947. */
  948. static readonly ACTION_OnDoublePickTrigger: number;
  949. /**
  950. * On pick up
  951. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPickUpTrigger: number;
  954. /**
  955. * On pick out.
  956. * This trigger will only be raised if you also declared a OnPickDown
  957. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  958. */
  959. static readonly ACTION_OnPickOutTrigger: number;
  960. /**
  961. * On long press
  962. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  963. */
  964. static readonly ACTION_OnLongPressTrigger: number;
  965. /**
  966. * On pointer over
  967. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  968. */
  969. static readonly ACTION_OnPointerOverTrigger: number;
  970. /**
  971. * On pointer out
  972. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  973. */
  974. static readonly ACTION_OnPointerOutTrigger: number;
  975. /**
  976. * On every frame
  977. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  978. */
  979. static readonly ACTION_OnEveryFrameTrigger: number;
  980. /**
  981. * On intersection enter
  982. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  983. */
  984. static readonly ACTION_OnIntersectionEnterTrigger: number;
  985. /**
  986. * On intersection exit
  987. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  988. */
  989. static readonly ACTION_OnIntersectionExitTrigger: number;
  990. /**
  991. * On key down
  992. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  993. */
  994. static readonly ACTION_OnKeyDownTrigger: number;
  995. /**
  996. * On key up
  997. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  998. */
  999. static readonly ACTION_OnKeyUpTrigger: number;
  1000. /**
  1001. * Billboard mode will only apply to Y axis
  1002. */
  1003. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  1004. /**
  1005. * Billboard mode will apply to all axes
  1006. */
  1007. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1008. /**
  1009. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1010. */
  1011. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1012. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1013. * Test order :
  1014. * Is the bounding sphere outside the frustum ?
  1015. * If not, are the bounding box vertices outside the frustum ?
  1016. * It not, then the cullable object is in the frustum.
  1017. */
  1018. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1019. /** Culling strategy : Bounding Sphere Only.
  1020. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1021. * It's also less accurate than the standard because some not visible objects can still be selected.
  1022. * Test : is the bounding sphere outside the frustum ?
  1023. * If not, then the cullable object is in the frustum.
  1024. */
  1025. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1026. /** Culling strategy : Optimistic Inclusion.
  1027. * This in an inclusion test first, then the standard exclusion test.
  1028. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1029. * 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.
  1030. * Anyway, it's as accurate as the standard strategy.
  1031. * Test :
  1032. * Is the cullable object bounding sphere center in the frustum ?
  1033. * If not, apply the default culling strategy.
  1034. */
  1035. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1036. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1037. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1038. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1039. * 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.
  1040. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1041. * Test :
  1042. * Is the cullable object bounding sphere center in the frustum ?
  1043. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1044. */
  1045. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1046. /**
  1047. * No logging while loading
  1048. */
  1049. static readonly SCENELOADER_NO_LOGGING: number;
  1050. /**
  1051. * Minimal logging while loading
  1052. */
  1053. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1054. /**
  1055. * Summary logging while loading
  1056. */
  1057. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1058. /**
  1059. * Detailled logging while loading
  1060. */
  1061. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1062. /**
  1063. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1064. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1065. */
  1066. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1067. /**
  1068. * Constant used to retrieve the position texture index in the textures array in the prepass
  1069. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1070. */
  1071. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1072. /**
  1073. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1074. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1075. */
  1076. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1077. /**
  1078. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1079. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1080. */
  1081. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1082. /**
  1083. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1084. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1085. */
  1086. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1087. /**
  1088. * Constant used to retrieve depth + normal index in the textures array in the prepass
  1089. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  1090. */
  1091. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  1092. /**
  1093. * Constant used to retrieve albedo index in the textures array in the prepass
  1094. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1095. */
  1096. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1097. }
  1098. }
  1099. declare module BABYLON {
  1100. /**
  1101. * This represents the required contract to create a new type of texture loader.
  1102. */
  1103. export interface IInternalTextureLoader {
  1104. /**
  1105. * Defines wether the loader supports cascade loading the different faces.
  1106. */
  1107. supportCascades: boolean;
  1108. /**
  1109. * This returns if the loader support the current file information.
  1110. * @param extension defines the file extension of the file being loaded
  1111. * @param mimeType defines the optional mime type of the file being loaded
  1112. * @returns true if the loader can load the specified file
  1113. */
  1114. canLoad(extension: string, mimeType?: string): boolean;
  1115. /**
  1116. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1117. * @param data contains the texture data
  1118. * @param texture defines the BabylonJS internal texture
  1119. * @param createPolynomials will be true if polynomials have been requested
  1120. * @param onLoad defines the callback to trigger once the texture is ready
  1121. * @param onError defines the callback to trigger in case of error
  1122. * @param options options to be passed to the loader
  1123. */
  1124. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  1125. /**
  1126. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1127. * @param data contains the texture data
  1128. * @param texture defines the BabylonJS internal texture
  1129. * @param callback defines the method to call once ready to upload
  1130. * @param options options to be passed to the loader
  1131. */
  1132. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  1133. }
  1134. }
  1135. declare module BABYLON {
  1136. /**
  1137. * Class used to store and describe the pipeline context associated with an effect
  1138. */
  1139. export interface IPipelineContext {
  1140. /**
  1141. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1142. */
  1143. isAsync: boolean;
  1144. /**
  1145. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1146. */
  1147. isReady: boolean;
  1148. /** @hidden */
  1149. _getVertexShaderCode(): string | null;
  1150. /** @hidden */
  1151. _getFragmentShaderCode(): string | null;
  1152. /** @hidden */
  1153. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1154. }
  1155. }
  1156. declare module BABYLON {
  1157. /**
  1158. * Class used to store gfx data (like WebGLBuffer)
  1159. */
  1160. export class DataBuffer {
  1161. /**
  1162. * Gets or sets the number of objects referencing this buffer
  1163. */
  1164. references: number;
  1165. /** Gets or sets the size of the underlying buffer */
  1166. capacity: number;
  1167. /**
  1168. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1169. */
  1170. is32Bits: boolean;
  1171. /**
  1172. * Gets the underlying buffer
  1173. */
  1174. get underlyingResource(): any;
  1175. }
  1176. }
  1177. declare module BABYLON {
  1178. /** @hidden */
  1179. export interface IShaderProcessor {
  1180. attributeProcessor?: (attribute: string) => string;
  1181. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1182. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1183. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1184. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1185. lineProcessor?: (line: string, isFragment: boolean) => string;
  1186. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1187. postProcessor?: (code: string, defines: string[], isFragment: boolean, engine: ThinEngine) => string;
  1188. }
  1189. }
  1190. declare module BABYLON {
  1191. /** @hidden */
  1192. export interface ProcessingOptions {
  1193. defines: string[];
  1194. indexParameters: any;
  1195. isFragment: boolean;
  1196. shouldUseHighPrecisionShader: boolean;
  1197. supportsUniformBuffers: boolean;
  1198. shadersRepository: string;
  1199. includesShadersStore: {
  1200. [key: string]: string;
  1201. };
  1202. processor?: IShaderProcessor;
  1203. version: string;
  1204. platformName: string;
  1205. lookForClosingBracketForUniformBuffer?: boolean;
  1206. }
  1207. }
  1208. declare module BABYLON {
  1209. /** @hidden */
  1210. export class ShaderCodeNode {
  1211. line: string;
  1212. children: ShaderCodeNode[];
  1213. additionalDefineKey?: string;
  1214. additionalDefineValue?: string;
  1215. isValid(preprocessors: {
  1216. [key: string]: string;
  1217. }): boolean;
  1218. process(preprocessors: {
  1219. [key: string]: string;
  1220. }, options: ProcessingOptions): string;
  1221. }
  1222. }
  1223. declare module BABYLON {
  1224. /** @hidden */
  1225. export class ShaderCodeCursor {
  1226. private _lines;
  1227. lineIndex: number;
  1228. get currentLine(): string;
  1229. get canRead(): boolean;
  1230. set lines(value: string[]);
  1231. }
  1232. }
  1233. declare module BABYLON {
  1234. /** @hidden */
  1235. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1236. process(preprocessors: {
  1237. [key: string]: string;
  1238. }, options: ProcessingOptions): string;
  1239. }
  1240. }
  1241. declare module BABYLON {
  1242. /** @hidden */
  1243. export class ShaderDefineExpression {
  1244. isTrue(preprocessors: {
  1245. [key: string]: string;
  1246. }): boolean;
  1247. private static _OperatorPriority;
  1248. private static _Stack;
  1249. static postfixToInfix(postfix: string[]): string;
  1250. static infixToPostfix(infix: string): string[];
  1251. }
  1252. }
  1253. declare module BABYLON {
  1254. /** @hidden */
  1255. export class ShaderCodeTestNode extends ShaderCodeNode {
  1256. testExpression: ShaderDefineExpression;
  1257. isValid(preprocessors: {
  1258. [key: string]: string;
  1259. }): boolean;
  1260. }
  1261. }
  1262. declare module BABYLON {
  1263. /** @hidden */
  1264. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1265. define: string;
  1266. not: boolean;
  1267. constructor(define: string, not?: boolean);
  1268. isTrue(preprocessors: {
  1269. [key: string]: string;
  1270. }): boolean;
  1271. }
  1272. }
  1273. declare module BABYLON {
  1274. /** @hidden */
  1275. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1276. leftOperand: ShaderDefineExpression;
  1277. rightOperand: ShaderDefineExpression;
  1278. isTrue(preprocessors: {
  1279. [key: string]: string;
  1280. }): boolean;
  1281. }
  1282. }
  1283. declare module BABYLON {
  1284. /** @hidden */
  1285. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1286. leftOperand: ShaderDefineExpression;
  1287. rightOperand: ShaderDefineExpression;
  1288. isTrue(preprocessors: {
  1289. [key: string]: string;
  1290. }): boolean;
  1291. }
  1292. }
  1293. declare module BABYLON {
  1294. /** @hidden */
  1295. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1296. define: string;
  1297. operand: string;
  1298. testValue: string;
  1299. constructor(define: string, operand: string, testValue: string);
  1300. isTrue(preprocessors: {
  1301. [key: string]: string;
  1302. }): boolean;
  1303. }
  1304. }
  1305. declare module BABYLON {
  1306. /**
  1307. * Class used to enable access to offline support
  1308. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1309. */
  1310. export interface IOfflineProvider {
  1311. /**
  1312. * Gets a boolean indicating if scene must be saved in the database
  1313. */
  1314. enableSceneOffline: boolean;
  1315. /**
  1316. * Gets a boolean indicating if textures must be saved in the database
  1317. */
  1318. enableTexturesOffline: boolean;
  1319. /**
  1320. * Open the offline support and make it available
  1321. * @param successCallback defines the callback to call on success
  1322. * @param errorCallback defines the callback to call on error
  1323. */
  1324. open(successCallback: () => void, errorCallback: () => void): void;
  1325. /**
  1326. * Loads an image from the offline support
  1327. * @param url defines the url to load from
  1328. * @param image defines the target DOM image
  1329. */
  1330. loadImage(url: string, image: HTMLImageElement): void;
  1331. /**
  1332. * Loads a file from offline support
  1333. * @param url defines the URL to load from
  1334. * @param sceneLoaded defines a callback to call on success
  1335. * @param progressCallBack defines a callback to call when progress changed
  1336. * @param errorCallback defines a callback to call on error
  1337. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1338. */
  1339. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1340. }
  1341. }
  1342. declare module BABYLON {
  1343. /**
  1344. * Class used to help managing file picking and drag'n'drop
  1345. * File Storage
  1346. */
  1347. export class FilesInputStore {
  1348. /**
  1349. * List of files ready to be loaded
  1350. */
  1351. static FilesToLoad: {
  1352. [key: string]: File;
  1353. };
  1354. }
  1355. }
  1356. declare module BABYLON {
  1357. /**
  1358. * Class used to define a retry strategy when error happens while loading assets
  1359. */
  1360. export class RetryStrategy {
  1361. /**
  1362. * Function used to defines an exponential back off strategy
  1363. * @param maxRetries defines the maximum number of retries (3 by default)
  1364. * @param baseInterval defines the interval between retries
  1365. * @returns the strategy function to use
  1366. */
  1367. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1368. }
  1369. }
  1370. declare module BABYLON {
  1371. /**
  1372. * @ignore
  1373. * Application error to support additional information when loading a file
  1374. */
  1375. export abstract class BaseError extends Error {
  1376. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1377. }
  1378. }
  1379. declare module BABYLON {
  1380. /** @ignore */
  1381. export class LoadFileError extends BaseError {
  1382. request?: WebRequest;
  1383. file?: File;
  1384. /**
  1385. * Creates a new LoadFileError
  1386. * @param message defines the message of the error
  1387. * @param request defines the optional web request
  1388. * @param file defines the optional file
  1389. */
  1390. constructor(message: string, object?: WebRequest | File);
  1391. }
  1392. /** @ignore */
  1393. export class RequestFileError extends BaseError {
  1394. request: WebRequest;
  1395. /**
  1396. * Creates a new LoadFileError
  1397. * @param message defines the message of the error
  1398. * @param request defines the optional web request
  1399. */
  1400. constructor(message: string, request: WebRequest);
  1401. }
  1402. /** @ignore */
  1403. export class ReadFileError extends BaseError {
  1404. file: File;
  1405. /**
  1406. * Creates a new ReadFileError
  1407. * @param message defines the message of the error
  1408. * @param file defines the optional file
  1409. */
  1410. constructor(message: string, file: File);
  1411. }
  1412. /**
  1413. * @hidden
  1414. */
  1415. export class FileTools {
  1416. /**
  1417. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1418. */
  1419. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1420. /**
  1421. * Gets or sets the base URL to use to load assets
  1422. */
  1423. static BaseUrl: string;
  1424. /**
  1425. * Default behaviour for cors in the application.
  1426. * It can be a string if the expected behavior is identical in the entire app.
  1427. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1428. */
  1429. static CorsBehavior: string | ((url: string | string[]) => string);
  1430. /**
  1431. * Gets or sets a function used to pre-process url before using them to load assets
  1432. */
  1433. static PreprocessUrl: (url: string) => string;
  1434. /**
  1435. * Removes unwanted characters from an url
  1436. * @param url defines the url to clean
  1437. * @returns the cleaned url
  1438. */
  1439. private static _CleanUrl;
  1440. /**
  1441. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1442. * @param url define the url we are trying
  1443. * @param element define the dom element where to configure the cors policy
  1444. */
  1445. static SetCorsBehavior(url: string | string[], element: {
  1446. crossOrigin: string | null;
  1447. }): void;
  1448. /**
  1449. * Loads an image as an HTMLImageElement.
  1450. * @param input url string, ArrayBuffer, or Blob to load
  1451. * @param onLoad callback called when the image successfully loads
  1452. * @param onError callback called when the image fails to load
  1453. * @param offlineProvider offline provider for caching
  1454. * @param mimeType optional mime type
  1455. * @returns the HTMLImageElement of the loaded image
  1456. */
  1457. 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>;
  1458. /**
  1459. * Reads a file from a File object
  1460. * @param file defines the file to load
  1461. * @param onSuccess defines the callback to call when data is loaded
  1462. * @param onProgress defines the callback to call during loading process
  1463. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1464. * @param onError defines the callback to call when an error occurs
  1465. * @returns a file request object
  1466. */
  1467. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1468. /**
  1469. * Loads a file from a url
  1470. * @param url url to load
  1471. * @param onSuccess callback called when the file successfully loads
  1472. * @param onProgress callback called while file is loading (if the server supports this mode)
  1473. * @param offlineProvider defines the offline provider for caching
  1474. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1475. * @param onError callback called when the file fails to load
  1476. * @returns a file request object
  1477. */
  1478. 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;
  1479. /**
  1480. * Loads a file
  1481. * @param url url to load
  1482. * @param onSuccess callback called when the file successfully loads
  1483. * @param onProgress callback called while file is loading (if the server supports this mode)
  1484. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1485. * @param onError callback called when the file fails to load
  1486. * @param onOpened callback called when the web request is opened
  1487. * @returns a file request object
  1488. */
  1489. 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;
  1490. /**
  1491. * Checks if the loaded document was accessed via `file:`-Protocol.
  1492. * @returns boolean
  1493. */
  1494. static IsFileURL(): boolean;
  1495. }
  1496. }
  1497. declare module BABYLON {
  1498. /** @hidden */
  1499. export class ShaderProcessor {
  1500. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine): void;
  1501. private static _ProcessPrecision;
  1502. private static _ExtractOperation;
  1503. private static _BuildSubExpression;
  1504. private static _BuildExpression;
  1505. private static _MoveCursorWithinIf;
  1506. private static _MoveCursor;
  1507. private static _EvaluatePreProcessors;
  1508. private static _PreparePreProcessors;
  1509. private static _ProcessShaderConversion;
  1510. private static _ProcessIncludes;
  1511. /**
  1512. * Loads a file from a url
  1513. * @param url url to load
  1514. * @param onSuccess callback called when the file successfully loads
  1515. * @param onProgress callback called while file is loading (if the server supports this mode)
  1516. * @param offlineProvider defines the offline provider for caching
  1517. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1518. * @param onError callback called when the file fails to load
  1519. * @returns a file request object
  1520. * @hidden
  1521. */
  1522. 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;
  1523. }
  1524. }
  1525. declare module BABYLON {
  1526. /**
  1527. * @hidden
  1528. */
  1529. export interface IColor4Like {
  1530. r: float;
  1531. g: float;
  1532. b: float;
  1533. a: float;
  1534. }
  1535. /**
  1536. * @hidden
  1537. */
  1538. export interface IColor3Like {
  1539. r: float;
  1540. g: float;
  1541. b: float;
  1542. }
  1543. /**
  1544. * @hidden
  1545. */
  1546. export interface IVector4Like {
  1547. x: float;
  1548. y: float;
  1549. z: float;
  1550. w: float;
  1551. }
  1552. /**
  1553. * @hidden
  1554. */
  1555. export interface IVector3Like {
  1556. x: float;
  1557. y: float;
  1558. z: float;
  1559. }
  1560. /**
  1561. * @hidden
  1562. */
  1563. export interface IVector2Like {
  1564. x: float;
  1565. y: float;
  1566. }
  1567. /**
  1568. * @hidden
  1569. */
  1570. export interface IMatrixLike {
  1571. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1572. updateFlag: int;
  1573. }
  1574. /**
  1575. * @hidden
  1576. */
  1577. export interface IViewportLike {
  1578. x: float;
  1579. y: float;
  1580. width: float;
  1581. height: float;
  1582. }
  1583. /**
  1584. * @hidden
  1585. */
  1586. export interface IPlaneLike {
  1587. normal: IVector3Like;
  1588. d: float;
  1589. normalize(): void;
  1590. }
  1591. }
  1592. declare module BABYLON {
  1593. /**
  1594. * Interface used to define common properties for effect fallbacks
  1595. */
  1596. export interface IEffectFallbacks {
  1597. /**
  1598. * Removes the defines that should be removed when falling back.
  1599. * @param currentDefines defines the current define statements for the shader.
  1600. * @param effect defines the current effect we try to compile
  1601. * @returns The resulting defines with defines of the current rank removed.
  1602. */
  1603. reduce(currentDefines: string, effect: Effect): string;
  1604. /**
  1605. * Removes the fallback from the bound mesh.
  1606. */
  1607. unBindMesh(): void;
  1608. /**
  1609. * Checks to see if more fallbacks are still availible.
  1610. */
  1611. hasMoreFallbacks: boolean;
  1612. }
  1613. }
  1614. declare module BABYLON {
  1615. /**
  1616. * Class used to evalaute queries containing `and` and `or` operators
  1617. */
  1618. export class AndOrNotEvaluator {
  1619. /**
  1620. * Evaluate a query
  1621. * @param query defines the query to evaluate
  1622. * @param evaluateCallback defines the callback used to filter result
  1623. * @returns true if the query matches
  1624. */
  1625. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1626. private static _HandleParenthesisContent;
  1627. private static _SimplifyNegation;
  1628. }
  1629. }
  1630. declare module BABYLON {
  1631. /**
  1632. * Class used to store custom tags
  1633. */
  1634. export class Tags {
  1635. /**
  1636. * Adds support for tags on the given object
  1637. * @param obj defines the object to use
  1638. */
  1639. static EnableFor(obj: any): void;
  1640. /**
  1641. * Removes tags support
  1642. * @param obj defines the object to use
  1643. */
  1644. static DisableFor(obj: any): void;
  1645. /**
  1646. * Gets a boolean indicating if the given object has tags
  1647. * @param obj defines the object to use
  1648. * @returns a boolean
  1649. */
  1650. static HasTags(obj: any): boolean;
  1651. /**
  1652. * Gets the tags available on a given object
  1653. * @param obj defines the object to use
  1654. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1655. * @returns the tags
  1656. */
  1657. static GetTags(obj: any, asString?: boolean): any;
  1658. /**
  1659. * Adds tags to an object
  1660. * @param obj defines the object to use
  1661. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1662. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1663. */
  1664. static AddTagsTo(obj: any, tagsString: string): void;
  1665. /**
  1666. * @hidden
  1667. */
  1668. static _AddTagTo(obj: any, tag: string): void;
  1669. /**
  1670. * Removes specific tags from a specific object
  1671. * @param obj defines the object to use
  1672. * @param tagsString defines the tags to remove
  1673. */
  1674. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1675. /**
  1676. * @hidden
  1677. */
  1678. static _RemoveTagFrom(obj: any, tag: string): void;
  1679. /**
  1680. * Defines if tags hosted on an object match a given query
  1681. * @param obj defines the object to use
  1682. * @param tagsQuery defines the tag query
  1683. * @returns a boolean
  1684. */
  1685. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1686. }
  1687. }
  1688. declare module BABYLON {
  1689. /**
  1690. * Scalar computation library
  1691. */
  1692. export class Scalar {
  1693. /**
  1694. * Two pi constants convenient for computation.
  1695. */
  1696. static TwoPi: number;
  1697. /**
  1698. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1699. * @param a number
  1700. * @param b number
  1701. * @param epsilon (default = 1.401298E-45)
  1702. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1703. */
  1704. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1705. /**
  1706. * Returns a string : the upper case translation of the number i to hexadecimal.
  1707. * @param i number
  1708. * @returns the upper case translation of the number i to hexadecimal.
  1709. */
  1710. static ToHex(i: number): string;
  1711. /**
  1712. * Returns -1 if value is negative and +1 is value is positive.
  1713. * @param value the value
  1714. * @returns the value itself if it's equal to zero.
  1715. */
  1716. static Sign(value: number): number;
  1717. /**
  1718. * Returns the value itself if it's between min and max.
  1719. * Returns min if the value is lower than min.
  1720. * Returns max if the value is greater than max.
  1721. * @param value the value to clmap
  1722. * @param min the min value to clamp to (default: 0)
  1723. * @param max the max value to clamp to (default: 1)
  1724. * @returns the clamped value
  1725. */
  1726. static Clamp(value: number, min?: number, max?: number): number;
  1727. /**
  1728. * the log2 of value.
  1729. * @param value the value to compute log2 of
  1730. * @returns the log2 of value.
  1731. */
  1732. static Log2(value: number): number;
  1733. /**
  1734. * Loops the value, so that it is never larger than length and never smaller than 0.
  1735. *
  1736. * This is similar to the modulo operator but it works with floating point numbers.
  1737. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1738. * With t = 5 and length = 2.5, the result would be 0.0.
  1739. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1740. * @param value the value
  1741. * @param length the length
  1742. * @returns the looped value
  1743. */
  1744. static Repeat(value: number, length: number): number;
  1745. /**
  1746. * Normalize the value between 0.0 and 1.0 using min and max values
  1747. * @param value value to normalize
  1748. * @param min max to normalize between
  1749. * @param max min to normalize between
  1750. * @returns the normalized value
  1751. */
  1752. static Normalize(value: number, min: number, max: number): number;
  1753. /**
  1754. * Denormalize the value from 0.0 and 1.0 using min and max values
  1755. * @param normalized value to denormalize
  1756. * @param min max to denormalize between
  1757. * @param max min to denormalize between
  1758. * @returns the denormalized value
  1759. */
  1760. static Denormalize(normalized: number, min: number, max: number): number;
  1761. /**
  1762. * Calculates the shortest difference between two given angles given in degrees.
  1763. * @param current current angle in degrees
  1764. * @param target target angle in degrees
  1765. * @returns the delta
  1766. */
  1767. static DeltaAngle(current: number, target: number): number;
  1768. /**
  1769. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1770. * @param tx value
  1771. * @param length length
  1772. * @returns The returned value will move back and forth between 0 and length
  1773. */
  1774. static PingPong(tx: number, length: number): number;
  1775. /**
  1776. * Interpolates between min and max with smoothing at the limits.
  1777. *
  1778. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1779. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1780. * @param from from
  1781. * @param to to
  1782. * @param tx value
  1783. * @returns the smooth stepped value
  1784. */
  1785. static SmoothStep(from: number, to: number, tx: number): number;
  1786. /**
  1787. * Moves a value current towards target.
  1788. *
  1789. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1790. * Negative values of maxDelta pushes the value away from target.
  1791. * @param current current value
  1792. * @param target target value
  1793. * @param maxDelta max distance to move
  1794. * @returns resulting value
  1795. */
  1796. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1797. /**
  1798. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1799. *
  1800. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1801. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1802. * @param current current value
  1803. * @param target target value
  1804. * @param maxDelta max distance to move
  1805. * @returns resulting angle
  1806. */
  1807. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1808. /**
  1809. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1810. * @param start start value
  1811. * @param end target value
  1812. * @param amount amount to lerp between
  1813. * @returns the lerped value
  1814. */
  1815. static Lerp(start: number, end: number, amount: number): number;
  1816. /**
  1817. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1818. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1819. * @param start start value
  1820. * @param end target value
  1821. * @param amount amount to lerp between
  1822. * @returns the lerped value
  1823. */
  1824. static LerpAngle(start: number, end: number, amount: number): number;
  1825. /**
  1826. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1827. * @param a start value
  1828. * @param b target value
  1829. * @param value value between a and b
  1830. * @returns the inverseLerp value
  1831. */
  1832. static InverseLerp(a: number, b: number, value: number): number;
  1833. /**
  1834. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1835. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1836. * @param value1 spline value
  1837. * @param tangent1 spline value
  1838. * @param value2 spline value
  1839. * @param tangent2 spline value
  1840. * @param amount input value
  1841. * @returns hermite result
  1842. */
  1843. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1844. /**
  1845. * Returns a random float number between and min and max values
  1846. * @param min min value of random
  1847. * @param max max value of random
  1848. * @returns random value
  1849. */
  1850. static RandomRange(min: number, max: number): number;
  1851. /**
  1852. * This function returns percentage of a number in a given range.
  1853. *
  1854. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1855. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1856. * @param number to convert to percentage
  1857. * @param min min range
  1858. * @param max max range
  1859. * @returns the percentage
  1860. */
  1861. static RangeToPercent(number: number, min: number, max: number): number;
  1862. /**
  1863. * This function returns number that corresponds to the percentage in a given range.
  1864. *
  1865. * PercentToRange(0.34,0,100) will return 34.
  1866. * @param percent to convert to number
  1867. * @param min min range
  1868. * @param max max range
  1869. * @returns the number
  1870. */
  1871. static PercentToRange(percent: number, min: number, max: number): number;
  1872. /**
  1873. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1874. * @param angle The angle to normalize in radian.
  1875. * @return The converted angle.
  1876. */
  1877. static NormalizeRadians(angle: number): number;
  1878. }
  1879. }
  1880. declare module BABYLON {
  1881. /**
  1882. * Constant used to convert a value to gamma space
  1883. * @ignorenaming
  1884. */
  1885. export const ToGammaSpace: number;
  1886. /**
  1887. * Constant used to convert a value to linear space
  1888. * @ignorenaming
  1889. */
  1890. export const ToLinearSpace = 2.2;
  1891. /**
  1892. * Constant used to define the minimal number value in Babylon.js
  1893. * @ignorenaming
  1894. */
  1895. let Epsilon: number;
  1896. }
  1897. declare module BABYLON {
  1898. /**
  1899. * Class used to represent a viewport on screen
  1900. */
  1901. export class Viewport {
  1902. /** viewport left coordinate */
  1903. x: number;
  1904. /** viewport top coordinate */
  1905. y: number;
  1906. /**viewport width */
  1907. width: number;
  1908. /** viewport height */
  1909. height: number;
  1910. /**
  1911. * Creates a Viewport object located at (x, y) and sized (width, height)
  1912. * @param x defines viewport left coordinate
  1913. * @param y defines viewport top coordinate
  1914. * @param width defines the viewport width
  1915. * @param height defines the viewport height
  1916. */
  1917. constructor(
  1918. /** viewport left coordinate */
  1919. x: number,
  1920. /** viewport top coordinate */
  1921. y: number,
  1922. /**viewport width */
  1923. width: number,
  1924. /** viewport height */
  1925. height: number);
  1926. /**
  1927. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1928. * @param renderWidth defines the rendering width
  1929. * @param renderHeight defines the rendering height
  1930. * @returns a new Viewport
  1931. */
  1932. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1933. /**
  1934. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1935. * @param renderWidth defines the rendering width
  1936. * @param renderHeight defines the rendering height
  1937. * @param ref defines the target viewport
  1938. * @returns the current viewport
  1939. */
  1940. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1941. /**
  1942. * Returns a new Viewport copied from the current one
  1943. * @returns a new Viewport
  1944. */
  1945. clone(): Viewport;
  1946. }
  1947. }
  1948. declare module BABYLON {
  1949. /**
  1950. * Class containing a set of static utilities functions for arrays.
  1951. */
  1952. export class ArrayTools {
  1953. /**
  1954. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1955. * @param size the number of element to construct and put in the array
  1956. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1957. * @returns a new array filled with new objects
  1958. */
  1959. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1960. }
  1961. }
  1962. declare module BABYLON {
  1963. /**
  1964. * Represents a plane by the equation ax + by + cz + d = 0
  1965. */
  1966. export class Plane {
  1967. private static _TmpMatrix;
  1968. /**
  1969. * Normal of the plane (a,b,c)
  1970. */
  1971. normal: Vector3;
  1972. /**
  1973. * d component of the plane
  1974. */
  1975. d: number;
  1976. /**
  1977. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1978. * @param a a component of the plane
  1979. * @param b b component of the plane
  1980. * @param c c component of the plane
  1981. * @param d d component of the plane
  1982. */
  1983. constructor(a: number, b: number, c: number, d: number);
  1984. /**
  1985. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1986. */
  1987. asArray(): number[];
  1988. /**
  1989. * @returns a new plane copied from the current Plane.
  1990. */
  1991. clone(): Plane;
  1992. /**
  1993. * @returns the string "Plane".
  1994. */
  1995. getClassName(): string;
  1996. /**
  1997. * @returns the Plane hash code.
  1998. */
  1999. getHashCode(): number;
  2000. /**
  2001. * Normalize the current Plane in place.
  2002. * @returns the updated Plane.
  2003. */
  2004. normalize(): Plane;
  2005. /**
  2006. * Applies a transformation the plane and returns the result
  2007. * @param transformation the transformation matrix to be applied to the plane
  2008. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2009. */
  2010. transform(transformation: DeepImmutable<Matrix>): Plane;
  2011. /**
  2012. * Compute the dot product between the point and the plane normal
  2013. * @param point point to calculate the dot product with
  2014. * @returns the dot product (float) of the point coordinates and the plane normal.
  2015. */
  2016. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2017. /**
  2018. * Updates the current Plane from the plane defined by the three given points.
  2019. * @param point1 one of the points used to contruct the plane
  2020. * @param point2 one of the points used to contruct the plane
  2021. * @param point3 one of the points used to contruct the plane
  2022. * @returns the updated Plane.
  2023. */
  2024. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2025. /**
  2026. * Checks if the plane is facing a given direction
  2027. * @param direction the direction to check if the plane is facing
  2028. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2029. * @returns True is the vector "direction" is the same side than the plane normal.
  2030. */
  2031. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2032. /**
  2033. * Calculates the distance to a point
  2034. * @param point point to calculate distance to
  2035. * @returns the signed distance (float) from the given point to the Plane.
  2036. */
  2037. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2038. /**
  2039. * Creates a plane from an array
  2040. * @param array the array to create a plane from
  2041. * @returns a new Plane from the given array.
  2042. */
  2043. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2044. /**
  2045. * Creates a plane from three points
  2046. * @param point1 point used to create the plane
  2047. * @param point2 point used to create the plane
  2048. * @param point3 point used to create the plane
  2049. * @returns a new Plane defined by the three given points.
  2050. */
  2051. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2052. /**
  2053. * Creates a plane from an origin point and a normal
  2054. * @param origin origin of the plane to be constructed
  2055. * @param normal normal of the plane to be constructed
  2056. * @returns a new Plane the normal vector to this plane at the given origin point.
  2057. * Note : the vector "normal" is updated because normalized.
  2058. */
  2059. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2060. /**
  2061. * Calculates the distance from a plane and a point
  2062. * @param origin origin of the plane to be constructed
  2063. * @param normal normal of the plane to be constructed
  2064. * @param point point to calculate distance to
  2065. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2066. */
  2067. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2068. }
  2069. }
  2070. declare module BABYLON {
  2071. /** @hidden */
  2072. export class PerformanceConfigurator {
  2073. /** @hidden */
  2074. static MatrixUse64Bits: boolean;
  2075. /** @hidden */
  2076. static MatrixTrackPrecisionChange: boolean;
  2077. /** @hidden */
  2078. static MatrixCurrentType: any;
  2079. /** @hidden */
  2080. static MatrixTrackedMatrices: Array<any> | null;
  2081. /** @hidden */
  2082. static SetMatrixPrecision(use64bits: boolean): void;
  2083. }
  2084. }
  2085. declare module BABYLON {
  2086. /**
  2087. * Class representing a vector containing 2 coordinates
  2088. */
  2089. export class Vector2 {
  2090. /** defines the first coordinate */
  2091. x: number;
  2092. /** defines the second coordinate */
  2093. y: number;
  2094. /**
  2095. * Creates a new Vector2 from the given x and y coordinates
  2096. * @param x defines the first coordinate
  2097. * @param y defines the second coordinate
  2098. */
  2099. constructor(
  2100. /** defines the first coordinate */
  2101. x?: number,
  2102. /** defines the second coordinate */
  2103. y?: number);
  2104. /**
  2105. * Gets a string with the Vector2 coordinates
  2106. * @returns a string with the Vector2 coordinates
  2107. */
  2108. toString(): string;
  2109. /**
  2110. * Gets class name
  2111. * @returns the string "Vector2"
  2112. */
  2113. getClassName(): string;
  2114. /**
  2115. * Gets current vector hash code
  2116. * @returns the Vector2 hash code as a number
  2117. */
  2118. getHashCode(): number;
  2119. /**
  2120. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2121. * @param array defines the source array
  2122. * @param index defines the offset in source array
  2123. * @returns the current Vector2
  2124. */
  2125. toArray(array: FloatArray, index?: number): Vector2;
  2126. /**
  2127. * Update the current vector from an array
  2128. * @param array defines the destination array
  2129. * @param index defines the offset in the destination array
  2130. * @returns the current Vector3
  2131. */
  2132. fromArray(array: FloatArray, index?: number): Vector2;
  2133. /**
  2134. * Copy the current vector to an array
  2135. * @returns a new array with 2 elements: the Vector2 coordinates.
  2136. */
  2137. asArray(): number[];
  2138. /**
  2139. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2140. * @param source defines the source Vector2
  2141. * @returns the current updated Vector2
  2142. */
  2143. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2144. /**
  2145. * Sets the Vector2 coordinates with the given floats
  2146. * @param x defines the first coordinate
  2147. * @param y defines the second coordinate
  2148. * @returns the current updated Vector2
  2149. */
  2150. copyFromFloats(x: number, y: number): Vector2;
  2151. /**
  2152. * Sets the Vector2 coordinates with the given floats
  2153. * @param x defines the first coordinate
  2154. * @param y defines the second coordinate
  2155. * @returns the current updated Vector2
  2156. */
  2157. set(x: number, y: number): Vector2;
  2158. /**
  2159. * Add another vector with the current one
  2160. * @param otherVector defines the other vector
  2161. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2162. */
  2163. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2164. /**
  2165. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2166. * @param otherVector defines the other vector
  2167. * @param result defines the target vector
  2168. * @returns the unmodified current Vector2
  2169. */
  2170. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2171. /**
  2172. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2173. * @param otherVector defines the other vector
  2174. * @returns the current updated Vector2
  2175. */
  2176. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2177. /**
  2178. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2179. * @param otherVector defines the other vector
  2180. * @returns a new Vector2
  2181. */
  2182. addVector3(otherVector: Vector3): Vector2;
  2183. /**
  2184. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2185. * @param otherVector defines the other vector
  2186. * @returns a new Vector2
  2187. */
  2188. subtract(otherVector: Vector2): Vector2;
  2189. /**
  2190. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2191. * @param otherVector defines the other vector
  2192. * @param result defines the target vector
  2193. * @returns the unmodified current Vector2
  2194. */
  2195. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2196. /**
  2197. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2198. * @param otherVector defines the other vector
  2199. * @returns the current updated Vector2
  2200. */
  2201. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2202. /**
  2203. * Multiplies in place the current Vector2 coordinates by the given ones
  2204. * @param otherVector defines the other vector
  2205. * @returns the current updated Vector2
  2206. */
  2207. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2208. /**
  2209. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2210. * @param otherVector defines the other vector
  2211. * @returns a new Vector2
  2212. */
  2213. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2214. /**
  2215. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2216. * @param otherVector defines the other vector
  2217. * @param result defines the target vector
  2218. * @returns the unmodified current Vector2
  2219. */
  2220. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2221. /**
  2222. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2223. * @param x defines the first coordinate
  2224. * @param y defines the second coordinate
  2225. * @returns a new Vector2
  2226. */
  2227. multiplyByFloats(x: number, y: number): Vector2;
  2228. /**
  2229. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2230. * @param otherVector defines the other vector
  2231. * @returns a new Vector2
  2232. */
  2233. divide(otherVector: Vector2): Vector2;
  2234. /**
  2235. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2236. * @param otherVector defines the other vector
  2237. * @param result defines the target vector
  2238. * @returns the unmodified current Vector2
  2239. */
  2240. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2241. /**
  2242. * Divides the current Vector2 coordinates by the given ones
  2243. * @param otherVector defines the other vector
  2244. * @returns the current updated Vector2
  2245. */
  2246. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2247. /**
  2248. * Gets a new Vector2 with current Vector2 negated coordinates
  2249. * @returns a new Vector2
  2250. */
  2251. negate(): Vector2;
  2252. /**
  2253. * Negate this vector in place
  2254. * @returns this
  2255. */
  2256. negateInPlace(): Vector2;
  2257. /**
  2258. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2259. * @param result defines the Vector3 object where to store the result
  2260. * @returns the current Vector2
  2261. */
  2262. negateToRef(result: Vector2): Vector2;
  2263. /**
  2264. * Multiply the Vector2 coordinates by scale
  2265. * @param scale defines the scaling factor
  2266. * @returns the current updated Vector2
  2267. */
  2268. scaleInPlace(scale: number): Vector2;
  2269. /**
  2270. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2271. * @param scale defines the scaling factor
  2272. * @returns a new Vector2
  2273. */
  2274. scale(scale: number): Vector2;
  2275. /**
  2276. * Scale the current Vector2 values by a factor to a given Vector2
  2277. * @param scale defines the scale factor
  2278. * @param result defines the Vector2 object where to store the result
  2279. * @returns the unmodified current Vector2
  2280. */
  2281. scaleToRef(scale: number, result: Vector2): Vector2;
  2282. /**
  2283. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2284. * @param scale defines the scale factor
  2285. * @param result defines the Vector2 object where to store the result
  2286. * @returns the unmodified current Vector2
  2287. */
  2288. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2289. /**
  2290. * Gets a boolean if two vectors are equals
  2291. * @param otherVector defines the other vector
  2292. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2293. */
  2294. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2295. /**
  2296. * Gets a boolean if two vectors are equals (using an epsilon value)
  2297. * @param otherVector defines the other vector
  2298. * @param epsilon defines the minimal distance to consider equality
  2299. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2300. */
  2301. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2302. /**
  2303. * Gets a new Vector2 from current Vector2 floored values
  2304. * @returns a new Vector2
  2305. */
  2306. floor(): Vector2;
  2307. /**
  2308. * Gets a new Vector2 from current Vector2 floored values
  2309. * @returns a new Vector2
  2310. */
  2311. fract(): Vector2;
  2312. /**
  2313. * Gets the length of the vector
  2314. * @returns the vector length (float)
  2315. */
  2316. length(): number;
  2317. /**
  2318. * Gets the vector squared length
  2319. * @returns the vector squared length (float)
  2320. */
  2321. lengthSquared(): number;
  2322. /**
  2323. * Normalize the vector
  2324. * @returns the current updated Vector2
  2325. */
  2326. normalize(): Vector2;
  2327. /**
  2328. * Gets a new Vector2 copied from the Vector2
  2329. * @returns a new Vector2
  2330. */
  2331. clone(): Vector2;
  2332. /**
  2333. * Gets a new Vector2(0, 0)
  2334. * @returns a new Vector2
  2335. */
  2336. static Zero(): Vector2;
  2337. /**
  2338. * Gets a new Vector2(1, 1)
  2339. * @returns a new Vector2
  2340. */
  2341. static One(): Vector2;
  2342. /**
  2343. * Gets a new Vector2 set from the given index element of the given array
  2344. * @param array defines the data source
  2345. * @param offset defines the offset in the data source
  2346. * @returns a new Vector2
  2347. */
  2348. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2349. /**
  2350. * Sets "result" from the given index element of the given array
  2351. * @param array defines the data source
  2352. * @param offset defines the offset in the data source
  2353. * @param result defines the target vector
  2354. */
  2355. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2356. /**
  2357. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2358. * @param value1 defines 1st point of control
  2359. * @param value2 defines 2nd point of control
  2360. * @param value3 defines 3rd point of control
  2361. * @param value4 defines 4th point of control
  2362. * @param amount defines the interpolation factor
  2363. * @returns a new Vector2
  2364. */
  2365. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2366. /**
  2367. * 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".
  2368. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2369. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2370. * @param value defines the value to clamp
  2371. * @param min defines the lower limit
  2372. * @param max defines the upper limit
  2373. * @returns a new Vector2
  2374. */
  2375. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2376. /**
  2377. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2378. * @param value1 defines the 1st control point
  2379. * @param tangent1 defines the outgoing tangent
  2380. * @param value2 defines the 2nd control point
  2381. * @param tangent2 defines the incoming tangent
  2382. * @param amount defines the interpolation factor
  2383. * @returns a new Vector2
  2384. */
  2385. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2386. /**
  2387. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2388. * @param start defines the start vector
  2389. * @param end defines the end vector
  2390. * @param amount defines the interpolation factor
  2391. * @returns a new Vector2
  2392. */
  2393. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2394. /**
  2395. * Gets the dot product of the vector "left" and the vector "right"
  2396. * @param left defines first vector
  2397. * @param right defines second vector
  2398. * @returns the dot product (float)
  2399. */
  2400. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2401. /**
  2402. * Returns a new Vector2 equal to the normalized given vector
  2403. * @param vector defines the vector to normalize
  2404. * @returns a new Vector2
  2405. */
  2406. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2407. /**
  2408. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2409. * @param left defines 1st vector
  2410. * @param right defines 2nd vector
  2411. * @returns a new Vector2
  2412. */
  2413. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2414. /**
  2415. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2416. * @param left defines 1st vector
  2417. * @param right defines 2nd vector
  2418. * @returns a new Vector2
  2419. */
  2420. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2421. /**
  2422. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2423. * @param vector defines the vector to transform
  2424. * @param transformation defines the matrix to apply
  2425. * @returns a new Vector2
  2426. */
  2427. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2428. /**
  2429. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2430. * @param vector defines the vector to transform
  2431. * @param transformation defines the matrix to apply
  2432. * @param result defines the target vector
  2433. */
  2434. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2435. /**
  2436. * Determines if a given vector is included in a triangle
  2437. * @param p defines the vector to test
  2438. * @param p0 defines 1st triangle point
  2439. * @param p1 defines 2nd triangle point
  2440. * @param p2 defines 3rd triangle point
  2441. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2442. */
  2443. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2444. /**
  2445. * Gets the distance between the vectors "value1" and "value2"
  2446. * @param value1 defines first vector
  2447. * @param value2 defines second vector
  2448. * @returns the distance between vectors
  2449. */
  2450. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2451. /**
  2452. * Returns the squared distance between the vectors "value1" and "value2"
  2453. * @param value1 defines first vector
  2454. * @param value2 defines second vector
  2455. * @returns the squared distance between vectors
  2456. */
  2457. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2458. /**
  2459. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2460. * @param value1 defines first vector
  2461. * @param value2 defines second vector
  2462. * @returns a new Vector2
  2463. */
  2464. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2465. /**
  2466. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2467. * @param p defines the middle point
  2468. * @param segA defines one point of the segment
  2469. * @param segB defines the other point of the segment
  2470. * @returns the shortest distance
  2471. */
  2472. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2473. }
  2474. /**
  2475. * Class used to store (x,y,z) vector representation
  2476. * A Vector3 is the main object used in 3D geometry
  2477. * It can represent etiher the coordinates of a point the space, either a direction
  2478. * Reminder: js uses a left handed forward facing system
  2479. */
  2480. export class Vector3 {
  2481. private static _UpReadOnly;
  2482. private static _ZeroReadOnly;
  2483. /** @hidden */
  2484. _x: number;
  2485. /** @hidden */
  2486. _y: number;
  2487. /** @hidden */
  2488. _z: number;
  2489. /** @hidden */
  2490. _isDirty: boolean;
  2491. /** Gets or sets the x coordinate */
  2492. get x(): number;
  2493. set x(value: number);
  2494. /** Gets or sets the y coordinate */
  2495. get y(): number;
  2496. set y(value: number);
  2497. /** Gets or sets the z coordinate */
  2498. get z(): number;
  2499. set z(value: number);
  2500. /**
  2501. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2502. * @param x defines the first coordinates (on X axis)
  2503. * @param y defines the second coordinates (on Y axis)
  2504. * @param z defines the third coordinates (on Z axis)
  2505. */
  2506. constructor(x?: number, y?: number, z?: number);
  2507. /**
  2508. * Creates a string representation of the Vector3
  2509. * @returns a string with the Vector3 coordinates.
  2510. */
  2511. toString(): string;
  2512. /**
  2513. * Gets the class name
  2514. * @returns the string "Vector3"
  2515. */
  2516. getClassName(): string;
  2517. /**
  2518. * Creates the Vector3 hash code
  2519. * @returns a number which tends to be unique between Vector3 instances
  2520. */
  2521. getHashCode(): number;
  2522. /**
  2523. * Creates an array containing three elements : the coordinates of the Vector3
  2524. * @returns a new array of numbers
  2525. */
  2526. asArray(): number[];
  2527. /**
  2528. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2529. * @param array defines the destination array
  2530. * @param index defines the offset in the destination array
  2531. * @returns the current Vector3
  2532. */
  2533. toArray(array: FloatArray, index?: number): Vector3;
  2534. /**
  2535. * Update the current vector from an array
  2536. * @param array defines the destination array
  2537. * @param index defines the offset in the destination array
  2538. * @returns the current Vector3
  2539. */
  2540. fromArray(array: FloatArray, index?: number): Vector3;
  2541. /**
  2542. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2543. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2544. */
  2545. toQuaternion(): Quaternion;
  2546. /**
  2547. * Adds the given vector to the current Vector3
  2548. * @param otherVector defines the second operand
  2549. * @returns the current updated Vector3
  2550. */
  2551. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2552. /**
  2553. * Adds the given coordinates to the current Vector3
  2554. * @param x defines the x coordinate of the operand
  2555. * @param y defines the y coordinate of the operand
  2556. * @param z defines the z coordinate of the operand
  2557. * @returns the current updated Vector3
  2558. */
  2559. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2560. /**
  2561. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2562. * @param otherVector defines the second operand
  2563. * @returns the resulting Vector3
  2564. */
  2565. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2566. /**
  2567. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2568. * @param otherVector defines the second operand
  2569. * @param result defines the Vector3 object where to store the result
  2570. * @returns the current Vector3
  2571. */
  2572. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2573. /**
  2574. * Subtract the given vector from the current Vector3
  2575. * @param otherVector defines the second operand
  2576. * @returns the current updated Vector3
  2577. */
  2578. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2579. /**
  2580. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2581. * @param otherVector defines the second operand
  2582. * @returns the resulting Vector3
  2583. */
  2584. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2585. /**
  2586. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2587. * @param otherVector defines the second operand
  2588. * @param result defines the Vector3 object where to store the result
  2589. * @returns the current Vector3
  2590. */
  2591. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2592. /**
  2593. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2594. * @param x defines the x coordinate of the operand
  2595. * @param y defines the y coordinate of the operand
  2596. * @param z defines the z coordinate of the operand
  2597. * @returns the resulting Vector3
  2598. */
  2599. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2600. /**
  2601. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2602. * @param x defines the x coordinate of the operand
  2603. * @param y defines the y coordinate of the operand
  2604. * @param z defines the z coordinate of the operand
  2605. * @param result defines the Vector3 object where to store the result
  2606. * @returns the current Vector3
  2607. */
  2608. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2609. /**
  2610. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2611. * @returns a new Vector3
  2612. */
  2613. negate(): Vector3;
  2614. /**
  2615. * Negate this vector in place
  2616. * @returns this
  2617. */
  2618. negateInPlace(): Vector3;
  2619. /**
  2620. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2621. * @param result defines the Vector3 object where to store the result
  2622. * @returns the current Vector3
  2623. */
  2624. negateToRef(result: Vector3): Vector3;
  2625. /**
  2626. * Multiplies the Vector3 coordinates by the float "scale"
  2627. * @param scale defines the multiplier factor
  2628. * @returns the current updated Vector3
  2629. */
  2630. scaleInPlace(scale: number): Vector3;
  2631. /**
  2632. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2633. * @param scale defines the multiplier factor
  2634. * @returns a new Vector3
  2635. */
  2636. scale(scale: number): Vector3;
  2637. /**
  2638. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2639. * @param scale defines the multiplier factor
  2640. * @param result defines the Vector3 object where to store the result
  2641. * @returns the current Vector3
  2642. */
  2643. scaleToRef(scale: number, result: Vector3): Vector3;
  2644. /**
  2645. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2646. * @param scale defines the scale factor
  2647. * @param result defines the Vector3 object where to store the result
  2648. * @returns the unmodified current Vector3
  2649. */
  2650. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2651. /**
  2652. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2653. * @param origin defines the origin of the projection ray
  2654. * @param plane defines the plane to project to
  2655. * @returns the projected vector3
  2656. */
  2657. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2658. /**
  2659. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2660. * @param origin defines the origin of the projection ray
  2661. * @param plane defines the plane to project to
  2662. * @param result defines the Vector3 where to store the result
  2663. */
  2664. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2665. /**
  2666. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2667. * @param otherVector defines the second operand
  2668. * @returns true if both vectors are equals
  2669. */
  2670. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2671. /**
  2672. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2673. * @param otherVector defines the second operand
  2674. * @param epsilon defines the minimal distance to define values as equals
  2675. * @returns true if both vectors are distant less than epsilon
  2676. */
  2677. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2678. /**
  2679. * Returns true if the current Vector3 coordinates equals the given floats
  2680. * @param x defines the x coordinate of the operand
  2681. * @param y defines the y coordinate of the operand
  2682. * @param z defines the z coordinate of the operand
  2683. * @returns true if both vectors are equals
  2684. */
  2685. equalsToFloats(x: number, y: number, z: number): boolean;
  2686. /**
  2687. * Multiplies the current Vector3 coordinates by the given ones
  2688. * @param otherVector defines the second operand
  2689. * @returns the current updated Vector3
  2690. */
  2691. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2692. /**
  2693. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2694. * @param otherVector defines the second operand
  2695. * @returns the new Vector3
  2696. */
  2697. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2698. /**
  2699. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2700. * @param otherVector defines the second operand
  2701. * @param result defines the Vector3 object where to store the result
  2702. * @returns the current Vector3
  2703. */
  2704. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2705. /**
  2706. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2707. * @param x defines the x coordinate of the operand
  2708. * @param y defines the y coordinate of the operand
  2709. * @param z defines the z coordinate of the operand
  2710. * @returns the new Vector3
  2711. */
  2712. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2713. /**
  2714. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2715. * @param otherVector defines the second operand
  2716. * @returns the new Vector3
  2717. */
  2718. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2719. /**
  2720. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2721. * @param otherVector defines the second operand
  2722. * @param result defines the Vector3 object where to store the result
  2723. * @returns the current Vector3
  2724. */
  2725. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2726. /**
  2727. * Divides the current Vector3 coordinates by the given ones.
  2728. * @param otherVector defines the second operand
  2729. * @returns the current updated Vector3
  2730. */
  2731. divideInPlace(otherVector: Vector3): Vector3;
  2732. /**
  2733. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2734. * @param other defines the second operand
  2735. * @returns the current updated Vector3
  2736. */
  2737. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2738. /**
  2739. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2740. * @param other defines the second operand
  2741. * @returns the current updated Vector3
  2742. */
  2743. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2744. /**
  2745. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2746. * @param x defines the x coordinate of the operand
  2747. * @param y defines the y coordinate of the operand
  2748. * @param z defines the z coordinate of the operand
  2749. * @returns the current updated Vector3
  2750. */
  2751. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2752. /**
  2753. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2754. * @param x defines the x coordinate of the operand
  2755. * @param y defines the y coordinate of the operand
  2756. * @param z defines the z coordinate of the operand
  2757. * @returns the current updated Vector3
  2758. */
  2759. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2760. /**
  2761. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2762. * Check if is non uniform within a certain amount of decimal places to account for this
  2763. * @param epsilon the amount the values can differ
  2764. * @returns if the the vector is non uniform to a certain number of decimal places
  2765. */
  2766. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2767. /**
  2768. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2769. */
  2770. get isNonUniform(): boolean;
  2771. /**
  2772. * Gets a new Vector3 from current Vector3 floored values
  2773. * @returns a new Vector3
  2774. */
  2775. floor(): Vector3;
  2776. /**
  2777. * Gets a new Vector3 from current Vector3 floored values
  2778. * @returns a new Vector3
  2779. */
  2780. fract(): Vector3;
  2781. /**
  2782. * Gets the length of the Vector3
  2783. * @returns the length of the Vector3
  2784. */
  2785. length(): number;
  2786. /**
  2787. * Gets the squared length of the Vector3
  2788. * @returns squared length of the Vector3
  2789. */
  2790. lengthSquared(): number;
  2791. /**
  2792. * Normalize the current Vector3.
  2793. * Please note that this is an in place operation.
  2794. * @returns the current updated Vector3
  2795. */
  2796. normalize(): Vector3;
  2797. /**
  2798. * Reorders the x y z properties of the vector in place
  2799. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2800. * @returns the current updated vector
  2801. */
  2802. reorderInPlace(order: string): this;
  2803. /**
  2804. * Rotates the vector around 0,0,0 by a quaternion
  2805. * @param quaternion the rotation quaternion
  2806. * @param result vector to store the result
  2807. * @returns the resulting vector
  2808. */
  2809. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2810. /**
  2811. * Rotates a vector around a given point
  2812. * @param quaternion the rotation quaternion
  2813. * @param point the point to rotate around
  2814. * @param result vector to store the result
  2815. * @returns the resulting vector
  2816. */
  2817. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2818. /**
  2819. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2820. * The cross product is then orthogonal to both current and "other"
  2821. * @param other defines the right operand
  2822. * @returns the cross product
  2823. */
  2824. cross(other: Vector3): Vector3;
  2825. /**
  2826. * Normalize the current Vector3 with the given input length.
  2827. * Please note that this is an in place operation.
  2828. * @param len the length of the vector
  2829. * @returns the current updated Vector3
  2830. */
  2831. normalizeFromLength(len: number): Vector3;
  2832. /**
  2833. * Normalize the current Vector3 to a new vector
  2834. * @returns the new Vector3
  2835. */
  2836. normalizeToNew(): Vector3;
  2837. /**
  2838. * Normalize the current Vector3 to the reference
  2839. * @param reference define the Vector3 to update
  2840. * @returns the updated Vector3
  2841. */
  2842. normalizeToRef(reference: Vector3): Vector3;
  2843. /**
  2844. * Creates a new Vector3 copied from the current Vector3
  2845. * @returns the new Vector3
  2846. */
  2847. clone(): Vector3;
  2848. /**
  2849. * Copies the given vector coordinates to the current Vector3 ones
  2850. * @param source defines the source Vector3
  2851. * @returns the current updated Vector3
  2852. */
  2853. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2854. /**
  2855. * Copies the given floats to the current Vector3 coordinates
  2856. * @param x defines the x coordinate of the operand
  2857. * @param y defines the y coordinate of the operand
  2858. * @param z defines the z coordinate of the operand
  2859. * @returns the current updated Vector3
  2860. */
  2861. copyFromFloats(x: number, y: number, z: number): Vector3;
  2862. /**
  2863. * Copies the given floats to the current Vector3 coordinates
  2864. * @param x defines the x coordinate of the operand
  2865. * @param y defines the y coordinate of the operand
  2866. * @param z defines the z coordinate of the operand
  2867. * @returns the current updated Vector3
  2868. */
  2869. set(x: number, y: number, z: number): Vector3;
  2870. /**
  2871. * Copies the given float to the current Vector3 coordinates
  2872. * @param v defines the x, y and z coordinates of the operand
  2873. * @returns the current updated Vector3
  2874. */
  2875. setAll(v: number): Vector3;
  2876. /**
  2877. * Get the clip factor between two vectors
  2878. * @param vector0 defines the first operand
  2879. * @param vector1 defines the second operand
  2880. * @param axis defines the axis to use
  2881. * @param size defines the size along the axis
  2882. * @returns the clip factor
  2883. */
  2884. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2885. /**
  2886. * Get angle between two vectors
  2887. * @param vector0 angle between vector0 and vector1
  2888. * @param vector1 angle between vector0 and vector1
  2889. * @param normal direction of the normal
  2890. * @return the angle between vector0 and vector1
  2891. */
  2892. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2893. /**
  2894. * Returns a new Vector3 set from the index "offset" of the given array
  2895. * @param array defines the source array
  2896. * @param offset defines the offset in the source array
  2897. * @returns the new Vector3
  2898. */
  2899. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2900. /**
  2901. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2902. * @param array defines the source array
  2903. * @param offset defines the offset in the source array
  2904. * @returns the new Vector3
  2905. * @deprecated Please use FromArray instead.
  2906. */
  2907. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2908. /**
  2909. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2910. * @param array defines the source array
  2911. * @param offset defines the offset in the source array
  2912. * @param result defines the Vector3 where to store the result
  2913. */
  2914. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2915. /**
  2916. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2917. * @param array defines the source array
  2918. * @param offset defines the offset in the source array
  2919. * @param result defines the Vector3 where to store the result
  2920. * @deprecated Please use FromArrayToRef instead.
  2921. */
  2922. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2923. /**
  2924. * Sets the given vector "result" with the given floats.
  2925. * @param x defines the x coordinate of the source
  2926. * @param y defines the y coordinate of the source
  2927. * @param z defines the z coordinate of the source
  2928. * @param result defines the Vector3 where to store the result
  2929. */
  2930. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2931. /**
  2932. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2933. * @returns a new empty Vector3
  2934. */
  2935. static Zero(): Vector3;
  2936. /**
  2937. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2938. * @returns a new unit Vector3
  2939. */
  2940. static One(): Vector3;
  2941. /**
  2942. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2943. * @returns a new up Vector3
  2944. */
  2945. static Up(): Vector3;
  2946. /**
  2947. * Gets a up Vector3 that must not be updated
  2948. */
  2949. static get UpReadOnly(): DeepImmutable<Vector3>;
  2950. /**
  2951. * Gets a zero Vector3 that must not be updated
  2952. */
  2953. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2954. /**
  2955. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2956. * @returns a new down Vector3
  2957. */
  2958. static Down(): Vector3;
  2959. /**
  2960. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2961. * @param rightHandedSystem is the scene right-handed (negative z)
  2962. * @returns a new forward Vector3
  2963. */
  2964. static Forward(rightHandedSystem?: boolean): Vector3;
  2965. /**
  2966. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2967. * @param rightHandedSystem is the scene right-handed (negative-z)
  2968. * @returns a new forward Vector3
  2969. */
  2970. static Backward(rightHandedSystem?: boolean): Vector3;
  2971. /**
  2972. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2973. * @returns a new right Vector3
  2974. */
  2975. static Right(): Vector3;
  2976. /**
  2977. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2978. * @returns a new left Vector3
  2979. */
  2980. static Left(): Vector3;
  2981. /**
  2982. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2983. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2984. * @param vector defines the Vector3 to transform
  2985. * @param transformation defines the transformation matrix
  2986. * @returns the transformed Vector3
  2987. */
  2988. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2989. /**
  2990. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2991. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2992. * @param vector defines the Vector3 to transform
  2993. * @param transformation defines the transformation matrix
  2994. * @param result defines the Vector3 where to store the result
  2995. */
  2996. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2997. /**
  2998. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2999. * This method computes tranformed coordinates only, not transformed direction vectors
  3000. * @param x define the x coordinate of the source vector
  3001. * @param y define the y coordinate of the source vector
  3002. * @param z define the z coordinate of the source vector
  3003. * @param transformation defines the transformation matrix
  3004. * @param result defines the Vector3 where to store the result
  3005. */
  3006. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3007. /**
  3008. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3009. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3010. * @param vector defines the Vector3 to transform
  3011. * @param transformation defines the transformation matrix
  3012. * @returns the new Vector3
  3013. */
  3014. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3015. /**
  3016. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3017. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3018. * @param vector defines the Vector3 to transform
  3019. * @param transformation defines the transformation matrix
  3020. * @param result defines the Vector3 where to store the result
  3021. */
  3022. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3023. /**
  3024. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3025. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3026. * @param x define the x coordinate of the source vector
  3027. * @param y define the y coordinate of the source vector
  3028. * @param z define the z coordinate of the source vector
  3029. * @param transformation defines the transformation matrix
  3030. * @param result defines the Vector3 where to store the result
  3031. */
  3032. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3033. /**
  3034. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3035. * @param value1 defines the first control point
  3036. * @param value2 defines the second control point
  3037. * @param value3 defines the third control point
  3038. * @param value4 defines the fourth control point
  3039. * @param amount defines the amount on the spline to use
  3040. * @returns the new Vector3
  3041. */
  3042. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3043. /**
  3044. * 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"
  3045. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3046. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3047. * @param value defines the current value
  3048. * @param min defines the lower range value
  3049. * @param max defines the upper range value
  3050. * @returns the new Vector3
  3051. */
  3052. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3053. /**
  3054. * 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"
  3055. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3056. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3057. * @param value defines the current value
  3058. * @param min defines the lower range value
  3059. * @param max defines the upper range value
  3060. * @param result defines the Vector3 where to store the result
  3061. */
  3062. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3063. /**
  3064. * Checks if a given vector is inside a specific range
  3065. * @param v defines the vector to test
  3066. * @param min defines the minimum range
  3067. * @param max defines the maximum range
  3068. */
  3069. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3070. /**
  3071. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3072. * @param value1 defines the first control point
  3073. * @param tangent1 defines the first tangent vector
  3074. * @param value2 defines the second control point
  3075. * @param tangent2 defines the second tangent vector
  3076. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3077. * @returns the new Vector3
  3078. */
  3079. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3080. /**
  3081. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3082. * @param start defines the start value
  3083. * @param end defines the end value
  3084. * @param amount max defines amount between both (between 0 and 1)
  3085. * @returns the new Vector3
  3086. */
  3087. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3088. /**
  3089. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3090. * @param start defines the start value
  3091. * @param end defines the end value
  3092. * @param amount max defines amount between both (between 0 and 1)
  3093. * @param result defines the Vector3 where to store the result
  3094. */
  3095. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3096. /**
  3097. * Returns the dot product (float) between the vectors "left" and "right"
  3098. * @param left defines the left operand
  3099. * @param right defines the right operand
  3100. * @returns the dot product
  3101. */
  3102. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3103. /**
  3104. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3105. * The cross product is then orthogonal to both "left" and "right"
  3106. * @param left defines the left operand
  3107. * @param right defines the right operand
  3108. * @returns the cross product
  3109. */
  3110. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3111. /**
  3112. * Sets the given vector "result" with the cross product of "left" and "right"
  3113. * The cross product is then orthogonal to both "left" and "right"
  3114. * @param left defines the left operand
  3115. * @param right defines the right operand
  3116. * @param result defines the Vector3 where to store the result
  3117. */
  3118. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3119. /**
  3120. * Returns a new Vector3 as the normalization of the given vector
  3121. * @param vector defines the Vector3 to normalize
  3122. * @returns the new Vector3
  3123. */
  3124. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3125. /**
  3126. * Sets the given vector "result" with the normalization of the given first vector
  3127. * @param vector defines the Vector3 to normalize
  3128. * @param result defines the Vector3 where to store the result
  3129. */
  3130. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3131. /**
  3132. * Project a Vector3 onto screen space
  3133. * @param vector defines the Vector3 to project
  3134. * @param world defines the world matrix to use
  3135. * @param transform defines the transform (view x projection) matrix to use
  3136. * @param viewport defines the screen viewport to use
  3137. * @returns the new Vector3
  3138. */
  3139. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3140. /**
  3141. * Project a Vector3 onto screen space to reference
  3142. * @param vector defines the Vector3 to project
  3143. * @param world defines the world matrix to use
  3144. * @param transform defines the transform (view x projection) matrix to use
  3145. * @param viewport defines the screen viewport to use
  3146. * @param result the vector in which the screen space will be stored
  3147. * @returns the new Vector3
  3148. */
  3149. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  3150. /** @hidden */
  3151. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3152. /**
  3153. * Unproject from screen space to object space
  3154. * @param source defines the screen space Vector3 to use
  3155. * @param viewportWidth defines the current width of the viewport
  3156. * @param viewportHeight defines the current height of the viewport
  3157. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3158. * @param transform defines the transform (view x projection) matrix to use
  3159. * @returns the new Vector3
  3160. */
  3161. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3162. /**
  3163. * Unproject from screen space to object space
  3164. * @param source defines the screen space Vector3 to use
  3165. * @param viewportWidth defines the current width of the viewport
  3166. * @param viewportHeight defines the current height of the viewport
  3167. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3168. * @param view defines the view matrix to use
  3169. * @param projection defines the projection matrix to use
  3170. * @returns the new Vector3
  3171. */
  3172. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3173. /**
  3174. * Unproject from screen space to object space
  3175. * @param source defines the screen space Vector3 to use
  3176. * @param viewportWidth defines the current width of the viewport
  3177. * @param viewportHeight defines the current height of the viewport
  3178. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3179. * @param view defines the view matrix to use
  3180. * @param projection defines the projection matrix to use
  3181. * @param result defines the Vector3 where to store the result
  3182. */
  3183. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3184. /**
  3185. * Unproject from screen space to object space
  3186. * @param sourceX defines the screen space x coordinate to use
  3187. * @param sourceY defines the screen space y coordinate to use
  3188. * @param sourceZ defines the screen space z coordinate to use
  3189. * @param viewportWidth defines the current width of the viewport
  3190. * @param viewportHeight defines the current height of the viewport
  3191. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3192. * @param view defines the view matrix to use
  3193. * @param projection defines the projection matrix to use
  3194. * @param result defines the Vector3 where to store the result
  3195. */
  3196. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3197. /**
  3198. * Gets the minimal coordinate values between two Vector3
  3199. * @param left defines the first operand
  3200. * @param right defines the second operand
  3201. * @returns the new Vector3
  3202. */
  3203. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3204. /**
  3205. * Gets the maximal coordinate values between two Vector3
  3206. * @param left defines the first operand
  3207. * @param right defines the second operand
  3208. * @returns the new Vector3
  3209. */
  3210. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3211. /**
  3212. * Returns the distance between the vectors "value1" and "value2"
  3213. * @param value1 defines the first operand
  3214. * @param value2 defines the second operand
  3215. * @returns the distance
  3216. */
  3217. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3218. /**
  3219. * Returns the squared distance between the vectors "value1" and "value2"
  3220. * @param value1 defines the first operand
  3221. * @param value2 defines the second operand
  3222. * @returns the squared distance
  3223. */
  3224. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3225. /**
  3226. * Returns a new Vector3 located at the center between "value1" and "value2"
  3227. * @param value1 defines the first operand
  3228. * @param value2 defines the second operand
  3229. * @returns the new Vector3
  3230. */
  3231. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3232. /**
  3233. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3234. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3235. * to something in order to rotate it from its local system to the given target system
  3236. * Note: axis1, axis2 and axis3 are normalized during this operation
  3237. * @param axis1 defines the first axis
  3238. * @param axis2 defines the second axis
  3239. * @param axis3 defines the third axis
  3240. * @returns a new Vector3
  3241. */
  3242. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3243. /**
  3244. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3245. * @param axis1 defines the first axis
  3246. * @param axis2 defines the second axis
  3247. * @param axis3 defines the third axis
  3248. * @param ref defines the Vector3 where to store the result
  3249. */
  3250. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3251. }
  3252. /**
  3253. * Vector4 class created for EulerAngle class conversion to Quaternion
  3254. */
  3255. export class Vector4 {
  3256. /** x value of the vector */
  3257. x: number;
  3258. /** y value of the vector */
  3259. y: number;
  3260. /** z value of the vector */
  3261. z: number;
  3262. /** w value of the vector */
  3263. w: number;
  3264. /**
  3265. * Creates a Vector4 object from the given floats.
  3266. * @param x x value of the vector
  3267. * @param y y value of the vector
  3268. * @param z z value of the vector
  3269. * @param w w value of the vector
  3270. */
  3271. constructor(
  3272. /** x value of the vector */
  3273. x: number,
  3274. /** y value of the vector */
  3275. y: number,
  3276. /** z value of the vector */
  3277. z: number,
  3278. /** w value of the vector */
  3279. w: number);
  3280. /**
  3281. * Returns the string with the Vector4 coordinates.
  3282. * @returns a string containing all the vector values
  3283. */
  3284. toString(): string;
  3285. /**
  3286. * Returns the string "Vector4".
  3287. * @returns "Vector4"
  3288. */
  3289. getClassName(): string;
  3290. /**
  3291. * Returns the Vector4 hash code.
  3292. * @returns a unique hash code
  3293. */
  3294. getHashCode(): number;
  3295. /**
  3296. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3297. * @returns the resulting array
  3298. */
  3299. asArray(): number[];
  3300. /**
  3301. * Populates the given array from the given index with the Vector4 coordinates.
  3302. * @param array array to populate
  3303. * @param index index of the array to start at (default: 0)
  3304. * @returns the Vector4.
  3305. */
  3306. toArray(array: FloatArray, index?: number): Vector4;
  3307. /**
  3308. * Update the current vector from an array
  3309. * @param array defines the destination array
  3310. * @param index defines the offset in the destination array
  3311. * @returns the current Vector3
  3312. */
  3313. fromArray(array: FloatArray, index?: number): Vector4;
  3314. /**
  3315. * Adds the given vector to the current Vector4.
  3316. * @param otherVector the vector to add
  3317. * @returns the updated Vector4.
  3318. */
  3319. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3320. /**
  3321. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3322. * @param otherVector the vector to add
  3323. * @returns the resulting vector
  3324. */
  3325. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3326. /**
  3327. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3328. * @param otherVector the vector to add
  3329. * @param result the vector to store the result
  3330. * @returns the current Vector4.
  3331. */
  3332. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3333. /**
  3334. * Subtract in place the given vector from the current Vector4.
  3335. * @param otherVector the vector to subtract
  3336. * @returns the updated Vector4.
  3337. */
  3338. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3339. /**
  3340. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3341. * @param otherVector the vector to add
  3342. * @returns the new vector with the result
  3343. */
  3344. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3345. /**
  3346. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3347. * @param otherVector the vector to subtract
  3348. * @param result the vector to store the result
  3349. * @returns the current Vector4.
  3350. */
  3351. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3352. /**
  3353. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3354. */
  3355. /**
  3356. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3357. * @param x value to subtract
  3358. * @param y value to subtract
  3359. * @param z value to subtract
  3360. * @param w value to subtract
  3361. * @returns new vector containing the result
  3362. */
  3363. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3364. /**
  3365. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3366. * @param x value to subtract
  3367. * @param y value to subtract
  3368. * @param z value to subtract
  3369. * @param w value to subtract
  3370. * @param result the vector to store the result in
  3371. * @returns the current Vector4.
  3372. */
  3373. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3374. /**
  3375. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3376. * @returns a new vector with the negated values
  3377. */
  3378. negate(): Vector4;
  3379. /**
  3380. * Negate this vector in place
  3381. * @returns this
  3382. */
  3383. negateInPlace(): Vector4;
  3384. /**
  3385. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3386. * @param result defines the Vector3 object where to store the result
  3387. * @returns the current Vector4
  3388. */
  3389. negateToRef(result: Vector4): Vector4;
  3390. /**
  3391. * Multiplies the current Vector4 coordinates by scale (float).
  3392. * @param scale the number to scale with
  3393. * @returns the updated Vector4.
  3394. */
  3395. scaleInPlace(scale: number): Vector4;
  3396. /**
  3397. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3398. * @param scale the number to scale with
  3399. * @returns a new vector with the result
  3400. */
  3401. scale(scale: number): Vector4;
  3402. /**
  3403. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3404. * @param scale the number to scale with
  3405. * @param result a vector to store the result in
  3406. * @returns the current Vector4.
  3407. */
  3408. scaleToRef(scale: number, result: Vector4): Vector4;
  3409. /**
  3410. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3411. * @param scale defines the scale factor
  3412. * @param result defines the Vector4 object where to store the result
  3413. * @returns the unmodified current Vector4
  3414. */
  3415. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3416. /**
  3417. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3418. * @param otherVector the vector to compare against
  3419. * @returns true if they are equal
  3420. */
  3421. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3422. /**
  3423. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3424. * @param otherVector vector to compare against
  3425. * @param epsilon (Default: very small number)
  3426. * @returns true if they are equal
  3427. */
  3428. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3429. /**
  3430. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3431. * @param x x value to compare against
  3432. * @param y y value to compare against
  3433. * @param z z value to compare against
  3434. * @param w w value to compare against
  3435. * @returns true if equal
  3436. */
  3437. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3438. /**
  3439. * Multiplies in place the current Vector4 by the given one.
  3440. * @param otherVector vector to multiple with
  3441. * @returns the updated Vector4.
  3442. */
  3443. multiplyInPlace(otherVector: Vector4): Vector4;
  3444. /**
  3445. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3446. * @param otherVector vector to multiple with
  3447. * @returns resulting new vector
  3448. */
  3449. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3450. /**
  3451. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3452. * @param otherVector vector to multiple with
  3453. * @param result vector to store the result
  3454. * @returns the current Vector4.
  3455. */
  3456. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3457. /**
  3458. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3459. * @param x x value multiply with
  3460. * @param y y value multiply with
  3461. * @param z z value multiply with
  3462. * @param w w value multiply with
  3463. * @returns resulting new vector
  3464. */
  3465. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3466. /**
  3467. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3468. * @param otherVector vector to devide with
  3469. * @returns resulting new vector
  3470. */
  3471. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3472. /**
  3473. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3474. * @param otherVector vector to devide with
  3475. * @param result vector to store the result
  3476. * @returns the current Vector4.
  3477. */
  3478. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3479. /**
  3480. * Divides the current Vector3 coordinates by the given ones.
  3481. * @param otherVector vector to devide with
  3482. * @returns the updated Vector3.
  3483. */
  3484. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3485. /**
  3486. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3487. * @param other defines the second operand
  3488. * @returns the current updated Vector4
  3489. */
  3490. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3491. /**
  3492. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3493. * @param other defines the second operand
  3494. * @returns the current updated Vector4
  3495. */
  3496. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3497. /**
  3498. * Gets a new Vector4 from current Vector4 floored values
  3499. * @returns a new Vector4
  3500. */
  3501. floor(): Vector4;
  3502. /**
  3503. * Gets a new Vector4 from current Vector3 floored values
  3504. * @returns a new Vector4
  3505. */
  3506. fract(): Vector4;
  3507. /**
  3508. * Returns the Vector4 length (float).
  3509. * @returns the length
  3510. */
  3511. length(): number;
  3512. /**
  3513. * Returns the Vector4 squared length (float).
  3514. * @returns the length squared
  3515. */
  3516. lengthSquared(): number;
  3517. /**
  3518. * Normalizes in place the Vector4.
  3519. * @returns the updated Vector4.
  3520. */
  3521. normalize(): Vector4;
  3522. /**
  3523. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3524. * @returns this converted to a new vector3
  3525. */
  3526. toVector3(): Vector3;
  3527. /**
  3528. * Returns a new Vector4 copied from the current one.
  3529. * @returns the new cloned vector
  3530. */
  3531. clone(): Vector4;
  3532. /**
  3533. * Updates the current Vector4 with the given one coordinates.
  3534. * @param source the source vector to copy from
  3535. * @returns the updated Vector4.
  3536. */
  3537. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3538. /**
  3539. * Updates the current Vector4 coordinates with the given floats.
  3540. * @param x float to copy from
  3541. * @param y float to copy from
  3542. * @param z float to copy from
  3543. * @param w float to copy from
  3544. * @returns the updated Vector4.
  3545. */
  3546. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3547. /**
  3548. * Updates the current Vector4 coordinates with the given floats.
  3549. * @param x float to set from
  3550. * @param y float to set from
  3551. * @param z float to set from
  3552. * @param w float to set from
  3553. * @returns the updated Vector4.
  3554. */
  3555. set(x: number, y: number, z: number, w: number): Vector4;
  3556. /**
  3557. * Copies the given float to the current Vector3 coordinates
  3558. * @param v defines the x, y, z and w coordinates of the operand
  3559. * @returns the current updated Vector3
  3560. */
  3561. setAll(v: number): Vector4;
  3562. /**
  3563. * Returns a new Vector4 set from the starting index of the given array.
  3564. * @param array the array to pull values from
  3565. * @param offset the offset into the array to start at
  3566. * @returns the new vector
  3567. */
  3568. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3569. /**
  3570. * Updates the given vector "result" from the starting index of the given array.
  3571. * @param array the array to pull values from
  3572. * @param offset the offset into the array to start at
  3573. * @param result the vector to store the result in
  3574. */
  3575. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3576. /**
  3577. * Updates the given vector "result" from the starting index of the given Float32Array.
  3578. * @param array the array to pull values from
  3579. * @param offset the offset into the array to start at
  3580. * @param result the vector to store the result in
  3581. */
  3582. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3583. /**
  3584. * Updates the given vector "result" coordinates from the given floats.
  3585. * @param x float to set from
  3586. * @param y float to set from
  3587. * @param z float to set from
  3588. * @param w float to set from
  3589. * @param result the vector to the floats in
  3590. */
  3591. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3592. /**
  3593. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3594. * @returns the new vector
  3595. */
  3596. static Zero(): Vector4;
  3597. /**
  3598. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3599. * @returns the new vector
  3600. */
  3601. static One(): Vector4;
  3602. /**
  3603. * Returns a new normalized Vector4 from the given one.
  3604. * @param vector the vector to normalize
  3605. * @returns the vector
  3606. */
  3607. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3608. /**
  3609. * Updates the given vector "result" from the normalization of the given one.
  3610. * @param vector the vector to normalize
  3611. * @param result the vector to store the result in
  3612. */
  3613. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3614. /**
  3615. * Returns a vector with the minimum values from the left and right vectors
  3616. * @param left left vector to minimize
  3617. * @param right right vector to minimize
  3618. * @returns a new vector with the minimum of the left and right vector values
  3619. */
  3620. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3621. /**
  3622. * Returns a vector with the maximum values from the left and right vectors
  3623. * @param left left vector to maximize
  3624. * @param right right vector to maximize
  3625. * @returns a new vector with the maximum of the left and right vector values
  3626. */
  3627. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3628. /**
  3629. * Returns the distance (float) between the vectors "value1" and "value2".
  3630. * @param value1 value to calulate the distance between
  3631. * @param value2 value to calulate the distance between
  3632. * @return the distance between the two vectors
  3633. */
  3634. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3635. /**
  3636. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3637. * @param value1 value to calulate the distance between
  3638. * @param value2 value to calulate the distance between
  3639. * @return the distance between the two vectors squared
  3640. */
  3641. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3642. /**
  3643. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3644. * @param value1 value to calulate the center between
  3645. * @param value2 value to calulate the center between
  3646. * @return the center between the two vectors
  3647. */
  3648. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3649. /**
  3650. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3651. * This methods computes transformed normalized direction vectors only.
  3652. * @param vector the vector to transform
  3653. * @param transformation the transformation matrix to apply
  3654. * @returns the new vector
  3655. */
  3656. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3657. /**
  3658. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3659. * This methods computes transformed normalized direction vectors only.
  3660. * @param vector the vector to transform
  3661. * @param transformation the transformation matrix to apply
  3662. * @param result the vector to store the result in
  3663. */
  3664. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3665. /**
  3666. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3667. * This methods computes transformed normalized direction vectors only.
  3668. * @param x value to transform
  3669. * @param y value to transform
  3670. * @param z value to transform
  3671. * @param w value to transform
  3672. * @param transformation the transformation matrix to apply
  3673. * @param result the vector to store the results in
  3674. */
  3675. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3676. /**
  3677. * Creates a new Vector4 from a Vector3
  3678. * @param source defines the source data
  3679. * @param w defines the 4th component (default is 0)
  3680. * @returns a new Vector4
  3681. */
  3682. static FromVector3(source: Vector3, w?: number): Vector4;
  3683. }
  3684. /**
  3685. * Class used to store quaternion data
  3686. * @see https://en.wikipedia.org/wiki/Quaternion
  3687. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3688. */
  3689. export class Quaternion {
  3690. /** @hidden */
  3691. _x: number;
  3692. /** @hidden */
  3693. _y: number;
  3694. /** @hidden */
  3695. _z: number;
  3696. /** @hidden */
  3697. _w: number;
  3698. /** @hidden */
  3699. _isDirty: boolean;
  3700. /** Gets or sets the x coordinate */
  3701. get x(): number;
  3702. set x(value: number);
  3703. /** Gets or sets the y coordinate */
  3704. get y(): number;
  3705. set y(value: number);
  3706. /** Gets or sets the z coordinate */
  3707. get z(): number;
  3708. set z(value: number);
  3709. /** Gets or sets the w coordinate */
  3710. get w(): number;
  3711. set w(value: number);
  3712. /**
  3713. * Creates a new Quaternion from the given floats
  3714. * @param x defines the first component (0 by default)
  3715. * @param y defines the second component (0 by default)
  3716. * @param z defines the third component (0 by default)
  3717. * @param w defines the fourth component (1.0 by default)
  3718. */
  3719. constructor(x?: number, y?: number, z?: number, w?: number);
  3720. /**
  3721. * Gets a string representation for the current quaternion
  3722. * @returns a string with the Quaternion coordinates
  3723. */
  3724. toString(): string;
  3725. /**
  3726. * Gets the class name of the quaternion
  3727. * @returns the string "Quaternion"
  3728. */
  3729. getClassName(): string;
  3730. /**
  3731. * Gets a hash code for this quaternion
  3732. * @returns the quaternion hash code
  3733. */
  3734. getHashCode(): number;
  3735. /**
  3736. * Copy the quaternion to an array
  3737. * @returns a new array populated with 4 elements from the quaternion coordinates
  3738. */
  3739. asArray(): number[];
  3740. /**
  3741. * Check if two quaternions are equals
  3742. * @param otherQuaternion defines the second operand
  3743. * @return true if the current quaternion and the given one coordinates are strictly equals
  3744. */
  3745. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3746. /**
  3747. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3748. * @param otherQuaternion defines the other quaternion
  3749. * @param epsilon defines the minimal distance to consider equality
  3750. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3751. */
  3752. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3753. /**
  3754. * Clone the current quaternion
  3755. * @returns a new quaternion copied from the current one
  3756. */
  3757. clone(): Quaternion;
  3758. /**
  3759. * Copy a quaternion to the current one
  3760. * @param other defines the other quaternion
  3761. * @returns the updated current quaternion
  3762. */
  3763. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3764. /**
  3765. * Updates the current quaternion with the given float coordinates
  3766. * @param x defines the x coordinate
  3767. * @param y defines the y coordinate
  3768. * @param z defines the z coordinate
  3769. * @param w defines the w coordinate
  3770. * @returns the updated current quaternion
  3771. */
  3772. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3773. /**
  3774. * Updates the current quaternion from the given float coordinates
  3775. * @param x defines the x coordinate
  3776. * @param y defines the y coordinate
  3777. * @param z defines the z coordinate
  3778. * @param w defines the w coordinate
  3779. * @returns the updated current quaternion
  3780. */
  3781. set(x: number, y: number, z: number, w: number): Quaternion;
  3782. /**
  3783. * Adds two quaternions
  3784. * @param other defines the second operand
  3785. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3786. */
  3787. add(other: DeepImmutable<Quaternion>): Quaternion;
  3788. /**
  3789. * Add a quaternion to the current one
  3790. * @param other defines the quaternion to add
  3791. * @returns the current quaternion
  3792. */
  3793. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3794. /**
  3795. * Subtract two quaternions
  3796. * @param other defines the second operand
  3797. * @returns a new quaternion as the subtraction result of the given one from the current one
  3798. */
  3799. subtract(other: Quaternion): Quaternion;
  3800. /**
  3801. * Multiplies the current quaternion by a scale factor
  3802. * @param value defines the scale factor
  3803. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3804. */
  3805. scale(value: number): Quaternion;
  3806. /**
  3807. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3808. * @param scale defines the scale factor
  3809. * @param result defines the Quaternion object where to store the result
  3810. * @returns the unmodified current quaternion
  3811. */
  3812. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3813. /**
  3814. * Multiplies in place the current quaternion by a scale factor
  3815. * @param value defines the scale factor
  3816. * @returns the current modified quaternion
  3817. */
  3818. scaleInPlace(value: number): Quaternion;
  3819. /**
  3820. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3821. * @param scale defines the scale factor
  3822. * @param result defines the Quaternion object where to store the result
  3823. * @returns the unmodified current quaternion
  3824. */
  3825. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3826. /**
  3827. * Multiplies two quaternions
  3828. * @param q1 defines the second operand
  3829. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3830. */
  3831. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3832. /**
  3833. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3834. * @param q1 defines the second operand
  3835. * @param result defines the target quaternion
  3836. * @returns the current quaternion
  3837. */
  3838. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3839. /**
  3840. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3841. * @param q1 defines the second operand
  3842. * @returns the currentupdated quaternion
  3843. */
  3844. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3845. /**
  3846. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3847. * @param ref defines the target quaternion
  3848. * @returns the current quaternion
  3849. */
  3850. conjugateToRef(ref: Quaternion): Quaternion;
  3851. /**
  3852. * Conjugates in place (1-q) the current quaternion
  3853. * @returns the current updated quaternion
  3854. */
  3855. conjugateInPlace(): Quaternion;
  3856. /**
  3857. * Conjugates in place (1-q) the current quaternion
  3858. * @returns a new quaternion
  3859. */
  3860. conjugate(): Quaternion;
  3861. /**
  3862. * Gets length of current quaternion
  3863. * @returns the quaternion length (float)
  3864. */
  3865. length(): number;
  3866. /**
  3867. * Normalize in place the current quaternion
  3868. * @returns the current updated quaternion
  3869. */
  3870. normalize(): Quaternion;
  3871. /**
  3872. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3873. * @param order is a reserved parameter and is ignored for now
  3874. * @returns a new Vector3 containing the Euler angles
  3875. */
  3876. toEulerAngles(order?: string): Vector3;
  3877. /**
  3878. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3879. * @param result defines the vector which will be filled with the Euler angles
  3880. * @returns the current unchanged quaternion
  3881. */
  3882. toEulerAnglesToRef(result: Vector3): Quaternion;
  3883. /**
  3884. * Updates the given rotation matrix with the current quaternion values
  3885. * @param result defines the target matrix
  3886. * @returns the current unchanged quaternion
  3887. */
  3888. toRotationMatrix(result: Matrix): Quaternion;
  3889. /**
  3890. * Updates the current quaternion from the given rotation matrix values
  3891. * @param matrix defines the source matrix
  3892. * @returns the current updated quaternion
  3893. */
  3894. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3895. /**
  3896. * Creates a new quaternion from a rotation matrix
  3897. * @param matrix defines the source matrix
  3898. * @returns a new quaternion created from the given rotation matrix values
  3899. */
  3900. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3901. /**
  3902. * Updates the given quaternion with the given rotation matrix values
  3903. * @param matrix defines the source matrix
  3904. * @param result defines the target quaternion
  3905. */
  3906. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3907. /**
  3908. * Returns the dot product (float) between the quaternions "left" and "right"
  3909. * @param left defines the left operand
  3910. * @param right defines the right operand
  3911. * @returns the dot product
  3912. */
  3913. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3914. /**
  3915. * Checks if the two quaternions are close to each other
  3916. * @param quat0 defines the first quaternion to check
  3917. * @param quat1 defines the second quaternion to check
  3918. * @returns true if the two quaternions are close to each other
  3919. */
  3920. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3921. /**
  3922. * Creates an empty quaternion
  3923. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3924. */
  3925. static Zero(): Quaternion;
  3926. /**
  3927. * Inverse a given quaternion
  3928. * @param q defines the source quaternion
  3929. * @returns a new quaternion as the inverted current quaternion
  3930. */
  3931. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3932. /**
  3933. * Inverse a given quaternion
  3934. * @param q defines the source quaternion
  3935. * @param result the quaternion the result will be stored in
  3936. * @returns the result quaternion
  3937. */
  3938. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3939. /**
  3940. * Creates an identity quaternion
  3941. * @returns the identity quaternion
  3942. */
  3943. static Identity(): Quaternion;
  3944. /**
  3945. * Gets a boolean indicating if the given quaternion is identity
  3946. * @param quaternion defines the quaternion to check
  3947. * @returns true if the quaternion is identity
  3948. */
  3949. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3950. /**
  3951. * Creates a quaternion from a rotation around an axis
  3952. * @param axis defines the axis to use
  3953. * @param angle defines the angle to use
  3954. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3955. */
  3956. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3957. /**
  3958. * Creates a rotation around an axis and stores it into the given quaternion
  3959. * @param axis defines the axis to use
  3960. * @param angle defines the angle to use
  3961. * @param result defines the target quaternion
  3962. * @returns the target quaternion
  3963. */
  3964. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3965. /**
  3966. * Creates a new quaternion from data stored into an array
  3967. * @param array defines the data source
  3968. * @param offset defines the offset in the source array where the data starts
  3969. * @returns a new quaternion
  3970. */
  3971. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3972. /**
  3973. * Updates the given quaternion "result" from the starting index of the given array.
  3974. * @param array the array to pull values from
  3975. * @param offset the offset into the array to start at
  3976. * @param result the quaternion to store the result in
  3977. */
  3978. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3979. /**
  3980. * Create a quaternion from Euler rotation angles
  3981. * @param x Pitch
  3982. * @param y Yaw
  3983. * @param z Roll
  3984. * @returns the new Quaternion
  3985. */
  3986. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3987. /**
  3988. * Updates a quaternion from Euler rotation angles
  3989. * @param x Pitch
  3990. * @param y Yaw
  3991. * @param z Roll
  3992. * @param result the quaternion to store the result
  3993. * @returns the updated quaternion
  3994. */
  3995. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3996. /**
  3997. * Create a quaternion from Euler rotation vector
  3998. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3999. * @returns the new Quaternion
  4000. */
  4001. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4002. /**
  4003. * Updates a quaternion from Euler rotation vector
  4004. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4005. * @param result the quaternion to store the result
  4006. * @returns the updated quaternion
  4007. */
  4008. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4009. /**
  4010. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4011. * @param yaw defines the rotation around Y axis
  4012. * @param pitch defines the rotation around X axis
  4013. * @param roll defines the rotation around Z axis
  4014. * @returns the new quaternion
  4015. */
  4016. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4017. /**
  4018. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4019. * @param yaw defines the rotation around Y axis
  4020. * @param pitch defines the rotation around X axis
  4021. * @param roll defines the rotation around Z axis
  4022. * @param result defines the target quaternion
  4023. */
  4024. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4025. /**
  4026. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4027. * @param alpha defines the rotation around first axis
  4028. * @param beta defines the rotation around second axis
  4029. * @param gamma defines the rotation around third axis
  4030. * @returns the new quaternion
  4031. */
  4032. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4033. /**
  4034. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4035. * @param alpha defines the rotation around first axis
  4036. * @param beta defines the rotation around second axis
  4037. * @param gamma defines the rotation around third axis
  4038. * @param result defines the target quaternion
  4039. */
  4040. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4041. /**
  4042. * 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)
  4043. * @param axis1 defines the first axis
  4044. * @param axis2 defines the second axis
  4045. * @param axis3 defines the third axis
  4046. * @returns the new quaternion
  4047. */
  4048. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4049. /**
  4050. * 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
  4051. * @param axis1 defines the first axis
  4052. * @param axis2 defines the second axis
  4053. * @param axis3 defines the third axis
  4054. * @param ref defines the target quaternion
  4055. */
  4056. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4057. /**
  4058. * Interpolates between two quaternions
  4059. * @param left defines first quaternion
  4060. * @param right defines second quaternion
  4061. * @param amount defines the gradient to use
  4062. * @returns the new interpolated quaternion
  4063. */
  4064. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4065. /**
  4066. * Interpolates between two quaternions and stores it into a target quaternion
  4067. * @param left defines first quaternion
  4068. * @param right defines second quaternion
  4069. * @param amount defines the gradient to use
  4070. * @param result defines the target quaternion
  4071. */
  4072. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4073. /**
  4074. * Interpolate between two quaternions using Hermite interpolation
  4075. * @param value1 defines first quaternion
  4076. * @param tangent1 defines the incoming tangent
  4077. * @param value2 defines second quaternion
  4078. * @param tangent2 defines the outgoing tangent
  4079. * @param amount defines the target quaternion
  4080. * @returns the new interpolated quaternion
  4081. */
  4082. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4083. }
  4084. /**
  4085. * Class used to store matrix data (4x4)
  4086. */
  4087. export class Matrix {
  4088. /**
  4089. * Gets the precision of matrix computations
  4090. */
  4091. static get Use64Bits(): boolean;
  4092. private static _updateFlagSeed;
  4093. private static _identityReadOnly;
  4094. private _isIdentity;
  4095. private _isIdentityDirty;
  4096. private _isIdentity3x2;
  4097. private _isIdentity3x2Dirty;
  4098. /**
  4099. * Gets the update flag of the matrix which is an unique number for the matrix.
  4100. * It will be incremented every time the matrix data change.
  4101. * You can use it to speed the comparison between two versions of the same matrix.
  4102. */
  4103. updateFlag: number;
  4104. private readonly _m;
  4105. /**
  4106. * Gets the internal data of the matrix
  4107. */
  4108. get m(): DeepImmutable<Float32Array | Array<number>>;
  4109. /** @hidden */
  4110. _markAsUpdated(): void;
  4111. /** @hidden */
  4112. private _updateIdentityStatus;
  4113. /**
  4114. * Creates an empty matrix (filled with zeros)
  4115. */
  4116. constructor();
  4117. /**
  4118. * Check if the current matrix is identity
  4119. * @returns true is the matrix is the identity matrix
  4120. */
  4121. isIdentity(): boolean;
  4122. /**
  4123. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4124. * @returns true is the matrix is the identity matrix
  4125. */
  4126. isIdentityAs3x2(): boolean;
  4127. /**
  4128. * Gets the determinant of the matrix
  4129. * @returns the matrix determinant
  4130. */
  4131. determinant(): number;
  4132. /**
  4133. * Returns the matrix as a Float32Array or Array<number>
  4134. * @returns the matrix underlying array
  4135. */
  4136. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4137. /**
  4138. * Returns the matrix as a Float32Array or Array<number>
  4139. * @returns the matrix underlying array.
  4140. */
  4141. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4142. /**
  4143. * Inverts the current matrix in place
  4144. * @returns the current inverted matrix
  4145. */
  4146. invert(): Matrix;
  4147. /**
  4148. * Sets all the matrix elements to zero
  4149. * @returns the current matrix
  4150. */
  4151. reset(): Matrix;
  4152. /**
  4153. * Adds the current matrix with a second one
  4154. * @param other defines the matrix to add
  4155. * @returns a new matrix as the addition of the current matrix and the given one
  4156. */
  4157. add(other: DeepImmutable<Matrix>): Matrix;
  4158. /**
  4159. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4160. * @param other defines the matrix to add
  4161. * @param result defines the target matrix
  4162. * @returns the current matrix
  4163. */
  4164. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4165. /**
  4166. * Adds in place the given matrix to the current matrix
  4167. * @param other defines the second operand
  4168. * @returns the current updated matrix
  4169. */
  4170. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4171. /**
  4172. * Sets the given matrix to the current inverted Matrix
  4173. * @param other defines the target matrix
  4174. * @returns the unmodified current matrix
  4175. */
  4176. invertToRef(other: Matrix): Matrix;
  4177. /**
  4178. * add a value at the specified position in the current Matrix
  4179. * @param index the index of the value within the matrix. between 0 and 15.
  4180. * @param value the value to be added
  4181. * @returns the current updated matrix
  4182. */
  4183. addAtIndex(index: number, value: number): Matrix;
  4184. /**
  4185. * mutiply the specified position in the current Matrix by a value
  4186. * @param index the index of the value within the matrix. between 0 and 15.
  4187. * @param value the value to be added
  4188. * @returns the current updated matrix
  4189. */
  4190. multiplyAtIndex(index: number, value: number): Matrix;
  4191. /**
  4192. * Inserts the translation vector (using 3 floats) in the current matrix
  4193. * @param x defines the 1st component of the translation
  4194. * @param y defines the 2nd component of the translation
  4195. * @param z defines the 3rd component of the translation
  4196. * @returns the current updated matrix
  4197. */
  4198. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4199. /**
  4200. * Adds the translation vector (using 3 floats) in the current matrix
  4201. * @param x defines the 1st component of the translation
  4202. * @param y defines the 2nd component of the translation
  4203. * @param z defines the 3rd component of the translation
  4204. * @returns the current updated matrix
  4205. */
  4206. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4207. /**
  4208. * Inserts the translation vector in the current matrix
  4209. * @param vector3 defines the translation to insert
  4210. * @returns the current updated matrix
  4211. */
  4212. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4213. /**
  4214. * Gets the translation value of the current matrix
  4215. * @returns a new Vector3 as the extracted translation from the matrix
  4216. */
  4217. getTranslation(): Vector3;
  4218. /**
  4219. * Fill a Vector3 with the extracted translation from the matrix
  4220. * @param result defines the Vector3 where to store the translation
  4221. * @returns the current matrix
  4222. */
  4223. getTranslationToRef(result: Vector3): Matrix;
  4224. /**
  4225. * Remove rotation and scaling part from the matrix
  4226. * @returns the updated matrix
  4227. */
  4228. removeRotationAndScaling(): Matrix;
  4229. /**
  4230. * Multiply two matrices
  4231. * @param other defines the second operand
  4232. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4233. */
  4234. multiply(other: DeepImmutable<Matrix>): Matrix;
  4235. /**
  4236. * Copy the current matrix from the given one
  4237. * @param other defines the source matrix
  4238. * @returns the current updated matrix
  4239. */
  4240. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4241. /**
  4242. * Populates the given array from the starting index with the current matrix values
  4243. * @param array defines the target array
  4244. * @param offset defines the offset in the target array where to start storing values
  4245. * @returns the current matrix
  4246. */
  4247. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4248. /**
  4249. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4250. * @param other defines the second operand
  4251. * @param result defines the matrix where to store the multiplication
  4252. * @returns the current matrix
  4253. */
  4254. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4255. /**
  4256. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4257. * @param other defines the second operand
  4258. * @param result defines the array where to store the multiplication
  4259. * @param offset defines the offset in the target array where to start storing values
  4260. * @returns the current matrix
  4261. */
  4262. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4263. /**
  4264. * Check equality between this matrix and a second one
  4265. * @param value defines the second matrix to compare
  4266. * @returns true is the current matrix and the given one values are strictly equal
  4267. */
  4268. equals(value: DeepImmutable<Matrix>): boolean;
  4269. /**
  4270. * Clone the current matrix
  4271. * @returns a new matrix from the current matrix
  4272. */
  4273. clone(): Matrix;
  4274. /**
  4275. * Returns the name of the current matrix class
  4276. * @returns the string "Matrix"
  4277. */
  4278. getClassName(): string;
  4279. /**
  4280. * Gets the hash code of the current matrix
  4281. * @returns the hash code
  4282. */
  4283. getHashCode(): number;
  4284. /**
  4285. * Decomposes the current Matrix into a translation, rotation and scaling components
  4286. * @param scale defines the scale vector3 given as a reference to update
  4287. * @param rotation defines the rotation quaternion given as a reference to update
  4288. * @param translation defines the translation vector3 given as a reference to update
  4289. * @returns true if operation was successful
  4290. */
  4291. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4292. /**
  4293. * Gets specific row of the matrix
  4294. * @param index defines the number of the row to get
  4295. * @returns the index-th row of the current matrix as a new Vector4
  4296. */
  4297. getRow(index: number): Nullable<Vector4>;
  4298. /**
  4299. * Sets the index-th row of the current matrix to the vector4 values
  4300. * @param index defines the number of the row to set
  4301. * @param row defines the target vector4
  4302. * @returns the updated current matrix
  4303. */
  4304. setRow(index: number, row: Vector4): Matrix;
  4305. /**
  4306. * Compute the transpose of the matrix
  4307. * @returns the new transposed matrix
  4308. */
  4309. transpose(): Matrix;
  4310. /**
  4311. * Compute the transpose of the matrix and store it in a given matrix
  4312. * @param result defines the target matrix
  4313. * @returns the current matrix
  4314. */
  4315. transposeToRef(result: Matrix): Matrix;
  4316. /**
  4317. * Sets the index-th row of the current matrix with the given 4 x float values
  4318. * @param index defines the row index
  4319. * @param x defines the x component to set
  4320. * @param y defines the y component to set
  4321. * @param z defines the z component to set
  4322. * @param w defines the w component to set
  4323. * @returns the updated current matrix
  4324. */
  4325. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4326. /**
  4327. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4328. * @param scale defines the scale factor
  4329. * @returns a new matrix
  4330. */
  4331. scale(scale: number): Matrix;
  4332. /**
  4333. * Scale the current matrix values by a factor to a given result matrix
  4334. * @param scale defines the scale factor
  4335. * @param result defines the matrix to store the result
  4336. * @returns the current matrix
  4337. */
  4338. scaleToRef(scale: number, result: Matrix): Matrix;
  4339. /**
  4340. * Scale the current matrix values by a factor and add the result to a given matrix
  4341. * @param scale defines the scale factor
  4342. * @param result defines the Matrix to store the result
  4343. * @returns the current matrix
  4344. */
  4345. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4346. /**
  4347. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4348. * @param ref matrix to store the result
  4349. */
  4350. toNormalMatrix(ref: Matrix): void;
  4351. /**
  4352. * Gets only rotation part of the current matrix
  4353. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4354. */
  4355. getRotationMatrix(): Matrix;
  4356. /**
  4357. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4358. * @param result defines the target matrix to store data to
  4359. * @returns the current matrix
  4360. */
  4361. getRotationMatrixToRef(result: Matrix): Matrix;
  4362. /**
  4363. * Toggles model matrix from being right handed to left handed in place and vice versa
  4364. */
  4365. toggleModelMatrixHandInPlace(): void;
  4366. /**
  4367. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4368. */
  4369. toggleProjectionMatrixHandInPlace(): void;
  4370. /**
  4371. * Creates a matrix from an array
  4372. * @param array defines the source array
  4373. * @param offset defines an offset in the source array
  4374. * @returns a new Matrix set from the starting index of the given array
  4375. */
  4376. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4377. /**
  4378. * Copy the content of an array into a given matrix
  4379. * @param array defines the source array
  4380. * @param offset defines an offset in the source array
  4381. * @param result defines the target matrix
  4382. */
  4383. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4384. /**
  4385. * Stores an array into a matrix after having multiplied each component by a given factor
  4386. * @param array defines the source array
  4387. * @param offset defines the offset in the source array
  4388. * @param scale defines the scaling factor
  4389. * @param result defines the target matrix
  4390. */
  4391. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4392. /**
  4393. * Gets an identity matrix that must not be updated
  4394. */
  4395. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4396. /**
  4397. * Stores a list of values (16) inside a given matrix
  4398. * @param initialM11 defines 1st value of 1st row
  4399. * @param initialM12 defines 2nd value of 1st row
  4400. * @param initialM13 defines 3rd value of 1st row
  4401. * @param initialM14 defines 4th value of 1st row
  4402. * @param initialM21 defines 1st value of 2nd row
  4403. * @param initialM22 defines 2nd value of 2nd row
  4404. * @param initialM23 defines 3rd value of 2nd row
  4405. * @param initialM24 defines 4th value of 2nd row
  4406. * @param initialM31 defines 1st value of 3rd row
  4407. * @param initialM32 defines 2nd value of 3rd row
  4408. * @param initialM33 defines 3rd value of 3rd row
  4409. * @param initialM34 defines 4th value of 3rd row
  4410. * @param initialM41 defines 1st value of 4th row
  4411. * @param initialM42 defines 2nd value of 4th row
  4412. * @param initialM43 defines 3rd value of 4th row
  4413. * @param initialM44 defines 4th value of 4th row
  4414. * @param result defines the target matrix
  4415. */
  4416. 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;
  4417. /**
  4418. * Creates new matrix from a list of values (16)
  4419. * @param initialM11 defines 1st value of 1st row
  4420. * @param initialM12 defines 2nd value of 1st row
  4421. * @param initialM13 defines 3rd value of 1st row
  4422. * @param initialM14 defines 4th value of 1st row
  4423. * @param initialM21 defines 1st value of 2nd row
  4424. * @param initialM22 defines 2nd value of 2nd row
  4425. * @param initialM23 defines 3rd value of 2nd row
  4426. * @param initialM24 defines 4th value of 2nd row
  4427. * @param initialM31 defines 1st value of 3rd row
  4428. * @param initialM32 defines 2nd value of 3rd row
  4429. * @param initialM33 defines 3rd value of 3rd row
  4430. * @param initialM34 defines 4th value of 3rd row
  4431. * @param initialM41 defines 1st value of 4th row
  4432. * @param initialM42 defines 2nd value of 4th row
  4433. * @param initialM43 defines 3rd value of 4th row
  4434. * @param initialM44 defines 4th value of 4th row
  4435. * @returns the new matrix
  4436. */
  4437. 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;
  4438. /**
  4439. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4440. * @param scale defines the scale vector3
  4441. * @param rotation defines the rotation quaternion
  4442. * @param translation defines the translation vector3
  4443. * @returns a new matrix
  4444. */
  4445. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4446. /**
  4447. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4448. * @param scale defines the scale vector3
  4449. * @param rotation defines the rotation quaternion
  4450. * @param translation defines the translation vector3
  4451. * @param result defines the target matrix
  4452. */
  4453. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4454. /**
  4455. * Creates a new identity matrix
  4456. * @returns a new identity matrix
  4457. */
  4458. static Identity(): Matrix;
  4459. /**
  4460. * Creates a new identity matrix and stores the result in a given matrix
  4461. * @param result defines the target matrix
  4462. */
  4463. static IdentityToRef(result: Matrix): void;
  4464. /**
  4465. * Creates a new zero matrix
  4466. * @returns a new zero matrix
  4467. */
  4468. static Zero(): Matrix;
  4469. /**
  4470. * Creates a new rotation matrix for "angle" radians around the X axis
  4471. * @param angle defines the angle (in radians) to use
  4472. * @return the new matrix
  4473. */
  4474. static RotationX(angle: number): Matrix;
  4475. /**
  4476. * Creates a new matrix as the invert of a given matrix
  4477. * @param source defines the source matrix
  4478. * @returns the new matrix
  4479. */
  4480. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4481. /**
  4482. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4483. * @param angle defines the angle (in radians) to use
  4484. * @param result defines the target matrix
  4485. */
  4486. static RotationXToRef(angle: number, result: Matrix): void;
  4487. /**
  4488. * Creates a new rotation matrix for "angle" radians around the Y axis
  4489. * @param angle defines the angle (in radians) to use
  4490. * @return the new matrix
  4491. */
  4492. static RotationY(angle: number): Matrix;
  4493. /**
  4494. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4495. * @param angle defines the angle (in radians) to use
  4496. * @param result defines the target matrix
  4497. */
  4498. static RotationYToRef(angle: number, result: Matrix): void;
  4499. /**
  4500. * Creates a new rotation matrix for "angle" radians around the Z axis
  4501. * @param angle defines the angle (in radians) to use
  4502. * @return the new matrix
  4503. */
  4504. static RotationZ(angle: number): Matrix;
  4505. /**
  4506. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4507. * @param angle defines the angle (in radians) to use
  4508. * @param result defines the target matrix
  4509. */
  4510. static RotationZToRef(angle: number, result: Matrix): void;
  4511. /**
  4512. * Creates a new rotation matrix for "angle" radians around the given axis
  4513. * @param axis defines the axis to use
  4514. * @param angle defines the angle (in radians) to use
  4515. * @return the new matrix
  4516. */
  4517. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4518. /**
  4519. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4520. * @param axis defines the axis to use
  4521. * @param angle defines the angle (in radians) to use
  4522. * @param result defines the target matrix
  4523. */
  4524. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4525. /**
  4526. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4527. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4528. * @param from defines the vector to align
  4529. * @param to defines the vector to align to
  4530. * @param result defines the target matrix
  4531. */
  4532. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4533. /**
  4534. * Creates a rotation matrix
  4535. * @param yaw defines the yaw angle in radians (Y axis)
  4536. * @param pitch defines the pitch angle in radians (X axis)
  4537. * @param roll defines the roll angle in radians (Z axis)
  4538. * @returns the new rotation matrix
  4539. */
  4540. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4541. /**
  4542. * Creates a rotation matrix and stores it in a given matrix
  4543. * @param yaw defines the yaw angle in radians (Y axis)
  4544. * @param pitch defines the pitch angle in radians (X axis)
  4545. * @param roll defines the roll angle in radians (Z axis)
  4546. * @param result defines the target matrix
  4547. */
  4548. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4549. /**
  4550. * Creates a scaling matrix
  4551. * @param x defines the scale factor on X axis
  4552. * @param y defines the scale factor on Y axis
  4553. * @param z defines the scale factor on Z axis
  4554. * @returns the new matrix
  4555. */
  4556. static Scaling(x: number, y: number, z: number): Matrix;
  4557. /**
  4558. * Creates a scaling matrix and stores it in a given matrix
  4559. * @param x defines the scale factor on X axis
  4560. * @param y defines the scale factor on Y axis
  4561. * @param z defines the scale factor on Z axis
  4562. * @param result defines the target matrix
  4563. */
  4564. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4565. /**
  4566. * Creates a translation matrix
  4567. * @param x defines the translation on X axis
  4568. * @param y defines the translation on Y axis
  4569. * @param z defines the translationon Z axis
  4570. * @returns the new matrix
  4571. */
  4572. static Translation(x: number, y: number, z: number): Matrix;
  4573. /**
  4574. * Creates a translation matrix and stores it in a given matrix
  4575. * @param x defines the translation on X axis
  4576. * @param y defines the translation on Y axis
  4577. * @param z defines the translationon Z axis
  4578. * @param result defines the target matrix
  4579. */
  4580. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4581. /**
  4582. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4583. * @param startValue defines the start value
  4584. * @param endValue defines the end value
  4585. * @param gradient defines the gradient factor
  4586. * @returns the new matrix
  4587. */
  4588. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4589. /**
  4590. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4591. * @param startValue defines the start value
  4592. * @param endValue defines the end value
  4593. * @param gradient defines the gradient factor
  4594. * @param result defines the Matrix object where to store data
  4595. */
  4596. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4597. /**
  4598. * Builds a new matrix whose values are computed by:
  4599. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4600. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4601. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4602. * @param startValue defines the first matrix
  4603. * @param endValue defines the second matrix
  4604. * @param gradient defines the gradient between the two matrices
  4605. * @returns the new matrix
  4606. */
  4607. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4608. /**
  4609. * Update a matrix to values which are computed by:
  4610. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4611. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4612. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4613. * @param startValue defines the first matrix
  4614. * @param endValue defines the second matrix
  4615. * @param gradient defines the gradient between the two matrices
  4616. * @param result defines the target matrix
  4617. */
  4618. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4619. /**
  4620. * 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"
  4621. * This function works in left handed mode
  4622. * @param eye defines the final position of the entity
  4623. * @param target defines where the entity should look at
  4624. * @param up defines the up vector for the entity
  4625. * @returns the new matrix
  4626. */
  4627. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4628. /**
  4629. * 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".
  4630. * This function works in left handed mode
  4631. * @param eye defines the final position of the entity
  4632. * @param target defines where the entity should look at
  4633. * @param up defines the up vector for the entity
  4634. * @param result defines the target matrix
  4635. */
  4636. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4637. /**
  4638. * 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"
  4639. * This function works in right handed mode
  4640. * @param eye defines the final position of the entity
  4641. * @param target defines where the entity should look at
  4642. * @param up defines the up vector for the entity
  4643. * @returns the new matrix
  4644. */
  4645. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4646. /**
  4647. * 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".
  4648. * This function works in right handed mode
  4649. * @param eye defines the final position of the entity
  4650. * @param target defines where the entity should look at
  4651. * @param up defines the up vector for the entity
  4652. * @param result defines the target matrix
  4653. */
  4654. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4655. /**
  4656. * Create a left-handed orthographic projection matrix
  4657. * @param width defines the viewport width
  4658. * @param height defines the viewport height
  4659. * @param znear defines the near clip plane
  4660. * @param zfar defines the far clip plane
  4661. * @returns a new matrix as a left-handed orthographic projection matrix
  4662. */
  4663. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4664. /**
  4665. * Store a left-handed orthographic projection to a given matrix
  4666. * @param width defines the viewport width
  4667. * @param height defines the viewport height
  4668. * @param znear defines the near clip plane
  4669. * @param zfar defines the far clip plane
  4670. * @param result defines the target matrix
  4671. */
  4672. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4673. /**
  4674. * Create a left-handed orthographic projection matrix
  4675. * @param left defines the viewport left coordinate
  4676. * @param right defines the viewport right coordinate
  4677. * @param bottom defines the viewport bottom coordinate
  4678. * @param top defines the viewport top coordinate
  4679. * @param znear defines the near clip plane
  4680. * @param zfar defines the far clip plane
  4681. * @returns a new matrix as a left-handed orthographic projection matrix
  4682. */
  4683. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4684. /**
  4685. * Stores a left-handed orthographic projection into a given matrix
  4686. * @param left defines the viewport left coordinate
  4687. * @param right defines the viewport right coordinate
  4688. * @param bottom defines the viewport bottom coordinate
  4689. * @param top defines the viewport top coordinate
  4690. * @param znear defines the near clip plane
  4691. * @param zfar defines the far clip plane
  4692. * @param result defines the target matrix
  4693. */
  4694. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4695. /**
  4696. * Creates a right-handed orthographic projection matrix
  4697. * @param left defines the viewport left coordinate
  4698. * @param right defines the viewport right coordinate
  4699. * @param bottom defines the viewport bottom coordinate
  4700. * @param top defines the viewport top coordinate
  4701. * @param znear defines the near clip plane
  4702. * @param zfar defines the far clip plane
  4703. * @returns a new matrix as a right-handed orthographic projection matrix
  4704. */
  4705. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4706. /**
  4707. * Stores a right-handed orthographic projection into a given matrix
  4708. * @param left defines the viewport left coordinate
  4709. * @param right defines the viewport right coordinate
  4710. * @param bottom defines the viewport bottom coordinate
  4711. * @param top defines the viewport top coordinate
  4712. * @param znear defines the near clip plane
  4713. * @param zfar defines the far clip plane
  4714. * @param result defines the target matrix
  4715. */
  4716. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4717. /**
  4718. * Creates a left-handed perspective projection matrix
  4719. * @param width defines the viewport width
  4720. * @param height defines the viewport height
  4721. * @param znear defines the near clip plane
  4722. * @param zfar defines the far clip plane
  4723. * @returns a new matrix as a left-handed perspective projection matrix
  4724. */
  4725. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4726. /**
  4727. * Creates a left-handed perspective projection matrix
  4728. * @param fov defines the horizontal field of view
  4729. * @param aspect defines the aspect ratio
  4730. * @param znear defines the near clip plane
  4731. * @param zfar defines the far clip plane
  4732. * @returns a new matrix as a left-handed perspective projection matrix
  4733. */
  4734. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4735. /**
  4736. * Stores a left-handed perspective projection into a given matrix
  4737. * @param fov defines the horizontal field of view
  4738. * @param aspect defines the aspect ratio
  4739. * @param znear defines the near clip plane
  4740. * @param zfar defines the far clip plane
  4741. * @param result defines the target matrix
  4742. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4743. */
  4744. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4745. /**
  4746. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4747. * @param fov defines the horizontal field of view
  4748. * @param aspect defines the aspect ratio
  4749. * @param znear defines the near clip plane
  4750. * @param zfar not used as infinity is used as far clip
  4751. * @param result defines the target matrix
  4752. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4753. */
  4754. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4755. /**
  4756. * Creates a right-handed perspective projection matrix
  4757. * @param fov defines the horizontal field of view
  4758. * @param aspect defines the aspect ratio
  4759. * @param znear defines the near clip plane
  4760. * @param zfar defines the far clip plane
  4761. * @returns a new matrix as a right-handed perspective projection matrix
  4762. */
  4763. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4764. /**
  4765. * Stores a right-handed perspective projection into a given matrix
  4766. * @param fov defines the horizontal field of view
  4767. * @param aspect defines the aspect ratio
  4768. * @param znear defines the near clip plane
  4769. * @param zfar defines the far clip plane
  4770. * @param result defines the target matrix
  4771. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4772. */
  4773. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4774. /**
  4775. * Stores a right-handed perspective projection into a given matrix
  4776. * @param fov defines the horizontal field of view
  4777. * @param aspect defines the aspect ratio
  4778. * @param znear defines the near clip plane
  4779. * @param zfar not used as infinity is used as far clip
  4780. * @param result defines the target matrix
  4781. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4782. */
  4783. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4784. /**
  4785. * Stores a perspective projection for WebVR info a given matrix
  4786. * @param fov defines the field of view
  4787. * @param znear defines the near clip plane
  4788. * @param zfar defines the far clip plane
  4789. * @param result defines the target matrix
  4790. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4791. */
  4792. static PerspectiveFovWebVRToRef(fov: {
  4793. upDegrees: number;
  4794. downDegrees: number;
  4795. leftDegrees: number;
  4796. rightDegrees: number;
  4797. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4798. /**
  4799. * Computes a complete transformation matrix
  4800. * @param viewport defines the viewport to use
  4801. * @param world defines the world matrix
  4802. * @param view defines the view matrix
  4803. * @param projection defines the projection matrix
  4804. * @param zmin defines the near clip plane
  4805. * @param zmax defines the far clip plane
  4806. * @returns the transformation matrix
  4807. */
  4808. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4809. /**
  4810. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4811. * @param matrix defines the matrix to use
  4812. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4813. */
  4814. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4815. /**
  4816. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4817. * @param matrix defines the matrix to use
  4818. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4819. */
  4820. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4821. /**
  4822. * Compute the transpose of a given matrix
  4823. * @param matrix defines the matrix to transpose
  4824. * @returns the new matrix
  4825. */
  4826. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4827. /**
  4828. * Compute the transpose of a matrix and store it in a target matrix
  4829. * @param matrix defines the matrix to transpose
  4830. * @param result defines the target matrix
  4831. */
  4832. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4833. /**
  4834. * Computes a reflection matrix from a plane
  4835. * @param plane defines the reflection plane
  4836. * @returns a new matrix
  4837. */
  4838. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4839. /**
  4840. * Computes a reflection matrix from a plane
  4841. * @param plane defines the reflection plane
  4842. * @param result defines the target matrix
  4843. */
  4844. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4845. /**
  4846. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4847. * @param xaxis defines the value of the 1st axis
  4848. * @param yaxis defines the value of the 2nd axis
  4849. * @param zaxis defines the value of the 3rd axis
  4850. * @param result defines the target matrix
  4851. */
  4852. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4853. /**
  4854. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4855. * @param quat defines the quaternion to use
  4856. * @param result defines the target matrix
  4857. */
  4858. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4859. }
  4860. /**
  4861. * @hidden
  4862. */
  4863. export class TmpVectors {
  4864. static Vector2: Vector2[];
  4865. static Vector3: Vector3[];
  4866. static Vector4: Vector4[];
  4867. static Quaternion: Quaternion[];
  4868. static Matrix: Matrix[];
  4869. }
  4870. }
  4871. declare module BABYLON {
  4872. /**
  4873. * Defines potential orientation for back face culling
  4874. */
  4875. export enum Orientation {
  4876. /**
  4877. * Clockwise
  4878. */
  4879. CW = 0,
  4880. /** Counter clockwise */
  4881. CCW = 1
  4882. }
  4883. /** Class used to represent a Bezier curve */
  4884. export class BezierCurve {
  4885. /**
  4886. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4887. * @param t defines the time
  4888. * @param x1 defines the left coordinate on X axis
  4889. * @param y1 defines the left coordinate on Y axis
  4890. * @param x2 defines the right coordinate on X axis
  4891. * @param y2 defines the right coordinate on Y axis
  4892. * @returns the interpolated value
  4893. */
  4894. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4895. }
  4896. /**
  4897. * Defines angle representation
  4898. */
  4899. export class Angle {
  4900. private _radians;
  4901. /**
  4902. * Creates an Angle object of "radians" radians (float).
  4903. * @param radians the angle in radians
  4904. */
  4905. constructor(radians: number);
  4906. /**
  4907. * Get value in degrees
  4908. * @returns the Angle value in degrees (float)
  4909. */
  4910. degrees(): number;
  4911. /**
  4912. * Get value in radians
  4913. * @returns the Angle value in radians (float)
  4914. */
  4915. radians(): number;
  4916. /**
  4917. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4918. * @param a defines first point as the origin
  4919. * @param b defines point
  4920. * @returns a new Angle
  4921. */
  4922. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4923. /**
  4924. * Gets a new Angle object from the given float in radians
  4925. * @param radians defines the angle value in radians
  4926. * @returns a new Angle
  4927. */
  4928. static FromRadians(radians: number): Angle;
  4929. /**
  4930. * Gets a new Angle object from the given float in degrees
  4931. * @param degrees defines the angle value in degrees
  4932. * @returns a new Angle
  4933. */
  4934. static FromDegrees(degrees: number): Angle;
  4935. }
  4936. /**
  4937. * This represents an arc in a 2d space.
  4938. */
  4939. export class Arc2 {
  4940. /** Defines the start point of the arc */
  4941. startPoint: Vector2;
  4942. /** Defines the mid point of the arc */
  4943. midPoint: Vector2;
  4944. /** Defines the end point of the arc */
  4945. endPoint: Vector2;
  4946. /**
  4947. * Defines the center point of the arc.
  4948. */
  4949. centerPoint: Vector2;
  4950. /**
  4951. * Defines the radius of the arc.
  4952. */
  4953. radius: number;
  4954. /**
  4955. * Defines the angle of the arc (from mid point to end point).
  4956. */
  4957. angle: Angle;
  4958. /**
  4959. * Defines the start angle of the arc (from start point to middle point).
  4960. */
  4961. startAngle: Angle;
  4962. /**
  4963. * Defines the orientation of the arc (clock wise/counter clock wise).
  4964. */
  4965. orientation: Orientation;
  4966. /**
  4967. * Creates an Arc object from the three given points : start, middle and end.
  4968. * @param startPoint Defines the start point of the arc
  4969. * @param midPoint Defines the midlle point of the arc
  4970. * @param endPoint Defines the end point of the arc
  4971. */
  4972. constructor(
  4973. /** Defines the start point of the arc */
  4974. startPoint: Vector2,
  4975. /** Defines the mid point of the arc */
  4976. midPoint: Vector2,
  4977. /** Defines the end point of the arc */
  4978. endPoint: Vector2);
  4979. }
  4980. /**
  4981. * Represents a 2D path made up of multiple 2D points
  4982. */
  4983. export class Path2 {
  4984. private _points;
  4985. private _length;
  4986. /**
  4987. * If the path start and end point are the same
  4988. */
  4989. closed: boolean;
  4990. /**
  4991. * Creates a Path2 object from the starting 2D coordinates x and y.
  4992. * @param x the starting points x value
  4993. * @param y the starting points y value
  4994. */
  4995. constructor(x: number, y: number);
  4996. /**
  4997. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4998. * @param x the added points x value
  4999. * @param y the added points y value
  5000. * @returns the updated Path2.
  5001. */
  5002. addLineTo(x: number, y: number): Path2;
  5003. /**
  5004. * 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.
  5005. * @param midX middle point x value
  5006. * @param midY middle point y value
  5007. * @param endX end point x value
  5008. * @param endY end point y value
  5009. * @param numberOfSegments (default: 36)
  5010. * @returns the updated Path2.
  5011. */
  5012. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5013. /**
  5014. * Closes the Path2.
  5015. * @returns the Path2.
  5016. */
  5017. close(): Path2;
  5018. /**
  5019. * Gets the sum of the distance between each sequential point in the path
  5020. * @returns the Path2 total length (float).
  5021. */
  5022. length(): number;
  5023. /**
  5024. * Gets the points which construct the path
  5025. * @returns the Path2 internal array of points.
  5026. */
  5027. getPoints(): Vector2[];
  5028. /**
  5029. * Retreives the point at the distance aways from the starting point
  5030. * @param normalizedLengthPosition the length along the path to retreive the point from
  5031. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5032. */
  5033. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5034. /**
  5035. * Creates a new path starting from an x and y position
  5036. * @param x starting x value
  5037. * @param y starting y value
  5038. * @returns a new Path2 starting at the coordinates (x, y).
  5039. */
  5040. static StartingAt(x: number, y: number): Path2;
  5041. }
  5042. /**
  5043. * Represents a 3D path made up of multiple 3D points
  5044. */
  5045. export class Path3D {
  5046. /**
  5047. * an array of Vector3, the curve axis of the Path3D
  5048. */
  5049. path: Vector3[];
  5050. private _curve;
  5051. private _distances;
  5052. private _tangents;
  5053. private _normals;
  5054. private _binormals;
  5055. private _raw;
  5056. private _alignTangentsWithPath;
  5057. private readonly _pointAtData;
  5058. /**
  5059. * new Path3D(path, normal, raw)
  5060. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5061. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5062. * @param path an array of Vector3, the curve axis of the Path3D
  5063. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5064. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5065. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5066. */
  5067. constructor(
  5068. /**
  5069. * an array of Vector3, the curve axis of the Path3D
  5070. */
  5071. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5072. /**
  5073. * Returns the Path3D array of successive Vector3 designing its curve.
  5074. * @returns the Path3D array of successive Vector3 designing its curve.
  5075. */
  5076. getCurve(): Vector3[];
  5077. /**
  5078. * Returns the Path3D array of successive Vector3 designing its curve.
  5079. * @returns the Path3D array of successive Vector3 designing its curve.
  5080. */
  5081. getPoints(): Vector3[];
  5082. /**
  5083. * @returns the computed length (float) of the path.
  5084. */
  5085. length(): number;
  5086. /**
  5087. * Returns an array populated with tangent vectors on each Path3D curve point.
  5088. * @returns an array populated with tangent vectors on each Path3D curve point.
  5089. */
  5090. getTangents(): Vector3[];
  5091. /**
  5092. * Returns an array populated with normal vectors on each Path3D curve point.
  5093. * @returns an array populated with normal vectors on each Path3D curve point.
  5094. */
  5095. getNormals(): Vector3[];
  5096. /**
  5097. * Returns an array populated with binormal vectors on each Path3D curve point.
  5098. * @returns an array populated with binormal vectors on each Path3D curve point.
  5099. */
  5100. getBinormals(): Vector3[];
  5101. /**
  5102. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5103. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5104. */
  5105. getDistances(): number[];
  5106. /**
  5107. * Returns an interpolated point along this path
  5108. * @param position the position of the point along this path, from 0.0 to 1.0
  5109. * @returns a new Vector3 as the point
  5110. */
  5111. getPointAt(position: number): Vector3;
  5112. /**
  5113. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5114. * @param position the position of the point along this path, from 0.0 to 1.0
  5115. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5116. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5117. */
  5118. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5119. /**
  5120. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5121. * @param position the position of the point along this path, from 0.0 to 1.0
  5122. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5123. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5124. */
  5125. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5126. /**
  5127. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5128. * @param position the position of the point along this path, from 0.0 to 1.0
  5129. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5130. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5131. */
  5132. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5133. /**
  5134. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5135. * @param position the position of the point along this path, from 0.0 to 1.0
  5136. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5137. */
  5138. getDistanceAt(position: number): number;
  5139. /**
  5140. * Returns the array index of the previous point of an interpolated point along this path
  5141. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5142. * @returns the array index
  5143. */
  5144. getPreviousPointIndexAt(position: number): number;
  5145. /**
  5146. * 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)
  5147. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5148. * @returns the sub position
  5149. */
  5150. getSubPositionAt(position: number): number;
  5151. /**
  5152. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5153. * @param target the vector of which to get the closest position to
  5154. * @returns the position of the closest virtual point on this path to the target vector
  5155. */
  5156. getClosestPositionTo(target: Vector3): number;
  5157. /**
  5158. * Returns a sub path (slice) of this path
  5159. * @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
  5160. * @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
  5161. * @returns a sub path (slice) of this path
  5162. */
  5163. slice(start?: number, end?: number): Path3D;
  5164. /**
  5165. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5166. * @param path path which all values are copied into the curves points
  5167. * @param firstNormal which should be projected onto the curve
  5168. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5169. * @returns the same object updated.
  5170. */
  5171. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5172. private _compute;
  5173. private _getFirstNonNullVector;
  5174. private _getLastNonNullVector;
  5175. private _normalVector;
  5176. /**
  5177. * Updates the point at data for an interpolated point along this curve
  5178. * @param position the position of the point along this curve, from 0.0 to 1.0
  5179. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5180. * @returns the (updated) point at data
  5181. */
  5182. private _updatePointAtData;
  5183. /**
  5184. * Updates the point at data from the specified parameters
  5185. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5186. * @param point the interpolated point
  5187. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5188. */
  5189. private _setPointAtData;
  5190. /**
  5191. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5192. */
  5193. private _updateInterpolationMatrix;
  5194. }
  5195. /**
  5196. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5197. * A Curve3 is designed from a series of successive Vector3.
  5198. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5199. */
  5200. export class Curve3 {
  5201. private _points;
  5202. private _length;
  5203. /**
  5204. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5205. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5206. * @param v1 (Vector3) the control point
  5207. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5208. * @param nbPoints (integer) the wanted number of points in the curve
  5209. * @returns the created Curve3
  5210. */
  5211. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5212. /**
  5213. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5214. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5215. * @param v1 (Vector3) the first control point
  5216. * @param v2 (Vector3) the second control point
  5217. * @param v3 (Vector3) the end point of the Cubic Bezier
  5218. * @param nbPoints (integer) the wanted number of points in the curve
  5219. * @returns the created Curve3
  5220. */
  5221. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5222. /**
  5223. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5224. * @param p1 (Vector3) the origin point of the Hermite Spline
  5225. * @param t1 (Vector3) the tangent vector at the origin point
  5226. * @param p2 (Vector3) the end point of the Hermite Spline
  5227. * @param t2 (Vector3) the tangent vector at the end point
  5228. * @param nbPoints (integer) the wanted number of points in the curve
  5229. * @returns the created Curve3
  5230. */
  5231. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5232. /**
  5233. * Returns a Curve3 object along a CatmullRom Spline curve :
  5234. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5235. * @param nbPoints (integer) the wanted number of points between each curve control points
  5236. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5237. * @returns the created Curve3
  5238. */
  5239. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5240. /**
  5241. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5242. * A Curve3 is designed from a series of successive Vector3.
  5243. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5244. * @param points points which make up the curve
  5245. */
  5246. constructor(points: Vector3[]);
  5247. /**
  5248. * @returns the Curve3 stored array of successive Vector3
  5249. */
  5250. getPoints(): Vector3[];
  5251. /**
  5252. * @returns the computed length (float) of the curve.
  5253. */
  5254. length(): number;
  5255. /**
  5256. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5257. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5258. * curveA and curveB keep unchanged.
  5259. * @param curve the curve to continue from this curve
  5260. * @returns the newly constructed curve
  5261. */
  5262. continue(curve: DeepImmutable<Curve3>): Curve3;
  5263. private _computeLength;
  5264. }
  5265. }
  5266. declare module BABYLON {
  5267. /**
  5268. * This represents the main contract an easing function should follow.
  5269. * Easing functions are used throughout the animation system.
  5270. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5271. */
  5272. export interface IEasingFunction {
  5273. /**
  5274. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5275. * of the easing function.
  5276. * The link below provides some of the most common examples of easing functions.
  5277. * @see https://easings.net/
  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. * Base class used for every default easing function.
  5285. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5286. */
  5287. export class EasingFunction implements IEasingFunction {
  5288. /**
  5289. * Interpolation follows the mathematical formula associated with the easing function.
  5290. */
  5291. static readonly EASINGMODE_EASEIN: number;
  5292. /**
  5293. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5294. */
  5295. static readonly EASINGMODE_EASEOUT: number;
  5296. /**
  5297. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5298. */
  5299. static readonly EASINGMODE_EASEINOUT: number;
  5300. private _easingMode;
  5301. /**
  5302. * Sets the easing mode of the current function.
  5303. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5304. */
  5305. setEasingMode(easingMode: number): void;
  5306. /**
  5307. * Gets the current easing mode.
  5308. * @returns the easing mode
  5309. */
  5310. getEasingMode(): number;
  5311. /**
  5312. * @hidden
  5313. */
  5314. easeInCore(gradient: number): number;
  5315. /**
  5316. * Given an input gradient between 0 and 1, this returns the corresponding value
  5317. * of the easing function.
  5318. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5319. * @returns the corresponding value on the curve defined by the easing function
  5320. */
  5321. ease(gradient: number): number;
  5322. }
  5323. /**
  5324. * Easing function with a circle shape (see link below).
  5325. * @see https://easings.net/#easeInCirc
  5326. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5327. */
  5328. export class CircleEase extends EasingFunction implements IEasingFunction {
  5329. /** @hidden */
  5330. easeInCore(gradient: number): number;
  5331. }
  5332. /**
  5333. * Easing function with a ease back shape (see link below).
  5334. * @see https://easings.net/#easeInBack
  5335. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5336. */
  5337. export class BackEase extends EasingFunction implements IEasingFunction {
  5338. /** Defines the amplitude of the function */
  5339. amplitude: number;
  5340. /**
  5341. * Instantiates a back ease easing
  5342. * @see https://easings.net/#easeInBack
  5343. * @param amplitude Defines the amplitude of the function
  5344. */
  5345. constructor(
  5346. /** Defines the amplitude of the function */
  5347. amplitude?: number);
  5348. /** @hidden */
  5349. easeInCore(gradient: number): number;
  5350. }
  5351. /**
  5352. * Easing function with a bouncing shape (see link below).
  5353. * @see https://easings.net/#easeInBounce
  5354. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5355. */
  5356. export class BounceEase extends EasingFunction implements IEasingFunction {
  5357. /** Defines the number of bounces */
  5358. bounces: number;
  5359. /** Defines the amplitude of the bounce */
  5360. bounciness: number;
  5361. /**
  5362. * Instantiates a bounce easing
  5363. * @see https://easings.net/#easeInBounce
  5364. * @param bounces Defines the number of bounces
  5365. * @param bounciness Defines the amplitude of the bounce
  5366. */
  5367. constructor(
  5368. /** Defines the number of bounces */
  5369. bounces?: number,
  5370. /** Defines the amplitude of the bounce */
  5371. bounciness?: number);
  5372. /** @hidden */
  5373. easeInCore(gradient: number): number;
  5374. }
  5375. /**
  5376. * Easing function with a power of 3 shape (see link below).
  5377. * @see https://easings.net/#easeInCubic
  5378. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5379. */
  5380. export class CubicEase extends EasingFunction implements IEasingFunction {
  5381. /** @hidden */
  5382. easeInCore(gradient: number): number;
  5383. }
  5384. /**
  5385. * Easing function with an elastic shape (see link below).
  5386. * @see https://easings.net/#easeInElastic
  5387. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5388. */
  5389. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5390. /** Defines the number of oscillations*/
  5391. oscillations: number;
  5392. /** Defines the amplitude of the oscillations*/
  5393. springiness: number;
  5394. /**
  5395. * Instantiates an elastic easing function
  5396. * @see https://easings.net/#easeInElastic
  5397. * @param oscillations Defines the number of oscillations
  5398. * @param springiness Defines the amplitude of the oscillations
  5399. */
  5400. constructor(
  5401. /** Defines the number of oscillations*/
  5402. oscillations?: number,
  5403. /** Defines the amplitude of the oscillations*/
  5404. springiness?: number);
  5405. /** @hidden */
  5406. easeInCore(gradient: number): number;
  5407. }
  5408. /**
  5409. * Easing function with an exponential shape (see link below).
  5410. * @see https://easings.net/#easeInExpo
  5411. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5412. */
  5413. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5414. /** Defines the exponent of the function */
  5415. exponent: number;
  5416. /**
  5417. * Instantiates an exponential easing function
  5418. * @see https://easings.net/#easeInExpo
  5419. * @param exponent Defines the exponent of the function
  5420. */
  5421. constructor(
  5422. /** Defines the exponent of the function */
  5423. exponent?: number);
  5424. /** @hidden */
  5425. easeInCore(gradient: number): number;
  5426. }
  5427. /**
  5428. * Easing function with a power shape (see link below).
  5429. * @see https://easings.net/#easeInQuad
  5430. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5431. */
  5432. export class PowerEase extends EasingFunction implements IEasingFunction {
  5433. /** Defines the power of the function */
  5434. power: number;
  5435. /**
  5436. * Instantiates an power base easing function
  5437. * @see https://easings.net/#easeInQuad
  5438. * @param power Defines the power of the function
  5439. */
  5440. constructor(
  5441. /** Defines the power of the function */
  5442. power?: number);
  5443. /** @hidden */
  5444. easeInCore(gradient: number): number;
  5445. }
  5446. /**
  5447. * Easing function with a power of 2 shape (see link below).
  5448. * @see https://easings.net/#easeInQuad
  5449. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5450. */
  5451. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5452. /** @hidden */
  5453. easeInCore(gradient: number): number;
  5454. }
  5455. /**
  5456. * Easing function with a power of 4 shape (see link below).
  5457. * @see https://easings.net/#easeInQuart
  5458. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5459. */
  5460. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5461. /** @hidden */
  5462. easeInCore(gradient: number): number;
  5463. }
  5464. /**
  5465. * Easing function with a power of 5 shape (see link below).
  5466. * @see https://easings.net/#easeInQuint
  5467. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5468. */
  5469. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5470. /** @hidden */
  5471. easeInCore(gradient: number): number;
  5472. }
  5473. /**
  5474. * Easing function with a sin shape (see link below).
  5475. * @see https://easings.net/#easeInSine
  5476. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5477. */
  5478. export class SineEase extends EasingFunction implements IEasingFunction {
  5479. /** @hidden */
  5480. easeInCore(gradient: number): number;
  5481. }
  5482. /**
  5483. * Easing function with a bezier shape (see link below).
  5484. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5485. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5486. */
  5487. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5488. /** Defines the x component of the start tangent in the bezier curve */
  5489. x1: number;
  5490. /** Defines the y component of the start tangent in the bezier curve */
  5491. y1: number;
  5492. /** Defines the x component of the end tangent in the bezier curve */
  5493. x2: number;
  5494. /** Defines the y component of the end tangent in the bezier curve */
  5495. y2: number;
  5496. /**
  5497. * Instantiates a bezier function
  5498. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5499. * @param x1 Defines the x component of the start tangent in the bezier curve
  5500. * @param y1 Defines the y component of the start tangent in the bezier curve
  5501. * @param x2 Defines the x component of the end tangent in the bezier curve
  5502. * @param y2 Defines the y component of the end tangent in the bezier curve
  5503. */
  5504. constructor(
  5505. /** Defines the x component of the start tangent in the bezier curve */
  5506. x1?: number,
  5507. /** Defines the y component of the start tangent in the bezier curve */
  5508. y1?: number,
  5509. /** Defines the x component of the end tangent in the bezier curve */
  5510. x2?: number,
  5511. /** Defines the y component of the end tangent in the bezier curve */
  5512. y2?: number);
  5513. /** @hidden */
  5514. easeInCore(gradient: number): number;
  5515. }
  5516. }
  5517. declare module BABYLON {
  5518. /**
  5519. * Class used to hold a RBG color
  5520. */
  5521. export class Color3 {
  5522. /**
  5523. * Defines the red component (between 0 and 1, default is 0)
  5524. */
  5525. r: number;
  5526. /**
  5527. * Defines the green component (between 0 and 1, default is 0)
  5528. */
  5529. g: number;
  5530. /**
  5531. * Defines the blue component (between 0 and 1, default is 0)
  5532. */
  5533. b: number;
  5534. /**
  5535. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5536. * @param r defines the red component (between 0 and 1, default is 0)
  5537. * @param g defines the green component (between 0 and 1, default is 0)
  5538. * @param b defines the blue component (between 0 and 1, default is 0)
  5539. */
  5540. constructor(
  5541. /**
  5542. * Defines the red component (between 0 and 1, default is 0)
  5543. */
  5544. r?: number,
  5545. /**
  5546. * Defines the green component (between 0 and 1, default is 0)
  5547. */
  5548. g?: number,
  5549. /**
  5550. * Defines the blue component (between 0 and 1, default is 0)
  5551. */
  5552. b?: number);
  5553. /**
  5554. * Creates a string with the Color3 current values
  5555. * @returns the string representation of the Color3 object
  5556. */
  5557. toString(): string;
  5558. /**
  5559. * Returns the string "Color3"
  5560. * @returns "Color3"
  5561. */
  5562. getClassName(): string;
  5563. /**
  5564. * Compute the Color3 hash code
  5565. * @returns an unique number that can be used to hash Color3 objects
  5566. */
  5567. getHashCode(): number;
  5568. /**
  5569. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5570. * @param array defines the array where to store the r,g,b components
  5571. * @param index defines an optional index in the target array to define where to start storing values
  5572. * @returns the current Color3 object
  5573. */
  5574. toArray(array: FloatArray, index?: number): Color3;
  5575. /**
  5576. * Update the current color with values stored in an array from the starting index of the given array
  5577. * @param array defines the source array
  5578. * @param offset defines an offset in the source array
  5579. * @returns the current Color3 object
  5580. */
  5581. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5582. /**
  5583. * Returns a new Color4 object from the current Color3 and the given alpha
  5584. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5585. * @returns a new Color4 object
  5586. */
  5587. toColor4(alpha?: number): Color4;
  5588. /**
  5589. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5590. * @returns the new array
  5591. */
  5592. asArray(): number[];
  5593. /**
  5594. * Returns the luminance value
  5595. * @returns a float value
  5596. */
  5597. toLuminance(): number;
  5598. /**
  5599. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5600. * @param otherColor defines the second operand
  5601. * @returns the new Color3 object
  5602. */
  5603. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5604. /**
  5605. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5606. * @param otherColor defines the second operand
  5607. * @param result defines the Color3 object where to store the result
  5608. * @returns the current Color3
  5609. */
  5610. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5611. /**
  5612. * Determines equality between Color3 objects
  5613. * @param otherColor defines the second operand
  5614. * @returns true if the rgb values are equal to the given ones
  5615. */
  5616. equals(otherColor: DeepImmutable<Color3>): boolean;
  5617. /**
  5618. * Determines equality between the current Color3 object and a set of r,b,g values
  5619. * @param r defines the red component to check
  5620. * @param g defines the green component to check
  5621. * @param b defines the blue component to check
  5622. * @returns true if the rgb values are equal to the given ones
  5623. */
  5624. equalsFloats(r: number, g: number, b: number): boolean;
  5625. /**
  5626. * Multiplies in place each rgb value by scale
  5627. * @param scale defines the scaling factor
  5628. * @returns the updated Color3
  5629. */
  5630. scale(scale: number): Color3;
  5631. /**
  5632. * Multiplies the rgb values by scale and stores the result into "result"
  5633. * @param scale defines the scaling factor
  5634. * @param result defines the Color3 object where to store the result
  5635. * @returns the unmodified current Color3
  5636. */
  5637. scaleToRef(scale: number, result: Color3): Color3;
  5638. /**
  5639. * Scale the current Color3 values by a factor and add the result to a given Color3
  5640. * @param scale defines the scale factor
  5641. * @param result defines color to store the result into
  5642. * @returns the unmodified current Color3
  5643. */
  5644. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5645. /**
  5646. * Clamps the rgb values by the min and max values and stores the result into "result"
  5647. * @param min defines minimum clamping value (default is 0)
  5648. * @param max defines maximum clamping value (default is 1)
  5649. * @param result defines color to store the result into
  5650. * @returns the original Color3
  5651. */
  5652. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5653. /**
  5654. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5655. * @param otherColor defines the second operand
  5656. * @returns the new Color3
  5657. */
  5658. add(otherColor: DeepImmutable<Color3>): Color3;
  5659. /**
  5660. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5661. * @param otherColor defines the second operand
  5662. * @param result defines Color3 object to store the result into
  5663. * @returns the unmodified current Color3
  5664. */
  5665. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5666. /**
  5667. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5668. * @param otherColor defines the second operand
  5669. * @returns the new Color3
  5670. */
  5671. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5672. /**
  5673. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5674. * @param otherColor defines the second operand
  5675. * @param result defines Color3 object to store the result into
  5676. * @returns the unmodified current Color3
  5677. */
  5678. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5679. /**
  5680. * Copy the current object
  5681. * @returns a new Color3 copied the current one
  5682. */
  5683. clone(): Color3;
  5684. /**
  5685. * Copies the rgb values from the source in the current Color3
  5686. * @param source defines the source Color3 object
  5687. * @returns the updated Color3 object
  5688. */
  5689. copyFrom(source: DeepImmutable<Color3>): Color3;
  5690. /**
  5691. * Updates the Color3 rgb values from the given floats
  5692. * @param r defines the red component to read from
  5693. * @param g defines the green component to read from
  5694. * @param b defines the blue component to read from
  5695. * @returns the current Color3 object
  5696. */
  5697. copyFromFloats(r: number, g: number, b: number): Color3;
  5698. /**
  5699. * Updates the Color3 rgb values from the given floats
  5700. * @param r defines the red component to read from
  5701. * @param g defines the green component to read from
  5702. * @param b defines the blue component to read from
  5703. * @returns the current Color3 object
  5704. */
  5705. set(r: number, g: number, b: number): Color3;
  5706. /**
  5707. * Compute the Color3 hexadecimal code as a string
  5708. * @returns a string containing the hexadecimal representation of the Color3 object
  5709. */
  5710. toHexString(): string;
  5711. /**
  5712. * Computes a new Color3 converted from the current one to linear space
  5713. * @returns a new Color3 object
  5714. */
  5715. toLinearSpace(): Color3;
  5716. /**
  5717. * Converts current color in rgb space to HSV values
  5718. * @returns a new color3 representing the HSV values
  5719. */
  5720. toHSV(): Color3;
  5721. /**
  5722. * Converts current color in rgb space to HSV values
  5723. * @param result defines the Color3 where to store the HSV values
  5724. */
  5725. toHSVToRef(result: Color3): void;
  5726. /**
  5727. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5728. * @param convertedColor defines the Color3 object where to store the linear space version
  5729. * @returns the unmodified Color3
  5730. */
  5731. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5732. /**
  5733. * Computes a new Color3 converted from the current one to gamma space
  5734. * @returns a new Color3 object
  5735. */
  5736. toGammaSpace(): Color3;
  5737. /**
  5738. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5739. * @param convertedColor defines the Color3 object where to store the gamma space version
  5740. * @returns the unmodified Color3
  5741. */
  5742. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5743. private static _BlackReadOnly;
  5744. /**
  5745. * Convert Hue, saturation and value to a Color3 (RGB)
  5746. * @param hue defines the hue
  5747. * @param saturation defines the saturation
  5748. * @param value defines the value
  5749. * @param result defines the Color3 where to store the RGB values
  5750. */
  5751. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5752. /**
  5753. * Creates a new Color3 from the string containing valid hexadecimal values
  5754. * @param hex defines a string containing valid hexadecimal values
  5755. * @returns a new Color3 object
  5756. */
  5757. static FromHexString(hex: string): Color3;
  5758. /**
  5759. * Creates a new Color3 from the starting index of the given array
  5760. * @param array defines the source array
  5761. * @param offset defines an offset in the source array
  5762. * @returns a new Color3 object
  5763. */
  5764. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5765. /**
  5766. * Creates a new Color3 from the starting index element of the given array
  5767. * @param array defines the source array to read from
  5768. * @param offset defines the offset in the source array
  5769. * @param result defines the target Color3 object
  5770. */
  5771. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5772. /**
  5773. * Creates a new Color3 from integer values (< 256)
  5774. * @param r defines the red component to read from (value between 0 and 255)
  5775. * @param g defines the green component to read from (value between 0 and 255)
  5776. * @param b defines the blue component to read from (value between 0 and 255)
  5777. * @returns a new Color3 object
  5778. */
  5779. static FromInts(r: number, g: number, b: number): Color3;
  5780. /**
  5781. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5782. * @param start defines the start Color3 value
  5783. * @param end defines the end Color3 value
  5784. * @param amount defines the gradient value between start and end
  5785. * @returns a new Color3 object
  5786. */
  5787. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5788. /**
  5789. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5790. * @param left defines the start value
  5791. * @param right defines the end value
  5792. * @param amount defines the gradient factor
  5793. * @param result defines the Color3 object where to store the result
  5794. */
  5795. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5796. /**
  5797. * Returns a Color3 value containing a red color
  5798. * @returns a new Color3 object
  5799. */
  5800. static Red(): Color3;
  5801. /**
  5802. * Returns a Color3 value containing a green color
  5803. * @returns a new Color3 object
  5804. */
  5805. static Green(): Color3;
  5806. /**
  5807. * Returns a Color3 value containing a blue color
  5808. * @returns a new Color3 object
  5809. */
  5810. static Blue(): Color3;
  5811. /**
  5812. * Returns a Color3 value containing a black color
  5813. * @returns a new Color3 object
  5814. */
  5815. static Black(): Color3;
  5816. /**
  5817. * Gets a Color3 value containing a black color that must not be updated
  5818. */
  5819. static get BlackReadOnly(): DeepImmutable<Color3>;
  5820. /**
  5821. * Returns a Color3 value containing a white color
  5822. * @returns a new Color3 object
  5823. */
  5824. static White(): Color3;
  5825. /**
  5826. * Returns a Color3 value containing a purple color
  5827. * @returns a new Color3 object
  5828. */
  5829. static Purple(): Color3;
  5830. /**
  5831. * Returns a Color3 value containing a magenta color
  5832. * @returns a new Color3 object
  5833. */
  5834. static Magenta(): Color3;
  5835. /**
  5836. * Returns a Color3 value containing a yellow color
  5837. * @returns a new Color3 object
  5838. */
  5839. static Yellow(): Color3;
  5840. /**
  5841. * Returns a Color3 value containing a gray color
  5842. * @returns a new Color3 object
  5843. */
  5844. static Gray(): Color3;
  5845. /**
  5846. * Returns a Color3 value containing a teal color
  5847. * @returns a new Color3 object
  5848. */
  5849. static Teal(): Color3;
  5850. /**
  5851. * Returns a Color3 value containing a random color
  5852. * @returns a new Color3 object
  5853. */
  5854. static Random(): Color3;
  5855. }
  5856. /**
  5857. * Class used to hold a RBGA color
  5858. */
  5859. export class Color4 {
  5860. /**
  5861. * Defines the red component (between 0 and 1, default is 0)
  5862. */
  5863. r: number;
  5864. /**
  5865. * Defines the green component (between 0 and 1, default is 0)
  5866. */
  5867. g: number;
  5868. /**
  5869. * Defines the blue component (between 0 and 1, default is 0)
  5870. */
  5871. b: number;
  5872. /**
  5873. * Defines the alpha component (between 0 and 1, default is 1)
  5874. */
  5875. a: number;
  5876. /**
  5877. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5878. * @param r defines the red component (between 0 and 1, default is 0)
  5879. * @param g defines the green component (between 0 and 1, default is 0)
  5880. * @param b defines the blue component (between 0 and 1, default is 0)
  5881. * @param a defines the alpha component (between 0 and 1, default is 1)
  5882. */
  5883. constructor(
  5884. /**
  5885. * Defines the red component (between 0 and 1, default is 0)
  5886. */
  5887. r?: number,
  5888. /**
  5889. * Defines the green component (between 0 and 1, default is 0)
  5890. */
  5891. g?: number,
  5892. /**
  5893. * Defines the blue component (between 0 and 1, default is 0)
  5894. */
  5895. b?: number,
  5896. /**
  5897. * Defines the alpha component (between 0 and 1, default is 1)
  5898. */
  5899. a?: number);
  5900. /**
  5901. * Adds in place the given Color4 values to the current Color4 object
  5902. * @param right defines the second operand
  5903. * @returns the current updated Color4 object
  5904. */
  5905. addInPlace(right: DeepImmutable<Color4>): Color4;
  5906. /**
  5907. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5908. * @returns the new array
  5909. */
  5910. asArray(): number[];
  5911. /**
  5912. * Stores from the starting index in the given array the Color4 successive values
  5913. * @param array defines the array where to store the r,g,b components
  5914. * @param index defines an optional index in the target array to define where to start storing values
  5915. * @returns the current Color4 object
  5916. */
  5917. toArray(array: number[], index?: number): Color4;
  5918. /**
  5919. * Update the current color with values stored in an array from the starting index of the given array
  5920. * @param array defines the source array
  5921. * @param offset defines an offset in the source array
  5922. * @returns the current Color4 object
  5923. */
  5924. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5925. /**
  5926. * Determines equality between Color4 objects
  5927. * @param otherColor defines the second operand
  5928. * @returns true if the rgba values are equal to the given ones
  5929. */
  5930. equals(otherColor: DeepImmutable<Color4>): boolean;
  5931. /**
  5932. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5933. * @param right defines the second operand
  5934. * @returns a new Color4 object
  5935. */
  5936. add(right: DeepImmutable<Color4>): Color4;
  5937. /**
  5938. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5939. * @param right defines the second operand
  5940. * @returns a new Color4 object
  5941. */
  5942. subtract(right: DeepImmutable<Color4>): Color4;
  5943. /**
  5944. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5945. * @param right defines the second operand
  5946. * @param result defines the Color4 object where to store the result
  5947. * @returns the current Color4 object
  5948. */
  5949. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5950. /**
  5951. * Creates a new Color4 with the current Color4 values multiplied by scale
  5952. * @param scale defines the scaling factor to apply
  5953. * @returns a new Color4 object
  5954. */
  5955. scale(scale: number): Color4;
  5956. /**
  5957. * Multiplies the current Color4 values by scale and stores the result in "result"
  5958. * @param scale defines the scaling factor to apply
  5959. * @param result defines the Color4 object where to store the result
  5960. * @returns the current unmodified Color4
  5961. */
  5962. scaleToRef(scale: number, result: Color4): Color4;
  5963. /**
  5964. * Scale the current Color4 values by a factor and add the result to a given Color4
  5965. * @param scale defines the scale factor
  5966. * @param result defines the Color4 object where to store the result
  5967. * @returns the unmodified current Color4
  5968. */
  5969. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5970. /**
  5971. * Clamps the rgb values by the min and max values and stores the result into "result"
  5972. * @param min defines minimum clamping value (default is 0)
  5973. * @param max defines maximum clamping value (default is 1)
  5974. * @param result defines color to store the result into.
  5975. * @returns the cuurent Color4
  5976. */
  5977. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5978. /**
  5979. * Multipy an Color4 value by another and return a new Color4 object
  5980. * @param color defines the Color4 value to multiply by
  5981. * @returns a new Color4 object
  5982. */
  5983. multiply(color: Color4): Color4;
  5984. /**
  5985. * Multipy a Color4 value by another and push the result in a reference value
  5986. * @param color defines the Color4 value to multiply by
  5987. * @param result defines the Color4 to fill the result in
  5988. * @returns the result Color4
  5989. */
  5990. multiplyToRef(color: Color4, result: Color4): Color4;
  5991. /**
  5992. * Creates a string with the Color4 current values
  5993. * @returns the string representation of the Color4 object
  5994. */
  5995. toString(): string;
  5996. /**
  5997. * Returns the string "Color4"
  5998. * @returns "Color4"
  5999. */
  6000. getClassName(): string;
  6001. /**
  6002. * Compute the Color4 hash code
  6003. * @returns an unique number that can be used to hash Color4 objects
  6004. */
  6005. getHashCode(): number;
  6006. /**
  6007. * Creates a new Color4 copied from the current one
  6008. * @returns a new Color4 object
  6009. */
  6010. clone(): Color4;
  6011. /**
  6012. * Copies the given Color4 values into the current one
  6013. * @param source defines the source Color4 object
  6014. * @returns the current updated Color4 object
  6015. */
  6016. copyFrom(source: Color4): Color4;
  6017. /**
  6018. * Copies the given float values into the current one
  6019. * @param r defines the red component to read from
  6020. * @param g defines the green component to read from
  6021. * @param b defines the blue component to read from
  6022. * @param a defines the alpha component to read from
  6023. * @returns the current updated Color4 object
  6024. */
  6025. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6026. /**
  6027. * Copies the given float values into the current one
  6028. * @param r defines the red component to read from
  6029. * @param g defines the green component to read from
  6030. * @param b defines the blue component to read from
  6031. * @param a defines the alpha component to read from
  6032. * @returns the current updated Color4 object
  6033. */
  6034. set(r: number, g: number, b: number, a: number): Color4;
  6035. /**
  6036. * Compute the Color4 hexadecimal code as a string
  6037. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6038. * @returns a string containing the hexadecimal representation of the Color4 object
  6039. */
  6040. toHexString(returnAsColor3?: boolean): string;
  6041. /**
  6042. * Computes a new Color4 converted from the current one to linear space
  6043. * @returns a new Color4 object
  6044. */
  6045. toLinearSpace(): Color4;
  6046. /**
  6047. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6048. * @param convertedColor defines the Color4 object where to store the linear space version
  6049. * @returns the unmodified Color4
  6050. */
  6051. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6052. /**
  6053. * Computes a new Color4 converted from the current one to gamma space
  6054. * @returns a new Color4 object
  6055. */
  6056. toGammaSpace(): Color4;
  6057. /**
  6058. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6059. * @param convertedColor defines the Color4 object where to store the gamma space version
  6060. * @returns the unmodified Color4
  6061. */
  6062. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6063. /**
  6064. * Creates a new Color4 from the string containing valid hexadecimal values
  6065. * @param hex defines a string containing valid hexadecimal values
  6066. * @returns a new Color4 object
  6067. */
  6068. static FromHexString(hex: string): Color4;
  6069. /**
  6070. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6071. * @param left defines the start value
  6072. * @param right defines the end value
  6073. * @param amount defines the gradient factor
  6074. * @returns a new Color4 object
  6075. */
  6076. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6077. /**
  6078. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6079. * @param left defines the start value
  6080. * @param right defines the end value
  6081. * @param amount defines the gradient factor
  6082. * @param result defines the Color4 object where to store data
  6083. */
  6084. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6085. /**
  6086. * Creates a new Color4 from a Color3 and an alpha value
  6087. * @param color3 defines the source Color3 to read from
  6088. * @param alpha defines the alpha component (1.0 by default)
  6089. * @returns a new Color4 object
  6090. */
  6091. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6092. /**
  6093. * Creates a new Color4 from the starting index element of the given array
  6094. * @param array defines the source array to read from
  6095. * @param offset defines the offset in the source array
  6096. * @returns a new Color4 object
  6097. */
  6098. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6099. /**
  6100. * Creates a new Color4 from the starting index element of the given array
  6101. * @param array defines the source array to read from
  6102. * @param offset defines the offset in the source array
  6103. * @param result defines the target Color4 object
  6104. */
  6105. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6106. /**
  6107. * Creates a new Color3 from integer values (< 256)
  6108. * @param r defines the red component to read from (value between 0 and 255)
  6109. * @param g defines the green component to read from (value between 0 and 255)
  6110. * @param b defines the blue component to read from (value between 0 and 255)
  6111. * @param a defines the alpha component to read from (value between 0 and 255)
  6112. * @returns a new Color3 object
  6113. */
  6114. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6115. /**
  6116. * Check the content of a given array and convert it to an array containing RGBA data
  6117. * If the original array was already containing count * 4 values then it is returned directly
  6118. * @param colors defines the array to check
  6119. * @param count defines the number of RGBA data to expect
  6120. * @returns an array containing count * 4 values (RGBA)
  6121. */
  6122. static CheckColors4(colors: number[], count: number): number[];
  6123. }
  6124. /**
  6125. * @hidden
  6126. */
  6127. export class TmpColors {
  6128. static Color3: Color3[];
  6129. static Color4: Color4[];
  6130. }
  6131. }
  6132. declare module BABYLON {
  6133. /**
  6134. * Defines an interface which represents an animation key frame
  6135. */
  6136. export interface IAnimationKey {
  6137. /**
  6138. * Frame of the key frame
  6139. */
  6140. frame: number;
  6141. /**
  6142. * Value at the specifies key frame
  6143. */
  6144. value: any;
  6145. /**
  6146. * The input tangent for the cubic hermite spline
  6147. */
  6148. inTangent?: any;
  6149. /**
  6150. * The output tangent for the cubic hermite spline
  6151. */
  6152. outTangent?: any;
  6153. /**
  6154. * The animation interpolation type
  6155. */
  6156. interpolation?: AnimationKeyInterpolation;
  6157. }
  6158. /**
  6159. * Enum for the animation key frame interpolation type
  6160. */
  6161. export enum AnimationKeyInterpolation {
  6162. /**
  6163. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6164. */
  6165. STEP = 1
  6166. }
  6167. }
  6168. declare module BABYLON {
  6169. /**
  6170. * Represents the range of an animation
  6171. */
  6172. export class AnimationRange {
  6173. /**The name of the animation range**/
  6174. name: string;
  6175. /**The starting frame of the animation */
  6176. from: number;
  6177. /**The ending frame of the animation*/
  6178. to: number;
  6179. /**
  6180. * Initializes the range of an animation
  6181. * @param name The name of the animation range
  6182. * @param from The starting frame of the animation
  6183. * @param to The ending frame of the animation
  6184. */
  6185. constructor(
  6186. /**The name of the animation range**/
  6187. name: string,
  6188. /**The starting frame of the animation */
  6189. from: number,
  6190. /**The ending frame of the animation*/
  6191. to: number);
  6192. /**
  6193. * Makes a copy of the animation range
  6194. * @returns A copy of the animation range
  6195. */
  6196. clone(): AnimationRange;
  6197. }
  6198. }
  6199. declare module BABYLON {
  6200. /**
  6201. * Composed of a frame, and an action function
  6202. */
  6203. export class AnimationEvent {
  6204. /** The frame for which the event is triggered **/
  6205. frame: number;
  6206. /** The event to perform when triggered **/
  6207. action: (currentFrame: number) => void;
  6208. /** Specifies if the event should be triggered only once**/
  6209. onlyOnce?: boolean | undefined;
  6210. /**
  6211. * Specifies if the animation event is done
  6212. */
  6213. isDone: boolean;
  6214. /**
  6215. * Initializes the animation event
  6216. * @param frame The frame for which the event is triggered
  6217. * @param action The event to perform when triggered
  6218. * @param onlyOnce Specifies if the event should be triggered only once
  6219. */
  6220. constructor(
  6221. /** The frame for which the event is triggered **/
  6222. frame: number,
  6223. /** The event to perform when triggered **/
  6224. action: (currentFrame: number) => void,
  6225. /** Specifies if the event should be triggered only once**/
  6226. onlyOnce?: boolean | undefined);
  6227. /** @hidden */
  6228. _clone(): AnimationEvent;
  6229. }
  6230. }
  6231. declare module BABYLON {
  6232. /**
  6233. * Interface used to define a behavior
  6234. */
  6235. export interface Behavior<T> {
  6236. /** gets or sets behavior's name */
  6237. name: string;
  6238. /**
  6239. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6240. */
  6241. init(): void;
  6242. /**
  6243. * Called when the behavior is attached to a target
  6244. * @param target defines the target where the behavior is attached to
  6245. */
  6246. attach(target: T): void;
  6247. /**
  6248. * Called when the behavior is detached from its target
  6249. */
  6250. detach(): void;
  6251. }
  6252. /**
  6253. * Interface implemented by classes supporting behaviors
  6254. */
  6255. export interface IBehaviorAware<T> {
  6256. /**
  6257. * Attach a behavior
  6258. * @param behavior defines the behavior to attach
  6259. * @returns the current host
  6260. */
  6261. addBehavior(behavior: Behavior<T>): T;
  6262. /**
  6263. * Remove a behavior from the current object
  6264. * @param behavior defines the behavior to detach
  6265. * @returns the current host
  6266. */
  6267. removeBehavior(behavior: Behavior<T>): T;
  6268. /**
  6269. * Gets a behavior using its name to search
  6270. * @param name defines the name to search
  6271. * @returns the behavior or null if not found
  6272. */
  6273. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6274. }
  6275. }
  6276. declare module BABYLON {
  6277. /**
  6278. * Defines an array and its length.
  6279. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6280. */
  6281. export interface ISmartArrayLike<T> {
  6282. /**
  6283. * The data of the array.
  6284. */
  6285. data: Array<T>;
  6286. /**
  6287. * The active length of the array.
  6288. */
  6289. length: number;
  6290. }
  6291. /**
  6292. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6293. */
  6294. export class SmartArray<T> implements ISmartArrayLike<T> {
  6295. /**
  6296. * The full set of data from the array.
  6297. */
  6298. data: Array<T>;
  6299. /**
  6300. * The active length of the array.
  6301. */
  6302. length: number;
  6303. protected _id: number;
  6304. /**
  6305. * Instantiates a Smart Array.
  6306. * @param capacity defines the default capacity of the array.
  6307. */
  6308. constructor(capacity: number);
  6309. /**
  6310. * Pushes a value at the end of the active data.
  6311. * @param value defines the object to push in the array.
  6312. */
  6313. push(value: T): void;
  6314. /**
  6315. * Iterates over the active data and apply the lambda to them.
  6316. * @param func defines the action to apply on each value.
  6317. */
  6318. forEach(func: (content: T) => void): void;
  6319. /**
  6320. * Sorts the full sets of data.
  6321. * @param compareFn defines the comparison function to apply.
  6322. */
  6323. sort(compareFn: (a: T, b: T) => number): void;
  6324. /**
  6325. * Resets the active data to an empty array.
  6326. */
  6327. reset(): void;
  6328. /**
  6329. * Releases all the data from the array as well as the array.
  6330. */
  6331. dispose(): void;
  6332. /**
  6333. * Concats the active data with a given array.
  6334. * @param array defines the data to concatenate with.
  6335. */
  6336. concat(array: any): void;
  6337. /**
  6338. * Returns the position of a value in the active data.
  6339. * @param value defines the value to find the index for
  6340. * @returns the index if found in the active data otherwise -1
  6341. */
  6342. indexOf(value: T): number;
  6343. /**
  6344. * Returns whether an element is part of the active data.
  6345. * @param value defines the value to look for
  6346. * @returns true if found in the active data otherwise false
  6347. */
  6348. contains(value: T): boolean;
  6349. private static _GlobalId;
  6350. }
  6351. /**
  6352. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6353. * The data in this array can only be present once
  6354. */
  6355. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6356. private _duplicateId;
  6357. /**
  6358. * Pushes a value at the end of the active data.
  6359. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6360. * @param value defines the object to push in the array.
  6361. */
  6362. push(value: T): void;
  6363. /**
  6364. * Pushes a value at the end of the active data.
  6365. * If the data is already present, it won t be added again
  6366. * @param value defines the object to push in the array.
  6367. * @returns true if added false if it was already present
  6368. */
  6369. pushNoDuplicate(value: T): boolean;
  6370. /**
  6371. * Resets the active data to an empty array.
  6372. */
  6373. reset(): void;
  6374. /**
  6375. * Concats the active data with a given array.
  6376. * This ensures no dupplicate will be present in the result.
  6377. * @param array defines the data to concatenate with.
  6378. */
  6379. concatWithNoDuplicate(array: any): void;
  6380. }
  6381. }
  6382. declare module BABYLON {
  6383. /**
  6384. * @ignore
  6385. * This is a list of all the different input types that are available in the application.
  6386. * Fo instance: ArcRotateCameraGamepadInput...
  6387. */
  6388. export var CameraInputTypes: {};
  6389. /**
  6390. * This is the contract to implement in order to create a new input class.
  6391. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6392. */
  6393. export interface ICameraInput<TCamera extends Camera> {
  6394. /**
  6395. * Defines the camera the input is attached to.
  6396. */
  6397. camera: Nullable<TCamera>;
  6398. /**
  6399. * Gets the class name of the current intput.
  6400. * @returns the class name
  6401. */
  6402. getClassName(): string;
  6403. /**
  6404. * Get the friendly name associated with the input class.
  6405. * @returns the input friendly name
  6406. */
  6407. getSimpleName(): string;
  6408. /**
  6409. * Attach the input controls to a specific dom element to get the input from.
  6410. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6411. */
  6412. attachControl(noPreventDefault?: boolean): void;
  6413. /**
  6414. * Detach the current controls from the specified dom element.
  6415. */
  6416. detachControl(): void;
  6417. /**
  6418. * Update the current camera state depending on the inputs that have been used this frame.
  6419. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6420. */
  6421. checkInputs?: () => void;
  6422. }
  6423. /**
  6424. * Represents a map of input types to input instance or input index to input instance.
  6425. */
  6426. export interface CameraInputsMap<TCamera extends Camera> {
  6427. /**
  6428. * Accessor to the input by input type.
  6429. */
  6430. [name: string]: ICameraInput<TCamera>;
  6431. /**
  6432. * Accessor to the input by input index.
  6433. */
  6434. [idx: number]: ICameraInput<TCamera>;
  6435. }
  6436. /**
  6437. * This represents the input manager used within a camera.
  6438. * It helps dealing with all the different kind of input attached to a camera.
  6439. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6440. */
  6441. export class CameraInputsManager<TCamera extends Camera> {
  6442. /**
  6443. * Defines the list of inputs attahed to the camera.
  6444. */
  6445. attached: CameraInputsMap<TCamera>;
  6446. /**
  6447. * Defines the dom element the camera is collecting inputs from.
  6448. * This is null if the controls have not been attached.
  6449. */
  6450. attachedToElement: boolean;
  6451. /**
  6452. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6453. */
  6454. noPreventDefault: boolean;
  6455. /**
  6456. * Defined the camera the input manager belongs to.
  6457. */
  6458. camera: TCamera;
  6459. /**
  6460. * Update the current camera state depending on the inputs that have been used this frame.
  6461. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6462. */
  6463. checkInputs: () => void;
  6464. /**
  6465. * Instantiate a new Camera Input Manager.
  6466. * @param camera Defines the camera the input manager blongs to
  6467. */
  6468. constructor(camera: TCamera);
  6469. /**
  6470. * Add an input method to a camera
  6471. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6472. * @param input camera input method
  6473. */
  6474. add(input: ICameraInput<TCamera>): void;
  6475. /**
  6476. * Remove a specific input method from a camera
  6477. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6478. * @param inputToRemove camera input method
  6479. */
  6480. remove(inputToRemove: ICameraInput<TCamera>): void;
  6481. /**
  6482. * Remove a specific input type from a camera
  6483. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6484. * @param inputType the type of the input to remove
  6485. */
  6486. removeByType(inputType: string): void;
  6487. private _addCheckInputs;
  6488. /**
  6489. * Attach the input controls to the currently attached dom element to listen the events from.
  6490. * @param input Defines the input to attach
  6491. */
  6492. attachInput(input: ICameraInput<TCamera>): void;
  6493. /**
  6494. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6495. * @param element Defines the dom element to collect the events from
  6496. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6497. */
  6498. attachElement(noPreventDefault?: boolean): void;
  6499. /**
  6500. * Detach the current manager inputs controls from a specific dom element.
  6501. * @param element Defines the dom element to collect the events from
  6502. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6503. */
  6504. detachElement(disconnect?: boolean): void;
  6505. /**
  6506. * Rebuild the dynamic inputCheck function from the current list of
  6507. * defined inputs in the manager.
  6508. */
  6509. rebuildInputCheck(): void;
  6510. /**
  6511. * Remove all attached input methods from a camera
  6512. */
  6513. clear(): void;
  6514. /**
  6515. * Serialize the current input manager attached to a camera.
  6516. * This ensures than once parsed,
  6517. * the input associated to the camera will be identical to the current ones
  6518. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6519. */
  6520. serialize(serializedCamera: any): void;
  6521. /**
  6522. * Parses an input manager serialized JSON to restore the previous list of inputs
  6523. * and states associated to a camera.
  6524. * @param parsedCamera Defines the JSON to parse
  6525. */
  6526. parse(parsedCamera: any): void;
  6527. }
  6528. }
  6529. declare module BABYLON {
  6530. /**
  6531. * Class used to store data that will be store in GPU memory
  6532. */
  6533. export class Buffer {
  6534. private _engine;
  6535. private _buffer;
  6536. /** @hidden */
  6537. _data: Nullable<DataArray>;
  6538. private _updatable;
  6539. private _instanced;
  6540. private _divisor;
  6541. /**
  6542. * Gets the byte stride.
  6543. */
  6544. readonly byteStride: number;
  6545. /**
  6546. * Constructor
  6547. * @param engine the engine
  6548. * @param data the data to use for this buffer
  6549. * @param updatable whether the data is updatable
  6550. * @param stride the stride (optional)
  6551. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6552. * @param instanced whether the buffer is instanced (optional)
  6553. * @param useBytes set to true if the stride in in bytes (optional)
  6554. * @param divisor sets an optional divisor for instances (1 by default)
  6555. */
  6556. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6557. /**
  6558. * Create a new VertexBuffer based on the current buffer
  6559. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6560. * @param offset defines offset in the buffer (0 by default)
  6561. * @param size defines the size in floats of attributes (position is 3 for instance)
  6562. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6563. * @param instanced defines if the vertex buffer contains indexed data
  6564. * @param useBytes defines if the offset and stride are in bytes *
  6565. * @param divisor sets an optional divisor for instances (1 by default)
  6566. * @returns the new vertex buffer
  6567. */
  6568. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6569. /**
  6570. * Gets a boolean indicating if the Buffer is updatable?
  6571. * @returns true if the buffer is updatable
  6572. */
  6573. isUpdatable(): boolean;
  6574. /**
  6575. * Gets current buffer's data
  6576. * @returns a DataArray or null
  6577. */
  6578. getData(): Nullable<DataArray>;
  6579. /**
  6580. * Gets underlying native buffer
  6581. * @returns underlying native buffer
  6582. */
  6583. getBuffer(): Nullable<DataBuffer>;
  6584. /**
  6585. * Gets the stride in float32 units (i.e. byte stride / 4).
  6586. * May not be an integer if the byte stride is not divisible by 4.
  6587. * @returns the stride in float32 units
  6588. * @deprecated Please use byteStride instead.
  6589. */
  6590. getStrideSize(): number;
  6591. /**
  6592. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6593. * @param data defines the data to store
  6594. */
  6595. create(data?: Nullable<DataArray>): void;
  6596. /** @hidden */
  6597. _rebuild(): void;
  6598. /**
  6599. * Update current buffer data
  6600. * @param data defines the data to store
  6601. */
  6602. update(data: DataArray): void;
  6603. /**
  6604. * Updates the data directly.
  6605. * @param data the new data
  6606. * @param offset the new offset
  6607. * @param vertexCount the vertex count (optional)
  6608. * @param useBytes set to true if the offset is in bytes
  6609. */
  6610. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6611. /**
  6612. * Release all resources
  6613. */
  6614. dispose(): void;
  6615. }
  6616. /**
  6617. * Specialized buffer used to store vertex data
  6618. */
  6619. export class VertexBuffer {
  6620. /** @hidden */
  6621. _buffer: Buffer;
  6622. private _kind;
  6623. private _size;
  6624. private _ownsBuffer;
  6625. private _instanced;
  6626. private _instanceDivisor;
  6627. /**
  6628. * The byte type.
  6629. */
  6630. static readonly BYTE: number;
  6631. /**
  6632. * The unsigned byte type.
  6633. */
  6634. static readonly UNSIGNED_BYTE: number;
  6635. /**
  6636. * The short type.
  6637. */
  6638. static readonly SHORT: number;
  6639. /**
  6640. * The unsigned short type.
  6641. */
  6642. static readonly UNSIGNED_SHORT: number;
  6643. /**
  6644. * The integer type.
  6645. */
  6646. static readonly INT: number;
  6647. /**
  6648. * The unsigned integer type.
  6649. */
  6650. static readonly UNSIGNED_INT: number;
  6651. /**
  6652. * The float type.
  6653. */
  6654. static readonly FLOAT: number;
  6655. /**
  6656. * Gets or sets the instance divisor when in instanced mode
  6657. */
  6658. get instanceDivisor(): number;
  6659. set instanceDivisor(value: number);
  6660. /**
  6661. * Gets the byte stride.
  6662. */
  6663. readonly byteStride: number;
  6664. /**
  6665. * Gets the byte offset.
  6666. */
  6667. readonly byteOffset: number;
  6668. /**
  6669. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6670. */
  6671. readonly normalized: boolean;
  6672. /**
  6673. * Gets the data type of each component in the array.
  6674. */
  6675. readonly type: number;
  6676. /**
  6677. * Constructor
  6678. * @param engine the engine
  6679. * @param data the data to use for this vertex buffer
  6680. * @param kind the vertex buffer kind
  6681. * @param updatable whether the data is updatable
  6682. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6683. * @param stride the stride (optional)
  6684. * @param instanced whether the buffer is instanced (optional)
  6685. * @param offset the offset of the data (optional)
  6686. * @param size the number of components (optional)
  6687. * @param type the type of the component (optional)
  6688. * @param normalized whether the data contains normalized data (optional)
  6689. * @param useBytes set to true if stride and offset are in bytes (optional)
  6690. * @param divisor defines the instance divisor to use (1 by default)
  6691. */
  6692. 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);
  6693. /** @hidden */
  6694. _rebuild(): void;
  6695. /**
  6696. * Returns the kind of the VertexBuffer (string)
  6697. * @returns a string
  6698. */
  6699. getKind(): string;
  6700. /**
  6701. * Gets a boolean indicating if the VertexBuffer is updatable?
  6702. * @returns true if the buffer is updatable
  6703. */
  6704. isUpdatable(): boolean;
  6705. /**
  6706. * Gets current buffer's data
  6707. * @returns a DataArray or null
  6708. */
  6709. getData(): Nullable<DataArray>;
  6710. /**
  6711. * Gets underlying native buffer
  6712. * @returns underlying native buffer
  6713. */
  6714. getBuffer(): Nullable<DataBuffer>;
  6715. /**
  6716. * Gets the stride in float32 units (i.e. byte stride / 4).
  6717. * May not be an integer if the byte stride is not divisible by 4.
  6718. * @returns the stride in float32 units
  6719. * @deprecated Please use byteStride instead.
  6720. */
  6721. getStrideSize(): number;
  6722. /**
  6723. * Returns the offset as a multiple of the type byte length.
  6724. * @returns the offset in bytes
  6725. * @deprecated Please use byteOffset instead.
  6726. */
  6727. getOffset(): number;
  6728. /**
  6729. * Returns the number of components per vertex attribute (integer)
  6730. * @returns the size in float
  6731. */
  6732. getSize(): number;
  6733. /**
  6734. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6735. * @returns true if this buffer is instanced
  6736. */
  6737. getIsInstanced(): boolean;
  6738. /**
  6739. * Returns the instancing divisor, zero for non-instanced (integer).
  6740. * @returns a number
  6741. */
  6742. getInstanceDivisor(): number;
  6743. /**
  6744. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6745. * @param data defines the data to store
  6746. */
  6747. create(data?: DataArray): void;
  6748. /**
  6749. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6750. * This function will create a new buffer if the current one is not updatable
  6751. * @param data defines the data to store
  6752. */
  6753. update(data: DataArray): void;
  6754. /**
  6755. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6756. * Returns the directly updated WebGLBuffer.
  6757. * @param data the new data
  6758. * @param offset the new offset
  6759. * @param useBytes set to true if the offset is in bytes
  6760. */
  6761. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6762. /**
  6763. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6764. */
  6765. dispose(): void;
  6766. /**
  6767. * Enumerates each value of this vertex buffer as numbers.
  6768. * @param count the number of values to enumerate
  6769. * @param callback the callback function called for each value
  6770. */
  6771. forEach(count: number, callback: (value: number, index: number) => void): void;
  6772. /**
  6773. * Positions
  6774. */
  6775. static readonly PositionKind: string;
  6776. /**
  6777. * Normals
  6778. */
  6779. static readonly NormalKind: string;
  6780. /**
  6781. * Tangents
  6782. */
  6783. static readonly TangentKind: string;
  6784. /**
  6785. * Texture coordinates
  6786. */
  6787. static readonly UVKind: string;
  6788. /**
  6789. * Texture coordinates 2
  6790. */
  6791. static readonly UV2Kind: string;
  6792. /**
  6793. * Texture coordinates 3
  6794. */
  6795. static readonly UV3Kind: string;
  6796. /**
  6797. * Texture coordinates 4
  6798. */
  6799. static readonly UV4Kind: string;
  6800. /**
  6801. * Texture coordinates 5
  6802. */
  6803. static readonly UV5Kind: string;
  6804. /**
  6805. * Texture coordinates 6
  6806. */
  6807. static readonly UV6Kind: string;
  6808. /**
  6809. * Colors
  6810. */
  6811. static readonly ColorKind: string;
  6812. /**
  6813. * Matrix indices (for bones)
  6814. */
  6815. static readonly MatricesIndicesKind: string;
  6816. /**
  6817. * Matrix weights (for bones)
  6818. */
  6819. static readonly MatricesWeightsKind: string;
  6820. /**
  6821. * Additional matrix indices (for bones)
  6822. */
  6823. static readonly MatricesIndicesExtraKind: string;
  6824. /**
  6825. * Additional matrix weights (for bones)
  6826. */
  6827. static readonly MatricesWeightsExtraKind: string;
  6828. /**
  6829. * Deduces the stride given a kind.
  6830. * @param kind The kind string to deduce
  6831. * @returns The deduced stride
  6832. */
  6833. static DeduceStride(kind: string): number;
  6834. /**
  6835. * Gets the byte length of the given type.
  6836. * @param type the type
  6837. * @returns the number of bytes
  6838. */
  6839. static GetTypeByteLength(type: number): number;
  6840. /**
  6841. * Enumerates each value of the given parameters as numbers.
  6842. * @param data the data to enumerate
  6843. * @param byteOffset the byte offset of the data
  6844. * @param byteStride the byte stride of the data
  6845. * @param componentCount the number of components per element
  6846. * @param componentType the type of the component
  6847. * @param count the number of values to enumerate
  6848. * @param normalized whether the data is normalized
  6849. * @param callback the callback function called for each value
  6850. */
  6851. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6852. private static _GetFloatValue;
  6853. }
  6854. }
  6855. declare module BABYLON {
  6856. /**
  6857. * The options Interface for creating a Capsule Mesh
  6858. */
  6859. export interface ICreateCapsuleOptions {
  6860. /** The Orientation of the capsule. Default : Vector3.Up() */
  6861. orientation?: Vector3;
  6862. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  6863. subdivisions: number;
  6864. /** Number of cylindrical segments on the capsule. */
  6865. tessellation: number;
  6866. /** Height or Length of the capsule. */
  6867. height: number;
  6868. /** Radius of the capsule. */
  6869. radius: number;
  6870. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  6871. capSubdivisions: number;
  6872. /** Overwrite for the top radius. */
  6873. radiusTop?: number;
  6874. /** Overwrite for the bottom radius. */
  6875. radiusBottom?: number;
  6876. /** Overwrite for the top capSubdivisions. */
  6877. topCapSubdivisions?: number;
  6878. /** Overwrite for the bottom capSubdivisions. */
  6879. bottomCapSubdivisions?: number;
  6880. }
  6881. /**
  6882. * Class containing static functions to help procedurally build meshes
  6883. */
  6884. export class CapsuleBuilder {
  6885. /**
  6886. * Creates a capsule or a pill mesh
  6887. * @param name defines the name of the mesh
  6888. * @param options The constructors options.
  6889. * @param scene The scene the mesh is scoped to.
  6890. * @returns Capsule Mesh
  6891. */
  6892. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  6893. }
  6894. }
  6895. declare module BABYLON {
  6896. /**
  6897. * @hidden
  6898. */
  6899. export class IntersectionInfo {
  6900. bu: Nullable<number>;
  6901. bv: Nullable<number>;
  6902. distance: number;
  6903. faceId: number;
  6904. subMeshId: number;
  6905. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6906. }
  6907. }
  6908. declare module BABYLON {
  6909. /**
  6910. * Class used to store bounding sphere information
  6911. */
  6912. export class BoundingSphere {
  6913. /**
  6914. * Gets the center of the bounding sphere in local space
  6915. */
  6916. readonly center: Vector3;
  6917. /**
  6918. * Radius of the bounding sphere in local space
  6919. */
  6920. radius: number;
  6921. /**
  6922. * Gets the center of the bounding sphere in world space
  6923. */
  6924. readonly centerWorld: Vector3;
  6925. /**
  6926. * Radius of the bounding sphere in world space
  6927. */
  6928. radiusWorld: number;
  6929. /**
  6930. * Gets the minimum vector in local space
  6931. */
  6932. readonly minimum: Vector3;
  6933. /**
  6934. * Gets the maximum vector in local space
  6935. */
  6936. readonly maximum: Vector3;
  6937. private _worldMatrix;
  6938. private static readonly TmpVector3;
  6939. /**
  6940. * Creates a new bounding sphere
  6941. * @param min defines the minimum vector (in local space)
  6942. * @param max defines the maximum vector (in local space)
  6943. * @param worldMatrix defines the new world matrix
  6944. */
  6945. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6946. /**
  6947. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6948. * @param min defines the new minimum vector (in local space)
  6949. * @param max defines the new maximum vector (in local space)
  6950. * @param worldMatrix defines the new world matrix
  6951. */
  6952. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6953. /**
  6954. * Scale the current bounding sphere by applying a scale factor
  6955. * @param factor defines the scale factor to apply
  6956. * @returns the current bounding box
  6957. */
  6958. scale(factor: number): BoundingSphere;
  6959. /**
  6960. * Gets the world matrix of the bounding box
  6961. * @returns a matrix
  6962. */
  6963. getWorldMatrix(): DeepImmutable<Matrix>;
  6964. /** @hidden */
  6965. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6966. /**
  6967. * Tests if the bounding sphere is intersecting the frustum planes
  6968. * @param frustumPlanes defines the frustum planes to test
  6969. * @returns true if there is an intersection
  6970. */
  6971. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6972. /**
  6973. * Tests if the bounding sphere center is in between the frustum planes.
  6974. * Used for optimistic fast inclusion.
  6975. * @param frustumPlanes defines the frustum planes to test
  6976. * @returns true if the sphere center is in between the frustum planes
  6977. */
  6978. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6979. /**
  6980. * Tests if a point is inside the bounding sphere
  6981. * @param point defines the point to test
  6982. * @returns true if the point is inside the bounding sphere
  6983. */
  6984. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6985. /**
  6986. * Checks if two sphere intersct
  6987. * @param sphere0 sphere 0
  6988. * @param sphere1 sphere 1
  6989. * @returns true if the speres intersect
  6990. */
  6991. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6992. }
  6993. }
  6994. declare module BABYLON {
  6995. /**
  6996. * Class used to store bounding box information
  6997. */
  6998. export class BoundingBox implements ICullable {
  6999. /**
  7000. * Gets the 8 vectors representing the bounding box in local space
  7001. */
  7002. readonly vectors: Vector3[];
  7003. /**
  7004. * Gets the center of the bounding box in local space
  7005. */
  7006. readonly center: Vector3;
  7007. /**
  7008. * Gets the center of the bounding box in world space
  7009. */
  7010. readonly centerWorld: Vector3;
  7011. /**
  7012. * Gets the extend size in local space
  7013. */
  7014. readonly extendSize: Vector3;
  7015. /**
  7016. * Gets the extend size in world space
  7017. */
  7018. readonly extendSizeWorld: Vector3;
  7019. /**
  7020. * Gets the OBB (object bounding box) directions
  7021. */
  7022. readonly directions: Vector3[];
  7023. /**
  7024. * Gets the 8 vectors representing the bounding box in world space
  7025. */
  7026. readonly vectorsWorld: Vector3[];
  7027. /**
  7028. * Gets the minimum vector in world space
  7029. */
  7030. readonly minimumWorld: Vector3;
  7031. /**
  7032. * Gets the maximum vector in world space
  7033. */
  7034. readonly maximumWorld: Vector3;
  7035. /**
  7036. * Gets the minimum vector in local space
  7037. */
  7038. readonly minimum: Vector3;
  7039. /**
  7040. * Gets the maximum vector in local space
  7041. */
  7042. readonly maximum: Vector3;
  7043. private _worldMatrix;
  7044. private static readonly TmpVector3;
  7045. /**
  7046. * @hidden
  7047. */
  7048. _tag: number;
  7049. /**
  7050. * Creates a new bounding box
  7051. * @param min defines the minimum vector (in local space)
  7052. * @param max defines the maximum vector (in local space)
  7053. * @param worldMatrix defines the new world matrix
  7054. */
  7055. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7056. /**
  7057. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7058. * @param min defines the new minimum vector (in local space)
  7059. * @param max defines the new maximum vector (in local space)
  7060. * @param worldMatrix defines the new world matrix
  7061. */
  7062. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7063. /**
  7064. * Scale the current bounding box by applying a scale factor
  7065. * @param factor defines the scale factor to apply
  7066. * @returns the current bounding box
  7067. */
  7068. scale(factor: number): BoundingBox;
  7069. /**
  7070. * Gets the world matrix of the bounding box
  7071. * @returns a matrix
  7072. */
  7073. getWorldMatrix(): DeepImmutable<Matrix>;
  7074. /** @hidden */
  7075. _update(world: DeepImmutable<Matrix>): void;
  7076. /**
  7077. * Tests if the bounding box is intersecting the frustum planes
  7078. * @param frustumPlanes defines the frustum planes to test
  7079. * @returns true if there is an intersection
  7080. */
  7081. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7082. /**
  7083. * Tests if the bounding box is entirely inside the frustum planes
  7084. * @param frustumPlanes defines the frustum planes to test
  7085. * @returns true if there is an inclusion
  7086. */
  7087. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7088. /**
  7089. * Tests if a point is inside the bounding box
  7090. * @param point defines the point to test
  7091. * @returns true if the point is inside the bounding box
  7092. */
  7093. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7094. /**
  7095. * Tests if the bounding box intersects with a bounding sphere
  7096. * @param sphere defines the sphere to test
  7097. * @returns true if there is an intersection
  7098. */
  7099. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7100. /**
  7101. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7102. * @param min defines the min vector to use
  7103. * @param max defines the max vector to use
  7104. * @returns true if there is an intersection
  7105. */
  7106. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7107. /**
  7108. * Tests if two bounding boxes are intersections
  7109. * @param box0 defines the first box to test
  7110. * @param box1 defines the second box to test
  7111. * @returns true if there is an intersection
  7112. */
  7113. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7114. /**
  7115. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7116. * @param minPoint defines the minimum vector of the bounding box
  7117. * @param maxPoint defines the maximum vector of the bounding box
  7118. * @param sphereCenter defines the sphere center
  7119. * @param sphereRadius defines the sphere radius
  7120. * @returns true if there is an intersection
  7121. */
  7122. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7123. /**
  7124. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7125. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7126. * @param frustumPlanes defines the frustum planes to test
  7127. * @return true if there is an inclusion
  7128. */
  7129. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7130. /**
  7131. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7132. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7133. * @param frustumPlanes defines the frustum planes to test
  7134. * @return true if there is an intersection
  7135. */
  7136. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7137. }
  7138. }
  7139. declare module BABYLON {
  7140. /** @hidden */
  7141. export class Collider {
  7142. /** Define if a collision was found */
  7143. collisionFound: boolean;
  7144. /**
  7145. * Define last intersection point in local space
  7146. */
  7147. intersectionPoint: Vector3;
  7148. /**
  7149. * Define last collided mesh
  7150. */
  7151. collidedMesh: Nullable<AbstractMesh>;
  7152. private _collisionPoint;
  7153. private _planeIntersectionPoint;
  7154. private _tempVector;
  7155. private _tempVector2;
  7156. private _tempVector3;
  7157. private _tempVector4;
  7158. private _edge;
  7159. private _baseToVertex;
  7160. private _destinationPoint;
  7161. private _slidePlaneNormal;
  7162. private _displacementVector;
  7163. /** @hidden */
  7164. _radius: Vector3;
  7165. /** @hidden */
  7166. _retry: number;
  7167. private _velocity;
  7168. private _basePoint;
  7169. private _epsilon;
  7170. /** @hidden */
  7171. _velocityWorldLength: number;
  7172. /** @hidden */
  7173. _basePointWorld: Vector3;
  7174. private _velocityWorld;
  7175. private _normalizedVelocity;
  7176. /** @hidden */
  7177. _initialVelocity: Vector3;
  7178. /** @hidden */
  7179. _initialPosition: Vector3;
  7180. private _nearestDistance;
  7181. private _collisionMask;
  7182. get collisionMask(): number;
  7183. set collisionMask(mask: number);
  7184. /**
  7185. * Gets the plane normal used to compute the sliding response (in local space)
  7186. */
  7187. get slidePlaneNormal(): Vector3;
  7188. /** @hidden */
  7189. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7190. /** @hidden */
  7191. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7192. /** @hidden */
  7193. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7194. /** @hidden */
  7195. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7196. /** @hidden */
  7197. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7198. /** @hidden */
  7199. _getResponse(pos: Vector3, vel: Vector3): void;
  7200. }
  7201. }
  7202. declare module BABYLON {
  7203. /**
  7204. * Interface for cullable objects
  7205. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7206. */
  7207. export interface ICullable {
  7208. /**
  7209. * Checks if the object or part of the object is in the frustum
  7210. * @param frustumPlanes Camera near/planes
  7211. * @returns true if the object is in frustum otherwise false
  7212. */
  7213. isInFrustum(frustumPlanes: Plane[]): boolean;
  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: Plane[]): boolean;
  7221. }
  7222. /**
  7223. * Info for a bounding data of a mesh
  7224. */
  7225. export class BoundingInfo implements ICullable {
  7226. /**
  7227. * Bounding box for the mesh
  7228. */
  7229. readonly boundingBox: BoundingBox;
  7230. /**
  7231. * Bounding sphere for the mesh
  7232. */
  7233. readonly boundingSphere: BoundingSphere;
  7234. private _isLocked;
  7235. private static readonly TmpVector3;
  7236. /**
  7237. * Constructs bounding info
  7238. * @param minimum min vector of the bounding box/sphere
  7239. * @param maximum max vector of the bounding box/sphere
  7240. * @param worldMatrix defines the new world matrix
  7241. */
  7242. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7243. /**
  7244. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7245. * @param min defines the new minimum vector (in local space)
  7246. * @param max defines the new maximum vector (in local space)
  7247. * @param worldMatrix defines the new world matrix
  7248. */
  7249. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7250. /**
  7251. * min vector of the bounding box/sphere
  7252. */
  7253. get minimum(): Vector3;
  7254. /**
  7255. * max vector of the bounding box/sphere
  7256. */
  7257. get maximum(): Vector3;
  7258. /**
  7259. * If the info is locked and won't be updated to avoid perf overhead
  7260. */
  7261. get isLocked(): boolean;
  7262. set isLocked(value: boolean);
  7263. /**
  7264. * Updates the bounding sphere and box
  7265. * @param world world matrix to be used to update
  7266. */
  7267. update(world: DeepImmutable<Matrix>): void;
  7268. /**
  7269. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7270. * @param center New center of the bounding info
  7271. * @param extend New extend of the bounding info
  7272. * @returns the current bounding info
  7273. */
  7274. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7275. /**
  7276. * Scale the current bounding info by applying a scale factor
  7277. * @param factor defines the scale factor to apply
  7278. * @returns the current bounding info
  7279. */
  7280. scale(factor: number): BoundingInfo;
  7281. /**
  7282. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7283. * @param frustumPlanes defines the frustum to test
  7284. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7285. * @returns true if the bounding info is in the frustum planes
  7286. */
  7287. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7288. /**
  7289. * Gets the world distance between the min and max points of the bounding box
  7290. */
  7291. get diagonalLength(): number;
  7292. /**
  7293. * Checks if a cullable object (mesh...) is in the camera frustum
  7294. * Unlike isInFrustum this cheks the full bounding box
  7295. * @param frustumPlanes Camera near/planes
  7296. * @returns true if the object is in frustum otherwise false
  7297. */
  7298. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7299. /** @hidden */
  7300. _checkCollision(collider: Collider): boolean;
  7301. /**
  7302. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7303. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7304. * @param point the point to check intersection with
  7305. * @returns if the point intersects
  7306. */
  7307. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7308. /**
  7309. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7310. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7311. * @param boundingInfo the bounding info to check intersection with
  7312. * @param precise if the intersection should be done using OBB
  7313. * @returns if the bounding info intersects
  7314. */
  7315. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7316. }
  7317. }
  7318. declare module BABYLON {
  7319. /**
  7320. * Extracts minimum and maximum values from a list of indexed positions
  7321. * @param positions defines the positions to use
  7322. * @param indices defines the indices to the positions
  7323. * @param indexStart defines the start index
  7324. * @param indexCount defines the end index
  7325. * @param bias defines bias value to add to the result
  7326. * @return minimum and maximum values
  7327. */
  7328. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7329. minimum: Vector3;
  7330. maximum: Vector3;
  7331. };
  7332. /**
  7333. * Extracts minimum and maximum values from a list of positions
  7334. * @param positions defines the positions to use
  7335. * @param start defines the start index in the positions array
  7336. * @param count defines the number of positions to handle
  7337. * @param bias defines bias value to add to the result
  7338. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7339. * @return minimum and maximum values
  7340. */
  7341. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7342. minimum: Vector3;
  7343. maximum: Vector3;
  7344. };
  7345. }
  7346. declare module BABYLON {
  7347. /** @hidden */
  7348. export class WebGLDataBuffer extends DataBuffer {
  7349. private _buffer;
  7350. constructor(resource: WebGLBuffer);
  7351. get underlyingResource(): any;
  7352. }
  7353. }
  7354. declare module BABYLON {
  7355. /** @hidden */
  7356. export class WebGLPipelineContext implements IPipelineContext {
  7357. engine: ThinEngine;
  7358. program: Nullable<WebGLProgram>;
  7359. context?: WebGLRenderingContext;
  7360. vertexShader?: WebGLShader;
  7361. fragmentShader?: WebGLShader;
  7362. isParallelCompiled: boolean;
  7363. onCompiled?: () => void;
  7364. transformFeedback?: WebGLTransformFeedback | null;
  7365. vertexCompilationError: Nullable<string>;
  7366. fragmentCompilationError: Nullable<string>;
  7367. programLinkError: Nullable<string>;
  7368. programValidationError: Nullable<string>;
  7369. get isAsync(): boolean;
  7370. get isReady(): boolean;
  7371. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7372. _getVertexShaderCode(): string | null;
  7373. _getFragmentShaderCode(): string | null;
  7374. }
  7375. }
  7376. declare module BABYLON {
  7377. interface ThinEngine {
  7378. /**
  7379. * Create an uniform buffer
  7380. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7381. * @param elements defines the content of the uniform buffer
  7382. * @returns the webGL uniform buffer
  7383. */
  7384. createUniformBuffer(elements: FloatArray): DataBuffer;
  7385. /**
  7386. * Create a dynamic uniform buffer
  7387. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7388. * @param elements defines the content of the uniform buffer
  7389. * @returns the webGL uniform buffer
  7390. */
  7391. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7392. /**
  7393. * Update an existing uniform buffer
  7394. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7395. * @param uniformBuffer defines the target uniform buffer
  7396. * @param elements defines the content to update
  7397. * @param offset defines the offset in the uniform buffer where update should start
  7398. * @param count defines the size of the data to update
  7399. */
  7400. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7401. /**
  7402. * Bind an uniform buffer to the current webGL context
  7403. * @param buffer defines the buffer to bind
  7404. */
  7405. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7406. /**
  7407. * Bind a buffer to the current webGL context at a given location
  7408. * @param buffer defines the buffer to bind
  7409. * @param location defines the index where to bind the buffer
  7410. */
  7411. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7412. /**
  7413. * Bind a specific block at a given index in a specific shader program
  7414. * @param pipelineContext defines the pipeline context to use
  7415. * @param blockName defines the block name
  7416. * @param index defines the index where to bind the block
  7417. */
  7418. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7419. }
  7420. }
  7421. declare module BABYLON {
  7422. /**
  7423. * Uniform buffer objects.
  7424. *
  7425. * Handles blocks of uniform on the GPU.
  7426. *
  7427. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7428. *
  7429. * For more information, please refer to :
  7430. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7431. */
  7432. export class UniformBuffer {
  7433. private _engine;
  7434. private _buffer;
  7435. private _data;
  7436. private _bufferData;
  7437. private _dynamic?;
  7438. private _uniformLocations;
  7439. private _uniformSizes;
  7440. private _uniformLocationPointer;
  7441. private _needSync;
  7442. private _noUBO;
  7443. private _currentEffect;
  7444. /** @hidden */
  7445. _alreadyBound: boolean;
  7446. private static _MAX_UNIFORM_SIZE;
  7447. private static _tempBuffer;
  7448. /**
  7449. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7450. * This is dynamic to allow compat with webgl 1 and 2.
  7451. * You will need to pass the name of the uniform as well as the value.
  7452. */
  7453. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7454. /**
  7455. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7456. * This is dynamic to allow compat with webgl 1 and 2.
  7457. * You will need to pass the name of the uniform as well as the value.
  7458. */
  7459. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7460. /**
  7461. * Lambda to Update a single float in a uniform buffer.
  7462. * This is dynamic to allow compat with webgl 1 and 2.
  7463. * You will need to pass the name of the uniform as well as the value.
  7464. */
  7465. updateFloat: (name: string, x: number) => void;
  7466. /**
  7467. * Lambda to Update a vec2 of float in a uniform buffer.
  7468. * This is dynamic to allow compat with webgl 1 and 2.
  7469. * You will need to pass the name of the uniform as well as the value.
  7470. */
  7471. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7472. /**
  7473. * Lambda to Update a vec3 of float in a uniform buffer.
  7474. * This is dynamic to allow compat with webgl 1 and 2.
  7475. * You will need to pass the name of the uniform as well as the value.
  7476. */
  7477. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7478. /**
  7479. * Lambda to Update a vec4 of float in a uniform buffer.
  7480. * This is dynamic to allow compat with webgl 1 and 2.
  7481. * You will need to pass the name of the uniform as well as the value.
  7482. */
  7483. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7484. /**
  7485. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7486. * This is dynamic to allow compat with webgl 1 and 2.
  7487. * You will need to pass the name of the uniform as well as the value.
  7488. */
  7489. updateMatrix: (name: string, mat: Matrix) => void;
  7490. /**
  7491. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7492. * This is dynamic to allow compat with webgl 1 and 2.
  7493. * You will need to pass the name of the uniform as well as the value.
  7494. */
  7495. updateVector3: (name: string, vector: Vector3) => void;
  7496. /**
  7497. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7498. * This is dynamic to allow compat with webgl 1 and 2.
  7499. * You will need to pass the name of the uniform as well as the value.
  7500. */
  7501. updateVector4: (name: string, vector: Vector4) => void;
  7502. /**
  7503. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7504. * This is dynamic to allow compat with webgl 1 and 2.
  7505. * You will need to pass the name of the uniform as well as the value.
  7506. */
  7507. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7508. /**
  7509. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7510. * This is dynamic to allow compat with webgl 1 and 2.
  7511. * You will need to pass the name of the uniform as well as the value.
  7512. */
  7513. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7514. /**
  7515. * Instantiates a new Uniform buffer objects.
  7516. *
  7517. * Handles blocks of uniform on the GPU.
  7518. *
  7519. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7520. *
  7521. * For more information, please refer to :
  7522. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7523. * @param engine Define the engine the buffer is associated with
  7524. * @param data Define the data contained in the buffer
  7525. * @param dynamic Define if the buffer is updatable
  7526. */
  7527. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7528. /**
  7529. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7530. * or just falling back on setUniformXXX calls.
  7531. */
  7532. get useUbo(): boolean;
  7533. /**
  7534. * Indicates if the WebGL underlying uniform buffer is in sync
  7535. * with the javascript cache data.
  7536. */
  7537. get isSync(): boolean;
  7538. /**
  7539. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7540. * Also, a dynamic UniformBuffer will disable cache verification and always
  7541. * update the underlying WebGL uniform buffer to the GPU.
  7542. * @returns if Dynamic, otherwise false
  7543. */
  7544. isDynamic(): boolean;
  7545. /**
  7546. * The data cache on JS side.
  7547. * @returns the underlying data as a float array
  7548. */
  7549. getData(): Float32Array;
  7550. /**
  7551. * The underlying WebGL Uniform buffer.
  7552. * @returns the webgl buffer
  7553. */
  7554. getBuffer(): Nullable<DataBuffer>;
  7555. /**
  7556. * std140 layout specifies how to align data within an UBO structure.
  7557. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7558. * for specs.
  7559. */
  7560. private _fillAlignment;
  7561. /**
  7562. * Adds an uniform in the buffer.
  7563. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7564. * for the layout to be correct !
  7565. * @param name Name of the uniform, as used in the uniform block in the shader.
  7566. * @param size Data size, or data directly.
  7567. */
  7568. addUniform(name: string, size: number | number[]): void;
  7569. /**
  7570. * Adds a Matrix 4x4 to the uniform buffer.
  7571. * @param name Name of the uniform, as used in the uniform block in the shader.
  7572. * @param mat A 4x4 matrix.
  7573. */
  7574. addMatrix(name: string, mat: Matrix): void;
  7575. /**
  7576. * Adds a vec2 to the uniform buffer.
  7577. * @param name Name of the uniform, as used in the uniform block in the shader.
  7578. * @param x Define the x component value of the vec2
  7579. * @param y Define the y component value of the vec2
  7580. */
  7581. addFloat2(name: string, x: number, y: number): void;
  7582. /**
  7583. * Adds a vec3 to the uniform buffer.
  7584. * @param name Name of the uniform, as used in the uniform block in the shader.
  7585. * @param x Define the x component value of the vec3
  7586. * @param y Define the y component value of the vec3
  7587. * @param z Define the z component value of the vec3
  7588. */
  7589. addFloat3(name: string, x: number, y: number, z: number): void;
  7590. /**
  7591. * Adds a vec3 to the uniform buffer.
  7592. * @param name Name of the uniform, as used in the uniform block in the shader.
  7593. * @param color Define the vec3 from a Color
  7594. */
  7595. addColor3(name: string, color: Color3): void;
  7596. /**
  7597. * Adds a vec4 to the uniform buffer.
  7598. * @param name Name of the uniform, as used in the uniform block in the shader.
  7599. * @param color Define the rgb components from a Color
  7600. * @param alpha Define the a component of the vec4
  7601. */
  7602. addColor4(name: string, color: Color3, alpha: number): void;
  7603. /**
  7604. * Adds a vec3 to the uniform buffer.
  7605. * @param name Name of the uniform, as used in the uniform block in the shader.
  7606. * @param vector Define the vec3 components from a Vector
  7607. */
  7608. addVector3(name: string, vector: Vector3): void;
  7609. /**
  7610. * Adds a Matrix 3x3 to the uniform buffer.
  7611. * @param name Name of the uniform, as used in the uniform block in the shader.
  7612. */
  7613. addMatrix3x3(name: string): void;
  7614. /**
  7615. * Adds a Matrix 2x2 to the uniform buffer.
  7616. * @param name Name of the uniform, as used in the uniform block in the shader.
  7617. */
  7618. addMatrix2x2(name: string): void;
  7619. /**
  7620. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7621. */
  7622. create(): void;
  7623. /** @hidden */
  7624. _rebuild(): void;
  7625. /**
  7626. * Updates the WebGL Uniform Buffer on the GPU.
  7627. * If the `dynamic` flag is set to true, no cache comparison is done.
  7628. * Otherwise, the buffer will be updated only if the cache differs.
  7629. */
  7630. update(): void;
  7631. /**
  7632. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7633. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7634. * @param data Define the flattened data
  7635. * @param size Define the size of the data.
  7636. */
  7637. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7638. private _valueCache;
  7639. private _cacheMatrix;
  7640. private _updateMatrix3x3ForUniform;
  7641. private _updateMatrix3x3ForEffect;
  7642. private _updateMatrix2x2ForEffect;
  7643. private _updateMatrix2x2ForUniform;
  7644. private _updateFloatForEffect;
  7645. private _updateFloatForUniform;
  7646. private _updateFloat2ForEffect;
  7647. private _updateFloat2ForUniform;
  7648. private _updateFloat3ForEffect;
  7649. private _updateFloat3ForUniform;
  7650. private _updateFloat4ForEffect;
  7651. private _updateFloat4ForUniform;
  7652. private _updateMatrixForEffect;
  7653. private _updateMatrixForUniform;
  7654. private _updateVector3ForEffect;
  7655. private _updateVector3ForUniform;
  7656. private _updateVector4ForEffect;
  7657. private _updateVector4ForUniform;
  7658. private _updateColor3ForEffect;
  7659. private _updateColor3ForUniform;
  7660. private _updateColor4ForEffect;
  7661. private _updateColor4ForUniform;
  7662. /**
  7663. * Sets a sampler uniform on the effect.
  7664. * @param name Define the name of the sampler.
  7665. * @param texture Define the texture to set in the sampler
  7666. */
  7667. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7668. /**
  7669. * Directly updates the value of the uniform in the cache AND on the GPU.
  7670. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7671. * @param data Define the flattened data
  7672. */
  7673. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7674. /**
  7675. * Binds this uniform buffer to an effect.
  7676. * @param effect Define the effect to bind the buffer to
  7677. * @param name Name of the uniform block in the shader.
  7678. */
  7679. bindToEffect(effect: Effect, name: string): void;
  7680. /**
  7681. * Disposes the uniform buffer.
  7682. */
  7683. dispose(): void;
  7684. }
  7685. }
  7686. declare module BABYLON {
  7687. /**
  7688. * Enum that determines the text-wrapping mode to use.
  7689. */
  7690. export enum InspectableType {
  7691. /**
  7692. * Checkbox for booleans
  7693. */
  7694. Checkbox = 0,
  7695. /**
  7696. * Sliders for numbers
  7697. */
  7698. Slider = 1,
  7699. /**
  7700. * Vector3
  7701. */
  7702. Vector3 = 2,
  7703. /**
  7704. * Quaternions
  7705. */
  7706. Quaternion = 3,
  7707. /**
  7708. * Color3
  7709. */
  7710. Color3 = 4,
  7711. /**
  7712. * String
  7713. */
  7714. String = 5
  7715. }
  7716. /**
  7717. * Interface used to define custom inspectable properties.
  7718. * This interface is used by the inspector to display custom property grids
  7719. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7720. */
  7721. export interface IInspectable {
  7722. /**
  7723. * Gets the label to display
  7724. */
  7725. label: string;
  7726. /**
  7727. * Gets the name of the property to edit
  7728. */
  7729. propertyName: string;
  7730. /**
  7731. * Gets the type of the editor to use
  7732. */
  7733. type: InspectableType;
  7734. /**
  7735. * Gets the minimum value of the property when using in "slider" mode
  7736. */
  7737. min?: number;
  7738. /**
  7739. * Gets the maximum value of the property when using in "slider" mode
  7740. */
  7741. max?: number;
  7742. /**
  7743. * Gets the setp to use when using in "slider" mode
  7744. */
  7745. step?: number;
  7746. }
  7747. }
  7748. declare module BABYLON {
  7749. /**
  7750. * Class used to provide helper for timing
  7751. */
  7752. export class TimingTools {
  7753. /**
  7754. * Polyfill for setImmediate
  7755. * @param action defines the action to execute after the current execution block
  7756. */
  7757. static SetImmediate(action: () => void): void;
  7758. }
  7759. }
  7760. declare module BABYLON {
  7761. /**
  7762. * Class used to enable instatition of objects by class name
  7763. */
  7764. export class InstantiationTools {
  7765. /**
  7766. * Use this object to register external classes like custom textures or material
  7767. * to allow the laoders to instantiate them
  7768. */
  7769. static RegisteredExternalClasses: {
  7770. [key: string]: Object;
  7771. };
  7772. /**
  7773. * Tries to instantiate a new object from a given class name
  7774. * @param className defines the class name to instantiate
  7775. * @returns the new object or null if the system was not able to do the instantiation
  7776. */
  7777. static Instantiate(className: string): any;
  7778. }
  7779. }
  7780. declare module BABYLON {
  7781. /**
  7782. * Class used to host copy specific utilities
  7783. */
  7784. export class CopyTools {
  7785. /**
  7786. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  7787. * @param texture defines the texture to read pixels from
  7788. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  7789. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  7790. * @returns The base64 encoded string or null
  7791. */
  7792. static GenerateBase64StringFromTexture(texture: BaseTexture, faceIndex?: number, level?: number): Nullable<string>;
  7793. }
  7794. }
  7795. declare module BABYLON {
  7796. /**
  7797. * Define options used to create a depth texture
  7798. */
  7799. export class DepthTextureCreationOptions {
  7800. /** Specifies whether or not a stencil should be allocated in the texture */
  7801. generateStencil?: boolean;
  7802. /** Specifies whether or not bilinear filtering is enable on the texture */
  7803. bilinearFiltering?: boolean;
  7804. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7805. comparisonFunction?: number;
  7806. /** Specifies if the created texture is a cube texture */
  7807. isCube?: boolean;
  7808. }
  7809. }
  7810. declare module BABYLON {
  7811. interface ThinEngine {
  7812. /**
  7813. * Creates a depth stencil cube texture.
  7814. * This is only available in WebGL 2.
  7815. * @param size The size of face edge in the cube texture.
  7816. * @param options The options defining the cube texture.
  7817. * @returns The cube texture
  7818. */
  7819. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7820. /**
  7821. * Creates a cube texture
  7822. * @param rootUrl defines the url where the files to load is located
  7823. * @param scene defines the current scene
  7824. * @param files defines the list of files to load (1 per face)
  7825. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7826. * @param onLoad defines an optional callback raised when the texture is loaded
  7827. * @param onError defines an optional callback raised if there is an issue to load the texture
  7828. * @param format defines the format of the data
  7829. * @param forcedExtension defines the extension to use to pick the right loader
  7830. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7831. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7832. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7833. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7834. * @param loaderOptions options to be passed to the loader
  7835. * @returns the cube texture as an InternalTexture
  7836. */
  7837. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, loaderOptions: any): InternalTexture;
  7838. /**
  7839. * Creates a cube texture
  7840. * @param rootUrl defines the url where the files to load is located
  7841. * @param scene defines the current scene
  7842. * @param files defines the list of files to load (1 per face)
  7843. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7844. * @param onLoad defines an optional callback raised when the texture is loaded
  7845. * @param onError defines an optional callback raised if there is an issue to load the texture
  7846. * @param format defines the format of the data
  7847. * @param forcedExtension defines the extension to use to pick the right loader
  7848. * @returns the cube texture as an InternalTexture
  7849. */
  7850. 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;
  7851. /**
  7852. * Creates a cube texture
  7853. * @param rootUrl defines the url where the files to load is located
  7854. * @param scene defines the current scene
  7855. * @param files defines the list of files to load (1 per face)
  7856. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7857. * @param onLoad defines an optional callback raised when the texture is loaded
  7858. * @param onError defines an optional callback raised if there is an issue to load the texture
  7859. * @param format defines the format of the data
  7860. * @param forcedExtension defines the extension to use to pick the right loader
  7861. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7862. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7863. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7864. * @returns the cube texture as an InternalTexture
  7865. */
  7866. 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;
  7867. /** @hidden */
  7868. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7869. /** @hidden */
  7870. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7871. /** @hidden */
  7872. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7873. /** @hidden */
  7874. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7875. /**
  7876. * @hidden
  7877. */
  7878. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  7879. }
  7880. }
  7881. declare module BABYLON {
  7882. /**
  7883. * Class for creating a cube texture
  7884. */
  7885. export class CubeTexture extends BaseTexture {
  7886. private _delayedOnLoad;
  7887. /**
  7888. * Observable triggered once the texture has been loaded.
  7889. */
  7890. onLoadObservable: Observable<CubeTexture>;
  7891. /**
  7892. * The url of the texture
  7893. */
  7894. url: string;
  7895. /**
  7896. * Gets or sets the center of the bounding box associated with the cube texture.
  7897. * It must define where the camera used to render the texture was set
  7898. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7899. */
  7900. boundingBoxPosition: Vector3;
  7901. private _boundingBoxSize;
  7902. /**
  7903. * Gets or sets the size of the bounding box associated with the cube texture
  7904. * When defined, the cubemap will switch to local mode
  7905. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7906. * @example https://www.babylonjs-playground.com/#RNASML
  7907. */
  7908. set boundingBoxSize(value: Vector3);
  7909. /**
  7910. * Returns the bounding box size
  7911. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7912. */
  7913. get boundingBoxSize(): Vector3;
  7914. protected _rotationY: number;
  7915. /**
  7916. * Sets texture matrix rotation angle around Y axis in radians.
  7917. */
  7918. set rotationY(value: number);
  7919. /**
  7920. * Gets texture matrix rotation angle around Y axis radians.
  7921. */
  7922. get rotationY(): number;
  7923. /**
  7924. * Are mip maps generated for this texture or not.
  7925. */
  7926. get noMipmap(): boolean;
  7927. private _noMipmap;
  7928. private _files;
  7929. protected _forcedExtension: Nullable<string>;
  7930. private _extensions;
  7931. private _textureMatrix;
  7932. private _format;
  7933. private _createPolynomials;
  7934. private _loaderOptions;
  7935. /**
  7936. * Creates a cube texture from an array of image urls
  7937. * @param files defines an array of image urls
  7938. * @param scene defines the hosting scene
  7939. * @param noMipmap specifies if mip maps are not used
  7940. * @returns a cube texture
  7941. */
  7942. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7943. /**
  7944. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7945. * @param url defines the url of the prefiltered texture
  7946. * @param scene defines the scene the texture is attached to
  7947. * @param forcedExtension defines the extension of the file if different from the url
  7948. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7949. * @return the prefiltered texture
  7950. */
  7951. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7952. /**
  7953. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7954. * as prefiltered data.
  7955. * @param rootUrl defines the url of the texture or the root name of the six images
  7956. * @param null defines the scene or engine the texture is attached to
  7957. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7958. * @param noMipmap defines if mipmaps should be created or not
  7959. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7960. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7961. * @param onError defines a callback triggered in case of error during load
  7962. * @param format defines the internal format to use for the texture once loaded
  7963. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7964. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7965. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7966. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7967. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7968. * @param loaderOptions options to be passed to the loader
  7969. * @return the cube texture
  7970. */
  7971. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, loaderOptions?: any);
  7972. /**
  7973. * Get the current class name of the texture useful for serialization or dynamic coding.
  7974. * @returns "CubeTexture"
  7975. */
  7976. getClassName(): string;
  7977. /**
  7978. * Update the url (and optional buffer) of this texture if url was null during construction.
  7979. * @param url the url of the texture
  7980. * @param forcedExtension defines the extension to use
  7981. * @param onLoad callback called when the texture is loaded (defaults to null)
  7982. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7983. */
  7984. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7985. /**
  7986. * Delays loading of the cube texture
  7987. * @param forcedExtension defines the extension to use
  7988. */
  7989. delayLoad(forcedExtension?: string): void;
  7990. /**
  7991. * Returns the reflection texture matrix
  7992. * @returns the reflection texture matrix
  7993. */
  7994. getReflectionTextureMatrix(): Matrix;
  7995. /**
  7996. * Sets the reflection texture matrix
  7997. * @param value Reflection texture matrix
  7998. */
  7999. setReflectionTextureMatrix(value: Matrix): void;
  8000. /**
  8001. * Parses text to create a cube texture
  8002. * @param parsedTexture define the serialized text to read from
  8003. * @param scene defines the hosting scene
  8004. * @param rootUrl defines the root url of the cube texture
  8005. * @returns a cube texture
  8006. */
  8007. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8008. /**
  8009. * Makes a clone, or deep copy, of the cube texture
  8010. * @returns a new cube texture
  8011. */
  8012. clone(): CubeTexture;
  8013. }
  8014. }
  8015. declare module BABYLON {
  8016. /**
  8017. * Manages the defines for the Material
  8018. */
  8019. export class MaterialDefines {
  8020. /** @hidden */
  8021. protected _keys: string[];
  8022. private _isDirty;
  8023. /** @hidden */
  8024. _renderId: number;
  8025. /** @hidden */
  8026. _areLightsDirty: boolean;
  8027. /** @hidden */
  8028. _areLightsDisposed: boolean;
  8029. /** @hidden */
  8030. _areAttributesDirty: boolean;
  8031. /** @hidden */
  8032. _areTexturesDirty: boolean;
  8033. /** @hidden */
  8034. _areFresnelDirty: boolean;
  8035. /** @hidden */
  8036. _areMiscDirty: boolean;
  8037. /** @hidden */
  8038. _arePrePassDirty: boolean;
  8039. /** @hidden */
  8040. _areImageProcessingDirty: boolean;
  8041. /** @hidden */
  8042. _normals: boolean;
  8043. /** @hidden */
  8044. _uvs: boolean;
  8045. /** @hidden */
  8046. _needNormals: boolean;
  8047. /** @hidden */
  8048. _needUVs: boolean;
  8049. [id: string]: any;
  8050. /**
  8051. * Specifies if the material needs to be re-calculated
  8052. */
  8053. get isDirty(): boolean;
  8054. /**
  8055. * Marks the material to indicate that it has been re-calculated
  8056. */
  8057. markAsProcessed(): void;
  8058. /**
  8059. * Marks the material to indicate that it needs to be re-calculated
  8060. */
  8061. markAsUnprocessed(): void;
  8062. /**
  8063. * Marks the material to indicate all of its defines need to be re-calculated
  8064. */
  8065. markAllAsDirty(): void;
  8066. /**
  8067. * Marks the material to indicate that image processing needs to be re-calculated
  8068. */
  8069. markAsImageProcessingDirty(): void;
  8070. /**
  8071. * Marks the material to indicate the lights need to be re-calculated
  8072. * @param disposed Defines whether the light is dirty due to dispose or not
  8073. */
  8074. markAsLightDirty(disposed?: boolean): void;
  8075. /**
  8076. * Marks the attribute state as changed
  8077. */
  8078. markAsAttributesDirty(): void;
  8079. /**
  8080. * Marks the texture state as changed
  8081. */
  8082. markAsTexturesDirty(): void;
  8083. /**
  8084. * Marks the fresnel state as changed
  8085. */
  8086. markAsFresnelDirty(): void;
  8087. /**
  8088. * Marks the misc state as changed
  8089. */
  8090. markAsMiscDirty(): void;
  8091. /**
  8092. * Marks the prepass state as changed
  8093. */
  8094. markAsPrePassDirty(): void;
  8095. /**
  8096. * Rebuilds the material defines
  8097. */
  8098. rebuild(): void;
  8099. /**
  8100. * Specifies if two material defines are equal
  8101. * @param other - A material define instance to compare to
  8102. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8103. */
  8104. isEqual(other: MaterialDefines): boolean;
  8105. /**
  8106. * Clones this instance's defines to another instance
  8107. * @param other - material defines to clone values to
  8108. */
  8109. cloneTo(other: MaterialDefines): void;
  8110. /**
  8111. * Resets the material define values
  8112. */
  8113. reset(): void;
  8114. /**
  8115. * Converts the material define values to a string
  8116. * @returns - String of material define information
  8117. */
  8118. toString(): string;
  8119. }
  8120. }
  8121. declare module BABYLON {
  8122. /**
  8123. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8124. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8125. * 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;
  8126. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8127. */
  8128. export class ColorCurves {
  8129. private _dirty;
  8130. private _tempColor;
  8131. private _globalCurve;
  8132. private _highlightsCurve;
  8133. private _midtonesCurve;
  8134. private _shadowsCurve;
  8135. private _positiveCurve;
  8136. private _negativeCurve;
  8137. private _globalHue;
  8138. private _globalDensity;
  8139. private _globalSaturation;
  8140. private _globalExposure;
  8141. /**
  8142. * Gets the global Hue value.
  8143. * 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).
  8144. */
  8145. get globalHue(): number;
  8146. /**
  8147. * Sets the global Hue value.
  8148. * 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).
  8149. */
  8150. set globalHue(value: number);
  8151. /**
  8152. * Gets the global Density value.
  8153. * 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.
  8154. * Values less than zero provide a filter of opposite hue.
  8155. */
  8156. get globalDensity(): number;
  8157. /**
  8158. * Sets the global Density value.
  8159. * 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.
  8160. * Values less than zero provide a filter of opposite hue.
  8161. */
  8162. set globalDensity(value: number);
  8163. /**
  8164. * Gets the global Saturation 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 saturation and negative values decrease saturation.
  8166. */
  8167. get globalSaturation(): number;
  8168. /**
  8169. * Sets the global Saturation 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 saturation and negative values decrease saturation.
  8171. */
  8172. set globalSaturation(value: number);
  8173. /**
  8174. * Gets the global Exposure value.
  8175. * 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.
  8176. */
  8177. get globalExposure(): number;
  8178. /**
  8179. * Sets the global Exposure value.
  8180. * 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.
  8181. */
  8182. set globalExposure(value: number);
  8183. private _highlightsHue;
  8184. private _highlightsDensity;
  8185. private _highlightsSaturation;
  8186. private _highlightsExposure;
  8187. /**
  8188. * Gets the highlights Hue value.
  8189. * 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).
  8190. */
  8191. get highlightsHue(): number;
  8192. /**
  8193. * Sets the highlights Hue value.
  8194. * 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).
  8195. */
  8196. set highlightsHue(value: number);
  8197. /**
  8198. * Gets the highlights Density value.
  8199. * 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.
  8200. * Values less than zero provide a filter of opposite hue.
  8201. */
  8202. get highlightsDensity(): number;
  8203. /**
  8204. * Sets the highlights Density value.
  8205. * 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.
  8206. * Values less than zero provide a filter of opposite hue.
  8207. */
  8208. set highlightsDensity(value: number);
  8209. /**
  8210. * Gets the highlights Saturation 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 saturation and negative values decrease saturation.
  8212. */
  8213. get highlightsSaturation(): number;
  8214. /**
  8215. * Sets the highlights Saturation 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 saturation and negative values decrease saturation.
  8217. */
  8218. set highlightsSaturation(value: number);
  8219. /**
  8220. * Gets the highlights Exposure value.
  8221. * 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.
  8222. */
  8223. get highlightsExposure(): number;
  8224. /**
  8225. * Sets the highlights Exposure value.
  8226. * 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.
  8227. */
  8228. set highlightsExposure(value: number);
  8229. private _midtonesHue;
  8230. private _midtonesDensity;
  8231. private _midtonesSaturation;
  8232. private _midtonesExposure;
  8233. /**
  8234. * Gets the midtones Hue value.
  8235. * 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).
  8236. */
  8237. get midtonesHue(): number;
  8238. /**
  8239. * Sets the midtones Hue value.
  8240. * 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).
  8241. */
  8242. set midtonesHue(value: number);
  8243. /**
  8244. * Gets the midtones Density value.
  8245. * 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.
  8246. * Values less than zero provide a filter of opposite hue.
  8247. */
  8248. get midtonesDensity(): number;
  8249. /**
  8250. * Sets the midtones Density value.
  8251. * 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.
  8252. * Values less than zero provide a filter of opposite hue.
  8253. */
  8254. set midtonesDensity(value: number);
  8255. /**
  8256. * Gets the midtones Saturation value.
  8257. * 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.
  8258. */
  8259. get midtonesSaturation(): number;
  8260. /**
  8261. * Sets the midtones Saturation value.
  8262. * 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.
  8263. */
  8264. set midtonesSaturation(value: number);
  8265. /**
  8266. * Gets the midtones Exposure value.
  8267. * 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.
  8268. */
  8269. get midtonesExposure(): number;
  8270. /**
  8271. * Sets the midtones Exposure value.
  8272. * 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.
  8273. */
  8274. set midtonesExposure(value: number);
  8275. private _shadowsHue;
  8276. private _shadowsDensity;
  8277. private _shadowsSaturation;
  8278. private _shadowsExposure;
  8279. /**
  8280. * Gets the shadows Hue value.
  8281. * 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).
  8282. */
  8283. get shadowsHue(): number;
  8284. /**
  8285. * Sets the shadows Hue value.
  8286. * 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).
  8287. */
  8288. set shadowsHue(value: number);
  8289. /**
  8290. * Gets the shadows Density value.
  8291. * 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.
  8292. * Values less than zero provide a filter of opposite hue.
  8293. */
  8294. get shadowsDensity(): number;
  8295. /**
  8296. * Sets the shadows Density value.
  8297. * 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.
  8298. * Values less than zero provide a filter of opposite hue.
  8299. */
  8300. set shadowsDensity(value: number);
  8301. /**
  8302. * Gets the shadows Saturation value.
  8303. * 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.
  8304. */
  8305. get shadowsSaturation(): number;
  8306. /**
  8307. * Sets the shadows Saturation value.
  8308. * 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.
  8309. */
  8310. set shadowsSaturation(value: number);
  8311. /**
  8312. * Gets the shadows Exposure value.
  8313. * 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.
  8314. */
  8315. get shadowsExposure(): number;
  8316. /**
  8317. * Sets the shadows Exposure value.
  8318. * 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.
  8319. */
  8320. set shadowsExposure(value: number);
  8321. /**
  8322. * Returns the class name
  8323. * @returns The class name
  8324. */
  8325. getClassName(): string;
  8326. /**
  8327. * Binds the color curves to the shader.
  8328. * @param colorCurves The color curve to bind
  8329. * @param effect The effect to bind to
  8330. * @param positiveUniform The positive uniform shader parameter
  8331. * @param neutralUniform The neutral uniform shader parameter
  8332. * @param negativeUniform The negative uniform shader parameter
  8333. */
  8334. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8335. /**
  8336. * Prepare the list of uniforms associated with the ColorCurves effects.
  8337. * @param uniformsList The list of uniforms used in the effect
  8338. */
  8339. static PrepareUniforms(uniformsList: string[]): void;
  8340. /**
  8341. * Returns color grading data based on a hue, density, saturation and exposure value.
  8342. * @param filterHue The hue of the color filter.
  8343. * @param filterDensity The density of the color filter.
  8344. * @param saturation The saturation.
  8345. * @param exposure The exposure.
  8346. * @param result The result data container.
  8347. */
  8348. private getColorGradingDataToRef;
  8349. /**
  8350. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8351. * @param value The input slider value in range [-100,100].
  8352. * @returns Adjusted value.
  8353. */
  8354. private static applyColorGradingSliderNonlinear;
  8355. /**
  8356. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8357. * @param hue The hue (H) input.
  8358. * @param saturation The saturation (S) input.
  8359. * @param brightness The brightness (B) input.
  8360. * @result An RGBA color represented as Vector4.
  8361. */
  8362. private static fromHSBToRef;
  8363. /**
  8364. * Returns a value clamped between min and max
  8365. * @param value The value to clamp
  8366. * @param min The minimum of value
  8367. * @param max The maximum of value
  8368. * @returns The clamped value.
  8369. */
  8370. private static clamp;
  8371. /**
  8372. * Clones the current color curve instance.
  8373. * @return The cloned curves
  8374. */
  8375. clone(): ColorCurves;
  8376. /**
  8377. * Serializes the current color curve instance to a json representation.
  8378. * @return a JSON representation
  8379. */
  8380. serialize(): any;
  8381. /**
  8382. * Parses the color curve from a json representation.
  8383. * @param source the JSON source to parse
  8384. * @return The parsed curves
  8385. */
  8386. static Parse(source: any): ColorCurves;
  8387. }
  8388. }
  8389. declare module BABYLON {
  8390. /**
  8391. * Interface to follow in your material defines to integrate easily the
  8392. * Image proccessing functions.
  8393. * @hidden
  8394. */
  8395. export interface IImageProcessingConfigurationDefines {
  8396. IMAGEPROCESSING: boolean;
  8397. VIGNETTE: boolean;
  8398. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8399. VIGNETTEBLENDMODEOPAQUE: boolean;
  8400. TONEMAPPING: boolean;
  8401. TONEMAPPING_ACES: boolean;
  8402. CONTRAST: boolean;
  8403. EXPOSURE: boolean;
  8404. COLORCURVES: boolean;
  8405. COLORGRADING: boolean;
  8406. COLORGRADING3D: boolean;
  8407. SAMPLER3DGREENDEPTH: boolean;
  8408. SAMPLER3DBGRMAP: boolean;
  8409. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8410. }
  8411. /**
  8412. * @hidden
  8413. */
  8414. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8415. IMAGEPROCESSING: boolean;
  8416. VIGNETTE: boolean;
  8417. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8418. VIGNETTEBLENDMODEOPAQUE: boolean;
  8419. TONEMAPPING: boolean;
  8420. TONEMAPPING_ACES: boolean;
  8421. CONTRAST: boolean;
  8422. COLORCURVES: boolean;
  8423. COLORGRADING: boolean;
  8424. COLORGRADING3D: boolean;
  8425. SAMPLER3DGREENDEPTH: boolean;
  8426. SAMPLER3DBGRMAP: boolean;
  8427. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8428. EXPOSURE: boolean;
  8429. constructor();
  8430. }
  8431. /**
  8432. * This groups together the common properties used for image processing either in direct forward pass
  8433. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8434. * or not.
  8435. */
  8436. export class ImageProcessingConfiguration {
  8437. /**
  8438. * Default tone mapping applied in BabylonJS.
  8439. */
  8440. static readonly TONEMAPPING_STANDARD: number;
  8441. /**
  8442. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8443. * to other engines rendering to increase portability.
  8444. */
  8445. static readonly TONEMAPPING_ACES: number;
  8446. /**
  8447. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8448. */
  8449. colorCurves: Nullable<ColorCurves>;
  8450. private _colorCurvesEnabled;
  8451. /**
  8452. * Gets wether the color curves effect is enabled.
  8453. */
  8454. get colorCurvesEnabled(): boolean;
  8455. /**
  8456. * Sets wether the color curves effect is enabled.
  8457. */
  8458. set colorCurvesEnabled(value: boolean);
  8459. private _colorGradingTexture;
  8460. /**
  8461. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8462. */
  8463. get colorGradingTexture(): Nullable<BaseTexture>;
  8464. /**
  8465. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8466. */
  8467. set colorGradingTexture(value: Nullable<BaseTexture>);
  8468. private _colorGradingEnabled;
  8469. /**
  8470. * Gets wether the color grading effect is enabled.
  8471. */
  8472. get colorGradingEnabled(): boolean;
  8473. /**
  8474. * Sets wether the color grading effect is enabled.
  8475. */
  8476. set colorGradingEnabled(value: boolean);
  8477. private _colorGradingWithGreenDepth;
  8478. /**
  8479. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8480. */
  8481. get colorGradingWithGreenDepth(): boolean;
  8482. /**
  8483. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8484. */
  8485. set colorGradingWithGreenDepth(value: boolean);
  8486. private _colorGradingBGR;
  8487. /**
  8488. * Gets wether the color grading texture contains BGR values.
  8489. */
  8490. get colorGradingBGR(): boolean;
  8491. /**
  8492. * Sets wether the color grading texture contains BGR values.
  8493. */
  8494. set colorGradingBGR(value: boolean);
  8495. /** @hidden */
  8496. _exposure: number;
  8497. /**
  8498. * Gets the Exposure used in the effect.
  8499. */
  8500. get exposure(): number;
  8501. /**
  8502. * Sets the Exposure used in the effect.
  8503. */
  8504. set exposure(value: number);
  8505. private _toneMappingEnabled;
  8506. /**
  8507. * Gets wether the tone mapping effect is enabled.
  8508. */
  8509. get toneMappingEnabled(): boolean;
  8510. /**
  8511. * Sets wether the tone mapping effect is enabled.
  8512. */
  8513. set toneMappingEnabled(value: boolean);
  8514. private _toneMappingType;
  8515. /**
  8516. * Gets the type of tone mapping effect.
  8517. */
  8518. get toneMappingType(): number;
  8519. /**
  8520. * Sets the type of tone mapping effect used in BabylonJS.
  8521. */
  8522. set toneMappingType(value: number);
  8523. protected _contrast: number;
  8524. /**
  8525. * Gets the contrast used in the effect.
  8526. */
  8527. get contrast(): number;
  8528. /**
  8529. * Sets the contrast used in the effect.
  8530. */
  8531. set contrast(value: number);
  8532. /**
  8533. * Vignette stretch size.
  8534. */
  8535. vignetteStretch: number;
  8536. /**
  8537. * Vignette centre X Offset.
  8538. */
  8539. vignetteCentreX: number;
  8540. /**
  8541. * Vignette centre Y Offset.
  8542. */
  8543. vignetteCentreY: number;
  8544. /**
  8545. * Vignette weight or intensity of the vignette effect.
  8546. */
  8547. vignetteWeight: number;
  8548. /**
  8549. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8550. * if vignetteEnabled is set to true.
  8551. */
  8552. vignetteColor: Color4;
  8553. /**
  8554. * Camera field of view used by the Vignette effect.
  8555. */
  8556. vignetteCameraFov: number;
  8557. private _vignetteBlendMode;
  8558. /**
  8559. * Gets the vignette blend mode allowing different kind of effect.
  8560. */
  8561. get vignetteBlendMode(): number;
  8562. /**
  8563. * Sets the vignette blend mode allowing different kind of effect.
  8564. */
  8565. set vignetteBlendMode(value: number);
  8566. private _vignetteEnabled;
  8567. /**
  8568. * Gets wether the vignette effect is enabled.
  8569. */
  8570. get vignetteEnabled(): boolean;
  8571. /**
  8572. * Sets wether the vignette effect is enabled.
  8573. */
  8574. set vignetteEnabled(value: boolean);
  8575. private _applyByPostProcess;
  8576. /**
  8577. * Gets wether the image processing is applied through a post process or not.
  8578. */
  8579. get applyByPostProcess(): boolean;
  8580. /**
  8581. * Sets wether the image processing is applied through a post process or not.
  8582. */
  8583. set applyByPostProcess(value: boolean);
  8584. private _isEnabled;
  8585. /**
  8586. * Gets wether the image processing is enabled or not.
  8587. */
  8588. get isEnabled(): boolean;
  8589. /**
  8590. * Sets wether the image processing is enabled or not.
  8591. */
  8592. set isEnabled(value: boolean);
  8593. /**
  8594. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8595. */
  8596. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8597. /**
  8598. * Method called each time the image processing information changes requires to recompile the effect.
  8599. */
  8600. protected _updateParameters(): void;
  8601. /**
  8602. * Gets the current class name.
  8603. * @return "ImageProcessingConfiguration"
  8604. */
  8605. getClassName(): string;
  8606. /**
  8607. * Prepare the list of uniforms associated with the Image Processing effects.
  8608. * @param uniforms The list of uniforms used in the effect
  8609. * @param defines the list of defines currently in use
  8610. */
  8611. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8612. /**
  8613. * Prepare the list of samplers associated with the Image Processing effects.
  8614. * @param samplersList The list of uniforms used in the effect
  8615. * @param defines the list of defines currently in use
  8616. */
  8617. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8618. /**
  8619. * Prepare the list of defines associated to the shader.
  8620. * @param defines the list of defines to complete
  8621. * @param forPostProcess Define if we are currently in post process mode or not
  8622. */
  8623. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8624. /**
  8625. * Returns true if all the image processing information are ready.
  8626. * @returns True if ready, otherwise, false
  8627. */
  8628. isReady(): boolean;
  8629. /**
  8630. * Binds the image processing to the shader.
  8631. * @param effect The effect to bind to
  8632. * @param overrideAspectRatio Override the aspect ratio of the effect
  8633. */
  8634. bind(effect: Effect, overrideAspectRatio?: number): void;
  8635. /**
  8636. * Clones the current image processing instance.
  8637. * @return The cloned image processing
  8638. */
  8639. clone(): ImageProcessingConfiguration;
  8640. /**
  8641. * Serializes the current image processing instance to a json representation.
  8642. * @return a JSON representation
  8643. */
  8644. serialize(): any;
  8645. /**
  8646. * Parses the image processing from a json representation.
  8647. * @param source the JSON source to parse
  8648. * @return The parsed image processing
  8649. */
  8650. static Parse(source: any): ImageProcessingConfiguration;
  8651. private static _VIGNETTEMODE_MULTIPLY;
  8652. private static _VIGNETTEMODE_OPAQUE;
  8653. /**
  8654. * Used to apply the vignette as a mix with the pixel color.
  8655. */
  8656. static get VIGNETTEMODE_MULTIPLY(): number;
  8657. /**
  8658. * Used to apply the vignette as a replacement of the pixel color.
  8659. */
  8660. static get VIGNETTEMODE_OPAQUE(): number;
  8661. }
  8662. }
  8663. declare module BABYLON {
  8664. /** @hidden */
  8665. export var postprocessVertexShader: {
  8666. name: string;
  8667. shader: string;
  8668. };
  8669. }
  8670. declare module BABYLON {
  8671. /**
  8672. * Type used to define a render target texture size (either with a number or with a rect width and height)
  8673. */
  8674. export type RenderTargetTextureSize = number | {
  8675. width: number;
  8676. height: number;
  8677. layers?: number;
  8678. };
  8679. interface ThinEngine {
  8680. /**
  8681. * Creates a new render target texture
  8682. * @param size defines the size of the texture
  8683. * @param options defines the options used to create the texture
  8684. * @returns a new render target texture stored in an InternalTexture
  8685. */
  8686. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8687. /**
  8688. * Creates a depth stencil texture.
  8689. * This is only available in WebGL 2 or with the depth texture extension available.
  8690. * @param size The size of face edge in the texture.
  8691. * @param options The options defining the texture.
  8692. * @returns The texture
  8693. */
  8694. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8695. /** @hidden */
  8696. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8697. }
  8698. }
  8699. declare module BABYLON {
  8700. /**
  8701. * Defines the kind of connection point for node based material
  8702. */
  8703. export enum NodeMaterialBlockConnectionPointTypes {
  8704. /** Float */
  8705. Float = 1,
  8706. /** Int */
  8707. Int = 2,
  8708. /** Vector2 */
  8709. Vector2 = 4,
  8710. /** Vector3 */
  8711. Vector3 = 8,
  8712. /** Vector4 */
  8713. Vector4 = 16,
  8714. /** Color3 */
  8715. Color3 = 32,
  8716. /** Color4 */
  8717. Color4 = 64,
  8718. /** Matrix */
  8719. Matrix = 128,
  8720. /** Custom object */
  8721. Object = 256,
  8722. /** Detect type based on connection */
  8723. AutoDetect = 1024,
  8724. /** Output type that will be defined by input type */
  8725. BasedOnInput = 2048
  8726. }
  8727. }
  8728. declare module BABYLON {
  8729. /**
  8730. * Enum used to define the target of a block
  8731. */
  8732. export enum NodeMaterialBlockTargets {
  8733. /** Vertex shader */
  8734. Vertex = 1,
  8735. /** Fragment shader */
  8736. Fragment = 2,
  8737. /** Neutral */
  8738. Neutral = 4,
  8739. /** Vertex and Fragment */
  8740. VertexAndFragment = 3
  8741. }
  8742. }
  8743. declare module BABYLON {
  8744. /**
  8745. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8746. */
  8747. export enum NodeMaterialBlockConnectionPointMode {
  8748. /** Value is an uniform */
  8749. Uniform = 0,
  8750. /** Value is a mesh attribute */
  8751. Attribute = 1,
  8752. /** Value is a varying between vertex and fragment shaders */
  8753. Varying = 2,
  8754. /** Mode is undefined */
  8755. Undefined = 3
  8756. }
  8757. }
  8758. declare module BABYLON {
  8759. /**
  8760. * Enum used to define system values e.g. values automatically provided by the system
  8761. */
  8762. export enum NodeMaterialSystemValues {
  8763. /** World */
  8764. World = 1,
  8765. /** View */
  8766. View = 2,
  8767. /** Projection */
  8768. Projection = 3,
  8769. /** ViewProjection */
  8770. ViewProjection = 4,
  8771. /** WorldView */
  8772. WorldView = 5,
  8773. /** WorldViewProjection */
  8774. WorldViewProjection = 6,
  8775. /** CameraPosition */
  8776. CameraPosition = 7,
  8777. /** Fog Color */
  8778. FogColor = 8,
  8779. /** Delta time */
  8780. DeltaTime = 9
  8781. }
  8782. }
  8783. declare module BABYLON {
  8784. /** Defines supported spaces */
  8785. export enum Space {
  8786. /** Local (object) space */
  8787. LOCAL = 0,
  8788. /** World space */
  8789. WORLD = 1,
  8790. /** Bone space */
  8791. BONE = 2
  8792. }
  8793. /** Defines the 3 main axes */
  8794. export class Axis {
  8795. /** X axis */
  8796. static X: Vector3;
  8797. /** Y axis */
  8798. static Y: Vector3;
  8799. /** Z axis */
  8800. static Z: Vector3;
  8801. }
  8802. /**
  8803. * Defines cartesian components.
  8804. */
  8805. export enum Coordinate {
  8806. /** X axis */
  8807. X = 0,
  8808. /** Y axis */
  8809. Y = 1,
  8810. /** Z axis */
  8811. Z = 2
  8812. }
  8813. }
  8814. declare module BABYLON {
  8815. /**
  8816. * Represents a camera frustum
  8817. */
  8818. export class Frustum {
  8819. /**
  8820. * Gets the planes representing the frustum
  8821. * @param transform matrix to be applied to the returned planes
  8822. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8823. */
  8824. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8825. /**
  8826. * Gets the near frustum plane transformed by the transform matrix
  8827. * @param transform transformation matrix to be applied to the resulting frustum plane
  8828. * @param frustumPlane the resuling frustum plane
  8829. */
  8830. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8831. /**
  8832. * Gets the far frustum plane transformed by the transform matrix
  8833. * @param transform transformation matrix to be applied to the resulting frustum plane
  8834. * @param frustumPlane the resuling frustum plane
  8835. */
  8836. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8837. /**
  8838. * Gets the left frustum plane transformed by the transform matrix
  8839. * @param transform transformation matrix to be applied to the resulting frustum plane
  8840. * @param frustumPlane the resuling frustum plane
  8841. */
  8842. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8843. /**
  8844. * Gets the right frustum plane transformed by the transform matrix
  8845. * @param transform transformation matrix to be applied to the resulting frustum plane
  8846. * @param frustumPlane the resuling frustum plane
  8847. */
  8848. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8849. /**
  8850. * Gets the top frustum plane transformed by the transform matrix
  8851. * @param transform transformation matrix to be applied to the resulting frustum plane
  8852. * @param frustumPlane the resuling frustum plane
  8853. */
  8854. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8855. /**
  8856. * Gets the bottom frustum plane transformed by the transform matrix
  8857. * @param transform transformation matrix to be applied to the resulting frustum plane
  8858. * @param frustumPlane the resuling frustum plane
  8859. */
  8860. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8861. /**
  8862. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8863. * @param transform transformation matrix to be applied to the resulting frustum planes
  8864. * @param frustumPlanes the resuling frustum planes
  8865. */
  8866. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8867. }
  8868. }
  8869. declare module BABYLON {
  8870. /**
  8871. * Interface for the size containing width and height
  8872. */
  8873. export interface ISize {
  8874. /**
  8875. * Width
  8876. */
  8877. width: number;
  8878. /**
  8879. * Heighht
  8880. */
  8881. height: number;
  8882. }
  8883. /**
  8884. * Size containing widht and height
  8885. */
  8886. export class Size implements ISize {
  8887. /**
  8888. * Width
  8889. */
  8890. width: number;
  8891. /**
  8892. * Height
  8893. */
  8894. height: number;
  8895. /**
  8896. * Creates a Size object from the given width and height (floats).
  8897. * @param width width of the new size
  8898. * @param height height of the new size
  8899. */
  8900. constructor(width: number, height: number);
  8901. /**
  8902. * Returns a string with the Size width and height
  8903. * @returns a string with the Size width and height
  8904. */
  8905. toString(): string;
  8906. /**
  8907. * "Size"
  8908. * @returns the string "Size"
  8909. */
  8910. getClassName(): string;
  8911. /**
  8912. * Returns the Size hash code.
  8913. * @returns a hash code for a unique width and height
  8914. */
  8915. getHashCode(): number;
  8916. /**
  8917. * Updates the current size from the given one.
  8918. * @param src the given size
  8919. */
  8920. copyFrom(src: Size): void;
  8921. /**
  8922. * Updates in place the current Size from the given floats.
  8923. * @param width width of the new size
  8924. * @param height height of the new size
  8925. * @returns the updated Size.
  8926. */
  8927. copyFromFloats(width: number, height: number): Size;
  8928. /**
  8929. * Updates in place the current Size from the given floats.
  8930. * @param width width to set
  8931. * @param height height to set
  8932. * @returns the updated Size.
  8933. */
  8934. set(width: number, height: number): Size;
  8935. /**
  8936. * Multiplies the width and height by numbers
  8937. * @param w factor to multiple the width by
  8938. * @param h factor to multiple the height by
  8939. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8940. */
  8941. multiplyByFloats(w: number, h: number): Size;
  8942. /**
  8943. * Clones the size
  8944. * @returns a new Size copied from the given one.
  8945. */
  8946. clone(): Size;
  8947. /**
  8948. * True if the current Size and the given one width and height are strictly equal.
  8949. * @param other the other size to compare against
  8950. * @returns True if the current Size and the given one width and height are strictly equal.
  8951. */
  8952. equals(other: Size): boolean;
  8953. /**
  8954. * The surface of the Size : width * height (float).
  8955. */
  8956. get surface(): number;
  8957. /**
  8958. * Create a new size of zero
  8959. * @returns a new Size set to (0.0, 0.0)
  8960. */
  8961. static Zero(): Size;
  8962. /**
  8963. * Sums the width and height of two sizes
  8964. * @param otherSize size to add to this size
  8965. * @returns a new Size set as the addition result of the current Size and the given one.
  8966. */
  8967. add(otherSize: Size): Size;
  8968. /**
  8969. * Subtracts the width and height of two
  8970. * @param otherSize size to subtract to this size
  8971. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8972. */
  8973. subtract(otherSize: Size): Size;
  8974. /**
  8975. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8976. * @param start starting size to lerp between
  8977. * @param end end size to lerp between
  8978. * @param amount amount to lerp between the start and end values
  8979. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8980. */
  8981. static Lerp(start: Size, end: Size, amount: number): Size;
  8982. }
  8983. }
  8984. declare module BABYLON {
  8985. /**
  8986. * Contains position and normal vectors for a vertex
  8987. */
  8988. export class PositionNormalVertex {
  8989. /** the position of the vertex (defaut: 0,0,0) */
  8990. position: Vector3;
  8991. /** the normal of the vertex (defaut: 0,1,0) */
  8992. normal: Vector3;
  8993. /**
  8994. * Creates a PositionNormalVertex
  8995. * @param position the position of the vertex (defaut: 0,0,0)
  8996. * @param normal the normal of the vertex (defaut: 0,1,0)
  8997. */
  8998. constructor(
  8999. /** the position of the vertex (defaut: 0,0,0) */
  9000. position?: Vector3,
  9001. /** the normal of the vertex (defaut: 0,1,0) */
  9002. normal?: Vector3);
  9003. /**
  9004. * Clones the PositionNormalVertex
  9005. * @returns the cloned PositionNormalVertex
  9006. */
  9007. clone(): PositionNormalVertex;
  9008. }
  9009. /**
  9010. * Contains position, normal and uv vectors for a vertex
  9011. */
  9012. export class PositionNormalTextureVertex {
  9013. /** the position of the vertex (defaut: 0,0,0) */
  9014. position: Vector3;
  9015. /** the normal of the vertex (defaut: 0,1,0) */
  9016. normal: Vector3;
  9017. /** the uv of the vertex (default: 0,0) */
  9018. uv: Vector2;
  9019. /**
  9020. * Creates a PositionNormalTextureVertex
  9021. * @param position the position of the vertex (defaut: 0,0,0)
  9022. * @param normal the normal of the vertex (defaut: 0,1,0)
  9023. * @param uv the uv of the vertex (default: 0,0)
  9024. */
  9025. constructor(
  9026. /** the position of the vertex (defaut: 0,0,0) */
  9027. position?: Vector3,
  9028. /** the normal of the vertex (defaut: 0,1,0) */
  9029. normal?: Vector3,
  9030. /** the uv of the vertex (default: 0,0) */
  9031. uv?: Vector2);
  9032. /**
  9033. * Clones the PositionNormalTextureVertex
  9034. * @returns the cloned PositionNormalTextureVertex
  9035. */
  9036. clone(): PositionNormalTextureVertex;
  9037. }
  9038. }
  9039. declare module BABYLON {
  9040. /**
  9041. * Enum defining the type of animations supported by InputBlock
  9042. */
  9043. export enum AnimatedInputBlockTypes {
  9044. /** No animation */
  9045. None = 0,
  9046. /** Time based animation. Will only work for floats */
  9047. Time = 1
  9048. }
  9049. }
  9050. declare module BABYLON {
  9051. /**
  9052. * Interface describing all the common properties and methods a shadow light needs to implement.
  9053. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9054. * as well as binding the different shadow properties to the effects.
  9055. */
  9056. export interface IShadowLight extends Light {
  9057. /**
  9058. * The light id in the scene (used in scene.findLighById for instance)
  9059. */
  9060. id: string;
  9061. /**
  9062. * The position the shdow will be casted from.
  9063. */
  9064. position: Vector3;
  9065. /**
  9066. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9067. */
  9068. direction: Vector3;
  9069. /**
  9070. * The transformed position. Position of the light in world space taking parenting in account.
  9071. */
  9072. transformedPosition: Vector3;
  9073. /**
  9074. * The transformed direction. Direction of the light in world space taking parenting in account.
  9075. */
  9076. transformedDirection: Vector3;
  9077. /**
  9078. * The friendly name of the light in the scene.
  9079. */
  9080. name: string;
  9081. /**
  9082. * Defines the shadow projection clipping minimum z value.
  9083. */
  9084. shadowMinZ: number;
  9085. /**
  9086. * Defines the shadow projection clipping maximum z value.
  9087. */
  9088. shadowMaxZ: number;
  9089. /**
  9090. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9091. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9092. */
  9093. computeTransformedInformation(): boolean;
  9094. /**
  9095. * Gets the scene the light belongs to.
  9096. * @returns The scene
  9097. */
  9098. getScene(): Scene;
  9099. /**
  9100. * Callback defining a custom Projection Matrix Builder.
  9101. * This can be used to override the default projection matrix computation.
  9102. */
  9103. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9104. /**
  9105. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9106. * @param matrix The materix to updated with the projection information
  9107. * @param viewMatrix The transform matrix of the light
  9108. * @param renderList The list of mesh to render in the map
  9109. * @returns The current light
  9110. */
  9111. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9112. /**
  9113. * Gets the current depth scale used in ESM.
  9114. * @returns The scale
  9115. */
  9116. getDepthScale(): number;
  9117. /**
  9118. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9119. * @returns true if a cube texture needs to be use
  9120. */
  9121. needCube(): boolean;
  9122. /**
  9123. * Detects if the projection matrix requires to be recomputed this frame.
  9124. * @returns true if it requires to be recomputed otherwise, false.
  9125. */
  9126. needProjectionMatrixCompute(): boolean;
  9127. /**
  9128. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9129. */
  9130. forceProjectionMatrixCompute(): void;
  9131. /**
  9132. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9133. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9134. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9135. */
  9136. getShadowDirection(faceIndex?: number): Vector3;
  9137. /**
  9138. * Gets the minZ used for shadow according to both the scene and the light.
  9139. * @param activeCamera The camera we are returning the min for
  9140. * @returns the depth min z
  9141. */
  9142. getDepthMinZ(activeCamera: Camera): number;
  9143. /**
  9144. * Gets the maxZ used for shadow according to both the scene and the light.
  9145. * @param activeCamera The camera we are returning the max for
  9146. * @returns the depth max z
  9147. */
  9148. getDepthMaxZ(activeCamera: Camera): number;
  9149. }
  9150. /**
  9151. * Base implementation IShadowLight
  9152. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9153. */
  9154. export abstract class ShadowLight extends Light implements IShadowLight {
  9155. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9156. protected _position: Vector3;
  9157. protected _setPosition(value: Vector3): void;
  9158. /**
  9159. * Sets the position the shadow will be casted from. Also use as the light position for both
  9160. * point and spot lights.
  9161. */
  9162. get position(): Vector3;
  9163. /**
  9164. * Sets the position the shadow will be casted from. Also use as the light position for both
  9165. * point and spot lights.
  9166. */
  9167. set position(value: Vector3);
  9168. protected _direction: Vector3;
  9169. protected _setDirection(value: Vector3): void;
  9170. /**
  9171. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9172. * Also use as the light direction on spot and directional lights.
  9173. */
  9174. get direction(): Vector3;
  9175. /**
  9176. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9177. * Also use as the light direction on spot and directional lights.
  9178. */
  9179. set direction(value: Vector3);
  9180. protected _shadowMinZ: number;
  9181. /**
  9182. * Gets the shadow projection clipping minimum z value.
  9183. */
  9184. get shadowMinZ(): number;
  9185. /**
  9186. * Sets the shadow projection clipping minimum z value.
  9187. */
  9188. set shadowMinZ(value: number);
  9189. protected _shadowMaxZ: number;
  9190. /**
  9191. * Sets the shadow projection clipping maximum z value.
  9192. */
  9193. get shadowMaxZ(): number;
  9194. /**
  9195. * Gets the shadow projection clipping maximum z value.
  9196. */
  9197. set shadowMaxZ(value: number);
  9198. /**
  9199. * Callback defining a custom Projection Matrix Builder.
  9200. * This can be used to override the default projection matrix computation.
  9201. */
  9202. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9203. /**
  9204. * The transformed position. Position of the light in world space taking parenting in account.
  9205. */
  9206. transformedPosition: Vector3;
  9207. /**
  9208. * The transformed direction. Direction of the light in world space taking parenting in account.
  9209. */
  9210. transformedDirection: Vector3;
  9211. private _needProjectionMatrixCompute;
  9212. /**
  9213. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9214. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9215. */
  9216. computeTransformedInformation(): boolean;
  9217. /**
  9218. * Return the depth scale used for the shadow map.
  9219. * @returns the depth scale.
  9220. */
  9221. getDepthScale(): number;
  9222. /**
  9223. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9224. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9225. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9226. */
  9227. getShadowDirection(faceIndex?: number): Vector3;
  9228. /**
  9229. * Returns the ShadowLight absolute position in the World.
  9230. * @returns the position vector in world space
  9231. */
  9232. getAbsolutePosition(): Vector3;
  9233. /**
  9234. * Sets the ShadowLight direction toward the passed target.
  9235. * @param target The point to target in local space
  9236. * @returns the updated ShadowLight direction
  9237. */
  9238. setDirectionToTarget(target: Vector3): Vector3;
  9239. /**
  9240. * Returns the light rotation in euler definition.
  9241. * @returns the x y z rotation in local space.
  9242. */
  9243. getRotation(): Vector3;
  9244. /**
  9245. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9246. * @returns true if a cube texture needs to be use
  9247. */
  9248. needCube(): boolean;
  9249. /**
  9250. * Detects if the projection matrix requires to be recomputed this frame.
  9251. * @returns true if it requires to be recomputed otherwise, false.
  9252. */
  9253. needProjectionMatrixCompute(): boolean;
  9254. /**
  9255. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9256. */
  9257. forceProjectionMatrixCompute(): void;
  9258. /** @hidden */
  9259. _initCache(): void;
  9260. /** @hidden */
  9261. _isSynchronized(): boolean;
  9262. /**
  9263. * Computes the world matrix of the node
  9264. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9265. * @returns the world matrix
  9266. */
  9267. computeWorldMatrix(force?: boolean): Matrix;
  9268. /**
  9269. * Gets the minZ used for shadow according to both the scene and the light.
  9270. * @param activeCamera The camera we are returning the min for
  9271. * @returns the depth min z
  9272. */
  9273. getDepthMinZ(activeCamera: Camera): number;
  9274. /**
  9275. * Gets the maxZ used for shadow according to both the scene and the light.
  9276. * @param activeCamera The camera we are returning the max for
  9277. * @returns the depth max z
  9278. */
  9279. getDepthMaxZ(activeCamera: Camera): number;
  9280. /**
  9281. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9282. * @param matrix The materix to updated with the projection information
  9283. * @param viewMatrix The transform matrix of the light
  9284. * @param renderList The list of mesh to render in the map
  9285. * @returns The current light
  9286. */
  9287. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9288. }
  9289. }
  9290. declare module BABYLON {
  9291. /** @hidden */
  9292. export var packingFunctions: {
  9293. name: string;
  9294. shader: string;
  9295. };
  9296. }
  9297. declare module BABYLON {
  9298. /** @hidden */
  9299. export var bayerDitherFunctions: {
  9300. name: string;
  9301. shader: string;
  9302. };
  9303. }
  9304. declare module BABYLON {
  9305. /** @hidden */
  9306. export var shadowMapFragmentDeclaration: {
  9307. name: string;
  9308. shader: string;
  9309. };
  9310. }
  9311. declare module BABYLON {
  9312. /** @hidden */
  9313. export var clipPlaneFragmentDeclaration: {
  9314. name: string;
  9315. shader: string;
  9316. };
  9317. }
  9318. declare module BABYLON {
  9319. /** @hidden */
  9320. export var clipPlaneFragment: {
  9321. name: string;
  9322. shader: string;
  9323. };
  9324. }
  9325. declare module BABYLON {
  9326. /** @hidden */
  9327. export var shadowMapFragment: {
  9328. name: string;
  9329. shader: string;
  9330. };
  9331. }
  9332. declare module BABYLON {
  9333. /** @hidden */
  9334. export var shadowMapPixelShader: {
  9335. name: string;
  9336. shader: string;
  9337. };
  9338. }
  9339. declare module BABYLON {
  9340. /** @hidden */
  9341. export var bonesDeclaration: {
  9342. name: string;
  9343. shader: string;
  9344. };
  9345. }
  9346. declare module BABYLON {
  9347. /** @hidden */
  9348. export var morphTargetsVertexGlobalDeclaration: {
  9349. name: string;
  9350. shader: string;
  9351. };
  9352. }
  9353. declare module BABYLON {
  9354. /** @hidden */
  9355. export var morphTargetsVertexDeclaration: {
  9356. name: string;
  9357. shader: string;
  9358. };
  9359. }
  9360. declare module BABYLON {
  9361. /** @hidden */
  9362. export var instancesDeclaration: {
  9363. name: string;
  9364. shader: string;
  9365. };
  9366. }
  9367. declare module BABYLON {
  9368. /** @hidden */
  9369. export var helperFunctions: {
  9370. name: string;
  9371. shader: string;
  9372. };
  9373. }
  9374. declare module BABYLON {
  9375. /** @hidden */
  9376. export var shadowMapVertexDeclaration: {
  9377. name: string;
  9378. shader: string;
  9379. };
  9380. }
  9381. declare module BABYLON {
  9382. /** @hidden */
  9383. export var clipPlaneVertexDeclaration: {
  9384. name: string;
  9385. shader: string;
  9386. };
  9387. }
  9388. declare module BABYLON {
  9389. /** @hidden */
  9390. export var morphTargetsVertex: {
  9391. name: string;
  9392. shader: string;
  9393. };
  9394. }
  9395. declare module BABYLON {
  9396. /** @hidden */
  9397. export var instancesVertex: {
  9398. name: string;
  9399. shader: string;
  9400. };
  9401. }
  9402. declare module BABYLON {
  9403. /** @hidden */
  9404. export var bonesVertex: {
  9405. name: string;
  9406. shader: string;
  9407. };
  9408. }
  9409. declare module BABYLON {
  9410. /** @hidden */
  9411. export var shadowMapVertexNormalBias: {
  9412. name: string;
  9413. shader: string;
  9414. };
  9415. }
  9416. declare module BABYLON {
  9417. /** @hidden */
  9418. export var shadowMapVertexMetric: {
  9419. name: string;
  9420. shader: string;
  9421. };
  9422. }
  9423. declare module BABYLON {
  9424. /** @hidden */
  9425. export var clipPlaneVertex: {
  9426. name: string;
  9427. shader: string;
  9428. };
  9429. }
  9430. declare module BABYLON {
  9431. /** @hidden */
  9432. export var shadowMapVertexShader: {
  9433. name: string;
  9434. shader: string;
  9435. };
  9436. }
  9437. declare module BABYLON {
  9438. /** @hidden */
  9439. export var depthBoxBlurPixelShader: {
  9440. name: string;
  9441. shader: string;
  9442. };
  9443. }
  9444. declare module BABYLON {
  9445. /** @hidden */
  9446. export var shadowMapFragmentSoftTransparentShadow: {
  9447. name: string;
  9448. shader: string;
  9449. };
  9450. }
  9451. declare module BABYLON {
  9452. /**
  9453. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9454. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9455. */
  9456. export class EffectFallbacks implements IEffectFallbacks {
  9457. private _defines;
  9458. private _currentRank;
  9459. private _maxRank;
  9460. private _mesh;
  9461. /**
  9462. * Removes the fallback from the bound mesh.
  9463. */
  9464. unBindMesh(): void;
  9465. /**
  9466. * Adds a fallback on the specified property.
  9467. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9468. * @param define The name of the define in the shader
  9469. */
  9470. addFallback(rank: number, define: string): void;
  9471. /**
  9472. * Sets the mesh to use CPU skinning when needing to fallback.
  9473. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9474. * @param mesh The mesh to use the fallbacks.
  9475. */
  9476. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9477. /**
  9478. * Checks to see if more fallbacks are still availible.
  9479. */
  9480. get hasMoreFallbacks(): boolean;
  9481. /**
  9482. * Removes the defines that should be removed when falling back.
  9483. * @param currentDefines defines the current define statements for the shader.
  9484. * @param effect defines the current effect we try to compile
  9485. * @returns The resulting defines with defines of the current rank removed.
  9486. */
  9487. reduce(currentDefines: string, effect: Effect): string;
  9488. }
  9489. }
  9490. declare module BABYLON {
  9491. /**
  9492. * Interface used to define Action
  9493. */
  9494. export interface IAction {
  9495. /**
  9496. * Trigger for the action
  9497. */
  9498. trigger: number;
  9499. /** Options of the trigger */
  9500. triggerOptions: any;
  9501. /**
  9502. * Gets the trigger parameters
  9503. * @returns the trigger parameters
  9504. */
  9505. getTriggerParameter(): any;
  9506. /**
  9507. * Internal only - executes current action event
  9508. * @hidden
  9509. */
  9510. _executeCurrent(evt?: ActionEvent): void;
  9511. /**
  9512. * Serialize placeholder for child classes
  9513. * @param parent of child
  9514. * @returns the serialized object
  9515. */
  9516. serialize(parent: any): any;
  9517. /**
  9518. * Internal only
  9519. * @hidden
  9520. */
  9521. _prepare(): void;
  9522. /**
  9523. * Internal only - manager for action
  9524. * @hidden
  9525. */
  9526. _actionManager: Nullable<AbstractActionManager>;
  9527. /**
  9528. * Adds action to chain of actions, may be a DoNothingAction
  9529. * @param action defines the next action to execute
  9530. * @returns The action passed in
  9531. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9532. */
  9533. then(action: IAction): IAction;
  9534. }
  9535. /**
  9536. * The action to be carried out following a trigger
  9537. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9538. */
  9539. export class Action implements IAction {
  9540. /** the trigger, with or without parameters, for the action */
  9541. triggerOptions: any;
  9542. /**
  9543. * Trigger for the action
  9544. */
  9545. trigger: number;
  9546. /**
  9547. * Internal only - manager for action
  9548. * @hidden
  9549. */
  9550. _actionManager: ActionManager;
  9551. private _nextActiveAction;
  9552. private _child;
  9553. private _condition?;
  9554. private _triggerParameter;
  9555. /**
  9556. * An event triggered prior to action being executed.
  9557. */
  9558. onBeforeExecuteObservable: Observable<Action>;
  9559. /**
  9560. * Creates a new Action
  9561. * @param triggerOptions the trigger, with or without parameters, for the action
  9562. * @param condition an optional determinant of action
  9563. */
  9564. constructor(
  9565. /** the trigger, with or without parameters, for the action */
  9566. triggerOptions: any, condition?: Condition);
  9567. /**
  9568. * Internal only
  9569. * @hidden
  9570. */
  9571. _prepare(): void;
  9572. /**
  9573. * Gets the trigger parameters
  9574. * @returns the trigger parameters
  9575. */
  9576. getTriggerParameter(): any;
  9577. /**
  9578. * Internal only - executes current action event
  9579. * @hidden
  9580. */
  9581. _executeCurrent(evt?: ActionEvent): void;
  9582. /**
  9583. * Execute placeholder for child classes
  9584. * @param evt optional action event
  9585. */
  9586. execute(evt?: ActionEvent): void;
  9587. /**
  9588. * Skips to next active action
  9589. */
  9590. skipToNextActiveAction(): void;
  9591. /**
  9592. * Adds action to chain of actions, may be a DoNothingAction
  9593. * @param action defines the next action to execute
  9594. * @returns The action passed in
  9595. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9596. */
  9597. then(action: Action): Action;
  9598. /**
  9599. * Internal only
  9600. * @hidden
  9601. */
  9602. _getProperty(propertyPath: string): string;
  9603. /**
  9604. * Internal only
  9605. * @hidden
  9606. */
  9607. _getEffectiveTarget(target: any, propertyPath: string): any;
  9608. /**
  9609. * Serialize placeholder for child classes
  9610. * @param parent of child
  9611. * @returns the serialized object
  9612. */
  9613. serialize(parent: any): any;
  9614. /**
  9615. * Internal only called by serialize
  9616. * @hidden
  9617. */
  9618. protected _serialize(serializedAction: any, parent?: any): any;
  9619. /**
  9620. * Internal only
  9621. * @hidden
  9622. */
  9623. static _SerializeValueAsString: (value: any) => string;
  9624. /**
  9625. * Internal only
  9626. * @hidden
  9627. */
  9628. static _GetTargetProperty: (target: Scene | Node) => {
  9629. name: string;
  9630. targetType: string;
  9631. value: string;
  9632. };
  9633. }
  9634. }
  9635. declare module BABYLON {
  9636. /**
  9637. * A Condition applied to an Action
  9638. */
  9639. export class Condition {
  9640. /**
  9641. * Internal only - manager for action
  9642. * @hidden
  9643. */
  9644. _actionManager: ActionManager;
  9645. /**
  9646. * Internal only
  9647. * @hidden
  9648. */
  9649. _evaluationId: number;
  9650. /**
  9651. * Internal only
  9652. * @hidden
  9653. */
  9654. _currentResult: boolean;
  9655. /**
  9656. * Creates a new Condition
  9657. * @param actionManager the manager of the action the condition is applied to
  9658. */
  9659. constructor(actionManager: ActionManager);
  9660. /**
  9661. * Check if the current condition is valid
  9662. * @returns a boolean
  9663. */
  9664. isValid(): boolean;
  9665. /**
  9666. * Internal only
  9667. * @hidden
  9668. */
  9669. _getProperty(propertyPath: string): string;
  9670. /**
  9671. * Internal only
  9672. * @hidden
  9673. */
  9674. _getEffectiveTarget(target: any, propertyPath: string): any;
  9675. /**
  9676. * Serialize placeholder for child classes
  9677. * @returns the serialized object
  9678. */
  9679. serialize(): any;
  9680. /**
  9681. * Internal only
  9682. * @hidden
  9683. */
  9684. protected _serialize(serializedCondition: any): any;
  9685. }
  9686. /**
  9687. * Defines specific conditional operators as extensions of Condition
  9688. */
  9689. export class ValueCondition extends Condition {
  9690. /** path to specify the property of the target the conditional operator uses */
  9691. propertyPath: string;
  9692. /** the value compared by the conditional operator against the current value of the property */
  9693. value: any;
  9694. /** the conditional operator, default ValueCondition.IsEqual */
  9695. operator: number;
  9696. /**
  9697. * Internal only
  9698. * @hidden
  9699. */
  9700. private static _IsEqual;
  9701. /**
  9702. * Internal only
  9703. * @hidden
  9704. */
  9705. private static _IsDifferent;
  9706. /**
  9707. * Internal only
  9708. * @hidden
  9709. */
  9710. private static _IsGreater;
  9711. /**
  9712. * Internal only
  9713. * @hidden
  9714. */
  9715. private static _IsLesser;
  9716. /**
  9717. * returns the number for IsEqual
  9718. */
  9719. static get IsEqual(): number;
  9720. /**
  9721. * Returns the number for IsDifferent
  9722. */
  9723. static get IsDifferent(): number;
  9724. /**
  9725. * Returns the number for IsGreater
  9726. */
  9727. static get IsGreater(): number;
  9728. /**
  9729. * Returns the number for IsLesser
  9730. */
  9731. static get IsLesser(): number;
  9732. /**
  9733. * Internal only The action manager for the condition
  9734. * @hidden
  9735. */
  9736. _actionManager: ActionManager;
  9737. /**
  9738. * Internal only
  9739. * @hidden
  9740. */
  9741. private _target;
  9742. /**
  9743. * Internal only
  9744. * @hidden
  9745. */
  9746. private _effectiveTarget;
  9747. /**
  9748. * Internal only
  9749. * @hidden
  9750. */
  9751. private _property;
  9752. /**
  9753. * Creates a new ValueCondition
  9754. * @param actionManager manager for the action the condition applies to
  9755. * @param target for the action
  9756. * @param propertyPath path to specify the property of the target the conditional operator uses
  9757. * @param value the value compared by the conditional operator against the current value of the property
  9758. * @param operator the conditional operator, default ValueCondition.IsEqual
  9759. */
  9760. constructor(actionManager: ActionManager, target: any,
  9761. /** path to specify the property of the target the conditional operator uses */
  9762. propertyPath: string,
  9763. /** the value compared by the conditional operator against the current value of the property */
  9764. value: any,
  9765. /** the conditional operator, default ValueCondition.IsEqual */
  9766. operator?: number);
  9767. /**
  9768. * Compares the given value with the property value for the specified conditional operator
  9769. * @returns the result of the comparison
  9770. */
  9771. isValid(): boolean;
  9772. /**
  9773. * Serialize the ValueCondition into a JSON compatible object
  9774. * @returns serialization object
  9775. */
  9776. serialize(): any;
  9777. /**
  9778. * Gets the name of the conditional operator for the ValueCondition
  9779. * @param operator the conditional operator
  9780. * @returns the name
  9781. */
  9782. static GetOperatorName(operator: number): string;
  9783. }
  9784. /**
  9785. * Defines a predicate condition as an extension of Condition
  9786. */
  9787. export class PredicateCondition extends Condition {
  9788. /** defines the predicate function used to validate the condition */
  9789. predicate: () => boolean;
  9790. /**
  9791. * Internal only - manager for action
  9792. * @hidden
  9793. */
  9794. _actionManager: ActionManager;
  9795. /**
  9796. * Creates a new PredicateCondition
  9797. * @param actionManager manager for the action the condition applies to
  9798. * @param predicate defines the predicate function used to validate the condition
  9799. */
  9800. constructor(actionManager: ActionManager,
  9801. /** defines the predicate function used to validate the condition */
  9802. predicate: () => boolean);
  9803. /**
  9804. * @returns the validity of the predicate condition
  9805. */
  9806. isValid(): boolean;
  9807. }
  9808. /**
  9809. * Defines a state condition as an extension of Condition
  9810. */
  9811. export class StateCondition extends Condition {
  9812. /** Value to compare with target state */
  9813. value: string;
  9814. /**
  9815. * Internal only - manager for action
  9816. * @hidden
  9817. */
  9818. _actionManager: ActionManager;
  9819. /**
  9820. * Internal only
  9821. * @hidden
  9822. */
  9823. private _target;
  9824. /**
  9825. * Creates a new StateCondition
  9826. * @param actionManager manager for the action the condition applies to
  9827. * @param target of the condition
  9828. * @param value to compare with target state
  9829. */
  9830. constructor(actionManager: ActionManager, target: any,
  9831. /** Value to compare with target state */
  9832. value: string);
  9833. /**
  9834. * Gets a boolean indicating if the current condition is met
  9835. * @returns the validity of the state
  9836. */
  9837. isValid(): boolean;
  9838. /**
  9839. * Serialize the StateCondition into a JSON compatible object
  9840. * @returns serialization object
  9841. */
  9842. serialize(): any;
  9843. }
  9844. }
  9845. declare module BABYLON {
  9846. /**
  9847. * This defines an action responsible to toggle a boolean once triggered.
  9848. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9849. */
  9850. export class SwitchBooleanAction extends Action {
  9851. /**
  9852. * The path to the boolean property in the target object
  9853. */
  9854. propertyPath: string;
  9855. private _target;
  9856. private _effectiveTarget;
  9857. private _property;
  9858. /**
  9859. * Instantiate the action
  9860. * @param triggerOptions defines the trigger options
  9861. * @param target defines the object containing the boolean
  9862. * @param propertyPath defines the path to the boolean property in the target object
  9863. * @param condition defines the trigger related conditions
  9864. */
  9865. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9866. /** @hidden */
  9867. _prepare(): void;
  9868. /**
  9869. * Execute the action toggle the boolean value.
  9870. */
  9871. execute(): void;
  9872. /**
  9873. * Serializes the actions and its related information.
  9874. * @param parent defines the object to serialize in
  9875. * @returns the serialized object
  9876. */
  9877. serialize(parent: any): any;
  9878. }
  9879. /**
  9880. * This defines an action responsible to set a the state field of the target
  9881. * to a desired value once triggered.
  9882. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9883. */
  9884. export class SetStateAction extends Action {
  9885. /**
  9886. * The value to store in the state field.
  9887. */
  9888. value: string;
  9889. private _target;
  9890. /**
  9891. * Instantiate the action
  9892. * @param triggerOptions defines the trigger options
  9893. * @param target defines the object containing the state property
  9894. * @param value defines the value to store in the state field
  9895. * @param condition defines the trigger related conditions
  9896. */
  9897. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9898. /**
  9899. * Execute the action and store the value on the target state property.
  9900. */
  9901. execute(): void;
  9902. /**
  9903. * Serializes the actions and its related information.
  9904. * @param parent defines the object to serialize in
  9905. * @returns the serialized object
  9906. */
  9907. serialize(parent: any): any;
  9908. }
  9909. /**
  9910. * This defines an action responsible to set a property of the target
  9911. * to a desired value once triggered.
  9912. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9913. */
  9914. export class SetValueAction extends Action {
  9915. /**
  9916. * The path of the property to set in the target.
  9917. */
  9918. propertyPath: string;
  9919. /**
  9920. * The value to set in the property
  9921. */
  9922. value: any;
  9923. private _target;
  9924. private _effectiveTarget;
  9925. private _property;
  9926. /**
  9927. * Instantiate the action
  9928. * @param triggerOptions defines the trigger options
  9929. * @param target defines the object containing the property
  9930. * @param propertyPath defines the path of the property to set in the target
  9931. * @param value defines the value to set in the property
  9932. * @param condition defines the trigger related conditions
  9933. */
  9934. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9935. /** @hidden */
  9936. _prepare(): void;
  9937. /**
  9938. * Execute the action and set the targetted property to the desired value.
  9939. */
  9940. execute(): void;
  9941. /**
  9942. * Serializes the actions and its related information.
  9943. * @param parent defines the object to serialize in
  9944. * @returns the serialized object
  9945. */
  9946. serialize(parent: any): any;
  9947. }
  9948. /**
  9949. * This defines an action responsible to increment the target value
  9950. * to a desired value once triggered.
  9951. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9952. */
  9953. export class IncrementValueAction extends Action {
  9954. /**
  9955. * The path of the property to increment in the target.
  9956. */
  9957. propertyPath: string;
  9958. /**
  9959. * The value we should increment the property by.
  9960. */
  9961. value: any;
  9962. private _target;
  9963. private _effectiveTarget;
  9964. private _property;
  9965. /**
  9966. * Instantiate the action
  9967. * @param triggerOptions defines the trigger options
  9968. * @param target defines the object containing the property
  9969. * @param propertyPath defines the path of the property to increment in the target
  9970. * @param value defines the value value we should increment the property by
  9971. * @param condition defines the trigger related conditions
  9972. */
  9973. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9974. /** @hidden */
  9975. _prepare(): void;
  9976. /**
  9977. * Execute the action and increment the target of the value amount.
  9978. */
  9979. execute(): void;
  9980. /**
  9981. * Serializes the actions and its related information.
  9982. * @param parent defines the object to serialize in
  9983. * @returns the serialized object
  9984. */
  9985. serialize(parent: any): any;
  9986. }
  9987. /**
  9988. * This defines an action responsible to start an animation once triggered.
  9989. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9990. */
  9991. export class PlayAnimationAction extends Action {
  9992. /**
  9993. * Where the animation should start (animation frame)
  9994. */
  9995. from: number;
  9996. /**
  9997. * Where the animation should stop (animation frame)
  9998. */
  9999. to: number;
  10000. /**
  10001. * Define if the animation should loop or stop after the first play.
  10002. */
  10003. loop?: boolean;
  10004. private _target;
  10005. /**
  10006. * Instantiate the action
  10007. * @param triggerOptions defines the trigger options
  10008. * @param target defines the target animation or animation name
  10009. * @param from defines from where the animation should start (animation frame)
  10010. * @param end defines where the animation should stop (animation frame)
  10011. * @param loop defines if the animation should loop or stop after the first play
  10012. * @param condition defines the trigger related conditions
  10013. */
  10014. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10015. /** @hidden */
  10016. _prepare(): void;
  10017. /**
  10018. * Execute the action and play the animation.
  10019. */
  10020. execute(): void;
  10021. /**
  10022. * Serializes the actions and its related information.
  10023. * @param parent defines the object to serialize in
  10024. * @returns the serialized object
  10025. */
  10026. serialize(parent: any): any;
  10027. }
  10028. /**
  10029. * This defines an action responsible to stop an animation once triggered.
  10030. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10031. */
  10032. export class StopAnimationAction extends Action {
  10033. private _target;
  10034. /**
  10035. * Instantiate the action
  10036. * @param triggerOptions defines the trigger options
  10037. * @param target defines the target animation or animation name
  10038. * @param condition defines the trigger related conditions
  10039. */
  10040. constructor(triggerOptions: any, target: any, condition?: Condition);
  10041. /** @hidden */
  10042. _prepare(): void;
  10043. /**
  10044. * Execute the action and stop the animation.
  10045. */
  10046. execute(): void;
  10047. /**
  10048. * Serializes the actions and its related information.
  10049. * @param parent defines the object to serialize in
  10050. * @returns the serialized object
  10051. */
  10052. serialize(parent: any): any;
  10053. }
  10054. /**
  10055. * This defines an action responsible that does nothing once triggered.
  10056. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10057. */
  10058. export class DoNothingAction extends Action {
  10059. /**
  10060. * Instantiate the action
  10061. * @param triggerOptions defines the trigger options
  10062. * @param condition defines the trigger related conditions
  10063. */
  10064. constructor(triggerOptions?: any, condition?: Condition);
  10065. /**
  10066. * Execute the action and do nothing.
  10067. */
  10068. execute(): void;
  10069. /**
  10070. * Serializes the actions and its related information.
  10071. * @param parent defines the object to serialize in
  10072. * @returns the serialized object
  10073. */
  10074. serialize(parent: any): any;
  10075. }
  10076. /**
  10077. * This defines an action responsible to trigger several actions once triggered.
  10078. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10079. */
  10080. export class CombineAction extends Action {
  10081. /**
  10082. * The list of aggregated animations to run.
  10083. */
  10084. children: Action[];
  10085. /**
  10086. * Instantiate the action
  10087. * @param triggerOptions defines the trigger options
  10088. * @param children defines the list of aggregated animations to run
  10089. * @param condition defines the trigger related conditions
  10090. */
  10091. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10092. /** @hidden */
  10093. _prepare(): void;
  10094. /**
  10095. * Execute the action and executes all the aggregated actions.
  10096. */
  10097. execute(evt: ActionEvent): void;
  10098. /**
  10099. * Serializes the actions and its related information.
  10100. * @param parent defines the object to serialize in
  10101. * @returns the serialized object
  10102. */
  10103. serialize(parent: any): any;
  10104. }
  10105. /**
  10106. * This defines an action responsible to run code (external event) once triggered.
  10107. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10108. */
  10109. export class ExecuteCodeAction extends Action {
  10110. /**
  10111. * The callback function to run.
  10112. */
  10113. func: (evt: ActionEvent) => void;
  10114. /**
  10115. * Instantiate the action
  10116. * @param triggerOptions defines the trigger options
  10117. * @param func defines the callback function to run
  10118. * @param condition defines the trigger related conditions
  10119. */
  10120. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10121. /**
  10122. * Execute the action and run the attached code.
  10123. */
  10124. execute(evt: ActionEvent): void;
  10125. }
  10126. /**
  10127. * This defines an action responsible to set the parent property of the target once triggered.
  10128. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10129. */
  10130. export class SetParentAction extends Action {
  10131. private _parent;
  10132. private _target;
  10133. /**
  10134. * Instantiate the action
  10135. * @param triggerOptions defines the trigger options
  10136. * @param target defines the target containing the parent property
  10137. * @param parent defines from where the animation should start (animation frame)
  10138. * @param condition defines the trigger related conditions
  10139. */
  10140. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10141. /** @hidden */
  10142. _prepare(): void;
  10143. /**
  10144. * Execute the action and set the parent property.
  10145. */
  10146. execute(): void;
  10147. /**
  10148. * Serializes the actions and its related information.
  10149. * @param parent defines the object to serialize in
  10150. * @returns the serialized object
  10151. */
  10152. serialize(parent: any): any;
  10153. }
  10154. }
  10155. declare module BABYLON {
  10156. /**
  10157. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10158. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10159. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10160. */
  10161. export class ActionManager extends AbstractActionManager {
  10162. /**
  10163. * Nothing
  10164. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10165. */
  10166. static readonly NothingTrigger: number;
  10167. /**
  10168. * On pick
  10169. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10170. */
  10171. static readonly OnPickTrigger: number;
  10172. /**
  10173. * On left pick
  10174. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10175. */
  10176. static readonly OnLeftPickTrigger: number;
  10177. /**
  10178. * On right pick
  10179. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10180. */
  10181. static readonly OnRightPickTrigger: number;
  10182. /**
  10183. * On center pick
  10184. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10185. */
  10186. static readonly OnCenterPickTrigger: number;
  10187. /**
  10188. * On pick down
  10189. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10190. */
  10191. static readonly OnPickDownTrigger: number;
  10192. /**
  10193. * On double pick
  10194. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10195. */
  10196. static readonly OnDoublePickTrigger: number;
  10197. /**
  10198. * On pick up
  10199. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10200. */
  10201. static readonly OnPickUpTrigger: number;
  10202. /**
  10203. * On pick out.
  10204. * This trigger will only be raised if you also declared a OnPickDown
  10205. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10206. */
  10207. static readonly OnPickOutTrigger: number;
  10208. /**
  10209. * On long press
  10210. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10211. */
  10212. static readonly OnLongPressTrigger: number;
  10213. /**
  10214. * On pointer over
  10215. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10216. */
  10217. static readonly OnPointerOverTrigger: number;
  10218. /**
  10219. * On pointer out
  10220. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10221. */
  10222. static readonly OnPointerOutTrigger: number;
  10223. /**
  10224. * On every frame
  10225. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10226. */
  10227. static readonly OnEveryFrameTrigger: number;
  10228. /**
  10229. * On intersection enter
  10230. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10231. */
  10232. static readonly OnIntersectionEnterTrigger: number;
  10233. /**
  10234. * On intersection exit
  10235. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10236. */
  10237. static readonly OnIntersectionExitTrigger: number;
  10238. /**
  10239. * On key down
  10240. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10241. */
  10242. static readonly OnKeyDownTrigger: number;
  10243. /**
  10244. * On key up
  10245. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10246. */
  10247. static readonly OnKeyUpTrigger: number;
  10248. private _scene;
  10249. /**
  10250. * Creates a new action manager
  10251. * @param scene defines the hosting scene
  10252. */
  10253. constructor(scene: Scene);
  10254. /**
  10255. * Releases all associated resources
  10256. */
  10257. dispose(): void;
  10258. /**
  10259. * Gets hosting scene
  10260. * @returns the hosting scene
  10261. */
  10262. getScene(): Scene;
  10263. /**
  10264. * Does this action manager handles actions of any of the given triggers
  10265. * @param triggers defines the triggers to be tested
  10266. * @return a boolean indicating whether one (or more) of the triggers is handled
  10267. */
  10268. hasSpecificTriggers(triggers: number[]): boolean;
  10269. /**
  10270. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10271. * speed.
  10272. * @param triggerA defines the trigger to be tested
  10273. * @param triggerB defines the trigger to be tested
  10274. * @return a boolean indicating whether one (or more) of the triggers is handled
  10275. */
  10276. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10277. /**
  10278. * Does this action manager handles actions of a given trigger
  10279. * @param trigger defines the trigger to be tested
  10280. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10281. * @return whether the trigger is handled
  10282. */
  10283. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10284. /**
  10285. * Does this action manager has pointer triggers
  10286. */
  10287. get hasPointerTriggers(): boolean;
  10288. /**
  10289. * Does this action manager has pick triggers
  10290. */
  10291. get hasPickTriggers(): boolean;
  10292. /**
  10293. * Registers an action to this action manager
  10294. * @param action defines the action to be registered
  10295. * @return the action amended (prepared) after registration
  10296. */
  10297. registerAction(action: IAction): Nullable<IAction>;
  10298. /**
  10299. * Unregisters an action to this action manager
  10300. * @param action defines the action to be unregistered
  10301. * @return a boolean indicating whether the action has been unregistered
  10302. */
  10303. unregisterAction(action: IAction): Boolean;
  10304. /**
  10305. * Process a specific trigger
  10306. * @param trigger defines the trigger to process
  10307. * @param evt defines the event details to be processed
  10308. */
  10309. processTrigger(trigger: number, evt?: IActionEvent): void;
  10310. /** @hidden */
  10311. _getEffectiveTarget(target: any, propertyPath: string): any;
  10312. /** @hidden */
  10313. _getProperty(propertyPath: string): string;
  10314. /**
  10315. * Serialize this manager to a JSON object
  10316. * @param name defines the property name to store this manager
  10317. * @returns a JSON representation of this manager
  10318. */
  10319. serialize(name: string): any;
  10320. /**
  10321. * Creates a new ActionManager from a JSON data
  10322. * @param parsedActions defines the JSON data to read from
  10323. * @param object defines the hosting mesh
  10324. * @param scene defines the hosting scene
  10325. */
  10326. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10327. /**
  10328. * Get a trigger name by index
  10329. * @param trigger defines the trigger index
  10330. * @returns a trigger name
  10331. */
  10332. static GetTriggerName(trigger: number): string;
  10333. }
  10334. }
  10335. declare module BABYLON {
  10336. /**
  10337. * Class used to represent a sprite
  10338. * @see https://doc.babylonjs.com/babylon101/sprites
  10339. */
  10340. export class Sprite implements IAnimatable {
  10341. /** defines the name */
  10342. name: string;
  10343. /** Gets or sets the current world position */
  10344. position: Vector3;
  10345. /** Gets or sets the main color */
  10346. color: Color4;
  10347. /** Gets or sets the width */
  10348. width: number;
  10349. /** Gets or sets the height */
  10350. height: number;
  10351. /** Gets or sets rotation angle */
  10352. angle: number;
  10353. /** Gets or sets the cell index in the sprite sheet */
  10354. cellIndex: number;
  10355. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10356. cellRef: string;
  10357. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10358. invertU: boolean;
  10359. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10360. invertV: boolean;
  10361. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10362. disposeWhenFinishedAnimating: boolean;
  10363. /** Gets the list of attached animations */
  10364. animations: Nullable<Array<Animation>>;
  10365. /** Gets or sets a boolean indicating if the sprite can be picked */
  10366. isPickable: boolean;
  10367. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10368. useAlphaForPicking: boolean;
  10369. /** @hidden */
  10370. _xOffset: number;
  10371. /** @hidden */
  10372. _yOffset: number;
  10373. /** @hidden */
  10374. _xSize: number;
  10375. /** @hidden */
  10376. _ySize: number;
  10377. /**
  10378. * Gets or sets the associated action manager
  10379. */
  10380. actionManager: Nullable<ActionManager>;
  10381. /**
  10382. * An event triggered when the control has been disposed
  10383. */
  10384. onDisposeObservable: Observable<Sprite>;
  10385. private _animationStarted;
  10386. private _loopAnimation;
  10387. private _fromIndex;
  10388. private _toIndex;
  10389. private _delay;
  10390. private _direction;
  10391. private _manager;
  10392. private _time;
  10393. private _onAnimationEnd;
  10394. /**
  10395. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10396. */
  10397. isVisible: boolean;
  10398. /**
  10399. * Gets or sets the sprite size
  10400. */
  10401. get size(): number;
  10402. set size(value: number);
  10403. /**
  10404. * Returns a boolean indicating if the animation is started
  10405. */
  10406. get animationStarted(): boolean;
  10407. /**
  10408. * Gets or sets the unique id of the sprite
  10409. */
  10410. uniqueId: number;
  10411. /**
  10412. * Gets the manager of this sprite
  10413. */
  10414. get manager(): ISpriteManager;
  10415. /**
  10416. * Creates a new Sprite
  10417. * @param name defines the name
  10418. * @param manager defines the manager
  10419. */
  10420. constructor(
  10421. /** defines the name */
  10422. name: string, manager: ISpriteManager);
  10423. /**
  10424. * Returns the string "Sprite"
  10425. * @returns "Sprite"
  10426. */
  10427. getClassName(): string;
  10428. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10429. get fromIndex(): number;
  10430. set fromIndex(value: number);
  10431. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10432. get toIndex(): number;
  10433. set toIndex(value: number);
  10434. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10435. get loopAnimation(): boolean;
  10436. set loopAnimation(value: boolean);
  10437. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10438. get delay(): number;
  10439. set delay(value: number);
  10440. /**
  10441. * Starts an animation
  10442. * @param from defines the initial key
  10443. * @param to defines the end key
  10444. * @param loop defines if the animation must loop
  10445. * @param delay defines the start delay (in ms)
  10446. * @param onAnimationEnd defines a callback to call when animation ends
  10447. */
  10448. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10449. /** Stops current animation (if any) */
  10450. stopAnimation(): void;
  10451. /** @hidden */
  10452. _animate(deltaTime: number): void;
  10453. /** Release associated resources */
  10454. dispose(): void;
  10455. /**
  10456. * Serializes the sprite to a JSON object
  10457. * @returns the JSON object
  10458. */
  10459. serialize(): any;
  10460. /**
  10461. * Parses a JSON object to create a new sprite
  10462. * @param parsedSprite The JSON object to parse
  10463. * @param manager defines the hosting manager
  10464. * @returns the new sprite
  10465. */
  10466. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10467. }
  10468. }
  10469. declare module BABYLON {
  10470. /**
  10471. * Information about the result of picking within a scene
  10472. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10473. */
  10474. export class PickingInfo {
  10475. /** @hidden */
  10476. _pickingUnavailable: boolean;
  10477. /**
  10478. * If the pick collided with an object
  10479. */
  10480. hit: boolean;
  10481. /**
  10482. * Distance away where the pick collided
  10483. */
  10484. distance: number;
  10485. /**
  10486. * The location of pick collision
  10487. */
  10488. pickedPoint: Nullable<Vector3>;
  10489. /**
  10490. * The mesh corresponding the the pick collision
  10491. */
  10492. pickedMesh: Nullable<AbstractMesh>;
  10493. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10494. bu: number;
  10495. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10496. bv: number;
  10497. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10498. faceId: number;
  10499. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10500. subMeshFaceId: number;
  10501. /** Id of the the submesh that was picked */
  10502. subMeshId: number;
  10503. /** If a sprite was picked, this will be the sprite the pick collided with */
  10504. pickedSprite: Nullable<Sprite>;
  10505. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10506. thinInstanceIndex: number;
  10507. /**
  10508. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10509. */
  10510. originMesh: Nullable<AbstractMesh>;
  10511. /**
  10512. * The ray that was used to perform the picking.
  10513. */
  10514. ray: Nullable<Ray>;
  10515. /**
  10516. * Gets the normal correspodning to the face the pick collided with
  10517. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10518. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10519. * @returns The normal correspodning to the face the pick collided with
  10520. */
  10521. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10522. /**
  10523. * Gets the texture coordinates of where the pick occured
  10524. * @returns the vector containing the coordnates of the texture
  10525. */
  10526. getTextureCoordinates(): Nullable<Vector2>;
  10527. }
  10528. }
  10529. declare module BABYLON {
  10530. /**
  10531. * Class representing a ray with position and direction
  10532. */
  10533. export class Ray {
  10534. /** origin point */
  10535. origin: Vector3;
  10536. /** direction */
  10537. direction: Vector3;
  10538. /** length of the ray */
  10539. length: number;
  10540. private static readonly _TmpVector3;
  10541. private _tmpRay;
  10542. /**
  10543. * Creates a new ray
  10544. * @param origin origin point
  10545. * @param direction direction
  10546. * @param length length of the ray
  10547. */
  10548. constructor(
  10549. /** origin point */
  10550. origin: Vector3,
  10551. /** direction */
  10552. direction: Vector3,
  10553. /** length of the ray */
  10554. length?: number);
  10555. /**
  10556. * Checks if the ray intersects a box
  10557. * This does not account for the ray lenght by design to improve perfs.
  10558. * @param minimum bound of the box
  10559. * @param maximum bound of the box
  10560. * @param intersectionTreshold extra extend to be added to the box in all direction
  10561. * @returns if the box was hit
  10562. */
  10563. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10564. /**
  10565. * Checks if the ray intersects a box
  10566. * This does not account for the ray lenght by design to improve perfs.
  10567. * @param box the bounding box to check
  10568. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10569. * @returns if the box was hit
  10570. */
  10571. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10572. /**
  10573. * If the ray hits a sphere
  10574. * @param sphere the bounding sphere to check
  10575. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10576. * @returns true if it hits the sphere
  10577. */
  10578. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10579. /**
  10580. * If the ray hits a triange
  10581. * @param vertex0 triangle vertex
  10582. * @param vertex1 triangle vertex
  10583. * @param vertex2 triangle vertex
  10584. * @returns intersection information if hit
  10585. */
  10586. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10587. /**
  10588. * Checks if ray intersects a plane
  10589. * @param plane the plane to check
  10590. * @returns the distance away it was hit
  10591. */
  10592. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10593. /**
  10594. * Calculate the intercept of a ray on a given axis
  10595. * @param axis to check 'x' | 'y' | 'z'
  10596. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10597. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10598. */
  10599. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10600. /**
  10601. * Checks if ray intersects a mesh
  10602. * @param mesh the mesh to check
  10603. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10604. * @returns picking info of the intersecton
  10605. */
  10606. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10607. /**
  10608. * Checks if ray intersects a mesh
  10609. * @param meshes the meshes to check
  10610. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10611. * @param results array to store result in
  10612. * @returns Array of picking infos
  10613. */
  10614. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10615. private _comparePickingInfo;
  10616. private static smallnum;
  10617. private static rayl;
  10618. /**
  10619. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10620. * @param sega the first point of the segment to test the intersection against
  10621. * @param segb the second point of the segment to test the intersection against
  10622. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10623. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10624. */
  10625. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10626. /**
  10627. * Update the ray from viewport position
  10628. * @param x position
  10629. * @param y y position
  10630. * @param viewportWidth viewport width
  10631. * @param viewportHeight viewport height
  10632. * @param world world matrix
  10633. * @param view view matrix
  10634. * @param projection projection matrix
  10635. * @returns this ray updated
  10636. */
  10637. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10638. /**
  10639. * Creates a ray with origin and direction of 0,0,0
  10640. * @returns the new ray
  10641. */
  10642. static Zero(): Ray;
  10643. /**
  10644. * Creates a new ray from screen space and viewport
  10645. * @param x position
  10646. * @param y y position
  10647. * @param viewportWidth viewport width
  10648. * @param viewportHeight viewport height
  10649. * @param world world matrix
  10650. * @param view view matrix
  10651. * @param projection projection matrix
  10652. * @returns new ray
  10653. */
  10654. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10655. /**
  10656. * 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
  10657. * transformed to the given world matrix.
  10658. * @param origin The origin point
  10659. * @param end The end point
  10660. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10661. * @returns the new ray
  10662. */
  10663. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10664. /**
  10665. * Transforms a ray by a matrix
  10666. * @param ray ray to transform
  10667. * @param matrix matrix to apply
  10668. * @returns the resulting new ray
  10669. */
  10670. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10671. /**
  10672. * Transforms a ray by a matrix
  10673. * @param ray ray to transform
  10674. * @param matrix matrix to apply
  10675. * @param result ray to store result in
  10676. */
  10677. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10678. /**
  10679. * Unproject a ray from screen space to object space
  10680. * @param sourceX defines the screen space x coordinate to use
  10681. * @param sourceY defines the screen space y coordinate to use
  10682. * @param viewportWidth defines the current width of the viewport
  10683. * @param viewportHeight defines the current height of the viewport
  10684. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10685. * @param view defines the view matrix to use
  10686. * @param projection defines the projection matrix to use
  10687. */
  10688. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10689. }
  10690. /**
  10691. * Type used to define predicate used to select faces when a mesh intersection is detected
  10692. */
  10693. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10694. interface Scene {
  10695. /** @hidden */
  10696. _tempPickingRay: Nullable<Ray>;
  10697. /** @hidden */
  10698. _cachedRayForTransform: Ray;
  10699. /** @hidden */
  10700. _pickWithRayInverseMatrix: Matrix;
  10701. /** @hidden */
  10702. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10703. /** @hidden */
  10704. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10705. /** @hidden */
  10706. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  10707. }
  10708. }
  10709. declare module BABYLON {
  10710. /**
  10711. * Groups all the scene component constants in one place to ease maintenance.
  10712. * @hidden
  10713. */
  10714. export class SceneComponentConstants {
  10715. static readonly NAME_EFFECTLAYER: string;
  10716. static readonly NAME_LAYER: string;
  10717. static readonly NAME_LENSFLARESYSTEM: string;
  10718. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10719. static readonly NAME_PARTICLESYSTEM: string;
  10720. static readonly NAME_GAMEPAD: string;
  10721. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10722. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10723. static readonly NAME_PREPASSRENDERER: string;
  10724. static readonly NAME_DEPTHRENDERER: string;
  10725. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10726. static readonly NAME_SPRITE: string;
  10727. static readonly NAME_SUBSURFACE: string;
  10728. static readonly NAME_OUTLINERENDERER: string;
  10729. static readonly NAME_PROCEDURALTEXTURE: string;
  10730. static readonly NAME_SHADOWGENERATOR: string;
  10731. static readonly NAME_OCTREE: string;
  10732. static readonly NAME_PHYSICSENGINE: string;
  10733. static readonly NAME_AUDIO: string;
  10734. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10735. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10736. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10737. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10738. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10739. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10740. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10741. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10742. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10743. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10744. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10745. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10746. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10747. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10748. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10749. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10750. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10751. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10752. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10753. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10754. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10755. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10756. static readonly STEP_AFTERRENDER_AUDIO: number;
  10757. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10758. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10759. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10760. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10761. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10762. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10763. static readonly STEP_POINTERMOVE_SPRITE: number;
  10764. static readonly STEP_POINTERDOWN_SPRITE: number;
  10765. static readonly STEP_POINTERUP_SPRITE: number;
  10766. }
  10767. /**
  10768. * This represents a scene component.
  10769. *
  10770. * This is used to decouple the dependency the scene is having on the different workloads like
  10771. * layers, post processes...
  10772. */
  10773. export interface ISceneComponent {
  10774. /**
  10775. * The name of the component. Each component must have a unique name.
  10776. */
  10777. name: string;
  10778. /**
  10779. * The scene the component belongs to.
  10780. */
  10781. scene: Scene;
  10782. /**
  10783. * Register the component to one instance of a scene.
  10784. */
  10785. register(): void;
  10786. /**
  10787. * Rebuilds the elements related to this component in case of
  10788. * context lost for instance.
  10789. */
  10790. rebuild(): void;
  10791. /**
  10792. * Disposes the component and the associated ressources.
  10793. */
  10794. dispose(): void;
  10795. }
  10796. /**
  10797. * This represents a SERIALIZABLE scene component.
  10798. *
  10799. * This extends Scene Component to add Serialization methods on top.
  10800. */
  10801. export interface ISceneSerializableComponent extends ISceneComponent {
  10802. /**
  10803. * Adds all the elements from the container to the scene
  10804. * @param container the container holding the elements
  10805. */
  10806. addFromContainer(container: AbstractScene): void;
  10807. /**
  10808. * Removes all the elements in the container from the scene
  10809. * @param container contains the elements to remove
  10810. * @param dispose if the removed element should be disposed (default: false)
  10811. */
  10812. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10813. /**
  10814. * Serializes the component data to the specified json object
  10815. * @param serializationObject The object to serialize to
  10816. */
  10817. serialize(serializationObject: any): void;
  10818. }
  10819. /**
  10820. * Strong typing of a Mesh related stage step action
  10821. */
  10822. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10823. /**
  10824. * Strong typing of a Evaluate Sub Mesh related stage step action
  10825. */
  10826. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10827. /**
  10828. * Strong typing of a pre active Mesh related stage step action
  10829. */
  10830. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  10831. /**
  10832. * Strong typing of a Camera related stage step action
  10833. */
  10834. export type CameraStageAction = (camera: Camera) => void;
  10835. /**
  10836. * Strong typing of a Camera Frame buffer related stage step action
  10837. */
  10838. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10839. /**
  10840. * Strong typing of a Render Target related stage step action
  10841. */
  10842. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10843. /**
  10844. * Strong typing of a RenderingGroup related stage step action
  10845. */
  10846. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10847. /**
  10848. * Strong typing of a Mesh Render related stage step action
  10849. */
  10850. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10851. /**
  10852. * Strong typing of a simple stage step action
  10853. */
  10854. export type SimpleStageAction = () => void;
  10855. /**
  10856. * Strong typing of a render target action.
  10857. */
  10858. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10859. /**
  10860. * Strong typing of a pointer move action.
  10861. */
  10862. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10863. /**
  10864. * Strong typing of a pointer up/down action.
  10865. */
  10866. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10867. /**
  10868. * Representation of a stage in the scene (Basically a list of ordered steps)
  10869. * @hidden
  10870. */
  10871. export class Stage<T extends Function> extends Array<{
  10872. index: number;
  10873. component: ISceneComponent;
  10874. action: T;
  10875. }> {
  10876. /**
  10877. * Hide ctor from the rest of the world.
  10878. * @param items The items to add.
  10879. */
  10880. private constructor();
  10881. /**
  10882. * Creates a new Stage.
  10883. * @returns A new instance of a Stage
  10884. */
  10885. static Create<T extends Function>(): Stage<T>;
  10886. /**
  10887. * Registers a step in an ordered way in the targeted stage.
  10888. * @param index Defines the position to register the step in
  10889. * @param component Defines the component attached to the step
  10890. * @param action Defines the action to launch during the step
  10891. */
  10892. registerStep(index: number, component: ISceneComponent, action: T): void;
  10893. /**
  10894. * Clears all the steps from the stage.
  10895. */
  10896. clear(): void;
  10897. }
  10898. }
  10899. declare module BABYLON {
  10900. interface Scene {
  10901. /** @hidden */
  10902. _pointerOverSprite: Nullable<Sprite>;
  10903. /** @hidden */
  10904. _pickedDownSprite: Nullable<Sprite>;
  10905. /** @hidden */
  10906. _tempSpritePickingRay: Nullable<Ray>;
  10907. /**
  10908. * All of the sprite managers added to this scene
  10909. * @see https://doc.babylonjs.com/babylon101/sprites
  10910. */
  10911. spriteManagers: Array<ISpriteManager>;
  10912. /**
  10913. * An event triggered when sprites rendering is about to start
  10914. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10915. */
  10916. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10917. /**
  10918. * An event triggered when sprites rendering is done
  10919. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10920. */
  10921. onAfterSpritesRenderingObservable: Observable<Scene>;
  10922. /** @hidden */
  10923. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10924. /** Launch a ray to try to pick a sprite in the scene
  10925. * @param x position on screen
  10926. * @param y position on screen
  10927. * @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
  10928. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10929. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10930. * @returns a PickingInfo
  10931. */
  10932. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10933. /** Use the given ray to pick a sprite in the scene
  10934. * @param ray The ray (in world space) to use to pick meshes
  10935. * @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
  10936. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10937. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10938. * @returns a PickingInfo
  10939. */
  10940. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10941. /** @hidden */
  10942. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10943. /** Launch a ray to try to pick sprites in the scene
  10944. * @param x position on screen
  10945. * @param y position on screen
  10946. * @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
  10947. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10948. * @returns a PickingInfo array
  10949. */
  10950. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10951. /** Use the given ray to pick sprites in the scene
  10952. * @param ray The ray (in world space) to use to pick meshes
  10953. * @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
  10954. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10955. * @returns a PickingInfo array
  10956. */
  10957. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10958. /**
  10959. * Force the sprite under the pointer
  10960. * @param sprite defines the sprite to use
  10961. */
  10962. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10963. /**
  10964. * Gets the sprite under the pointer
  10965. * @returns a Sprite or null if no sprite is under the pointer
  10966. */
  10967. getPointerOverSprite(): Nullable<Sprite>;
  10968. }
  10969. /**
  10970. * Defines the sprite scene component responsible to manage sprites
  10971. * in a given scene.
  10972. */
  10973. export class SpriteSceneComponent implements ISceneComponent {
  10974. /**
  10975. * The component name helpfull to identify the component in the list of scene components.
  10976. */
  10977. readonly name: string;
  10978. /**
  10979. * The scene the component belongs to.
  10980. */
  10981. scene: Scene;
  10982. /** @hidden */
  10983. private _spritePredicate;
  10984. /**
  10985. * Creates a new instance of the component for the given scene
  10986. * @param scene Defines the scene to register the component in
  10987. */
  10988. constructor(scene: Scene);
  10989. /**
  10990. * Registers the component in a given scene
  10991. */
  10992. register(): void;
  10993. /**
  10994. * Rebuilds the elements related to this component in case of
  10995. * context lost for instance.
  10996. */
  10997. rebuild(): void;
  10998. /**
  10999. * Disposes the component and the associated ressources.
  11000. */
  11001. dispose(): void;
  11002. private _pickSpriteButKeepRay;
  11003. private _pointerMove;
  11004. private _pointerDown;
  11005. private _pointerUp;
  11006. }
  11007. }
  11008. declare module BABYLON {
  11009. /** @hidden */
  11010. export var fogFragmentDeclaration: {
  11011. name: string;
  11012. shader: string;
  11013. };
  11014. }
  11015. declare module BABYLON {
  11016. /** @hidden */
  11017. export var fogFragment: {
  11018. name: string;
  11019. shader: string;
  11020. };
  11021. }
  11022. declare module BABYLON {
  11023. /** @hidden */
  11024. export var imageProcessingCompatibility: {
  11025. name: string;
  11026. shader: string;
  11027. };
  11028. }
  11029. declare module BABYLON {
  11030. /** @hidden */
  11031. export var spritesPixelShader: {
  11032. name: string;
  11033. shader: string;
  11034. };
  11035. }
  11036. declare module BABYLON {
  11037. /** @hidden */
  11038. export var fogVertexDeclaration: {
  11039. name: string;
  11040. shader: string;
  11041. };
  11042. }
  11043. declare module BABYLON {
  11044. /** @hidden */
  11045. export var spritesVertexShader: {
  11046. name: string;
  11047. shader: string;
  11048. };
  11049. }
  11050. declare module BABYLON {
  11051. /**
  11052. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11053. */
  11054. export interface ISpriteManager extends IDisposable {
  11055. /**
  11056. * Gets manager's name
  11057. */
  11058. name: string;
  11059. /**
  11060. * Restricts the camera to viewing objects with the same layerMask.
  11061. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11062. */
  11063. layerMask: number;
  11064. /**
  11065. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11066. */
  11067. isPickable: boolean;
  11068. /**
  11069. * Gets the hosting scene
  11070. */
  11071. scene: Scene;
  11072. /**
  11073. * Specifies the rendering group id for this mesh (0 by default)
  11074. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11075. */
  11076. renderingGroupId: number;
  11077. /**
  11078. * Defines the list of sprites managed by the manager.
  11079. */
  11080. sprites: Array<Sprite>;
  11081. /**
  11082. * Gets or sets the spritesheet texture
  11083. */
  11084. texture: Texture;
  11085. /** Defines the default width of a cell in the spritesheet */
  11086. cellWidth: number;
  11087. /** Defines the default height of a cell in the spritesheet */
  11088. cellHeight: number;
  11089. /**
  11090. * Tests the intersection of a sprite with a specific ray.
  11091. * @param ray The ray we are sending to test the collision
  11092. * @param camera The camera space we are sending rays in
  11093. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11094. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11095. * @returns picking info or null.
  11096. */
  11097. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11098. /**
  11099. * Intersects the sprites with a ray
  11100. * @param ray defines the ray to intersect with
  11101. * @param camera defines the current active camera
  11102. * @param predicate defines a predicate used to select candidate sprites
  11103. * @returns null if no hit or a PickingInfo array
  11104. */
  11105. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11106. /**
  11107. * Renders the list of sprites on screen.
  11108. */
  11109. render(): void;
  11110. }
  11111. /**
  11112. * Class used to manage multiple sprites on the same spritesheet
  11113. * @see https://doc.babylonjs.com/babylon101/sprites
  11114. */
  11115. export class SpriteManager implements ISpriteManager {
  11116. /** defines the manager's name */
  11117. name: string;
  11118. /** Define the Url to load snippets */
  11119. static SnippetUrl: string;
  11120. /** Snippet ID if the manager was created from the snippet server */
  11121. snippetId: string;
  11122. /** Gets the list of sprites */
  11123. sprites: Sprite[];
  11124. /** Gets or sets the rendering group id (0 by default) */
  11125. renderingGroupId: number;
  11126. /** Gets or sets camera layer mask */
  11127. layerMask: number;
  11128. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11129. fogEnabled: boolean;
  11130. /** Gets or sets a boolean indicating if the sprites are pickable */
  11131. isPickable: boolean;
  11132. /** Defines the default width of a cell in the spritesheet */
  11133. cellWidth: number;
  11134. /** Defines the default height of a cell in the spritesheet */
  11135. cellHeight: number;
  11136. /** Associative array from JSON sprite data file */
  11137. private _cellData;
  11138. /** Array of sprite names from JSON sprite data file */
  11139. private _spriteMap;
  11140. /** True when packed cell data from JSON file is ready*/
  11141. private _packedAndReady;
  11142. private _textureContent;
  11143. private _useInstancing;
  11144. /**
  11145. * An event triggered when the manager is disposed.
  11146. */
  11147. onDisposeObservable: Observable<SpriteManager>;
  11148. private _onDisposeObserver;
  11149. /**
  11150. * Callback called when the manager is disposed
  11151. */
  11152. set onDispose(callback: () => void);
  11153. private _capacity;
  11154. private _fromPacked;
  11155. private _spriteTexture;
  11156. private _epsilon;
  11157. private _scene;
  11158. private _vertexData;
  11159. private _buffer;
  11160. private _vertexBuffers;
  11161. private _spriteBuffer;
  11162. private _indexBuffer;
  11163. private _effectBase;
  11164. private _effectFog;
  11165. private _vertexBufferSize;
  11166. /**
  11167. * Gets or sets the unique id of the sprite
  11168. */
  11169. uniqueId: number;
  11170. /**
  11171. * Gets the array of sprites
  11172. */
  11173. get children(): Sprite[];
  11174. /**
  11175. * Gets the hosting scene
  11176. */
  11177. get scene(): Scene;
  11178. /**
  11179. * Gets the capacity of the manager
  11180. */
  11181. get capacity(): number;
  11182. /**
  11183. * Gets or sets the spritesheet texture
  11184. */
  11185. get texture(): Texture;
  11186. set texture(value: Texture);
  11187. private _blendMode;
  11188. /**
  11189. * Blend mode use to render the particle, it can be any of
  11190. * the static Constants.ALPHA_x properties provided in this class.
  11191. * Default value is Constants.ALPHA_COMBINE
  11192. */
  11193. get blendMode(): number;
  11194. set blendMode(blendMode: number);
  11195. /** Disables writing to the depth buffer when rendering the sprites.
  11196. * It can be handy to disable depth writing when using textures without alpha channel
  11197. * and setting some specific blend modes.
  11198. */
  11199. disableDepthWrite: boolean;
  11200. /**
  11201. * Creates a new sprite manager
  11202. * @param name defines the manager's name
  11203. * @param imgUrl defines the sprite sheet url
  11204. * @param capacity defines the maximum allowed number of sprites
  11205. * @param cellSize defines the size of a sprite cell
  11206. * @param scene defines the hosting scene
  11207. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11208. * @param samplingMode defines the smapling mode to use with spritesheet
  11209. * @param fromPacked set to false; do not alter
  11210. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11211. */
  11212. constructor(
  11213. /** defines the manager's name */
  11214. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11215. /**
  11216. * Returns the string "SpriteManager"
  11217. * @returns "SpriteManager"
  11218. */
  11219. getClassName(): string;
  11220. private _makePacked;
  11221. private _appendSpriteVertex;
  11222. private _checkTextureAlpha;
  11223. /**
  11224. * Intersects the sprites with a ray
  11225. * @param ray defines the ray to intersect with
  11226. * @param camera defines the current active camera
  11227. * @param predicate defines a predicate used to select candidate sprites
  11228. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11229. * @returns null if no hit or a PickingInfo
  11230. */
  11231. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11232. /**
  11233. * Intersects the sprites with a ray
  11234. * @param ray defines the ray to intersect with
  11235. * @param camera defines the current active camera
  11236. * @param predicate defines a predicate used to select candidate sprites
  11237. * @returns null if no hit or a PickingInfo array
  11238. */
  11239. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11240. /**
  11241. * Render all child sprites
  11242. */
  11243. render(): void;
  11244. /**
  11245. * Release associated resources
  11246. */
  11247. dispose(): void;
  11248. /**
  11249. * Serializes the sprite manager to a JSON object
  11250. * @param serializeTexture defines if the texture must be serialized as well
  11251. * @returns the JSON object
  11252. */
  11253. serialize(serializeTexture?: boolean): any;
  11254. /**
  11255. * Parses a JSON object to create a new sprite manager.
  11256. * @param parsedManager The JSON object to parse
  11257. * @param scene The scene to create the sprite managerin
  11258. * @param rootUrl The root url to use to load external dependencies like texture
  11259. * @returns the new sprite manager
  11260. */
  11261. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11262. /**
  11263. * Creates a sprite manager from a snippet saved in a remote file
  11264. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11265. * @param url defines the url to load from
  11266. * @param scene defines the hosting scene
  11267. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11268. * @returns a promise that will resolve to the new sprite manager
  11269. */
  11270. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11271. /**
  11272. * Creates a sprite manager from a snippet saved by the sprite editor
  11273. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11274. * @param scene defines the hosting scene
  11275. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11276. * @returns a promise that will resolve to the new sprite manager
  11277. */
  11278. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11279. }
  11280. }
  11281. declare module BABYLON {
  11282. /** Interface used by value gradients (color, factor, ...) */
  11283. export interface IValueGradient {
  11284. /**
  11285. * Gets or sets the gradient value (between 0 and 1)
  11286. */
  11287. gradient: number;
  11288. }
  11289. /** Class used to store color4 gradient */
  11290. export class ColorGradient implements IValueGradient {
  11291. /**
  11292. * Gets or sets the gradient value (between 0 and 1)
  11293. */
  11294. gradient: number;
  11295. /**
  11296. * Gets or sets first associated color
  11297. */
  11298. color1: Color4;
  11299. /**
  11300. * Gets or sets second associated color
  11301. */
  11302. color2?: Color4 | undefined;
  11303. /**
  11304. * Creates a new color4 gradient
  11305. * @param gradient gets or sets the gradient value (between 0 and 1)
  11306. * @param color1 gets or sets first associated color
  11307. * @param color2 gets or sets first second color
  11308. */
  11309. constructor(
  11310. /**
  11311. * Gets or sets the gradient value (between 0 and 1)
  11312. */
  11313. gradient: number,
  11314. /**
  11315. * Gets or sets first associated color
  11316. */
  11317. color1: Color4,
  11318. /**
  11319. * Gets or sets second associated color
  11320. */
  11321. color2?: Color4 | undefined);
  11322. /**
  11323. * Will get a color picked randomly between color1 and color2.
  11324. * If color2 is undefined then color1 will be used
  11325. * @param result defines the target Color4 to store the result in
  11326. */
  11327. getColorToRef(result: Color4): void;
  11328. }
  11329. /** Class used to store color 3 gradient */
  11330. export class Color3Gradient implements IValueGradient {
  11331. /**
  11332. * Gets or sets the gradient value (between 0 and 1)
  11333. */
  11334. gradient: number;
  11335. /**
  11336. * Gets or sets the associated color
  11337. */
  11338. color: Color3;
  11339. /**
  11340. * Creates a new color3 gradient
  11341. * @param gradient gets or sets the gradient value (between 0 and 1)
  11342. * @param color gets or sets associated color
  11343. */
  11344. constructor(
  11345. /**
  11346. * Gets or sets the gradient value (between 0 and 1)
  11347. */
  11348. gradient: number,
  11349. /**
  11350. * Gets or sets the associated color
  11351. */
  11352. color: Color3);
  11353. }
  11354. /** Class used to store factor gradient */
  11355. export class FactorGradient implements IValueGradient {
  11356. /**
  11357. * Gets or sets the gradient value (between 0 and 1)
  11358. */
  11359. gradient: number;
  11360. /**
  11361. * Gets or sets first associated factor
  11362. */
  11363. factor1: number;
  11364. /**
  11365. * Gets or sets second associated factor
  11366. */
  11367. factor2?: number | undefined;
  11368. /**
  11369. * Creates a new factor gradient
  11370. * @param gradient gets or sets the gradient value (between 0 and 1)
  11371. * @param factor1 gets or sets first associated factor
  11372. * @param factor2 gets or sets second associated factor
  11373. */
  11374. constructor(
  11375. /**
  11376. * Gets or sets the gradient value (between 0 and 1)
  11377. */
  11378. gradient: number,
  11379. /**
  11380. * Gets or sets first associated factor
  11381. */
  11382. factor1: number,
  11383. /**
  11384. * Gets or sets second associated factor
  11385. */
  11386. factor2?: number | undefined);
  11387. /**
  11388. * Will get a number picked randomly between factor1 and factor2.
  11389. * If factor2 is undefined then factor1 will be used
  11390. * @returns the picked number
  11391. */
  11392. getFactor(): number;
  11393. }
  11394. /**
  11395. * Helper used to simplify some generic gradient tasks
  11396. */
  11397. export class GradientHelper {
  11398. /**
  11399. * Gets the current gradient from an array of IValueGradient
  11400. * @param ratio defines the current ratio to get
  11401. * @param gradients defines the array of IValueGradient
  11402. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11403. */
  11404. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11405. }
  11406. }
  11407. declare module BABYLON {
  11408. interface ThinEngine {
  11409. /**
  11410. * Creates a raw texture
  11411. * @param data defines the data to store in the texture
  11412. * @param width defines the width of the texture
  11413. * @param height defines the height of the texture
  11414. * @param format defines the format of the data
  11415. * @param generateMipMaps defines if the engine should generate the mip levels
  11416. * @param invertY defines if data must be stored with Y axis inverted
  11417. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11418. * @param compression defines the compression used (null by default)
  11419. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11420. * @returns the raw texture inside an InternalTexture
  11421. */
  11422. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11423. /**
  11424. * Update a raw texture
  11425. * @param texture defines the texture to update
  11426. * @param data defines the data to store in the texture
  11427. * @param format defines the format of the data
  11428. * @param invertY defines if data must be stored with Y axis inverted
  11429. */
  11430. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11431. /**
  11432. * Update a raw texture
  11433. * @param texture defines the texture to update
  11434. * @param data defines the data to store in the texture
  11435. * @param format defines the format of the data
  11436. * @param invertY defines if data must be stored with Y axis inverted
  11437. * @param compression defines the compression used (null by default)
  11438. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11439. */
  11440. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11441. /**
  11442. * Creates a new raw cube texture
  11443. * @param data defines the array of data to use to create each face
  11444. * @param size defines the size of the textures
  11445. * @param format defines the format of the data
  11446. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11447. * @param generateMipMaps defines if the engine should generate the mip levels
  11448. * @param invertY defines if data must be stored with Y axis inverted
  11449. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11450. * @param compression defines the compression used (null by default)
  11451. * @returns the cube texture as an InternalTexture
  11452. */
  11453. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11454. /**
  11455. * Update a raw cube texture
  11456. * @param texture defines the texture to udpdate
  11457. * @param data defines the data to store
  11458. * @param format defines the data format
  11459. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11460. * @param invertY defines if data must be stored with Y axis inverted
  11461. */
  11462. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11463. /**
  11464. * Update a raw cube texture
  11465. * @param texture defines the texture to udpdate
  11466. * @param data defines the data to store
  11467. * @param format defines the data format
  11468. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11469. * @param invertY defines if data must be stored with Y axis inverted
  11470. * @param compression defines the compression used (null by default)
  11471. */
  11472. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11473. /**
  11474. * Update a raw cube texture
  11475. * @param texture defines the texture to udpdate
  11476. * @param data defines the data to store
  11477. * @param format defines the data format
  11478. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11479. * @param invertY defines if data must be stored with Y axis inverted
  11480. * @param compression defines the compression used (null by default)
  11481. * @param level defines which level of the texture to update
  11482. */
  11483. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11484. /**
  11485. * Creates a new raw cube texture from a specified url
  11486. * @param url defines the url where the data is located
  11487. * @param scene defines the current scene
  11488. * @param size defines the size of the textures
  11489. * @param format defines the format of the data
  11490. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11491. * @param noMipmap defines if the engine should avoid generating the mip levels
  11492. * @param callback defines a callback used to extract texture data from loaded data
  11493. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11494. * @param onLoad defines a callback called when texture is loaded
  11495. * @param onError defines a callback called if there is an error
  11496. * @returns the cube texture as an InternalTexture
  11497. */
  11498. 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;
  11499. /**
  11500. * Creates a new raw cube texture from a specified url
  11501. * @param url defines the url where the data is located
  11502. * @param scene defines the current scene
  11503. * @param size defines the size of the textures
  11504. * @param format defines the format of the data
  11505. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11506. * @param noMipmap defines if the engine should avoid generating the mip levels
  11507. * @param callback defines a callback used to extract texture data from loaded data
  11508. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11509. * @param onLoad defines a callback called when texture is loaded
  11510. * @param onError defines a callback called if there is an error
  11511. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11512. * @param invertY defines if data must be stored with Y axis inverted
  11513. * @returns the cube texture as an InternalTexture
  11514. */
  11515. 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;
  11516. /**
  11517. * Creates a new raw 3D texture
  11518. * @param data defines the data used to create the texture
  11519. * @param width defines the width of the texture
  11520. * @param height defines the height of the texture
  11521. * @param depth defines the depth of the texture
  11522. * @param format defines the format of the texture
  11523. * @param generateMipMaps defines if the engine must generate mip levels
  11524. * @param invertY defines if data must be stored with Y axis inverted
  11525. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11526. * @param compression defines the compressed used (can be null)
  11527. * @param textureType defines the compressed used (can be null)
  11528. * @returns a new raw 3D texture (stored in an InternalTexture)
  11529. */
  11530. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11531. /**
  11532. * Update a raw 3D texture
  11533. * @param texture defines the texture to update
  11534. * @param data defines the data to store
  11535. * @param format defines the data format
  11536. * @param invertY defines if data must be stored with Y axis inverted
  11537. */
  11538. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11539. /**
  11540. * Update a raw 3D texture
  11541. * @param texture defines the texture to update
  11542. * @param data defines the data to store
  11543. * @param format defines the data format
  11544. * @param invertY defines if data must be stored with Y axis inverted
  11545. * @param compression defines the used compression (can be null)
  11546. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11547. */
  11548. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11549. /**
  11550. * Creates a new raw 2D array texture
  11551. * @param data defines the data used to create the texture
  11552. * @param width defines the width of the texture
  11553. * @param height defines the height of the texture
  11554. * @param depth defines the number of layers of the texture
  11555. * @param format defines the format of the texture
  11556. * @param generateMipMaps defines if the engine must generate mip levels
  11557. * @param invertY defines if data must be stored with Y axis inverted
  11558. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11559. * @param compression defines the compressed used (can be null)
  11560. * @param textureType defines the compressed used (can be null)
  11561. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11562. */
  11563. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11564. /**
  11565. * Update a raw 2D array texture
  11566. * @param texture defines the texture to update
  11567. * @param data defines the data to store
  11568. * @param format defines the data format
  11569. * @param invertY defines if data must be stored with Y axis inverted
  11570. */
  11571. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11572. /**
  11573. * Update a raw 2D array texture
  11574. * @param texture defines the texture to update
  11575. * @param data defines the data to store
  11576. * @param format defines the data format
  11577. * @param invertY defines if data must be stored with Y axis inverted
  11578. * @param compression defines the used compression (can be null)
  11579. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11580. */
  11581. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11582. }
  11583. }
  11584. declare module BABYLON {
  11585. /**
  11586. * Raw texture can help creating a texture directly from an array of data.
  11587. * This can be super useful if you either get the data from an uncompressed source or
  11588. * if you wish to create your texture pixel by pixel.
  11589. */
  11590. export class RawTexture extends Texture {
  11591. /**
  11592. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11593. */
  11594. format: number;
  11595. /**
  11596. * Instantiates a new RawTexture.
  11597. * Raw texture can help creating a texture directly from an array of data.
  11598. * This can be super useful if you either get the data from an uncompressed source or
  11599. * if you wish to create your texture pixel by pixel.
  11600. * @param data define the array of data to use to create the texture
  11601. * @param width define the width of the texture
  11602. * @param height define the height of the texture
  11603. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11604. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11605. * @param generateMipMaps define whether mip maps should be generated or not
  11606. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11607. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11608. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11609. */
  11610. constructor(data: ArrayBufferView, width: number, height: number,
  11611. /**
  11612. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11613. */
  11614. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11615. /**
  11616. * Updates the texture underlying data.
  11617. * @param data Define the new data of the texture
  11618. */
  11619. update(data: ArrayBufferView): void;
  11620. /**
  11621. * Creates a luminance texture from some data.
  11622. * @param data Define the texture data
  11623. * @param width Define the width of the texture
  11624. * @param height Define the height of the texture
  11625. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11626. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11627. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11628. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11629. * @returns the luminance texture
  11630. */
  11631. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11632. /**
  11633. * Creates a luminance alpha texture from some data.
  11634. * @param data Define the texture data
  11635. * @param width Define the width of the texture
  11636. * @param height Define the height of the texture
  11637. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11638. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11639. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11640. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11641. * @returns the luminance alpha texture
  11642. */
  11643. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11644. /**
  11645. * Creates an alpha texture from some data.
  11646. * @param data Define the texture data
  11647. * @param width Define the width of the texture
  11648. * @param height Define the height of the texture
  11649. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11650. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11651. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11652. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11653. * @returns the alpha texture
  11654. */
  11655. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11656. /**
  11657. * Creates a RGB texture from some data.
  11658. * @param data Define the texture data
  11659. * @param width Define the width of the texture
  11660. * @param height Define the height of the texture
  11661. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11662. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11663. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11664. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11665. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11666. * @returns the RGB alpha texture
  11667. */
  11668. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11669. /**
  11670. * Creates a RGBA texture from some data.
  11671. * @param data Define the texture data
  11672. * @param width Define the width of the texture
  11673. * @param height Define the height of the texture
  11674. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11675. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11676. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11677. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11678. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11679. * @returns the RGBA texture
  11680. */
  11681. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11682. /**
  11683. * Creates a R texture from some data.
  11684. * @param data Define the texture data
  11685. * @param width Define the width of the texture
  11686. * @param height Define the height of the texture
  11687. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11688. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11689. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11690. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11691. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11692. * @returns the R texture
  11693. */
  11694. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11695. }
  11696. }
  11697. declare module BABYLON {
  11698. interface ThinEngine {
  11699. /**
  11700. * Update a dynamic index buffer
  11701. * @param indexBuffer defines the target index buffer
  11702. * @param indices defines the data to update
  11703. * @param offset defines the offset in the target index buffer where update should start
  11704. */
  11705. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11706. /**
  11707. * Updates a dynamic vertex buffer.
  11708. * @param vertexBuffer the vertex buffer to update
  11709. * @param data the data used to update the vertex buffer
  11710. * @param byteOffset the byte offset of the data
  11711. * @param byteLength the byte length of the data
  11712. */
  11713. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11714. }
  11715. }
  11716. declare module BABYLON {
  11717. interface AbstractScene {
  11718. /**
  11719. * The list of procedural textures added to the scene
  11720. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11721. */
  11722. proceduralTextures: Array<ProceduralTexture>;
  11723. }
  11724. /**
  11725. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11726. * in a given scene.
  11727. */
  11728. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11729. /**
  11730. * The component name helpfull to identify the component in the list of scene components.
  11731. */
  11732. readonly name: string;
  11733. /**
  11734. * The scene the component belongs to.
  11735. */
  11736. scene: Scene;
  11737. /**
  11738. * Creates a new instance of the component for the given scene
  11739. * @param scene Defines the scene to register the component in
  11740. */
  11741. constructor(scene: Scene);
  11742. /**
  11743. * Registers the component in a given scene
  11744. */
  11745. register(): void;
  11746. /**
  11747. * Rebuilds the elements related to this component in case of
  11748. * context lost for instance.
  11749. */
  11750. rebuild(): void;
  11751. /**
  11752. * Disposes the component and the associated ressources.
  11753. */
  11754. dispose(): void;
  11755. private _beforeClear;
  11756. }
  11757. }
  11758. declare module BABYLON {
  11759. interface ThinEngine {
  11760. /**
  11761. * Creates a new render target cube texture
  11762. * @param size defines the size of the texture
  11763. * @param options defines the options used to create the texture
  11764. * @returns a new render target cube texture stored in an InternalTexture
  11765. */
  11766. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11767. }
  11768. }
  11769. declare module BABYLON {
  11770. /** @hidden */
  11771. export var proceduralVertexShader: {
  11772. name: string;
  11773. shader: string;
  11774. };
  11775. }
  11776. declare module BABYLON {
  11777. /**
  11778. * 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.
  11779. * This is the base class of any Procedural texture and contains most of the shareable code.
  11780. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11781. */
  11782. export class ProceduralTexture extends Texture {
  11783. /**
  11784. * Define if the texture is enabled or not (disabled texture will not render)
  11785. */
  11786. isEnabled: boolean;
  11787. /**
  11788. * Define if the texture must be cleared before rendering (default is true)
  11789. */
  11790. autoClear: boolean;
  11791. /**
  11792. * Callback called when the texture is generated
  11793. */
  11794. onGenerated: () => void;
  11795. /**
  11796. * Event raised when the texture is generated
  11797. */
  11798. onGeneratedObservable: Observable<ProceduralTexture>;
  11799. /**
  11800. * Event raised before the texture is generated
  11801. */
  11802. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  11803. /**
  11804. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  11805. */
  11806. nodeMaterialSource: Nullable<NodeMaterial>;
  11807. /** @hidden */
  11808. _generateMipMaps: boolean;
  11809. /** @hidden **/
  11810. _effect: Effect;
  11811. /** @hidden */
  11812. _textures: {
  11813. [key: string]: Texture;
  11814. };
  11815. /** @hidden */
  11816. protected _fallbackTexture: Nullable<Texture>;
  11817. private _size;
  11818. private _currentRefreshId;
  11819. private _frameId;
  11820. private _refreshRate;
  11821. private _vertexBuffers;
  11822. private _indexBuffer;
  11823. private _uniforms;
  11824. private _samplers;
  11825. private _fragment;
  11826. private _floats;
  11827. private _ints;
  11828. private _floatsArrays;
  11829. private _colors3;
  11830. private _colors4;
  11831. private _vectors2;
  11832. private _vectors3;
  11833. private _matrices;
  11834. private _fallbackTextureUsed;
  11835. private _fullEngine;
  11836. private _cachedDefines;
  11837. private _contentUpdateId;
  11838. private _contentData;
  11839. /**
  11840. * Instantiates a new procedural texture.
  11841. * 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.
  11842. * This is the base class of any Procedural texture and contains most of the shareable code.
  11843. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11844. * @param name Define the name of the texture
  11845. * @param size Define the size of the texture to create
  11846. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11847. * @param scene Define the scene the texture belongs to
  11848. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11849. * @param generateMipMaps Define if the texture should creates mip maps or not
  11850. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11851. * @param textureType The FBO internal texture type
  11852. */
  11853. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  11854. /**
  11855. * The effect that is created when initializing the post process.
  11856. * @returns The created effect corresponding the the postprocess.
  11857. */
  11858. getEffect(): Effect;
  11859. /**
  11860. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11861. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11862. */
  11863. getContent(): Nullable<ArrayBufferView>;
  11864. private _createIndexBuffer;
  11865. /** @hidden */
  11866. _rebuild(): void;
  11867. /**
  11868. * Resets the texture in order to recreate its associated resources.
  11869. * This can be called in case of context loss
  11870. */
  11871. reset(): void;
  11872. protected _getDefines(): string;
  11873. /**
  11874. * Is the texture ready to be used ? (rendered at least once)
  11875. * @returns true if ready, otherwise, false.
  11876. */
  11877. isReady(): boolean;
  11878. /**
  11879. * Resets the refresh counter of the texture and start bak from scratch.
  11880. * Could be useful to regenerate the texture if it is setup to render only once.
  11881. */
  11882. resetRefreshCounter(): void;
  11883. /**
  11884. * Set the fragment shader to use in order to render the texture.
  11885. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11886. */
  11887. setFragment(fragment: any): void;
  11888. /**
  11889. * Define the refresh rate of the texture or the rendering frequency.
  11890. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11891. */
  11892. get refreshRate(): number;
  11893. set refreshRate(value: number);
  11894. /** @hidden */
  11895. _shouldRender(): boolean;
  11896. /**
  11897. * Get the size the texture is rendering at.
  11898. * @returns the size (on cube texture it is always squared)
  11899. */
  11900. getRenderSize(): RenderTargetTextureSize;
  11901. /**
  11902. * Resize the texture to new value.
  11903. * @param size Define the new size the texture should have
  11904. * @param generateMipMaps Define whether the new texture should create mip maps
  11905. */
  11906. resize(size: number, generateMipMaps: boolean): void;
  11907. private _checkUniform;
  11908. /**
  11909. * Set a texture in the shader program used to render.
  11910. * @param name Define the name of the uniform samplers as defined in the shader
  11911. * @param texture Define the texture to bind to this sampler
  11912. * @return the texture itself allowing "fluent" like uniform updates
  11913. */
  11914. setTexture(name: string, texture: Texture): ProceduralTexture;
  11915. /**
  11916. * Set a float in the shader.
  11917. * @param name Define the name of the uniform as defined in the shader
  11918. * @param value Define the value to give to the uniform
  11919. * @return the texture itself allowing "fluent" like uniform updates
  11920. */
  11921. setFloat(name: string, value: number): ProceduralTexture;
  11922. /**
  11923. * Set a int in the shader.
  11924. * @param name Define the name of the uniform as defined in the shader
  11925. * @param value Define the value to give to the uniform
  11926. * @return the texture itself allowing "fluent" like uniform updates
  11927. */
  11928. setInt(name: string, value: number): ProceduralTexture;
  11929. /**
  11930. * Set an array of floats in the shader.
  11931. * @param name Define the name of the uniform as defined in the shader
  11932. * @param value Define the value to give to the uniform
  11933. * @return the texture itself allowing "fluent" like uniform updates
  11934. */
  11935. setFloats(name: string, value: number[]): ProceduralTexture;
  11936. /**
  11937. * Set a vec3 in the shader from a Color3.
  11938. * @param name Define the name of the uniform as defined in the shader
  11939. * @param value Define the value to give to the uniform
  11940. * @return the texture itself allowing "fluent" like uniform updates
  11941. */
  11942. setColor3(name: string, value: Color3): ProceduralTexture;
  11943. /**
  11944. * Set a vec4 in the shader from a Color4.
  11945. * @param name Define the name of the uniform as defined in the shader
  11946. * @param value Define the value to give to the uniform
  11947. * @return the texture itself allowing "fluent" like uniform updates
  11948. */
  11949. setColor4(name: string, value: Color4): ProceduralTexture;
  11950. /**
  11951. * Set a vec2 in the shader from a Vector2.
  11952. * @param name Define the name of the uniform as defined in the shader
  11953. * @param value Define the value to give to the uniform
  11954. * @return the texture itself allowing "fluent" like uniform updates
  11955. */
  11956. setVector2(name: string, value: Vector2): ProceduralTexture;
  11957. /**
  11958. * Set a vec3 in the shader from a Vector3.
  11959. * @param name Define the name of the uniform as defined in the shader
  11960. * @param value Define the value to give to the uniform
  11961. * @return the texture itself allowing "fluent" like uniform updates
  11962. */
  11963. setVector3(name: string, value: Vector3): ProceduralTexture;
  11964. /**
  11965. * Set a mat4 in the shader from a MAtrix.
  11966. * @param name Define the name of the uniform as defined in the shader
  11967. * @param value Define the value to give to the uniform
  11968. * @return the texture itself allowing "fluent" like uniform updates
  11969. */
  11970. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11971. /**
  11972. * Render the texture to its associated render target.
  11973. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11974. */
  11975. render(useCameraPostProcess?: boolean): void;
  11976. /**
  11977. * Clone the texture.
  11978. * @returns the cloned texture
  11979. */
  11980. clone(): ProceduralTexture;
  11981. /**
  11982. * Dispose the texture and release its asoociated resources.
  11983. */
  11984. dispose(): void;
  11985. }
  11986. }
  11987. declare module BABYLON {
  11988. /**
  11989. * This represents the base class for particle system in Babylon.
  11990. * 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.
  11991. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11992. * @example https://doc.babylonjs.com/babylon101/particles
  11993. */
  11994. export class BaseParticleSystem {
  11995. /**
  11996. * Source color is added to the destination color without alpha affecting the result
  11997. */
  11998. static BLENDMODE_ONEONE: number;
  11999. /**
  12000. * Blend current color and particle color using particle’s alpha
  12001. */
  12002. static BLENDMODE_STANDARD: number;
  12003. /**
  12004. * Add current color and particle color multiplied by particle’s alpha
  12005. */
  12006. static BLENDMODE_ADD: number;
  12007. /**
  12008. * Multiply current color with particle color
  12009. */
  12010. static BLENDMODE_MULTIPLY: number;
  12011. /**
  12012. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12013. */
  12014. static BLENDMODE_MULTIPLYADD: number;
  12015. /**
  12016. * List of animations used by the particle system.
  12017. */
  12018. animations: Animation[];
  12019. /**
  12020. * Gets or sets the unique id of the particle system
  12021. */
  12022. uniqueId: number;
  12023. /**
  12024. * The id of the Particle system.
  12025. */
  12026. id: string;
  12027. /**
  12028. * The friendly name of the Particle system.
  12029. */
  12030. name: string;
  12031. /**
  12032. * Snippet ID if the particle system was created from the snippet server
  12033. */
  12034. snippetId: string;
  12035. /**
  12036. * The rendering group used by the Particle system to chose when to render.
  12037. */
  12038. renderingGroupId: number;
  12039. /**
  12040. * The emitter represents the Mesh or position we are attaching the particle system to.
  12041. */
  12042. emitter: Nullable<AbstractMesh | Vector3>;
  12043. /**
  12044. * The maximum number of particles to emit per frame
  12045. */
  12046. emitRate: number;
  12047. /**
  12048. * If you want to launch only a few particles at once, that can be done, as well.
  12049. */
  12050. manualEmitCount: number;
  12051. /**
  12052. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12053. */
  12054. updateSpeed: number;
  12055. /**
  12056. * The amount of time the particle system is running (depends of the overall update speed).
  12057. */
  12058. targetStopDuration: number;
  12059. /**
  12060. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12061. */
  12062. disposeOnStop: boolean;
  12063. /**
  12064. * Minimum power of emitting particles.
  12065. */
  12066. minEmitPower: number;
  12067. /**
  12068. * Maximum power of emitting particles.
  12069. */
  12070. maxEmitPower: number;
  12071. /**
  12072. * Minimum life time of emitting particles.
  12073. */
  12074. minLifeTime: number;
  12075. /**
  12076. * Maximum life time of emitting particles.
  12077. */
  12078. maxLifeTime: number;
  12079. /**
  12080. * Minimum Size of emitting particles.
  12081. */
  12082. minSize: number;
  12083. /**
  12084. * Maximum Size of emitting particles.
  12085. */
  12086. maxSize: number;
  12087. /**
  12088. * Minimum scale of emitting particles on X axis.
  12089. */
  12090. minScaleX: number;
  12091. /**
  12092. * Maximum scale of emitting particles on X axis.
  12093. */
  12094. maxScaleX: number;
  12095. /**
  12096. * Minimum scale of emitting particles on Y axis.
  12097. */
  12098. minScaleY: number;
  12099. /**
  12100. * Maximum scale of emitting particles on Y axis.
  12101. */
  12102. maxScaleY: number;
  12103. /**
  12104. * Gets or sets the minimal initial rotation in radians.
  12105. */
  12106. minInitialRotation: number;
  12107. /**
  12108. * Gets or sets the maximal initial rotation in radians.
  12109. */
  12110. maxInitialRotation: number;
  12111. /**
  12112. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12113. */
  12114. minAngularSpeed: number;
  12115. /**
  12116. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12117. */
  12118. maxAngularSpeed: number;
  12119. /**
  12120. * The texture used to render each particle. (this can be a spritesheet)
  12121. */
  12122. particleTexture: Nullable<BaseTexture>;
  12123. /**
  12124. * The layer mask we are rendering the particles through.
  12125. */
  12126. layerMask: number;
  12127. /**
  12128. * This can help using your own shader to render the particle system.
  12129. * The according effect will be created
  12130. */
  12131. customShader: any;
  12132. /**
  12133. * By default particle system starts as soon as they are created. This prevents the
  12134. * automatic start to happen and let you decide when to start emitting particles.
  12135. */
  12136. preventAutoStart: boolean;
  12137. private _noiseTexture;
  12138. /**
  12139. * Gets or sets a texture used to add random noise to particle positions
  12140. */
  12141. get noiseTexture(): Nullable<ProceduralTexture>;
  12142. set noiseTexture(value: Nullable<ProceduralTexture>);
  12143. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12144. noiseStrength: Vector3;
  12145. /**
  12146. * Callback triggered when the particle animation is ending.
  12147. */
  12148. onAnimationEnd: Nullable<() => void>;
  12149. /**
  12150. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12151. */
  12152. blendMode: number;
  12153. /**
  12154. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12155. * to override the particles.
  12156. */
  12157. forceDepthWrite: boolean;
  12158. /** 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 */
  12159. preWarmCycles: number;
  12160. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12161. preWarmStepOffset: number;
  12162. /**
  12163. * 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)
  12164. */
  12165. spriteCellChangeSpeed: number;
  12166. /**
  12167. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12168. */
  12169. startSpriteCellID: number;
  12170. /**
  12171. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12172. */
  12173. endSpriteCellID: number;
  12174. /**
  12175. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12176. */
  12177. spriteCellWidth: number;
  12178. /**
  12179. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12180. */
  12181. spriteCellHeight: number;
  12182. /**
  12183. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12184. */
  12185. spriteRandomStartCell: boolean;
  12186. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12187. translationPivot: Vector2;
  12188. /** @hidden */
  12189. protected _isAnimationSheetEnabled: boolean;
  12190. /**
  12191. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12192. */
  12193. beginAnimationOnStart: boolean;
  12194. /**
  12195. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12196. */
  12197. beginAnimationFrom: number;
  12198. /**
  12199. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12200. */
  12201. beginAnimationTo: number;
  12202. /**
  12203. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12204. */
  12205. beginAnimationLoop: boolean;
  12206. /**
  12207. * Gets or sets a world offset applied to all particles
  12208. */
  12209. worldOffset: Vector3;
  12210. /**
  12211. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12212. */
  12213. get isAnimationSheetEnabled(): boolean;
  12214. set isAnimationSheetEnabled(value: boolean);
  12215. /**
  12216. * Get hosting scene
  12217. * @returns the scene
  12218. */
  12219. getScene(): Nullable<Scene>;
  12220. /**
  12221. * You can use gravity if you want to give an orientation to your particles.
  12222. */
  12223. gravity: Vector3;
  12224. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12225. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12226. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12227. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12228. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12229. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12230. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12231. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12232. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12233. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12234. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12235. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12236. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12237. /**
  12238. * Defines the delay in milliseconds before starting the system (0 by default)
  12239. */
  12240. startDelay: number;
  12241. /**
  12242. * Gets the current list of drag gradients.
  12243. * You must use addDragGradient and removeDragGradient to udpate this list
  12244. * @returns the list of drag gradients
  12245. */
  12246. getDragGradients(): Nullable<Array<FactorGradient>>;
  12247. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12248. limitVelocityDamping: number;
  12249. /**
  12250. * Gets the current list of limit velocity gradients.
  12251. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12252. * @returns the list of limit velocity gradients
  12253. */
  12254. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12255. /**
  12256. * Gets the current list of color gradients.
  12257. * You must use addColorGradient and removeColorGradient to udpate this list
  12258. * @returns the list of color gradients
  12259. */
  12260. getColorGradients(): Nullable<Array<ColorGradient>>;
  12261. /**
  12262. * Gets the current list of size gradients.
  12263. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12264. * @returns the list of size gradients
  12265. */
  12266. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12267. /**
  12268. * Gets the current list of color remap gradients.
  12269. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12270. * @returns the list of color remap gradients
  12271. */
  12272. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12273. /**
  12274. * Gets the current list of alpha remap gradients.
  12275. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12276. * @returns the list of alpha remap gradients
  12277. */
  12278. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12279. /**
  12280. * Gets the current list of life time gradients.
  12281. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12282. * @returns the list of life time gradients
  12283. */
  12284. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12285. /**
  12286. * Gets the current list of angular speed gradients.
  12287. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12288. * @returns the list of angular speed gradients
  12289. */
  12290. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12291. /**
  12292. * Gets the current list of velocity gradients.
  12293. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12294. * @returns the list of velocity gradients
  12295. */
  12296. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12297. /**
  12298. * Gets the current list of start size gradients.
  12299. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12300. * @returns the list of start size gradients
  12301. */
  12302. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12303. /**
  12304. * Gets the current list of emit rate gradients.
  12305. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12306. * @returns the list of emit rate gradients
  12307. */
  12308. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12309. /**
  12310. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12311. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12312. */
  12313. get direction1(): Vector3;
  12314. set direction1(value: Vector3);
  12315. /**
  12316. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12317. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12318. */
  12319. get direction2(): Vector3;
  12320. set direction2(value: Vector3);
  12321. /**
  12322. * 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.
  12323. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12324. */
  12325. get minEmitBox(): Vector3;
  12326. set minEmitBox(value: Vector3);
  12327. /**
  12328. * 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.
  12329. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12330. */
  12331. get maxEmitBox(): Vector3;
  12332. set maxEmitBox(value: Vector3);
  12333. /**
  12334. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12335. */
  12336. color1: Color4;
  12337. /**
  12338. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12339. */
  12340. color2: Color4;
  12341. /**
  12342. * Color the particle will have at the end of its lifetime
  12343. */
  12344. colorDead: Color4;
  12345. /**
  12346. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12347. */
  12348. textureMask: Color4;
  12349. /**
  12350. * The particle emitter type defines the emitter used by the particle system.
  12351. * It can be for example box, sphere, or cone...
  12352. */
  12353. particleEmitterType: IParticleEmitterType;
  12354. /** @hidden */
  12355. _isSubEmitter: boolean;
  12356. /**
  12357. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12358. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12359. */
  12360. billboardMode: number;
  12361. protected _isBillboardBased: boolean;
  12362. /**
  12363. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12364. */
  12365. get isBillboardBased(): boolean;
  12366. set isBillboardBased(value: boolean);
  12367. /**
  12368. * The scene the particle system belongs to.
  12369. */
  12370. protected _scene: Nullable<Scene>;
  12371. /**
  12372. * The engine the particle system belongs to.
  12373. */
  12374. protected _engine: ThinEngine;
  12375. /**
  12376. * Local cache of defines for image processing.
  12377. */
  12378. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12379. /**
  12380. * Default configuration related to image processing available in the standard Material.
  12381. */
  12382. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12383. /**
  12384. * Gets the image processing configuration used either in this material.
  12385. */
  12386. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12387. /**
  12388. * Sets the Default image processing configuration used either in the this material.
  12389. *
  12390. * If sets to null, the scene one is in use.
  12391. */
  12392. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12393. /**
  12394. * Attaches a new image processing configuration to the Standard Material.
  12395. * @param configuration
  12396. */
  12397. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12398. /** @hidden */
  12399. protected _reset(): void;
  12400. /** @hidden */
  12401. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12402. /**
  12403. * Instantiates a particle system.
  12404. * 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.
  12405. * @param name The name of the particle system
  12406. */
  12407. constructor(name: string);
  12408. /**
  12409. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12410. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12411. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12412. * @returns the emitter
  12413. */
  12414. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12415. /**
  12416. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12417. * @param radius The radius of the hemisphere to emit from
  12418. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12419. * @returns the emitter
  12420. */
  12421. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12422. /**
  12423. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12424. * @param radius The radius of the sphere to emit from
  12425. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12426. * @returns the emitter
  12427. */
  12428. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12429. /**
  12430. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12431. * @param radius The radius of the sphere to emit from
  12432. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12433. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12434. * @returns the emitter
  12435. */
  12436. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12437. /**
  12438. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12439. * @param radius The radius of the emission cylinder
  12440. * @param height The height of the emission cylinder
  12441. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12442. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12443. * @returns the emitter
  12444. */
  12445. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12446. /**
  12447. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12448. * @param radius The radius of the cylinder to emit from
  12449. * @param height The height of the emission cylinder
  12450. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12451. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12452. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12453. * @returns the emitter
  12454. */
  12455. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12456. /**
  12457. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12458. * @param radius The radius of the cone to emit from
  12459. * @param angle The base angle of the cone
  12460. * @returns the emitter
  12461. */
  12462. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12463. /**
  12464. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12465. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12466. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12467. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12468. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12469. * @returns the emitter
  12470. */
  12471. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12472. }
  12473. }
  12474. declare module BABYLON {
  12475. /**
  12476. * Type of sub emitter
  12477. */
  12478. export enum SubEmitterType {
  12479. /**
  12480. * Attached to the particle over it's lifetime
  12481. */
  12482. ATTACHED = 0,
  12483. /**
  12484. * Created when the particle dies
  12485. */
  12486. END = 1
  12487. }
  12488. /**
  12489. * Sub emitter class used to emit particles from an existing particle
  12490. */
  12491. export class SubEmitter {
  12492. /**
  12493. * the particle system to be used by the sub emitter
  12494. */
  12495. particleSystem: ParticleSystem;
  12496. /**
  12497. * Type of the submitter (Default: END)
  12498. */
  12499. type: SubEmitterType;
  12500. /**
  12501. * 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)
  12502. * Note: This only is supported when using an emitter of type Mesh
  12503. */
  12504. inheritDirection: boolean;
  12505. /**
  12506. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12507. */
  12508. inheritedVelocityAmount: number;
  12509. /**
  12510. * Creates a sub emitter
  12511. * @param particleSystem the particle system to be used by the sub emitter
  12512. */
  12513. constructor(
  12514. /**
  12515. * the particle system to be used by the sub emitter
  12516. */
  12517. particleSystem: ParticleSystem);
  12518. /**
  12519. * Clones the sub emitter
  12520. * @returns the cloned sub emitter
  12521. */
  12522. clone(): SubEmitter;
  12523. /**
  12524. * Serialize current object to a JSON object
  12525. * @returns the serialized object
  12526. */
  12527. serialize(): any;
  12528. /** @hidden */
  12529. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12530. /**
  12531. * Creates a new SubEmitter from a serialized JSON version
  12532. * @param serializationObject defines the JSON object to read from
  12533. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12534. * @param rootUrl defines the rootUrl for data loading
  12535. * @returns a new SubEmitter
  12536. */
  12537. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12538. /** Release associated resources */
  12539. dispose(): void;
  12540. }
  12541. }
  12542. declare module BABYLON {
  12543. /** @hidden */
  12544. export var imageProcessingDeclaration: {
  12545. name: string;
  12546. shader: string;
  12547. };
  12548. }
  12549. declare module BABYLON {
  12550. /** @hidden */
  12551. export var imageProcessingFunctions: {
  12552. name: string;
  12553. shader: string;
  12554. };
  12555. }
  12556. declare module BABYLON {
  12557. /** @hidden */
  12558. export var particlesPixelShader: {
  12559. name: string;
  12560. shader: string;
  12561. };
  12562. }
  12563. declare module BABYLON {
  12564. /** @hidden */
  12565. export var particlesVertexShader: {
  12566. name: string;
  12567. shader: string;
  12568. };
  12569. }
  12570. declare module BABYLON {
  12571. /**
  12572. * Interface used to define entities containing multiple clip planes
  12573. */
  12574. export interface IClipPlanesHolder {
  12575. /**
  12576. * Gets or sets the active clipplane 1
  12577. */
  12578. clipPlane: Nullable<Plane>;
  12579. /**
  12580. * Gets or sets the active clipplane 2
  12581. */
  12582. clipPlane2: Nullable<Plane>;
  12583. /**
  12584. * Gets or sets the active clipplane 3
  12585. */
  12586. clipPlane3: Nullable<Plane>;
  12587. /**
  12588. * Gets or sets the active clipplane 4
  12589. */
  12590. clipPlane4: Nullable<Plane>;
  12591. /**
  12592. * Gets or sets the active clipplane 5
  12593. */
  12594. clipPlane5: Nullable<Plane>;
  12595. /**
  12596. * Gets or sets the active clipplane 6
  12597. */
  12598. clipPlane6: Nullable<Plane>;
  12599. }
  12600. }
  12601. declare module BABYLON {
  12602. /**
  12603. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12604. *
  12605. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12606. *
  12607. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12608. */
  12609. export class ThinMaterialHelper {
  12610. /**
  12611. * Binds the clip plane information from the holder to the effect.
  12612. * @param effect The effect we are binding the data to
  12613. * @param holder The entity containing the clip plane information
  12614. */
  12615. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12616. }
  12617. }
  12618. declare module BABYLON {
  12619. interface ThinEngine {
  12620. /**
  12621. * Sets alpha constants used by some alpha blending modes
  12622. * @param r defines the red component
  12623. * @param g defines the green component
  12624. * @param b defines the blue component
  12625. * @param a defines the alpha component
  12626. */
  12627. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12628. /**
  12629. * Sets the current alpha mode
  12630. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12631. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12632. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12633. */
  12634. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12635. /**
  12636. * Gets the current alpha mode
  12637. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12638. * @returns the current alpha mode
  12639. */
  12640. getAlphaMode(): number;
  12641. /**
  12642. * Sets the current alpha equation
  12643. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12644. */
  12645. setAlphaEquation(equation: number): void;
  12646. /**
  12647. * Gets the current alpha equation.
  12648. * @returns the current alpha equation
  12649. */
  12650. getAlphaEquation(): number;
  12651. }
  12652. }
  12653. declare module BABYLON {
  12654. /**
  12655. * This represents a particle system in Babylon.
  12656. * 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.
  12657. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12658. * @example https://doc.babylonjs.com/babylon101/particles
  12659. */
  12660. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12661. /**
  12662. * Billboard mode will only apply to Y axis
  12663. */
  12664. static readonly BILLBOARDMODE_Y: number;
  12665. /**
  12666. * Billboard mode will apply to all axes
  12667. */
  12668. static readonly BILLBOARDMODE_ALL: number;
  12669. /**
  12670. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12671. */
  12672. static readonly BILLBOARDMODE_STRETCHED: number;
  12673. /**
  12674. * This function can be defined to provide custom update for active particles.
  12675. * This function will be called instead of regular update (age, position, color, etc.).
  12676. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12677. */
  12678. updateFunction: (particles: Particle[]) => void;
  12679. private _emitterWorldMatrix;
  12680. /**
  12681. * This function can be defined to specify initial direction for every new particle.
  12682. * It by default use the emitterType defined function
  12683. */
  12684. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12685. /**
  12686. * This function can be defined to specify initial position for every new particle.
  12687. * It by default use the emitterType defined function
  12688. */
  12689. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12690. /**
  12691. * @hidden
  12692. */
  12693. _inheritedVelocityOffset: Vector3;
  12694. /**
  12695. * An event triggered when the system is disposed
  12696. */
  12697. onDisposeObservable: Observable<IParticleSystem>;
  12698. /**
  12699. * An event triggered when the system is stopped
  12700. */
  12701. onStoppedObservable: Observable<IParticleSystem>;
  12702. private _onDisposeObserver;
  12703. /**
  12704. * Sets a callback that will be triggered when the system is disposed
  12705. */
  12706. set onDispose(callback: () => void);
  12707. private _particles;
  12708. private _epsilon;
  12709. private _capacity;
  12710. private _stockParticles;
  12711. private _newPartsExcess;
  12712. private _vertexData;
  12713. private _vertexBuffer;
  12714. private _vertexBuffers;
  12715. private _spriteBuffer;
  12716. private _indexBuffer;
  12717. private _effect;
  12718. private _customEffect;
  12719. private _cachedDefines;
  12720. private _scaledColorStep;
  12721. private _colorDiff;
  12722. private _scaledDirection;
  12723. private _scaledGravity;
  12724. private _currentRenderId;
  12725. private _alive;
  12726. private _useInstancing;
  12727. private _vertexArrayObject;
  12728. private _started;
  12729. private _stopped;
  12730. private _actualFrame;
  12731. private _scaledUpdateSpeed;
  12732. private _vertexBufferSize;
  12733. /** @hidden */
  12734. _currentEmitRateGradient: Nullable<FactorGradient>;
  12735. /** @hidden */
  12736. _currentEmitRate1: number;
  12737. /** @hidden */
  12738. _currentEmitRate2: number;
  12739. /** @hidden */
  12740. _currentStartSizeGradient: Nullable<FactorGradient>;
  12741. /** @hidden */
  12742. _currentStartSize1: number;
  12743. /** @hidden */
  12744. _currentStartSize2: number;
  12745. private readonly _rawTextureWidth;
  12746. private _rampGradientsTexture;
  12747. private _useRampGradients;
  12748. /** Gets or sets a matrix to use to compute projection */
  12749. defaultProjectionMatrix: Matrix;
  12750. /** Gets or sets a matrix to use to compute view */
  12751. defaultViewMatrix: Matrix;
  12752. /** Gets or sets a boolean indicating that ramp gradients must be used
  12753. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12754. */
  12755. get useRampGradients(): boolean;
  12756. set useRampGradients(value: boolean);
  12757. /**
  12758. * 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.
  12759. * 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: [])
  12760. */
  12761. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12762. private _subEmitters;
  12763. /**
  12764. * @hidden
  12765. * If the particle systems emitter should be disposed when the particle system is disposed
  12766. */
  12767. _disposeEmitterOnDispose: boolean;
  12768. /**
  12769. * The current active Sub-systems, this property is used by the root particle system only.
  12770. */
  12771. activeSubSystems: Array<ParticleSystem>;
  12772. /**
  12773. * Specifies if the particles are updated in emitter local space or world space
  12774. */
  12775. isLocal: boolean;
  12776. private _rootParticleSystem;
  12777. /**
  12778. * Gets the current list of active particles
  12779. */
  12780. get particles(): Particle[];
  12781. /**
  12782. * Gets the number of particles active at the same time.
  12783. * @returns The number of active particles.
  12784. */
  12785. getActiveCount(): number;
  12786. /**
  12787. * Returns the string "ParticleSystem"
  12788. * @returns a string containing the class name
  12789. */
  12790. getClassName(): string;
  12791. /**
  12792. * Gets a boolean indicating that the system is stopping
  12793. * @returns true if the system is currently stopping
  12794. */
  12795. isStopping(): boolean;
  12796. /**
  12797. * Gets the custom effect used to render the particles
  12798. * @param blendMode Blend mode for which the effect should be retrieved
  12799. * @returns The effect
  12800. */
  12801. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12802. /**
  12803. * Sets the custom effect used to render the particles
  12804. * @param effect The effect to set
  12805. * @param blendMode Blend mode for which the effect should be set
  12806. */
  12807. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12808. /** @hidden */
  12809. private _onBeforeDrawParticlesObservable;
  12810. /**
  12811. * Observable that will be called just before the particles are drawn
  12812. */
  12813. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12814. /**
  12815. * Gets the name of the particle vertex shader
  12816. */
  12817. get vertexShaderName(): string;
  12818. /**
  12819. * Instantiates a particle system.
  12820. * 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.
  12821. * @param name The name of the particle system
  12822. * @param capacity The max number of particles alive at the same time
  12823. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  12824. * @param customEffect a custom effect used to change the way particles are rendered by default
  12825. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12826. * @param epsilon Offset used to render the particles
  12827. */
  12828. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12829. private _addFactorGradient;
  12830. private _removeFactorGradient;
  12831. /**
  12832. * Adds a new life time gradient
  12833. * @param gradient defines the gradient to use (between 0 and 1)
  12834. * @param factor defines the life time factor to affect to the specified gradient
  12835. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12836. * @returns the current particle system
  12837. */
  12838. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12839. /**
  12840. * Remove a specific life time gradient
  12841. * @param gradient defines the gradient to remove
  12842. * @returns the current particle system
  12843. */
  12844. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12845. /**
  12846. * Adds a new size gradient
  12847. * @param gradient defines the gradient to use (between 0 and 1)
  12848. * @param factor defines the size factor to affect to the specified gradient
  12849. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12850. * @returns the current particle system
  12851. */
  12852. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12853. /**
  12854. * Remove a specific size gradient
  12855. * @param gradient defines the gradient to remove
  12856. * @returns the current particle system
  12857. */
  12858. removeSizeGradient(gradient: number): IParticleSystem;
  12859. /**
  12860. * Adds a new color remap gradient
  12861. * @param gradient defines the gradient to use (between 0 and 1)
  12862. * @param min defines the color remap minimal range
  12863. * @param max defines the color remap maximal range
  12864. * @returns the current particle system
  12865. */
  12866. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12867. /**
  12868. * Remove a specific color remap gradient
  12869. * @param gradient defines the gradient to remove
  12870. * @returns the current particle system
  12871. */
  12872. removeColorRemapGradient(gradient: number): IParticleSystem;
  12873. /**
  12874. * Adds a new alpha remap gradient
  12875. * @param gradient defines the gradient to use (between 0 and 1)
  12876. * @param min defines the alpha remap minimal range
  12877. * @param max defines the alpha remap maximal range
  12878. * @returns the current particle system
  12879. */
  12880. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12881. /**
  12882. * Remove a specific alpha remap gradient
  12883. * @param gradient defines the gradient to remove
  12884. * @returns the current particle system
  12885. */
  12886. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12887. /**
  12888. * Adds a new angular speed gradient
  12889. * @param gradient defines the gradient to use (between 0 and 1)
  12890. * @param factor defines the angular speed to affect to the specified gradient
  12891. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12892. * @returns the current particle system
  12893. */
  12894. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12895. /**
  12896. * Remove a specific angular speed gradient
  12897. * @param gradient defines the gradient to remove
  12898. * @returns the current particle system
  12899. */
  12900. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12901. /**
  12902. * Adds a new velocity gradient
  12903. * @param gradient defines the gradient to use (between 0 and 1)
  12904. * @param factor defines the velocity to affect to the specified gradient
  12905. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12906. * @returns the current particle system
  12907. */
  12908. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12909. /**
  12910. * Remove a specific velocity gradient
  12911. * @param gradient defines the gradient to remove
  12912. * @returns the current particle system
  12913. */
  12914. removeVelocityGradient(gradient: number): IParticleSystem;
  12915. /**
  12916. * Adds a new limit velocity gradient
  12917. * @param gradient defines the gradient to use (between 0 and 1)
  12918. * @param factor defines the limit velocity value to affect to the specified gradient
  12919. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12920. * @returns the current particle system
  12921. */
  12922. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12923. /**
  12924. * Remove a specific limit velocity gradient
  12925. * @param gradient defines the gradient to remove
  12926. * @returns the current particle system
  12927. */
  12928. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12929. /**
  12930. * Adds a new drag gradient
  12931. * @param gradient defines the gradient to use (between 0 and 1)
  12932. * @param factor defines the drag value to affect to the specified gradient
  12933. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12934. * @returns the current particle system
  12935. */
  12936. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12937. /**
  12938. * Remove a specific drag gradient
  12939. * @param gradient defines the gradient to remove
  12940. * @returns the current particle system
  12941. */
  12942. removeDragGradient(gradient: number): IParticleSystem;
  12943. /**
  12944. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12945. * @param gradient defines the gradient to use (between 0 and 1)
  12946. * @param factor defines the emit rate value to affect to the specified gradient
  12947. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12948. * @returns the current particle system
  12949. */
  12950. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12951. /**
  12952. * Remove a specific emit rate gradient
  12953. * @param gradient defines the gradient to remove
  12954. * @returns the current particle system
  12955. */
  12956. removeEmitRateGradient(gradient: number): IParticleSystem;
  12957. /**
  12958. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12959. * @param gradient defines the gradient to use (between 0 and 1)
  12960. * @param factor defines the start size value to affect to the specified gradient
  12961. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12962. * @returns the current particle system
  12963. */
  12964. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12965. /**
  12966. * Remove a specific start size gradient
  12967. * @param gradient defines the gradient to remove
  12968. * @returns the current particle system
  12969. */
  12970. removeStartSizeGradient(gradient: number): IParticleSystem;
  12971. private _createRampGradientTexture;
  12972. /**
  12973. * Gets the current list of ramp gradients.
  12974. * You must use addRampGradient and removeRampGradient to udpate this list
  12975. * @returns the list of ramp gradients
  12976. */
  12977. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12978. /** Force the system to rebuild all gradients that need to be resync */
  12979. forceRefreshGradients(): void;
  12980. private _syncRampGradientTexture;
  12981. /**
  12982. * Adds a new ramp gradient used to remap particle colors
  12983. * @param gradient defines the gradient to use (between 0 and 1)
  12984. * @param color defines the color to affect to the specified gradient
  12985. * @returns the current particle system
  12986. */
  12987. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12988. /**
  12989. * Remove a specific ramp gradient
  12990. * @param gradient defines the gradient to remove
  12991. * @returns the current particle system
  12992. */
  12993. removeRampGradient(gradient: number): ParticleSystem;
  12994. /**
  12995. * Adds a new color gradient
  12996. * @param gradient defines the gradient to use (between 0 and 1)
  12997. * @param color1 defines the color to affect to the specified gradient
  12998. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12999. * @returns this particle system
  13000. */
  13001. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13002. /**
  13003. * Remove a specific color gradient
  13004. * @param gradient defines the gradient to remove
  13005. * @returns this particle system
  13006. */
  13007. removeColorGradient(gradient: number): IParticleSystem;
  13008. private _fetchR;
  13009. protected _reset(): void;
  13010. private _resetEffect;
  13011. private _createVertexBuffers;
  13012. private _createIndexBuffer;
  13013. /**
  13014. * Gets the maximum number of particles active at the same time.
  13015. * @returns The max number of active particles.
  13016. */
  13017. getCapacity(): number;
  13018. /**
  13019. * Gets whether there are still active particles in the system.
  13020. * @returns True if it is alive, otherwise false.
  13021. */
  13022. isAlive(): boolean;
  13023. /**
  13024. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13025. * @returns True if it has been started, otherwise false.
  13026. */
  13027. isStarted(): boolean;
  13028. private _prepareSubEmitterInternalArray;
  13029. /**
  13030. * Starts the particle system and begins to emit
  13031. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13032. */
  13033. start(delay?: number): void;
  13034. /**
  13035. * Stops the particle system.
  13036. * @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.
  13037. */
  13038. stop(stopSubEmitters?: boolean): void;
  13039. /**
  13040. * Remove all active particles
  13041. */
  13042. reset(): void;
  13043. /**
  13044. * @hidden (for internal use only)
  13045. */
  13046. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13047. /**
  13048. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13049. * Its lifetime will start back at 0.
  13050. */
  13051. recycleParticle: (particle: Particle) => void;
  13052. private _stopSubEmitters;
  13053. private _createParticle;
  13054. private _removeFromRoot;
  13055. private _emitFromParticle;
  13056. private _update;
  13057. /** @hidden */
  13058. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13059. /** @hidden */
  13060. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13061. /**
  13062. * Fill the defines array according to the current settings of the particle system
  13063. * @param defines Array to be updated
  13064. * @param blendMode blend mode to take into account when updating the array
  13065. */
  13066. fillDefines(defines: Array<string>, blendMode: number): void;
  13067. /**
  13068. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13069. * @param uniforms Uniforms array to fill
  13070. * @param attributes Attributes array to fill
  13071. * @param samplers Samplers array to fill
  13072. */
  13073. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13074. /** @hidden */
  13075. private _getEffect;
  13076. /**
  13077. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13078. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13079. */
  13080. animate(preWarmOnly?: boolean): void;
  13081. private _appendParticleVertices;
  13082. /**
  13083. * Rebuilds the particle system.
  13084. */
  13085. rebuild(): void;
  13086. /**
  13087. * Is this system ready to be used/rendered
  13088. * @return true if the system is ready
  13089. */
  13090. isReady(): boolean;
  13091. private _render;
  13092. /**
  13093. * Renders the particle system in its current state.
  13094. * @returns the current number of particles
  13095. */
  13096. render(): number;
  13097. /**
  13098. * Disposes the particle system and free the associated resources
  13099. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13100. */
  13101. dispose(disposeTexture?: boolean): void;
  13102. /**
  13103. * Clones the particle system.
  13104. * @param name The name of the cloned object
  13105. * @param newEmitter The new emitter to use
  13106. * @returns the cloned particle system
  13107. */
  13108. clone(name: string, newEmitter: any): ParticleSystem;
  13109. /**
  13110. * Serializes the particle system to a JSON object
  13111. * @param serializeTexture defines if the texture must be serialized as well
  13112. * @returns the JSON object
  13113. */
  13114. serialize(serializeTexture?: boolean): any;
  13115. /** @hidden */
  13116. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13117. /** @hidden */
  13118. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13119. /**
  13120. * Parses a JSON object to create a particle system.
  13121. * @param parsedParticleSystem The JSON object to parse
  13122. * @param sceneOrEngine The scene or the engine to create the particle system in
  13123. * @param rootUrl The root url to use to load external dependencies like texture
  13124. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13125. * @returns the Parsed particle system
  13126. */
  13127. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13128. }
  13129. }
  13130. declare module BABYLON {
  13131. /**
  13132. * A particle represents one of the element emitted by a particle system.
  13133. * This is mainly define by its coordinates, direction, velocity and age.
  13134. */
  13135. export class Particle {
  13136. /**
  13137. * The particle system the particle belongs to.
  13138. */
  13139. particleSystem: ParticleSystem;
  13140. private static _Count;
  13141. /**
  13142. * Unique ID of the particle
  13143. */
  13144. id: number;
  13145. /**
  13146. * The world position of the particle in the scene.
  13147. */
  13148. position: Vector3;
  13149. /**
  13150. * The world direction of the particle in the scene.
  13151. */
  13152. direction: Vector3;
  13153. /**
  13154. * The color of the particle.
  13155. */
  13156. color: Color4;
  13157. /**
  13158. * The color change of the particle per step.
  13159. */
  13160. colorStep: Color4;
  13161. /**
  13162. * Defines how long will the life of the particle be.
  13163. */
  13164. lifeTime: number;
  13165. /**
  13166. * The current age of the particle.
  13167. */
  13168. age: number;
  13169. /**
  13170. * The current size of the particle.
  13171. */
  13172. size: number;
  13173. /**
  13174. * The current scale of the particle.
  13175. */
  13176. scale: Vector2;
  13177. /**
  13178. * The current angle of the particle.
  13179. */
  13180. angle: number;
  13181. /**
  13182. * Defines how fast is the angle changing.
  13183. */
  13184. angularSpeed: number;
  13185. /**
  13186. * Defines the cell index used by the particle to be rendered from a sprite.
  13187. */
  13188. cellIndex: number;
  13189. /**
  13190. * The information required to support color remapping
  13191. */
  13192. remapData: Vector4;
  13193. /** @hidden */
  13194. _randomCellOffset?: number;
  13195. /** @hidden */
  13196. _initialDirection: Nullable<Vector3>;
  13197. /** @hidden */
  13198. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13199. /** @hidden */
  13200. _initialStartSpriteCellID: number;
  13201. /** @hidden */
  13202. _initialEndSpriteCellID: number;
  13203. /** @hidden */
  13204. _currentColorGradient: Nullable<ColorGradient>;
  13205. /** @hidden */
  13206. _currentColor1: Color4;
  13207. /** @hidden */
  13208. _currentColor2: Color4;
  13209. /** @hidden */
  13210. _currentSizeGradient: Nullable<FactorGradient>;
  13211. /** @hidden */
  13212. _currentSize1: number;
  13213. /** @hidden */
  13214. _currentSize2: number;
  13215. /** @hidden */
  13216. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13217. /** @hidden */
  13218. _currentAngularSpeed1: number;
  13219. /** @hidden */
  13220. _currentAngularSpeed2: number;
  13221. /** @hidden */
  13222. _currentVelocityGradient: Nullable<FactorGradient>;
  13223. /** @hidden */
  13224. _currentVelocity1: number;
  13225. /** @hidden */
  13226. _currentVelocity2: number;
  13227. /** @hidden */
  13228. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13229. /** @hidden */
  13230. _currentLimitVelocity1: number;
  13231. /** @hidden */
  13232. _currentLimitVelocity2: number;
  13233. /** @hidden */
  13234. _currentDragGradient: Nullable<FactorGradient>;
  13235. /** @hidden */
  13236. _currentDrag1: number;
  13237. /** @hidden */
  13238. _currentDrag2: number;
  13239. /** @hidden */
  13240. _randomNoiseCoordinates1: Vector3;
  13241. /** @hidden */
  13242. _randomNoiseCoordinates2: Vector3;
  13243. /** @hidden */
  13244. _localPosition?: Vector3;
  13245. /**
  13246. * Creates a new instance Particle
  13247. * @param particleSystem the particle system the particle belongs to
  13248. */
  13249. constructor(
  13250. /**
  13251. * The particle system the particle belongs to.
  13252. */
  13253. particleSystem: ParticleSystem);
  13254. private updateCellInfoFromSystem;
  13255. /**
  13256. * Defines how the sprite cell index is updated for the particle
  13257. */
  13258. updateCellIndex(): void;
  13259. /** @hidden */
  13260. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13261. /** @hidden */
  13262. _inheritParticleInfoToSubEmitters(): void;
  13263. /** @hidden */
  13264. _reset(): void;
  13265. /**
  13266. * Copy the properties of particle to another one.
  13267. * @param other the particle to copy the information to.
  13268. */
  13269. copyTo(other: Particle): void;
  13270. }
  13271. }
  13272. declare module BABYLON {
  13273. /**
  13274. * Particle emitter represents a volume emitting particles.
  13275. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13276. */
  13277. export interface IParticleEmitterType {
  13278. /**
  13279. * Called by the particle System when the direction is computed for the created particle.
  13280. * @param worldMatrix is the world matrix of the particle system
  13281. * @param directionToUpdate is the direction vector to update with the result
  13282. * @param particle is the particle we are computed the direction for
  13283. * @param isLocal defines if the direction should be set in local space
  13284. */
  13285. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13286. /**
  13287. * Called by the particle System when the position is computed for the created particle.
  13288. * @param worldMatrix is the world matrix of the particle system
  13289. * @param positionToUpdate is the position vector to update with the result
  13290. * @param particle is the particle we are computed the position for
  13291. * @param isLocal defines if the position should be set in local space
  13292. */
  13293. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13294. /**
  13295. * Clones the current emitter and returns a copy of it
  13296. * @returns the new emitter
  13297. */
  13298. clone(): IParticleEmitterType;
  13299. /**
  13300. * Called by the GPUParticleSystem to setup the update shader
  13301. * @param effect defines the update shader
  13302. */
  13303. applyToShader(effect: Effect): void;
  13304. /**
  13305. * Returns a string to use to update the GPU particles update shader
  13306. * @returns the effect defines string
  13307. */
  13308. getEffectDefines(): string;
  13309. /**
  13310. * Returns a string representing the class name
  13311. * @returns a string containing the class name
  13312. */
  13313. getClassName(): string;
  13314. /**
  13315. * Serializes the particle system to a JSON object.
  13316. * @returns the JSON object
  13317. */
  13318. serialize(): any;
  13319. /**
  13320. * Parse properties from a JSON object
  13321. * @param serializationObject defines the JSON object
  13322. * @param scene defines the hosting scene
  13323. */
  13324. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13325. }
  13326. }
  13327. declare module BABYLON {
  13328. /**
  13329. * Particle emitter emitting particles from the inside of a box.
  13330. * It emits the particles randomly between 2 given directions.
  13331. */
  13332. export class BoxParticleEmitter implements IParticleEmitterType {
  13333. /**
  13334. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13335. */
  13336. direction1: Vector3;
  13337. /**
  13338. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13339. */
  13340. direction2: Vector3;
  13341. /**
  13342. * 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.
  13343. */
  13344. minEmitBox: Vector3;
  13345. /**
  13346. * 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.
  13347. */
  13348. maxEmitBox: Vector3;
  13349. /**
  13350. * Creates a new instance BoxParticleEmitter
  13351. */
  13352. constructor();
  13353. /**
  13354. * Called by the particle System when the direction is computed for the created particle.
  13355. * @param worldMatrix is the world matrix of the particle system
  13356. * @param directionToUpdate is the direction vector to update with the result
  13357. * @param particle is the particle we are computed the direction for
  13358. * @param isLocal defines if the direction should be set in local space
  13359. */
  13360. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13361. /**
  13362. * Called by the particle System when the position is computed for the created particle.
  13363. * @param worldMatrix is the world matrix of the particle system
  13364. * @param positionToUpdate is the position vector to update with the result
  13365. * @param particle is the particle we are computed the position for
  13366. * @param isLocal defines if the position should be set in local space
  13367. */
  13368. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13369. /**
  13370. * Clones the current emitter and returns a copy of it
  13371. * @returns the new emitter
  13372. */
  13373. clone(): BoxParticleEmitter;
  13374. /**
  13375. * Called by the GPUParticleSystem to setup the update shader
  13376. * @param effect defines the update shader
  13377. */
  13378. applyToShader(effect: Effect): void;
  13379. /**
  13380. * Returns a string to use to update the GPU particles update shader
  13381. * @returns a string containng the defines string
  13382. */
  13383. getEffectDefines(): string;
  13384. /**
  13385. * Returns the string "BoxParticleEmitter"
  13386. * @returns a string containing the class name
  13387. */
  13388. getClassName(): string;
  13389. /**
  13390. * Serializes the particle system to a JSON object.
  13391. * @returns the JSON object
  13392. */
  13393. serialize(): any;
  13394. /**
  13395. * Parse properties from a JSON object
  13396. * @param serializationObject defines the JSON object
  13397. */
  13398. parse(serializationObject: any): void;
  13399. }
  13400. }
  13401. declare module BABYLON {
  13402. /**
  13403. * Particle emitter emitting particles from the inside of a cone.
  13404. * It emits the particles alongside the cone volume from the base to the particle.
  13405. * The emission direction might be randomized.
  13406. */
  13407. export class ConeParticleEmitter implements IParticleEmitterType {
  13408. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13409. directionRandomizer: number;
  13410. private _radius;
  13411. private _angle;
  13412. private _height;
  13413. /**
  13414. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13415. */
  13416. radiusRange: number;
  13417. /**
  13418. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13419. */
  13420. heightRange: number;
  13421. /**
  13422. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13423. */
  13424. emitFromSpawnPointOnly: boolean;
  13425. /**
  13426. * Gets or sets the radius of the emission cone
  13427. */
  13428. get radius(): number;
  13429. set radius(value: number);
  13430. /**
  13431. * Gets or sets the angle of the emission cone
  13432. */
  13433. get angle(): number;
  13434. set angle(value: number);
  13435. private _buildHeight;
  13436. /**
  13437. * Creates a new instance ConeParticleEmitter
  13438. * @param radius the radius of the emission cone (1 by default)
  13439. * @param angle the cone base angle (PI by default)
  13440. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13441. */
  13442. constructor(radius?: number, angle?: number,
  13443. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13444. directionRandomizer?: number);
  13445. /**
  13446. * Called by the particle System when the direction is computed for the created particle.
  13447. * @param worldMatrix is the world matrix of the particle system
  13448. * @param directionToUpdate is the direction vector to update with the result
  13449. * @param particle is the particle we are computed the direction for
  13450. * @param isLocal defines if the direction should be set in local space
  13451. */
  13452. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13453. /**
  13454. * Called by the particle System when the position is computed for the created particle.
  13455. * @param worldMatrix is the world matrix of the particle system
  13456. * @param positionToUpdate is the position vector to update with the result
  13457. * @param particle is the particle we are computed the position for
  13458. * @param isLocal defines if the position should be set in local space
  13459. */
  13460. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13461. /**
  13462. * Clones the current emitter and returns a copy of it
  13463. * @returns the new emitter
  13464. */
  13465. clone(): ConeParticleEmitter;
  13466. /**
  13467. * Called by the GPUParticleSystem to setup the update shader
  13468. * @param effect defines the update shader
  13469. */
  13470. applyToShader(effect: Effect): void;
  13471. /**
  13472. * Returns a string to use to update the GPU particles update shader
  13473. * @returns a string containng the defines string
  13474. */
  13475. getEffectDefines(): string;
  13476. /**
  13477. * Returns the string "ConeParticleEmitter"
  13478. * @returns a string containing the class name
  13479. */
  13480. getClassName(): string;
  13481. /**
  13482. * Serializes the particle system to a JSON object.
  13483. * @returns the JSON object
  13484. */
  13485. serialize(): any;
  13486. /**
  13487. * Parse properties from a JSON object
  13488. * @param serializationObject defines the JSON object
  13489. */
  13490. parse(serializationObject: any): void;
  13491. }
  13492. }
  13493. declare module BABYLON {
  13494. /**
  13495. * Particle emitter emitting particles from the inside of a cylinder.
  13496. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13497. */
  13498. export class CylinderParticleEmitter implements IParticleEmitterType {
  13499. /**
  13500. * The radius of the emission cylinder.
  13501. */
  13502. radius: number;
  13503. /**
  13504. * The height of the emission cylinder.
  13505. */
  13506. height: number;
  13507. /**
  13508. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13509. */
  13510. radiusRange: number;
  13511. /**
  13512. * How much to randomize the particle direction [0-1].
  13513. */
  13514. directionRandomizer: number;
  13515. /**
  13516. * Creates a new instance CylinderParticleEmitter
  13517. * @param radius the radius of the emission cylinder (1 by default)
  13518. * @param height the height of the emission cylinder (1 by default)
  13519. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13520. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13521. */
  13522. constructor(
  13523. /**
  13524. * The radius of the emission cylinder.
  13525. */
  13526. radius?: number,
  13527. /**
  13528. * The height of the emission cylinder.
  13529. */
  13530. height?: number,
  13531. /**
  13532. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13533. */
  13534. radiusRange?: number,
  13535. /**
  13536. * How much to randomize the particle direction [0-1].
  13537. */
  13538. directionRandomizer?: number);
  13539. /**
  13540. * Called by the particle System when the direction is computed for the created particle.
  13541. * @param worldMatrix is the world matrix of the particle system
  13542. * @param directionToUpdate is the direction vector to update with the result
  13543. * @param particle is the particle we are computed the direction for
  13544. * @param isLocal defines if the direction should be set in local space
  13545. */
  13546. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13547. /**
  13548. * Called by the particle System when the position is computed for the created particle.
  13549. * @param worldMatrix is the world matrix of the particle system
  13550. * @param positionToUpdate is the position vector to update with the result
  13551. * @param particle is the particle we are computed the position for
  13552. * @param isLocal defines if the position should be set in local space
  13553. */
  13554. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13555. /**
  13556. * Clones the current emitter and returns a copy of it
  13557. * @returns the new emitter
  13558. */
  13559. clone(): CylinderParticleEmitter;
  13560. /**
  13561. * Called by the GPUParticleSystem to setup the update shader
  13562. * @param effect defines the update shader
  13563. */
  13564. applyToShader(effect: Effect): void;
  13565. /**
  13566. * Returns a string to use to update the GPU particles update shader
  13567. * @returns a string containng the defines string
  13568. */
  13569. getEffectDefines(): string;
  13570. /**
  13571. * Returns the string "CylinderParticleEmitter"
  13572. * @returns a string containing the class name
  13573. */
  13574. getClassName(): string;
  13575. /**
  13576. * Serializes the particle system to a JSON object.
  13577. * @returns the JSON object
  13578. */
  13579. serialize(): any;
  13580. /**
  13581. * Parse properties from a JSON object
  13582. * @param serializationObject defines the JSON object
  13583. */
  13584. parse(serializationObject: any): void;
  13585. }
  13586. /**
  13587. * Particle emitter emitting particles from the inside of a cylinder.
  13588. * It emits the particles randomly between two vectors.
  13589. */
  13590. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13591. /**
  13592. * The min limit of the emission direction.
  13593. */
  13594. direction1: Vector3;
  13595. /**
  13596. * The max limit of the emission direction.
  13597. */
  13598. direction2: Vector3;
  13599. /**
  13600. * Creates a new instance CylinderDirectedParticleEmitter
  13601. * @param radius the radius of the emission cylinder (1 by default)
  13602. * @param height the height of the emission cylinder (1 by default)
  13603. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13604. * @param direction1 the min limit of the emission direction (up vector by default)
  13605. * @param direction2 the max limit of the emission direction (up vector by default)
  13606. */
  13607. constructor(radius?: number, height?: number, radiusRange?: number,
  13608. /**
  13609. * The min limit of the emission direction.
  13610. */
  13611. direction1?: Vector3,
  13612. /**
  13613. * The max limit of the emission direction.
  13614. */
  13615. direction2?: Vector3);
  13616. /**
  13617. * Called by the particle System when the direction is computed for the created particle.
  13618. * @param worldMatrix is the world matrix of the particle system
  13619. * @param directionToUpdate is the direction vector to update with the result
  13620. * @param particle is the particle we are computed the direction for
  13621. */
  13622. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13623. /**
  13624. * Clones the current emitter and returns a copy of it
  13625. * @returns the new emitter
  13626. */
  13627. clone(): CylinderDirectedParticleEmitter;
  13628. /**
  13629. * Called by the GPUParticleSystem to setup the update shader
  13630. * @param effect defines the update shader
  13631. */
  13632. applyToShader(effect: Effect): void;
  13633. /**
  13634. * Returns a string to use to update the GPU particles update shader
  13635. * @returns a string containng the defines string
  13636. */
  13637. getEffectDefines(): string;
  13638. /**
  13639. * Returns the string "CylinderDirectedParticleEmitter"
  13640. * @returns a string containing the class name
  13641. */
  13642. getClassName(): string;
  13643. /**
  13644. * Serializes the particle system to a JSON object.
  13645. * @returns the JSON object
  13646. */
  13647. serialize(): any;
  13648. /**
  13649. * Parse properties from a JSON object
  13650. * @param serializationObject defines the JSON object
  13651. */
  13652. parse(serializationObject: any): void;
  13653. }
  13654. }
  13655. declare module BABYLON {
  13656. /**
  13657. * Particle emitter emitting particles from the inside of a hemisphere.
  13658. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13659. */
  13660. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13661. /**
  13662. * The radius of the emission hemisphere.
  13663. */
  13664. radius: number;
  13665. /**
  13666. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13667. */
  13668. radiusRange: number;
  13669. /**
  13670. * How much to randomize the particle direction [0-1].
  13671. */
  13672. directionRandomizer: number;
  13673. /**
  13674. * Creates a new instance HemisphericParticleEmitter
  13675. * @param radius the radius of the emission hemisphere (1 by default)
  13676. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13677. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13678. */
  13679. constructor(
  13680. /**
  13681. * The radius of the emission hemisphere.
  13682. */
  13683. radius?: number,
  13684. /**
  13685. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13686. */
  13687. radiusRange?: number,
  13688. /**
  13689. * How much to randomize the particle direction [0-1].
  13690. */
  13691. directionRandomizer?: number);
  13692. /**
  13693. * Called by the particle System when the direction is computed for the created particle.
  13694. * @param worldMatrix is the world matrix of the particle system
  13695. * @param directionToUpdate is the direction vector to update with the result
  13696. * @param particle is the particle we are computed the direction for
  13697. * @param isLocal defines if the direction should be set in local space
  13698. */
  13699. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13700. /**
  13701. * Called by the particle System when the position is computed for the created particle.
  13702. * @param worldMatrix is the world matrix of the particle system
  13703. * @param positionToUpdate is the position vector to update with the result
  13704. * @param particle is the particle we are computed the position for
  13705. * @param isLocal defines if the position should be set in local space
  13706. */
  13707. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13708. /**
  13709. * Clones the current emitter and returns a copy of it
  13710. * @returns the new emitter
  13711. */
  13712. clone(): HemisphericParticleEmitter;
  13713. /**
  13714. * Called by the GPUParticleSystem to setup the update shader
  13715. * @param effect defines the update shader
  13716. */
  13717. applyToShader(effect: Effect): void;
  13718. /**
  13719. * Returns a string to use to update the GPU particles update shader
  13720. * @returns a string containng the defines string
  13721. */
  13722. getEffectDefines(): string;
  13723. /**
  13724. * Returns the string "HemisphericParticleEmitter"
  13725. * @returns a string containing the class name
  13726. */
  13727. getClassName(): string;
  13728. /**
  13729. * Serializes the particle system to a JSON object.
  13730. * @returns the JSON object
  13731. */
  13732. serialize(): any;
  13733. /**
  13734. * Parse properties from a JSON object
  13735. * @param serializationObject defines the JSON object
  13736. */
  13737. parse(serializationObject: any): void;
  13738. }
  13739. }
  13740. declare module BABYLON {
  13741. /**
  13742. * Particle emitter emitting particles from a point.
  13743. * It emits the particles randomly between 2 given directions.
  13744. */
  13745. export class PointParticleEmitter implements IParticleEmitterType {
  13746. /**
  13747. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13748. */
  13749. direction1: Vector3;
  13750. /**
  13751. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13752. */
  13753. direction2: Vector3;
  13754. /**
  13755. * Creates a new instance PointParticleEmitter
  13756. */
  13757. constructor();
  13758. /**
  13759. * Called by the particle System when the direction is computed for the created particle.
  13760. * @param worldMatrix is the world matrix of the particle system
  13761. * @param directionToUpdate is the direction vector to update with the result
  13762. * @param particle is the particle we are computed the direction for
  13763. * @param isLocal defines if the direction should be set in local space
  13764. */
  13765. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13766. /**
  13767. * Called by the particle System when the position is computed for the created particle.
  13768. * @param worldMatrix is the world matrix of the particle system
  13769. * @param positionToUpdate is the position vector to update with the result
  13770. * @param particle is the particle we are computed the position for
  13771. * @param isLocal defines if the position should be set in local space
  13772. */
  13773. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13774. /**
  13775. * Clones the current emitter and returns a copy of it
  13776. * @returns the new emitter
  13777. */
  13778. clone(): PointParticleEmitter;
  13779. /**
  13780. * Called by the GPUParticleSystem to setup the update shader
  13781. * @param effect defines the update shader
  13782. */
  13783. applyToShader(effect: Effect): void;
  13784. /**
  13785. * Returns a string to use to update the GPU particles update shader
  13786. * @returns a string containng the defines string
  13787. */
  13788. getEffectDefines(): string;
  13789. /**
  13790. * Returns the string "PointParticleEmitter"
  13791. * @returns a string containing the class name
  13792. */
  13793. getClassName(): string;
  13794. /**
  13795. * Serializes the particle system to a JSON object.
  13796. * @returns the JSON object
  13797. */
  13798. serialize(): any;
  13799. /**
  13800. * Parse properties from a JSON object
  13801. * @param serializationObject defines the JSON object
  13802. */
  13803. parse(serializationObject: any): void;
  13804. }
  13805. }
  13806. declare module BABYLON {
  13807. /**
  13808. * Particle emitter emitting particles from the inside of a sphere.
  13809. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13810. */
  13811. export class SphereParticleEmitter implements IParticleEmitterType {
  13812. /**
  13813. * The radius of the emission sphere.
  13814. */
  13815. radius: number;
  13816. /**
  13817. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13818. */
  13819. radiusRange: number;
  13820. /**
  13821. * How much to randomize the particle direction [0-1].
  13822. */
  13823. directionRandomizer: number;
  13824. /**
  13825. * Creates a new instance SphereParticleEmitter
  13826. * @param radius the radius of the emission sphere (1 by default)
  13827. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13828. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13829. */
  13830. constructor(
  13831. /**
  13832. * The radius of the emission sphere.
  13833. */
  13834. radius?: number,
  13835. /**
  13836. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13837. */
  13838. radiusRange?: number,
  13839. /**
  13840. * How much to randomize the particle direction [0-1].
  13841. */
  13842. directionRandomizer?: number);
  13843. /**
  13844. * Called by the particle System when the direction is computed for the created particle.
  13845. * @param worldMatrix is the world matrix of the particle system
  13846. * @param directionToUpdate is the direction vector to update with the result
  13847. * @param particle is the particle we are computed the direction for
  13848. * @param isLocal defines if the direction should be set in local space
  13849. */
  13850. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13851. /**
  13852. * Called by the particle System when the position is computed for the created particle.
  13853. * @param worldMatrix is the world matrix of the particle system
  13854. * @param positionToUpdate is the position vector to update with the result
  13855. * @param particle is the particle we are computed the position for
  13856. * @param isLocal defines if the position should be set in local space
  13857. */
  13858. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13859. /**
  13860. * Clones the current emitter and returns a copy of it
  13861. * @returns the new emitter
  13862. */
  13863. clone(): SphereParticleEmitter;
  13864. /**
  13865. * Called by the GPUParticleSystem to setup the update shader
  13866. * @param effect defines the update shader
  13867. */
  13868. applyToShader(effect: Effect): void;
  13869. /**
  13870. * Returns a string to use to update the GPU particles update shader
  13871. * @returns a string containng the defines string
  13872. */
  13873. getEffectDefines(): string;
  13874. /**
  13875. * Returns the string "SphereParticleEmitter"
  13876. * @returns a string containing the class name
  13877. */
  13878. getClassName(): string;
  13879. /**
  13880. * Serializes the particle system to a JSON object.
  13881. * @returns the JSON object
  13882. */
  13883. serialize(): any;
  13884. /**
  13885. * Parse properties from a JSON object
  13886. * @param serializationObject defines the JSON object
  13887. */
  13888. parse(serializationObject: any): void;
  13889. }
  13890. /**
  13891. * Particle emitter emitting particles from the inside of a sphere.
  13892. * It emits the particles randomly between two vectors.
  13893. */
  13894. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13895. /**
  13896. * The min limit of the emission direction.
  13897. */
  13898. direction1: Vector3;
  13899. /**
  13900. * The max limit of the emission direction.
  13901. */
  13902. direction2: Vector3;
  13903. /**
  13904. * Creates a new instance SphereDirectedParticleEmitter
  13905. * @param radius the radius of the emission sphere (1 by default)
  13906. * @param direction1 the min limit of the emission direction (up vector by default)
  13907. * @param direction2 the max limit of the emission direction (up vector by default)
  13908. */
  13909. constructor(radius?: number,
  13910. /**
  13911. * The min limit of the emission direction.
  13912. */
  13913. direction1?: Vector3,
  13914. /**
  13915. * The max limit of the emission direction.
  13916. */
  13917. direction2?: Vector3);
  13918. /**
  13919. * Called by the particle System when the direction is computed for the created particle.
  13920. * @param worldMatrix is the world matrix of the particle system
  13921. * @param directionToUpdate is the direction vector to update with the result
  13922. * @param particle is the particle we are computed the direction for
  13923. */
  13924. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13925. /**
  13926. * Clones the current emitter and returns a copy of it
  13927. * @returns the new emitter
  13928. */
  13929. clone(): SphereDirectedParticleEmitter;
  13930. /**
  13931. * Called by the GPUParticleSystem to setup the update shader
  13932. * @param effect defines the update shader
  13933. */
  13934. applyToShader(effect: Effect): void;
  13935. /**
  13936. * Returns a string to use to update the GPU particles update shader
  13937. * @returns a string containng the defines string
  13938. */
  13939. getEffectDefines(): string;
  13940. /**
  13941. * Returns the string "SphereDirectedParticleEmitter"
  13942. * @returns a string containing the class name
  13943. */
  13944. getClassName(): string;
  13945. /**
  13946. * Serializes the particle system to a JSON object.
  13947. * @returns the JSON object
  13948. */
  13949. serialize(): any;
  13950. /**
  13951. * Parse properties from a JSON object
  13952. * @param serializationObject defines the JSON object
  13953. */
  13954. parse(serializationObject: any): void;
  13955. }
  13956. }
  13957. declare module BABYLON {
  13958. /**
  13959. * Particle emitter emitting particles from a custom list of positions.
  13960. */
  13961. export class CustomParticleEmitter implements IParticleEmitterType {
  13962. /**
  13963. * Gets or sets the position generator that will create the inital position of each particle.
  13964. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13965. */
  13966. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13967. /**
  13968. * Gets or sets the destination generator that will create the final destination of each particle.
  13969. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13970. */
  13971. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13972. /**
  13973. * Creates a new instance CustomParticleEmitter
  13974. */
  13975. constructor();
  13976. /**
  13977. * Called by the particle System when the direction is computed for the created particle.
  13978. * @param worldMatrix is the world matrix of the particle system
  13979. * @param directionToUpdate is the direction vector to update with the result
  13980. * @param particle is the particle we are computed the direction for
  13981. * @param isLocal defines if the direction should be set in local space
  13982. */
  13983. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13984. /**
  13985. * Called by the particle System when the position is computed for the created particle.
  13986. * @param worldMatrix is the world matrix of the particle system
  13987. * @param positionToUpdate is the position vector to update with the result
  13988. * @param particle is the particle we are computed the position for
  13989. * @param isLocal defines if the position should be set in local space
  13990. */
  13991. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13992. /**
  13993. * Clones the current emitter and returns a copy of it
  13994. * @returns the new emitter
  13995. */
  13996. clone(): CustomParticleEmitter;
  13997. /**
  13998. * Called by the GPUParticleSystem to setup the update shader
  13999. * @param effect defines the update shader
  14000. */
  14001. applyToShader(effect: Effect): void;
  14002. /**
  14003. * Returns a string to use to update the GPU particles update shader
  14004. * @returns a string containng the defines string
  14005. */
  14006. getEffectDefines(): string;
  14007. /**
  14008. * Returns the string "PointParticleEmitter"
  14009. * @returns a string containing the class name
  14010. */
  14011. getClassName(): string;
  14012. /**
  14013. * Serializes the particle system to a JSON object.
  14014. * @returns the JSON object
  14015. */
  14016. serialize(): any;
  14017. /**
  14018. * Parse properties from a JSON object
  14019. * @param serializationObject defines the JSON object
  14020. */
  14021. parse(serializationObject: any): void;
  14022. }
  14023. }
  14024. declare module BABYLON {
  14025. /**
  14026. * Particle emitter emitting particles from the inside of a box.
  14027. * It emits the particles randomly between 2 given directions.
  14028. */
  14029. export class MeshParticleEmitter implements IParticleEmitterType {
  14030. private _indices;
  14031. private _positions;
  14032. private _normals;
  14033. private _storedNormal;
  14034. private _mesh;
  14035. /**
  14036. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14037. */
  14038. direction1: Vector3;
  14039. /**
  14040. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14041. */
  14042. direction2: Vector3;
  14043. /**
  14044. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14045. */
  14046. useMeshNormalsForDirection: boolean;
  14047. /** Defines the mesh to use as source */
  14048. get mesh(): Nullable<AbstractMesh>;
  14049. set mesh(value: Nullable<AbstractMesh>);
  14050. /**
  14051. * Creates a new instance MeshParticleEmitter
  14052. * @param mesh defines the mesh to use as source
  14053. */
  14054. constructor(mesh?: Nullable<AbstractMesh>);
  14055. /**
  14056. * Called by the particle System when the direction is computed for the created particle.
  14057. * @param worldMatrix is the world matrix of the particle system
  14058. * @param directionToUpdate is the direction vector to update with the result
  14059. * @param particle is the particle we are computed the direction for
  14060. * @param isLocal defines if the direction should be set in local space
  14061. */
  14062. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14063. /**
  14064. * Called by the particle System when the position is computed for the created particle.
  14065. * @param worldMatrix is the world matrix of the particle system
  14066. * @param positionToUpdate is the position vector to update with the result
  14067. * @param particle is the particle we are computed the position for
  14068. * @param isLocal defines if the position should be set in local space
  14069. */
  14070. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14071. /**
  14072. * Clones the current emitter and returns a copy of it
  14073. * @returns the new emitter
  14074. */
  14075. clone(): MeshParticleEmitter;
  14076. /**
  14077. * Called by the GPUParticleSystem to setup the update shader
  14078. * @param effect defines the update shader
  14079. */
  14080. applyToShader(effect: Effect): void;
  14081. /**
  14082. * Returns a string to use to update the GPU particles update shader
  14083. * @returns a string containng the defines string
  14084. */
  14085. getEffectDefines(): string;
  14086. /**
  14087. * Returns the string "BoxParticleEmitter"
  14088. * @returns a string containing the class name
  14089. */
  14090. getClassName(): string;
  14091. /**
  14092. * Serializes the particle system to a JSON object.
  14093. * @returns the JSON object
  14094. */
  14095. serialize(): any;
  14096. /**
  14097. * Parse properties from a JSON object
  14098. * @param serializationObject defines the JSON object
  14099. * @param scene defines the hosting scene
  14100. */
  14101. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14102. }
  14103. }
  14104. declare module BABYLON {
  14105. /**
  14106. * Interface representing a particle system in Babylon.js.
  14107. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14108. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14109. */
  14110. export interface IParticleSystem {
  14111. /**
  14112. * List of animations used by the particle system.
  14113. */
  14114. animations: Animation[];
  14115. /**
  14116. * The id of the Particle system.
  14117. */
  14118. id: string;
  14119. /**
  14120. * The name of the Particle system.
  14121. */
  14122. name: string;
  14123. /**
  14124. * The emitter represents the Mesh or position we are attaching the particle system to.
  14125. */
  14126. emitter: Nullable<AbstractMesh | Vector3>;
  14127. /**
  14128. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14129. */
  14130. isBillboardBased: boolean;
  14131. /**
  14132. * The rendering group used by the Particle system to chose when to render.
  14133. */
  14134. renderingGroupId: number;
  14135. /**
  14136. * The layer mask we are rendering the particles through.
  14137. */
  14138. layerMask: number;
  14139. /**
  14140. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14141. */
  14142. updateSpeed: number;
  14143. /**
  14144. * The amount of time the particle system is running (depends of the overall update speed).
  14145. */
  14146. targetStopDuration: number;
  14147. /**
  14148. * The texture used to render each particle. (this can be a spritesheet)
  14149. */
  14150. particleTexture: Nullable<BaseTexture>;
  14151. /**
  14152. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14153. */
  14154. blendMode: number;
  14155. /**
  14156. * Minimum life time of emitting particles.
  14157. */
  14158. minLifeTime: number;
  14159. /**
  14160. * Maximum life time of emitting particles.
  14161. */
  14162. maxLifeTime: number;
  14163. /**
  14164. * Minimum Size of emitting particles.
  14165. */
  14166. minSize: number;
  14167. /**
  14168. * Maximum Size of emitting particles.
  14169. */
  14170. maxSize: number;
  14171. /**
  14172. * Minimum scale of emitting particles on X axis.
  14173. */
  14174. minScaleX: number;
  14175. /**
  14176. * Maximum scale of emitting particles on X axis.
  14177. */
  14178. maxScaleX: number;
  14179. /**
  14180. * Minimum scale of emitting particles on Y axis.
  14181. */
  14182. minScaleY: number;
  14183. /**
  14184. * Maximum scale of emitting particles on Y axis.
  14185. */
  14186. maxScaleY: number;
  14187. /**
  14188. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14189. */
  14190. color1: Color4;
  14191. /**
  14192. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14193. */
  14194. color2: Color4;
  14195. /**
  14196. * Color the particle will have at the end of its lifetime.
  14197. */
  14198. colorDead: Color4;
  14199. /**
  14200. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14201. */
  14202. emitRate: number;
  14203. /**
  14204. * You can use gravity if you want to give an orientation to your particles.
  14205. */
  14206. gravity: Vector3;
  14207. /**
  14208. * Minimum power of emitting particles.
  14209. */
  14210. minEmitPower: number;
  14211. /**
  14212. * Maximum power of emitting particles.
  14213. */
  14214. maxEmitPower: number;
  14215. /**
  14216. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14217. */
  14218. minAngularSpeed: number;
  14219. /**
  14220. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14221. */
  14222. maxAngularSpeed: number;
  14223. /**
  14224. * Gets or sets the minimal initial rotation in radians.
  14225. */
  14226. minInitialRotation: number;
  14227. /**
  14228. * Gets or sets the maximal initial rotation in radians.
  14229. */
  14230. maxInitialRotation: number;
  14231. /**
  14232. * The particle emitter type defines the emitter used by the particle system.
  14233. * It can be for example box, sphere, or cone...
  14234. */
  14235. particleEmitterType: Nullable<IParticleEmitterType>;
  14236. /**
  14237. * Defines the delay in milliseconds before starting the system (0 by default)
  14238. */
  14239. startDelay: number;
  14240. /**
  14241. * 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
  14242. */
  14243. preWarmCycles: number;
  14244. /**
  14245. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14246. */
  14247. preWarmStepOffset: number;
  14248. /**
  14249. * 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)
  14250. */
  14251. spriteCellChangeSpeed: number;
  14252. /**
  14253. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14254. */
  14255. startSpriteCellID: number;
  14256. /**
  14257. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14258. */
  14259. endSpriteCellID: number;
  14260. /**
  14261. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14262. */
  14263. spriteCellWidth: number;
  14264. /**
  14265. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14266. */
  14267. spriteCellHeight: number;
  14268. /**
  14269. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14270. */
  14271. spriteRandomStartCell: boolean;
  14272. /**
  14273. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14274. */
  14275. isAnimationSheetEnabled: boolean;
  14276. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14277. translationPivot: Vector2;
  14278. /**
  14279. * Gets or sets a texture used to add random noise to particle positions
  14280. */
  14281. noiseTexture: Nullable<BaseTexture>;
  14282. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14283. noiseStrength: Vector3;
  14284. /**
  14285. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14286. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14287. */
  14288. billboardMode: number;
  14289. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14290. limitVelocityDamping: number;
  14291. /**
  14292. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14293. */
  14294. beginAnimationOnStart: boolean;
  14295. /**
  14296. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14297. */
  14298. beginAnimationFrom: number;
  14299. /**
  14300. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14301. */
  14302. beginAnimationTo: number;
  14303. /**
  14304. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14305. */
  14306. beginAnimationLoop: boolean;
  14307. /**
  14308. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14309. */
  14310. disposeOnStop: boolean;
  14311. /**
  14312. * Specifies if the particles are updated in emitter local space or world space
  14313. */
  14314. isLocal: boolean;
  14315. /** Snippet ID if the particle system was created from the snippet server */
  14316. snippetId: string;
  14317. /** Gets or sets a matrix to use to compute projection */
  14318. defaultProjectionMatrix: Matrix;
  14319. /**
  14320. * Gets the maximum number of particles active at the same time.
  14321. * @returns The max number of active particles.
  14322. */
  14323. getCapacity(): number;
  14324. /**
  14325. * Gets the number of particles active at the same time.
  14326. * @returns The number of active particles.
  14327. */
  14328. getActiveCount(): number;
  14329. /**
  14330. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14331. * @returns True if it has been started, otherwise false.
  14332. */
  14333. isStarted(): boolean;
  14334. /**
  14335. * Animates the particle system for this frame.
  14336. */
  14337. animate(): void;
  14338. /**
  14339. * Renders the particle system in its current state.
  14340. * @returns the current number of particles
  14341. */
  14342. render(): number;
  14343. /**
  14344. * Dispose the particle system and frees its associated resources.
  14345. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14346. */
  14347. dispose(disposeTexture?: boolean): void;
  14348. /**
  14349. * An event triggered when the system is disposed
  14350. */
  14351. onDisposeObservable: Observable<IParticleSystem>;
  14352. /**
  14353. * An event triggered when the system is stopped
  14354. */
  14355. onStoppedObservable: Observable<IParticleSystem>;
  14356. /**
  14357. * Clones the particle system.
  14358. * @param name The name of the cloned object
  14359. * @param newEmitter The new emitter to use
  14360. * @returns the cloned particle system
  14361. */
  14362. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14363. /**
  14364. * Serializes the particle system to a JSON object
  14365. * @param serializeTexture defines if the texture must be serialized as well
  14366. * @returns the JSON object
  14367. */
  14368. serialize(serializeTexture: boolean): any;
  14369. /**
  14370. * Rebuild the particle system
  14371. */
  14372. rebuild(): void;
  14373. /** Force the system to rebuild all gradients that need to be resync */
  14374. forceRefreshGradients(): void;
  14375. /**
  14376. * Starts the particle system and begins to emit
  14377. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14378. */
  14379. start(delay?: number): void;
  14380. /**
  14381. * Stops the particle system.
  14382. */
  14383. stop(): void;
  14384. /**
  14385. * Remove all active particles
  14386. */
  14387. reset(): void;
  14388. /**
  14389. * Gets a boolean indicating that the system is stopping
  14390. * @returns true if the system is currently stopping
  14391. */
  14392. isStopping(): boolean;
  14393. /**
  14394. * Is this system ready to be used/rendered
  14395. * @return true if the system is ready
  14396. */
  14397. isReady(): boolean;
  14398. /**
  14399. * Returns the string "ParticleSystem"
  14400. * @returns a string containing the class name
  14401. */
  14402. getClassName(): string;
  14403. /**
  14404. * Gets the custom effect used to render the particles
  14405. * @param blendMode Blend mode for which the effect should be retrieved
  14406. * @returns The effect
  14407. */
  14408. getCustomEffect(blendMode: number): Nullable<Effect>;
  14409. /**
  14410. * Sets the custom effect used to render the particles
  14411. * @param effect The effect to set
  14412. * @param blendMode Blend mode for which the effect should be set
  14413. */
  14414. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14415. /**
  14416. * Fill the defines array according to the current settings of the particle system
  14417. * @param defines Array to be updated
  14418. * @param blendMode blend mode to take into account when updating the array
  14419. */
  14420. fillDefines(defines: Array<string>, blendMode: number): void;
  14421. /**
  14422. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14423. * @param uniforms Uniforms array to fill
  14424. * @param attributes Attributes array to fill
  14425. * @param samplers Samplers array to fill
  14426. */
  14427. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14428. /**
  14429. * Observable that will be called just before the particles are drawn
  14430. */
  14431. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14432. /**
  14433. * Gets the name of the particle vertex shader
  14434. */
  14435. vertexShaderName: string;
  14436. /**
  14437. * Adds a new color gradient
  14438. * @param gradient defines the gradient to use (between 0 and 1)
  14439. * @param color1 defines the color to affect to the specified gradient
  14440. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14441. * @returns the current particle system
  14442. */
  14443. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14444. /**
  14445. * Remove a specific color gradient
  14446. * @param gradient defines the gradient to remove
  14447. * @returns the current particle system
  14448. */
  14449. removeColorGradient(gradient: number): IParticleSystem;
  14450. /**
  14451. * Adds a new size gradient
  14452. * @param gradient defines the gradient to use (between 0 and 1)
  14453. * @param factor defines the size factor to affect to the specified gradient
  14454. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14455. * @returns the current particle system
  14456. */
  14457. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14458. /**
  14459. * Remove a specific size gradient
  14460. * @param gradient defines the gradient to remove
  14461. * @returns the current particle system
  14462. */
  14463. removeSizeGradient(gradient: number): IParticleSystem;
  14464. /**
  14465. * Gets the current list of color gradients.
  14466. * You must use addColorGradient and removeColorGradient to udpate this list
  14467. * @returns the list of color gradients
  14468. */
  14469. getColorGradients(): Nullable<Array<ColorGradient>>;
  14470. /**
  14471. * Gets the current list of size gradients.
  14472. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14473. * @returns the list of size gradients
  14474. */
  14475. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14476. /**
  14477. * Gets the current list of angular speed gradients.
  14478. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14479. * @returns the list of angular speed gradients
  14480. */
  14481. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14482. /**
  14483. * Adds a new angular speed gradient
  14484. * @param gradient defines the gradient to use (between 0 and 1)
  14485. * @param factor defines the angular speed to affect to the specified gradient
  14486. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14487. * @returns the current particle system
  14488. */
  14489. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14490. /**
  14491. * Remove a specific angular speed gradient
  14492. * @param gradient defines the gradient to remove
  14493. * @returns the current particle system
  14494. */
  14495. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14496. /**
  14497. * Gets the current list of velocity gradients.
  14498. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14499. * @returns the list of velocity gradients
  14500. */
  14501. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14502. /**
  14503. * Adds a new velocity gradient
  14504. * @param gradient defines the gradient to use (between 0 and 1)
  14505. * @param factor defines the velocity to affect to the specified gradient
  14506. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14507. * @returns the current particle system
  14508. */
  14509. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14510. /**
  14511. * Remove a specific velocity gradient
  14512. * @param gradient defines the gradient to remove
  14513. * @returns the current particle system
  14514. */
  14515. removeVelocityGradient(gradient: number): IParticleSystem;
  14516. /**
  14517. * Gets the current list of limit velocity gradients.
  14518. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14519. * @returns the list of limit velocity gradients
  14520. */
  14521. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14522. /**
  14523. * Adds a new limit velocity gradient
  14524. * @param gradient defines the gradient to use (between 0 and 1)
  14525. * @param factor defines the limit velocity to affect to the specified gradient
  14526. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14527. * @returns the current particle system
  14528. */
  14529. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14530. /**
  14531. * Remove a specific limit velocity gradient
  14532. * @param gradient defines the gradient to remove
  14533. * @returns the current particle system
  14534. */
  14535. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14536. /**
  14537. * Adds a new drag gradient
  14538. * @param gradient defines the gradient to use (between 0 and 1)
  14539. * @param factor defines the drag to affect to the specified gradient
  14540. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14541. * @returns the current particle system
  14542. */
  14543. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14544. /**
  14545. * Remove a specific drag gradient
  14546. * @param gradient defines the gradient to remove
  14547. * @returns the current particle system
  14548. */
  14549. removeDragGradient(gradient: number): IParticleSystem;
  14550. /**
  14551. * Gets the current list of drag gradients.
  14552. * You must use addDragGradient and removeDragGradient to udpate this list
  14553. * @returns the list of drag gradients
  14554. */
  14555. getDragGradients(): Nullable<Array<FactorGradient>>;
  14556. /**
  14557. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14558. * @param gradient defines the gradient to use (between 0 and 1)
  14559. * @param factor defines the emit rate to affect to the specified gradient
  14560. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14561. * @returns the current particle system
  14562. */
  14563. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14564. /**
  14565. * Remove a specific emit rate gradient
  14566. * @param gradient defines the gradient to remove
  14567. * @returns the current particle system
  14568. */
  14569. removeEmitRateGradient(gradient: number): IParticleSystem;
  14570. /**
  14571. * Gets the current list of emit rate gradients.
  14572. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14573. * @returns the list of emit rate gradients
  14574. */
  14575. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14576. /**
  14577. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14578. * @param gradient defines the gradient to use (between 0 and 1)
  14579. * @param factor defines the start size to affect to the specified gradient
  14580. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14581. * @returns the current particle system
  14582. */
  14583. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14584. /**
  14585. * Remove a specific start size gradient
  14586. * @param gradient defines the gradient to remove
  14587. * @returns the current particle system
  14588. */
  14589. removeStartSizeGradient(gradient: number): IParticleSystem;
  14590. /**
  14591. * Gets the current list of start size gradients.
  14592. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14593. * @returns the list of start size gradients
  14594. */
  14595. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14596. /**
  14597. * Adds a new life time gradient
  14598. * @param gradient defines the gradient to use (between 0 and 1)
  14599. * @param factor defines the life time factor to affect to the specified gradient
  14600. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14601. * @returns the current particle system
  14602. */
  14603. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14604. /**
  14605. * Remove a specific life time gradient
  14606. * @param gradient defines the gradient to remove
  14607. * @returns the current particle system
  14608. */
  14609. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14610. /**
  14611. * Gets the current list of life time gradients.
  14612. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14613. * @returns the list of life time gradients
  14614. */
  14615. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14616. /**
  14617. * Gets the current list of color gradients.
  14618. * You must use addColorGradient and removeColorGradient to udpate this list
  14619. * @returns the list of color gradients
  14620. */
  14621. getColorGradients(): Nullable<Array<ColorGradient>>;
  14622. /**
  14623. * Adds a new ramp gradient used to remap particle colors
  14624. * @param gradient defines the gradient to use (between 0 and 1)
  14625. * @param color defines the color to affect to the specified gradient
  14626. * @returns the current particle system
  14627. */
  14628. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14629. /**
  14630. * Gets the current list of ramp gradients.
  14631. * You must use addRampGradient and removeRampGradient to udpate this list
  14632. * @returns the list of ramp gradients
  14633. */
  14634. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14635. /** Gets or sets a boolean indicating that ramp gradients must be used
  14636. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14637. */
  14638. useRampGradients: boolean;
  14639. /**
  14640. * Adds a new color remap gradient
  14641. * @param gradient defines the gradient to use (between 0 and 1)
  14642. * @param min defines the color remap minimal range
  14643. * @param max defines the color remap maximal range
  14644. * @returns the current particle system
  14645. */
  14646. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14647. /**
  14648. * Gets the current list of color remap gradients.
  14649. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14650. * @returns the list of color remap gradients
  14651. */
  14652. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14653. /**
  14654. * Adds a new alpha remap gradient
  14655. * @param gradient defines the gradient to use (between 0 and 1)
  14656. * @param min defines the alpha remap minimal range
  14657. * @param max defines the alpha remap maximal range
  14658. * @returns the current particle system
  14659. */
  14660. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14661. /**
  14662. * Gets the current list of alpha remap gradients.
  14663. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14664. * @returns the list of alpha remap gradients
  14665. */
  14666. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14667. /**
  14668. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14669. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14670. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14671. * @returns the emitter
  14672. */
  14673. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14674. /**
  14675. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14676. * @param radius The radius of the hemisphere to emit from
  14677. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14678. * @returns the emitter
  14679. */
  14680. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14681. /**
  14682. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14683. * @param radius The radius of the sphere to emit from
  14684. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14685. * @returns the emitter
  14686. */
  14687. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14688. /**
  14689. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14690. * @param radius The radius of the sphere to emit from
  14691. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14692. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14693. * @returns the emitter
  14694. */
  14695. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14696. /**
  14697. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14698. * @param radius The radius of the emission cylinder
  14699. * @param height The height of the emission cylinder
  14700. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14701. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14702. * @returns the emitter
  14703. */
  14704. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14705. /**
  14706. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14707. * @param radius The radius of the cylinder to emit from
  14708. * @param height The height of the emission cylinder
  14709. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14710. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14711. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14712. * @returns the emitter
  14713. */
  14714. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14715. /**
  14716. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14717. * @param radius The radius of the cone to emit from
  14718. * @param angle The base angle of the cone
  14719. * @returns the emitter
  14720. */
  14721. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14722. /**
  14723. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14724. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14725. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14726. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14727. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14728. * @returns the emitter
  14729. */
  14730. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14731. /**
  14732. * Get hosting scene
  14733. * @returns the scene
  14734. */
  14735. getScene(): Nullable<Scene>;
  14736. }
  14737. }
  14738. declare module BABYLON {
  14739. /**
  14740. * 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.
  14741. * @see https://doc.babylonjs.com/how_to/transformnode
  14742. */
  14743. export class TransformNode extends Node {
  14744. /**
  14745. * Object will not rotate to face the camera
  14746. */
  14747. static BILLBOARDMODE_NONE: number;
  14748. /**
  14749. * Object will rotate to face the camera but only on the x axis
  14750. */
  14751. static BILLBOARDMODE_X: number;
  14752. /**
  14753. * Object will rotate to face the camera but only on the y axis
  14754. */
  14755. static BILLBOARDMODE_Y: number;
  14756. /**
  14757. * Object will rotate to face the camera but only on the z axis
  14758. */
  14759. static BILLBOARDMODE_Z: number;
  14760. /**
  14761. * Object will rotate to face the camera
  14762. */
  14763. static BILLBOARDMODE_ALL: number;
  14764. /**
  14765. * Object will rotate to face the camera's position instead of orientation
  14766. */
  14767. static BILLBOARDMODE_USE_POSITION: number;
  14768. private static _TmpRotation;
  14769. private static _TmpScaling;
  14770. private static _TmpTranslation;
  14771. private _forward;
  14772. private _forwardInverted;
  14773. private _up;
  14774. private _right;
  14775. private _rightInverted;
  14776. private _position;
  14777. private _rotation;
  14778. private _rotationQuaternion;
  14779. protected _scaling: Vector3;
  14780. protected _isDirty: boolean;
  14781. private _transformToBoneReferal;
  14782. private _isAbsoluteSynced;
  14783. private _billboardMode;
  14784. /**
  14785. * Gets or sets the billboard mode. Default is 0.
  14786. *
  14787. * | Value | Type | Description |
  14788. * | --- | --- | --- |
  14789. * | 0 | BILLBOARDMODE_NONE | |
  14790. * | 1 | BILLBOARDMODE_X | |
  14791. * | 2 | BILLBOARDMODE_Y | |
  14792. * | 4 | BILLBOARDMODE_Z | |
  14793. * | 7 | BILLBOARDMODE_ALL | |
  14794. *
  14795. */
  14796. get billboardMode(): number;
  14797. set billboardMode(value: number);
  14798. private _preserveParentRotationForBillboard;
  14799. /**
  14800. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14801. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14802. */
  14803. get preserveParentRotationForBillboard(): boolean;
  14804. set preserveParentRotationForBillboard(value: boolean);
  14805. /**
  14806. * 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
  14807. */
  14808. scalingDeterminant: number;
  14809. private _infiniteDistance;
  14810. /**
  14811. * Gets or sets the distance of the object to max, often used by skybox
  14812. */
  14813. get infiniteDistance(): boolean;
  14814. set infiniteDistance(value: boolean);
  14815. /**
  14816. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14817. * By default the system will update normals to compensate
  14818. */
  14819. ignoreNonUniformScaling: boolean;
  14820. /**
  14821. * 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
  14822. */
  14823. reIntegrateRotationIntoRotationQuaternion: boolean;
  14824. /** @hidden */
  14825. _poseMatrix: Nullable<Matrix>;
  14826. /** @hidden */
  14827. _localMatrix: Matrix;
  14828. private _usePivotMatrix;
  14829. private _absolutePosition;
  14830. private _absoluteScaling;
  14831. private _absoluteRotationQuaternion;
  14832. private _pivotMatrix;
  14833. private _pivotMatrixInverse;
  14834. /** @hidden */
  14835. _postMultiplyPivotMatrix: boolean;
  14836. protected _isWorldMatrixFrozen: boolean;
  14837. /** @hidden */
  14838. _indexInSceneTransformNodesArray: number;
  14839. /**
  14840. * An event triggered after the world matrix is updated
  14841. */
  14842. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14843. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14844. /**
  14845. * Gets a string identifying the name of the class
  14846. * @returns "TransformNode" string
  14847. */
  14848. getClassName(): string;
  14849. /**
  14850. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14851. */
  14852. get position(): Vector3;
  14853. set position(newPosition: Vector3);
  14854. /**
  14855. * 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)).
  14856. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14857. */
  14858. get rotation(): Vector3;
  14859. set rotation(newRotation: Vector3);
  14860. /**
  14861. * 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)).
  14862. */
  14863. get scaling(): Vector3;
  14864. set scaling(newScaling: Vector3);
  14865. /**
  14866. * 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).
  14867. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14868. */
  14869. get rotationQuaternion(): Nullable<Quaternion>;
  14870. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14871. /**
  14872. * The forward direction of that transform in world space.
  14873. */
  14874. get forward(): Vector3;
  14875. /**
  14876. * The up direction of that transform in world space.
  14877. */
  14878. get up(): Vector3;
  14879. /**
  14880. * The right direction of that transform in world space.
  14881. */
  14882. get right(): Vector3;
  14883. /**
  14884. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14885. * @param matrix the matrix to copy the pose from
  14886. * @returns this TransformNode.
  14887. */
  14888. updatePoseMatrix(matrix: Matrix): TransformNode;
  14889. /**
  14890. * Returns the mesh Pose matrix.
  14891. * @returns the pose matrix
  14892. */
  14893. getPoseMatrix(): Matrix;
  14894. /** @hidden */
  14895. _isSynchronized(): boolean;
  14896. /** @hidden */
  14897. _initCache(): void;
  14898. /**
  14899. * Flag the transform node as dirty (Forcing it to update everything)
  14900. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14901. * @returns this transform node
  14902. */
  14903. markAsDirty(property: string): TransformNode;
  14904. /**
  14905. * Returns the current mesh absolute position.
  14906. * Returns a Vector3.
  14907. */
  14908. get absolutePosition(): Vector3;
  14909. /**
  14910. * Returns the current mesh absolute scaling.
  14911. * Returns a Vector3.
  14912. */
  14913. get absoluteScaling(): Vector3;
  14914. /**
  14915. * Returns the current mesh absolute rotation.
  14916. * Returns a Quaternion.
  14917. */
  14918. get absoluteRotationQuaternion(): Quaternion;
  14919. /**
  14920. * Sets a new matrix to apply before all other transformation
  14921. * @param matrix defines the transform matrix
  14922. * @returns the current TransformNode
  14923. */
  14924. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14925. /**
  14926. * Sets a new pivot matrix to the current node
  14927. * @param matrix defines the new pivot matrix to use
  14928. * @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
  14929. * @returns the current TransformNode
  14930. */
  14931. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14932. /**
  14933. * Returns the mesh pivot matrix.
  14934. * Default : Identity.
  14935. * @returns the matrix
  14936. */
  14937. getPivotMatrix(): Matrix;
  14938. /**
  14939. * Instantiate (when possible) or clone that node with its hierarchy
  14940. * @param newParent defines the new parent to use for the instance (or clone)
  14941. * @param options defines options to configure how copy is done
  14942. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14943. * @returns an instance (or a clone) of the current node with its hiearchy
  14944. */
  14945. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14946. doNotInstantiate: boolean;
  14947. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14948. /**
  14949. * Prevents the World matrix to be computed any longer
  14950. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14951. * @returns the TransformNode.
  14952. */
  14953. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14954. /**
  14955. * Allows back the World matrix computation.
  14956. * @returns the TransformNode.
  14957. */
  14958. unfreezeWorldMatrix(): this;
  14959. /**
  14960. * True if the World matrix has been frozen.
  14961. */
  14962. get isWorldMatrixFrozen(): boolean;
  14963. /**
  14964. * Retuns the mesh absolute position in the World.
  14965. * @returns a Vector3.
  14966. */
  14967. getAbsolutePosition(): Vector3;
  14968. /**
  14969. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14970. * @param absolutePosition the absolute position to set
  14971. * @returns the TransformNode.
  14972. */
  14973. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14974. /**
  14975. * Sets the mesh position in its local space.
  14976. * @param vector3 the position to set in localspace
  14977. * @returns the TransformNode.
  14978. */
  14979. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14980. /**
  14981. * Returns the mesh position in the local space from the current World matrix values.
  14982. * @returns a new Vector3.
  14983. */
  14984. getPositionExpressedInLocalSpace(): Vector3;
  14985. /**
  14986. * Translates the mesh along the passed Vector3 in its local space.
  14987. * @param vector3 the distance to translate in localspace
  14988. * @returns the TransformNode.
  14989. */
  14990. locallyTranslate(vector3: Vector3): TransformNode;
  14991. private static _lookAtVectorCache;
  14992. /**
  14993. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14994. * @param targetPoint the position (must be in same space as current mesh) to look at
  14995. * @param yawCor optional yaw (y-axis) correction in radians
  14996. * @param pitchCor optional pitch (x-axis) correction in radians
  14997. * @param rollCor optional roll (z-axis) correction in radians
  14998. * @param space the choosen space of the target
  14999. * @returns the TransformNode.
  15000. */
  15001. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15002. /**
  15003. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15004. * This Vector3 is expressed in the World space.
  15005. * @param localAxis axis to rotate
  15006. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15007. */
  15008. getDirection(localAxis: Vector3): Vector3;
  15009. /**
  15010. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15011. * localAxis is expressed in the mesh local space.
  15012. * result is computed in the Wordl space from the mesh World matrix.
  15013. * @param localAxis axis to rotate
  15014. * @param result the resulting transformnode
  15015. * @returns this TransformNode.
  15016. */
  15017. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15018. /**
  15019. * Sets this transform node rotation to the given local axis.
  15020. * @param localAxis the axis in local space
  15021. * @param yawCor optional yaw (y-axis) correction in radians
  15022. * @param pitchCor optional pitch (x-axis) correction in radians
  15023. * @param rollCor optional roll (z-axis) correction in radians
  15024. * @returns this TransformNode
  15025. */
  15026. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15027. /**
  15028. * Sets a new pivot point to the current node
  15029. * @param point defines the new pivot point to use
  15030. * @param space defines if the point is in world or local space (local by default)
  15031. * @returns the current TransformNode
  15032. */
  15033. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15034. /**
  15035. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15036. * @returns the pivot point
  15037. */
  15038. getPivotPoint(): Vector3;
  15039. /**
  15040. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15041. * @param result the vector3 to store the result
  15042. * @returns this TransformNode.
  15043. */
  15044. getPivotPointToRef(result: Vector3): TransformNode;
  15045. /**
  15046. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15047. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15048. */
  15049. getAbsolutePivotPoint(): Vector3;
  15050. /**
  15051. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15052. * @param result vector3 to store the result
  15053. * @returns this TransformNode.
  15054. */
  15055. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15056. /**
  15057. * Defines the passed node as the parent of the current node.
  15058. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15059. * @see https://doc.babylonjs.com/how_to/parenting
  15060. * @param node the node ot set as the parent
  15061. * @returns this TransformNode.
  15062. */
  15063. setParent(node: Nullable<Node>): TransformNode;
  15064. private _nonUniformScaling;
  15065. /**
  15066. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15067. */
  15068. get nonUniformScaling(): boolean;
  15069. /** @hidden */
  15070. _updateNonUniformScalingState(value: boolean): boolean;
  15071. /**
  15072. * Attach the current TransformNode to another TransformNode associated with a bone
  15073. * @param bone Bone affecting the TransformNode
  15074. * @param affectedTransformNode TransformNode associated with the bone
  15075. * @returns this object
  15076. */
  15077. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15078. /**
  15079. * Detach the transform node if its associated with a bone
  15080. * @returns this object
  15081. */
  15082. detachFromBone(): TransformNode;
  15083. private static _rotationAxisCache;
  15084. /**
  15085. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15086. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15087. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15088. * The passed axis is also normalized.
  15089. * @param axis the axis to rotate around
  15090. * @param amount the amount to rotate in radians
  15091. * @param space Space to rotate in (Default: local)
  15092. * @returns the TransformNode.
  15093. */
  15094. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15095. /**
  15096. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15097. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15098. * The passed axis is also normalized. .
  15099. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15100. * @param point the point to rotate around
  15101. * @param axis the axis to rotate around
  15102. * @param amount the amount to rotate in radians
  15103. * @returns the TransformNode
  15104. */
  15105. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15106. /**
  15107. * Translates the mesh along the axis vector for the passed distance in the given space.
  15108. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15109. * @param axis the axis to translate in
  15110. * @param distance the distance to translate
  15111. * @param space Space to rotate in (Default: local)
  15112. * @returns the TransformNode.
  15113. */
  15114. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15115. /**
  15116. * Adds a rotation step to the mesh current rotation.
  15117. * x, y, z are Euler angles expressed in radians.
  15118. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15119. * This means this rotation is made in the mesh local space only.
  15120. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15121. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15122. * ```javascript
  15123. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15124. * ```
  15125. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15126. * 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.
  15127. * @param x Rotation to add
  15128. * @param y Rotation to add
  15129. * @param z Rotation to add
  15130. * @returns the TransformNode.
  15131. */
  15132. addRotation(x: number, y: number, z: number): TransformNode;
  15133. /**
  15134. * @hidden
  15135. */
  15136. protected _getEffectiveParent(): Nullable<Node>;
  15137. /**
  15138. * Computes the world matrix of the node
  15139. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15140. * @returns the world matrix
  15141. */
  15142. computeWorldMatrix(force?: boolean): Matrix;
  15143. /**
  15144. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15145. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15146. */
  15147. resetLocalMatrix(independentOfChildren?: boolean): void;
  15148. protected _afterComputeWorldMatrix(): void;
  15149. /**
  15150. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15151. * @param func callback function to add
  15152. *
  15153. * @returns the TransformNode.
  15154. */
  15155. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15156. /**
  15157. * Removes a registered callback function.
  15158. * @param func callback function to remove
  15159. * @returns the TransformNode.
  15160. */
  15161. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15162. /**
  15163. * Gets the position of the current mesh in camera space
  15164. * @param camera defines the camera to use
  15165. * @returns a position
  15166. */
  15167. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15168. /**
  15169. * Returns the distance from the mesh to the active camera
  15170. * @param camera defines the camera to use
  15171. * @returns the distance
  15172. */
  15173. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15174. /**
  15175. * Clone the current transform node
  15176. * @param name Name of the new clone
  15177. * @param newParent New parent for the clone
  15178. * @param doNotCloneChildren Do not clone children hierarchy
  15179. * @returns the new transform node
  15180. */
  15181. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15182. /**
  15183. * Serializes the objects information.
  15184. * @param currentSerializationObject defines the object to serialize in
  15185. * @returns the serialized object
  15186. */
  15187. serialize(currentSerializationObject?: any): any;
  15188. /**
  15189. * Returns a new TransformNode object parsed from the source provided.
  15190. * @param parsedTransformNode is the source.
  15191. * @param scene the scne the object belongs to
  15192. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15193. * @returns a new TransformNode object parsed from the source provided.
  15194. */
  15195. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15196. /**
  15197. * Get all child-transformNodes of this node
  15198. * @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
  15199. * @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
  15200. * @returns an array of TransformNode
  15201. */
  15202. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15203. /**
  15204. * Releases resources associated with this transform node.
  15205. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15206. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15207. */
  15208. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15209. /**
  15210. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15211. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15212. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15213. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15214. * @returns the current mesh
  15215. */
  15216. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15217. private _syncAbsoluteScalingAndRotation;
  15218. }
  15219. }
  15220. declare module BABYLON {
  15221. /**
  15222. * Class used to override all child animations of a given target
  15223. */
  15224. export class AnimationPropertiesOverride {
  15225. /**
  15226. * Gets or sets a value indicating if animation blending must be used
  15227. */
  15228. enableBlending: boolean;
  15229. /**
  15230. * Gets or sets the blending speed to use when enableBlending is true
  15231. */
  15232. blendingSpeed: number;
  15233. /**
  15234. * Gets or sets the default loop mode to use
  15235. */
  15236. loopMode: number;
  15237. }
  15238. }
  15239. declare module BABYLON {
  15240. /**
  15241. * Class used to store bone information
  15242. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15243. */
  15244. export class Bone extends Node {
  15245. /**
  15246. * defines the bone name
  15247. */
  15248. name: string;
  15249. private static _tmpVecs;
  15250. private static _tmpQuat;
  15251. private static _tmpMats;
  15252. /**
  15253. * Gets the list of child bones
  15254. */
  15255. children: Bone[];
  15256. /** Gets the animations associated with this bone */
  15257. animations: Animation[];
  15258. /**
  15259. * Gets or sets bone length
  15260. */
  15261. length: number;
  15262. /**
  15263. * @hidden Internal only
  15264. * Set this value to map this bone to a different index in the transform matrices
  15265. * Set this value to -1 to exclude the bone from the transform matrices
  15266. */
  15267. _index: Nullable<number>;
  15268. private _skeleton;
  15269. private _localMatrix;
  15270. private _restPose;
  15271. private _bindPose;
  15272. private _baseMatrix;
  15273. private _absoluteTransform;
  15274. private _invertedAbsoluteTransform;
  15275. private _parent;
  15276. private _scalingDeterminant;
  15277. private _worldTransform;
  15278. private _localScaling;
  15279. private _localRotation;
  15280. private _localPosition;
  15281. private _needToDecompose;
  15282. private _needToCompose;
  15283. /** @hidden */
  15284. _linkedTransformNode: Nullable<TransformNode>;
  15285. /** @hidden */
  15286. _waitingTransformNodeId: Nullable<string>;
  15287. /** @hidden */
  15288. get _matrix(): Matrix;
  15289. /** @hidden */
  15290. set _matrix(value: Matrix);
  15291. /**
  15292. * Create a new bone
  15293. * @param name defines the bone name
  15294. * @param skeleton defines the parent skeleton
  15295. * @param parentBone defines the parent (can be null if the bone is the root)
  15296. * @param localMatrix defines the local matrix
  15297. * @param restPose defines the rest pose matrix
  15298. * @param baseMatrix defines the base matrix
  15299. * @param index defines index of the bone in the hiearchy
  15300. */
  15301. constructor(
  15302. /**
  15303. * defines the bone name
  15304. */
  15305. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15306. /**
  15307. * Gets the current object class name.
  15308. * @return the class name
  15309. */
  15310. getClassName(): string;
  15311. /**
  15312. * Gets the parent skeleton
  15313. * @returns a skeleton
  15314. */
  15315. getSkeleton(): Skeleton;
  15316. /**
  15317. * Gets parent bone
  15318. * @returns a bone or null if the bone is the root of the bone hierarchy
  15319. */
  15320. getParent(): Nullable<Bone>;
  15321. /**
  15322. * Returns an array containing the root bones
  15323. * @returns an array containing the root bones
  15324. */
  15325. getChildren(): Array<Bone>;
  15326. /**
  15327. * Gets the node index in matrix array generated for rendering
  15328. * @returns the node index
  15329. */
  15330. getIndex(): number;
  15331. /**
  15332. * Sets the parent bone
  15333. * @param parent defines the parent (can be null if the bone is the root)
  15334. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15335. */
  15336. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15337. /**
  15338. * Gets the local matrix
  15339. * @returns a matrix
  15340. */
  15341. getLocalMatrix(): Matrix;
  15342. /**
  15343. * Gets the base matrix (initial matrix which remains unchanged)
  15344. * @returns a matrix
  15345. */
  15346. getBaseMatrix(): Matrix;
  15347. /**
  15348. * Gets the rest pose matrix
  15349. * @returns a matrix
  15350. */
  15351. getRestPose(): Matrix;
  15352. /**
  15353. * Sets the rest pose matrix
  15354. * @param matrix the local-space rest pose to set for this bone
  15355. */
  15356. setRestPose(matrix: Matrix): void;
  15357. /**
  15358. * Gets the bind pose matrix
  15359. * @returns the bind pose matrix
  15360. */
  15361. getBindPose(): Matrix;
  15362. /**
  15363. * Sets the bind pose matrix
  15364. * @param matrix the local-space bind pose to set for this bone
  15365. */
  15366. setBindPose(matrix: Matrix): void;
  15367. /**
  15368. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15369. */
  15370. getWorldMatrix(): Matrix;
  15371. /**
  15372. * Sets the local matrix to rest pose matrix
  15373. */
  15374. returnToRest(): void;
  15375. /**
  15376. * Gets the inverse of the absolute transform matrix.
  15377. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15378. * @returns a matrix
  15379. */
  15380. getInvertedAbsoluteTransform(): Matrix;
  15381. /**
  15382. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15383. * @returns a matrix
  15384. */
  15385. getAbsoluteTransform(): Matrix;
  15386. /**
  15387. * Links with the given transform node.
  15388. * The local matrix of this bone is copied from the transform node every frame.
  15389. * @param transformNode defines the transform node to link to
  15390. */
  15391. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15392. /**
  15393. * Gets the node used to drive the bone's transformation
  15394. * @returns a transform node or null
  15395. */
  15396. getTransformNode(): Nullable<TransformNode>;
  15397. /** Gets or sets current position (in local space) */
  15398. get position(): Vector3;
  15399. set position(newPosition: Vector3);
  15400. /** Gets or sets current rotation (in local space) */
  15401. get rotation(): Vector3;
  15402. set rotation(newRotation: Vector3);
  15403. /** Gets or sets current rotation quaternion (in local space) */
  15404. get rotationQuaternion(): Quaternion;
  15405. set rotationQuaternion(newRotation: Quaternion);
  15406. /** Gets or sets current scaling (in local space) */
  15407. get scaling(): Vector3;
  15408. set scaling(newScaling: Vector3);
  15409. /**
  15410. * Gets the animation properties override
  15411. */
  15412. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15413. private _decompose;
  15414. private _compose;
  15415. /**
  15416. * Update the base and local matrices
  15417. * @param matrix defines the new base or local matrix
  15418. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15419. * @param updateLocalMatrix defines if the local matrix should be updated
  15420. */
  15421. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15422. /** @hidden */
  15423. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15424. /**
  15425. * Flag the bone as dirty (Forcing it to update everything)
  15426. */
  15427. markAsDirty(): void;
  15428. /** @hidden */
  15429. _markAsDirtyAndCompose(): void;
  15430. private _markAsDirtyAndDecompose;
  15431. /**
  15432. * Translate the bone in local or world space
  15433. * @param vec The amount to translate the bone
  15434. * @param space The space that the translation is in
  15435. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15436. */
  15437. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15438. /**
  15439. * Set the postion of the bone in local or world space
  15440. * @param position The position to set the bone
  15441. * @param space The space that the position is in
  15442. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15443. */
  15444. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15445. /**
  15446. * Set the absolute position of the bone (world space)
  15447. * @param position The position to set the bone
  15448. * @param mesh The mesh that this bone is attached to
  15449. */
  15450. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15451. /**
  15452. * Scale the bone on the x, y and z axes (in local space)
  15453. * @param x The amount to scale the bone on the x axis
  15454. * @param y The amount to scale the bone on the y axis
  15455. * @param z The amount to scale the bone on the z axis
  15456. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15457. */
  15458. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15459. /**
  15460. * Set the bone scaling in local space
  15461. * @param scale defines the scaling vector
  15462. */
  15463. setScale(scale: Vector3): void;
  15464. /**
  15465. * Gets the current scaling in local space
  15466. * @returns the current scaling vector
  15467. */
  15468. getScale(): Vector3;
  15469. /**
  15470. * Gets the current scaling in local space and stores it in a target vector
  15471. * @param result defines the target vector
  15472. */
  15473. getScaleToRef(result: Vector3): void;
  15474. /**
  15475. * Set the yaw, pitch, and roll of the bone in local or world space
  15476. * @param yaw The rotation of the bone on the y axis
  15477. * @param pitch The rotation of the bone on the x axis
  15478. * @param roll The rotation of the bone on the z axis
  15479. * @param space The space that the axes of rotation are in
  15480. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15481. */
  15482. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15483. /**
  15484. * Add a rotation to the bone on an axis in local or world space
  15485. * @param axis The axis to rotate the bone on
  15486. * @param amount The amount to rotate the bone
  15487. * @param space The space that the axis is in
  15488. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15489. */
  15490. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15491. /**
  15492. * Set the rotation of the bone to a particular axis angle in local or world space
  15493. * @param axis The axis to rotate the bone on
  15494. * @param angle The angle that the bone should be rotated to
  15495. * @param space The space that the axis is in
  15496. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15497. */
  15498. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15499. /**
  15500. * Set the euler rotation of the bone in local or world space
  15501. * @param rotation The euler rotation that the bone should be set to
  15502. * @param space The space that the rotation is in
  15503. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15504. */
  15505. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15506. /**
  15507. * Set the quaternion rotation of the bone in local or world space
  15508. * @param quat The quaternion rotation that the bone should be set to
  15509. * @param space The space that the rotation is in
  15510. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15511. */
  15512. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15513. /**
  15514. * Set the rotation matrix of the bone in local or world space
  15515. * @param rotMat The rotation matrix that the bone should be set to
  15516. * @param space The space that the rotation is in
  15517. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15518. */
  15519. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15520. private _rotateWithMatrix;
  15521. private _getNegativeRotationToRef;
  15522. /**
  15523. * Get the position of the bone in local or world space
  15524. * @param space The space that the returned position is in
  15525. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15526. * @returns The position of the bone
  15527. */
  15528. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15529. /**
  15530. * Copy the position of the bone to a vector3 in local or world space
  15531. * @param space The space that the returned position is in
  15532. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15533. * @param result The vector3 to copy the position to
  15534. */
  15535. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15536. /**
  15537. * Get the absolute position of the bone (world space)
  15538. * @param mesh The mesh that this bone is attached to
  15539. * @returns The absolute position of the bone
  15540. */
  15541. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15542. /**
  15543. * Copy the absolute position of the bone (world space) to the result param
  15544. * @param mesh The mesh that this bone is attached to
  15545. * @param result The vector3 to copy the absolute position to
  15546. */
  15547. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15548. /**
  15549. * Compute the absolute transforms of this bone and its children
  15550. */
  15551. computeAbsoluteTransforms(): void;
  15552. /**
  15553. * Get the world direction from an axis that is in the local space of the bone
  15554. * @param localAxis The local direction that is used to compute the world direction
  15555. * @param mesh The mesh that this bone is attached to
  15556. * @returns The world direction
  15557. */
  15558. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15559. /**
  15560. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15561. * @param localAxis The local direction that is used to compute the world direction
  15562. * @param mesh The mesh that this bone is attached to
  15563. * @param result The vector3 that the world direction will be copied to
  15564. */
  15565. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15566. /**
  15567. * Get the euler rotation of the bone in local or world space
  15568. * @param space The space that the rotation should be in
  15569. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15570. * @returns The euler rotation
  15571. */
  15572. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15573. /**
  15574. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15575. * @param space The space that the rotation should be in
  15576. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15577. * @param result The vector3 that the rotation should be copied to
  15578. */
  15579. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15580. /**
  15581. * Get the quaternion rotation of the bone in either local or world space
  15582. * @param space The space that the rotation should be in
  15583. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15584. * @returns The quaternion rotation
  15585. */
  15586. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15587. /**
  15588. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15589. * @param space The space that the rotation should be in
  15590. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15591. * @param result The quaternion that the rotation should be copied to
  15592. */
  15593. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15594. /**
  15595. * Get the rotation matrix of the bone in local or world space
  15596. * @param space The space that the rotation should be in
  15597. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15598. * @returns The rotation matrix
  15599. */
  15600. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15601. /**
  15602. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15603. * @param space The space that the rotation should be in
  15604. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15605. * @param result The quaternion that the rotation should be copied to
  15606. */
  15607. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15608. /**
  15609. * Get the world position of a point that is in the local space of the bone
  15610. * @param position The local position
  15611. * @param mesh The mesh that this bone is attached to
  15612. * @returns The world position
  15613. */
  15614. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15615. /**
  15616. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15617. * @param position The local position
  15618. * @param mesh The mesh that this bone is attached to
  15619. * @param result The vector3 that the world position should be copied to
  15620. */
  15621. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15622. /**
  15623. * Get the local position of a point that is in world space
  15624. * @param position The world position
  15625. * @param mesh The mesh that this bone is attached to
  15626. * @returns The local position
  15627. */
  15628. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15629. /**
  15630. * Get the local position of a point that is in world space and copy it to the result param
  15631. * @param position The world position
  15632. * @param mesh The mesh that this bone is attached to
  15633. * @param result The vector3 that the local position should be copied to
  15634. */
  15635. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15636. /**
  15637. * Set the current local matrix as the restPose for this bone.
  15638. */
  15639. setCurrentPoseAsRest(): void;
  15640. }
  15641. }
  15642. declare module BABYLON {
  15643. /**
  15644. * Defines a runtime animation
  15645. */
  15646. export class RuntimeAnimation {
  15647. private _events;
  15648. /**
  15649. * The current frame of the runtime animation
  15650. */
  15651. private _currentFrame;
  15652. /**
  15653. * The animation used by the runtime animation
  15654. */
  15655. private _animation;
  15656. /**
  15657. * The target of the runtime animation
  15658. */
  15659. private _target;
  15660. /**
  15661. * The initiating animatable
  15662. */
  15663. private _host;
  15664. /**
  15665. * The original value of the runtime animation
  15666. */
  15667. private _originalValue;
  15668. /**
  15669. * The original blend value of the runtime animation
  15670. */
  15671. private _originalBlendValue;
  15672. /**
  15673. * The offsets cache of the runtime animation
  15674. */
  15675. private _offsetsCache;
  15676. /**
  15677. * The high limits cache of the runtime animation
  15678. */
  15679. private _highLimitsCache;
  15680. /**
  15681. * Specifies if the runtime animation has been stopped
  15682. */
  15683. private _stopped;
  15684. /**
  15685. * The blending factor of the runtime animation
  15686. */
  15687. private _blendingFactor;
  15688. /**
  15689. * The BabylonJS scene
  15690. */
  15691. private _scene;
  15692. /**
  15693. * The current value of the runtime animation
  15694. */
  15695. private _currentValue;
  15696. /** @hidden */
  15697. _animationState: _IAnimationState;
  15698. /**
  15699. * The active target of the runtime animation
  15700. */
  15701. private _activeTargets;
  15702. private _currentActiveTarget;
  15703. private _directTarget;
  15704. /**
  15705. * The target path of the runtime animation
  15706. */
  15707. private _targetPath;
  15708. /**
  15709. * The weight of the runtime animation
  15710. */
  15711. private _weight;
  15712. /**
  15713. * The ratio offset of the runtime animation
  15714. */
  15715. private _ratioOffset;
  15716. /**
  15717. * The previous delay of the runtime animation
  15718. */
  15719. private _previousDelay;
  15720. /**
  15721. * The previous ratio of the runtime animation
  15722. */
  15723. private _previousRatio;
  15724. private _enableBlending;
  15725. private _keys;
  15726. private _minFrame;
  15727. private _maxFrame;
  15728. private _minValue;
  15729. private _maxValue;
  15730. private _targetIsArray;
  15731. /**
  15732. * Gets the current frame of the runtime animation
  15733. */
  15734. get currentFrame(): number;
  15735. /**
  15736. * Gets the weight of the runtime animation
  15737. */
  15738. get weight(): number;
  15739. /**
  15740. * Gets the current value of the runtime animation
  15741. */
  15742. get currentValue(): any;
  15743. /**
  15744. * Gets the target path of the runtime animation
  15745. */
  15746. get targetPath(): string;
  15747. /**
  15748. * Gets the actual target of the runtime animation
  15749. */
  15750. get target(): any;
  15751. /**
  15752. * Gets the additive state of the runtime animation
  15753. */
  15754. get isAdditive(): boolean;
  15755. /** @hidden */
  15756. _onLoop: () => void;
  15757. /**
  15758. * Create a new RuntimeAnimation object
  15759. * @param target defines the target of the animation
  15760. * @param animation defines the source animation object
  15761. * @param scene defines the hosting scene
  15762. * @param host defines the initiating Animatable
  15763. */
  15764. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15765. private _preparePath;
  15766. /**
  15767. * Gets the animation from the runtime animation
  15768. */
  15769. get animation(): Animation;
  15770. /**
  15771. * Resets the runtime animation to the beginning
  15772. * @param restoreOriginal defines whether to restore the target property to the original value
  15773. */
  15774. reset(restoreOriginal?: boolean): void;
  15775. /**
  15776. * Specifies if the runtime animation is stopped
  15777. * @returns Boolean specifying if the runtime animation is stopped
  15778. */
  15779. isStopped(): boolean;
  15780. /**
  15781. * Disposes of the runtime animation
  15782. */
  15783. dispose(): void;
  15784. /**
  15785. * Apply the interpolated value to the target
  15786. * @param currentValue defines the value computed by the animation
  15787. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15788. */
  15789. setValue(currentValue: any, weight: number): void;
  15790. private _getOriginalValues;
  15791. private _setValue;
  15792. /**
  15793. * Gets the loop pmode of the runtime animation
  15794. * @returns Loop Mode
  15795. */
  15796. private _getCorrectLoopMode;
  15797. /**
  15798. * Move the current animation to a given frame
  15799. * @param frame defines the frame to move to
  15800. */
  15801. goToFrame(frame: number): void;
  15802. /**
  15803. * @hidden Internal use only
  15804. */
  15805. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15806. /**
  15807. * Execute the current animation
  15808. * @param delay defines the delay to add to the current frame
  15809. * @param from defines the lower bound of the animation range
  15810. * @param to defines the upper bound of the animation range
  15811. * @param loop defines if the current animation must loop
  15812. * @param speedRatio defines the current speed ratio
  15813. * @param weight defines the weight of the animation (default is -1 so no weight)
  15814. * @param onLoop optional callback called when animation loops
  15815. * @returns a boolean indicating if the animation is running
  15816. */
  15817. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15818. }
  15819. }
  15820. declare module BABYLON {
  15821. /**
  15822. * Class used to store an actual running animation
  15823. */
  15824. export class Animatable {
  15825. /** defines the target object */
  15826. target: any;
  15827. /** defines the starting frame number (default is 0) */
  15828. fromFrame: number;
  15829. /** defines the ending frame number (default is 100) */
  15830. toFrame: number;
  15831. /** defines if the animation must loop (default is false) */
  15832. loopAnimation: boolean;
  15833. /** defines a callback to call when animation ends if it is not looping */
  15834. onAnimationEnd?: (() => void) | null | undefined;
  15835. /** defines a callback to call when animation loops */
  15836. onAnimationLoop?: (() => void) | null | undefined;
  15837. /** defines whether the animation should be evaluated additively */
  15838. isAdditive: boolean;
  15839. private _localDelayOffset;
  15840. private _pausedDelay;
  15841. private _runtimeAnimations;
  15842. private _paused;
  15843. private _scene;
  15844. private _speedRatio;
  15845. private _weight;
  15846. private _syncRoot;
  15847. /**
  15848. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15849. * This will only apply for non looping animation (default is true)
  15850. */
  15851. disposeOnEnd: boolean;
  15852. /**
  15853. * Gets a boolean indicating if the animation has started
  15854. */
  15855. animationStarted: boolean;
  15856. /**
  15857. * Observer raised when the animation ends
  15858. */
  15859. onAnimationEndObservable: Observable<Animatable>;
  15860. /**
  15861. * Observer raised when the animation loops
  15862. */
  15863. onAnimationLoopObservable: Observable<Animatable>;
  15864. /**
  15865. * Gets the root Animatable used to synchronize and normalize animations
  15866. */
  15867. get syncRoot(): Nullable<Animatable>;
  15868. /**
  15869. * Gets the current frame of the first RuntimeAnimation
  15870. * Used to synchronize Animatables
  15871. */
  15872. get masterFrame(): number;
  15873. /**
  15874. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15875. */
  15876. get weight(): number;
  15877. set weight(value: number);
  15878. /**
  15879. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15880. */
  15881. get speedRatio(): number;
  15882. set speedRatio(value: number);
  15883. /**
  15884. * Creates a new Animatable
  15885. * @param scene defines the hosting scene
  15886. * @param target defines the target object
  15887. * @param fromFrame defines the starting frame number (default is 0)
  15888. * @param toFrame defines the ending frame number (default is 100)
  15889. * @param loopAnimation defines if the animation must loop (default is false)
  15890. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15891. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15892. * @param animations defines a group of animation to add to the new Animatable
  15893. * @param onAnimationLoop defines a callback to call when animation loops
  15894. * @param isAdditive defines whether the animation should be evaluated additively
  15895. */
  15896. constructor(scene: Scene,
  15897. /** defines the target object */
  15898. target: any,
  15899. /** defines the starting frame number (default is 0) */
  15900. fromFrame?: number,
  15901. /** defines the ending frame number (default is 100) */
  15902. toFrame?: number,
  15903. /** defines if the animation must loop (default is false) */
  15904. loopAnimation?: boolean, speedRatio?: number,
  15905. /** defines a callback to call when animation ends if it is not looping */
  15906. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15907. /** defines a callback to call when animation loops */
  15908. onAnimationLoop?: (() => void) | null | undefined,
  15909. /** defines whether the animation should be evaluated additively */
  15910. isAdditive?: boolean);
  15911. /**
  15912. * Synchronize and normalize current Animatable with a source Animatable
  15913. * This is useful when using animation weights and when animations are not of the same length
  15914. * @param root defines the root Animatable to synchronize with
  15915. * @returns the current Animatable
  15916. */
  15917. syncWith(root: Animatable): Animatable;
  15918. /**
  15919. * Gets the list of runtime animations
  15920. * @returns an array of RuntimeAnimation
  15921. */
  15922. getAnimations(): RuntimeAnimation[];
  15923. /**
  15924. * Adds more animations to the current animatable
  15925. * @param target defines the target of the animations
  15926. * @param animations defines the new animations to add
  15927. */
  15928. appendAnimations(target: any, animations: Animation[]): void;
  15929. /**
  15930. * Gets the source animation for a specific property
  15931. * @param property defines the propertyu to look for
  15932. * @returns null or the source animation for the given property
  15933. */
  15934. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15935. /**
  15936. * Gets the runtime animation for a specific property
  15937. * @param property defines the propertyu to look for
  15938. * @returns null or the runtime animation for the given property
  15939. */
  15940. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15941. /**
  15942. * Resets the animatable to its original state
  15943. */
  15944. reset(): void;
  15945. /**
  15946. * Allows the animatable to blend with current running animations
  15947. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15948. * @param blendingSpeed defines the blending speed to use
  15949. */
  15950. enableBlending(blendingSpeed: number): void;
  15951. /**
  15952. * Disable animation blending
  15953. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15954. */
  15955. disableBlending(): void;
  15956. /**
  15957. * Jump directly to a given frame
  15958. * @param frame defines the frame to jump to
  15959. */
  15960. goToFrame(frame: number): void;
  15961. /**
  15962. * Pause the animation
  15963. */
  15964. pause(): void;
  15965. /**
  15966. * Restart the animation
  15967. */
  15968. restart(): void;
  15969. private _raiseOnAnimationEnd;
  15970. /**
  15971. * Stop and delete the current animation
  15972. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15973. * @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)
  15974. */
  15975. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15976. /**
  15977. * Wait asynchronously for the animation to end
  15978. * @returns a promise which will be fullfilled when the animation ends
  15979. */
  15980. waitAsync(): Promise<Animatable>;
  15981. /** @hidden */
  15982. _animate(delay: number): boolean;
  15983. }
  15984. interface Scene {
  15985. /** @hidden */
  15986. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15987. /** @hidden */
  15988. _processLateAnimationBindingsForMatrices(holder: {
  15989. totalWeight: number;
  15990. totalAdditiveWeight: number;
  15991. animations: RuntimeAnimation[];
  15992. additiveAnimations: RuntimeAnimation[];
  15993. originalValue: Matrix;
  15994. }): any;
  15995. /** @hidden */
  15996. _processLateAnimationBindingsForQuaternions(holder: {
  15997. totalWeight: number;
  15998. totalAdditiveWeight: number;
  15999. animations: RuntimeAnimation[];
  16000. additiveAnimations: RuntimeAnimation[];
  16001. originalValue: Quaternion;
  16002. }, refQuaternion: Quaternion): Quaternion;
  16003. /** @hidden */
  16004. _processLateAnimationBindings(): void;
  16005. /**
  16006. * Will start the animation sequence of a given target
  16007. * @param target defines the target
  16008. * @param from defines from which frame should animation start
  16009. * @param to defines until which frame should animation run.
  16010. * @param weight defines the weight to apply to the animation (1.0 by default)
  16011. * @param loop defines if the animation loops
  16012. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16013. * @param onAnimationEnd defines the function to be executed when the animation ends
  16014. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16015. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16016. * @param onAnimationLoop defines the callback to call when an animation loops
  16017. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16018. * @returns the animatable object created for this animation
  16019. */
  16020. 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;
  16021. /**
  16022. * Will start the animation sequence of a given target
  16023. * @param target defines the target
  16024. * @param from defines from which frame should animation start
  16025. * @param to defines until which frame should animation run.
  16026. * @param loop defines if the animation loops
  16027. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16028. * @param onAnimationEnd defines the function to be executed when the animation ends
  16029. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16030. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16031. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16032. * @param onAnimationLoop defines the callback to call when an animation loops
  16033. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16034. * @returns the animatable object created for this animation
  16035. */
  16036. 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;
  16037. /**
  16038. * Will start the animation sequence of a given target and its hierarchy
  16039. * @param target defines the target
  16040. * @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.
  16041. * @param from defines from which frame should animation start
  16042. * @param to defines until which frame should animation run.
  16043. * @param loop defines if the animation loops
  16044. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16045. * @param onAnimationEnd defines the function to be executed when the animation ends
  16046. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16047. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16048. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16049. * @param onAnimationLoop defines the callback to call when an animation loops
  16050. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16051. * @returns the list of created animatables
  16052. */
  16053. 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[];
  16054. /**
  16055. * Begin a new animation on a given node
  16056. * @param target defines the target where the animation will take place
  16057. * @param animations defines the list of animations to start
  16058. * @param from defines the initial value
  16059. * @param to defines the final value
  16060. * @param loop defines if you want animation to loop (off by default)
  16061. * @param speedRatio defines the speed ratio to apply to all animations
  16062. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16063. * @param onAnimationLoop defines the callback to call when an animation loops
  16064. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16065. * @returns the list of created animatables
  16066. */
  16067. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16068. /**
  16069. * Begin a new animation on a given node and its hierarchy
  16070. * @param target defines the root node where the animation will take place
  16071. * @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.
  16072. * @param animations defines the list of animations to start
  16073. * @param from defines the initial value
  16074. * @param to defines the final value
  16075. * @param loop defines if you want animation to loop (off by default)
  16076. * @param speedRatio defines the speed ratio to apply to all animations
  16077. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16078. * @param onAnimationLoop defines the callback to call when an animation loops
  16079. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16080. * @returns the list of animatables created for all nodes
  16081. */
  16082. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16083. /**
  16084. * Gets the animatable associated with a specific target
  16085. * @param target defines the target of the animatable
  16086. * @returns the required animatable if found
  16087. */
  16088. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16089. /**
  16090. * Gets all animatables associated with a given target
  16091. * @param target defines the target to look animatables for
  16092. * @returns an array of Animatables
  16093. */
  16094. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16095. /**
  16096. * Stops and removes all animations that have been applied to the scene
  16097. */
  16098. stopAllAnimations(): void;
  16099. /**
  16100. * Gets the current delta time used by animation engine
  16101. */
  16102. deltaTime: number;
  16103. }
  16104. interface Bone {
  16105. /**
  16106. * Copy an animation range from another bone
  16107. * @param source defines the source bone
  16108. * @param rangeName defines the range name to copy
  16109. * @param frameOffset defines the frame offset
  16110. * @param rescaleAsRequired defines if rescaling must be applied if required
  16111. * @param skelDimensionsRatio defines the scaling ratio
  16112. * @returns true if operation was successful
  16113. */
  16114. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16115. }
  16116. }
  16117. declare module BABYLON {
  16118. /**
  16119. * Class used to handle skinning animations
  16120. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16121. */
  16122. export class Skeleton implements IAnimatable {
  16123. /** defines the skeleton name */
  16124. name: string;
  16125. /** defines the skeleton Id */
  16126. id: string;
  16127. /**
  16128. * Defines the list of child bones
  16129. */
  16130. bones: Bone[];
  16131. /**
  16132. * Defines an estimate of the dimension of the skeleton at rest
  16133. */
  16134. dimensionsAtRest: Vector3;
  16135. /**
  16136. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16137. */
  16138. needInitialSkinMatrix: boolean;
  16139. /**
  16140. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16141. */
  16142. overrideMesh: Nullable<AbstractMesh>;
  16143. /**
  16144. * Gets the list of animations attached to this skeleton
  16145. */
  16146. animations: Array<Animation>;
  16147. private _scene;
  16148. private _isDirty;
  16149. private _transformMatrices;
  16150. private _transformMatrixTexture;
  16151. private _meshesWithPoseMatrix;
  16152. private _animatables;
  16153. private _identity;
  16154. private _synchronizedWithMesh;
  16155. private _ranges;
  16156. private _lastAbsoluteTransformsUpdateId;
  16157. private _canUseTextureForBones;
  16158. private _uniqueId;
  16159. /** @hidden */
  16160. _numBonesWithLinkedTransformNode: number;
  16161. /** @hidden */
  16162. _hasWaitingData: Nullable<boolean>;
  16163. /** @hidden */
  16164. _waitingOverrideMeshId: Nullable<string>;
  16165. /**
  16166. * Specifies if the skeleton should be serialized
  16167. */
  16168. doNotSerialize: boolean;
  16169. private _useTextureToStoreBoneMatrices;
  16170. /**
  16171. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16172. * Please note that this option is not available if the hardware does not support it
  16173. */
  16174. get useTextureToStoreBoneMatrices(): boolean;
  16175. set useTextureToStoreBoneMatrices(value: boolean);
  16176. private _animationPropertiesOverride;
  16177. /**
  16178. * Gets or sets the animation properties override
  16179. */
  16180. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16181. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16182. /**
  16183. * List of inspectable custom properties (used by the Inspector)
  16184. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16185. */
  16186. inspectableCustomProperties: IInspectable[];
  16187. /**
  16188. * An observable triggered before computing the skeleton's matrices
  16189. */
  16190. onBeforeComputeObservable: Observable<Skeleton>;
  16191. /**
  16192. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16193. */
  16194. get isUsingTextureForMatrices(): boolean;
  16195. /**
  16196. * Gets the unique ID of this skeleton
  16197. */
  16198. get uniqueId(): number;
  16199. /**
  16200. * Creates a new skeleton
  16201. * @param name defines the skeleton name
  16202. * @param id defines the skeleton Id
  16203. * @param scene defines the hosting scene
  16204. */
  16205. constructor(
  16206. /** defines the skeleton name */
  16207. name: string,
  16208. /** defines the skeleton Id */
  16209. id: string, scene: Scene);
  16210. /**
  16211. * Gets the current object class name.
  16212. * @return the class name
  16213. */
  16214. getClassName(): string;
  16215. /**
  16216. * Returns an array containing the root bones
  16217. * @returns an array containing the root bones
  16218. */
  16219. getChildren(): Array<Bone>;
  16220. /**
  16221. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16222. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16223. * @returns a Float32Array containing matrices data
  16224. */
  16225. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16226. /**
  16227. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16228. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16229. * @returns a raw texture containing the data
  16230. */
  16231. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16232. /**
  16233. * Gets the current hosting scene
  16234. * @returns a scene object
  16235. */
  16236. getScene(): Scene;
  16237. /**
  16238. * Gets a string representing the current skeleton data
  16239. * @param fullDetails defines a boolean indicating if we want a verbose version
  16240. * @returns a string representing the current skeleton data
  16241. */
  16242. toString(fullDetails?: boolean): string;
  16243. /**
  16244. * Get bone's index searching by name
  16245. * @param name defines bone's name to search for
  16246. * @return the indice of the bone. Returns -1 if not found
  16247. */
  16248. getBoneIndexByName(name: string): number;
  16249. /**
  16250. * Creater a new animation range
  16251. * @param name defines the name of the range
  16252. * @param from defines the start key
  16253. * @param to defines the end key
  16254. */
  16255. createAnimationRange(name: string, from: number, to: number): void;
  16256. /**
  16257. * Delete a specific animation range
  16258. * @param name defines the name of the range
  16259. * @param deleteFrames defines if frames must be removed as well
  16260. */
  16261. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16262. /**
  16263. * Gets a specific animation range
  16264. * @param name defines the name of the range to look for
  16265. * @returns the requested animation range or null if not found
  16266. */
  16267. getAnimationRange(name: string): Nullable<AnimationRange>;
  16268. /**
  16269. * Gets the list of all animation ranges defined on this skeleton
  16270. * @returns an array
  16271. */
  16272. getAnimationRanges(): Nullable<AnimationRange>[];
  16273. /**
  16274. * Copy animation range from a source skeleton.
  16275. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16276. * @param source defines the source skeleton
  16277. * @param name defines the name of the range to copy
  16278. * @param rescaleAsRequired defines if rescaling must be applied if required
  16279. * @returns true if operation was successful
  16280. */
  16281. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16282. /**
  16283. * Forces the skeleton to go to rest pose
  16284. */
  16285. returnToRest(): void;
  16286. private _getHighestAnimationFrame;
  16287. /**
  16288. * Begin a specific animation range
  16289. * @param name defines the name of the range to start
  16290. * @param loop defines if looping must be turned on (false by default)
  16291. * @param speedRatio defines the speed ratio to apply (1 by default)
  16292. * @param onAnimationEnd defines a callback which will be called when animation will end
  16293. * @returns a new animatable
  16294. */
  16295. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16296. /**
  16297. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16298. * @param skeleton defines the Skeleton containing the animation range to convert
  16299. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16300. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16301. * @returns the original skeleton
  16302. */
  16303. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16304. /** @hidden */
  16305. _markAsDirty(): void;
  16306. /** @hidden */
  16307. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16308. /** @hidden */
  16309. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16310. private _computeTransformMatrices;
  16311. /**
  16312. * Build all resources required to render a skeleton
  16313. */
  16314. prepare(): void;
  16315. /**
  16316. * Gets the list of animatables currently running for this skeleton
  16317. * @returns an array of animatables
  16318. */
  16319. getAnimatables(): IAnimatable[];
  16320. /**
  16321. * Clone the current skeleton
  16322. * @param name defines the name of the new skeleton
  16323. * @param id defines the id of the new skeleton
  16324. * @returns the new skeleton
  16325. */
  16326. clone(name: string, id?: string): Skeleton;
  16327. /**
  16328. * Enable animation blending for this skeleton
  16329. * @param blendingSpeed defines the blending speed to apply
  16330. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16331. */
  16332. enableBlending(blendingSpeed?: number): void;
  16333. /**
  16334. * Releases all resources associated with the current skeleton
  16335. */
  16336. dispose(): void;
  16337. /**
  16338. * Serialize the skeleton in a JSON object
  16339. * @returns a JSON object
  16340. */
  16341. serialize(): any;
  16342. /**
  16343. * Creates a new skeleton from serialized data
  16344. * @param parsedSkeleton defines the serialized data
  16345. * @param scene defines the hosting scene
  16346. * @returns a new skeleton
  16347. */
  16348. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16349. /**
  16350. * Compute all node absolute transforms
  16351. * @param forceUpdate defines if computation must be done even if cache is up to date
  16352. */
  16353. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16354. /**
  16355. * Gets the root pose matrix
  16356. * @returns a matrix
  16357. */
  16358. getPoseMatrix(): Nullable<Matrix>;
  16359. /**
  16360. * Sorts bones per internal index
  16361. */
  16362. sortBones(): void;
  16363. private _sortBones;
  16364. /**
  16365. * Set the current local matrix as the restPose for all bones in the skeleton.
  16366. */
  16367. setCurrentPoseAsRest(): void;
  16368. }
  16369. }
  16370. declare module BABYLON {
  16371. /**
  16372. * Creates an instance based on a source mesh.
  16373. */
  16374. export class InstancedMesh extends AbstractMesh {
  16375. private _sourceMesh;
  16376. private _currentLOD;
  16377. /** @hidden */
  16378. _indexInSourceMeshInstanceArray: number;
  16379. constructor(name: string, source: Mesh);
  16380. /**
  16381. * Returns the string "InstancedMesh".
  16382. */
  16383. getClassName(): string;
  16384. /** Gets the list of lights affecting that mesh */
  16385. get lightSources(): Light[];
  16386. _resyncLightSources(): void;
  16387. _resyncLightSource(light: Light): void;
  16388. _removeLightSource(light: Light, dispose: boolean): void;
  16389. /**
  16390. * If the source mesh receives shadows
  16391. */
  16392. get receiveShadows(): boolean;
  16393. /**
  16394. * The material of the source mesh
  16395. */
  16396. get material(): Nullable<Material>;
  16397. /**
  16398. * Visibility of the source mesh
  16399. */
  16400. get visibility(): number;
  16401. /**
  16402. * Skeleton of the source mesh
  16403. */
  16404. get skeleton(): Nullable<Skeleton>;
  16405. /**
  16406. * Rendering ground id of the source mesh
  16407. */
  16408. get renderingGroupId(): number;
  16409. set renderingGroupId(value: number);
  16410. /**
  16411. * Returns the total number of vertices (integer).
  16412. */
  16413. getTotalVertices(): number;
  16414. /**
  16415. * Returns a positive integer : the total number of indices in this mesh geometry.
  16416. * @returns the numner of indices or zero if the mesh has no geometry.
  16417. */
  16418. getTotalIndices(): number;
  16419. /**
  16420. * The source mesh of the instance
  16421. */
  16422. get sourceMesh(): Mesh;
  16423. /**
  16424. * Creates a new InstancedMesh object from the mesh model.
  16425. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16426. * @param name defines the name of the new instance
  16427. * @returns a new InstancedMesh
  16428. */
  16429. createInstance(name: string): InstancedMesh;
  16430. /**
  16431. * Is this node ready to be used/rendered
  16432. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16433. * @return {boolean} is it ready
  16434. */
  16435. isReady(completeCheck?: boolean): boolean;
  16436. /**
  16437. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16438. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16439. * @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.
  16440. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16441. */
  16442. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16443. /**
  16444. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16445. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16446. * The `data` are either a numeric array either a Float32Array.
  16447. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16448. * 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).
  16449. * Note that a new underlying VertexBuffer object is created each call.
  16450. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16451. *
  16452. * Possible `kind` values :
  16453. * - VertexBuffer.PositionKind
  16454. * - VertexBuffer.UVKind
  16455. * - VertexBuffer.UV2Kind
  16456. * - VertexBuffer.UV3Kind
  16457. * - VertexBuffer.UV4Kind
  16458. * - VertexBuffer.UV5Kind
  16459. * - VertexBuffer.UV6Kind
  16460. * - VertexBuffer.ColorKind
  16461. * - VertexBuffer.MatricesIndicesKind
  16462. * - VertexBuffer.MatricesIndicesExtraKind
  16463. * - VertexBuffer.MatricesWeightsKind
  16464. * - VertexBuffer.MatricesWeightsExtraKind
  16465. *
  16466. * Returns the Mesh.
  16467. */
  16468. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16469. /**
  16470. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16471. * If the mesh has no geometry, it is simply returned as it is.
  16472. * The `data` are either a numeric array either a Float32Array.
  16473. * No new underlying VertexBuffer object is created.
  16474. * 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.
  16475. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16476. *
  16477. * Possible `kind` values :
  16478. * - VertexBuffer.PositionKind
  16479. * - VertexBuffer.UVKind
  16480. * - VertexBuffer.UV2Kind
  16481. * - VertexBuffer.UV3Kind
  16482. * - VertexBuffer.UV4Kind
  16483. * - VertexBuffer.UV5Kind
  16484. * - VertexBuffer.UV6Kind
  16485. * - VertexBuffer.ColorKind
  16486. * - VertexBuffer.MatricesIndicesKind
  16487. * - VertexBuffer.MatricesIndicesExtraKind
  16488. * - VertexBuffer.MatricesWeightsKind
  16489. * - VertexBuffer.MatricesWeightsExtraKind
  16490. *
  16491. * Returns the Mesh.
  16492. */
  16493. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16494. /**
  16495. * Sets the mesh indices.
  16496. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16497. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16498. * This method creates a new index buffer each call.
  16499. * Returns the Mesh.
  16500. */
  16501. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16502. /**
  16503. * Boolean : True if the mesh owns the requested kind of data.
  16504. */
  16505. isVerticesDataPresent(kind: string): boolean;
  16506. /**
  16507. * Returns an array of indices (IndicesArray).
  16508. */
  16509. getIndices(): Nullable<IndicesArray>;
  16510. get _positions(): Nullable<Vector3[]>;
  16511. /**
  16512. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16513. * This means the mesh underlying bounding box and sphere are recomputed.
  16514. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16515. * @returns the current mesh
  16516. */
  16517. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16518. /** @hidden */
  16519. _preActivate(): InstancedMesh;
  16520. /** @hidden */
  16521. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16522. /** @hidden */
  16523. _postActivate(): void;
  16524. getWorldMatrix(): Matrix;
  16525. get isAnInstance(): boolean;
  16526. /**
  16527. * Returns the current associated LOD AbstractMesh.
  16528. */
  16529. getLOD(camera: Camera): AbstractMesh;
  16530. /** @hidden */
  16531. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16532. /** @hidden */
  16533. _syncSubMeshes(): InstancedMesh;
  16534. /** @hidden */
  16535. _generatePointsArray(): boolean;
  16536. /** @hidden */
  16537. _updateBoundingInfo(): AbstractMesh;
  16538. /**
  16539. * Creates a new InstancedMesh from the current mesh.
  16540. * - name (string) : the cloned mesh name
  16541. * - newParent (optional Node) : the optional Node to parent the clone to.
  16542. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16543. *
  16544. * Returns the clone.
  16545. */
  16546. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16547. /**
  16548. * Disposes the InstancedMesh.
  16549. * Returns nothing.
  16550. */
  16551. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16552. }
  16553. interface Mesh {
  16554. /**
  16555. * Register a custom buffer that will be instanced
  16556. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16557. * @param kind defines the buffer kind
  16558. * @param stride defines the stride in floats
  16559. */
  16560. registerInstancedBuffer(kind: string, stride: number): void;
  16561. /**
  16562. * true to use the edge renderer for all instances of this mesh
  16563. */
  16564. edgesShareWithInstances: boolean;
  16565. /** @hidden */
  16566. _userInstancedBuffersStorage: {
  16567. data: {
  16568. [key: string]: Float32Array;
  16569. };
  16570. sizes: {
  16571. [key: string]: number;
  16572. };
  16573. vertexBuffers: {
  16574. [key: string]: Nullable<VertexBuffer>;
  16575. };
  16576. strides: {
  16577. [key: string]: number;
  16578. };
  16579. };
  16580. }
  16581. interface AbstractMesh {
  16582. /**
  16583. * Object used to store instanced buffers defined by user
  16584. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16585. */
  16586. instancedBuffers: {
  16587. [key: string]: any;
  16588. };
  16589. }
  16590. }
  16591. declare module BABYLON {
  16592. /**
  16593. * Defines the options associated with the creation of a shader material.
  16594. */
  16595. export interface IShaderMaterialOptions {
  16596. /**
  16597. * Does the material work in alpha blend mode
  16598. */
  16599. needAlphaBlending: boolean;
  16600. /**
  16601. * Does the material work in alpha test mode
  16602. */
  16603. needAlphaTesting: boolean;
  16604. /**
  16605. * The list of attribute names used in the shader
  16606. */
  16607. attributes: string[];
  16608. /**
  16609. * The list of unifrom names used in the shader
  16610. */
  16611. uniforms: string[];
  16612. /**
  16613. * The list of UBO names used in the shader
  16614. */
  16615. uniformBuffers: string[];
  16616. /**
  16617. * The list of sampler names used in the shader
  16618. */
  16619. samplers: string[];
  16620. /**
  16621. * The list of defines used in the shader
  16622. */
  16623. defines: string[];
  16624. }
  16625. /**
  16626. * 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.
  16627. *
  16628. * This returned material effects how the mesh will look based on the code in the shaders.
  16629. *
  16630. * @see https://doc.babylonjs.com/how_to/shader_material
  16631. */
  16632. export class ShaderMaterial extends Material {
  16633. private _shaderPath;
  16634. private _options;
  16635. private _textures;
  16636. private _textureArrays;
  16637. private _floats;
  16638. private _ints;
  16639. private _floatsArrays;
  16640. private _colors3;
  16641. private _colors3Arrays;
  16642. private _colors4;
  16643. private _colors4Arrays;
  16644. private _vectors2;
  16645. private _vectors3;
  16646. private _vectors4;
  16647. private _matrices;
  16648. private _matrixArrays;
  16649. private _matrices3x3;
  16650. private _matrices2x2;
  16651. private _vectors2Arrays;
  16652. private _vectors3Arrays;
  16653. private _vectors4Arrays;
  16654. private _cachedWorldViewMatrix;
  16655. private _cachedWorldViewProjectionMatrix;
  16656. private _renderId;
  16657. private _multiview;
  16658. private _cachedDefines;
  16659. /** Define the Url to load snippets */
  16660. static SnippetUrl: string;
  16661. /** Snippet ID if the material was created from the snippet server */
  16662. snippetId: string;
  16663. /**
  16664. * Instantiate a new shader material.
  16665. * 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.
  16666. * This returned material effects how the mesh will look based on the code in the shaders.
  16667. * @see https://doc.babylonjs.com/how_to/shader_material
  16668. * @param name Define the name of the material in the scene
  16669. * @param scene Define the scene the material belongs to
  16670. * @param shaderPath Defines the route to the shader code in one of three ways:
  16671. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16672. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16673. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16674. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16675. * @param options Define the options used to create the shader
  16676. */
  16677. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16678. /**
  16679. * Gets the shader path used to define the shader code
  16680. * It can be modified to trigger a new compilation
  16681. */
  16682. get shaderPath(): any;
  16683. /**
  16684. * Sets the shader path used to define the shader code
  16685. * It can be modified to trigger a new compilation
  16686. */
  16687. set shaderPath(shaderPath: any);
  16688. /**
  16689. * Gets the options used to compile the shader.
  16690. * They can be modified to trigger a new compilation
  16691. */
  16692. get options(): IShaderMaterialOptions;
  16693. /**
  16694. * Gets the current class name of the material e.g. "ShaderMaterial"
  16695. * Mainly use in serialization.
  16696. * @returns the class name
  16697. */
  16698. getClassName(): string;
  16699. /**
  16700. * Specifies if the material will require alpha blending
  16701. * @returns a boolean specifying if alpha blending is needed
  16702. */
  16703. needAlphaBlending(): boolean;
  16704. /**
  16705. * Specifies if this material should be rendered in alpha test mode
  16706. * @returns a boolean specifying if an alpha test is needed.
  16707. */
  16708. needAlphaTesting(): boolean;
  16709. private _checkUniform;
  16710. /**
  16711. * Set a texture in the shader.
  16712. * @param name Define the name of the uniform samplers as defined in the shader
  16713. * @param texture Define the texture to bind to this sampler
  16714. * @return the material itself allowing "fluent" like uniform updates
  16715. */
  16716. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16717. /**
  16718. * Set a texture array in the shader.
  16719. * @param name Define the name of the uniform sampler array as defined in the shader
  16720. * @param textures Define the list of textures to bind to this sampler
  16721. * @return the material itself allowing "fluent" like uniform updates
  16722. */
  16723. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16724. /**
  16725. * Set a float in the shader.
  16726. * @param name Define the name of the uniform as defined in the shader
  16727. * @param value Define the value to give to the uniform
  16728. * @return the material itself allowing "fluent" like uniform updates
  16729. */
  16730. setFloat(name: string, value: number): ShaderMaterial;
  16731. /**
  16732. * Set a int in the shader.
  16733. * @param name Define the name of the uniform as defined in the shader
  16734. * @param value Define the value to give to the uniform
  16735. * @return the material itself allowing "fluent" like uniform updates
  16736. */
  16737. setInt(name: string, value: number): ShaderMaterial;
  16738. /**
  16739. * Set an array of floats in the shader.
  16740. * @param name Define the name of the uniform as defined in the shader
  16741. * @param value Define the value to give to the uniform
  16742. * @return the material itself allowing "fluent" like uniform updates
  16743. */
  16744. setFloats(name: string, value: number[]): ShaderMaterial;
  16745. /**
  16746. * Set a vec3 in the shader from a Color3.
  16747. * @param name Define the name of the uniform as defined in the shader
  16748. * @param value Define the value to give to the uniform
  16749. * @return the material itself allowing "fluent" like uniform updates
  16750. */
  16751. setColor3(name: string, value: Color3): ShaderMaterial;
  16752. /**
  16753. * Set a vec3 array in the shader from a Color3 array.
  16754. * @param name Define the name of the uniform as defined in the shader
  16755. * @param value Define the value to give to the uniform
  16756. * @return the material itself allowing "fluent" like uniform updates
  16757. */
  16758. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16759. /**
  16760. * Set a vec4 in the shader from a Color4.
  16761. * @param name Define the name of the uniform as defined in the shader
  16762. * @param value Define the value to give to the uniform
  16763. * @return the material itself allowing "fluent" like uniform updates
  16764. */
  16765. setColor4(name: string, value: Color4): ShaderMaterial;
  16766. /**
  16767. * Set a vec4 array in the shader from a Color4 array.
  16768. * @param name Define the name of the uniform as defined in the shader
  16769. * @param value Define the value to give to the uniform
  16770. * @return the material itself allowing "fluent" like uniform updates
  16771. */
  16772. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16773. /**
  16774. * Set a vec2 in the shader from a Vector2.
  16775. * @param name Define the name of the uniform as defined in the shader
  16776. * @param value Define the value to give to the uniform
  16777. * @return the material itself allowing "fluent" like uniform updates
  16778. */
  16779. setVector2(name: string, value: Vector2): ShaderMaterial;
  16780. /**
  16781. * Set a vec3 in the shader from a Vector3.
  16782. * @param name Define the name of the uniform as defined in the shader
  16783. * @param value Define the value to give to the uniform
  16784. * @return the material itself allowing "fluent" like uniform updates
  16785. */
  16786. setVector3(name: string, value: Vector3): ShaderMaterial;
  16787. /**
  16788. * Set a vec4 in the shader from a Vector4.
  16789. * @param name Define the name of the uniform as defined in the shader
  16790. * @param value Define the value to give to the uniform
  16791. * @return the material itself allowing "fluent" like uniform updates
  16792. */
  16793. setVector4(name: string, value: Vector4): ShaderMaterial;
  16794. /**
  16795. * Set a mat4 in the shader from a Matrix.
  16796. * @param name Define the name of the uniform as defined in the shader
  16797. * @param value Define the value to give to the uniform
  16798. * @return the material itself allowing "fluent" like uniform updates
  16799. */
  16800. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16801. /**
  16802. * Set a float32Array in the shader from a matrix array.
  16803. * @param name Define the name of the uniform as defined in the shader
  16804. * @param value Define the value to give to the uniform
  16805. * @return the material itself allowing "fluent" like uniform updates
  16806. */
  16807. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16808. /**
  16809. * Set a mat3 in the shader from a Float32Array.
  16810. * @param name Define the name of the uniform as defined in the shader
  16811. * @param value Define the value to give to the uniform
  16812. * @return the material itself allowing "fluent" like uniform updates
  16813. */
  16814. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16815. /**
  16816. * Set a mat2 in the shader from a Float32Array.
  16817. * @param name Define the name of the uniform as defined in the shader
  16818. * @param value Define the value to give to the uniform
  16819. * @return the material itself allowing "fluent" like uniform updates
  16820. */
  16821. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16822. /**
  16823. * Set a vec2 array in the shader from a number array.
  16824. * @param name Define the name of the uniform as defined in the shader
  16825. * @param value Define the value to give to the uniform
  16826. * @return the material itself allowing "fluent" like uniform updates
  16827. */
  16828. setArray2(name: string, value: number[]): ShaderMaterial;
  16829. /**
  16830. * Set a vec3 array in the shader from a number array.
  16831. * @param name Define the name of the uniform as defined in the shader
  16832. * @param value Define the value to give to the uniform
  16833. * @return the material itself allowing "fluent" like uniform updates
  16834. */
  16835. setArray3(name: string, value: number[]): ShaderMaterial;
  16836. /**
  16837. * Set a vec4 array in the shader from a number array.
  16838. * @param name Define the name of the uniform as defined in the shader
  16839. * @param value Define the value to give to the uniform
  16840. * @return the material itself allowing "fluent" like uniform updates
  16841. */
  16842. setArray4(name: string, value: number[]): ShaderMaterial;
  16843. private _checkCache;
  16844. /**
  16845. * Specifies that the submesh is ready to be used
  16846. * @param mesh defines the mesh to check
  16847. * @param subMesh defines which submesh to check
  16848. * @param useInstances specifies that instances should be used
  16849. * @returns a boolean indicating that the submesh is ready or not
  16850. */
  16851. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16852. /**
  16853. * Checks if the material is ready to render the requested mesh
  16854. * @param mesh Define the mesh to render
  16855. * @param useInstances Define whether or not the material is used with instances
  16856. * @returns true if ready, otherwise false
  16857. */
  16858. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16859. /**
  16860. * Binds the world matrix to the material
  16861. * @param world defines the world transformation matrix
  16862. * @param effectOverride - If provided, use this effect instead of internal effect
  16863. */
  16864. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16865. /**
  16866. * Binds the submesh to this material by preparing the effect and shader to draw
  16867. * @param world defines the world transformation matrix
  16868. * @param mesh defines the mesh containing the submesh
  16869. * @param subMesh defines the submesh to bind the material to
  16870. */
  16871. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16872. /**
  16873. * Binds the material to the mesh
  16874. * @param world defines the world transformation matrix
  16875. * @param mesh defines the mesh to bind the material to
  16876. * @param effectOverride - If provided, use this effect instead of internal effect
  16877. */
  16878. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16879. protected _afterBind(mesh?: Mesh): void;
  16880. /**
  16881. * Gets the active textures from the material
  16882. * @returns an array of textures
  16883. */
  16884. getActiveTextures(): BaseTexture[];
  16885. /**
  16886. * Specifies if the material uses a texture
  16887. * @param texture defines the texture to check against the material
  16888. * @returns a boolean specifying if the material uses the texture
  16889. */
  16890. hasTexture(texture: BaseTexture): boolean;
  16891. /**
  16892. * Makes a duplicate of the material, and gives it a new name
  16893. * @param name defines the new name for the duplicated material
  16894. * @returns the cloned material
  16895. */
  16896. clone(name: string): ShaderMaterial;
  16897. /**
  16898. * Disposes the material
  16899. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16900. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16901. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16902. */
  16903. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16904. /**
  16905. * Serializes this material in a JSON representation
  16906. * @returns the serialized material object
  16907. */
  16908. serialize(): any;
  16909. /**
  16910. * Creates a shader material from parsed shader material data
  16911. * @param source defines the JSON represnetation of the material
  16912. * @param scene defines the hosting scene
  16913. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16914. * @returns a new material
  16915. */
  16916. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16917. /**
  16918. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16919. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16920. * @param url defines the url to load from
  16921. * @param scene defines the hosting scene
  16922. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16923. * @returns a promise that will resolve to the new ShaderMaterial
  16924. */
  16925. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16926. /**
  16927. * Creates a ShaderMaterial from a snippet saved by the Inspector
  16928. * @param snippetId defines the snippet to load
  16929. * @param scene defines the hosting scene
  16930. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16931. * @returns a promise that will resolve to the new ShaderMaterial
  16932. */
  16933. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16934. }
  16935. }
  16936. declare module BABYLON {
  16937. /** @hidden */
  16938. export var colorPixelShader: {
  16939. name: string;
  16940. shader: string;
  16941. };
  16942. }
  16943. declare module BABYLON {
  16944. /** @hidden */
  16945. export var colorVertexShader: {
  16946. name: string;
  16947. shader: string;
  16948. };
  16949. }
  16950. declare module BABYLON {
  16951. /**
  16952. * Line mesh
  16953. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16954. */
  16955. export class LinesMesh extends Mesh {
  16956. /**
  16957. * If vertex color should be applied to the mesh
  16958. */
  16959. readonly useVertexColor?: boolean | undefined;
  16960. /**
  16961. * If vertex alpha should be applied to the mesh
  16962. */
  16963. readonly useVertexAlpha?: boolean | undefined;
  16964. /**
  16965. * Color of the line (Default: White)
  16966. */
  16967. color: Color3;
  16968. /**
  16969. * Alpha of the line (Default: 1)
  16970. */
  16971. alpha: number;
  16972. /**
  16973. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16974. * This margin is expressed in world space coordinates, so its value may vary.
  16975. * Default value is 0.1
  16976. */
  16977. intersectionThreshold: number;
  16978. private _colorShader;
  16979. private color4;
  16980. /**
  16981. * Creates a new LinesMesh
  16982. * @param name defines the name
  16983. * @param scene defines the hosting scene
  16984. * @param parent defines the parent mesh if any
  16985. * @param source defines the optional source LinesMesh used to clone data from
  16986. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16987. * When false, achieved by calling a clone(), also passing False.
  16988. * This will make creation of children, recursive.
  16989. * @param useVertexColor defines if this LinesMesh supports vertex color
  16990. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16991. */
  16992. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16993. /**
  16994. * If vertex color should be applied to the mesh
  16995. */
  16996. useVertexColor?: boolean | undefined,
  16997. /**
  16998. * If vertex alpha should be applied to the mesh
  16999. */
  17000. useVertexAlpha?: boolean | undefined);
  17001. private _addClipPlaneDefine;
  17002. private _removeClipPlaneDefine;
  17003. isReady(): boolean;
  17004. /**
  17005. * Returns the string "LineMesh"
  17006. */
  17007. getClassName(): string;
  17008. /**
  17009. * @hidden
  17010. */
  17011. get material(): Material;
  17012. /**
  17013. * @hidden
  17014. */
  17015. set material(value: Material);
  17016. /**
  17017. * @hidden
  17018. */
  17019. get checkCollisions(): boolean;
  17020. /** @hidden */
  17021. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17022. /** @hidden */
  17023. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17024. /**
  17025. * Disposes of the line mesh
  17026. * @param doNotRecurse If children should be disposed
  17027. */
  17028. dispose(doNotRecurse?: boolean): void;
  17029. /**
  17030. * Returns a new LineMesh object cloned from the current one.
  17031. */
  17032. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17033. /**
  17034. * Creates a new InstancedLinesMesh object from the mesh model.
  17035. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17036. * @param name defines the name of the new instance
  17037. * @returns a new InstancedLinesMesh
  17038. */
  17039. createInstance(name: string): InstancedLinesMesh;
  17040. }
  17041. /**
  17042. * Creates an instance based on a source LinesMesh
  17043. */
  17044. export class InstancedLinesMesh extends InstancedMesh {
  17045. /**
  17046. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17047. * This margin is expressed in world space coordinates, so its value may vary.
  17048. * Initilized with the intersectionThreshold value of the source LinesMesh
  17049. */
  17050. intersectionThreshold: number;
  17051. constructor(name: string, source: LinesMesh);
  17052. /**
  17053. * Returns the string "InstancedLinesMesh".
  17054. */
  17055. getClassName(): string;
  17056. }
  17057. }
  17058. declare module BABYLON {
  17059. /** @hidden */
  17060. export var linePixelShader: {
  17061. name: string;
  17062. shader: string;
  17063. };
  17064. }
  17065. declare module BABYLON {
  17066. /** @hidden */
  17067. export var lineVertexShader: {
  17068. name: string;
  17069. shader: string;
  17070. };
  17071. }
  17072. declare module BABYLON {
  17073. interface Scene {
  17074. /** @hidden */
  17075. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17076. }
  17077. interface AbstractMesh {
  17078. /**
  17079. * Gets the edgesRenderer associated with the mesh
  17080. */
  17081. edgesRenderer: Nullable<EdgesRenderer>;
  17082. }
  17083. interface LinesMesh {
  17084. /**
  17085. * Enables the edge rendering mode on the mesh.
  17086. * This mode makes the mesh edges visible
  17087. * @param epsilon defines the maximal distance between two angles to detect a face
  17088. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17089. * @returns the currentAbstractMesh
  17090. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17091. */
  17092. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17093. }
  17094. interface InstancedLinesMesh {
  17095. /**
  17096. * Enables the edge rendering mode on the mesh.
  17097. * This mode makes the mesh edges visible
  17098. * @param epsilon defines the maximal distance between two angles to detect a face
  17099. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17100. * @returns the current InstancedLinesMesh
  17101. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17102. */
  17103. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17104. }
  17105. /**
  17106. * Defines the minimum contract an Edges renderer should follow.
  17107. */
  17108. export interface IEdgesRenderer extends IDisposable {
  17109. /**
  17110. * Gets or sets a boolean indicating if the edgesRenderer is active
  17111. */
  17112. isEnabled: boolean;
  17113. /**
  17114. * Renders the edges of the attached mesh,
  17115. */
  17116. render(): void;
  17117. /**
  17118. * Checks wether or not the edges renderer is ready to render.
  17119. * @return true if ready, otherwise false.
  17120. */
  17121. isReady(): boolean;
  17122. /**
  17123. * List of instances to render in case the source mesh has instances
  17124. */
  17125. customInstances: SmartArray<Matrix>;
  17126. }
  17127. /**
  17128. * Defines the additional options of the edges renderer
  17129. */
  17130. export interface IEdgesRendererOptions {
  17131. /**
  17132. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17133. * If not defined, the default value is true
  17134. */
  17135. useAlternateEdgeFinder?: boolean;
  17136. /**
  17137. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17138. * If not defined, the default value is true.
  17139. * 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)
  17140. * This option is used only if useAlternateEdgeFinder = true
  17141. */
  17142. useFastVertexMerger?: boolean;
  17143. /**
  17144. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17145. * The default value is 1e-6
  17146. * This option is used only if useAlternateEdgeFinder = true
  17147. */
  17148. epsilonVertexMerge?: number;
  17149. /**
  17150. * 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
  17151. * 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.
  17152. * This option is used only if useAlternateEdgeFinder = true
  17153. */
  17154. applyTessellation?: boolean;
  17155. /**
  17156. * 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
  17157. * The default value is 1e-6
  17158. * This option is used only if useAlternateEdgeFinder = true
  17159. */
  17160. epsilonVertexAligned?: number;
  17161. }
  17162. /**
  17163. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17164. */
  17165. export class EdgesRenderer implements IEdgesRenderer {
  17166. /**
  17167. * Define the size of the edges with an orthographic camera
  17168. */
  17169. edgesWidthScalerForOrthographic: number;
  17170. /**
  17171. * Define the size of the edges with a perspective camera
  17172. */
  17173. edgesWidthScalerForPerspective: number;
  17174. protected _source: AbstractMesh;
  17175. protected _linesPositions: number[];
  17176. protected _linesNormals: number[];
  17177. protected _linesIndices: number[];
  17178. protected _epsilon: number;
  17179. protected _indicesCount: number;
  17180. protected _lineShader: ShaderMaterial;
  17181. protected _ib: DataBuffer;
  17182. protected _buffers: {
  17183. [key: string]: Nullable<VertexBuffer>;
  17184. };
  17185. protected _buffersForInstances: {
  17186. [key: string]: Nullable<VertexBuffer>;
  17187. };
  17188. protected _checkVerticesInsteadOfIndices: boolean;
  17189. protected _options: Nullable<IEdgesRendererOptions>;
  17190. private _meshRebuildObserver;
  17191. private _meshDisposeObserver;
  17192. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17193. isEnabled: boolean;
  17194. /**
  17195. * List of instances to render in case the source mesh has instances
  17196. */
  17197. customInstances: SmartArray<Matrix>;
  17198. private static GetShader;
  17199. /**
  17200. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17201. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17202. * @param source Mesh used to create edges
  17203. * @param epsilon sum of angles in adjacency to check for edge
  17204. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17205. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17206. * @param options The options to apply when generating the edges
  17207. */
  17208. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17209. protected _prepareRessources(): void;
  17210. /** @hidden */
  17211. _rebuild(): void;
  17212. /**
  17213. * Releases the required resources for the edges renderer
  17214. */
  17215. dispose(): void;
  17216. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17217. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17218. /**
  17219. * Checks if the pair of p0 and p1 is en edge
  17220. * @param faceIndex
  17221. * @param edge
  17222. * @param faceNormals
  17223. * @param p0
  17224. * @param p1
  17225. * @private
  17226. */
  17227. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17228. /**
  17229. * push line into the position, normal and index buffer
  17230. * @protected
  17231. */
  17232. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17233. /**
  17234. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17235. */
  17236. private _tessellateTriangle;
  17237. private _generateEdgesLinesAlternate;
  17238. /**
  17239. * Generates lines edges from adjacencjes
  17240. * @private
  17241. */
  17242. _generateEdgesLines(): void;
  17243. /**
  17244. * Checks wether or not the edges renderer is ready to render.
  17245. * @return true if ready, otherwise false.
  17246. */
  17247. isReady(): boolean;
  17248. /**
  17249. * Renders the edges of the attached mesh,
  17250. */
  17251. render(): void;
  17252. }
  17253. /**
  17254. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17255. */
  17256. export class LineEdgesRenderer extends EdgesRenderer {
  17257. /**
  17258. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17259. * @param source LineMesh used to generate edges
  17260. * @param epsilon not important (specified angle for edge detection)
  17261. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17262. */
  17263. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17264. /**
  17265. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17266. */
  17267. _generateEdgesLines(): void;
  17268. }
  17269. }
  17270. declare module BABYLON {
  17271. /**
  17272. * This represents the object necessary to create a rendering group.
  17273. * This is exclusively used and created by the rendering manager.
  17274. * To modify the behavior, you use the available helpers in your scene or meshes.
  17275. * @hidden
  17276. */
  17277. export class RenderingGroup {
  17278. index: number;
  17279. private static _zeroVector;
  17280. private _scene;
  17281. private _opaqueSubMeshes;
  17282. private _transparentSubMeshes;
  17283. private _alphaTestSubMeshes;
  17284. private _depthOnlySubMeshes;
  17285. private _particleSystems;
  17286. private _spriteManagers;
  17287. private _opaqueSortCompareFn;
  17288. private _alphaTestSortCompareFn;
  17289. private _transparentSortCompareFn;
  17290. private _renderOpaque;
  17291. private _renderAlphaTest;
  17292. private _renderTransparent;
  17293. /** @hidden */
  17294. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17295. onBeforeTransparentRendering: () => void;
  17296. /**
  17297. * Set the opaque sort comparison function.
  17298. * If null the sub meshes will be render in the order they were created
  17299. */
  17300. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17301. /**
  17302. * Set the alpha test sort comparison function.
  17303. * If null the sub meshes will be render in the order they were created
  17304. */
  17305. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17306. /**
  17307. * Set the transparent sort comparison function.
  17308. * If null the sub meshes will be render in the order they were created
  17309. */
  17310. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17311. /**
  17312. * Creates a new rendering group.
  17313. * @param index The rendering group index
  17314. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17315. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17316. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17317. */
  17318. 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>);
  17319. /**
  17320. * Render all the sub meshes contained in the group.
  17321. * @param customRenderFunction Used to override the default render behaviour of the group.
  17322. * @returns true if rendered some submeshes.
  17323. */
  17324. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17325. /**
  17326. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17327. * @param subMeshes The submeshes to render
  17328. */
  17329. private renderOpaqueSorted;
  17330. /**
  17331. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17332. * @param subMeshes The submeshes to render
  17333. */
  17334. private renderAlphaTestSorted;
  17335. /**
  17336. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17337. * @param subMeshes The submeshes to render
  17338. */
  17339. private renderTransparentSorted;
  17340. /**
  17341. * Renders the submeshes in a specified order.
  17342. * @param subMeshes The submeshes to sort before render
  17343. * @param sortCompareFn The comparison function use to sort
  17344. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17345. * @param transparent Specifies to activate blending if true
  17346. */
  17347. private static renderSorted;
  17348. /**
  17349. * Renders the submeshes in the order they were dispatched (no sort applied).
  17350. * @param subMeshes The submeshes to render
  17351. */
  17352. private static renderUnsorted;
  17353. /**
  17354. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17355. * are rendered back to front if in the same alpha index.
  17356. *
  17357. * @param a The first submesh
  17358. * @param b The second submesh
  17359. * @returns The result of the comparison
  17360. */
  17361. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17362. /**
  17363. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17364. * are rendered back to front.
  17365. *
  17366. * @param a The first submesh
  17367. * @param b The second submesh
  17368. * @returns The result of the comparison
  17369. */
  17370. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17371. /**
  17372. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17373. * are rendered front to back (prevent overdraw).
  17374. *
  17375. * @param a The first submesh
  17376. * @param b The second submesh
  17377. * @returns The result of the comparison
  17378. */
  17379. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17380. /**
  17381. * Resets the different lists of submeshes to prepare a new frame.
  17382. */
  17383. prepare(): void;
  17384. dispose(): void;
  17385. /**
  17386. * Inserts the submesh in its correct queue depending on its material.
  17387. * @param subMesh The submesh to dispatch
  17388. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17389. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17390. */
  17391. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17392. dispatchSprites(spriteManager: ISpriteManager): void;
  17393. dispatchParticles(particleSystem: IParticleSystem): void;
  17394. private _renderParticles;
  17395. private _renderSprites;
  17396. }
  17397. }
  17398. declare module BABYLON {
  17399. /**
  17400. * Interface describing the different options available in the rendering manager
  17401. * regarding Auto Clear between groups.
  17402. */
  17403. export interface IRenderingManagerAutoClearSetup {
  17404. /**
  17405. * Defines whether or not autoclear is enable.
  17406. */
  17407. autoClear: boolean;
  17408. /**
  17409. * Defines whether or not to autoclear the depth buffer.
  17410. */
  17411. depth: boolean;
  17412. /**
  17413. * Defines whether or not to autoclear the stencil buffer.
  17414. */
  17415. stencil: boolean;
  17416. }
  17417. /**
  17418. * This class is used by the onRenderingGroupObservable
  17419. */
  17420. export class RenderingGroupInfo {
  17421. /**
  17422. * The Scene that being rendered
  17423. */
  17424. scene: Scene;
  17425. /**
  17426. * The camera currently used for the rendering pass
  17427. */
  17428. camera: Nullable<Camera>;
  17429. /**
  17430. * The ID of the renderingGroup being processed
  17431. */
  17432. renderingGroupId: number;
  17433. }
  17434. /**
  17435. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17436. * It is enable to manage the different groups as well as the different necessary sort functions.
  17437. * This should not be used directly aside of the few static configurations
  17438. */
  17439. export class RenderingManager {
  17440. /**
  17441. * The max id used for rendering groups (not included)
  17442. */
  17443. static MAX_RENDERINGGROUPS: number;
  17444. /**
  17445. * The min id used for rendering groups (included)
  17446. */
  17447. static MIN_RENDERINGGROUPS: number;
  17448. /**
  17449. * Used to globally prevent autoclearing scenes.
  17450. */
  17451. static AUTOCLEAR: boolean;
  17452. /**
  17453. * @hidden
  17454. */
  17455. _useSceneAutoClearSetup: boolean;
  17456. private _scene;
  17457. private _renderingGroups;
  17458. private _depthStencilBufferAlreadyCleaned;
  17459. private _autoClearDepthStencil;
  17460. private _customOpaqueSortCompareFn;
  17461. private _customAlphaTestSortCompareFn;
  17462. private _customTransparentSortCompareFn;
  17463. private _renderingGroupInfo;
  17464. /**
  17465. * Instantiates a new rendering group for a particular scene
  17466. * @param scene Defines the scene the groups belongs to
  17467. */
  17468. constructor(scene: Scene);
  17469. private _clearDepthStencilBuffer;
  17470. /**
  17471. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17472. * @hidden
  17473. */
  17474. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17475. /**
  17476. * Resets the different information of the group to prepare a new frame
  17477. * @hidden
  17478. */
  17479. reset(): void;
  17480. /**
  17481. * Dispose and release the group and its associated resources.
  17482. * @hidden
  17483. */
  17484. dispose(): void;
  17485. /**
  17486. * Clear the info related to rendering groups preventing retention points during dispose.
  17487. */
  17488. freeRenderingGroups(): void;
  17489. private _prepareRenderingGroup;
  17490. /**
  17491. * Add a sprite manager to the rendering manager in order to render it this frame.
  17492. * @param spriteManager Define the sprite manager to render
  17493. */
  17494. dispatchSprites(spriteManager: ISpriteManager): void;
  17495. /**
  17496. * Add a particle system to the rendering manager in order to render it this frame.
  17497. * @param particleSystem Define the particle system to render
  17498. */
  17499. dispatchParticles(particleSystem: IParticleSystem): void;
  17500. /**
  17501. * Add a submesh to the manager in order to render it this frame
  17502. * @param subMesh The submesh to dispatch
  17503. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17504. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17505. */
  17506. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17507. /**
  17508. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17509. * This allowed control for front to back rendering or reversly depending of the special needs.
  17510. *
  17511. * @param renderingGroupId The rendering group id corresponding to its index
  17512. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17513. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17514. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17515. */
  17516. 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;
  17517. /**
  17518. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17519. *
  17520. * @param renderingGroupId The rendering group id corresponding to its index
  17521. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17522. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17523. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17524. */
  17525. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17526. /**
  17527. * Gets the current auto clear configuration for one rendering group of the rendering
  17528. * manager.
  17529. * @param index the rendering group index to get the information for
  17530. * @returns The auto clear setup for the requested rendering group
  17531. */
  17532. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17533. }
  17534. }
  17535. declare module BABYLON {
  17536. /**
  17537. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17538. */
  17539. export interface ICustomShaderOptions {
  17540. /**
  17541. * Gets or sets the custom shader name to use
  17542. */
  17543. shaderName: string;
  17544. /**
  17545. * The list of attribute names used in the shader
  17546. */
  17547. attributes?: string[];
  17548. /**
  17549. * The list of unifrom names used in the shader
  17550. */
  17551. uniforms?: string[];
  17552. /**
  17553. * The list of sampler names used in the shader
  17554. */
  17555. samplers?: string[];
  17556. /**
  17557. * The list of defines used in the shader
  17558. */
  17559. defines?: string[];
  17560. }
  17561. /**
  17562. * Interface to implement to create a shadow generator compatible with BJS.
  17563. */
  17564. export interface IShadowGenerator {
  17565. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17566. id: string;
  17567. /**
  17568. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17569. * @returns The render target texture if present otherwise, null
  17570. */
  17571. getShadowMap(): Nullable<RenderTargetTexture>;
  17572. /**
  17573. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17574. * @param subMesh The submesh we want to render in the shadow map
  17575. * @param useInstances Defines wether will draw in the map using instances
  17576. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17577. * @returns true if ready otherwise, false
  17578. */
  17579. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17580. /**
  17581. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17582. * @param defines Defines of the material we want to update
  17583. * @param lightIndex Index of the light in the enabled light list of the material
  17584. */
  17585. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17586. /**
  17587. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17588. * defined in the generator but impacting the effect).
  17589. * It implies the unifroms available on the materials are the standard BJS ones.
  17590. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17591. * @param effect The effect we are binfing the information for
  17592. */
  17593. bindShadowLight(lightIndex: string, effect: Effect): void;
  17594. /**
  17595. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17596. * (eq to shadow prjection matrix * light transform matrix)
  17597. * @returns The transform matrix used to create the shadow map
  17598. */
  17599. getTransformMatrix(): Matrix;
  17600. /**
  17601. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17602. * Cube and 2D textures for instance.
  17603. */
  17604. recreateShadowMap(): void;
  17605. /**
  17606. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17607. * @param onCompiled Callback triggered at the and of the effects compilation
  17608. * @param options Sets of optional options forcing the compilation with different modes
  17609. */
  17610. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17611. useInstances: boolean;
  17612. }>): void;
  17613. /**
  17614. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17615. * @param options Sets of optional options forcing the compilation with different modes
  17616. * @returns A promise that resolves when the compilation completes
  17617. */
  17618. forceCompilationAsync(options?: Partial<{
  17619. useInstances: boolean;
  17620. }>): Promise<void>;
  17621. /**
  17622. * Serializes the shadow generator setup to a json object.
  17623. * @returns The serialized JSON object
  17624. */
  17625. serialize(): any;
  17626. /**
  17627. * Disposes the Shadow map and related Textures and effects.
  17628. */
  17629. dispose(): void;
  17630. }
  17631. /**
  17632. * Default implementation IShadowGenerator.
  17633. * This is the main object responsible of generating shadows in the framework.
  17634. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17635. */
  17636. export class ShadowGenerator implements IShadowGenerator {
  17637. /**
  17638. * Name of the shadow generator class
  17639. */
  17640. static CLASSNAME: string;
  17641. /**
  17642. * Shadow generator mode None: no filtering applied.
  17643. */
  17644. static readonly FILTER_NONE: number;
  17645. /**
  17646. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17647. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17648. */
  17649. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17650. /**
  17651. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17652. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17653. */
  17654. static readonly FILTER_POISSONSAMPLING: number;
  17655. /**
  17656. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17657. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17658. */
  17659. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17660. /**
  17661. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17662. * edge artifacts on steep falloff.
  17663. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17664. */
  17665. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17666. /**
  17667. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17668. * edge artifacts on steep falloff.
  17669. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17670. */
  17671. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17672. /**
  17673. * Shadow generator mode PCF: Percentage Closer Filtering
  17674. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17675. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17676. */
  17677. static readonly FILTER_PCF: number;
  17678. /**
  17679. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17680. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17681. * Contact Hardening
  17682. */
  17683. static readonly FILTER_PCSS: number;
  17684. /**
  17685. * Reserved for PCF and PCSS
  17686. * Highest Quality.
  17687. *
  17688. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17689. *
  17690. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17691. */
  17692. static readonly QUALITY_HIGH: number;
  17693. /**
  17694. * Reserved for PCF and PCSS
  17695. * Good tradeoff for quality/perf cross devices
  17696. *
  17697. * Execute PCF on a 3*3 kernel.
  17698. *
  17699. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17700. */
  17701. static readonly QUALITY_MEDIUM: number;
  17702. /**
  17703. * Reserved for PCF and PCSS
  17704. * The lowest quality but the fastest.
  17705. *
  17706. * Execute PCF on a 1*1 kernel.
  17707. *
  17708. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17709. */
  17710. static readonly QUALITY_LOW: number;
  17711. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17712. id: string;
  17713. /** Gets or sets the custom shader name to use */
  17714. customShaderOptions: ICustomShaderOptions;
  17715. /**
  17716. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17717. */
  17718. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17719. /**
  17720. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17721. */
  17722. onAfterShadowMapRenderObservable: Observable<Effect>;
  17723. /**
  17724. * Observable triggered before a mesh is rendered in the shadow map.
  17725. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17726. */
  17727. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17728. /**
  17729. * Observable triggered after a mesh is rendered in the shadow map.
  17730. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17731. */
  17732. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17733. protected _bias: number;
  17734. /**
  17735. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17736. */
  17737. get bias(): number;
  17738. /**
  17739. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17740. */
  17741. set bias(bias: number);
  17742. protected _normalBias: number;
  17743. /**
  17744. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17745. */
  17746. get normalBias(): number;
  17747. /**
  17748. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17749. */
  17750. set normalBias(normalBias: number);
  17751. protected _blurBoxOffset: number;
  17752. /**
  17753. * Gets the blur box offset: offset applied during the blur pass.
  17754. * Only useful if useKernelBlur = false
  17755. */
  17756. get blurBoxOffset(): number;
  17757. /**
  17758. * Sets the blur box offset: offset applied during the blur pass.
  17759. * Only useful if useKernelBlur = false
  17760. */
  17761. set blurBoxOffset(value: number);
  17762. protected _blurScale: number;
  17763. /**
  17764. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17765. * 2 means half of the size.
  17766. */
  17767. get blurScale(): number;
  17768. /**
  17769. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17770. * 2 means half of the size.
  17771. */
  17772. set blurScale(value: number);
  17773. protected _blurKernel: number;
  17774. /**
  17775. * Gets the blur kernel: kernel size of the blur pass.
  17776. * Only useful if useKernelBlur = true
  17777. */
  17778. get blurKernel(): number;
  17779. /**
  17780. * Sets the blur kernel: kernel size of the blur pass.
  17781. * Only useful if useKernelBlur = true
  17782. */
  17783. set blurKernel(value: number);
  17784. protected _useKernelBlur: boolean;
  17785. /**
  17786. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17787. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17788. */
  17789. get useKernelBlur(): boolean;
  17790. /**
  17791. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17792. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17793. */
  17794. set useKernelBlur(value: boolean);
  17795. protected _depthScale: number;
  17796. /**
  17797. * Gets the depth scale used in ESM mode.
  17798. */
  17799. get depthScale(): number;
  17800. /**
  17801. * Sets the depth scale used in ESM mode.
  17802. * This can override the scale stored on the light.
  17803. */
  17804. set depthScale(value: number);
  17805. protected _validateFilter(filter: number): number;
  17806. protected _filter: number;
  17807. /**
  17808. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17809. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17810. */
  17811. get filter(): number;
  17812. /**
  17813. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17814. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17815. */
  17816. set filter(value: number);
  17817. /**
  17818. * Gets if the current filter is set to Poisson Sampling.
  17819. */
  17820. get usePoissonSampling(): boolean;
  17821. /**
  17822. * Sets the current filter to Poisson Sampling.
  17823. */
  17824. set usePoissonSampling(value: boolean);
  17825. /**
  17826. * Gets if the current filter is set to ESM.
  17827. */
  17828. get useExponentialShadowMap(): boolean;
  17829. /**
  17830. * Sets the current filter is to ESM.
  17831. */
  17832. set useExponentialShadowMap(value: boolean);
  17833. /**
  17834. * Gets if the current filter is set to filtered ESM.
  17835. */
  17836. get useBlurExponentialShadowMap(): boolean;
  17837. /**
  17838. * Gets if the current filter is set to filtered ESM.
  17839. */
  17840. set useBlurExponentialShadowMap(value: boolean);
  17841. /**
  17842. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17843. * exponential to prevent steep falloff artifacts).
  17844. */
  17845. get useCloseExponentialShadowMap(): boolean;
  17846. /**
  17847. * Sets the current filter to "close ESM" (using the inverse of the
  17848. * exponential to prevent steep falloff artifacts).
  17849. */
  17850. set useCloseExponentialShadowMap(value: boolean);
  17851. /**
  17852. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17853. * exponential to prevent steep falloff artifacts).
  17854. */
  17855. get useBlurCloseExponentialShadowMap(): boolean;
  17856. /**
  17857. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17858. * exponential to prevent steep falloff artifacts).
  17859. */
  17860. set useBlurCloseExponentialShadowMap(value: boolean);
  17861. /**
  17862. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17863. */
  17864. get usePercentageCloserFiltering(): boolean;
  17865. /**
  17866. * Sets the current filter to "PCF" (percentage closer filtering).
  17867. */
  17868. set usePercentageCloserFiltering(value: boolean);
  17869. protected _filteringQuality: number;
  17870. /**
  17871. * Gets the PCF or PCSS Quality.
  17872. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17873. */
  17874. get filteringQuality(): number;
  17875. /**
  17876. * Sets the PCF or PCSS Quality.
  17877. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17878. */
  17879. set filteringQuality(filteringQuality: number);
  17880. /**
  17881. * Gets if the current filter is set to "PCSS" (contact hardening).
  17882. */
  17883. get useContactHardeningShadow(): boolean;
  17884. /**
  17885. * Sets the current filter to "PCSS" (contact hardening).
  17886. */
  17887. set useContactHardeningShadow(value: boolean);
  17888. protected _contactHardeningLightSizeUVRatio: number;
  17889. /**
  17890. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17891. * Using a ratio helps keeping shape stability independently of the map size.
  17892. *
  17893. * It does not account for the light projection as it was having too much
  17894. * instability during the light setup or during light position changes.
  17895. *
  17896. * Only valid if useContactHardeningShadow is true.
  17897. */
  17898. get contactHardeningLightSizeUVRatio(): number;
  17899. /**
  17900. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17901. * Using a ratio helps keeping shape stability independently of the map size.
  17902. *
  17903. * It does not account for the light projection as it was having too much
  17904. * instability during the light setup or during light position changes.
  17905. *
  17906. * Only valid if useContactHardeningShadow is true.
  17907. */
  17908. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17909. protected _darkness: number;
  17910. /** Gets or sets the actual darkness of a shadow */
  17911. get darkness(): number;
  17912. set darkness(value: number);
  17913. /**
  17914. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17915. * 0 means strongest and 1 would means no shadow.
  17916. * @returns the darkness.
  17917. */
  17918. getDarkness(): number;
  17919. /**
  17920. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17921. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17922. * @returns the shadow generator allowing fluent coding.
  17923. */
  17924. setDarkness(darkness: number): ShadowGenerator;
  17925. protected _transparencyShadow: boolean;
  17926. /** Gets or sets the ability to have transparent shadow */
  17927. get transparencyShadow(): boolean;
  17928. set transparencyShadow(value: boolean);
  17929. /**
  17930. * Sets the ability to have transparent shadow (boolean).
  17931. * @param transparent True if transparent else False
  17932. * @returns the shadow generator allowing fluent coding
  17933. */
  17934. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17935. /**
  17936. * Enables or disables shadows with varying strength based on the transparency
  17937. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17938. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17939. * mesh.visibility * alphaTexture.a
  17940. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17941. */
  17942. enableSoftTransparentShadow: boolean;
  17943. protected _shadowMap: Nullable<RenderTargetTexture>;
  17944. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17945. /**
  17946. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17947. * @returns The render target texture if present otherwise, null
  17948. */
  17949. getShadowMap(): Nullable<RenderTargetTexture>;
  17950. /**
  17951. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17952. * @returns The render target texture if the shadow map is present otherwise, null
  17953. */
  17954. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17955. /**
  17956. * Gets the class name of that object
  17957. * @returns "ShadowGenerator"
  17958. */
  17959. getClassName(): string;
  17960. /**
  17961. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17962. * @param mesh Mesh to add
  17963. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17964. * @returns the Shadow Generator itself
  17965. */
  17966. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17967. /**
  17968. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17969. * @param mesh Mesh to remove
  17970. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17971. * @returns the Shadow Generator itself
  17972. */
  17973. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17974. /**
  17975. * Controls the extent to which the shadows fade out at the edge of the frustum
  17976. */
  17977. frustumEdgeFalloff: number;
  17978. protected _light: IShadowLight;
  17979. /**
  17980. * Returns the associated light object.
  17981. * @returns the light generating the shadow
  17982. */
  17983. getLight(): IShadowLight;
  17984. /**
  17985. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17986. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17987. * It might on the other hand introduce peter panning.
  17988. */
  17989. forceBackFacesOnly: boolean;
  17990. protected _scene: Scene;
  17991. protected _lightDirection: Vector3;
  17992. protected _effect: Effect;
  17993. protected _viewMatrix: Matrix;
  17994. protected _projectionMatrix: Matrix;
  17995. protected _transformMatrix: Matrix;
  17996. protected _cachedPosition: Vector3;
  17997. protected _cachedDirection: Vector3;
  17998. protected _cachedDefines: string;
  17999. protected _currentRenderID: number;
  18000. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18001. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18002. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18003. protected _blurPostProcesses: PostProcess[];
  18004. protected _mapSize: number;
  18005. protected _currentFaceIndex: number;
  18006. protected _currentFaceIndexCache: number;
  18007. protected _textureType: number;
  18008. protected _defaultTextureMatrix: Matrix;
  18009. protected _storedUniqueId: Nullable<number>;
  18010. /** @hidden */
  18011. static _SceneComponentInitialization: (scene: Scene) => void;
  18012. /**
  18013. * Gets or sets the size of the texture what stores the shadows
  18014. */
  18015. get mapSize(): number;
  18016. set mapSize(size: number);
  18017. /**
  18018. * Creates a ShadowGenerator object.
  18019. * A ShadowGenerator is the required tool to use the shadows.
  18020. * Each light casting shadows needs to use its own ShadowGenerator.
  18021. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18022. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18023. * @param light The light object generating the shadows.
  18024. * @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.
  18025. */
  18026. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18027. protected _initializeGenerator(): void;
  18028. protected _createTargetRenderTexture(): void;
  18029. protected _initializeShadowMap(): void;
  18030. protected _initializeBlurRTTAndPostProcesses(): void;
  18031. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18032. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18033. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18034. protected _applyFilterValues(): void;
  18035. /**
  18036. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18037. * @param onCompiled Callback triggered at the and of the effects compilation
  18038. * @param options Sets of optional options forcing the compilation with different modes
  18039. */
  18040. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18041. useInstances: boolean;
  18042. }>): void;
  18043. /**
  18044. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18045. * @param options Sets of optional options forcing the compilation with different modes
  18046. * @returns A promise that resolves when the compilation completes
  18047. */
  18048. forceCompilationAsync(options?: Partial<{
  18049. useInstances: boolean;
  18050. }>): Promise<void>;
  18051. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18052. private _prepareShadowDefines;
  18053. /**
  18054. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18055. * @param subMesh The submesh we want to render in the shadow map
  18056. * @param useInstances Defines wether will draw in the map using instances
  18057. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18058. * @returns true if ready otherwise, false
  18059. */
  18060. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18061. /**
  18062. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18063. * @param defines Defines of the material we want to update
  18064. * @param lightIndex Index of the light in the enabled light list of the material
  18065. */
  18066. prepareDefines(defines: any, lightIndex: number): void;
  18067. /**
  18068. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18069. * defined in the generator but impacting the effect).
  18070. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18071. * @param effect The effect we are binfing the information for
  18072. */
  18073. bindShadowLight(lightIndex: string, effect: Effect): void;
  18074. /**
  18075. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18076. * (eq to shadow prjection matrix * light transform matrix)
  18077. * @returns The transform matrix used to create the shadow map
  18078. */
  18079. getTransformMatrix(): Matrix;
  18080. /**
  18081. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18082. * Cube and 2D textures for instance.
  18083. */
  18084. recreateShadowMap(): void;
  18085. protected _disposeBlurPostProcesses(): void;
  18086. protected _disposeRTTandPostProcesses(): void;
  18087. /**
  18088. * Disposes the ShadowGenerator.
  18089. * Returns nothing.
  18090. */
  18091. dispose(): void;
  18092. /**
  18093. * Serializes the shadow generator setup to a json object.
  18094. * @returns The serialized JSON object
  18095. */
  18096. serialize(): any;
  18097. /**
  18098. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18099. * @param parsedShadowGenerator The JSON object to parse
  18100. * @param scene The scene to create the shadow map for
  18101. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18102. * @returns The parsed shadow generator
  18103. */
  18104. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18105. }
  18106. }
  18107. declare module BABYLON {
  18108. /**
  18109. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18110. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18111. * 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.
  18112. */
  18113. export abstract class Light extends Node {
  18114. /**
  18115. * Falloff Default: light is falling off following the material specification:
  18116. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18117. */
  18118. static readonly FALLOFF_DEFAULT: number;
  18119. /**
  18120. * Falloff Physical: light is falling off following the inverse squared distance law.
  18121. */
  18122. static readonly FALLOFF_PHYSICAL: number;
  18123. /**
  18124. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18125. * to enhance interoperability with other engines.
  18126. */
  18127. static readonly FALLOFF_GLTF: number;
  18128. /**
  18129. * Falloff Standard: light is falling off like in the standard material
  18130. * to enhance interoperability with other materials.
  18131. */
  18132. static readonly FALLOFF_STANDARD: number;
  18133. /**
  18134. * If every light affecting the material is in this lightmapMode,
  18135. * material.lightmapTexture adds or multiplies
  18136. * (depends on material.useLightmapAsShadowmap)
  18137. * after every other light calculations.
  18138. */
  18139. static readonly LIGHTMAP_DEFAULT: number;
  18140. /**
  18141. * material.lightmapTexture as only diffuse lighting from this light
  18142. * adds only specular lighting from this light
  18143. * adds dynamic shadows
  18144. */
  18145. static readonly LIGHTMAP_SPECULAR: number;
  18146. /**
  18147. * material.lightmapTexture as only lighting
  18148. * no light calculation from this light
  18149. * only adds dynamic shadows from this light
  18150. */
  18151. static readonly LIGHTMAP_SHADOWSONLY: number;
  18152. /**
  18153. * Each light type uses the default quantity according to its type:
  18154. * point/spot lights use luminous intensity
  18155. * directional lights use illuminance
  18156. */
  18157. static readonly INTENSITYMODE_AUTOMATIC: number;
  18158. /**
  18159. * lumen (lm)
  18160. */
  18161. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18162. /**
  18163. * candela (lm/sr)
  18164. */
  18165. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18166. /**
  18167. * lux (lm/m^2)
  18168. */
  18169. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18170. /**
  18171. * nit (cd/m^2)
  18172. */
  18173. static readonly INTENSITYMODE_LUMINANCE: number;
  18174. /**
  18175. * Light type const id of the point light.
  18176. */
  18177. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18178. /**
  18179. * Light type const id of the directional light.
  18180. */
  18181. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18182. /**
  18183. * Light type const id of the spot light.
  18184. */
  18185. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18186. /**
  18187. * Light type const id of the hemispheric light.
  18188. */
  18189. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18190. /**
  18191. * Diffuse gives the basic color to an object.
  18192. */
  18193. diffuse: Color3;
  18194. /**
  18195. * Specular produces a highlight color on an object.
  18196. * Note: This is note affecting PBR materials.
  18197. */
  18198. specular: Color3;
  18199. /**
  18200. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18201. * falling off base on range or angle.
  18202. * This can be set to any values in Light.FALLOFF_x.
  18203. *
  18204. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18205. * other types of materials.
  18206. */
  18207. falloffType: number;
  18208. /**
  18209. * Strength of the light.
  18210. * Note: By default it is define in the framework own unit.
  18211. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18212. */
  18213. intensity: number;
  18214. private _range;
  18215. protected _inverseSquaredRange: number;
  18216. /**
  18217. * Defines how far from the source the light is impacting in scene units.
  18218. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18219. */
  18220. get range(): number;
  18221. /**
  18222. * Defines how far from the source the light is impacting in scene units.
  18223. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18224. */
  18225. set range(value: number);
  18226. /**
  18227. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18228. * of light.
  18229. */
  18230. private _photometricScale;
  18231. private _intensityMode;
  18232. /**
  18233. * Gets the photometric scale used to interpret the intensity.
  18234. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18235. */
  18236. get intensityMode(): number;
  18237. /**
  18238. * Sets the photometric scale used to interpret the intensity.
  18239. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18240. */
  18241. set intensityMode(value: number);
  18242. private _radius;
  18243. /**
  18244. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18245. */
  18246. get radius(): number;
  18247. /**
  18248. * sets the light radius used by PBR Materials to simulate soft area lights.
  18249. */
  18250. set radius(value: number);
  18251. private _renderPriority;
  18252. /**
  18253. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18254. * exceeding the number allowed of the materials.
  18255. */
  18256. renderPriority: number;
  18257. private _shadowEnabled;
  18258. /**
  18259. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18260. * the current shadow generator.
  18261. */
  18262. get shadowEnabled(): boolean;
  18263. /**
  18264. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18265. * the current shadow generator.
  18266. */
  18267. set shadowEnabled(value: boolean);
  18268. private _includedOnlyMeshes;
  18269. /**
  18270. * Gets the only meshes impacted by this light.
  18271. */
  18272. get includedOnlyMeshes(): AbstractMesh[];
  18273. /**
  18274. * Sets the only meshes impacted by this light.
  18275. */
  18276. set includedOnlyMeshes(value: AbstractMesh[]);
  18277. private _excludedMeshes;
  18278. /**
  18279. * Gets the meshes not impacted by this light.
  18280. */
  18281. get excludedMeshes(): AbstractMesh[];
  18282. /**
  18283. * Sets the meshes not impacted by this light.
  18284. */
  18285. set excludedMeshes(value: AbstractMesh[]);
  18286. private _excludeWithLayerMask;
  18287. /**
  18288. * Gets the layer id use to find what meshes are not impacted by the light.
  18289. * Inactive if 0
  18290. */
  18291. get excludeWithLayerMask(): number;
  18292. /**
  18293. * Sets the layer id use to find what meshes are not impacted by the light.
  18294. * Inactive if 0
  18295. */
  18296. set excludeWithLayerMask(value: number);
  18297. private _includeOnlyWithLayerMask;
  18298. /**
  18299. * Gets the layer id use to find what meshes are impacted by the light.
  18300. * Inactive if 0
  18301. */
  18302. get includeOnlyWithLayerMask(): number;
  18303. /**
  18304. * Sets the layer id use to find what meshes are impacted by the light.
  18305. * Inactive if 0
  18306. */
  18307. set includeOnlyWithLayerMask(value: number);
  18308. private _lightmapMode;
  18309. /**
  18310. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18311. */
  18312. get lightmapMode(): number;
  18313. /**
  18314. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18315. */
  18316. set lightmapMode(value: number);
  18317. /**
  18318. * Shadow generator associted to the light.
  18319. * @hidden Internal use only.
  18320. */
  18321. _shadowGenerator: Nullable<IShadowGenerator>;
  18322. /**
  18323. * @hidden Internal use only.
  18324. */
  18325. _excludedMeshesIds: string[];
  18326. /**
  18327. * @hidden Internal use only.
  18328. */
  18329. _includedOnlyMeshesIds: string[];
  18330. /**
  18331. * The current light unifom buffer.
  18332. * @hidden Internal use only.
  18333. */
  18334. _uniformBuffer: UniformBuffer;
  18335. /** @hidden */
  18336. _renderId: number;
  18337. /**
  18338. * Creates a Light object in the scene.
  18339. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18340. * @param name The firendly name of the light
  18341. * @param scene The scene the light belongs too
  18342. */
  18343. constructor(name: string, scene: Scene);
  18344. protected abstract _buildUniformLayout(): void;
  18345. /**
  18346. * Sets the passed Effect "effect" with the Light information.
  18347. * @param effect The effect to update
  18348. * @param lightIndex The index of the light in the effect to update
  18349. * @returns The light
  18350. */
  18351. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18352. /**
  18353. * Sets the passed Effect "effect" with the Light textures.
  18354. * @param effect The effect to update
  18355. * @param lightIndex The index of the light in the effect to update
  18356. * @returns The light
  18357. */
  18358. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18359. /**
  18360. * Binds the lights information from the scene to the effect for the given mesh.
  18361. * @param lightIndex Light index
  18362. * @param scene The scene where the light belongs to
  18363. * @param effect The effect we are binding the data to
  18364. * @param useSpecular Defines if specular is supported
  18365. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18366. */
  18367. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18368. /**
  18369. * Sets the passed Effect "effect" with the Light information.
  18370. * @param effect The effect to update
  18371. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18372. * @returns The light
  18373. */
  18374. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18375. /**
  18376. * Returns the string "Light".
  18377. * @returns the class name
  18378. */
  18379. getClassName(): string;
  18380. /** @hidden */
  18381. readonly _isLight: boolean;
  18382. /**
  18383. * Converts the light information to a readable string for debug purpose.
  18384. * @param fullDetails Supports for multiple levels of logging within scene loading
  18385. * @returns the human readable light info
  18386. */
  18387. toString(fullDetails?: boolean): string;
  18388. /** @hidden */
  18389. protected _syncParentEnabledState(): void;
  18390. /**
  18391. * Set the enabled state of this node.
  18392. * @param value - the new enabled state
  18393. */
  18394. setEnabled(value: boolean): void;
  18395. /**
  18396. * Returns the Light associated shadow generator if any.
  18397. * @return the associated shadow generator.
  18398. */
  18399. getShadowGenerator(): Nullable<IShadowGenerator>;
  18400. /**
  18401. * Returns a Vector3, the absolute light position in the World.
  18402. * @returns the world space position of the light
  18403. */
  18404. getAbsolutePosition(): Vector3;
  18405. /**
  18406. * Specifies if the light will affect the passed mesh.
  18407. * @param mesh The mesh to test against the light
  18408. * @return true the mesh is affected otherwise, false.
  18409. */
  18410. canAffectMesh(mesh: AbstractMesh): boolean;
  18411. /**
  18412. * Sort function to order lights for rendering.
  18413. * @param a First Light object to compare to second.
  18414. * @param b Second Light object to compare first.
  18415. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18416. */
  18417. static CompareLightsPriority(a: Light, b: Light): number;
  18418. /**
  18419. * Releases resources associated with this node.
  18420. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18421. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18422. */
  18423. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18424. /**
  18425. * Returns the light type ID (integer).
  18426. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18427. */
  18428. getTypeID(): number;
  18429. /**
  18430. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18431. * @returns the scaled intensity in intensity mode unit
  18432. */
  18433. getScaledIntensity(): number;
  18434. /**
  18435. * Returns a new Light object, named "name", from the current one.
  18436. * @param name The name of the cloned light
  18437. * @param newParent The parent of this light, if it has one
  18438. * @returns the new created light
  18439. */
  18440. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18441. /**
  18442. * Serializes the current light into a Serialization object.
  18443. * @returns the serialized object.
  18444. */
  18445. serialize(): any;
  18446. /**
  18447. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18448. * This new light is named "name" and added to the passed scene.
  18449. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18450. * @param name The friendly name of the light
  18451. * @param scene The scene the new light will belong to
  18452. * @returns the constructor function
  18453. */
  18454. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18455. /**
  18456. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18457. * @param parsedLight The JSON representation of the light
  18458. * @param scene The scene to create the parsed light in
  18459. * @returns the created light after parsing
  18460. */
  18461. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18462. private _hookArrayForExcluded;
  18463. private _hookArrayForIncludedOnly;
  18464. private _resyncMeshes;
  18465. /**
  18466. * Forces the meshes to update their light related information in their rendering used effects
  18467. * @hidden Internal Use Only
  18468. */
  18469. _markMeshesAsLightDirty(): void;
  18470. /**
  18471. * Recomputes the cached photometric scale if needed.
  18472. */
  18473. private _computePhotometricScale;
  18474. /**
  18475. * Returns the Photometric Scale according to the light type and intensity mode.
  18476. */
  18477. private _getPhotometricScale;
  18478. /**
  18479. * Reorder the light in the scene according to their defined priority.
  18480. * @hidden Internal Use Only
  18481. */
  18482. _reorderLightsInScene(): void;
  18483. /**
  18484. * Prepares the list of defines specific to the light type.
  18485. * @param defines the list of defines
  18486. * @param lightIndex defines the index of the light for the effect
  18487. */
  18488. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18489. }
  18490. }
  18491. declare module BABYLON {
  18492. /**
  18493. * Configuration needed for prepass-capable materials
  18494. */
  18495. export class PrePassConfiguration {
  18496. /**
  18497. * Previous world matrices of meshes carrying this material
  18498. * Used for computing velocity
  18499. */
  18500. previousWorldMatrices: {
  18501. [index: number]: Matrix;
  18502. };
  18503. /**
  18504. * Previous view project matrix
  18505. * Used for computing velocity
  18506. */
  18507. previousViewProjection: Matrix;
  18508. /**
  18509. * Previous bones of meshes carrying this material
  18510. * Used for computing velocity
  18511. */
  18512. previousBones: {
  18513. [index: number]: Float32Array;
  18514. };
  18515. /**
  18516. * Add the required uniforms to the current list.
  18517. * @param uniforms defines the current uniform list.
  18518. */
  18519. static AddUniforms(uniforms: string[]): void;
  18520. /**
  18521. * Add the required samplers to the current list.
  18522. * @param samplers defines the current sampler list.
  18523. */
  18524. static AddSamplers(samplers: string[]): void;
  18525. /**
  18526. * Binds the material data.
  18527. * @param effect defines the effect to update
  18528. * @param scene defines the scene the material belongs to.
  18529. * @param mesh The mesh
  18530. * @param world World matrix of this mesh
  18531. * @param isFrozen Is the material frozen
  18532. */
  18533. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  18534. }
  18535. }
  18536. declare module BABYLON {
  18537. /**
  18538. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18539. * This is the base of the follow, arc rotate cameras and Free camera
  18540. * @see https://doc.babylonjs.com/features/cameras
  18541. */
  18542. export class TargetCamera extends Camera {
  18543. private static _RigCamTransformMatrix;
  18544. private static _TargetTransformMatrix;
  18545. private static _TargetFocalPoint;
  18546. private _tmpUpVector;
  18547. private _tmpTargetVector;
  18548. /**
  18549. * Define the current direction the camera is moving to
  18550. */
  18551. cameraDirection: Vector3;
  18552. /**
  18553. * Define the current rotation the camera is rotating to
  18554. */
  18555. cameraRotation: Vector2;
  18556. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18557. ignoreParentScaling: boolean;
  18558. /**
  18559. * When set, the up vector of the camera will be updated by the rotation of the camera
  18560. */
  18561. updateUpVectorFromRotation: boolean;
  18562. private _tmpQuaternion;
  18563. /**
  18564. * Define the current rotation of the camera
  18565. */
  18566. rotation: Vector3;
  18567. /**
  18568. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18569. */
  18570. rotationQuaternion: Quaternion;
  18571. /**
  18572. * Define the current speed of the camera
  18573. */
  18574. speed: number;
  18575. /**
  18576. * Add constraint to the camera to prevent it to move freely in all directions and
  18577. * around all axis.
  18578. */
  18579. noRotationConstraint: boolean;
  18580. /**
  18581. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18582. * panning
  18583. */
  18584. invertRotation: boolean;
  18585. /**
  18586. * Speed multiplier for inverse camera panning
  18587. */
  18588. inverseRotationSpeed: number;
  18589. /**
  18590. * Define the current target of the camera as an object or a position.
  18591. */
  18592. lockedTarget: any;
  18593. /** @hidden */
  18594. _currentTarget: Vector3;
  18595. /** @hidden */
  18596. _initialFocalDistance: number;
  18597. /** @hidden */
  18598. _viewMatrix: Matrix;
  18599. /** @hidden */
  18600. _camMatrix: Matrix;
  18601. /** @hidden */
  18602. _cameraTransformMatrix: Matrix;
  18603. /** @hidden */
  18604. _cameraRotationMatrix: Matrix;
  18605. /** @hidden */
  18606. _referencePoint: Vector3;
  18607. /** @hidden */
  18608. _transformedReferencePoint: Vector3;
  18609. /** @hidden */
  18610. _reset: () => void;
  18611. private _defaultUp;
  18612. /**
  18613. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18614. * This is the base of the follow, arc rotate cameras and Free camera
  18615. * @see https://doc.babylonjs.com/features/cameras
  18616. * @param name Defines the name of the camera in the scene
  18617. * @param position Defines the start position of the camera in the scene
  18618. * @param scene Defines the scene the camera belongs to
  18619. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18620. */
  18621. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18622. /**
  18623. * Gets the position in front of the camera at a given distance.
  18624. * @param distance The distance from the camera we want the position to be
  18625. * @returns the position
  18626. */
  18627. getFrontPosition(distance: number): Vector3;
  18628. /** @hidden */
  18629. _getLockedTargetPosition(): Nullable<Vector3>;
  18630. private _storedPosition;
  18631. private _storedRotation;
  18632. private _storedRotationQuaternion;
  18633. /**
  18634. * Store current camera state of the camera (fov, position, rotation, etc..)
  18635. * @returns the camera
  18636. */
  18637. storeState(): Camera;
  18638. /**
  18639. * Restored camera state. You must call storeState() first
  18640. * @returns whether it was successful or not
  18641. * @hidden
  18642. */
  18643. _restoreStateValues(): boolean;
  18644. /** @hidden */
  18645. _initCache(): void;
  18646. /** @hidden */
  18647. _updateCache(ignoreParentClass?: boolean): void;
  18648. /** @hidden */
  18649. _isSynchronizedViewMatrix(): boolean;
  18650. /** @hidden */
  18651. _computeLocalCameraSpeed(): number;
  18652. /**
  18653. * Defines the target the camera should look at.
  18654. * @param target Defines the new target as a Vector or a mesh
  18655. */
  18656. setTarget(target: Vector3): void;
  18657. /**
  18658. * Defines the target point of the camera.
  18659. * The camera looks towards it form the radius distance.
  18660. */
  18661. get target(): Vector3;
  18662. set target(value: Vector3);
  18663. /**
  18664. * Return the current target position of the camera. This value is expressed in local space.
  18665. * @returns the target position
  18666. */
  18667. getTarget(): Vector3;
  18668. /** @hidden */
  18669. _decideIfNeedsToMove(): boolean;
  18670. /** @hidden */
  18671. _updatePosition(): void;
  18672. /** @hidden */
  18673. _checkInputs(): void;
  18674. protected _updateCameraRotationMatrix(): void;
  18675. /**
  18676. * 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)
  18677. * @returns the current camera
  18678. */
  18679. private _rotateUpVectorWithCameraRotationMatrix;
  18680. private _cachedRotationZ;
  18681. private _cachedQuaternionRotationZ;
  18682. /** @hidden */
  18683. _getViewMatrix(): Matrix;
  18684. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18685. /**
  18686. * @hidden
  18687. */
  18688. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18689. /**
  18690. * @hidden
  18691. */
  18692. _updateRigCameras(): void;
  18693. private _getRigCamPositionAndTarget;
  18694. /**
  18695. * Gets the current object class name.
  18696. * @return the class name
  18697. */
  18698. getClassName(): string;
  18699. }
  18700. }
  18701. declare module BABYLON {
  18702. /**
  18703. * Gather the list of keyboard event types as constants.
  18704. */
  18705. export class KeyboardEventTypes {
  18706. /**
  18707. * The keydown event is fired when a key becomes active (pressed).
  18708. */
  18709. static readonly KEYDOWN: number;
  18710. /**
  18711. * The keyup event is fired when a key has been released.
  18712. */
  18713. static readonly KEYUP: number;
  18714. }
  18715. /**
  18716. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18717. */
  18718. export class KeyboardInfo {
  18719. /**
  18720. * Defines the type of event (KeyboardEventTypes)
  18721. */
  18722. type: number;
  18723. /**
  18724. * Defines the related dom event
  18725. */
  18726. event: KeyboardEvent;
  18727. /**
  18728. * Instantiates a new keyboard info.
  18729. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18730. * @param type Defines the type of event (KeyboardEventTypes)
  18731. * @param event Defines the related dom event
  18732. */
  18733. constructor(
  18734. /**
  18735. * Defines the type of event (KeyboardEventTypes)
  18736. */
  18737. type: number,
  18738. /**
  18739. * Defines the related dom event
  18740. */
  18741. event: KeyboardEvent);
  18742. }
  18743. /**
  18744. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18745. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18746. */
  18747. export class KeyboardInfoPre extends KeyboardInfo {
  18748. /**
  18749. * Defines the type of event (KeyboardEventTypes)
  18750. */
  18751. type: number;
  18752. /**
  18753. * Defines the related dom event
  18754. */
  18755. event: KeyboardEvent;
  18756. /**
  18757. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18758. */
  18759. skipOnPointerObservable: boolean;
  18760. /**
  18761. * Instantiates a new keyboard pre info.
  18762. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18763. * @param type Defines the type of event (KeyboardEventTypes)
  18764. * @param event Defines the related dom event
  18765. */
  18766. constructor(
  18767. /**
  18768. * Defines the type of event (KeyboardEventTypes)
  18769. */
  18770. type: number,
  18771. /**
  18772. * Defines the related dom event
  18773. */
  18774. event: KeyboardEvent);
  18775. }
  18776. }
  18777. declare module BABYLON {
  18778. /**
  18779. * Manage the keyboard inputs to control the movement of a free camera.
  18780. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18781. */
  18782. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18783. /**
  18784. * Defines the camera the input is attached to.
  18785. */
  18786. camera: FreeCamera;
  18787. /**
  18788. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18789. */
  18790. keysUp: number[];
  18791. /**
  18792. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18793. */
  18794. keysUpward: number[];
  18795. /**
  18796. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18797. */
  18798. keysDown: number[];
  18799. /**
  18800. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18801. */
  18802. keysDownward: number[];
  18803. /**
  18804. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18805. */
  18806. keysLeft: number[];
  18807. /**
  18808. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18809. */
  18810. keysRight: number[];
  18811. private _keys;
  18812. private _onCanvasBlurObserver;
  18813. private _onKeyboardObserver;
  18814. private _engine;
  18815. private _scene;
  18816. /**
  18817. * Attach the input controls to a specific dom element to get the input from.
  18818. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18819. */
  18820. attachControl(noPreventDefault?: boolean): void;
  18821. /**
  18822. * Detach the current controls from the specified dom element.
  18823. */
  18824. detachControl(): void;
  18825. /**
  18826. * Update the current camera state depending on the inputs that have been used this frame.
  18827. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18828. */
  18829. checkInputs(): void;
  18830. /**
  18831. * Gets the class name of the current intput.
  18832. * @returns the class name
  18833. */
  18834. getClassName(): string;
  18835. /** @hidden */
  18836. _onLostFocus(): void;
  18837. /**
  18838. * Get the friendly name associated with the input class.
  18839. * @returns the input friendly name
  18840. */
  18841. getSimpleName(): string;
  18842. }
  18843. }
  18844. declare module BABYLON {
  18845. /**
  18846. * Gather the list of pointer event types as constants.
  18847. */
  18848. export class PointerEventTypes {
  18849. /**
  18850. * 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.
  18851. */
  18852. static readonly POINTERDOWN: number;
  18853. /**
  18854. * The pointerup event is fired when a pointer is no longer active.
  18855. */
  18856. static readonly POINTERUP: number;
  18857. /**
  18858. * The pointermove event is fired when a pointer changes coordinates.
  18859. */
  18860. static readonly POINTERMOVE: number;
  18861. /**
  18862. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18863. */
  18864. static readonly POINTERWHEEL: number;
  18865. /**
  18866. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18867. */
  18868. static readonly POINTERPICK: number;
  18869. /**
  18870. * The pointertap event is fired when a the object has been touched and released without drag.
  18871. */
  18872. static readonly POINTERTAP: number;
  18873. /**
  18874. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18875. */
  18876. static readonly POINTERDOUBLETAP: number;
  18877. }
  18878. /**
  18879. * Base class of pointer info types.
  18880. */
  18881. export class PointerInfoBase {
  18882. /**
  18883. * Defines the type of event (PointerEventTypes)
  18884. */
  18885. type: number;
  18886. /**
  18887. * Defines the related dom event
  18888. */
  18889. event: PointerEvent | MouseWheelEvent;
  18890. /**
  18891. * Instantiates the base class of pointers info.
  18892. * @param type Defines the type of event (PointerEventTypes)
  18893. * @param event Defines the related dom event
  18894. */
  18895. constructor(
  18896. /**
  18897. * Defines the type of event (PointerEventTypes)
  18898. */
  18899. type: number,
  18900. /**
  18901. * Defines the related dom event
  18902. */
  18903. event: PointerEvent | MouseWheelEvent);
  18904. }
  18905. /**
  18906. * This class is used to store pointer related info for the onPrePointerObservable event.
  18907. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18908. */
  18909. export class PointerInfoPre extends PointerInfoBase {
  18910. /**
  18911. * Ray from a pointer if availible (eg. 6dof controller)
  18912. */
  18913. ray: Nullable<Ray>;
  18914. /**
  18915. * Defines the local position of the pointer on the canvas.
  18916. */
  18917. localPosition: Vector2;
  18918. /**
  18919. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18920. */
  18921. skipOnPointerObservable: boolean;
  18922. /**
  18923. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18924. * @param type Defines the type of event (PointerEventTypes)
  18925. * @param event Defines the related dom event
  18926. * @param localX Defines the local x coordinates of the pointer when the event occured
  18927. * @param localY Defines the local y coordinates of the pointer when the event occured
  18928. */
  18929. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18930. }
  18931. /**
  18932. * This type contains all the data related to a pointer event in Babylon.js.
  18933. * 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.
  18934. */
  18935. export class PointerInfo extends PointerInfoBase {
  18936. /**
  18937. * Defines the picking info associated to the info (if any)\
  18938. */
  18939. pickInfo: Nullable<PickingInfo>;
  18940. /**
  18941. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18942. * @param type Defines the type of event (PointerEventTypes)
  18943. * @param event Defines the related dom event
  18944. * @param pickInfo Defines the picking info associated to the info (if any)\
  18945. */
  18946. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18947. /**
  18948. * Defines the picking info associated to the info (if any)\
  18949. */
  18950. pickInfo: Nullable<PickingInfo>);
  18951. }
  18952. /**
  18953. * Data relating to a touch event on the screen.
  18954. */
  18955. export interface PointerTouch {
  18956. /**
  18957. * X coordinate of touch.
  18958. */
  18959. x: number;
  18960. /**
  18961. * Y coordinate of touch.
  18962. */
  18963. y: number;
  18964. /**
  18965. * Id of touch. Unique for each finger.
  18966. */
  18967. pointerId: number;
  18968. /**
  18969. * Event type passed from DOM.
  18970. */
  18971. type: any;
  18972. }
  18973. }
  18974. declare module BABYLON {
  18975. /**
  18976. * Manage the mouse inputs to control the movement of a free camera.
  18977. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18978. */
  18979. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18980. /**
  18981. * Define if touch is enabled in the mouse input
  18982. */
  18983. touchEnabled: boolean;
  18984. /**
  18985. * Defines the camera the input is attached to.
  18986. */
  18987. camera: FreeCamera;
  18988. /**
  18989. * Defines the buttons associated with the input to handle camera move.
  18990. */
  18991. buttons: number[];
  18992. /**
  18993. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18994. */
  18995. angularSensibility: number;
  18996. private _pointerInput;
  18997. private _onMouseMove;
  18998. private _observer;
  18999. private previousPosition;
  19000. /**
  19001. * Observable for when a pointer move event occurs containing the move offset
  19002. */
  19003. onPointerMovedObservable: Observable<{
  19004. offsetX: number;
  19005. offsetY: number;
  19006. }>;
  19007. /**
  19008. * @hidden
  19009. * If the camera should be rotated automatically based on pointer movement
  19010. */
  19011. _allowCameraRotation: boolean;
  19012. /**
  19013. * Manage the mouse inputs to control the movement of a free camera.
  19014. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19015. * @param touchEnabled Defines if touch is enabled or not
  19016. */
  19017. constructor(
  19018. /**
  19019. * Define if touch is enabled in the mouse input
  19020. */
  19021. touchEnabled?: boolean);
  19022. /**
  19023. * Attach the input controls to a specific dom element to get the input from.
  19024. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19025. */
  19026. attachControl(noPreventDefault?: boolean): void;
  19027. /**
  19028. * Called on JS contextmenu event.
  19029. * Override this method to provide functionality.
  19030. */
  19031. protected onContextMenu(evt: PointerEvent): void;
  19032. /**
  19033. * Detach the current controls from the specified dom element.
  19034. */
  19035. detachControl(): void;
  19036. /**
  19037. * Gets the class name of the current intput.
  19038. * @returns the class name
  19039. */
  19040. getClassName(): string;
  19041. /**
  19042. * Get the friendly name associated with the input class.
  19043. * @returns the input friendly name
  19044. */
  19045. getSimpleName(): string;
  19046. }
  19047. }
  19048. declare module BABYLON {
  19049. /**
  19050. * Base class for mouse wheel input..
  19051. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  19052. * for example usage.
  19053. */
  19054. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  19055. /**
  19056. * Defines the camera the input is attached to.
  19057. */
  19058. abstract camera: Camera;
  19059. /**
  19060. * How fast is the camera moves in relation to X axis mouseWheel events.
  19061. * Use negative value to reverse direction.
  19062. */
  19063. wheelPrecisionX: number;
  19064. /**
  19065. * How fast is the camera moves in relation to Y axis mouseWheel events.
  19066. * Use negative value to reverse direction.
  19067. */
  19068. wheelPrecisionY: number;
  19069. /**
  19070. * How fast is the camera moves in relation to Z axis mouseWheel events.
  19071. * Use negative value to reverse direction.
  19072. */
  19073. wheelPrecisionZ: number;
  19074. /**
  19075. * Observable for when a mouse wheel move event occurs.
  19076. */
  19077. onChangedObservable: Observable<{
  19078. wheelDeltaX: number;
  19079. wheelDeltaY: number;
  19080. wheelDeltaZ: number;
  19081. }>;
  19082. private _wheel;
  19083. private _observer;
  19084. /**
  19085. * Attach the input controls to a specific dom element to get the input from.
  19086. * @param noPreventDefault Defines whether event caught by the controls
  19087. * should call preventdefault().
  19088. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19089. */
  19090. attachControl(noPreventDefault?: boolean): void;
  19091. /**
  19092. * Detach the current controls from the specified dom element.
  19093. */
  19094. detachControl(): void;
  19095. /**
  19096. * Called for each rendered frame.
  19097. */
  19098. checkInputs(): void;
  19099. /**
  19100. * Gets the class name of the current intput.
  19101. * @returns the class name
  19102. */
  19103. getClassName(): string;
  19104. /**
  19105. * Get the friendly name associated with the input class.
  19106. * @returns the input friendly name
  19107. */
  19108. getSimpleName(): string;
  19109. /**
  19110. * Incremental value of multiple mouse wheel movements of the X axis.
  19111. * Should be zero-ed when read.
  19112. */
  19113. protected _wheelDeltaX: number;
  19114. /**
  19115. * Incremental value of multiple mouse wheel movements of the Y axis.
  19116. * Should be zero-ed when read.
  19117. */
  19118. protected _wheelDeltaY: number;
  19119. /**
  19120. * Incremental value of multiple mouse wheel movements of the Z axis.
  19121. * Should be zero-ed when read.
  19122. */
  19123. protected _wheelDeltaZ: number;
  19124. /**
  19125. * Firefox uses a different scheme to report scroll distances to other
  19126. * browsers. Rather than use complicated methods to calculate the exact
  19127. * multiple we need to apply, let's just cheat and use a constant.
  19128. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  19129. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  19130. */
  19131. private readonly _ffMultiplier;
  19132. /**
  19133. * Different event attributes for wheel data fall into a few set ranges.
  19134. * Some relevant but dated date here:
  19135. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  19136. */
  19137. private readonly _normalize;
  19138. }
  19139. }
  19140. declare module BABYLON {
  19141. /**
  19142. * Manage the mouse wheel inputs to control a free camera.
  19143. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19144. */
  19145. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  19146. /**
  19147. * Defines the camera the input is attached to.
  19148. */
  19149. camera: FreeCamera;
  19150. /**
  19151. * Gets the class name of the current input.
  19152. * @returns the class name
  19153. */
  19154. getClassName(): string;
  19155. /**
  19156. * Set which movement axis (relative to camera's orientation) the mouse
  19157. * wheel's X axis controls.
  19158. * @param axis The axis to be moved. Set null to clear.
  19159. */
  19160. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  19161. /**
  19162. * Get the configured movement axis (relative to camera's orientation) the
  19163. * mouse wheel's X axis controls.
  19164. * @returns The configured axis or null if none.
  19165. */
  19166. get wheelXMoveRelative(): Nullable<Coordinate>;
  19167. /**
  19168. * Set which movement axis (relative to camera's orientation) the mouse
  19169. * wheel's Y axis controls.
  19170. * @param axis The axis to be moved. Set null to clear.
  19171. */
  19172. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  19173. /**
  19174. * Get the configured movement axis (relative to camera's orientation) the
  19175. * mouse wheel's Y axis controls.
  19176. * @returns The configured axis or null if none.
  19177. */
  19178. get wheelYMoveRelative(): Nullable<Coordinate>;
  19179. /**
  19180. * Set which movement axis (relative to camera's orientation) the mouse
  19181. * wheel's Z axis controls.
  19182. * @param axis The axis to be moved. Set null to clear.
  19183. */
  19184. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  19185. /**
  19186. * Get the configured movement axis (relative to camera's orientation) the
  19187. * mouse wheel's Z axis controls.
  19188. * @returns The configured axis or null if none.
  19189. */
  19190. get wheelZMoveRelative(): Nullable<Coordinate>;
  19191. /**
  19192. * Set which rotation axis (relative to camera's orientation) the mouse
  19193. * wheel's X axis controls.
  19194. * @param axis The axis to be moved. Set null to clear.
  19195. */
  19196. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  19197. /**
  19198. * Get the configured rotation axis (relative to camera's orientation) the
  19199. * mouse wheel's X axis controls.
  19200. * @returns The configured axis or null if none.
  19201. */
  19202. get wheelXRotateRelative(): Nullable<Coordinate>;
  19203. /**
  19204. * Set which rotation axis (relative to camera's orientation) the mouse
  19205. * wheel's Y axis controls.
  19206. * @param axis The axis to be moved. Set null to clear.
  19207. */
  19208. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  19209. /**
  19210. * Get the configured rotation axis (relative to camera's orientation) the
  19211. * mouse wheel's Y axis controls.
  19212. * @returns The configured axis or null if none.
  19213. */
  19214. get wheelYRotateRelative(): Nullable<Coordinate>;
  19215. /**
  19216. * Set which rotation axis (relative to camera's orientation) the mouse
  19217. * wheel's Z axis controls.
  19218. * @param axis The axis to be moved. Set null to clear.
  19219. */
  19220. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  19221. /**
  19222. * Get the configured rotation axis (relative to camera's orientation) the
  19223. * mouse wheel's Z axis controls.
  19224. * @returns The configured axis or null if none.
  19225. */
  19226. get wheelZRotateRelative(): Nullable<Coordinate>;
  19227. /**
  19228. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  19229. * controls.
  19230. * @param axis The axis to be moved. Set null to clear.
  19231. */
  19232. set wheelXMoveScene(axis: Nullable<Coordinate>);
  19233. /**
  19234. * Get the configured movement axis (relative to the scene) the mouse wheel's
  19235. * X axis controls.
  19236. * @returns The configured axis or null if none.
  19237. */
  19238. get wheelXMoveScene(): Nullable<Coordinate>;
  19239. /**
  19240. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  19241. * controls.
  19242. * @param axis The axis to be moved. Set null to clear.
  19243. */
  19244. set wheelYMoveScene(axis: Nullable<Coordinate>);
  19245. /**
  19246. * Get the configured movement axis (relative to the scene) the mouse wheel's
  19247. * Y axis controls.
  19248. * @returns The configured axis or null if none.
  19249. */
  19250. get wheelYMoveScene(): Nullable<Coordinate>;
  19251. /**
  19252. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  19253. * controls.
  19254. * @param axis The axis to be moved. Set null to clear.
  19255. */
  19256. set wheelZMoveScene(axis: Nullable<Coordinate>);
  19257. /**
  19258. * Get the configured movement axis (relative to the scene) the mouse wheel's
  19259. * Z axis controls.
  19260. * @returns The configured axis or null if none.
  19261. */
  19262. get wheelZMoveScene(): Nullable<Coordinate>;
  19263. /**
  19264. * Called for each rendered frame.
  19265. */
  19266. checkInputs(): void;
  19267. private _moveRelative;
  19268. private _rotateRelative;
  19269. private _moveScene;
  19270. /**
  19271. * These are set to the desired default behaviour.
  19272. */
  19273. private _wheelXAction;
  19274. private _wheelXActionCoordinate;
  19275. private _wheelYAction;
  19276. private _wheelYActionCoordinate;
  19277. private _wheelZAction;
  19278. private _wheelZActionCoordinate;
  19279. /**
  19280. * Update the camera according to any configured properties for the 3
  19281. * mouse-wheel axis.
  19282. */
  19283. private _updateCamera;
  19284. }
  19285. }
  19286. declare module BABYLON {
  19287. /**
  19288. * Manage the touch inputs to control the movement of a free camera.
  19289. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19290. */
  19291. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19292. /**
  19293. * Define if mouse events can be treated as touch events
  19294. */
  19295. allowMouse: boolean;
  19296. /**
  19297. * Defines the camera the input is attached to.
  19298. */
  19299. camera: FreeCamera;
  19300. /**
  19301. * Defines the touch sensibility for rotation.
  19302. * The higher the faster.
  19303. */
  19304. touchAngularSensibility: number;
  19305. /**
  19306. * Defines the touch sensibility for move.
  19307. * The higher the faster.
  19308. */
  19309. touchMoveSensibility: number;
  19310. private _offsetX;
  19311. private _offsetY;
  19312. private _pointerPressed;
  19313. private _pointerInput?;
  19314. private _observer;
  19315. private _onLostFocus;
  19316. /**
  19317. * Manage the touch inputs to control the movement of a free camera.
  19318. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19319. * @param allowMouse Defines if mouse events can be treated as touch events
  19320. */
  19321. constructor(
  19322. /**
  19323. * Define if mouse events can be treated as touch events
  19324. */
  19325. allowMouse?: boolean);
  19326. /**
  19327. * Attach the input controls to a specific dom element to get the input from.
  19328. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19329. */
  19330. attachControl(noPreventDefault?: boolean): void;
  19331. /**
  19332. * Detach the current controls from the specified dom element.
  19333. * @param element Defines the element to stop listening the inputs from
  19334. */
  19335. detachControl(): void;
  19336. /**
  19337. * Update the current camera state depending on the inputs that have been used this frame.
  19338. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19339. */
  19340. checkInputs(): void;
  19341. /**
  19342. * Gets the class name of the current intput.
  19343. * @returns the class name
  19344. */
  19345. getClassName(): string;
  19346. /**
  19347. * Get the friendly name associated with the input class.
  19348. * @returns the input friendly name
  19349. */
  19350. getSimpleName(): string;
  19351. }
  19352. }
  19353. declare module BABYLON {
  19354. /**
  19355. * Default Inputs manager for the FreeCamera.
  19356. * It groups all the default supported inputs for ease of use.
  19357. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19358. */
  19359. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19360. /**
  19361. * @hidden
  19362. */
  19363. _mouseInput: Nullable<FreeCameraMouseInput>;
  19364. /**
  19365. * @hidden
  19366. */
  19367. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  19368. /**
  19369. * Instantiates a new FreeCameraInputsManager.
  19370. * @param camera Defines the camera the inputs belong to
  19371. */
  19372. constructor(camera: FreeCamera);
  19373. /**
  19374. * Add keyboard input support to the input manager.
  19375. * @returns the current input manager
  19376. */
  19377. addKeyboard(): FreeCameraInputsManager;
  19378. /**
  19379. * Add mouse input support to the input manager.
  19380. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19381. * @returns the current input manager
  19382. */
  19383. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19384. /**
  19385. * Removes the mouse input support from the manager
  19386. * @returns the current input manager
  19387. */
  19388. removeMouse(): FreeCameraInputsManager;
  19389. /**
  19390. * Add mouse wheel input support to the input manager.
  19391. * @returns the current input manager
  19392. */
  19393. addMouseWheel(): FreeCameraInputsManager;
  19394. /**
  19395. * Removes the mouse wheel input support from the manager
  19396. * @returns the current input manager
  19397. */
  19398. removeMouseWheel(): FreeCameraInputsManager;
  19399. /**
  19400. * Add touch input support to the input manager.
  19401. * @returns the current input manager
  19402. */
  19403. addTouch(): FreeCameraInputsManager;
  19404. /**
  19405. * Remove all attached input methods from a camera
  19406. */
  19407. clear(): void;
  19408. }
  19409. }
  19410. declare module BABYLON {
  19411. /**
  19412. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19413. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19414. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19415. */
  19416. export class FreeCamera extends TargetCamera {
  19417. /**
  19418. * Define the collision ellipsoid of the camera.
  19419. * This is helpful to simulate a camera body like the player body around the camera
  19420. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19421. */
  19422. ellipsoid: Vector3;
  19423. /**
  19424. * Define an offset for the position of the ellipsoid around the camera.
  19425. * This can be helpful to determine the center of the body near the gravity center of the body
  19426. * instead of its head.
  19427. */
  19428. ellipsoidOffset: Vector3;
  19429. /**
  19430. * Enable or disable collisions of the camera with the rest of the scene objects.
  19431. */
  19432. checkCollisions: boolean;
  19433. /**
  19434. * Enable or disable gravity on the camera.
  19435. */
  19436. applyGravity: boolean;
  19437. /**
  19438. * Define the input manager associated to the camera.
  19439. */
  19440. inputs: FreeCameraInputsManager;
  19441. /**
  19442. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19443. * Higher values reduce sensitivity.
  19444. */
  19445. get angularSensibility(): number;
  19446. /**
  19447. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19448. * Higher values reduce sensitivity.
  19449. */
  19450. set angularSensibility(value: number);
  19451. /**
  19452. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19453. */
  19454. get keysUp(): number[];
  19455. set keysUp(value: number[]);
  19456. /**
  19457. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19458. */
  19459. get keysUpward(): number[];
  19460. set keysUpward(value: number[]);
  19461. /**
  19462. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19463. */
  19464. get keysDown(): number[];
  19465. set keysDown(value: number[]);
  19466. /**
  19467. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19468. */
  19469. get keysDownward(): number[];
  19470. set keysDownward(value: number[]);
  19471. /**
  19472. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19473. */
  19474. get keysLeft(): number[];
  19475. set keysLeft(value: number[]);
  19476. /**
  19477. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19478. */
  19479. get keysRight(): number[];
  19480. set keysRight(value: number[]);
  19481. /**
  19482. * Event raised when the camera collide with a mesh in the scene.
  19483. */
  19484. onCollide: (collidedMesh: AbstractMesh) => void;
  19485. private _collider;
  19486. private _needMoveForGravity;
  19487. private _oldPosition;
  19488. private _diffPosition;
  19489. private _newPosition;
  19490. /** @hidden */
  19491. _localDirection: Vector3;
  19492. /** @hidden */
  19493. _transformedDirection: Vector3;
  19494. /**
  19495. * Instantiates a Free Camera.
  19496. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19497. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19498. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19499. * @param name Define the name of the camera in the scene
  19500. * @param position Define the start position of the camera in the scene
  19501. * @param scene Define the scene the camera belongs to
  19502. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19503. */
  19504. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19505. /**
  19506. * Attached controls to the current camera.
  19507. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19508. */
  19509. attachControl(noPreventDefault?: boolean): void;
  19510. /**
  19511. * Detach the current controls from the camera.
  19512. * The camera will stop reacting to inputs.
  19513. */
  19514. detachControl(): void;
  19515. private _collisionMask;
  19516. /**
  19517. * Define a collision mask to limit the list of object the camera can collide with
  19518. */
  19519. get collisionMask(): number;
  19520. set collisionMask(mask: number);
  19521. /** @hidden */
  19522. _collideWithWorld(displacement: Vector3): void;
  19523. private _onCollisionPositionChange;
  19524. /** @hidden */
  19525. _checkInputs(): void;
  19526. /** @hidden */
  19527. _decideIfNeedsToMove(): boolean;
  19528. /** @hidden */
  19529. _updatePosition(): void;
  19530. /**
  19531. * Destroy the camera and release the current resources hold by it.
  19532. */
  19533. dispose(): void;
  19534. /**
  19535. * Gets the current object class name.
  19536. * @return the class name
  19537. */
  19538. getClassName(): string;
  19539. }
  19540. }
  19541. declare module BABYLON {
  19542. /**
  19543. * Represents a gamepad control stick position
  19544. */
  19545. export class StickValues {
  19546. /**
  19547. * The x component of the control stick
  19548. */
  19549. x: number;
  19550. /**
  19551. * The y component of the control stick
  19552. */
  19553. y: number;
  19554. /**
  19555. * Initializes the gamepad x and y control stick values
  19556. * @param x The x component of the gamepad control stick value
  19557. * @param y The y component of the gamepad control stick value
  19558. */
  19559. constructor(
  19560. /**
  19561. * The x component of the control stick
  19562. */
  19563. x: number,
  19564. /**
  19565. * The y component of the control stick
  19566. */
  19567. y: number);
  19568. }
  19569. /**
  19570. * An interface which manages callbacks for gamepad button changes
  19571. */
  19572. export interface GamepadButtonChanges {
  19573. /**
  19574. * Called when a gamepad has been changed
  19575. */
  19576. changed: boolean;
  19577. /**
  19578. * Called when a gamepad press event has been triggered
  19579. */
  19580. pressChanged: boolean;
  19581. /**
  19582. * Called when a touch event has been triggered
  19583. */
  19584. touchChanged: boolean;
  19585. /**
  19586. * Called when a value has changed
  19587. */
  19588. valueChanged: boolean;
  19589. }
  19590. /**
  19591. * Represents a gamepad
  19592. */
  19593. export class Gamepad {
  19594. /**
  19595. * The id of the gamepad
  19596. */
  19597. id: string;
  19598. /**
  19599. * The index of the gamepad
  19600. */
  19601. index: number;
  19602. /**
  19603. * The browser gamepad
  19604. */
  19605. browserGamepad: any;
  19606. /**
  19607. * Specifies what type of gamepad this represents
  19608. */
  19609. type: number;
  19610. private _leftStick;
  19611. private _rightStick;
  19612. /** @hidden */
  19613. _isConnected: boolean;
  19614. private _leftStickAxisX;
  19615. private _leftStickAxisY;
  19616. private _rightStickAxisX;
  19617. private _rightStickAxisY;
  19618. /**
  19619. * Triggered when the left control stick has been changed
  19620. */
  19621. private _onleftstickchanged;
  19622. /**
  19623. * Triggered when the right control stick has been changed
  19624. */
  19625. private _onrightstickchanged;
  19626. /**
  19627. * Represents a gamepad controller
  19628. */
  19629. static GAMEPAD: number;
  19630. /**
  19631. * Represents a generic controller
  19632. */
  19633. static GENERIC: number;
  19634. /**
  19635. * Represents an XBox controller
  19636. */
  19637. static XBOX: number;
  19638. /**
  19639. * Represents a pose-enabled controller
  19640. */
  19641. static POSE_ENABLED: number;
  19642. /**
  19643. * Represents an Dual Shock controller
  19644. */
  19645. static DUALSHOCK: number;
  19646. /**
  19647. * Specifies whether the left control stick should be Y-inverted
  19648. */
  19649. protected _invertLeftStickY: boolean;
  19650. /**
  19651. * Specifies if the gamepad has been connected
  19652. */
  19653. get isConnected(): boolean;
  19654. /**
  19655. * Initializes the gamepad
  19656. * @param id The id of the gamepad
  19657. * @param index The index of the gamepad
  19658. * @param browserGamepad The browser gamepad
  19659. * @param leftStickX The x component of the left joystick
  19660. * @param leftStickY The y component of the left joystick
  19661. * @param rightStickX The x component of the right joystick
  19662. * @param rightStickY The y component of the right joystick
  19663. */
  19664. constructor(
  19665. /**
  19666. * The id of the gamepad
  19667. */
  19668. id: string,
  19669. /**
  19670. * The index of the gamepad
  19671. */
  19672. index: number,
  19673. /**
  19674. * The browser gamepad
  19675. */
  19676. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19677. /**
  19678. * Callback triggered when the left joystick has changed
  19679. * @param callback
  19680. */
  19681. onleftstickchanged(callback: (values: StickValues) => void): void;
  19682. /**
  19683. * Callback triggered when the right joystick has changed
  19684. * @param callback
  19685. */
  19686. onrightstickchanged(callback: (values: StickValues) => void): void;
  19687. /**
  19688. * Gets the left joystick
  19689. */
  19690. get leftStick(): StickValues;
  19691. /**
  19692. * Sets the left joystick values
  19693. */
  19694. set leftStick(newValues: StickValues);
  19695. /**
  19696. * Gets the right joystick
  19697. */
  19698. get rightStick(): StickValues;
  19699. /**
  19700. * Sets the right joystick value
  19701. */
  19702. set rightStick(newValues: StickValues);
  19703. /**
  19704. * Updates the gamepad joystick positions
  19705. */
  19706. update(): void;
  19707. /**
  19708. * Disposes the gamepad
  19709. */
  19710. dispose(): void;
  19711. }
  19712. /**
  19713. * Represents a generic gamepad
  19714. */
  19715. export class GenericPad extends Gamepad {
  19716. private _buttons;
  19717. private _onbuttondown;
  19718. private _onbuttonup;
  19719. /**
  19720. * Observable triggered when a button has been pressed
  19721. */
  19722. onButtonDownObservable: Observable<number>;
  19723. /**
  19724. * Observable triggered when a button has been released
  19725. */
  19726. onButtonUpObservable: Observable<number>;
  19727. /**
  19728. * Callback triggered when a button has been pressed
  19729. * @param callback Called when a button has been pressed
  19730. */
  19731. onbuttondown(callback: (buttonPressed: number) => void): void;
  19732. /**
  19733. * Callback triggered when a button has been released
  19734. * @param callback Called when a button has been released
  19735. */
  19736. onbuttonup(callback: (buttonReleased: number) => void): void;
  19737. /**
  19738. * Initializes the generic gamepad
  19739. * @param id The id of the generic gamepad
  19740. * @param index The index of the generic gamepad
  19741. * @param browserGamepad The browser gamepad
  19742. */
  19743. constructor(id: string, index: number, browserGamepad: any);
  19744. private _setButtonValue;
  19745. /**
  19746. * Updates the generic gamepad
  19747. */
  19748. update(): void;
  19749. /**
  19750. * Disposes the generic gamepad
  19751. */
  19752. dispose(): void;
  19753. }
  19754. }
  19755. declare module BABYLON {
  19756. /**
  19757. * Defines the types of pose enabled controllers that are supported
  19758. */
  19759. export enum PoseEnabledControllerType {
  19760. /**
  19761. * HTC Vive
  19762. */
  19763. VIVE = 0,
  19764. /**
  19765. * Oculus Rift
  19766. */
  19767. OCULUS = 1,
  19768. /**
  19769. * Windows mixed reality
  19770. */
  19771. WINDOWS = 2,
  19772. /**
  19773. * Samsung gear VR
  19774. */
  19775. GEAR_VR = 3,
  19776. /**
  19777. * Google Daydream
  19778. */
  19779. DAYDREAM = 4,
  19780. /**
  19781. * Generic
  19782. */
  19783. GENERIC = 5
  19784. }
  19785. /**
  19786. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19787. */
  19788. export interface MutableGamepadButton {
  19789. /**
  19790. * Value of the button/trigger
  19791. */
  19792. value: number;
  19793. /**
  19794. * If the button/trigger is currently touched
  19795. */
  19796. touched: boolean;
  19797. /**
  19798. * If the button/trigger is currently pressed
  19799. */
  19800. pressed: boolean;
  19801. }
  19802. /**
  19803. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19804. * @hidden
  19805. */
  19806. export interface ExtendedGamepadButton extends GamepadButton {
  19807. /**
  19808. * If the button/trigger is currently pressed
  19809. */
  19810. readonly pressed: boolean;
  19811. /**
  19812. * If the button/trigger is currently touched
  19813. */
  19814. readonly touched: boolean;
  19815. /**
  19816. * Value of the button/trigger
  19817. */
  19818. readonly value: number;
  19819. }
  19820. /** @hidden */
  19821. export interface _GamePadFactory {
  19822. /**
  19823. * Returns whether or not the current gamepad can be created for this type of controller.
  19824. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19825. * @returns true if it can be created, otherwise false
  19826. */
  19827. canCreate(gamepadInfo: any): boolean;
  19828. /**
  19829. * Creates a new instance of the Gamepad.
  19830. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19831. * @returns the new gamepad instance
  19832. */
  19833. create(gamepadInfo: any): Gamepad;
  19834. }
  19835. /**
  19836. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19837. */
  19838. export class PoseEnabledControllerHelper {
  19839. /** @hidden */
  19840. static _ControllerFactories: _GamePadFactory[];
  19841. /** @hidden */
  19842. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19843. /**
  19844. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19845. * @param vrGamepad the gamepad to initialized
  19846. * @returns a vr controller of the type the gamepad identified as
  19847. */
  19848. static InitiateController(vrGamepad: any): Gamepad;
  19849. }
  19850. /**
  19851. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19852. */
  19853. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19854. /**
  19855. * If the controller is used in a webXR session
  19856. */
  19857. isXR: boolean;
  19858. private _deviceRoomPosition;
  19859. private _deviceRoomRotationQuaternion;
  19860. /**
  19861. * The device position in babylon space
  19862. */
  19863. devicePosition: Vector3;
  19864. /**
  19865. * The device rotation in babylon space
  19866. */
  19867. deviceRotationQuaternion: Quaternion;
  19868. /**
  19869. * The scale factor of the device in babylon space
  19870. */
  19871. deviceScaleFactor: number;
  19872. /**
  19873. * (Likely devicePosition should be used instead) The device position in its room space
  19874. */
  19875. position: Vector3;
  19876. /**
  19877. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19878. */
  19879. rotationQuaternion: Quaternion;
  19880. /**
  19881. * The type of controller (Eg. Windows mixed reality)
  19882. */
  19883. controllerType: PoseEnabledControllerType;
  19884. protected _calculatedPosition: Vector3;
  19885. private _calculatedRotation;
  19886. /**
  19887. * The raw pose from the device
  19888. */
  19889. rawPose: DevicePose;
  19890. private _trackPosition;
  19891. private _maxRotationDistFromHeadset;
  19892. private _draggedRoomRotation;
  19893. /**
  19894. * @hidden
  19895. */
  19896. _disableTrackPosition(fixedPosition: Vector3): void;
  19897. /**
  19898. * Internal, the mesh attached to the controller
  19899. * @hidden
  19900. */
  19901. _mesh: Nullable<AbstractMesh>;
  19902. private _poseControlledCamera;
  19903. private _leftHandSystemQuaternion;
  19904. /**
  19905. * Internal, matrix used to convert room space to babylon space
  19906. * @hidden
  19907. */
  19908. _deviceToWorld: Matrix;
  19909. /**
  19910. * Node to be used when casting a ray from the controller
  19911. * @hidden
  19912. */
  19913. _pointingPoseNode: Nullable<TransformNode>;
  19914. /**
  19915. * Name of the child mesh that can be used to cast a ray from the controller
  19916. */
  19917. static readonly POINTING_POSE: string;
  19918. /**
  19919. * Creates a new PoseEnabledController from a gamepad
  19920. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19921. */
  19922. constructor(browserGamepad: any);
  19923. private _workingMatrix;
  19924. /**
  19925. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19926. */
  19927. update(): void;
  19928. /**
  19929. * Updates only the pose device and mesh without doing any button event checking
  19930. */
  19931. protected _updatePoseAndMesh(): void;
  19932. /**
  19933. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19934. * @param poseData raw pose fromthe device
  19935. */
  19936. updateFromDevice(poseData: DevicePose): void;
  19937. /**
  19938. * @hidden
  19939. */
  19940. _meshAttachedObservable: Observable<AbstractMesh>;
  19941. /**
  19942. * Attaches a mesh to the controller
  19943. * @param mesh the mesh to be attached
  19944. */
  19945. attachToMesh(mesh: AbstractMesh): void;
  19946. /**
  19947. * Attaches the controllers mesh to a camera
  19948. * @param camera the camera the mesh should be attached to
  19949. */
  19950. attachToPoseControlledCamera(camera: TargetCamera): void;
  19951. /**
  19952. * Disposes of the controller
  19953. */
  19954. dispose(): void;
  19955. /**
  19956. * The mesh that is attached to the controller
  19957. */
  19958. get mesh(): Nullable<AbstractMesh>;
  19959. /**
  19960. * Gets the ray of the controller in the direction the controller is pointing
  19961. * @param length the length the resulting ray should be
  19962. * @returns a ray in the direction the controller is pointing
  19963. */
  19964. getForwardRay(length?: number): Ray;
  19965. }
  19966. }
  19967. declare module BABYLON {
  19968. /**
  19969. * Defines the WebVRController object that represents controllers tracked in 3D space
  19970. */
  19971. export abstract class WebVRController extends PoseEnabledController {
  19972. /**
  19973. * Internal, the default controller model for the controller
  19974. */
  19975. protected _defaultModel: Nullable<AbstractMesh>;
  19976. /**
  19977. * Fired when the trigger state has changed
  19978. */
  19979. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19980. /**
  19981. * Fired when the main button state has changed
  19982. */
  19983. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19984. /**
  19985. * Fired when the secondary button state has changed
  19986. */
  19987. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19988. /**
  19989. * Fired when the pad state has changed
  19990. */
  19991. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19992. /**
  19993. * Fired when controllers stick values have changed
  19994. */
  19995. onPadValuesChangedObservable: Observable<StickValues>;
  19996. /**
  19997. * Array of button availible on the controller
  19998. */
  19999. protected _buttons: Array<MutableGamepadButton>;
  20000. private _onButtonStateChange;
  20001. /**
  20002. * Fired when a controller button's state has changed
  20003. * @param callback the callback containing the button that was modified
  20004. */
  20005. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  20006. /**
  20007. * X and Y axis corresponding to the controllers joystick
  20008. */
  20009. pad: StickValues;
  20010. /**
  20011. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  20012. */
  20013. hand: string;
  20014. /**
  20015. * The default controller model for the controller
  20016. */
  20017. get defaultModel(): Nullable<AbstractMesh>;
  20018. /**
  20019. * Creates a new WebVRController from a gamepad
  20020. * @param vrGamepad the gamepad that the WebVRController should be created from
  20021. */
  20022. constructor(vrGamepad: any);
  20023. /**
  20024. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  20025. */
  20026. update(): void;
  20027. /**
  20028. * Function to be called when a button is modified
  20029. */
  20030. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  20031. /**
  20032. * Loads a mesh and attaches it to the controller
  20033. * @param scene the scene the mesh should be added to
  20034. * @param meshLoaded callback for when the mesh has been loaded
  20035. */
  20036. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  20037. private _setButtonValue;
  20038. private _changes;
  20039. private _checkChanges;
  20040. /**
  20041. * Disposes of th webVRCOntroller
  20042. */
  20043. dispose(): void;
  20044. }
  20045. }
  20046. declare module BABYLON {
  20047. /**
  20048. * The HemisphericLight simulates the ambient environment light,
  20049. * so the passed direction is the light reflection direction, not the incoming direction.
  20050. */
  20051. export class HemisphericLight extends Light {
  20052. /**
  20053. * The groundColor is the light in the opposite direction to the one specified during creation.
  20054. * 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.
  20055. */
  20056. groundColor: Color3;
  20057. /**
  20058. * The light reflection direction, not the incoming direction.
  20059. */
  20060. direction: Vector3;
  20061. /**
  20062. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  20063. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  20064. * The HemisphericLight can't cast shadows.
  20065. * Documentation : https://doc.babylonjs.com/babylon101/lights
  20066. * @param name The friendly name of the light
  20067. * @param direction The direction of the light reflection
  20068. * @param scene The scene the light belongs to
  20069. */
  20070. constructor(name: string, direction: Vector3, scene: Scene);
  20071. protected _buildUniformLayout(): void;
  20072. /**
  20073. * Returns the string "HemisphericLight".
  20074. * @return The class name
  20075. */
  20076. getClassName(): string;
  20077. /**
  20078. * Sets the HemisphericLight direction towards the passed target (Vector3).
  20079. * Returns the updated direction.
  20080. * @param target The target the direction should point to
  20081. * @return The computed direction
  20082. */
  20083. setDirectionToTarget(target: Vector3): Vector3;
  20084. /**
  20085. * Returns the shadow generator associated to the light.
  20086. * @returns Always null for hemispheric lights because it does not support shadows.
  20087. */
  20088. getShadowGenerator(): Nullable<IShadowGenerator>;
  20089. /**
  20090. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  20091. * @param effect The effect to update
  20092. * @param lightIndex The index of the light in the effect to update
  20093. * @returns The hemispheric light
  20094. */
  20095. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  20096. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  20097. /**
  20098. * Computes the world matrix of the node
  20099. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20100. * @param useWasUpdatedFlag defines a reserved property
  20101. * @returns the world matrix
  20102. */
  20103. computeWorldMatrix(): Matrix;
  20104. /**
  20105. * Returns the integer 3.
  20106. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20107. */
  20108. getTypeID(): number;
  20109. /**
  20110. * Prepares the list of defines specific to the light type.
  20111. * @param defines the list of defines
  20112. * @param lightIndex defines the index of the light for the effect
  20113. */
  20114. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20115. }
  20116. }
  20117. declare module BABYLON {
  20118. /** @hidden */
  20119. export var vrMultiviewToSingleviewPixelShader: {
  20120. name: string;
  20121. shader: string;
  20122. };
  20123. }
  20124. declare module BABYLON {
  20125. /**
  20126. * Renders to multiple views with a single draw call
  20127. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20128. */
  20129. export class MultiviewRenderTarget extends RenderTargetTexture {
  20130. /**
  20131. * Creates a multiview render target
  20132. * @param scene scene used with the render target
  20133. * @param size the size of the render target (used for each view)
  20134. */
  20135. constructor(scene: Scene, size?: number | {
  20136. width: number;
  20137. height: number;
  20138. } | {
  20139. ratio: number;
  20140. });
  20141. /**
  20142. * @hidden
  20143. * @param faceIndex the face index, if its a cube texture
  20144. */
  20145. _bindFrameBuffer(faceIndex?: number): void;
  20146. /**
  20147. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20148. * @returns the view count
  20149. */
  20150. getViewCount(): number;
  20151. }
  20152. }
  20153. declare module BABYLON {
  20154. interface Engine {
  20155. /**
  20156. * Creates a new multiview render target
  20157. * @param width defines the width of the texture
  20158. * @param height defines the height of the texture
  20159. * @returns the created multiview texture
  20160. */
  20161. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20162. /**
  20163. * Binds a multiview framebuffer to be drawn to
  20164. * @param multiviewTexture texture to bind
  20165. */
  20166. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20167. }
  20168. interface Camera {
  20169. /**
  20170. * @hidden
  20171. * 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)
  20172. */
  20173. _useMultiviewToSingleView: boolean;
  20174. /**
  20175. * @hidden
  20176. * 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)
  20177. */
  20178. _multiviewTexture: Nullable<RenderTargetTexture>;
  20179. /**
  20180. * @hidden
  20181. * ensures the multiview texture of the camera exists and has the specified width/height
  20182. * @param width height to set on the multiview texture
  20183. * @param height width to set on the multiview texture
  20184. */
  20185. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20186. }
  20187. interface Scene {
  20188. /** @hidden */
  20189. _transformMatrixR: Matrix;
  20190. /** @hidden */
  20191. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20192. /** @hidden */
  20193. _createMultiviewUbo(): void;
  20194. /** @hidden */
  20195. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20196. /** @hidden */
  20197. _renderMultiviewToSingleView(camera: Camera): void;
  20198. }
  20199. }
  20200. declare module BABYLON {
  20201. /**
  20202. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20203. * This will not be used for webXR as it supports displaying texture arrays directly
  20204. */
  20205. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20206. /**
  20207. * Gets a string identifying the name of the class
  20208. * @returns "VRMultiviewToSingleviewPostProcess" string
  20209. */
  20210. getClassName(): string;
  20211. /**
  20212. * Initializes a VRMultiviewToSingleview
  20213. * @param name name of the post process
  20214. * @param camera camera to be applied to
  20215. * @param scaleFactor scaling factor to the size of the output texture
  20216. */
  20217. constructor(name: string, camera: Camera, scaleFactor: number);
  20218. }
  20219. }
  20220. declare module BABYLON {
  20221. /**
  20222. * Interface used to define additional presentation attributes
  20223. */
  20224. export interface IVRPresentationAttributes {
  20225. /**
  20226. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20227. */
  20228. highRefreshRate: boolean;
  20229. /**
  20230. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20231. */
  20232. foveationLevel: number;
  20233. }
  20234. interface Engine {
  20235. /** @hidden */
  20236. _vrDisplay: any;
  20237. /** @hidden */
  20238. _vrSupported: boolean;
  20239. /** @hidden */
  20240. _oldSize: Size;
  20241. /** @hidden */
  20242. _oldHardwareScaleFactor: number;
  20243. /** @hidden */
  20244. _vrExclusivePointerMode: boolean;
  20245. /** @hidden */
  20246. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20247. /** @hidden */
  20248. _onVRDisplayPointerRestricted: () => void;
  20249. /** @hidden */
  20250. _onVRDisplayPointerUnrestricted: () => void;
  20251. /** @hidden */
  20252. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20253. /** @hidden */
  20254. _onVrDisplayDisconnect: Nullable<() => void>;
  20255. /** @hidden */
  20256. _onVrDisplayPresentChange: Nullable<() => void>;
  20257. /**
  20258. * Observable signaled when VR display mode changes
  20259. */
  20260. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20261. /**
  20262. * Observable signaled when VR request present is complete
  20263. */
  20264. onVRRequestPresentComplete: Observable<boolean>;
  20265. /**
  20266. * Observable signaled when VR request present starts
  20267. */
  20268. onVRRequestPresentStart: Observable<Engine>;
  20269. /**
  20270. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20271. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20272. */
  20273. isInVRExclusivePointerMode: boolean;
  20274. /**
  20275. * Gets a boolean indicating if a webVR device was detected
  20276. * @returns true if a webVR device was detected
  20277. */
  20278. isVRDevicePresent(): boolean;
  20279. /**
  20280. * Gets the current webVR device
  20281. * @returns the current webVR device (or null)
  20282. */
  20283. getVRDevice(): any;
  20284. /**
  20285. * Initializes a webVR display and starts listening to display change events
  20286. * The onVRDisplayChangedObservable will be notified upon these changes
  20287. * @returns A promise containing a VRDisplay and if vr is supported
  20288. */
  20289. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20290. /** @hidden */
  20291. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20292. /**
  20293. * Gets or sets the presentation attributes used to configure VR rendering
  20294. */
  20295. vrPresentationAttributes?: IVRPresentationAttributes;
  20296. /**
  20297. * Call this function to switch to webVR mode
  20298. * Will do nothing if webVR is not supported or if there is no webVR device
  20299. * @param options the webvr options provided to the camera. mainly used for multiview
  20300. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20301. */
  20302. enableVR(options: WebVROptions): void;
  20303. /** @hidden */
  20304. _onVRFullScreenTriggered(): void;
  20305. }
  20306. }
  20307. declare module BABYLON {
  20308. /**
  20309. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20310. * IMPORTANT!! The data is right-hand data.
  20311. * @export
  20312. * @interface DevicePose
  20313. */
  20314. export interface DevicePose {
  20315. /**
  20316. * The position of the device, values in array are [x,y,z].
  20317. */
  20318. readonly position: Nullable<Float32Array>;
  20319. /**
  20320. * The linearVelocity of the device, values in array are [x,y,z].
  20321. */
  20322. readonly linearVelocity: Nullable<Float32Array>;
  20323. /**
  20324. * The linearAcceleration of the device, values in array are [x,y,z].
  20325. */
  20326. readonly linearAcceleration: Nullable<Float32Array>;
  20327. /**
  20328. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20329. */
  20330. readonly orientation: Nullable<Float32Array>;
  20331. /**
  20332. * The angularVelocity of the device, values in array are [x,y,z].
  20333. */
  20334. readonly angularVelocity: Nullable<Float32Array>;
  20335. /**
  20336. * The angularAcceleration of the device, values in array are [x,y,z].
  20337. */
  20338. readonly angularAcceleration: Nullable<Float32Array>;
  20339. }
  20340. /**
  20341. * Interface representing a pose controlled object in Babylon.
  20342. * A pose controlled object has both regular pose values as well as pose values
  20343. * from an external device such as a VR head mounted display
  20344. */
  20345. export interface PoseControlled {
  20346. /**
  20347. * The position of the object in babylon space.
  20348. */
  20349. position: Vector3;
  20350. /**
  20351. * The rotation quaternion of the object in babylon space.
  20352. */
  20353. rotationQuaternion: Quaternion;
  20354. /**
  20355. * The position of the device in babylon space.
  20356. */
  20357. devicePosition?: Vector3;
  20358. /**
  20359. * The rotation quaternion of the device in babylon space.
  20360. */
  20361. deviceRotationQuaternion: Quaternion;
  20362. /**
  20363. * The raw pose coming from the device.
  20364. */
  20365. rawPose: Nullable<DevicePose>;
  20366. /**
  20367. * The scale of the device to be used when translating from device space to babylon space.
  20368. */
  20369. deviceScaleFactor: number;
  20370. /**
  20371. * Updates the poseControlled values based on the input device pose.
  20372. * @param poseData the pose data to update the object with
  20373. */
  20374. updateFromDevice(poseData: DevicePose): void;
  20375. }
  20376. /**
  20377. * Set of options to customize the webVRCamera
  20378. */
  20379. export interface WebVROptions {
  20380. /**
  20381. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20382. */
  20383. trackPosition?: boolean;
  20384. /**
  20385. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20386. */
  20387. positionScale?: number;
  20388. /**
  20389. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20390. */
  20391. displayName?: string;
  20392. /**
  20393. * Should the native controller meshes be initialized. (default: true)
  20394. */
  20395. controllerMeshes?: boolean;
  20396. /**
  20397. * Creating a default HemiLight only on controllers. (default: true)
  20398. */
  20399. defaultLightingOnControllers?: boolean;
  20400. /**
  20401. * If you don't want to use the default VR button of the helper. (default: false)
  20402. */
  20403. useCustomVRButton?: boolean;
  20404. /**
  20405. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20406. */
  20407. customVRButton?: HTMLButtonElement;
  20408. /**
  20409. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20410. */
  20411. rayLength?: number;
  20412. /**
  20413. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20414. */
  20415. defaultHeight?: number;
  20416. /**
  20417. * If multiview should be used if availible (default: false)
  20418. */
  20419. useMultiview?: boolean;
  20420. }
  20421. /**
  20422. * This represents a WebVR camera.
  20423. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20424. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20425. */
  20426. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20427. private webVROptions;
  20428. /**
  20429. * @hidden
  20430. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20431. */
  20432. _vrDevice: any;
  20433. /**
  20434. * The rawPose of the vrDevice.
  20435. */
  20436. rawPose: Nullable<DevicePose>;
  20437. private _onVREnabled;
  20438. private _specsVersion;
  20439. private _attached;
  20440. private _frameData;
  20441. protected _descendants: Array<Node>;
  20442. private _deviceRoomPosition;
  20443. /** @hidden */
  20444. _deviceRoomRotationQuaternion: Quaternion;
  20445. private _standingMatrix;
  20446. /**
  20447. * Represents device position in babylon space.
  20448. */
  20449. devicePosition: Vector3;
  20450. /**
  20451. * Represents device rotation in babylon space.
  20452. */
  20453. deviceRotationQuaternion: Quaternion;
  20454. /**
  20455. * The scale of the device to be used when translating from device space to babylon space.
  20456. */
  20457. deviceScaleFactor: number;
  20458. private _deviceToWorld;
  20459. private _worldToDevice;
  20460. /**
  20461. * References to the webVR controllers for the vrDevice.
  20462. */
  20463. controllers: Array<WebVRController>;
  20464. /**
  20465. * Emits an event when a controller is attached.
  20466. */
  20467. onControllersAttachedObservable: Observable<WebVRController[]>;
  20468. /**
  20469. * Emits an event when a controller's mesh has been loaded;
  20470. */
  20471. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20472. /**
  20473. * Emits an event when the HMD's pose has been updated.
  20474. */
  20475. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20476. private _poseSet;
  20477. /**
  20478. * If the rig cameras be used as parent instead of this camera.
  20479. */
  20480. rigParenting: boolean;
  20481. private _lightOnControllers;
  20482. private _defaultHeight?;
  20483. /**
  20484. * Instantiates a WebVRFreeCamera.
  20485. * @param name The name of the WebVRFreeCamera
  20486. * @param position The starting anchor position for the camera
  20487. * @param scene The scene the camera belongs to
  20488. * @param webVROptions a set of customizable options for the webVRCamera
  20489. */
  20490. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20491. /**
  20492. * Gets the device distance from the ground in meters.
  20493. * @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.
  20494. */
  20495. deviceDistanceToRoomGround(): number;
  20496. /**
  20497. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20498. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20499. */
  20500. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20501. /**
  20502. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20503. * @returns A promise with a boolean set to if the standing matrix is supported.
  20504. */
  20505. useStandingMatrixAsync(): Promise<boolean>;
  20506. /**
  20507. * Disposes the camera
  20508. */
  20509. dispose(): void;
  20510. /**
  20511. * Gets a vrController by name.
  20512. * @param name The name of the controller to retreive
  20513. * @returns the controller matching the name specified or null if not found
  20514. */
  20515. getControllerByName(name: string): Nullable<WebVRController>;
  20516. private _leftController;
  20517. /**
  20518. * The controller corresponding to the users left hand.
  20519. */
  20520. get leftController(): Nullable<WebVRController>;
  20521. private _rightController;
  20522. /**
  20523. * The controller corresponding to the users right hand.
  20524. */
  20525. get rightController(): Nullable<WebVRController>;
  20526. /**
  20527. * Casts a ray forward from the vrCamera's gaze.
  20528. * @param length Length of the ray (default: 100)
  20529. * @returns the ray corresponding to the gaze
  20530. */
  20531. getForwardRay(length?: number): Ray;
  20532. /**
  20533. * @hidden
  20534. * Updates the camera based on device's frame data
  20535. */
  20536. _checkInputs(): void;
  20537. /**
  20538. * Updates the poseControlled values based on the input device pose.
  20539. * @param poseData Pose coming from the device
  20540. */
  20541. updateFromDevice(poseData: DevicePose): void;
  20542. private _detachIfAttached;
  20543. /**
  20544. * WebVR's attach control will start broadcasting frames to the device.
  20545. * Note that in certain browsers (chrome for example) this function must be called
  20546. * within a user-interaction callback. Example:
  20547. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20548. *
  20549. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20550. */
  20551. attachControl(noPreventDefault?: boolean): void;
  20552. /**
  20553. * Detaches the camera from the html element and disables VR
  20554. */
  20555. detachControl(): void;
  20556. /**
  20557. * @returns the name of this class
  20558. */
  20559. getClassName(): string;
  20560. /**
  20561. * Calls resetPose on the vrDisplay
  20562. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20563. */
  20564. resetToCurrentRotation(): void;
  20565. /**
  20566. * @hidden
  20567. * Updates the rig cameras (left and right eye)
  20568. */
  20569. _updateRigCameras(): void;
  20570. private _workingVector;
  20571. private _oneVector;
  20572. private _workingMatrix;
  20573. private updateCacheCalled;
  20574. private _correctPositionIfNotTrackPosition;
  20575. /**
  20576. * @hidden
  20577. * Updates the cached values of the camera
  20578. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20579. */
  20580. _updateCache(ignoreParentClass?: boolean): void;
  20581. /**
  20582. * @hidden
  20583. * Get current device position in babylon world
  20584. */
  20585. _computeDevicePosition(): void;
  20586. /**
  20587. * Updates the current device position and rotation in the babylon world
  20588. */
  20589. update(): void;
  20590. /**
  20591. * @hidden
  20592. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20593. * @returns an identity matrix
  20594. */
  20595. _getViewMatrix(): Matrix;
  20596. private _tmpMatrix;
  20597. /**
  20598. * This function is called by the two RIG cameras.
  20599. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20600. * @hidden
  20601. */
  20602. _getWebVRViewMatrix(): Matrix;
  20603. /** @hidden */
  20604. _getWebVRProjectionMatrix(): Matrix;
  20605. private _onGamepadConnectedObserver;
  20606. private _onGamepadDisconnectedObserver;
  20607. private _updateCacheWhenTrackingDisabledObserver;
  20608. /**
  20609. * Initializes the controllers and their meshes
  20610. */
  20611. initControllers(): void;
  20612. }
  20613. }
  20614. declare module BABYLON {
  20615. /**
  20616. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20617. *
  20618. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20619. *
  20620. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20621. */
  20622. export class MaterialHelper {
  20623. /**
  20624. * Bind the current view position to an effect.
  20625. * @param effect The effect to be bound
  20626. * @param scene The scene the eyes position is used from
  20627. * @param variableName name of the shader variable that will hold the eye position
  20628. */
  20629. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20630. /**
  20631. * Helps preparing the defines values about the UVs in used in the effect.
  20632. * UVs are shared as much as we can accross channels in the shaders.
  20633. * @param texture The texture we are preparing the UVs for
  20634. * @param defines The defines to update
  20635. * @param key The channel key "diffuse", "specular"... used in the shader
  20636. */
  20637. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20638. /**
  20639. * Binds a texture matrix value to its corrsponding uniform
  20640. * @param texture The texture to bind the matrix for
  20641. * @param uniformBuffer The uniform buffer receivin the data
  20642. * @param key The channel key "diffuse", "specular"... used in the shader
  20643. */
  20644. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20645. /**
  20646. * Gets the current status of the fog (should it be enabled?)
  20647. * @param mesh defines the mesh to evaluate for fog support
  20648. * @param scene defines the hosting scene
  20649. * @returns true if fog must be enabled
  20650. */
  20651. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20652. /**
  20653. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20654. * @param mesh defines the current mesh
  20655. * @param scene defines the current scene
  20656. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20657. * @param pointsCloud defines if point cloud rendering has to be turned on
  20658. * @param fogEnabled defines if fog has to be turned on
  20659. * @param alphaTest defines if alpha testing has to be turned on
  20660. * @param defines defines the current list of defines
  20661. */
  20662. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20663. /**
  20664. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20665. * @param scene defines the current scene
  20666. * @param engine defines the current engine
  20667. * @param defines specifies the list of active defines
  20668. * @param useInstances defines if instances have to be turned on
  20669. * @param useClipPlane defines if clip plane have to be turned on
  20670. * @param useInstances defines if instances have to be turned on
  20671. * @param useThinInstances defines if thin instances have to be turned on
  20672. */
  20673. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20674. /**
  20675. * Prepares the defines for bones
  20676. * @param mesh The mesh containing the geometry data we will draw
  20677. * @param defines The defines to update
  20678. */
  20679. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20680. /**
  20681. * Prepares the defines for morph targets
  20682. * @param mesh The mesh containing the geometry data we will draw
  20683. * @param defines The defines to update
  20684. */
  20685. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20686. /**
  20687. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20688. * @param mesh The mesh containing the geometry data we will draw
  20689. * @param defines The defines to update
  20690. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20691. * @param useBones Precise whether bones should be used or not (override mesh info)
  20692. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20693. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20694. * @returns false if defines are considered not dirty and have not been checked
  20695. */
  20696. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20697. /**
  20698. * Prepares the defines related to multiview
  20699. * @param scene The scene we are intending to draw
  20700. * @param defines The defines to update
  20701. */
  20702. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20703. /**
  20704. * Prepares the defines related to the prepass
  20705. * @param scene The scene we are intending to draw
  20706. * @param defines The defines to update
  20707. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20708. */
  20709. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20710. /**
  20711. * Prepares the defines related to the light information passed in parameter
  20712. * @param scene The scene we are intending to draw
  20713. * @param mesh The mesh the effect is compiling for
  20714. * @param light The light the effect is compiling for
  20715. * @param lightIndex The index of the light
  20716. * @param defines The defines to update
  20717. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20718. * @param state Defines the current state regarding what is needed (normals, etc...)
  20719. */
  20720. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20721. needNormals: boolean;
  20722. needRebuild: boolean;
  20723. shadowEnabled: boolean;
  20724. specularEnabled: boolean;
  20725. lightmapMode: boolean;
  20726. }): void;
  20727. /**
  20728. * Prepares the defines related to the light information passed in parameter
  20729. * @param scene The scene we are intending to draw
  20730. * @param mesh The mesh the effect is compiling for
  20731. * @param defines The defines to update
  20732. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20733. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20734. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20735. * @returns true if normals will be required for the rest of the effect
  20736. */
  20737. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20738. /**
  20739. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20740. * @param lightIndex defines the light index
  20741. * @param uniformsList The uniform list
  20742. * @param samplersList The sampler list
  20743. * @param projectedLightTexture defines if projected texture must be used
  20744. * @param uniformBuffersList defines an optional list of uniform buffers
  20745. */
  20746. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20747. /**
  20748. * Prepares the uniforms and samplers list to be used in the effect
  20749. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20750. * @param samplersList The sampler list
  20751. * @param defines The defines helping in the list generation
  20752. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20753. */
  20754. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20755. /**
  20756. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20757. * @param defines The defines to update while falling back
  20758. * @param fallbacks The authorized effect fallbacks
  20759. * @param maxSimultaneousLights The maximum number of lights allowed
  20760. * @param rank the current rank of the Effect
  20761. * @returns The newly affected rank
  20762. */
  20763. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20764. private static _TmpMorphInfluencers;
  20765. /**
  20766. * Prepares the list of attributes required for morph targets according to the effect defines.
  20767. * @param attribs The current list of supported attribs
  20768. * @param mesh The mesh to prepare the morph targets attributes for
  20769. * @param influencers The number of influencers
  20770. */
  20771. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20772. /**
  20773. * Prepares the list of attributes required for morph targets according to the effect defines.
  20774. * @param attribs The current list of supported attribs
  20775. * @param mesh The mesh to prepare the morph targets attributes for
  20776. * @param defines The current Defines of the effect
  20777. */
  20778. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20779. /**
  20780. * Prepares the list of attributes required for bones according to the effect defines.
  20781. * @param attribs The current list of supported attribs
  20782. * @param mesh The mesh to prepare the bones attributes for
  20783. * @param defines The current Defines of the effect
  20784. * @param fallbacks The current efffect fallback strategy
  20785. */
  20786. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20787. /**
  20788. * Check and prepare the list of attributes required for instances according to the effect defines.
  20789. * @param attribs The current list of supported attribs
  20790. * @param defines The current MaterialDefines of the effect
  20791. */
  20792. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20793. /**
  20794. * Add the list of attributes required for instances to the attribs array.
  20795. * @param attribs The current list of supported attribs
  20796. */
  20797. static PushAttributesForInstances(attribs: string[]): void;
  20798. /**
  20799. * Binds the light information to the effect.
  20800. * @param light The light containing the generator
  20801. * @param effect The effect we are binding the data to
  20802. * @param lightIndex The light index in the effect used to render
  20803. */
  20804. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20805. /**
  20806. * Binds the lights information from the scene to the effect for the given mesh.
  20807. * @param light Light to bind
  20808. * @param lightIndex Light index
  20809. * @param scene The scene where the light belongs to
  20810. * @param effect The effect we are binding the data to
  20811. * @param useSpecular Defines if specular is supported
  20812. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20813. */
  20814. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20815. /**
  20816. * Binds the lights information from the scene to the effect for the given mesh.
  20817. * @param scene The scene the lights belongs to
  20818. * @param mesh The mesh we are binding the information to render
  20819. * @param effect The effect we are binding the data to
  20820. * @param defines The generated defines for the effect
  20821. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20822. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20823. */
  20824. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20825. private static _tempFogColor;
  20826. /**
  20827. * Binds the fog information from the scene to the effect for the given mesh.
  20828. * @param scene The scene the lights belongs to
  20829. * @param mesh The mesh we are binding the information to render
  20830. * @param effect The effect we are binding the data to
  20831. * @param linearSpace Defines if the fog effect is applied in linear space
  20832. */
  20833. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20834. /**
  20835. * Binds the bones information from the mesh to the effect.
  20836. * @param mesh The mesh we are binding the information to render
  20837. * @param effect The effect we are binding the data to
  20838. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  20839. */
  20840. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  20841. private static _CopyBonesTransformationMatrices;
  20842. /**
  20843. * Binds the morph targets information from the mesh to the effect.
  20844. * @param abstractMesh The mesh we are binding the information to render
  20845. * @param effect The effect we are binding the data to
  20846. */
  20847. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20848. /**
  20849. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20850. * @param defines The generated defines used in the effect
  20851. * @param effect The effect we are binding the data to
  20852. * @param scene The scene we are willing to render with logarithmic scale for
  20853. */
  20854. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20855. /**
  20856. * Binds the clip plane information from the scene to the effect.
  20857. * @param scene The scene the clip plane information are extracted from
  20858. * @param effect The effect we are binding the data to
  20859. */
  20860. static BindClipPlane(effect: Effect, scene: Scene): void;
  20861. }
  20862. }
  20863. declare module BABYLON {
  20864. /**
  20865. * Block used to expose an input value
  20866. */
  20867. export class InputBlock extends NodeMaterialBlock {
  20868. private _mode;
  20869. private _associatedVariableName;
  20870. private _storedValue;
  20871. private _valueCallback;
  20872. private _type;
  20873. private _animationType;
  20874. /** Gets or set a value used to limit the range of float values */
  20875. min: number;
  20876. /** Gets or set a value used to limit the range of float values */
  20877. max: number;
  20878. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20879. isBoolean: boolean;
  20880. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20881. matrixMode: number;
  20882. /** @hidden */
  20883. _systemValue: Nullable<NodeMaterialSystemValues>;
  20884. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20885. isConstant: boolean;
  20886. /** Gets or sets the group to use to display this block in the Inspector */
  20887. groupInInspector: string;
  20888. /** Gets an observable raised when the value is changed */
  20889. onValueChangedObservable: Observable<InputBlock>;
  20890. /**
  20891. * Gets or sets the connection point type (default is float)
  20892. */
  20893. get type(): NodeMaterialBlockConnectionPointTypes;
  20894. /**
  20895. * Creates a new InputBlock
  20896. * @param name defines the block name
  20897. * @param target defines the target of that block (Vertex by default)
  20898. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20899. */
  20900. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20901. /**
  20902. * Validates if a name is a reserve word.
  20903. * @param newName the new name to be given to the node.
  20904. * @returns false if the name is a reserve word, else true.
  20905. */
  20906. validateBlockName(newName: string): boolean;
  20907. /**
  20908. * Gets the output component
  20909. */
  20910. get output(): NodeMaterialConnectionPoint;
  20911. /**
  20912. * Set the source of this connection point to a vertex attribute
  20913. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20914. * @returns the current connection point
  20915. */
  20916. setAsAttribute(attributeName?: string): InputBlock;
  20917. /**
  20918. * Set the source of this connection point to a system value
  20919. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20920. * @returns the current connection point
  20921. */
  20922. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20923. /**
  20924. * Gets or sets the value of that point.
  20925. * Please note that this value will be ignored if valueCallback is defined
  20926. */
  20927. get value(): any;
  20928. set value(value: any);
  20929. /**
  20930. * Gets or sets a callback used to get the value of that point.
  20931. * Please note that setting this value will force the connection point to ignore the value property
  20932. */
  20933. get valueCallback(): () => any;
  20934. set valueCallback(value: () => any);
  20935. /**
  20936. * Gets or sets the associated variable name in the shader
  20937. */
  20938. get associatedVariableName(): string;
  20939. set associatedVariableName(value: string);
  20940. /** Gets or sets the type of animation applied to the input */
  20941. get animationType(): AnimatedInputBlockTypes;
  20942. set animationType(value: AnimatedInputBlockTypes);
  20943. /**
  20944. * Gets a boolean indicating that this connection point not defined yet
  20945. */
  20946. get isUndefined(): boolean;
  20947. /**
  20948. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20949. * In this case the connection point name must be the name of the uniform to use.
  20950. * Can only be set on inputs
  20951. */
  20952. get isUniform(): boolean;
  20953. set isUniform(value: boolean);
  20954. /**
  20955. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20956. * In this case the connection point name must be the name of the attribute to use
  20957. * Can only be set on inputs
  20958. */
  20959. get isAttribute(): boolean;
  20960. set isAttribute(value: boolean);
  20961. /**
  20962. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20963. * Can only be set on exit points
  20964. */
  20965. get isVarying(): boolean;
  20966. set isVarying(value: boolean);
  20967. /**
  20968. * Gets a boolean indicating that the current connection point is a system value
  20969. */
  20970. get isSystemValue(): boolean;
  20971. /**
  20972. * Gets or sets the current well known value or null if not defined as a system value
  20973. */
  20974. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20975. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20976. /**
  20977. * Gets the current class name
  20978. * @returns the class name
  20979. */
  20980. getClassName(): string;
  20981. /**
  20982. * Animate the input if animationType !== None
  20983. * @param scene defines the rendering scene
  20984. */
  20985. animate(scene: Scene): void;
  20986. private _emitDefine;
  20987. initialize(state: NodeMaterialBuildState): void;
  20988. /**
  20989. * Set the input block to its default value (based on its type)
  20990. */
  20991. setDefaultValue(): void;
  20992. private _emitConstant;
  20993. /** @hidden */
  20994. get _noContextSwitch(): boolean;
  20995. private _emit;
  20996. /** @hidden */
  20997. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20998. /** @hidden */
  20999. _transmit(effect: Effect, scene: Scene): void;
  21000. protected _buildBlock(state: NodeMaterialBuildState): void;
  21001. protected _dumpPropertiesCode(): string;
  21002. dispose(): void;
  21003. serialize(): any;
  21004. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21005. }
  21006. }
  21007. declare module BABYLON {
  21008. /**
  21009. * Enum used to define the compatibility state between two connection points
  21010. */
  21011. export enum NodeMaterialConnectionPointCompatibilityStates {
  21012. /** Points are compatibles */
  21013. Compatible = 0,
  21014. /** Points are incompatible because of their types */
  21015. TypeIncompatible = 1,
  21016. /** Points are incompatible because of their targets (vertex vs fragment) */
  21017. TargetIncompatible = 2
  21018. }
  21019. /**
  21020. * Defines the direction of a connection point
  21021. */
  21022. export enum NodeMaterialConnectionPointDirection {
  21023. /** Input */
  21024. Input = 0,
  21025. /** Output */
  21026. Output = 1
  21027. }
  21028. /**
  21029. * Defines a connection point for a block
  21030. */
  21031. export class NodeMaterialConnectionPoint {
  21032. /** @hidden */
  21033. _ownerBlock: NodeMaterialBlock;
  21034. /** @hidden */
  21035. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  21036. private _endpoints;
  21037. private _associatedVariableName;
  21038. private _direction;
  21039. /** @hidden */
  21040. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21041. /** @hidden */
  21042. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21043. private _type;
  21044. /** @hidden */
  21045. _enforceAssociatedVariableName: boolean;
  21046. /** Gets the direction of the point */
  21047. get direction(): NodeMaterialConnectionPointDirection;
  21048. /** Indicates that this connection point needs dual validation before being connected to another point */
  21049. needDualDirectionValidation: boolean;
  21050. /**
  21051. * Gets or sets the additional types supported by this connection point
  21052. */
  21053. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21054. /**
  21055. * Gets or sets the additional types excluded by this connection point
  21056. */
  21057. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21058. /**
  21059. * Observable triggered when this point is connected
  21060. */
  21061. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21062. /**
  21063. * Gets or sets the associated variable name in the shader
  21064. */
  21065. get associatedVariableName(): string;
  21066. set associatedVariableName(value: string);
  21067. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21068. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21069. /**
  21070. * Gets or sets the connection point type (default is float)
  21071. */
  21072. get type(): NodeMaterialBlockConnectionPointTypes;
  21073. set type(value: NodeMaterialBlockConnectionPointTypes);
  21074. /**
  21075. * Gets or sets the connection point name
  21076. */
  21077. name: string;
  21078. /**
  21079. * Gets or sets the connection point name
  21080. */
  21081. displayName: string;
  21082. /**
  21083. * Gets or sets a boolean indicating that this connection point can be omitted
  21084. */
  21085. isOptional: boolean;
  21086. /**
  21087. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  21088. */
  21089. isExposedOnFrame: boolean;
  21090. /**
  21091. * Gets or sets number indicating the position that the port is exposed to on a frame
  21092. */
  21093. exposedPortPosition: number;
  21094. /**
  21095. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21096. */
  21097. define: string;
  21098. /** @hidden */
  21099. _prioritizeVertex: boolean;
  21100. private _target;
  21101. /** Gets or sets the target of that connection point */
  21102. get target(): NodeMaterialBlockTargets;
  21103. set target(value: NodeMaterialBlockTargets);
  21104. /**
  21105. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21106. */
  21107. get isConnected(): boolean;
  21108. /**
  21109. * Gets a boolean indicating that the current point is connected to an input block
  21110. */
  21111. get isConnectedToInputBlock(): boolean;
  21112. /**
  21113. * Gets a the connected input block (if any)
  21114. */
  21115. get connectInputBlock(): Nullable<InputBlock>;
  21116. /** Get the other side of the connection (if any) */
  21117. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21118. /** Get the block that owns this connection point */
  21119. get ownerBlock(): NodeMaterialBlock;
  21120. /** Get the block connected on the other side of this connection (if any) */
  21121. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21122. /** Get the block connected on the endpoints of this connection (if any) */
  21123. get connectedBlocks(): Array<NodeMaterialBlock>;
  21124. /** Gets the list of connected endpoints */
  21125. get endpoints(): NodeMaterialConnectionPoint[];
  21126. /** Gets a boolean indicating if that output point is connected to at least one input */
  21127. get hasEndpoints(): boolean;
  21128. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21129. get isConnectedInVertexShader(): boolean;
  21130. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21131. get isConnectedInFragmentShader(): boolean;
  21132. /**
  21133. * Creates a block suitable to be used as an input for this input point.
  21134. * If null is returned, a block based on the point type will be created.
  21135. * @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
  21136. */
  21137. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21138. /**
  21139. * Creates a new connection point
  21140. * @param name defines the connection point name
  21141. * @param ownerBlock defines the block hosting this connection point
  21142. * @param direction defines the direction of the connection point
  21143. */
  21144. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21145. /**
  21146. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21147. * @returns the class name
  21148. */
  21149. getClassName(): string;
  21150. /**
  21151. * Gets a boolean indicating if the current point can be connected to another point
  21152. * @param connectionPoint defines the other connection point
  21153. * @returns a boolean
  21154. */
  21155. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21156. /**
  21157. * Gets a number indicating if the current point can be connected to another point
  21158. * @param connectionPoint defines the other connection point
  21159. * @returns a number defining the compatibility state
  21160. */
  21161. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21162. /**
  21163. * Connect this point to another connection point
  21164. * @param connectionPoint defines the other connection point
  21165. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21166. * @returns the current connection point
  21167. */
  21168. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21169. /**
  21170. * Disconnect this point from one of his endpoint
  21171. * @param endpoint defines the other connection point
  21172. * @returns the current connection point
  21173. */
  21174. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21175. /**
  21176. * Serializes this point in a JSON representation
  21177. * @param isInput defines if the connection point is an input (default is true)
  21178. * @returns the serialized point object
  21179. */
  21180. serialize(isInput?: boolean): any;
  21181. /**
  21182. * Release resources
  21183. */
  21184. dispose(): void;
  21185. }
  21186. }
  21187. declare module BABYLON {
  21188. /**
  21189. * Enum used to define the material modes
  21190. */
  21191. export enum NodeMaterialModes {
  21192. /** Regular material */
  21193. Material = 0,
  21194. /** For post process */
  21195. PostProcess = 1,
  21196. /** For particle system */
  21197. Particle = 2,
  21198. /** For procedural texture */
  21199. ProceduralTexture = 3
  21200. }
  21201. }
  21202. declare module BABYLON {
  21203. /**
  21204. * Block used to read a texture from a sampler
  21205. */
  21206. export class TextureBlock extends NodeMaterialBlock {
  21207. private _defineName;
  21208. private _linearDefineName;
  21209. private _gammaDefineName;
  21210. private _tempTextureRead;
  21211. private _samplerName;
  21212. private _transformedUVName;
  21213. private _textureTransformName;
  21214. private _textureInfoName;
  21215. private _mainUVName;
  21216. private _mainUVDefineName;
  21217. private _fragmentOnly;
  21218. /**
  21219. * Gets or sets the texture associated with the node
  21220. */
  21221. texture: Nullable<Texture>;
  21222. /**
  21223. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21224. */
  21225. convertToGammaSpace: boolean;
  21226. /**
  21227. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21228. */
  21229. convertToLinearSpace: boolean;
  21230. /**
  21231. * Create a new TextureBlock
  21232. * @param name defines the block name
  21233. */
  21234. constructor(name: string, fragmentOnly?: boolean);
  21235. /**
  21236. * Gets the current class name
  21237. * @returns the class name
  21238. */
  21239. getClassName(): string;
  21240. /**
  21241. * Gets the uv input component
  21242. */
  21243. get uv(): NodeMaterialConnectionPoint;
  21244. /**
  21245. * Gets the rgba output component
  21246. */
  21247. get rgba(): NodeMaterialConnectionPoint;
  21248. /**
  21249. * Gets the rgb output component
  21250. */
  21251. get rgb(): NodeMaterialConnectionPoint;
  21252. /**
  21253. * Gets the r output component
  21254. */
  21255. get r(): NodeMaterialConnectionPoint;
  21256. /**
  21257. * Gets the g output component
  21258. */
  21259. get g(): NodeMaterialConnectionPoint;
  21260. /**
  21261. * Gets the b output component
  21262. */
  21263. get b(): NodeMaterialConnectionPoint;
  21264. /**
  21265. * Gets the a output component
  21266. */
  21267. get a(): NodeMaterialConnectionPoint;
  21268. get target(): NodeMaterialBlockTargets;
  21269. autoConfigure(material: NodeMaterial): void;
  21270. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21271. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21272. isReady(): boolean;
  21273. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21274. private get _isMixed();
  21275. private _injectVertexCode;
  21276. private _writeTextureRead;
  21277. private _writeOutput;
  21278. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21279. protected _dumpPropertiesCode(): string;
  21280. serialize(): any;
  21281. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21282. }
  21283. }
  21284. declare module BABYLON {
  21285. /** @hidden */
  21286. export var reflectionFunction: {
  21287. name: string;
  21288. shader: string;
  21289. };
  21290. }
  21291. declare module BABYLON {
  21292. /**
  21293. * Base block used to read a reflection texture from a sampler
  21294. */
  21295. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21296. /** @hidden */
  21297. _define3DName: string;
  21298. /** @hidden */
  21299. _defineCubicName: string;
  21300. /** @hidden */
  21301. _defineExplicitName: string;
  21302. /** @hidden */
  21303. _defineProjectionName: string;
  21304. /** @hidden */
  21305. _defineLocalCubicName: string;
  21306. /** @hidden */
  21307. _defineSphericalName: string;
  21308. /** @hidden */
  21309. _definePlanarName: string;
  21310. /** @hidden */
  21311. _defineEquirectangularName: string;
  21312. /** @hidden */
  21313. _defineMirroredEquirectangularFixedName: string;
  21314. /** @hidden */
  21315. _defineEquirectangularFixedName: string;
  21316. /** @hidden */
  21317. _defineSkyboxName: string;
  21318. /** @hidden */
  21319. _defineOppositeZ: string;
  21320. /** @hidden */
  21321. _cubeSamplerName: string;
  21322. /** @hidden */
  21323. _2DSamplerName: string;
  21324. protected _positionUVWName: string;
  21325. protected _directionWName: string;
  21326. protected _reflectionVectorName: string;
  21327. /** @hidden */
  21328. _reflectionCoordsName: string;
  21329. /** @hidden */
  21330. _reflectionMatrixName: string;
  21331. protected _reflectionColorName: string;
  21332. /**
  21333. * Gets or sets the texture associated with the node
  21334. */
  21335. texture: Nullable<BaseTexture>;
  21336. /**
  21337. * Create a new ReflectionTextureBaseBlock
  21338. * @param name defines the block name
  21339. */
  21340. constructor(name: string);
  21341. /**
  21342. * Gets the current class name
  21343. * @returns the class name
  21344. */
  21345. getClassName(): string;
  21346. /**
  21347. * Gets the world position input component
  21348. */
  21349. abstract get position(): NodeMaterialConnectionPoint;
  21350. /**
  21351. * Gets the world position input component
  21352. */
  21353. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21354. /**
  21355. * Gets the world normal input component
  21356. */
  21357. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21358. /**
  21359. * Gets the world input component
  21360. */
  21361. abstract get world(): NodeMaterialConnectionPoint;
  21362. /**
  21363. * Gets the camera (or eye) position component
  21364. */
  21365. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21366. /**
  21367. * Gets the view input component
  21368. */
  21369. abstract get view(): NodeMaterialConnectionPoint;
  21370. protected _getTexture(): Nullable<BaseTexture>;
  21371. autoConfigure(material: NodeMaterial): void;
  21372. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21373. isReady(): boolean;
  21374. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21375. /**
  21376. * Gets the code to inject in the vertex shader
  21377. * @param state current state of the node material building
  21378. * @returns the shader code
  21379. */
  21380. handleVertexSide(state: NodeMaterialBuildState): string;
  21381. /**
  21382. * Handles the inits for the fragment code path
  21383. * @param state node material build state
  21384. */
  21385. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21386. /**
  21387. * Generates the reflection coords code for the fragment code path
  21388. * @param worldNormalVarName name of the world normal variable
  21389. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21390. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21391. * @returns the shader code
  21392. */
  21393. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21394. /**
  21395. * Generates the reflection color code for the fragment code path
  21396. * @param lodVarName name of the lod variable
  21397. * @param swizzleLookupTexture swizzle to use for the final color variable
  21398. * @returns the shader code
  21399. */
  21400. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21401. /**
  21402. * Generates the code corresponding to the connected output points
  21403. * @param state node material build state
  21404. * @param varName name of the variable to output
  21405. * @returns the shader code
  21406. */
  21407. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21408. protected _buildBlock(state: NodeMaterialBuildState): this;
  21409. protected _dumpPropertiesCode(): string;
  21410. serialize(): any;
  21411. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21412. }
  21413. }
  21414. declare module BABYLON {
  21415. /**
  21416. * Defines a connection point to be used for points with a custom object type
  21417. */
  21418. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21419. private _blockType;
  21420. private _blockName;
  21421. private _nameForCheking?;
  21422. /**
  21423. * Creates a new connection point
  21424. * @param name defines the connection point name
  21425. * @param ownerBlock defines the block hosting this connection point
  21426. * @param direction defines the direction of the connection point
  21427. */
  21428. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21429. /**
  21430. * Gets a number indicating if the current point can be connected to another point
  21431. * @param connectionPoint defines the other connection point
  21432. * @returns a number defining the compatibility state
  21433. */
  21434. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21435. /**
  21436. * Creates a block suitable to be used as an input for this input point.
  21437. * If null is returned, a block based on the point type will be created.
  21438. * @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
  21439. */
  21440. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21441. }
  21442. }
  21443. declare module BABYLON {
  21444. /**
  21445. * Enum defining the type of properties that can be edited in the property pages in the NME
  21446. */
  21447. export enum PropertyTypeForEdition {
  21448. /** property is a boolean */
  21449. Boolean = 0,
  21450. /** property is a float */
  21451. Float = 1,
  21452. /** property is a Vector2 */
  21453. Vector2 = 2,
  21454. /** property is a list of values */
  21455. List = 3
  21456. }
  21457. /**
  21458. * Interface that defines an option in a variable of type list
  21459. */
  21460. export interface IEditablePropertyListOption {
  21461. /** label of the option */
  21462. "label": string;
  21463. /** value of the option */
  21464. "value": number;
  21465. }
  21466. /**
  21467. * Interface that defines the options available for an editable property
  21468. */
  21469. export interface IEditablePropertyOption {
  21470. /** min value */
  21471. "min"?: number;
  21472. /** max value */
  21473. "max"?: number;
  21474. /** notifiers: indicates which actions to take when the property is changed */
  21475. "notifiers"?: {
  21476. /** the material should be rebuilt */
  21477. "rebuild"?: boolean;
  21478. /** the preview should be updated */
  21479. "update"?: boolean;
  21480. };
  21481. /** list of the options for a variable of type list */
  21482. "options"?: IEditablePropertyListOption[];
  21483. }
  21484. /**
  21485. * Interface that describes an editable property
  21486. */
  21487. export interface IPropertyDescriptionForEdition {
  21488. /** name of the property */
  21489. "propertyName": string;
  21490. /** display name of the property */
  21491. "displayName": string;
  21492. /** type of the property */
  21493. "type": PropertyTypeForEdition;
  21494. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21495. "groupName": string;
  21496. /** options for the property */
  21497. "options": IEditablePropertyOption;
  21498. }
  21499. /**
  21500. * Decorator that flags a property in a node material block as being editable
  21501. */
  21502. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21503. }
  21504. declare module BABYLON {
  21505. /**
  21506. * Block used to implement the refraction part of the sub surface module of the PBR material
  21507. */
  21508. export class RefractionBlock extends NodeMaterialBlock {
  21509. /** @hidden */
  21510. _define3DName: string;
  21511. /** @hidden */
  21512. _refractionMatrixName: string;
  21513. /** @hidden */
  21514. _defineLODRefractionAlpha: string;
  21515. /** @hidden */
  21516. _defineLinearSpecularRefraction: string;
  21517. /** @hidden */
  21518. _defineOppositeZ: string;
  21519. /** @hidden */
  21520. _cubeSamplerName: string;
  21521. /** @hidden */
  21522. _2DSamplerName: string;
  21523. /** @hidden */
  21524. _vRefractionMicrosurfaceInfosName: string;
  21525. /** @hidden */
  21526. _vRefractionInfosName: string;
  21527. private _scene;
  21528. /**
  21529. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21530. * Materials half opaque for instance using refraction could benefit from this control.
  21531. */
  21532. linkRefractionWithTransparency: boolean;
  21533. /**
  21534. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21535. */
  21536. invertRefractionY: boolean;
  21537. /**
  21538. * Gets or sets the texture associated with the node
  21539. */
  21540. texture: Nullable<BaseTexture>;
  21541. /**
  21542. * Create a new RefractionBlock
  21543. * @param name defines the block name
  21544. */
  21545. constructor(name: string);
  21546. /**
  21547. * Gets the current class name
  21548. * @returns the class name
  21549. */
  21550. getClassName(): string;
  21551. /**
  21552. * Gets the intensity input component
  21553. */
  21554. get intensity(): NodeMaterialConnectionPoint;
  21555. /**
  21556. * Gets the index of refraction input component
  21557. */
  21558. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21559. /**
  21560. * Gets the tint at distance input component
  21561. */
  21562. get tintAtDistance(): NodeMaterialConnectionPoint;
  21563. /**
  21564. * Gets the view input component
  21565. */
  21566. get view(): NodeMaterialConnectionPoint;
  21567. /**
  21568. * Gets the refraction object output component
  21569. */
  21570. get refraction(): NodeMaterialConnectionPoint;
  21571. /**
  21572. * Returns true if the block has a texture
  21573. */
  21574. get hasTexture(): boolean;
  21575. protected _getTexture(): Nullable<BaseTexture>;
  21576. autoConfigure(material: NodeMaterial): void;
  21577. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21578. isReady(): boolean;
  21579. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21580. /**
  21581. * Gets the main code of the block (fragment side)
  21582. * @param state current state of the node material building
  21583. * @returns the shader code
  21584. */
  21585. getCode(state: NodeMaterialBuildState): string;
  21586. protected _buildBlock(state: NodeMaterialBuildState): this;
  21587. protected _dumpPropertiesCode(): string;
  21588. serialize(): any;
  21589. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21590. }
  21591. }
  21592. declare module BABYLON {
  21593. /**
  21594. * Base block used as input for post process
  21595. */
  21596. export class CurrentScreenBlock extends NodeMaterialBlock {
  21597. private _samplerName;
  21598. private _linearDefineName;
  21599. private _gammaDefineName;
  21600. private _mainUVName;
  21601. private _tempTextureRead;
  21602. /**
  21603. * Gets or sets the texture associated with the node
  21604. */
  21605. texture: Nullable<BaseTexture>;
  21606. /**
  21607. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21608. */
  21609. convertToGammaSpace: boolean;
  21610. /**
  21611. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21612. */
  21613. convertToLinearSpace: boolean;
  21614. /**
  21615. * Create a new CurrentScreenBlock
  21616. * @param name defines the block name
  21617. */
  21618. constructor(name: string);
  21619. /**
  21620. * Gets the current class name
  21621. * @returns the class name
  21622. */
  21623. getClassName(): string;
  21624. /**
  21625. * Gets the uv input component
  21626. */
  21627. get uv(): NodeMaterialConnectionPoint;
  21628. /**
  21629. * Gets the rgba output component
  21630. */
  21631. get rgba(): NodeMaterialConnectionPoint;
  21632. /**
  21633. * Gets the rgb output component
  21634. */
  21635. get rgb(): NodeMaterialConnectionPoint;
  21636. /**
  21637. * Gets the r output component
  21638. */
  21639. get r(): NodeMaterialConnectionPoint;
  21640. /**
  21641. * Gets the g output component
  21642. */
  21643. get g(): NodeMaterialConnectionPoint;
  21644. /**
  21645. * Gets the b output component
  21646. */
  21647. get b(): NodeMaterialConnectionPoint;
  21648. /**
  21649. * Gets the a output component
  21650. */
  21651. get a(): NodeMaterialConnectionPoint;
  21652. /**
  21653. * Initialize the block and prepare the context for build
  21654. * @param state defines the state that will be used for the build
  21655. */
  21656. initialize(state: NodeMaterialBuildState): void;
  21657. get target(): NodeMaterialBlockTargets;
  21658. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21659. isReady(): boolean;
  21660. private _injectVertexCode;
  21661. private _writeTextureRead;
  21662. private _writeOutput;
  21663. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21664. serialize(): any;
  21665. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21666. }
  21667. }
  21668. declare module BABYLON {
  21669. /**
  21670. * Base block used for the particle texture
  21671. */
  21672. export class ParticleTextureBlock extends NodeMaterialBlock {
  21673. private _samplerName;
  21674. private _linearDefineName;
  21675. private _gammaDefineName;
  21676. private _tempTextureRead;
  21677. /**
  21678. * Gets or sets the texture associated with the node
  21679. */
  21680. texture: Nullable<BaseTexture>;
  21681. /**
  21682. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21683. */
  21684. convertToGammaSpace: boolean;
  21685. /**
  21686. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21687. */
  21688. convertToLinearSpace: boolean;
  21689. /**
  21690. * Create a new ParticleTextureBlock
  21691. * @param name defines the block name
  21692. */
  21693. constructor(name: string);
  21694. /**
  21695. * Gets the current class name
  21696. * @returns the class name
  21697. */
  21698. getClassName(): string;
  21699. /**
  21700. * Gets the uv input component
  21701. */
  21702. get uv(): NodeMaterialConnectionPoint;
  21703. /**
  21704. * Gets the rgba output component
  21705. */
  21706. get rgba(): NodeMaterialConnectionPoint;
  21707. /**
  21708. * Gets the rgb output component
  21709. */
  21710. get rgb(): NodeMaterialConnectionPoint;
  21711. /**
  21712. * Gets the r output component
  21713. */
  21714. get r(): NodeMaterialConnectionPoint;
  21715. /**
  21716. * Gets the g output component
  21717. */
  21718. get g(): NodeMaterialConnectionPoint;
  21719. /**
  21720. * Gets the b output component
  21721. */
  21722. get b(): NodeMaterialConnectionPoint;
  21723. /**
  21724. * Gets the a output component
  21725. */
  21726. get a(): NodeMaterialConnectionPoint;
  21727. /**
  21728. * Initialize the block and prepare the context for build
  21729. * @param state defines the state that will be used for the build
  21730. */
  21731. initialize(state: NodeMaterialBuildState): void;
  21732. autoConfigure(material: NodeMaterial): void;
  21733. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21734. isReady(): boolean;
  21735. private _writeOutput;
  21736. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21737. serialize(): any;
  21738. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21739. }
  21740. }
  21741. declare module BABYLON {
  21742. /**
  21743. * Class used to store shared data between 2 NodeMaterialBuildState
  21744. */
  21745. export class NodeMaterialBuildStateSharedData {
  21746. /**
  21747. * Gets the list of emitted varyings
  21748. */
  21749. temps: string[];
  21750. /**
  21751. * Gets the list of emitted varyings
  21752. */
  21753. varyings: string[];
  21754. /**
  21755. * Gets the varying declaration string
  21756. */
  21757. varyingDeclaration: string;
  21758. /**
  21759. * Input blocks
  21760. */
  21761. inputBlocks: InputBlock[];
  21762. /**
  21763. * Input blocks
  21764. */
  21765. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21766. /**
  21767. * Bindable blocks (Blocks that need to set data to the effect)
  21768. */
  21769. bindableBlocks: NodeMaterialBlock[];
  21770. /**
  21771. * List of blocks that can provide a compilation fallback
  21772. */
  21773. blocksWithFallbacks: NodeMaterialBlock[];
  21774. /**
  21775. * List of blocks that can provide a define update
  21776. */
  21777. blocksWithDefines: NodeMaterialBlock[];
  21778. /**
  21779. * List of blocks that can provide a repeatable content
  21780. */
  21781. repeatableContentBlocks: NodeMaterialBlock[];
  21782. /**
  21783. * List of blocks that can provide a dynamic list of uniforms
  21784. */
  21785. dynamicUniformBlocks: NodeMaterialBlock[];
  21786. /**
  21787. * List of blocks that can block the isReady function for the material
  21788. */
  21789. blockingBlocks: NodeMaterialBlock[];
  21790. /**
  21791. * Gets the list of animated inputs
  21792. */
  21793. animatedInputs: InputBlock[];
  21794. /**
  21795. * Build Id used to avoid multiple recompilations
  21796. */
  21797. buildId: number;
  21798. /** List of emitted variables */
  21799. variableNames: {
  21800. [key: string]: number;
  21801. };
  21802. /** List of emitted defines */
  21803. defineNames: {
  21804. [key: string]: number;
  21805. };
  21806. /** Should emit comments? */
  21807. emitComments: boolean;
  21808. /** Emit build activity */
  21809. verbose: boolean;
  21810. /** Gets or sets the hosting scene */
  21811. scene: Scene;
  21812. /**
  21813. * Gets the compilation hints emitted at compilation time
  21814. */
  21815. hints: {
  21816. needWorldViewMatrix: boolean;
  21817. needWorldViewProjectionMatrix: boolean;
  21818. needAlphaBlending: boolean;
  21819. needAlphaTesting: boolean;
  21820. };
  21821. /**
  21822. * List of compilation checks
  21823. */
  21824. checks: {
  21825. emitVertex: boolean;
  21826. emitFragment: boolean;
  21827. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21828. };
  21829. /**
  21830. * Is vertex program allowed to be empty?
  21831. */
  21832. allowEmptyVertexProgram: boolean;
  21833. /** Creates a new shared data */
  21834. constructor();
  21835. /**
  21836. * Emits console errors and exceptions if there is a failing check
  21837. */
  21838. emitErrors(): void;
  21839. }
  21840. }
  21841. declare module BABYLON {
  21842. /**
  21843. * Class used to store node based material build state
  21844. */
  21845. export class NodeMaterialBuildState {
  21846. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21847. supportUniformBuffers: boolean;
  21848. /**
  21849. * Gets the list of emitted attributes
  21850. */
  21851. attributes: string[];
  21852. /**
  21853. * Gets the list of emitted uniforms
  21854. */
  21855. uniforms: string[];
  21856. /**
  21857. * Gets the list of emitted constants
  21858. */
  21859. constants: string[];
  21860. /**
  21861. * Gets the list of emitted samplers
  21862. */
  21863. samplers: string[];
  21864. /**
  21865. * Gets the list of emitted functions
  21866. */
  21867. functions: {
  21868. [key: string]: string;
  21869. };
  21870. /**
  21871. * Gets the list of emitted extensions
  21872. */
  21873. extensions: {
  21874. [key: string]: string;
  21875. };
  21876. /**
  21877. * Gets the target of the compilation state
  21878. */
  21879. target: NodeMaterialBlockTargets;
  21880. /**
  21881. * Gets the list of emitted counters
  21882. */
  21883. counters: {
  21884. [key: string]: number;
  21885. };
  21886. /**
  21887. * Shared data between multiple NodeMaterialBuildState instances
  21888. */
  21889. sharedData: NodeMaterialBuildStateSharedData;
  21890. /** @hidden */
  21891. _vertexState: NodeMaterialBuildState;
  21892. /** @hidden */
  21893. _attributeDeclaration: string;
  21894. /** @hidden */
  21895. _uniformDeclaration: string;
  21896. /** @hidden */
  21897. _constantDeclaration: string;
  21898. /** @hidden */
  21899. _samplerDeclaration: string;
  21900. /** @hidden */
  21901. _varyingTransfer: string;
  21902. /** @hidden */
  21903. _injectAtEnd: string;
  21904. private _repeatableContentAnchorIndex;
  21905. /** @hidden */
  21906. _builtCompilationString: string;
  21907. /**
  21908. * Gets the emitted compilation strings
  21909. */
  21910. compilationString: string;
  21911. /**
  21912. * Finalize the compilation strings
  21913. * @param state defines the current compilation state
  21914. */
  21915. finalize(state: NodeMaterialBuildState): void;
  21916. /** @hidden */
  21917. get _repeatableContentAnchor(): string;
  21918. /** @hidden */
  21919. _getFreeVariableName(prefix: string): string;
  21920. /** @hidden */
  21921. _getFreeDefineName(prefix: string): string;
  21922. /** @hidden */
  21923. _excludeVariableName(name: string): void;
  21924. /** @hidden */
  21925. _emit2DSampler(name: string): void;
  21926. /** @hidden */
  21927. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21928. /** @hidden */
  21929. _emitExtension(name: string, extension: string, define?: string): void;
  21930. /** @hidden */
  21931. _emitFunction(name: string, code: string, comments: string): void;
  21932. /** @hidden */
  21933. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21934. replaceStrings?: {
  21935. search: RegExp;
  21936. replace: string;
  21937. }[];
  21938. repeatKey?: string;
  21939. }): string;
  21940. /** @hidden */
  21941. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21942. repeatKey?: string;
  21943. removeAttributes?: boolean;
  21944. removeUniforms?: boolean;
  21945. removeVaryings?: boolean;
  21946. removeIfDef?: boolean;
  21947. replaceStrings?: {
  21948. search: RegExp;
  21949. replace: string;
  21950. }[];
  21951. }, storeKey?: string): void;
  21952. /** @hidden */
  21953. _registerTempVariable(name: string): boolean;
  21954. /** @hidden */
  21955. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21956. /** @hidden */
  21957. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21958. /** @hidden */
  21959. _emitFloat(value: number): string;
  21960. }
  21961. }
  21962. declare module BABYLON {
  21963. /**
  21964. * Helper class used to generate session unique ID
  21965. */
  21966. export class UniqueIdGenerator {
  21967. private static _UniqueIdCounter;
  21968. /**
  21969. * Gets an unique (relatively to the current scene) Id
  21970. */
  21971. static get UniqueId(): number;
  21972. }
  21973. }
  21974. declare module BABYLON {
  21975. /**
  21976. * Defines a block that can be used inside a node based material
  21977. */
  21978. export class NodeMaterialBlock {
  21979. private _buildId;
  21980. private _buildTarget;
  21981. private _target;
  21982. private _isFinalMerger;
  21983. private _isInput;
  21984. private _name;
  21985. protected _isUnique: boolean;
  21986. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21987. inputsAreExclusive: boolean;
  21988. /** @hidden */
  21989. _codeVariableName: string;
  21990. /** @hidden */
  21991. _inputs: NodeMaterialConnectionPoint[];
  21992. /** @hidden */
  21993. _outputs: NodeMaterialConnectionPoint[];
  21994. /** @hidden */
  21995. _preparationId: number;
  21996. /**
  21997. * Gets the name of the block
  21998. */
  21999. get name(): string;
  22000. /**
  22001. * Sets the name of the block. Will check if the name is valid.
  22002. */
  22003. set name(newName: string);
  22004. /**
  22005. * Gets or sets the unique id of the node
  22006. */
  22007. uniqueId: number;
  22008. /**
  22009. * Gets or sets the comments associated with this block
  22010. */
  22011. comments: string;
  22012. /**
  22013. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22014. */
  22015. get isUnique(): boolean;
  22016. /**
  22017. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22018. */
  22019. get isFinalMerger(): boolean;
  22020. /**
  22021. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22022. */
  22023. get isInput(): boolean;
  22024. /**
  22025. * Gets or sets the build Id
  22026. */
  22027. get buildId(): number;
  22028. set buildId(value: number);
  22029. /**
  22030. * Gets or sets the target of the block
  22031. */
  22032. get target(): NodeMaterialBlockTargets;
  22033. set target(value: NodeMaterialBlockTargets);
  22034. /**
  22035. * Gets the list of input points
  22036. */
  22037. get inputs(): NodeMaterialConnectionPoint[];
  22038. /** Gets the list of output points */
  22039. get outputs(): NodeMaterialConnectionPoint[];
  22040. /**
  22041. * Find an input by its name
  22042. * @param name defines the name of the input to look for
  22043. * @returns the input or null if not found
  22044. */
  22045. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22046. /**
  22047. * Find an output by its name
  22048. * @param name defines the name of the outputto look for
  22049. * @returns the output or null if not found
  22050. */
  22051. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22052. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  22053. visibleInInspector: boolean;
  22054. /**
  22055. * Creates a new NodeMaterialBlock
  22056. * @param name defines the block name
  22057. * @param target defines the target of that block (Vertex by default)
  22058. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22059. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22060. */
  22061. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22062. /**
  22063. * Initialize the block and prepare the context for build
  22064. * @param state defines the state that will be used for the build
  22065. */
  22066. initialize(state: NodeMaterialBuildState): void;
  22067. /**
  22068. * Bind data to effect. Will only be called for blocks with isBindable === true
  22069. * @param effect defines the effect to bind data to
  22070. * @param nodeMaterial defines the hosting NodeMaterial
  22071. * @param mesh defines the mesh that will be rendered
  22072. * @param subMesh defines the submesh that will be rendered
  22073. */
  22074. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22075. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22076. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22077. protected _writeFloat(value: number): string;
  22078. /**
  22079. * Gets the current class name e.g. "NodeMaterialBlock"
  22080. * @returns the class name
  22081. */
  22082. getClassName(): string;
  22083. /**
  22084. * Register a new input. Must be called inside a block constructor
  22085. * @param name defines the connection point name
  22086. * @param type defines the connection point type
  22087. * @param isOptional defines a boolean indicating that this input can be omitted
  22088. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22089. * @param point an already created connection point. If not provided, create a new one
  22090. * @returns the current block
  22091. */
  22092. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22093. /**
  22094. * Register a new output. Must be called inside a block constructor
  22095. * @param name defines the connection point name
  22096. * @param type defines the connection point type
  22097. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22098. * @param point an already created connection point. If not provided, create a new one
  22099. * @returns the current block
  22100. */
  22101. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22102. /**
  22103. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22104. * @param forOutput defines an optional connection point to check compatibility with
  22105. * @returns the first available input or null
  22106. */
  22107. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22108. /**
  22109. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22110. * @param forBlock defines an optional block to check compatibility with
  22111. * @returns the first available input or null
  22112. */
  22113. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22114. /**
  22115. * Gets the sibling of the given output
  22116. * @param current defines the current output
  22117. * @returns the next output in the list or null
  22118. */
  22119. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22120. /**
  22121. * Connect current block with another block
  22122. * @param other defines the block to connect with
  22123. * @param options define the various options to help pick the right connections
  22124. * @returns the current block
  22125. */
  22126. connectTo(other: NodeMaterialBlock, options?: {
  22127. input?: string;
  22128. output?: string;
  22129. outputSwizzle?: string;
  22130. }): this | undefined;
  22131. protected _buildBlock(state: NodeMaterialBuildState): void;
  22132. /**
  22133. * Add uniforms, samplers and uniform buffers at compilation time
  22134. * @param state defines the state to update
  22135. * @param nodeMaterial defines the node material requesting the update
  22136. * @param defines defines the material defines to update
  22137. * @param uniformBuffers defines the list of uniform buffer names
  22138. */
  22139. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22140. /**
  22141. * Add potential fallbacks if shader compilation fails
  22142. * @param mesh defines the mesh to be rendered
  22143. * @param fallbacks defines the current prioritized list of fallbacks
  22144. */
  22145. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22146. /**
  22147. * Initialize defines for shader compilation
  22148. * @param mesh defines the mesh to be rendered
  22149. * @param nodeMaterial defines the node material requesting the update
  22150. * @param defines defines the material defines to update
  22151. * @param useInstances specifies that instances should be used
  22152. */
  22153. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22154. /**
  22155. * Update defines for shader compilation
  22156. * @param mesh defines the mesh to be rendered
  22157. * @param nodeMaterial defines the node material requesting the update
  22158. * @param defines defines the material defines to update
  22159. * @param useInstances specifies that instances should be used
  22160. * @param subMesh defines which submesh to render
  22161. */
  22162. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22163. /**
  22164. * Lets the block try to connect some inputs automatically
  22165. * @param material defines the hosting NodeMaterial
  22166. */
  22167. autoConfigure(material: NodeMaterial): void;
  22168. /**
  22169. * Function called when a block is declared as repeatable content generator
  22170. * @param vertexShaderState defines the current compilation state for the vertex shader
  22171. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22172. * @param mesh defines the mesh to be rendered
  22173. * @param defines defines the material defines to update
  22174. */
  22175. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22176. /**
  22177. * Checks if the block is ready
  22178. * @param mesh defines the mesh to be rendered
  22179. * @param nodeMaterial defines the node material requesting the update
  22180. * @param defines defines the material defines to update
  22181. * @param useInstances specifies that instances should be used
  22182. * @returns true if the block is ready
  22183. */
  22184. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22185. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22186. private _processBuild;
  22187. /**
  22188. * Validates the new name for the block node.
  22189. * @param newName the new name to be given to the node.
  22190. * @returns false if the name is a reserve word, else true.
  22191. */
  22192. validateBlockName(newName: string): boolean;
  22193. /**
  22194. * Compile the current node and generate the shader code
  22195. * @param state defines the current compilation state (uniforms, samplers, current string)
  22196. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22197. * @returns true if already built
  22198. */
  22199. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22200. protected _inputRename(name: string): string;
  22201. protected _outputRename(name: string): string;
  22202. protected _dumpPropertiesCode(): string;
  22203. /** @hidden */
  22204. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22205. /** @hidden */
  22206. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22207. /**
  22208. * Clone the current block to a new identical block
  22209. * @param scene defines the hosting scene
  22210. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22211. * @returns a copy of the current block
  22212. */
  22213. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22214. /**
  22215. * Serializes this block in a JSON representation
  22216. * @returns the serialized block object
  22217. */
  22218. serialize(): any;
  22219. /** @hidden */
  22220. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22221. private _deserializePortDisplayNamesAndExposedOnFrame;
  22222. /**
  22223. * Release resources
  22224. */
  22225. dispose(): void;
  22226. }
  22227. }
  22228. declare module BABYLON {
  22229. /**
  22230. * Base class of materials working in push mode in babylon JS
  22231. * @hidden
  22232. */
  22233. export class PushMaterial extends Material {
  22234. protected _activeEffect: Effect;
  22235. protected _normalMatrix: Matrix;
  22236. constructor(name: string, scene: Scene);
  22237. getEffect(): Effect;
  22238. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22239. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22240. /**
  22241. * Binds the given world matrix to the active effect
  22242. *
  22243. * @param world the matrix to bind
  22244. */
  22245. bindOnlyWorldMatrix(world: Matrix): void;
  22246. /**
  22247. * Binds the given normal matrix to the active effect
  22248. *
  22249. * @param normalMatrix the matrix to bind
  22250. */
  22251. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22252. bind(world: Matrix, mesh?: Mesh): void;
  22253. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22254. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22255. }
  22256. }
  22257. declare module BABYLON {
  22258. /**
  22259. * Root class for all node material optimizers
  22260. */
  22261. export class NodeMaterialOptimizer {
  22262. /**
  22263. * Function used to optimize a NodeMaterial graph
  22264. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22265. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22266. */
  22267. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22268. }
  22269. }
  22270. declare module BABYLON {
  22271. /**
  22272. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22273. */
  22274. export class TransformBlock extends NodeMaterialBlock {
  22275. /**
  22276. * Defines the value to use to complement W value to transform it to a Vector4
  22277. */
  22278. complementW: number;
  22279. /**
  22280. * Defines the value to use to complement z value to transform it to a Vector4
  22281. */
  22282. complementZ: number;
  22283. /**
  22284. * Creates a new TransformBlock
  22285. * @param name defines the block name
  22286. */
  22287. constructor(name: string);
  22288. /**
  22289. * Gets the current class name
  22290. * @returns the class name
  22291. */
  22292. getClassName(): string;
  22293. /**
  22294. * Gets the vector input
  22295. */
  22296. get vector(): NodeMaterialConnectionPoint;
  22297. /**
  22298. * Gets the output component
  22299. */
  22300. get output(): NodeMaterialConnectionPoint;
  22301. /**
  22302. * Gets the xyz output component
  22303. */
  22304. get xyz(): NodeMaterialConnectionPoint;
  22305. /**
  22306. * Gets the matrix transform input
  22307. */
  22308. get transform(): NodeMaterialConnectionPoint;
  22309. protected _buildBlock(state: NodeMaterialBuildState): this;
  22310. /**
  22311. * Update defines for shader compilation
  22312. * @param mesh defines the mesh to be rendered
  22313. * @param nodeMaterial defines the node material requesting the update
  22314. * @param defines defines the material defines to update
  22315. * @param useInstances specifies that instances should be used
  22316. * @param subMesh defines which submesh to render
  22317. */
  22318. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22319. serialize(): any;
  22320. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22321. protected _dumpPropertiesCode(): string;
  22322. }
  22323. }
  22324. declare module BABYLON {
  22325. /**
  22326. * Block used to output the vertex position
  22327. */
  22328. export class VertexOutputBlock extends NodeMaterialBlock {
  22329. /**
  22330. * Creates a new VertexOutputBlock
  22331. * @param name defines the block name
  22332. */
  22333. constructor(name: string);
  22334. /**
  22335. * Gets the current class name
  22336. * @returns the class name
  22337. */
  22338. getClassName(): string;
  22339. /**
  22340. * Gets the vector input component
  22341. */
  22342. get vector(): NodeMaterialConnectionPoint;
  22343. protected _buildBlock(state: NodeMaterialBuildState): this;
  22344. }
  22345. }
  22346. declare module BABYLON {
  22347. /**
  22348. * Block used to output the final color
  22349. */
  22350. export class FragmentOutputBlock extends NodeMaterialBlock {
  22351. /**
  22352. * Create a new FragmentOutputBlock
  22353. * @param name defines the block name
  22354. */
  22355. constructor(name: string);
  22356. /**
  22357. * Gets the current class name
  22358. * @returns the class name
  22359. */
  22360. getClassName(): string;
  22361. /**
  22362. * Gets the rgba input component
  22363. */
  22364. get rgba(): NodeMaterialConnectionPoint;
  22365. /**
  22366. * Gets the rgb input component
  22367. */
  22368. get rgb(): NodeMaterialConnectionPoint;
  22369. /**
  22370. * Gets the a input component
  22371. */
  22372. get a(): NodeMaterialConnectionPoint;
  22373. protected _buildBlock(state: NodeMaterialBuildState): this;
  22374. }
  22375. }
  22376. declare module BABYLON {
  22377. /**
  22378. * Block used for the particle ramp gradient section
  22379. */
  22380. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22381. /**
  22382. * Create a new ParticleRampGradientBlock
  22383. * @param name defines the block name
  22384. */
  22385. constructor(name: string);
  22386. /**
  22387. * Gets the current class name
  22388. * @returns the class name
  22389. */
  22390. getClassName(): string;
  22391. /**
  22392. * Gets the color input component
  22393. */
  22394. get color(): NodeMaterialConnectionPoint;
  22395. /**
  22396. * Gets the rampColor output component
  22397. */
  22398. get rampColor(): NodeMaterialConnectionPoint;
  22399. /**
  22400. * Initialize the block and prepare the context for build
  22401. * @param state defines the state that will be used for the build
  22402. */
  22403. initialize(state: NodeMaterialBuildState): void;
  22404. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22405. }
  22406. }
  22407. declare module BABYLON {
  22408. /**
  22409. * Block used for the particle blend multiply section
  22410. */
  22411. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22412. /**
  22413. * Create a new ParticleBlendMultiplyBlock
  22414. * @param name defines the block name
  22415. */
  22416. constructor(name: string);
  22417. /**
  22418. * Gets the current class name
  22419. * @returns the class name
  22420. */
  22421. getClassName(): string;
  22422. /**
  22423. * Gets the color input component
  22424. */
  22425. get color(): NodeMaterialConnectionPoint;
  22426. /**
  22427. * Gets the alphaTexture input component
  22428. */
  22429. get alphaTexture(): NodeMaterialConnectionPoint;
  22430. /**
  22431. * Gets the alphaColor input component
  22432. */
  22433. get alphaColor(): NodeMaterialConnectionPoint;
  22434. /**
  22435. * Gets the blendColor output component
  22436. */
  22437. get blendColor(): NodeMaterialConnectionPoint;
  22438. /**
  22439. * Initialize the block and prepare the context for build
  22440. * @param state defines the state that will be used for the build
  22441. */
  22442. initialize(state: NodeMaterialBuildState): void;
  22443. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22444. }
  22445. }
  22446. declare module BABYLON {
  22447. /**
  22448. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22449. */
  22450. export class VectorMergerBlock extends NodeMaterialBlock {
  22451. /**
  22452. * Create a new VectorMergerBlock
  22453. * @param name defines the block name
  22454. */
  22455. constructor(name: string);
  22456. /**
  22457. * Gets the current class name
  22458. * @returns the class name
  22459. */
  22460. getClassName(): string;
  22461. /**
  22462. * Gets the xyz component (input)
  22463. */
  22464. get xyzIn(): NodeMaterialConnectionPoint;
  22465. /**
  22466. * Gets the xy component (input)
  22467. */
  22468. get xyIn(): NodeMaterialConnectionPoint;
  22469. /**
  22470. * Gets the x component (input)
  22471. */
  22472. get x(): NodeMaterialConnectionPoint;
  22473. /**
  22474. * Gets the y component (input)
  22475. */
  22476. get y(): NodeMaterialConnectionPoint;
  22477. /**
  22478. * Gets the z component (input)
  22479. */
  22480. get z(): NodeMaterialConnectionPoint;
  22481. /**
  22482. * Gets the w component (input)
  22483. */
  22484. get w(): NodeMaterialConnectionPoint;
  22485. /**
  22486. * Gets the xyzw component (output)
  22487. */
  22488. get xyzw(): NodeMaterialConnectionPoint;
  22489. /**
  22490. * Gets the xyz component (output)
  22491. */
  22492. get xyzOut(): NodeMaterialConnectionPoint;
  22493. /**
  22494. * Gets the xy component (output)
  22495. */
  22496. get xyOut(): NodeMaterialConnectionPoint;
  22497. /**
  22498. * Gets the xy component (output)
  22499. * @deprecated Please use xyOut instead.
  22500. */
  22501. get xy(): NodeMaterialConnectionPoint;
  22502. /**
  22503. * Gets the xyz component (output)
  22504. * @deprecated Please use xyzOut instead.
  22505. */
  22506. get xyz(): NodeMaterialConnectionPoint;
  22507. protected _buildBlock(state: NodeMaterialBuildState): this;
  22508. }
  22509. }
  22510. declare module BABYLON {
  22511. /**
  22512. * Block used to remap a float from a range to a new one
  22513. */
  22514. export class RemapBlock extends NodeMaterialBlock {
  22515. /**
  22516. * Gets or sets the source range
  22517. */
  22518. sourceRange: Vector2;
  22519. /**
  22520. * Gets or sets the target range
  22521. */
  22522. targetRange: Vector2;
  22523. /**
  22524. * Creates a new RemapBlock
  22525. * @param name defines the block name
  22526. */
  22527. constructor(name: string);
  22528. /**
  22529. * Gets the current class name
  22530. * @returns the class name
  22531. */
  22532. getClassName(): string;
  22533. /**
  22534. * Gets the input component
  22535. */
  22536. get input(): NodeMaterialConnectionPoint;
  22537. /**
  22538. * Gets the source min input component
  22539. */
  22540. get sourceMin(): NodeMaterialConnectionPoint;
  22541. /**
  22542. * Gets the source max input component
  22543. */
  22544. get sourceMax(): NodeMaterialConnectionPoint;
  22545. /**
  22546. * Gets the target min input component
  22547. */
  22548. get targetMin(): NodeMaterialConnectionPoint;
  22549. /**
  22550. * Gets the target max input component
  22551. */
  22552. get targetMax(): NodeMaterialConnectionPoint;
  22553. /**
  22554. * Gets the output component
  22555. */
  22556. get output(): NodeMaterialConnectionPoint;
  22557. protected _buildBlock(state: NodeMaterialBuildState): this;
  22558. protected _dumpPropertiesCode(): string;
  22559. serialize(): any;
  22560. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22561. }
  22562. }
  22563. declare module BABYLON {
  22564. /**
  22565. * Block used to multiply 2 values
  22566. */
  22567. export class MultiplyBlock extends NodeMaterialBlock {
  22568. /**
  22569. * Creates a new MultiplyBlock
  22570. * @param name defines the block name
  22571. */
  22572. constructor(name: string);
  22573. /**
  22574. * Gets the current class name
  22575. * @returns the class name
  22576. */
  22577. getClassName(): string;
  22578. /**
  22579. * Gets the left operand input component
  22580. */
  22581. get left(): NodeMaterialConnectionPoint;
  22582. /**
  22583. * Gets the right operand input component
  22584. */
  22585. get right(): NodeMaterialConnectionPoint;
  22586. /**
  22587. * Gets the output component
  22588. */
  22589. get output(): NodeMaterialConnectionPoint;
  22590. protected _buildBlock(state: NodeMaterialBuildState): this;
  22591. }
  22592. }
  22593. declare module BABYLON {
  22594. /**
  22595. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22596. */
  22597. export class ColorSplitterBlock extends NodeMaterialBlock {
  22598. /**
  22599. * Create a new ColorSplitterBlock
  22600. * @param name defines the block name
  22601. */
  22602. constructor(name: string);
  22603. /**
  22604. * Gets the current class name
  22605. * @returns the class name
  22606. */
  22607. getClassName(): string;
  22608. /**
  22609. * Gets the rgba component (input)
  22610. */
  22611. get rgba(): NodeMaterialConnectionPoint;
  22612. /**
  22613. * Gets the rgb component (input)
  22614. */
  22615. get rgbIn(): NodeMaterialConnectionPoint;
  22616. /**
  22617. * Gets the rgb component (output)
  22618. */
  22619. get rgbOut(): NodeMaterialConnectionPoint;
  22620. /**
  22621. * Gets the r component (output)
  22622. */
  22623. get r(): NodeMaterialConnectionPoint;
  22624. /**
  22625. * Gets the g component (output)
  22626. */
  22627. get g(): NodeMaterialConnectionPoint;
  22628. /**
  22629. * Gets the b component (output)
  22630. */
  22631. get b(): NodeMaterialConnectionPoint;
  22632. /**
  22633. * Gets the a component (output)
  22634. */
  22635. get a(): NodeMaterialConnectionPoint;
  22636. protected _inputRename(name: string): string;
  22637. protected _outputRename(name: string): string;
  22638. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22639. }
  22640. }
  22641. declare module BABYLON {
  22642. /**
  22643. * Operations supported by the Trigonometry block
  22644. */
  22645. export enum TrigonometryBlockOperations {
  22646. /** Cos */
  22647. Cos = 0,
  22648. /** Sin */
  22649. Sin = 1,
  22650. /** Abs */
  22651. Abs = 2,
  22652. /** Exp */
  22653. Exp = 3,
  22654. /** Exp2 */
  22655. Exp2 = 4,
  22656. /** Round */
  22657. Round = 5,
  22658. /** Floor */
  22659. Floor = 6,
  22660. /** Ceiling */
  22661. Ceiling = 7,
  22662. /** Square root */
  22663. Sqrt = 8,
  22664. /** Log */
  22665. Log = 9,
  22666. /** Tangent */
  22667. Tan = 10,
  22668. /** Arc tangent */
  22669. ArcTan = 11,
  22670. /** Arc cosinus */
  22671. ArcCos = 12,
  22672. /** Arc sinus */
  22673. ArcSin = 13,
  22674. /** Fraction */
  22675. Fract = 14,
  22676. /** Sign */
  22677. Sign = 15,
  22678. /** To radians (from degrees) */
  22679. Radians = 16,
  22680. /** To degrees (from radians) */
  22681. Degrees = 17
  22682. }
  22683. /**
  22684. * Block used to apply trigonometry operation to floats
  22685. */
  22686. export class TrigonometryBlock extends NodeMaterialBlock {
  22687. /**
  22688. * Gets or sets the operation applied by the block
  22689. */
  22690. operation: TrigonometryBlockOperations;
  22691. /**
  22692. * Creates a new TrigonometryBlock
  22693. * @param name defines the block name
  22694. */
  22695. constructor(name: string);
  22696. /**
  22697. * Gets the current class name
  22698. * @returns the class name
  22699. */
  22700. getClassName(): string;
  22701. /**
  22702. * Gets the input component
  22703. */
  22704. get input(): NodeMaterialConnectionPoint;
  22705. /**
  22706. * Gets the output component
  22707. */
  22708. get output(): NodeMaterialConnectionPoint;
  22709. protected _buildBlock(state: NodeMaterialBuildState): this;
  22710. serialize(): any;
  22711. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22712. protected _dumpPropertiesCode(): string;
  22713. }
  22714. }
  22715. declare module BABYLON {
  22716. /**
  22717. * Interface used to configure the node material editor
  22718. */
  22719. export interface INodeMaterialEditorOptions {
  22720. /** Define the URl to load node editor script */
  22721. editorURL?: string;
  22722. }
  22723. /** @hidden */
  22724. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22725. NORMAL: boolean;
  22726. TANGENT: boolean;
  22727. UV1: boolean;
  22728. /** BONES */
  22729. NUM_BONE_INFLUENCERS: number;
  22730. BonesPerMesh: number;
  22731. BONETEXTURE: boolean;
  22732. /** MORPH TARGETS */
  22733. MORPHTARGETS: boolean;
  22734. MORPHTARGETS_NORMAL: boolean;
  22735. MORPHTARGETS_TANGENT: boolean;
  22736. MORPHTARGETS_UV: boolean;
  22737. NUM_MORPH_INFLUENCERS: number;
  22738. /** IMAGE PROCESSING */
  22739. IMAGEPROCESSING: boolean;
  22740. VIGNETTE: boolean;
  22741. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22742. VIGNETTEBLENDMODEOPAQUE: boolean;
  22743. TONEMAPPING: boolean;
  22744. TONEMAPPING_ACES: boolean;
  22745. CONTRAST: boolean;
  22746. EXPOSURE: boolean;
  22747. COLORCURVES: boolean;
  22748. COLORGRADING: boolean;
  22749. COLORGRADING3D: boolean;
  22750. SAMPLER3DGREENDEPTH: boolean;
  22751. SAMPLER3DBGRMAP: boolean;
  22752. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22753. /** MISC. */
  22754. BUMPDIRECTUV: number;
  22755. constructor();
  22756. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22757. }
  22758. /**
  22759. * Class used to configure NodeMaterial
  22760. */
  22761. export interface INodeMaterialOptions {
  22762. /**
  22763. * Defines if blocks should emit comments
  22764. */
  22765. emitComments: boolean;
  22766. }
  22767. /**
  22768. * Class used to create a node based material built by assembling shader blocks
  22769. */
  22770. export class NodeMaterial extends PushMaterial {
  22771. private static _BuildIdGenerator;
  22772. private _options;
  22773. private _vertexCompilationState;
  22774. private _fragmentCompilationState;
  22775. private _sharedData;
  22776. private _buildId;
  22777. private _buildWasSuccessful;
  22778. private _cachedWorldViewMatrix;
  22779. private _cachedWorldViewProjectionMatrix;
  22780. private _optimizers;
  22781. private _animationFrame;
  22782. /** Define the Url to load node editor script */
  22783. static EditorURL: string;
  22784. /** Define the Url to load snippets */
  22785. static SnippetUrl: string;
  22786. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22787. static IgnoreTexturesAtLoadTime: boolean;
  22788. private BJSNODEMATERIALEDITOR;
  22789. /** Get the inspector from bundle or global */
  22790. private _getGlobalNodeMaterialEditor;
  22791. /**
  22792. * Snippet ID if the material was created from the snippet server
  22793. */
  22794. snippetId: string;
  22795. /**
  22796. * Gets or sets data used by visual editor
  22797. * @see https://nme.babylonjs.com
  22798. */
  22799. editorData: any;
  22800. /**
  22801. * 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)
  22802. */
  22803. ignoreAlpha: boolean;
  22804. /**
  22805. * Defines the maximum number of lights that can be used in the material
  22806. */
  22807. maxSimultaneousLights: number;
  22808. /**
  22809. * Observable raised when the material is built
  22810. */
  22811. onBuildObservable: Observable<NodeMaterial>;
  22812. /**
  22813. * Gets or sets the root nodes of the material vertex shader
  22814. */
  22815. _vertexOutputNodes: NodeMaterialBlock[];
  22816. /**
  22817. * Gets or sets the root nodes of the material fragment (pixel) shader
  22818. */
  22819. _fragmentOutputNodes: NodeMaterialBlock[];
  22820. /** Gets or sets options to control the node material overall behavior */
  22821. get options(): INodeMaterialOptions;
  22822. set options(options: INodeMaterialOptions);
  22823. /**
  22824. * Default configuration related to image processing available in the standard Material.
  22825. */
  22826. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22827. /**
  22828. * Gets the image processing configuration used either in this material.
  22829. */
  22830. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22831. /**
  22832. * Sets the Default image processing configuration used either in the this material.
  22833. *
  22834. * If sets to null, the scene one is in use.
  22835. */
  22836. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22837. /**
  22838. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22839. */
  22840. attachedBlocks: NodeMaterialBlock[];
  22841. /**
  22842. * Specifies the mode of the node material
  22843. * @hidden
  22844. */
  22845. _mode: NodeMaterialModes;
  22846. /**
  22847. * Gets the mode property
  22848. */
  22849. get mode(): NodeMaterialModes;
  22850. /**
  22851. * A free comment about the material
  22852. */
  22853. comment: string;
  22854. /**
  22855. * Create a new node based material
  22856. * @param name defines the material name
  22857. * @param scene defines the hosting scene
  22858. * @param options defines creation option
  22859. */
  22860. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22861. /**
  22862. * Gets the current class name of the material e.g. "NodeMaterial"
  22863. * @returns the class name
  22864. */
  22865. getClassName(): string;
  22866. /**
  22867. * Keep track of the image processing observer to allow dispose and replace.
  22868. */
  22869. private _imageProcessingObserver;
  22870. /**
  22871. * Attaches a new image processing configuration to the Standard Material.
  22872. * @param configuration
  22873. */
  22874. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22875. /**
  22876. * Get a block by its name
  22877. * @param name defines the name of the block to retrieve
  22878. * @returns the required block or null if not found
  22879. */
  22880. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22881. /**
  22882. * Get a block by its name
  22883. * @param predicate defines the predicate used to find the good candidate
  22884. * @returns the required block or null if not found
  22885. */
  22886. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22887. /**
  22888. * Get an input block by its name
  22889. * @param predicate defines the predicate used to find the good candidate
  22890. * @returns the required input block or null if not found
  22891. */
  22892. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22893. /**
  22894. * Gets the list of input blocks attached to this material
  22895. * @returns an array of InputBlocks
  22896. */
  22897. getInputBlocks(): InputBlock[];
  22898. /**
  22899. * Adds a new optimizer to the list of optimizers
  22900. * @param optimizer defines the optimizers to add
  22901. * @returns the current material
  22902. */
  22903. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22904. /**
  22905. * Remove an optimizer from the list of optimizers
  22906. * @param optimizer defines the optimizers to remove
  22907. * @returns the current material
  22908. */
  22909. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22910. /**
  22911. * Add a new block to the list of output nodes
  22912. * @param node defines the node to add
  22913. * @returns the current material
  22914. */
  22915. addOutputNode(node: NodeMaterialBlock): this;
  22916. /**
  22917. * Remove a block from the list of root nodes
  22918. * @param node defines the node to remove
  22919. * @returns the current material
  22920. */
  22921. removeOutputNode(node: NodeMaterialBlock): this;
  22922. private _addVertexOutputNode;
  22923. private _removeVertexOutputNode;
  22924. private _addFragmentOutputNode;
  22925. private _removeFragmentOutputNode;
  22926. /**
  22927. * Specifies if the material will require alpha blending
  22928. * @returns a boolean specifying if alpha blending is needed
  22929. */
  22930. needAlphaBlending(): boolean;
  22931. /**
  22932. * Specifies if this material should be rendered in alpha test mode
  22933. * @returns a boolean specifying if an alpha test is needed.
  22934. */
  22935. needAlphaTesting(): boolean;
  22936. private _initializeBlock;
  22937. private _resetDualBlocks;
  22938. /**
  22939. * Remove a block from the current node material
  22940. * @param block defines the block to remove
  22941. */
  22942. removeBlock(block: NodeMaterialBlock): void;
  22943. /**
  22944. * Build the material and generates the inner effect
  22945. * @param verbose defines if the build should log activity
  22946. */
  22947. build(verbose?: boolean): void;
  22948. /**
  22949. * Runs an otpimization phase to try to improve the shader code
  22950. */
  22951. optimize(): void;
  22952. private _prepareDefinesForAttributes;
  22953. /**
  22954. * Create a post process from the material
  22955. * @param camera The camera to apply the render pass to.
  22956. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22957. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22958. * @param engine The engine which the post process will be applied. (default: current engine)
  22959. * @param reusable If the post process can be reused on the same frame. (default: false)
  22960. * @param textureType Type of textures used when performing the post process. (default: 0)
  22961. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22962. * @returns the post process created
  22963. */
  22964. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  22965. /**
  22966. * Create the post process effect from the material
  22967. * @param postProcess The post process to create the effect for
  22968. */
  22969. createEffectForPostProcess(postProcess: PostProcess): void;
  22970. private _createEffectForPostProcess;
  22971. /**
  22972. * Create a new procedural texture based on this node material
  22973. * @param size defines the size of the texture
  22974. * @param scene defines the hosting scene
  22975. * @returns the new procedural texture attached to this node material
  22976. */
  22977. createProceduralTexture(size: number | {
  22978. width: number;
  22979. height: number;
  22980. layers?: number;
  22981. }, scene: Scene): Nullable<ProceduralTexture>;
  22982. private _createEffectForParticles;
  22983. private _checkInternals;
  22984. /**
  22985. * Create the effect to be used as the custom effect for a particle system
  22986. * @param particleSystem Particle system to create the effect for
  22987. * @param onCompiled defines a function to call when the effect creation is successful
  22988. * @param onError defines a function to call when the effect creation has failed
  22989. */
  22990. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22991. private _processDefines;
  22992. /**
  22993. * Get if the submesh is ready to be used and all its information available.
  22994. * Child classes can use it to update shaders
  22995. * @param mesh defines the mesh to check
  22996. * @param subMesh defines which submesh to check
  22997. * @param useInstances specifies that instances should be used
  22998. * @returns a boolean indicating that the submesh is ready or not
  22999. */
  23000. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23001. /**
  23002. * Get a string representing the shaders built by the current node graph
  23003. */
  23004. get compiledShaders(): string;
  23005. /**
  23006. * Binds the world matrix to the material
  23007. * @param world defines the world transformation matrix
  23008. */
  23009. bindOnlyWorldMatrix(world: Matrix): void;
  23010. /**
  23011. * Binds the submesh to this material by preparing the effect and shader to draw
  23012. * @param world defines the world transformation matrix
  23013. * @param mesh defines the mesh containing the submesh
  23014. * @param subMesh defines the submesh to bind the material to
  23015. */
  23016. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23017. /**
  23018. * Gets the active textures from the material
  23019. * @returns an array of textures
  23020. */
  23021. getActiveTextures(): BaseTexture[];
  23022. /**
  23023. * Gets the list of texture blocks
  23024. * @returns an array of texture blocks
  23025. */
  23026. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23027. /**
  23028. * Specifies if the material uses a texture
  23029. * @param texture defines the texture to check against the material
  23030. * @returns a boolean specifying if the material uses the texture
  23031. */
  23032. hasTexture(texture: BaseTexture): boolean;
  23033. /**
  23034. * Disposes the material
  23035. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23036. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23037. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23038. */
  23039. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23040. /** Creates the node editor window. */
  23041. private _createNodeEditor;
  23042. /**
  23043. * Launch the node material editor
  23044. * @param config Define the configuration of the editor
  23045. * @return a promise fulfilled when the node editor is visible
  23046. */
  23047. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23048. /**
  23049. * Clear the current material
  23050. */
  23051. clear(): void;
  23052. /**
  23053. * Clear the current material and set it to a default state
  23054. */
  23055. setToDefault(): void;
  23056. /**
  23057. * Clear the current material and set it to a default state for post process
  23058. */
  23059. setToDefaultPostProcess(): void;
  23060. /**
  23061. * Clear the current material and set it to a default state for procedural texture
  23062. */
  23063. setToDefaultProceduralTexture(): void;
  23064. /**
  23065. * Clear the current material and set it to a default state for particle
  23066. */
  23067. setToDefaultParticle(): void;
  23068. /**
  23069. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23070. * @param url defines the url to load from
  23071. * @returns a promise that will fullfil when the material is fully loaded
  23072. */
  23073. loadAsync(url: string): Promise<void>;
  23074. private _gatherBlocks;
  23075. /**
  23076. * Generate a string containing the code declaration required to create an equivalent of this material
  23077. * @returns a string
  23078. */
  23079. generateCode(): string;
  23080. /**
  23081. * Serializes this material in a JSON representation
  23082. * @returns the serialized material object
  23083. */
  23084. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23085. private _restoreConnections;
  23086. /**
  23087. * Clear the current graph and load a new one from a serialization object
  23088. * @param source defines the JSON representation of the material
  23089. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23090. * @param merge defines whether or not the source must be merged or replace the current content
  23091. */
  23092. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23093. /**
  23094. * Makes a duplicate of the current material.
  23095. * @param name - name to use for the new material.
  23096. */
  23097. clone(name: string): NodeMaterial;
  23098. /**
  23099. * Creates a node material from parsed material data
  23100. * @param source defines the JSON representation of the material
  23101. * @param scene defines the hosting scene
  23102. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23103. * @returns a new node material
  23104. */
  23105. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23106. /**
  23107. * Creates a node material from a snippet saved in a remote file
  23108. * @param name defines the name of the material to create
  23109. * @param url defines the url to load from
  23110. * @param scene defines the hosting scene
  23111. * @returns a promise that will resolve to the new node material
  23112. */
  23113. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23114. /**
  23115. * Creates a node material from a snippet saved by the node material editor
  23116. * @param snippetId defines the snippet to load
  23117. * @param scene defines the hosting scene
  23118. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23119. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23120. * @returns a promise that will resolve to the new node material
  23121. */
  23122. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23123. /**
  23124. * Creates a new node material set to default basic configuration
  23125. * @param name defines the name of the material
  23126. * @param scene defines the hosting scene
  23127. * @returns a new NodeMaterial
  23128. */
  23129. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23130. }
  23131. }
  23132. declare module BABYLON {
  23133. interface ThinEngine {
  23134. /**
  23135. * Unbind a list of render target textures from the webGL context
  23136. * This is used only when drawBuffer extension or webGL2 are active
  23137. * @param textures defines the render target textures to unbind
  23138. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  23139. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  23140. */
  23141. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  23142. /**
  23143. * Create a multi render target texture
  23144. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  23145. * @param size defines the size of the texture
  23146. * @param options defines the creation options
  23147. * @returns the cube texture as an InternalTexture
  23148. */
  23149. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  23150. /**
  23151. * Update the sample count for a given multiple render target texture
  23152. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  23153. * @param textures defines the textures to update
  23154. * @param samples defines the sample count to set
  23155. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  23156. */
  23157. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  23158. /**
  23159. * Select a subsets of attachments to draw to.
  23160. * @param attachments gl attachments
  23161. */
  23162. bindAttachments(attachments: number[]): void;
  23163. /**
  23164. * Creates a layout object to draw/clear on specific textures in a MRT
  23165. * @param textureStatus textureStatus[i] indicates if the i-th is active
  23166. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  23167. */
  23168. buildTextureLayout(textureStatus: boolean[]): number[];
  23169. /**
  23170. * Restores the webgl state to only draw on the main color attachment
  23171. */
  23172. restoreSingleAttachment(): void;
  23173. }
  23174. }
  23175. declare module BABYLON {
  23176. /**
  23177. * Creation options of the multi render target texture.
  23178. */
  23179. export interface IMultiRenderTargetOptions {
  23180. /**
  23181. * Define if the texture needs to create mip maps after render.
  23182. */
  23183. generateMipMaps?: boolean;
  23184. /**
  23185. * Define the types of all the draw buffers we want to create
  23186. */
  23187. types?: number[];
  23188. /**
  23189. * Define the sampling modes of all the draw buffers we want to create
  23190. */
  23191. samplingModes?: number[];
  23192. /**
  23193. * Define if a depth buffer is required
  23194. */
  23195. generateDepthBuffer?: boolean;
  23196. /**
  23197. * Define if a stencil buffer is required
  23198. */
  23199. generateStencilBuffer?: boolean;
  23200. /**
  23201. * Define if a depth texture is required instead of a depth buffer
  23202. */
  23203. generateDepthTexture?: boolean;
  23204. /**
  23205. * Define the number of desired draw buffers
  23206. */
  23207. textureCount?: number;
  23208. /**
  23209. * Define if aspect ratio should be adapted to the texture or stay the scene one
  23210. */
  23211. doNotChangeAspectRatio?: boolean;
  23212. /**
  23213. * Define the default type of the buffers we are creating
  23214. */
  23215. defaultType?: number;
  23216. }
  23217. /**
  23218. * A multi render target, like a render target provides the ability to render to a texture.
  23219. * Unlike the render target, it can render to several draw buffers in one draw.
  23220. * This is specially interesting in deferred rendering or for any effects requiring more than
  23221. * just one color from a single pass.
  23222. */
  23223. export class MultiRenderTarget extends RenderTargetTexture {
  23224. private _internalTextures;
  23225. private _textures;
  23226. private _multiRenderTargetOptions;
  23227. private _count;
  23228. /**
  23229. * Get if draw buffers are currently supported by the used hardware and browser.
  23230. */
  23231. get isSupported(): boolean;
  23232. /**
  23233. * Get the list of textures generated by the multi render target.
  23234. */
  23235. get textures(): Texture[];
  23236. /**
  23237. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  23238. */
  23239. get count(): number;
  23240. /**
  23241. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  23242. */
  23243. get depthTexture(): Texture;
  23244. /**
  23245. * Set the wrapping mode on U of all the textures we are rendering to.
  23246. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23247. */
  23248. set wrapU(wrap: number);
  23249. /**
  23250. * Set the wrapping mode on V of all the textures we are rendering to.
  23251. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23252. */
  23253. set wrapV(wrap: number);
  23254. /**
  23255. * Instantiate a new multi render target texture.
  23256. * A multi render target, like a render target provides the ability to render to a texture.
  23257. * Unlike the render target, it can render to several draw buffers in one draw.
  23258. * This is specially interesting in deferred rendering or for any effects requiring more than
  23259. * just one color from a single pass.
  23260. * @param name Define the name of the texture
  23261. * @param size Define the size of the buffers to render to
  23262. * @param count Define the number of target we are rendering into
  23263. * @param scene Define the scene the texture belongs to
  23264. * @param options Define the options used to create the multi render target
  23265. */
  23266. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  23267. private _initTypes;
  23268. /** @hidden */
  23269. _rebuild(forceFullRebuild?: boolean): void;
  23270. private _createInternalTextures;
  23271. private _createTextures;
  23272. /**
  23273. * Replaces a texture within the MRT.
  23274. * @param texture The new texture to insert in the MRT
  23275. * @param index The index of the texture to replace
  23276. */
  23277. replaceTexture(texture: Texture, index: number): void;
  23278. /**
  23279. * Define the number of samples used if MSAA is enabled.
  23280. */
  23281. get samples(): number;
  23282. set samples(value: number);
  23283. /**
  23284. * Resize all the textures in the multi render target.
  23285. * Be careful as it will recreate all the data in the new texture.
  23286. * @param size Define the new size
  23287. */
  23288. resize(size: any): void;
  23289. /**
  23290. * Changes the number of render targets in this MRT
  23291. * Be careful as it will recreate all the data in the new texture.
  23292. * @param count new texture count
  23293. * @param options Specifies texture types and sampling modes for new textures
  23294. */
  23295. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  23296. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23297. /**
  23298. * Dispose the render targets and their associated resources
  23299. */
  23300. dispose(): void;
  23301. /**
  23302. * Release all the underlying texture used as draw buffers.
  23303. */
  23304. releaseInternalTextures(): void;
  23305. }
  23306. }
  23307. declare module BABYLON {
  23308. /** @hidden */
  23309. export var imageProcessingPixelShader: {
  23310. name: string;
  23311. shader: string;
  23312. };
  23313. }
  23314. declare module BABYLON {
  23315. /**
  23316. * ImageProcessingPostProcess
  23317. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  23318. */
  23319. export class ImageProcessingPostProcess extends PostProcess {
  23320. /**
  23321. * Default configuration related to image processing available in the PBR Material.
  23322. */
  23323. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23324. /**
  23325. * Gets the image processing configuration used either in this material.
  23326. */
  23327. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23328. /**
  23329. * Sets the Default image processing configuration used either in the this material.
  23330. *
  23331. * If sets to null, the scene one is in use.
  23332. */
  23333. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23334. /**
  23335. * Keep track of the image processing observer to allow dispose and replace.
  23336. */
  23337. private _imageProcessingObserver;
  23338. /**
  23339. * Attaches a new image processing configuration to the PBR Material.
  23340. * @param configuration
  23341. */
  23342. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  23343. /**
  23344. * If the post process is supported.
  23345. */
  23346. get isSupported(): boolean;
  23347. /**
  23348. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23349. */
  23350. get colorCurves(): Nullable<ColorCurves>;
  23351. /**
  23352. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23353. */
  23354. set colorCurves(value: Nullable<ColorCurves>);
  23355. /**
  23356. * Gets wether the color curves effect is enabled.
  23357. */
  23358. get colorCurvesEnabled(): boolean;
  23359. /**
  23360. * Sets wether the color curves effect is enabled.
  23361. */
  23362. set colorCurvesEnabled(value: boolean);
  23363. /**
  23364. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23365. */
  23366. get colorGradingTexture(): Nullable<BaseTexture>;
  23367. /**
  23368. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23369. */
  23370. set colorGradingTexture(value: Nullable<BaseTexture>);
  23371. /**
  23372. * Gets wether the color grading effect is enabled.
  23373. */
  23374. get colorGradingEnabled(): boolean;
  23375. /**
  23376. * Gets wether the color grading effect is enabled.
  23377. */
  23378. set colorGradingEnabled(value: boolean);
  23379. /**
  23380. * Gets exposure used in the effect.
  23381. */
  23382. get exposure(): number;
  23383. /**
  23384. * Sets exposure used in the effect.
  23385. */
  23386. set exposure(value: number);
  23387. /**
  23388. * Gets wether tonemapping is enabled or not.
  23389. */
  23390. get toneMappingEnabled(): boolean;
  23391. /**
  23392. * Sets wether tonemapping is enabled or not
  23393. */
  23394. set toneMappingEnabled(value: boolean);
  23395. /**
  23396. * Gets the type of tone mapping effect.
  23397. */
  23398. get toneMappingType(): number;
  23399. /**
  23400. * Sets the type of tone mapping effect.
  23401. */
  23402. set toneMappingType(value: number);
  23403. /**
  23404. * Gets contrast used in the effect.
  23405. */
  23406. get contrast(): number;
  23407. /**
  23408. * Sets contrast used in the effect.
  23409. */
  23410. set contrast(value: number);
  23411. /**
  23412. * Gets Vignette stretch size.
  23413. */
  23414. get vignetteStretch(): number;
  23415. /**
  23416. * Sets Vignette stretch size.
  23417. */
  23418. set vignetteStretch(value: number);
  23419. /**
  23420. * Gets Vignette centre X Offset.
  23421. */
  23422. get vignetteCentreX(): number;
  23423. /**
  23424. * Sets Vignette centre X Offset.
  23425. */
  23426. set vignetteCentreX(value: number);
  23427. /**
  23428. * Gets Vignette centre Y Offset.
  23429. */
  23430. get vignetteCentreY(): number;
  23431. /**
  23432. * Sets Vignette centre Y Offset.
  23433. */
  23434. set vignetteCentreY(value: number);
  23435. /**
  23436. * Gets Vignette weight or intensity of the vignette effect.
  23437. */
  23438. get vignetteWeight(): number;
  23439. /**
  23440. * Sets Vignette weight or intensity of the vignette effect.
  23441. */
  23442. set vignetteWeight(value: number);
  23443. /**
  23444. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  23445. * if vignetteEnabled is set to true.
  23446. */
  23447. get vignetteColor(): Color4;
  23448. /**
  23449. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  23450. * if vignetteEnabled is set to true.
  23451. */
  23452. set vignetteColor(value: Color4);
  23453. /**
  23454. * Gets Camera field of view used by the Vignette effect.
  23455. */
  23456. get vignetteCameraFov(): number;
  23457. /**
  23458. * Sets Camera field of view used by the Vignette effect.
  23459. */
  23460. set vignetteCameraFov(value: number);
  23461. /**
  23462. * Gets the vignette blend mode allowing different kind of effect.
  23463. */
  23464. get vignetteBlendMode(): number;
  23465. /**
  23466. * Sets the vignette blend mode allowing different kind of effect.
  23467. */
  23468. set vignetteBlendMode(value: number);
  23469. /**
  23470. * Gets wether the vignette effect is enabled.
  23471. */
  23472. get vignetteEnabled(): boolean;
  23473. /**
  23474. * Sets wether the vignette effect is enabled.
  23475. */
  23476. set vignetteEnabled(value: boolean);
  23477. private _fromLinearSpace;
  23478. /**
  23479. * Gets wether the input of the processing is in Gamma or Linear Space.
  23480. */
  23481. get fromLinearSpace(): boolean;
  23482. /**
  23483. * Sets wether the input of the processing is in Gamma or Linear Space.
  23484. */
  23485. set fromLinearSpace(value: boolean);
  23486. /**
  23487. * Defines cache preventing GC.
  23488. */
  23489. private _defines;
  23490. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  23491. /**
  23492. * "ImageProcessingPostProcess"
  23493. * @returns "ImageProcessingPostProcess"
  23494. */
  23495. getClassName(): string;
  23496. /**
  23497. * @hidden
  23498. */
  23499. _updateParameters(): void;
  23500. dispose(camera?: Camera): void;
  23501. }
  23502. }
  23503. declare module BABYLON {
  23504. /**
  23505. * Interface for defining prepass effects in the prepass post-process pipeline
  23506. */
  23507. export interface PrePassEffectConfiguration {
  23508. /**
  23509. * Name of the effect
  23510. */
  23511. name: string;
  23512. /**
  23513. * Post process to attach for this effect
  23514. */
  23515. postProcess?: PostProcess;
  23516. /**
  23517. * Textures required in the MRT
  23518. */
  23519. texturesRequired: number[];
  23520. /**
  23521. * Is the effect enabled
  23522. */
  23523. enabled: boolean;
  23524. /**
  23525. * Disposes the effect configuration
  23526. */
  23527. dispose?: () => void;
  23528. /**
  23529. * Creates the associated post process
  23530. */
  23531. createPostProcess?: () => PostProcess;
  23532. }
  23533. }
  23534. declare module BABYLON {
  23535. /**
  23536. * Options to be used when creating a FresnelParameters.
  23537. */
  23538. export type IFresnelParametersCreationOptions = {
  23539. /**
  23540. * Define the color used on edges (grazing angle)
  23541. */
  23542. leftColor?: Color3;
  23543. /**
  23544. * Define the color used on center
  23545. */
  23546. rightColor?: Color3;
  23547. /**
  23548. * Define bias applied to computed fresnel term
  23549. */
  23550. bias?: number;
  23551. /**
  23552. * Defined the power exponent applied to fresnel term
  23553. */
  23554. power?: number;
  23555. /**
  23556. * Define if the fresnel effect is enable or not.
  23557. */
  23558. isEnabled?: boolean;
  23559. };
  23560. /**
  23561. * Serialized format for FresnelParameters.
  23562. */
  23563. export type IFresnelParametersSerialized = {
  23564. /**
  23565. * Define the color used on edges (grazing angle) [as an array]
  23566. */
  23567. leftColor: number[];
  23568. /**
  23569. * Define the color used on center [as an array]
  23570. */
  23571. rightColor: number[];
  23572. /**
  23573. * Define bias applied to computed fresnel term
  23574. */
  23575. bias: number;
  23576. /**
  23577. * Defined the power exponent applied to fresnel term
  23578. */
  23579. power?: number;
  23580. /**
  23581. * Define if the fresnel effect is enable or not.
  23582. */
  23583. isEnabled: boolean;
  23584. };
  23585. /**
  23586. * This represents all the required information to add a fresnel effect on a material:
  23587. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  23588. */
  23589. export class FresnelParameters {
  23590. private _isEnabled;
  23591. /**
  23592. * Define if the fresnel effect is enable or not.
  23593. */
  23594. get isEnabled(): boolean;
  23595. set isEnabled(value: boolean);
  23596. /**
  23597. * Define the color used on edges (grazing angle)
  23598. */
  23599. leftColor: Color3;
  23600. /**
  23601. * Define the color used on center
  23602. */
  23603. rightColor: Color3;
  23604. /**
  23605. * Define bias applied to computed fresnel term
  23606. */
  23607. bias: number;
  23608. /**
  23609. * Defined the power exponent applied to fresnel term
  23610. */
  23611. power: number;
  23612. /**
  23613. * Creates a new FresnelParameters object.
  23614. *
  23615. * @param options provide your own settings to optionally to override defaults
  23616. */
  23617. constructor(options?: IFresnelParametersCreationOptions);
  23618. /**
  23619. * Clones the current fresnel and its valuues
  23620. * @returns a clone fresnel configuration
  23621. */
  23622. clone(): FresnelParameters;
  23623. /**
  23624. * Determines equality between FresnelParameters objects
  23625. * @param otherFresnelParameters defines the second operand
  23626. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  23627. */
  23628. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  23629. /**
  23630. * Serializes the current fresnel parameters to a JSON representation.
  23631. * @return the JSON serialization
  23632. */
  23633. serialize(): IFresnelParametersSerialized;
  23634. /**
  23635. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  23636. * @param parsedFresnelParameters Define the JSON representation
  23637. * @returns the parsed parameters
  23638. */
  23639. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  23640. }
  23641. }
  23642. declare module BABYLON {
  23643. /**
  23644. * This groups all the flags used to control the materials channel.
  23645. */
  23646. export class MaterialFlags {
  23647. private static _DiffuseTextureEnabled;
  23648. /**
  23649. * Are diffuse textures enabled in the application.
  23650. */
  23651. static get DiffuseTextureEnabled(): boolean;
  23652. static set DiffuseTextureEnabled(value: boolean);
  23653. private static _DetailTextureEnabled;
  23654. /**
  23655. * Are detail textures enabled in the application.
  23656. */
  23657. static get DetailTextureEnabled(): boolean;
  23658. static set DetailTextureEnabled(value: boolean);
  23659. private static _AmbientTextureEnabled;
  23660. /**
  23661. * Are ambient textures enabled in the application.
  23662. */
  23663. static get AmbientTextureEnabled(): boolean;
  23664. static set AmbientTextureEnabled(value: boolean);
  23665. private static _OpacityTextureEnabled;
  23666. /**
  23667. * Are opacity textures enabled in the application.
  23668. */
  23669. static get OpacityTextureEnabled(): boolean;
  23670. static set OpacityTextureEnabled(value: boolean);
  23671. private static _ReflectionTextureEnabled;
  23672. /**
  23673. * Are reflection textures enabled in the application.
  23674. */
  23675. static get ReflectionTextureEnabled(): boolean;
  23676. static set ReflectionTextureEnabled(value: boolean);
  23677. private static _EmissiveTextureEnabled;
  23678. /**
  23679. * Are emissive textures enabled in the application.
  23680. */
  23681. static get EmissiveTextureEnabled(): boolean;
  23682. static set EmissiveTextureEnabled(value: boolean);
  23683. private static _SpecularTextureEnabled;
  23684. /**
  23685. * Are specular textures enabled in the application.
  23686. */
  23687. static get SpecularTextureEnabled(): boolean;
  23688. static set SpecularTextureEnabled(value: boolean);
  23689. private static _BumpTextureEnabled;
  23690. /**
  23691. * Are bump textures enabled in the application.
  23692. */
  23693. static get BumpTextureEnabled(): boolean;
  23694. static set BumpTextureEnabled(value: boolean);
  23695. private static _LightmapTextureEnabled;
  23696. /**
  23697. * Are lightmap textures enabled in the application.
  23698. */
  23699. static get LightmapTextureEnabled(): boolean;
  23700. static set LightmapTextureEnabled(value: boolean);
  23701. private static _RefractionTextureEnabled;
  23702. /**
  23703. * Are refraction textures enabled in the application.
  23704. */
  23705. static get RefractionTextureEnabled(): boolean;
  23706. static set RefractionTextureEnabled(value: boolean);
  23707. private static _ColorGradingTextureEnabled;
  23708. /**
  23709. * Are color grading textures enabled in the application.
  23710. */
  23711. static get ColorGradingTextureEnabled(): boolean;
  23712. static set ColorGradingTextureEnabled(value: boolean);
  23713. private static _FresnelEnabled;
  23714. /**
  23715. * Are fresnels enabled in the application.
  23716. */
  23717. static get FresnelEnabled(): boolean;
  23718. static set FresnelEnabled(value: boolean);
  23719. private static _ClearCoatTextureEnabled;
  23720. /**
  23721. * Are clear coat textures enabled in the application.
  23722. */
  23723. static get ClearCoatTextureEnabled(): boolean;
  23724. static set ClearCoatTextureEnabled(value: boolean);
  23725. private static _ClearCoatBumpTextureEnabled;
  23726. /**
  23727. * Are clear coat bump textures enabled in the application.
  23728. */
  23729. static get ClearCoatBumpTextureEnabled(): boolean;
  23730. static set ClearCoatBumpTextureEnabled(value: boolean);
  23731. private static _ClearCoatTintTextureEnabled;
  23732. /**
  23733. * Are clear coat tint textures enabled in the application.
  23734. */
  23735. static get ClearCoatTintTextureEnabled(): boolean;
  23736. static set ClearCoatTintTextureEnabled(value: boolean);
  23737. private static _SheenTextureEnabled;
  23738. /**
  23739. * Are sheen textures enabled in the application.
  23740. */
  23741. static get SheenTextureEnabled(): boolean;
  23742. static set SheenTextureEnabled(value: boolean);
  23743. private static _AnisotropicTextureEnabled;
  23744. /**
  23745. * Are anisotropic textures enabled in the application.
  23746. */
  23747. static get AnisotropicTextureEnabled(): boolean;
  23748. static set AnisotropicTextureEnabled(value: boolean);
  23749. private static _ThicknessTextureEnabled;
  23750. /**
  23751. * Are thickness textures enabled in the application.
  23752. */
  23753. static get ThicknessTextureEnabled(): boolean;
  23754. static set ThicknessTextureEnabled(value: boolean);
  23755. }
  23756. }
  23757. declare module BABYLON {
  23758. /** @hidden */
  23759. export var defaultFragmentDeclaration: {
  23760. name: string;
  23761. shader: string;
  23762. };
  23763. }
  23764. declare module BABYLON {
  23765. /** @hidden */
  23766. export var defaultUboDeclaration: {
  23767. name: string;
  23768. shader: string;
  23769. };
  23770. }
  23771. declare module BABYLON {
  23772. /** @hidden */
  23773. export var prePassDeclaration: {
  23774. name: string;
  23775. shader: string;
  23776. };
  23777. }
  23778. declare module BABYLON {
  23779. /** @hidden */
  23780. export var lightFragmentDeclaration: {
  23781. name: string;
  23782. shader: string;
  23783. };
  23784. }
  23785. declare module BABYLON {
  23786. /** @hidden */
  23787. export var lightUboDeclaration: {
  23788. name: string;
  23789. shader: string;
  23790. };
  23791. }
  23792. declare module BABYLON {
  23793. /** @hidden */
  23794. export var lightsFragmentFunctions: {
  23795. name: string;
  23796. shader: string;
  23797. };
  23798. }
  23799. declare module BABYLON {
  23800. /** @hidden */
  23801. export var shadowsFragmentFunctions: {
  23802. name: string;
  23803. shader: string;
  23804. };
  23805. }
  23806. declare module BABYLON {
  23807. /** @hidden */
  23808. export var fresnelFunction: {
  23809. name: string;
  23810. shader: string;
  23811. };
  23812. }
  23813. declare module BABYLON {
  23814. /** @hidden */
  23815. export var bumpFragmentMainFunctions: {
  23816. name: string;
  23817. shader: string;
  23818. };
  23819. }
  23820. declare module BABYLON {
  23821. /** @hidden */
  23822. export var bumpFragmentFunctions: {
  23823. name: string;
  23824. shader: string;
  23825. };
  23826. }
  23827. declare module BABYLON {
  23828. /** @hidden */
  23829. export var logDepthDeclaration: {
  23830. name: string;
  23831. shader: string;
  23832. };
  23833. }
  23834. declare module BABYLON {
  23835. /** @hidden */
  23836. export var bumpFragment: {
  23837. name: string;
  23838. shader: string;
  23839. };
  23840. }
  23841. declare module BABYLON {
  23842. /** @hidden */
  23843. export var depthPrePass: {
  23844. name: string;
  23845. shader: string;
  23846. };
  23847. }
  23848. declare module BABYLON {
  23849. /** @hidden */
  23850. export var lightFragment: {
  23851. name: string;
  23852. shader: string;
  23853. };
  23854. }
  23855. declare module BABYLON {
  23856. /** @hidden */
  23857. export var logDepthFragment: {
  23858. name: string;
  23859. shader: string;
  23860. };
  23861. }
  23862. declare module BABYLON {
  23863. /** @hidden */
  23864. export var defaultPixelShader: {
  23865. name: string;
  23866. shader: string;
  23867. };
  23868. }
  23869. declare module BABYLON {
  23870. /** @hidden */
  23871. export var defaultVertexDeclaration: {
  23872. name: string;
  23873. shader: string;
  23874. };
  23875. }
  23876. declare module BABYLON {
  23877. /** @hidden */
  23878. export var prePassVertexDeclaration: {
  23879. name: string;
  23880. shader: string;
  23881. };
  23882. }
  23883. declare module BABYLON {
  23884. /** @hidden */
  23885. export var bumpVertexDeclaration: {
  23886. name: string;
  23887. shader: string;
  23888. };
  23889. }
  23890. declare module BABYLON {
  23891. /** @hidden */
  23892. export var prePassVertex: {
  23893. name: string;
  23894. shader: string;
  23895. };
  23896. }
  23897. declare module BABYLON {
  23898. /** @hidden */
  23899. export var bumpVertex: {
  23900. name: string;
  23901. shader: string;
  23902. };
  23903. }
  23904. declare module BABYLON {
  23905. /** @hidden */
  23906. export var fogVertex: {
  23907. name: string;
  23908. shader: string;
  23909. };
  23910. }
  23911. declare module BABYLON {
  23912. /** @hidden */
  23913. export var shadowsVertex: {
  23914. name: string;
  23915. shader: string;
  23916. };
  23917. }
  23918. declare module BABYLON {
  23919. /** @hidden */
  23920. export var pointCloudVertex: {
  23921. name: string;
  23922. shader: string;
  23923. };
  23924. }
  23925. declare module BABYLON {
  23926. /** @hidden */
  23927. export var logDepthVertex: {
  23928. name: string;
  23929. shader: string;
  23930. };
  23931. }
  23932. declare module BABYLON {
  23933. /** @hidden */
  23934. export var defaultVertexShader: {
  23935. name: string;
  23936. shader: string;
  23937. };
  23938. }
  23939. declare module BABYLON {
  23940. /**
  23941. * @hidden
  23942. */
  23943. export interface IMaterialDetailMapDefines {
  23944. DETAIL: boolean;
  23945. DETAILDIRECTUV: number;
  23946. DETAIL_NORMALBLENDMETHOD: number;
  23947. /** @hidden */
  23948. _areTexturesDirty: boolean;
  23949. }
  23950. /**
  23951. * Define the code related to the detail map parameters of a material
  23952. *
  23953. * Inspired from:
  23954. * 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
  23955. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  23956. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  23957. */
  23958. export class DetailMapConfiguration {
  23959. private _texture;
  23960. /**
  23961. * The detail texture of the material.
  23962. */
  23963. texture: Nullable<BaseTexture>;
  23964. /**
  23965. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  23966. * Bigger values mean stronger blending
  23967. */
  23968. diffuseBlendLevel: number;
  23969. /**
  23970. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  23971. * Bigger values mean stronger blending. Only used with PBR materials
  23972. */
  23973. roughnessBlendLevel: number;
  23974. /**
  23975. * Defines how strong the bump effect from the detail map is
  23976. * Bigger values mean stronger effect
  23977. */
  23978. bumpLevel: number;
  23979. private _normalBlendMethod;
  23980. /**
  23981. * The method used to blend the bump and detail normals together
  23982. */
  23983. normalBlendMethod: number;
  23984. private _isEnabled;
  23985. /**
  23986. * Enable or disable the detail map on this material
  23987. */
  23988. isEnabled: boolean;
  23989. /** @hidden */
  23990. private _internalMarkAllSubMeshesAsTexturesDirty;
  23991. /** @hidden */
  23992. _markAllSubMeshesAsTexturesDirty(): void;
  23993. /**
  23994. * Instantiate a new detail map
  23995. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  23996. */
  23997. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  23998. /**
  23999. * Gets whether the submesh is ready to be used or not.
  24000. * @param defines the list of "defines" to update.
  24001. * @param scene defines the scene the material belongs to.
  24002. * @returns - boolean indicating that the submesh is ready or not.
  24003. */
  24004. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  24005. /**
  24006. * Update the defines for detail map usage
  24007. * @param defines the list of "defines" to update.
  24008. * @param scene defines the scene the material belongs to.
  24009. */
  24010. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  24011. /**
  24012. * Binds the material data.
  24013. * @param uniformBuffer defines the Uniform buffer to fill in.
  24014. * @param scene defines the scene the material belongs to.
  24015. * @param isFrozen defines whether the material is frozen or not.
  24016. */
  24017. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  24018. /**
  24019. * Checks to see if a texture is used in the material.
  24020. * @param texture - Base texture to use.
  24021. * @returns - Boolean specifying if a texture is used in the material.
  24022. */
  24023. hasTexture(texture: BaseTexture): boolean;
  24024. /**
  24025. * Returns an array of the actively used textures.
  24026. * @param activeTextures Array of BaseTextures
  24027. */
  24028. getActiveTextures(activeTextures: BaseTexture[]): void;
  24029. /**
  24030. * Returns the animatable textures.
  24031. * @param animatables Array of animatable textures.
  24032. */
  24033. getAnimatables(animatables: IAnimatable[]): void;
  24034. /**
  24035. * Disposes the resources of the material.
  24036. * @param forceDisposeTextures - Forces the disposal of all textures.
  24037. */
  24038. dispose(forceDisposeTextures?: boolean): void;
  24039. /**
  24040. * Get the current class name useful for serialization or dynamic coding.
  24041. * @returns "DetailMap"
  24042. */
  24043. getClassName(): string;
  24044. /**
  24045. * Add the required uniforms to the current list.
  24046. * @param uniforms defines the current uniform list.
  24047. */
  24048. static AddUniforms(uniforms: string[]): void;
  24049. /**
  24050. * Add the required samplers to the current list.
  24051. * @param samplers defines the current sampler list.
  24052. */
  24053. static AddSamplers(samplers: string[]): void;
  24054. /**
  24055. * Add the required uniforms to the current buffer.
  24056. * @param uniformBuffer defines the current uniform buffer.
  24057. */
  24058. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  24059. /**
  24060. * Makes a duplicate of the current instance into another one.
  24061. * @param detailMap define the instance where to copy the info
  24062. */
  24063. copyTo(detailMap: DetailMapConfiguration): void;
  24064. /**
  24065. * Serializes this detail map instance
  24066. * @returns - An object with the serialized instance.
  24067. */
  24068. serialize(): any;
  24069. /**
  24070. * Parses a detail map setting from a serialized object.
  24071. * @param source - Serialized object.
  24072. * @param scene Defines the scene we are parsing for
  24073. * @param rootUrl Defines the rootUrl to load from
  24074. */
  24075. parse(source: any, scene: Scene, rootUrl: string): void;
  24076. }
  24077. }
  24078. declare module BABYLON {
  24079. /** @hidden */
  24080. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  24081. MAINUV1: boolean;
  24082. MAINUV2: boolean;
  24083. DIFFUSE: boolean;
  24084. DIFFUSEDIRECTUV: number;
  24085. DETAIL: boolean;
  24086. DETAILDIRECTUV: number;
  24087. DETAIL_NORMALBLENDMETHOD: number;
  24088. AMBIENT: boolean;
  24089. AMBIENTDIRECTUV: number;
  24090. OPACITY: boolean;
  24091. OPACITYDIRECTUV: number;
  24092. OPACITYRGB: boolean;
  24093. REFLECTION: boolean;
  24094. EMISSIVE: boolean;
  24095. EMISSIVEDIRECTUV: number;
  24096. SPECULAR: boolean;
  24097. SPECULARDIRECTUV: number;
  24098. BUMP: boolean;
  24099. BUMPDIRECTUV: number;
  24100. PARALLAX: boolean;
  24101. PARALLAXOCCLUSION: boolean;
  24102. SPECULAROVERALPHA: boolean;
  24103. CLIPPLANE: boolean;
  24104. CLIPPLANE2: boolean;
  24105. CLIPPLANE3: boolean;
  24106. CLIPPLANE4: boolean;
  24107. CLIPPLANE5: boolean;
  24108. CLIPPLANE6: boolean;
  24109. ALPHATEST: boolean;
  24110. DEPTHPREPASS: boolean;
  24111. ALPHAFROMDIFFUSE: boolean;
  24112. POINTSIZE: boolean;
  24113. FOG: boolean;
  24114. SPECULARTERM: boolean;
  24115. DIFFUSEFRESNEL: boolean;
  24116. OPACITYFRESNEL: boolean;
  24117. REFLECTIONFRESNEL: boolean;
  24118. REFRACTIONFRESNEL: boolean;
  24119. EMISSIVEFRESNEL: boolean;
  24120. FRESNEL: boolean;
  24121. NORMAL: boolean;
  24122. UV1: boolean;
  24123. UV2: boolean;
  24124. VERTEXCOLOR: boolean;
  24125. VERTEXALPHA: boolean;
  24126. NUM_BONE_INFLUENCERS: number;
  24127. BonesPerMesh: number;
  24128. BONETEXTURE: boolean;
  24129. BONES_VELOCITY_ENABLED: boolean;
  24130. INSTANCES: boolean;
  24131. THIN_INSTANCES: boolean;
  24132. GLOSSINESS: boolean;
  24133. ROUGHNESS: boolean;
  24134. EMISSIVEASILLUMINATION: boolean;
  24135. LINKEMISSIVEWITHDIFFUSE: boolean;
  24136. REFLECTIONFRESNELFROMSPECULAR: boolean;
  24137. LIGHTMAP: boolean;
  24138. LIGHTMAPDIRECTUV: number;
  24139. OBJECTSPACE_NORMALMAP: boolean;
  24140. USELIGHTMAPASSHADOWMAP: boolean;
  24141. REFLECTIONMAP_3D: boolean;
  24142. REFLECTIONMAP_SPHERICAL: boolean;
  24143. REFLECTIONMAP_PLANAR: boolean;
  24144. REFLECTIONMAP_CUBIC: boolean;
  24145. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  24146. REFLECTIONMAP_PROJECTION: boolean;
  24147. REFLECTIONMAP_SKYBOX: boolean;
  24148. REFLECTIONMAP_EXPLICIT: boolean;
  24149. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  24150. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  24151. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  24152. INVERTCUBICMAP: boolean;
  24153. LOGARITHMICDEPTH: boolean;
  24154. REFRACTION: boolean;
  24155. REFRACTIONMAP_3D: boolean;
  24156. REFLECTIONOVERALPHA: boolean;
  24157. TWOSIDEDLIGHTING: boolean;
  24158. SHADOWFLOAT: boolean;
  24159. MORPHTARGETS: boolean;
  24160. MORPHTARGETS_NORMAL: boolean;
  24161. MORPHTARGETS_TANGENT: boolean;
  24162. MORPHTARGETS_UV: boolean;
  24163. NUM_MORPH_INFLUENCERS: number;
  24164. NONUNIFORMSCALING: boolean;
  24165. PREMULTIPLYALPHA: boolean;
  24166. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  24167. ALPHABLEND: boolean;
  24168. PREPASS: boolean;
  24169. PREPASS_IRRADIANCE: boolean;
  24170. PREPASS_IRRADIANCE_INDEX: number;
  24171. PREPASS_ALBEDO: boolean;
  24172. PREPASS_ALBEDO_INDEX: number;
  24173. PREPASS_DEPTHNORMAL: boolean;
  24174. PREPASS_DEPTHNORMAL_INDEX: number;
  24175. PREPASS_POSITION: boolean;
  24176. PREPASS_POSITION_INDEX: number;
  24177. PREPASS_VELOCITY: boolean;
  24178. PREPASS_VELOCITY_INDEX: number;
  24179. PREPASS_REFLECTIVITY: boolean;
  24180. PREPASS_REFLECTIVITY_INDEX: number;
  24181. SCENE_MRT_COUNT: number;
  24182. RGBDLIGHTMAP: boolean;
  24183. RGBDREFLECTION: boolean;
  24184. RGBDREFRACTION: boolean;
  24185. IMAGEPROCESSING: boolean;
  24186. VIGNETTE: boolean;
  24187. VIGNETTEBLENDMODEMULTIPLY: boolean;
  24188. VIGNETTEBLENDMODEOPAQUE: boolean;
  24189. TONEMAPPING: boolean;
  24190. TONEMAPPING_ACES: boolean;
  24191. CONTRAST: boolean;
  24192. COLORCURVES: boolean;
  24193. COLORGRADING: boolean;
  24194. COLORGRADING3D: boolean;
  24195. SAMPLER3DGREENDEPTH: boolean;
  24196. SAMPLER3DBGRMAP: boolean;
  24197. IMAGEPROCESSINGPOSTPROCESS: boolean;
  24198. MULTIVIEW: boolean;
  24199. /**
  24200. * If the reflection texture on this material is in linear color space
  24201. * @hidden
  24202. */
  24203. IS_REFLECTION_LINEAR: boolean;
  24204. /**
  24205. * If the refraction texture on this material is in linear color space
  24206. * @hidden
  24207. */
  24208. IS_REFRACTION_LINEAR: boolean;
  24209. EXPOSURE: boolean;
  24210. constructor();
  24211. setReflectionMode(modeToEnable: string): void;
  24212. }
  24213. /**
  24214. * This is the default material used in Babylon. It is the best trade off between quality
  24215. * and performances.
  24216. * @see https://doc.babylonjs.com/babylon101/materials
  24217. */
  24218. export class StandardMaterial extends PushMaterial {
  24219. private _diffuseTexture;
  24220. /**
  24221. * The basic texture of the material as viewed under a light.
  24222. */
  24223. diffuseTexture: Nullable<BaseTexture>;
  24224. private _ambientTexture;
  24225. /**
  24226. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  24227. */
  24228. ambientTexture: Nullable<BaseTexture>;
  24229. private _opacityTexture;
  24230. /**
  24231. * Define the transparency of the material from a texture.
  24232. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  24233. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  24234. */
  24235. opacityTexture: Nullable<BaseTexture>;
  24236. private _reflectionTexture;
  24237. /**
  24238. * Define the texture used to display the reflection.
  24239. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24240. */
  24241. reflectionTexture: Nullable<BaseTexture>;
  24242. private _emissiveTexture;
  24243. /**
  24244. * Define texture of the material as if self lit.
  24245. * This will be mixed in the final result even in the absence of light.
  24246. */
  24247. emissiveTexture: Nullable<BaseTexture>;
  24248. private _specularTexture;
  24249. /**
  24250. * Define how the color and intensity of the highlight given by the light in the material.
  24251. */
  24252. specularTexture: Nullable<BaseTexture>;
  24253. private _bumpTexture;
  24254. /**
  24255. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  24256. * 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.
  24257. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  24258. */
  24259. bumpTexture: Nullable<BaseTexture>;
  24260. private _lightmapTexture;
  24261. /**
  24262. * Complex lighting can be computationally expensive to compute at runtime.
  24263. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  24264. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  24265. */
  24266. lightmapTexture: Nullable<BaseTexture>;
  24267. private _refractionTexture;
  24268. /**
  24269. * Define the texture used to display the refraction.
  24270. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24271. */
  24272. refractionTexture: Nullable<BaseTexture>;
  24273. /**
  24274. * The color of the material lit by the environmental background lighting.
  24275. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  24276. */
  24277. ambientColor: Color3;
  24278. /**
  24279. * The basic color of the material as viewed under a light.
  24280. */
  24281. diffuseColor: Color3;
  24282. /**
  24283. * Define how the color and intensity of the highlight given by the light in the material.
  24284. */
  24285. specularColor: Color3;
  24286. /**
  24287. * Define the color of the material as if self lit.
  24288. * This will be mixed in the final result even in the absence of light.
  24289. */
  24290. emissiveColor: Color3;
  24291. /**
  24292. * Defines how sharp are the highlights in the material.
  24293. * The bigger the value the sharper giving a more glossy feeling to the result.
  24294. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  24295. */
  24296. specularPower: number;
  24297. private _useAlphaFromDiffuseTexture;
  24298. /**
  24299. * Does the transparency come from the diffuse texture alpha channel.
  24300. */
  24301. useAlphaFromDiffuseTexture: boolean;
  24302. private _useEmissiveAsIllumination;
  24303. /**
  24304. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  24305. */
  24306. useEmissiveAsIllumination: boolean;
  24307. private _linkEmissiveWithDiffuse;
  24308. /**
  24309. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  24310. * the emissive level when the final color is close to one.
  24311. */
  24312. linkEmissiveWithDiffuse: boolean;
  24313. private _useSpecularOverAlpha;
  24314. /**
  24315. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  24316. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  24317. */
  24318. useSpecularOverAlpha: boolean;
  24319. private _useReflectionOverAlpha;
  24320. /**
  24321. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  24322. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  24323. */
  24324. useReflectionOverAlpha: boolean;
  24325. private _disableLighting;
  24326. /**
  24327. * Does lights from the scene impacts this material.
  24328. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  24329. */
  24330. disableLighting: boolean;
  24331. private _useObjectSpaceNormalMap;
  24332. /**
  24333. * Allows using an object space normal map (instead of tangent space).
  24334. */
  24335. useObjectSpaceNormalMap: boolean;
  24336. private _useParallax;
  24337. /**
  24338. * Is parallax enabled or not.
  24339. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  24340. */
  24341. useParallax: boolean;
  24342. private _useParallaxOcclusion;
  24343. /**
  24344. * Is parallax occlusion enabled or not.
  24345. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  24346. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  24347. */
  24348. useParallaxOcclusion: boolean;
  24349. /**
  24350. * 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.
  24351. */
  24352. parallaxScaleBias: number;
  24353. private _roughness;
  24354. /**
  24355. * Helps to define how blurry the reflections should appears in the material.
  24356. */
  24357. roughness: number;
  24358. /**
  24359. * In case of refraction, define the value of the index of refraction.
  24360. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24361. */
  24362. indexOfRefraction: number;
  24363. /**
  24364. * Invert the refraction texture alongside the y axis.
  24365. * It can be useful with procedural textures or probe for instance.
  24366. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24367. */
  24368. invertRefractionY: boolean;
  24369. /**
  24370. * Defines the alpha limits in alpha test mode.
  24371. */
  24372. alphaCutOff: number;
  24373. private _useLightmapAsShadowmap;
  24374. /**
  24375. * In case of light mapping, define whether the map contains light or shadow informations.
  24376. */
  24377. useLightmapAsShadowmap: boolean;
  24378. private _diffuseFresnelParameters;
  24379. /**
  24380. * Define the diffuse fresnel parameters of the material.
  24381. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24382. */
  24383. diffuseFresnelParameters: FresnelParameters;
  24384. private _opacityFresnelParameters;
  24385. /**
  24386. * Define the opacity fresnel parameters of the material.
  24387. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24388. */
  24389. opacityFresnelParameters: FresnelParameters;
  24390. private _reflectionFresnelParameters;
  24391. /**
  24392. * Define the reflection fresnel parameters of the material.
  24393. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24394. */
  24395. reflectionFresnelParameters: FresnelParameters;
  24396. private _refractionFresnelParameters;
  24397. /**
  24398. * Define the refraction fresnel parameters of the material.
  24399. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24400. */
  24401. refractionFresnelParameters: FresnelParameters;
  24402. private _emissiveFresnelParameters;
  24403. /**
  24404. * Define the emissive fresnel parameters of the material.
  24405. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24406. */
  24407. emissiveFresnelParameters: FresnelParameters;
  24408. private _useReflectionFresnelFromSpecular;
  24409. /**
  24410. * If true automatically deducts the fresnels values from the material specularity.
  24411. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24412. */
  24413. useReflectionFresnelFromSpecular: boolean;
  24414. private _useGlossinessFromSpecularMapAlpha;
  24415. /**
  24416. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  24417. */
  24418. useGlossinessFromSpecularMapAlpha: boolean;
  24419. private _maxSimultaneousLights;
  24420. /**
  24421. * Defines the maximum number of lights that can be used in the material
  24422. */
  24423. maxSimultaneousLights: number;
  24424. private _invertNormalMapX;
  24425. /**
  24426. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  24427. */
  24428. invertNormalMapX: boolean;
  24429. private _invertNormalMapY;
  24430. /**
  24431. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  24432. */
  24433. invertNormalMapY: boolean;
  24434. private _twoSidedLighting;
  24435. /**
  24436. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  24437. */
  24438. twoSidedLighting: boolean;
  24439. /**
  24440. * Default configuration related to image processing available in the standard Material.
  24441. */
  24442. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24443. /**
  24444. * Gets the image processing configuration used either in this material.
  24445. */
  24446. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  24447. /**
  24448. * Sets the Default image processing configuration used either in the this material.
  24449. *
  24450. * If sets to null, the scene one is in use.
  24451. */
  24452. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  24453. /**
  24454. * Keep track of the image processing observer to allow dispose and replace.
  24455. */
  24456. private _imageProcessingObserver;
  24457. /**
  24458. * Attaches a new image processing configuration to the Standard Material.
  24459. * @param configuration
  24460. */
  24461. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  24462. /**
  24463. * Defines additionnal PrePass parameters for the material.
  24464. */
  24465. readonly prePassConfiguration: PrePassConfiguration;
  24466. /**
  24467. * Gets wether the color curves effect is enabled.
  24468. */
  24469. get cameraColorCurvesEnabled(): boolean;
  24470. /**
  24471. * Sets wether the color curves effect is enabled.
  24472. */
  24473. set cameraColorCurvesEnabled(value: boolean);
  24474. /**
  24475. * Gets wether the color grading effect is enabled.
  24476. */
  24477. get cameraColorGradingEnabled(): boolean;
  24478. /**
  24479. * Gets wether the color grading effect is enabled.
  24480. */
  24481. set cameraColorGradingEnabled(value: boolean);
  24482. /**
  24483. * Gets wether tonemapping is enabled or not.
  24484. */
  24485. get cameraToneMappingEnabled(): boolean;
  24486. /**
  24487. * Sets wether tonemapping is enabled or not
  24488. */
  24489. set cameraToneMappingEnabled(value: boolean);
  24490. /**
  24491. * The camera exposure used on this material.
  24492. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  24493. * This corresponds to a photographic exposure.
  24494. */
  24495. get cameraExposure(): number;
  24496. /**
  24497. * The camera exposure used on this material.
  24498. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  24499. * This corresponds to a photographic exposure.
  24500. */
  24501. set cameraExposure(value: number);
  24502. /**
  24503. * Gets The camera contrast used on this material.
  24504. */
  24505. get cameraContrast(): number;
  24506. /**
  24507. * Sets The camera contrast used on this material.
  24508. */
  24509. set cameraContrast(value: number);
  24510. /**
  24511. * Gets the Color Grading 2D Lookup Texture.
  24512. */
  24513. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  24514. /**
  24515. * Sets the Color Grading 2D Lookup Texture.
  24516. */
  24517. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  24518. /**
  24519. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  24520. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  24521. * 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;
  24522. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  24523. */
  24524. get cameraColorCurves(): Nullable<ColorCurves>;
  24525. /**
  24526. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  24527. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  24528. * 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;
  24529. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  24530. */
  24531. set cameraColorCurves(value: Nullable<ColorCurves>);
  24532. /**
  24533. * Can this material render to several textures at once
  24534. */
  24535. get canRenderToMRT(): boolean;
  24536. /**
  24537. * Defines the detail map parameters for the material.
  24538. */
  24539. readonly detailMap: DetailMapConfiguration;
  24540. protected _renderTargets: SmartArray<RenderTargetTexture>;
  24541. protected _worldViewProjectionMatrix: Matrix;
  24542. protected _globalAmbientColor: Color3;
  24543. protected _useLogarithmicDepth: boolean;
  24544. protected _rebuildInParallel: boolean;
  24545. /**
  24546. * Instantiates a new standard material.
  24547. * This is the default material used in Babylon. It is the best trade off between quality
  24548. * and performances.
  24549. * @see https://doc.babylonjs.com/babylon101/materials
  24550. * @param name Define the name of the material in the scene
  24551. * @param scene Define the scene the material belong to
  24552. */
  24553. constructor(name: string, scene: Scene);
  24554. /**
  24555. * Gets a boolean indicating that current material needs to register RTT
  24556. */
  24557. get hasRenderTargetTextures(): boolean;
  24558. /**
  24559. * Gets the current class name of the material e.g. "StandardMaterial"
  24560. * Mainly use in serialization.
  24561. * @returns the class name
  24562. */
  24563. getClassName(): string;
  24564. /**
  24565. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  24566. * You can try switching to logarithmic depth.
  24567. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  24568. */
  24569. get useLogarithmicDepth(): boolean;
  24570. set useLogarithmicDepth(value: boolean);
  24571. /**
  24572. * Specifies if the material will require alpha blending
  24573. * @returns a boolean specifying if alpha blending is needed
  24574. */
  24575. needAlphaBlending(): boolean;
  24576. /**
  24577. * Specifies if this material should be rendered in alpha test mode
  24578. * @returns a boolean specifying if an alpha test is needed.
  24579. */
  24580. needAlphaTesting(): boolean;
  24581. /**
  24582. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  24583. */
  24584. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  24585. /**
  24586. * Specifies whether or not there is a usable alpha channel for transparency.
  24587. */
  24588. protected _hasAlphaChannel(): boolean;
  24589. /**
  24590. * Get the texture used for alpha test purpose.
  24591. * @returns the diffuse texture in case of the standard material.
  24592. */
  24593. getAlphaTestTexture(): Nullable<BaseTexture>;
  24594. /**
  24595. * Get if the submesh is ready to be used and all its information available.
  24596. * Child classes can use it to update shaders
  24597. * @param mesh defines the mesh to check
  24598. * @param subMesh defines which submesh to check
  24599. * @param useInstances specifies that instances should be used
  24600. * @returns a boolean indicating that the submesh is ready or not
  24601. */
  24602. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24603. /**
  24604. * Builds the material UBO layouts.
  24605. * Used internally during the effect preparation.
  24606. */
  24607. buildUniformLayout(): void;
  24608. /**
  24609. * Unbinds the material from the mesh
  24610. */
  24611. unbind(): void;
  24612. /**
  24613. * Binds the submesh to this material by preparing the effect and shader to draw
  24614. * @param world defines the world transformation matrix
  24615. * @param mesh defines the mesh containing the submesh
  24616. * @param subMesh defines the submesh to bind the material to
  24617. */
  24618. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24619. /**
  24620. * Get the list of animatables in the material.
  24621. * @returns the list of animatables object used in the material
  24622. */
  24623. getAnimatables(): IAnimatable[];
  24624. /**
  24625. * Gets the active textures from the material
  24626. * @returns an array of textures
  24627. */
  24628. getActiveTextures(): BaseTexture[];
  24629. /**
  24630. * Specifies if the material uses a texture
  24631. * @param texture defines the texture to check against the material
  24632. * @returns a boolean specifying if the material uses the texture
  24633. */
  24634. hasTexture(texture: BaseTexture): boolean;
  24635. /**
  24636. * Disposes the material
  24637. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  24638. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  24639. */
  24640. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  24641. /**
  24642. * Makes a duplicate of the material, and gives it a new name
  24643. * @param name defines the new name for the duplicated material
  24644. * @returns the cloned material
  24645. */
  24646. clone(name: string): StandardMaterial;
  24647. /**
  24648. * Serializes this material in a JSON representation
  24649. * @returns the serialized material object
  24650. */
  24651. serialize(): any;
  24652. /**
  24653. * Creates a standard material from parsed material data
  24654. * @param source defines the JSON representation of the material
  24655. * @param scene defines the hosting scene
  24656. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24657. * @returns a new standard material
  24658. */
  24659. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  24660. /**
  24661. * Are diffuse textures enabled in the application.
  24662. */
  24663. static get DiffuseTextureEnabled(): boolean;
  24664. static set DiffuseTextureEnabled(value: boolean);
  24665. /**
  24666. * Are detail textures enabled in the application.
  24667. */
  24668. static get DetailTextureEnabled(): boolean;
  24669. static set DetailTextureEnabled(value: boolean);
  24670. /**
  24671. * Are ambient textures enabled in the application.
  24672. */
  24673. static get AmbientTextureEnabled(): boolean;
  24674. static set AmbientTextureEnabled(value: boolean);
  24675. /**
  24676. * Are opacity textures enabled in the application.
  24677. */
  24678. static get OpacityTextureEnabled(): boolean;
  24679. static set OpacityTextureEnabled(value: boolean);
  24680. /**
  24681. * Are reflection textures enabled in the application.
  24682. */
  24683. static get ReflectionTextureEnabled(): boolean;
  24684. static set ReflectionTextureEnabled(value: boolean);
  24685. /**
  24686. * Are emissive textures enabled in the application.
  24687. */
  24688. static get EmissiveTextureEnabled(): boolean;
  24689. static set EmissiveTextureEnabled(value: boolean);
  24690. /**
  24691. * Are specular textures enabled in the application.
  24692. */
  24693. static get SpecularTextureEnabled(): boolean;
  24694. static set SpecularTextureEnabled(value: boolean);
  24695. /**
  24696. * Are bump textures enabled in the application.
  24697. */
  24698. static get BumpTextureEnabled(): boolean;
  24699. static set BumpTextureEnabled(value: boolean);
  24700. /**
  24701. * Are lightmap textures enabled in the application.
  24702. */
  24703. static get LightmapTextureEnabled(): boolean;
  24704. static set LightmapTextureEnabled(value: boolean);
  24705. /**
  24706. * Are refraction textures enabled in the application.
  24707. */
  24708. static get RefractionTextureEnabled(): boolean;
  24709. static set RefractionTextureEnabled(value: boolean);
  24710. /**
  24711. * Are color grading textures enabled in the application.
  24712. */
  24713. static get ColorGradingTextureEnabled(): boolean;
  24714. static set ColorGradingTextureEnabled(value: boolean);
  24715. /**
  24716. * Are fresnels enabled in the application.
  24717. */
  24718. static get FresnelEnabled(): boolean;
  24719. static set FresnelEnabled(value: boolean);
  24720. }
  24721. }
  24722. declare module BABYLON {
  24723. /** @hidden */
  24724. export var rgbdDecodePixelShader: {
  24725. name: string;
  24726. shader: string;
  24727. };
  24728. }
  24729. declare module BABYLON {
  24730. /**
  24731. * Class used to host RGBD texture specific utilities
  24732. */
  24733. export class RGBDTextureTools {
  24734. /**
  24735. * Expand the RGBD Texture from RGBD to Half Float if possible.
  24736. * @param texture the texture to expand.
  24737. */
  24738. static ExpandRGBDTexture(texture: Texture): void;
  24739. }
  24740. }
  24741. declare module BABYLON {
  24742. /**
  24743. * Class used to host texture specific utilities
  24744. */
  24745. export class BRDFTextureTools {
  24746. /**
  24747. * Prevents texture cache collision
  24748. */
  24749. private static _instanceNumber;
  24750. /**
  24751. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  24752. * @param scene defines the hosting scene
  24753. * @returns the environment BRDF texture
  24754. */
  24755. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  24756. private static _environmentBRDFBase64Texture;
  24757. }
  24758. }
  24759. declare module BABYLON {
  24760. /**
  24761. * @hidden
  24762. */
  24763. export interface IMaterialClearCoatDefines {
  24764. CLEARCOAT: boolean;
  24765. CLEARCOAT_DEFAULTIOR: boolean;
  24766. CLEARCOAT_TEXTURE: boolean;
  24767. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  24768. CLEARCOAT_TEXTUREDIRECTUV: number;
  24769. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  24770. CLEARCOAT_BUMP: boolean;
  24771. CLEARCOAT_BUMPDIRECTUV: number;
  24772. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  24773. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  24774. CLEARCOAT_REMAP_F0: boolean;
  24775. CLEARCOAT_TINT: boolean;
  24776. CLEARCOAT_TINT_TEXTURE: boolean;
  24777. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  24778. /** @hidden */
  24779. _areTexturesDirty: boolean;
  24780. }
  24781. /**
  24782. * Define the code related to the clear coat parameters of the pbr material.
  24783. */
  24784. export class PBRClearCoatConfiguration {
  24785. /**
  24786. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  24787. * The default fits with a polyurethane material.
  24788. */
  24789. private static readonly _DefaultIndexOfRefraction;
  24790. private _isEnabled;
  24791. /**
  24792. * Defines if the clear coat is enabled in the material.
  24793. */
  24794. isEnabled: boolean;
  24795. /**
  24796. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  24797. */
  24798. intensity: number;
  24799. /**
  24800. * Defines the clear coat layer roughness.
  24801. */
  24802. roughness: number;
  24803. private _indexOfRefraction;
  24804. /**
  24805. * Defines the index of refraction of the clear coat.
  24806. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  24807. * The default fits with a polyurethane material.
  24808. * Changing the default value is more performance intensive.
  24809. */
  24810. indexOfRefraction: number;
  24811. private _texture;
  24812. /**
  24813. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  24814. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  24815. * if textureRoughness is not empty, else no texture roughness is used
  24816. */
  24817. texture: Nullable<BaseTexture>;
  24818. private _useRoughnessFromMainTexture;
  24819. /**
  24820. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  24821. * If false, the green channel from textureRoughness is used for roughness
  24822. */
  24823. useRoughnessFromMainTexture: boolean;
  24824. private _textureRoughness;
  24825. /**
  24826. * Stores the clear coat roughness in a texture (green channel)
  24827. * Not used if useRoughnessFromMainTexture is true
  24828. */
  24829. textureRoughness: Nullable<BaseTexture>;
  24830. private _remapF0OnInterfaceChange;
  24831. /**
  24832. * Defines if the F0 value should be remapped to account for the interface change in the material.
  24833. */
  24834. remapF0OnInterfaceChange: boolean;
  24835. private _bumpTexture;
  24836. /**
  24837. * Define the clear coat specific bump texture.
  24838. */
  24839. bumpTexture: Nullable<BaseTexture>;
  24840. private _isTintEnabled;
  24841. /**
  24842. * Defines if the clear coat tint is enabled in the material.
  24843. */
  24844. isTintEnabled: boolean;
  24845. /**
  24846. * Defines the clear coat tint of the material.
  24847. * This is only use if tint is enabled
  24848. */
  24849. tintColor: Color3;
  24850. /**
  24851. * Defines the distance at which the tint color should be found in the
  24852. * clear coat media.
  24853. * This is only use if tint is enabled
  24854. */
  24855. tintColorAtDistance: number;
  24856. /**
  24857. * Defines the clear coat layer thickness.
  24858. * This is only use if tint is enabled
  24859. */
  24860. tintThickness: number;
  24861. private _tintTexture;
  24862. /**
  24863. * Stores the clear tint values in a texture.
  24864. * rgb is tint
  24865. * a is a thickness factor
  24866. */
  24867. tintTexture: Nullable<BaseTexture>;
  24868. /** @hidden */
  24869. private _internalMarkAllSubMeshesAsTexturesDirty;
  24870. /** @hidden */
  24871. _markAllSubMeshesAsTexturesDirty(): void;
  24872. /**
  24873. * Instantiate a new istance of clear coat configuration.
  24874. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  24875. */
  24876. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  24877. /**
  24878. * Gets wehter the submesh is ready to be used or not.
  24879. * @param defines the list of "defines" to update.
  24880. * @param scene defines the scene the material belongs to.
  24881. * @param engine defines the engine the material belongs to.
  24882. * @param disableBumpMap defines wether the material disables bump or not.
  24883. * @returns - boolean indicating that the submesh is ready or not.
  24884. */
  24885. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  24886. /**
  24887. * Checks to see if a texture is used in the material.
  24888. * @param defines the list of "defines" to update.
  24889. * @param scene defines the scene to the material belongs to.
  24890. */
  24891. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  24892. /**
  24893. * Binds the material data.
  24894. * @param uniformBuffer defines the Uniform buffer to fill in.
  24895. * @param scene defines the scene the material belongs to.
  24896. * @param engine defines the engine the material belongs to.
  24897. * @param disableBumpMap defines wether the material disables bump or not.
  24898. * @param isFrozen defines wether the material is frozen or not.
  24899. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  24900. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  24901. * @param subMesh the submesh to bind data for
  24902. */
  24903. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  24904. /**
  24905. * Checks to see if a texture is used in the material.
  24906. * @param texture - Base texture to use.
  24907. * @returns - Boolean specifying if a texture is used in the material.
  24908. */
  24909. hasTexture(texture: BaseTexture): boolean;
  24910. /**
  24911. * Returns an array of the actively used textures.
  24912. * @param activeTextures Array of BaseTextures
  24913. */
  24914. getActiveTextures(activeTextures: BaseTexture[]): void;
  24915. /**
  24916. * Returns the animatable textures.
  24917. * @param animatables Array of animatable textures.
  24918. */
  24919. getAnimatables(animatables: IAnimatable[]): void;
  24920. /**
  24921. * Disposes the resources of the material.
  24922. * @param forceDisposeTextures - Forces the disposal of all textures.
  24923. */
  24924. dispose(forceDisposeTextures?: boolean): void;
  24925. /**
  24926. * Get the current class name of the texture useful for serialization or dynamic coding.
  24927. * @returns "PBRClearCoatConfiguration"
  24928. */
  24929. getClassName(): string;
  24930. /**
  24931. * Add fallbacks to the effect fallbacks list.
  24932. * @param defines defines the Base texture to use.
  24933. * @param fallbacks defines the current fallback list.
  24934. * @param currentRank defines the current fallback rank.
  24935. * @returns the new fallback rank.
  24936. */
  24937. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  24938. /**
  24939. * Add the required uniforms to the current list.
  24940. * @param uniforms defines the current uniform list.
  24941. */
  24942. static AddUniforms(uniforms: string[]): void;
  24943. /**
  24944. * Add the required samplers to the current list.
  24945. * @param samplers defines the current sampler list.
  24946. */
  24947. static AddSamplers(samplers: string[]): void;
  24948. /**
  24949. * Add the required uniforms to the current buffer.
  24950. * @param uniformBuffer defines the current uniform buffer.
  24951. */
  24952. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  24953. /**
  24954. * Makes a duplicate of the current configuration into another one.
  24955. * @param clearCoatConfiguration define the config where to copy the info
  24956. */
  24957. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  24958. /**
  24959. * Serializes this clear coat configuration.
  24960. * @returns - An object with the serialized config.
  24961. */
  24962. serialize(): any;
  24963. /**
  24964. * Parses a anisotropy Configuration from a serialized object.
  24965. * @param source - Serialized object.
  24966. * @param scene Defines the scene we are parsing for
  24967. * @param rootUrl Defines the rootUrl to load from
  24968. */
  24969. parse(source: any, scene: Scene, rootUrl: string): void;
  24970. }
  24971. }
  24972. declare module BABYLON {
  24973. /**
  24974. * @hidden
  24975. */
  24976. export interface IMaterialAnisotropicDefines {
  24977. ANISOTROPIC: boolean;
  24978. ANISOTROPIC_TEXTURE: boolean;
  24979. ANISOTROPIC_TEXTUREDIRECTUV: number;
  24980. MAINUV1: boolean;
  24981. _areTexturesDirty: boolean;
  24982. _needUVs: boolean;
  24983. }
  24984. /**
  24985. * Define the code related to the anisotropic parameters of the pbr material.
  24986. */
  24987. export class PBRAnisotropicConfiguration {
  24988. private _isEnabled;
  24989. /**
  24990. * Defines if the anisotropy is enabled in the material.
  24991. */
  24992. isEnabled: boolean;
  24993. /**
  24994. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  24995. */
  24996. intensity: number;
  24997. /**
  24998. * Defines if the effect is along the tangents, bitangents or in between.
  24999. * By default, the effect is "strectching" the highlights along the tangents.
  25000. */
  25001. direction: Vector2;
  25002. private _texture;
  25003. /**
  25004. * Stores the anisotropy values in a texture.
  25005. * rg is direction (like normal from -1 to 1)
  25006. * b is a intensity
  25007. */
  25008. texture: Nullable<BaseTexture>;
  25009. /** @hidden */
  25010. private _internalMarkAllSubMeshesAsTexturesDirty;
  25011. /** @hidden */
  25012. _markAllSubMeshesAsTexturesDirty(): void;
  25013. /**
  25014. * Instantiate a new istance of anisotropy configuration.
  25015. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25016. */
  25017. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25018. /**
  25019. * Specifies that the submesh is ready to be used.
  25020. * @param defines the list of "defines" to update.
  25021. * @param scene defines the scene the material belongs to.
  25022. * @returns - boolean indicating that the submesh is ready or not.
  25023. */
  25024. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  25025. /**
  25026. * Checks to see if a texture is used in the material.
  25027. * @param defines the list of "defines" to update.
  25028. * @param mesh the mesh we are preparing the defines for.
  25029. * @param scene defines the scene the material belongs to.
  25030. */
  25031. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  25032. /**
  25033. * Binds the material data.
  25034. * @param uniformBuffer defines the Uniform buffer to fill in.
  25035. * @param scene defines the scene the material belongs to.
  25036. * @param isFrozen defines wether the material is frozen or not.
  25037. */
  25038. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  25039. /**
  25040. * Checks to see if a texture is used in the material.
  25041. * @param texture - Base texture to use.
  25042. * @returns - Boolean specifying if a texture is used in the material.
  25043. */
  25044. hasTexture(texture: BaseTexture): boolean;
  25045. /**
  25046. * Returns an array of the actively used textures.
  25047. * @param activeTextures Array of BaseTextures
  25048. */
  25049. getActiveTextures(activeTextures: BaseTexture[]): void;
  25050. /**
  25051. * Returns the animatable textures.
  25052. * @param animatables Array of animatable textures.
  25053. */
  25054. getAnimatables(animatables: IAnimatable[]): void;
  25055. /**
  25056. * Disposes the resources of the material.
  25057. * @param forceDisposeTextures - Forces the disposal of all textures.
  25058. */
  25059. dispose(forceDisposeTextures?: boolean): void;
  25060. /**
  25061. * Get the current class name of the texture useful for serialization or dynamic coding.
  25062. * @returns "PBRAnisotropicConfiguration"
  25063. */
  25064. getClassName(): string;
  25065. /**
  25066. * Add fallbacks to the effect fallbacks list.
  25067. * @param defines defines the Base texture to use.
  25068. * @param fallbacks defines the current fallback list.
  25069. * @param currentRank defines the current fallback rank.
  25070. * @returns the new fallback rank.
  25071. */
  25072. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25073. /**
  25074. * Add the required uniforms to the current list.
  25075. * @param uniforms defines the current uniform list.
  25076. */
  25077. static AddUniforms(uniforms: string[]): void;
  25078. /**
  25079. * Add the required uniforms to the current buffer.
  25080. * @param uniformBuffer defines the current uniform buffer.
  25081. */
  25082. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25083. /**
  25084. * Add the required samplers to the current list.
  25085. * @param samplers defines the current sampler list.
  25086. */
  25087. static AddSamplers(samplers: string[]): void;
  25088. /**
  25089. * Makes a duplicate of the current configuration into another one.
  25090. * @param anisotropicConfiguration define the config where to copy the info
  25091. */
  25092. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  25093. /**
  25094. * Serializes this anisotropy configuration.
  25095. * @returns - An object with the serialized config.
  25096. */
  25097. serialize(): any;
  25098. /**
  25099. * Parses a anisotropy Configuration from a serialized object.
  25100. * @param source - Serialized object.
  25101. * @param scene Defines the scene we are parsing for
  25102. * @param rootUrl Defines the rootUrl to load from
  25103. */
  25104. parse(source: any, scene: Scene, rootUrl: string): void;
  25105. }
  25106. }
  25107. declare module BABYLON {
  25108. /**
  25109. * @hidden
  25110. */
  25111. export interface IMaterialBRDFDefines {
  25112. BRDF_V_HEIGHT_CORRELATED: boolean;
  25113. MS_BRDF_ENERGY_CONSERVATION: boolean;
  25114. SPHERICAL_HARMONICS: boolean;
  25115. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  25116. /** @hidden */
  25117. _areMiscDirty: boolean;
  25118. }
  25119. /**
  25120. * Define the code related to the BRDF parameters of the pbr material.
  25121. */
  25122. export class PBRBRDFConfiguration {
  25123. /**
  25124. * Default value used for the energy conservation.
  25125. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  25126. */
  25127. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  25128. /**
  25129. * Default value used for the Smith Visibility Height Correlated mode.
  25130. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  25131. */
  25132. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  25133. /**
  25134. * Default value used for the IBL diffuse part.
  25135. * This can help switching back to the polynomials mode globally which is a tiny bit
  25136. * less GPU intensive at the drawback of a lower quality.
  25137. */
  25138. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  25139. /**
  25140. * Default value used for activating energy conservation for the specular workflow.
  25141. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  25142. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  25143. */
  25144. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  25145. private _useEnergyConservation;
  25146. /**
  25147. * Defines if the material uses energy conservation.
  25148. */
  25149. useEnergyConservation: boolean;
  25150. private _useSmithVisibilityHeightCorrelated;
  25151. /**
  25152. * LEGACY Mode set to false
  25153. * Defines if the material uses height smith correlated visibility term.
  25154. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  25155. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  25156. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  25157. * Not relying on height correlated will also disable energy conservation.
  25158. */
  25159. useSmithVisibilityHeightCorrelated: boolean;
  25160. private _useSphericalHarmonics;
  25161. /**
  25162. * LEGACY Mode set to false
  25163. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  25164. * diffuse part of the IBL.
  25165. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  25166. * to the ground truth.
  25167. */
  25168. useSphericalHarmonics: boolean;
  25169. private _useSpecularGlossinessInputEnergyConservation;
  25170. /**
  25171. * Defines if the material uses energy conservation, when the specular workflow is active.
  25172. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  25173. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  25174. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  25175. */
  25176. useSpecularGlossinessInputEnergyConservation: boolean;
  25177. /** @hidden */
  25178. private _internalMarkAllSubMeshesAsMiscDirty;
  25179. /** @hidden */
  25180. _markAllSubMeshesAsMiscDirty(): void;
  25181. /**
  25182. * Instantiate a new istance of clear coat configuration.
  25183. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  25184. */
  25185. constructor(markAllSubMeshesAsMiscDirty: () => void);
  25186. /**
  25187. * Checks to see if a texture is used in the material.
  25188. * @param defines the list of "defines" to update.
  25189. */
  25190. prepareDefines(defines: IMaterialBRDFDefines): void;
  25191. /**
  25192. * Get the current class name of the texture useful for serialization or dynamic coding.
  25193. * @returns "PBRClearCoatConfiguration"
  25194. */
  25195. getClassName(): string;
  25196. /**
  25197. * Makes a duplicate of the current configuration into another one.
  25198. * @param brdfConfiguration define the config where to copy the info
  25199. */
  25200. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  25201. /**
  25202. * Serializes this BRDF configuration.
  25203. * @returns - An object with the serialized config.
  25204. */
  25205. serialize(): any;
  25206. /**
  25207. * Parses a anisotropy Configuration from a serialized object.
  25208. * @param source - Serialized object.
  25209. * @param scene Defines the scene we are parsing for
  25210. * @param rootUrl Defines the rootUrl to load from
  25211. */
  25212. parse(source: any, scene: Scene, rootUrl: string): void;
  25213. }
  25214. }
  25215. declare module BABYLON {
  25216. /**
  25217. * @hidden
  25218. */
  25219. export interface IMaterialSheenDefines {
  25220. SHEEN: boolean;
  25221. SHEEN_TEXTURE: boolean;
  25222. SHEEN_TEXTURE_ROUGHNESS: boolean;
  25223. SHEEN_TEXTUREDIRECTUV: number;
  25224. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  25225. SHEEN_LINKWITHALBEDO: boolean;
  25226. SHEEN_ROUGHNESS: boolean;
  25227. SHEEN_ALBEDOSCALING: boolean;
  25228. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  25229. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  25230. /** @hidden */
  25231. _areTexturesDirty: boolean;
  25232. }
  25233. /**
  25234. * Define the code related to the Sheen parameters of the pbr material.
  25235. */
  25236. export class PBRSheenConfiguration {
  25237. private _isEnabled;
  25238. /**
  25239. * Defines if the material uses sheen.
  25240. */
  25241. isEnabled: boolean;
  25242. private _linkSheenWithAlbedo;
  25243. /**
  25244. * Defines if the sheen is linked to the sheen color.
  25245. */
  25246. linkSheenWithAlbedo: boolean;
  25247. /**
  25248. * Defines the sheen intensity.
  25249. */
  25250. intensity: number;
  25251. /**
  25252. * Defines the sheen color.
  25253. */
  25254. color: Color3;
  25255. private _texture;
  25256. /**
  25257. * Stores the sheen tint values in a texture.
  25258. * rgb is tint
  25259. * a is a intensity or roughness if the roughness property has been defined and useRoughnessFromTexture is true (in that case, textureRoughness won't be used)
  25260. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  25261. */
  25262. texture: Nullable<BaseTexture>;
  25263. private _useRoughnessFromMainTexture;
  25264. /**
  25265. * Indicates that the alpha channel of the texture property will be used for roughness.
  25266. * Has no effect if the roughness (and texture!) property is not defined
  25267. */
  25268. useRoughnessFromMainTexture: boolean;
  25269. private _roughness;
  25270. /**
  25271. * Defines the sheen roughness.
  25272. * It is not taken into account if linkSheenWithAlbedo is true.
  25273. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  25274. */
  25275. roughness: Nullable<number>;
  25276. private _textureRoughness;
  25277. /**
  25278. * Stores the sheen roughness in a texture.
  25279. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  25280. */
  25281. textureRoughness: Nullable<BaseTexture>;
  25282. private _albedoScaling;
  25283. /**
  25284. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  25285. * It allows the strength of the sheen effect to not depend on the base color of the material,
  25286. * making it easier to setup and tweak the effect
  25287. */
  25288. albedoScaling: boolean;
  25289. /** @hidden */
  25290. private _internalMarkAllSubMeshesAsTexturesDirty;
  25291. /** @hidden */
  25292. _markAllSubMeshesAsTexturesDirty(): void;
  25293. /**
  25294. * Instantiate a new istance of clear coat configuration.
  25295. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25296. */
  25297. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25298. /**
  25299. * Specifies that the submesh is ready to be used.
  25300. * @param defines the list of "defines" to update.
  25301. * @param scene defines the scene the material belongs to.
  25302. * @returns - boolean indicating that the submesh is ready or not.
  25303. */
  25304. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  25305. /**
  25306. * Checks to see if a texture is used in the material.
  25307. * @param defines the list of "defines" to update.
  25308. * @param scene defines the scene the material belongs to.
  25309. */
  25310. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  25311. /**
  25312. * Binds the material data.
  25313. * @param uniformBuffer defines the Uniform buffer to fill in.
  25314. * @param scene defines the scene the material belongs to.
  25315. * @param isFrozen defines wether the material is frozen or not.
  25316. * @param subMesh the submesh to bind data for
  25317. */
  25318. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  25319. /**
  25320. * Checks to see if a texture is used in the material.
  25321. * @param texture - Base texture to use.
  25322. * @returns - Boolean specifying if a texture is used in the material.
  25323. */
  25324. hasTexture(texture: BaseTexture): boolean;
  25325. /**
  25326. * Returns an array of the actively used textures.
  25327. * @param activeTextures Array of BaseTextures
  25328. */
  25329. getActiveTextures(activeTextures: BaseTexture[]): void;
  25330. /**
  25331. * Returns the animatable textures.
  25332. * @param animatables Array of animatable textures.
  25333. */
  25334. getAnimatables(animatables: IAnimatable[]): void;
  25335. /**
  25336. * Disposes the resources of the material.
  25337. * @param forceDisposeTextures - Forces the disposal of all textures.
  25338. */
  25339. dispose(forceDisposeTextures?: boolean): void;
  25340. /**
  25341. * Get the current class name of the texture useful for serialization or dynamic coding.
  25342. * @returns "PBRSheenConfiguration"
  25343. */
  25344. getClassName(): string;
  25345. /**
  25346. * Add fallbacks to the effect fallbacks list.
  25347. * @param defines defines the Base texture to use.
  25348. * @param fallbacks defines the current fallback list.
  25349. * @param currentRank defines the current fallback rank.
  25350. * @returns the new fallback rank.
  25351. */
  25352. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25353. /**
  25354. * Add the required uniforms to the current list.
  25355. * @param uniforms defines the current uniform list.
  25356. */
  25357. static AddUniforms(uniforms: string[]): void;
  25358. /**
  25359. * Add the required uniforms to the current buffer.
  25360. * @param uniformBuffer defines the current uniform buffer.
  25361. */
  25362. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25363. /**
  25364. * Add the required samplers to the current list.
  25365. * @param samplers defines the current sampler list.
  25366. */
  25367. static AddSamplers(samplers: string[]): void;
  25368. /**
  25369. * Makes a duplicate of the current configuration into another one.
  25370. * @param sheenConfiguration define the config where to copy the info
  25371. */
  25372. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  25373. /**
  25374. * Serializes this BRDF configuration.
  25375. * @returns - An object with the serialized config.
  25376. */
  25377. serialize(): any;
  25378. /**
  25379. * Parses a anisotropy Configuration from a serialized object.
  25380. * @param source - Serialized object.
  25381. * @param scene Defines the scene we are parsing for
  25382. * @param rootUrl Defines the rootUrl to load from
  25383. */
  25384. parse(source: any, scene: Scene, rootUrl: string): void;
  25385. }
  25386. }
  25387. declare module BABYLON {
  25388. /**
  25389. * @hidden
  25390. */
  25391. export interface IMaterialSubSurfaceDefines {
  25392. SUBSURFACE: boolean;
  25393. SS_REFRACTION: boolean;
  25394. SS_TRANSLUCENCY: boolean;
  25395. SS_SCATTERING: boolean;
  25396. SS_THICKNESSANDMASK_TEXTURE: boolean;
  25397. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  25398. SS_REFRACTIONMAP_3D: boolean;
  25399. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  25400. SS_LODINREFRACTIONALPHA: boolean;
  25401. SS_GAMMAREFRACTION: boolean;
  25402. SS_RGBDREFRACTION: boolean;
  25403. SS_LINEARSPECULARREFRACTION: boolean;
  25404. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  25405. SS_ALBEDOFORREFRACTIONTINT: boolean;
  25406. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  25407. /** @hidden */
  25408. _areTexturesDirty: boolean;
  25409. }
  25410. /**
  25411. * Define the code related to the sub surface parameters of the pbr material.
  25412. */
  25413. export class PBRSubSurfaceConfiguration {
  25414. private _isRefractionEnabled;
  25415. /**
  25416. * Defines if the refraction is enabled in the material.
  25417. */
  25418. isRefractionEnabled: boolean;
  25419. private _isTranslucencyEnabled;
  25420. /**
  25421. * Defines if the translucency is enabled in the material.
  25422. */
  25423. isTranslucencyEnabled: boolean;
  25424. private _isScatteringEnabled;
  25425. /**
  25426. * Defines if the sub surface scattering is enabled in the material.
  25427. */
  25428. isScatteringEnabled: boolean;
  25429. private _scatteringDiffusionProfileIndex;
  25430. /**
  25431. * Diffusion profile for subsurface scattering.
  25432. * Useful for better scattering in the skins or foliages.
  25433. */
  25434. get scatteringDiffusionProfile(): Nullable<Color3>;
  25435. set scatteringDiffusionProfile(c: Nullable<Color3>);
  25436. /**
  25437. * Defines the refraction intensity of the material.
  25438. * The refraction when enabled replaces the Diffuse part of the material.
  25439. * The intensity helps transitionning between diffuse and refraction.
  25440. */
  25441. refractionIntensity: number;
  25442. /**
  25443. * Defines the translucency intensity of the material.
  25444. * When translucency has been enabled, this defines how much of the "translucency"
  25445. * is addded to the diffuse part of the material.
  25446. */
  25447. translucencyIntensity: number;
  25448. /**
  25449. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  25450. */
  25451. useAlbedoToTintRefraction: boolean;
  25452. private _thicknessTexture;
  25453. /**
  25454. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  25455. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  25456. * 0 would mean minimumThickness
  25457. * 1 would mean maximumThickness
  25458. * The other channels might be use as a mask to vary the different effects intensity.
  25459. */
  25460. thicknessTexture: Nullable<BaseTexture>;
  25461. private _refractionTexture;
  25462. /**
  25463. * Defines the texture to use for refraction.
  25464. */
  25465. refractionTexture: Nullable<BaseTexture>;
  25466. private _indexOfRefraction;
  25467. /**
  25468. * Index of refraction of the material base layer.
  25469. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  25470. *
  25471. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  25472. *
  25473. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  25474. */
  25475. indexOfRefraction: number;
  25476. private _volumeIndexOfRefraction;
  25477. /**
  25478. * Index of refraction of the material's volume.
  25479. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  25480. *
  25481. * This ONLY impacts refraction. If not provided or given a non-valid value,
  25482. * the volume will use the same IOR as the surface.
  25483. */
  25484. get volumeIndexOfRefraction(): number;
  25485. set volumeIndexOfRefraction(value: number);
  25486. private _invertRefractionY;
  25487. /**
  25488. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  25489. */
  25490. invertRefractionY: boolean;
  25491. private _linkRefractionWithTransparency;
  25492. /**
  25493. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  25494. * Materials half opaque for instance using refraction could benefit from this control.
  25495. */
  25496. linkRefractionWithTransparency: boolean;
  25497. /**
  25498. * Defines the minimum thickness stored in the thickness map.
  25499. * If no thickness map is defined, this value will be used to simulate thickness.
  25500. */
  25501. minimumThickness: number;
  25502. /**
  25503. * Defines the maximum thickness stored in the thickness map.
  25504. */
  25505. maximumThickness: number;
  25506. /**
  25507. * Defines the volume tint of the material.
  25508. * This is used for both translucency and scattering.
  25509. */
  25510. tintColor: Color3;
  25511. /**
  25512. * Defines the distance at which the tint color should be found in the media.
  25513. * This is used for refraction only.
  25514. */
  25515. tintColorAtDistance: number;
  25516. /**
  25517. * Defines how far each channel transmit through the media.
  25518. * It is defined as a color to simplify it selection.
  25519. */
  25520. diffusionDistance: Color3;
  25521. private _useMaskFromThicknessTexture;
  25522. /**
  25523. * Stores the intensity of the different subsurface effects in the thickness texture.
  25524. * * the green channel is the translucency intensity.
  25525. * * the blue channel is the scattering intensity.
  25526. * * the alpha channel is the refraction intensity.
  25527. */
  25528. useMaskFromThicknessTexture: boolean;
  25529. private _scene;
  25530. /** @hidden */
  25531. private _internalMarkAllSubMeshesAsTexturesDirty;
  25532. private _internalMarkScenePrePassDirty;
  25533. /** @hidden */
  25534. _markAllSubMeshesAsTexturesDirty(): void;
  25535. /** @hidden */
  25536. _markScenePrePassDirty(): void;
  25537. /**
  25538. * Instantiate a new istance of sub surface configuration.
  25539. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25540. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  25541. * @param scene The scene
  25542. */
  25543. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  25544. /**
  25545. * Gets wehter the submesh is ready to be used or not.
  25546. * @param defines the list of "defines" to update.
  25547. * @param scene defines the scene the material belongs to.
  25548. * @returns - boolean indicating that the submesh is ready or not.
  25549. */
  25550. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  25551. /**
  25552. * Checks to see if a texture is used in the material.
  25553. * @param defines the list of "defines" to update.
  25554. * @param scene defines the scene to the material belongs to.
  25555. */
  25556. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  25557. /**
  25558. * Binds the material data.
  25559. * @param uniformBuffer defines the Uniform buffer to fill in.
  25560. * @param scene defines the scene the material belongs to.
  25561. * @param engine defines the engine the material belongs to.
  25562. * @param isFrozen defines whether the material is frozen or not.
  25563. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  25564. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  25565. */
  25566. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  25567. /**
  25568. * Unbinds the material from the mesh.
  25569. * @param activeEffect defines the effect that should be unbound from.
  25570. * @returns true if unbound, otherwise false
  25571. */
  25572. unbind(activeEffect: Effect): boolean;
  25573. /**
  25574. * Returns the texture used for refraction or null if none is used.
  25575. * @param scene defines the scene the material belongs to.
  25576. * @returns - Refraction texture if present. If no refraction texture and refraction
  25577. * is linked with transparency, returns environment texture. Otherwise, returns null.
  25578. */
  25579. private _getRefractionTexture;
  25580. /**
  25581. * Returns true if alpha blending should be disabled.
  25582. */
  25583. get disableAlphaBlending(): boolean;
  25584. /**
  25585. * Fills the list of render target textures.
  25586. * @param renderTargets the list of render targets to update
  25587. */
  25588. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  25589. /**
  25590. * Checks to see if a texture is used in the material.
  25591. * @param texture - Base texture to use.
  25592. * @returns - Boolean specifying if a texture is used in the material.
  25593. */
  25594. hasTexture(texture: BaseTexture): boolean;
  25595. /**
  25596. * Gets a boolean indicating that current material needs to register RTT
  25597. * @returns true if this uses a render target otherwise false.
  25598. */
  25599. hasRenderTargetTextures(): boolean;
  25600. /**
  25601. * Returns an array of the actively used textures.
  25602. * @param activeTextures Array of BaseTextures
  25603. */
  25604. getActiveTextures(activeTextures: BaseTexture[]): void;
  25605. /**
  25606. * Returns the animatable textures.
  25607. * @param animatables Array of animatable textures.
  25608. */
  25609. getAnimatables(animatables: IAnimatable[]): void;
  25610. /**
  25611. * Disposes the resources of the material.
  25612. * @param forceDisposeTextures - Forces the disposal of all textures.
  25613. */
  25614. dispose(forceDisposeTextures?: boolean): void;
  25615. /**
  25616. * Get the current class name of the texture useful for serialization or dynamic coding.
  25617. * @returns "PBRSubSurfaceConfiguration"
  25618. */
  25619. getClassName(): string;
  25620. /**
  25621. * Add fallbacks to the effect fallbacks list.
  25622. * @param defines defines the Base texture to use.
  25623. * @param fallbacks defines the current fallback list.
  25624. * @param currentRank defines the current fallback rank.
  25625. * @returns the new fallback rank.
  25626. */
  25627. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25628. /**
  25629. * Add the required uniforms to the current list.
  25630. * @param uniforms defines the current uniform list.
  25631. */
  25632. static AddUniforms(uniforms: string[]): void;
  25633. /**
  25634. * Add the required samplers to the current list.
  25635. * @param samplers defines the current sampler list.
  25636. */
  25637. static AddSamplers(samplers: string[]): void;
  25638. /**
  25639. * Add the required uniforms to the current buffer.
  25640. * @param uniformBuffer defines the current uniform buffer.
  25641. */
  25642. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25643. /**
  25644. * Makes a duplicate of the current configuration into another one.
  25645. * @param configuration define the config where to copy the info
  25646. */
  25647. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  25648. /**
  25649. * Serializes this Sub Surface configuration.
  25650. * @returns - An object with the serialized config.
  25651. */
  25652. serialize(): any;
  25653. /**
  25654. * Parses a anisotropy Configuration from a serialized object.
  25655. * @param source - Serialized object.
  25656. * @param scene Defines the scene we are parsing for
  25657. * @param rootUrl Defines the rootUrl to load from
  25658. */
  25659. parse(source: any, scene: Scene, rootUrl: string): void;
  25660. }
  25661. }
  25662. declare module BABYLON {
  25663. /**
  25664. * Class representing spherical harmonics coefficients to the 3rd degree
  25665. */
  25666. export class SphericalHarmonics {
  25667. /**
  25668. * Defines whether or not the harmonics have been prescaled for rendering.
  25669. */
  25670. preScaled: boolean;
  25671. /**
  25672. * The l0,0 coefficients of the spherical harmonics
  25673. */
  25674. l00: Vector3;
  25675. /**
  25676. * The l1,-1 coefficients of the spherical harmonics
  25677. */
  25678. l1_1: Vector3;
  25679. /**
  25680. * The l1,0 coefficients of the spherical harmonics
  25681. */
  25682. l10: Vector3;
  25683. /**
  25684. * The l1,1 coefficients of the spherical harmonics
  25685. */
  25686. l11: Vector3;
  25687. /**
  25688. * The l2,-2 coefficients of the spherical harmonics
  25689. */
  25690. l2_2: Vector3;
  25691. /**
  25692. * The l2,-1 coefficients of the spherical harmonics
  25693. */
  25694. l2_1: Vector3;
  25695. /**
  25696. * The l2,0 coefficients of the spherical harmonics
  25697. */
  25698. l20: Vector3;
  25699. /**
  25700. * The l2,1 coefficients of the spherical harmonics
  25701. */
  25702. l21: Vector3;
  25703. /**
  25704. * The l2,2 coefficients of the spherical harmonics
  25705. */
  25706. l22: Vector3;
  25707. /**
  25708. * Adds a light to the spherical harmonics
  25709. * @param direction the direction of the light
  25710. * @param color the color of the light
  25711. * @param deltaSolidAngle the delta solid angle of the light
  25712. */
  25713. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  25714. /**
  25715. * Scales the spherical harmonics by the given amount
  25716. * @param scale the amount to scale
  25717. */
  25718. scaleInPlace(scale: number): void;
  25719. /**
  25720. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  25721. *
  25722. * ```
  25723. * E_lm = A_l * L_lm
  25724. * ```
  25725. *
  25726. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  25727. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  25728. * the scaling factors are given in equation 9.
  25729. */
  25730. convertIncidentRadianceToIrradiance(): void;
  25731. /**
  25732. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  25733. *
  25734. * ```
  25735. * L = (1/pi) * E * rho
  25736. * ```
  25737. *
  25738. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  25739. */
  25740. convertIrradianceToLambertianRadiance(): void;
  25741. /**
  25742. * Integrates the reconstruction coefficients directly in to the SH preventing further
  25743. * required operations at run time.
  25744. *
  25745. * This is simply done by scaling back the SH with Ylm constants parameter.
  25746. * The trigonometric part being applied by the shader at run time.
  25747. */
  25748. preScaleForRendering(): void;
  25749. /**
  25750. * Constructs a spherical harmonics from an array.
  25751. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  25752. * @returns the spherical harmonics
  25753. */
  25754. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  25755. /**
  25756. * Gets the spherical harmonics from polynomial
  25757. * @param polynomial the spherical polynomial
  25758. * @returns the spherical harmonics
  25759. */
  25760. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  25761. }
  25762. /**
  25763. * Class representing spherical polynomial coefficients to the 3rd degree
  25764. */
  25765. export class SphericalPolynomial {
  25766. private _harmonics;
  25767. /**
  25768. * The spherical harmonics used to create the polynomials.
  25769. */
  25770. get preScaledHarmonics(): SphericalHarmonics;
  25771. /**
  25772. * The x coefficients of the spherical polynomial
  25773. */
  25774. x: Vector3;
  25775. /**
  25776. * The y coefficients of the spherical polynomial
  25777. */
  25778. y: Vector3;
  25779. /**
  25780. * The z coefficients of the spherical polynomial
  25781. */
  25782. z: Vector3;
  25783. /**
  25784. * The xx coefficients of the spherical polynomial
  25785. */
  25786. xx: Vector3;
  25787. /**
  25788. * The yy coefficients of the spherical polynomial
  25789. */
  25790. yy: Vector3;
  25791. /**
  25792. * The zz coefficients of the spherical polynomial
  25793. */
  25794. zz: Vector3;
  25795. /**
  25796. * The xy coefficients of the spherical polynomial
  25797. */
  25798. xy: Vector3;
  25799. /**
  25800. * The yz coefficients of the spherical polynomial
  25801. */
  25802. yz: Vector3;
  25803. /**
  25804. * The zx coefficients of the spherical polynomial
  25805. */
  25806. zx: Vector3;
  25807. /**
  25808. * Adds an ambient color to the spherical polynomial
  25809. * @param color the color to add
  25810. */
  25811. addAmbient(color: Color3): void;
  25812. /**
  25813. * Scales the spherical polynomial by the given amount
  25814. * @param scale the amount to scale
  25815. */
  25816. scaleInPlace(scale: number): void;
  25817. /**
  25818. * Gets the spherical polynomial from harmonics
  25819. * @param harmonics the spherical harmonics
  25820. * @returns the spherical polynomial
  25821. */
  25822. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  25823. /**
  25824. * Constructs a spherical polynomial from an array.
  25825. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  25826. * @returns the spherical polynomial
  25827. */
  25828. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  25829. }
  25830. }
  25831. declare module BABYLON {
  25832. /**
  25833. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  25834. */
  25835. export interface CubeMapInfo {
  25836. /**
  25837. * The pixel array for the front face.
  25838. * This is stored in format, left to right, up to down format.
  25839. */
  25840. front: Nullable<ArrayBufferView>;
  25841. /**
  25842. * The pixel array for the back face.
  25843. * This is stored in format, left to right, up to down format.
  25844. */
  25845. back: Nullable<ArrayBufferView>;
  25846. /**
  25847. * The pixel array for the left face.
  25848. * This is stored in format, left to right, up to down format.
  25849. */
  25850. left: Nullable<ArrayBufferView>;
  25851. /**
  25852. * The pixel array for the right face.
  25853. * This is stored in format, left to right, up to down format.
  25854. */
  25855. right: Nullable<ArrayBufferView>;
  25856. /**
  25857. * The pixel array for the up face.
  25858. * This is stored in format, left to right, up to down format.
  25859. */
  25860. up: Nullable<ArrayBufferView>;
  25861. /**
  25862. * The pixel array for the down face.
  25863. * This is stored in format, left to right, up to down format.
  25864. */
  25865. down: Nullable<ArrayBufferView>;
  25866. /**
  25867. * The size of the cubemap stored.
  25868. *
  25869. * Each faces will be size * size pixels.
  25870. */
  25871. size: number;
  25872. /**
  25873. * The format of the texture.
  25874. *
  25875. * RGBA, RGB.
  25876. */
  25877. format: number;
  25878. /**
  25879. * The type of the texture data.
  25880. *
  25881. * UNSIGNED_INT, FLOAT.
  25882. */
  25883. type: number;
  25884. /**
  25885. * Specifies whether the texture is in gamma space.
  25886. */
  25887. gammaSpace: boolean;
  25888. }
  25889. /**
  25890. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  25891. */
  25892. export class PanoramaToCubeMapTools {
  25893. private static FACE_LEFT;
  25894. private static FACE_RIGHT;
  25895. private static FACE_FRONT;
  25896. private static FACE_BACK;
  25897. private static FACE_DOWN;
  25898. private static FACE_UP;
  25899. /**
  25900. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  25901. *
  25902. * @param float32Array The source data.
  25903. * @param inputWidth The width of the input panorama.
  25904. * @param inputHeight The height of the input panorama.
  25905. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  25906. * @return The cubemap data
  25907. */
  25908. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  25909. private static CreateCubemapTexture;
  25910. private static CalcProjectionSpherical;
  25911. }
  25912. }
  25913. declare module BABYLON {
  25914. /**
  25915. * Helper class dealing with the extraction of spherical polynomial dataArray
  25916. * from a cube map.
  25917. */
  25918. export class CubeMapToSphericalPolynomialTools {
  25919. private static FileFaces;
  25920. /**
  25921. * Converts a texture to the according Spherical Polynomial data.
  25922. * This extracts the first 3 orders only as they are the only one used in the lighting.
  25923. *
  25924. * @param texture The texture to extract the information from.
  25925. * @return The Spherical Polynomial data.
  25926. */
  25927. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  25928. /**
  25929. * Converts a cubemap to the according Spherical Polynomial data.
  25930. * This extracts the first 3 orders only as they are the only one used in the lighting.
  25931. *
  25932. * @param cubeInfo The Cube map to extract the information from.
  25933. * @return The Spherical Polynomial data.
  25934. */
  25935. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  25936. }
  25937. }
  25938. declare module BABYLON {
  25939. interface BaseTexture {
  25940. /**
  25941. * Get the polynomial representation of the texture data.
  25942. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25943. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25944. */
  25945. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25946. }
  25947. }
  25948. declare module BABYLON {
  25949. /** @hidden */
  25950. export var pbrFragmentDeclaration: {
  25951. name: string;
  25952. shader: string;
  25953. };
  25954. }
  25955. declare module BABYLON {
  25956. /** @hidden */
  25957. export var pbrUboDeclaration: {
  25958. name: string;
  25959. shader: string;
  25960. };
  25961. }
  25962. declare module BABYLON {
  25963. /** @hidden */
  25964. export var pbrFragmentExtraDeclaration: {
  25965. name: string;
  25966. shader: string;
  25967. };
  25968. }
  25969. declare module BABYLON {
  25970. /** @hidden */
  25971. export var pbrFragmentSamplersDeclaration: {
  25972. name: string;
  25973. shader: string;
  25974. };
  25975. }
  25976. declare module BABYLON {
  25977. /** @hidden */
  25978. export var subSurfaceScatteringFunctions: {
  25979. name: string;
  25980. shader: string;
  25981. };
  25982. }
  25983. declare module BABYLON {
  25984. /** @hidden */
  25985. export var importanceSampling: {
  25986. name: string;
  25987. shader: string;
  25988. };
  25989. }
  25990. declare module BABYLON {
  25991. /** @hidden */
  25992. export var pbrHelperFunctions: {
  25993. name: string;
  25994. shader: string;
  25995. };
  25996. }
  25997. declare module BABYLON {
  25998. /** @hidden */
  25999. export var harmonicsFunctions: {
  26000. name: string;
  26001. shader: string;
  26002. };
  26003. }
  26004. declare module BABYLON {
  26005. /** @hidden */
  26006. export var pbrDirectLightingSetupFunctions: {
  26007. name: string;
  26008. shader: string;
  26009. };
  26010. }
  26011. declare module BABYLON {
  26012. /** @hidden */
  26013. export var pbrDirectLightingFalloffFunctions: {
  26014. name: string;
  26015. shader: string;
  26016. };
  26017. }
  26018. declare module BABYLON {
  26019. /** @hidden */
  26020. export var pbrBRDFFunctions: {
  26021. name: string;
  26022. shader: string;
  26023. };
  26024. }
  26025. declare module BABYLON {
  26026. /** @hidden */
  26027. export var hdrFilteringFunctions: {
  26028. name: string;
  26029. shader: string;
  26030. };
  26031. }
  26032. declare module BABYLON {
  26033. /** @hidden */
  26034. export var pbrDirectLightingFunctions: {
  26035. name: string;
  26036. shader: string;
  26037. };
  26038. }
  26039. declare module BABYLON {
  26040. /** @hidden */
  26041. export var pbrIBLFunctions: {
  26042. name: string;
  26043. shader: string;
  26044. };
  26045. }
  26046. declare module BABYLON {
  26047. /** @hidden */
  26048. export var pbrBlockAlbedoOpacity: {
  26049. name: string;
  26050. shader: string;
  26051. };
  26052. }
  26053. declare module BABYLON {
  26054. /** @hidden */
  26055. export var pbrBlockReflectivity: {
  26056. name: string;
  26057. shader: string;
  26058. };
  26059. }
  26060. declare module BABYLON {
  26061. /** @hidden */
  26062. export var pbrBlockAmbientOcclusion: {
  26063. name: string;
  26064. shader: string;
  26065. };
  26066. }
  26067. declare module BABYLON {
  26068. /** @hidden */
  26069. export var pbrBlockAlphaFresnel: {
  26070. name: string;
  26071. shader: string;
  26072. };
  26073. }
  26074. declare module BABYLON {
  26075. /** @hidden */
  26076. export var pbrBlockAnisotropic: {
  26077. name: string;
  26078. shader: string;
  26079. };
  26080. }
  26081. declare module BABYLON {
  26082. /** @hidden */
  26083. export var pbrBlockReflection: {
  26084. name: string;
  26085. shader: string;
  26086. };
  26087. }
  26088. declare module BABYLON {
  26089. /** @hidden */
  26090. export var pbrBlockSheen: {
  26091. name: string;
  26092. shader: string;
  26093. };
  26094. }
  26095. declare module BABYLON {
  26096. /** @hidden */
  26097. export var pbrBlockClearcoat: {
  26098. name: string;
  26099. shader: string;
  26100. };
  26101. }
  26102. declare module BABYLON {
  26103. /** @hidden */
  26104. export var pbrBlockSubSurface: {
  26105. name: string;
  26106. shader: string;
  26107. };
  26108. }
  26109. declare module BABYLON {
  26110. /** @hidden */
  26111. export var pbrBlockNormalGeometric: {
  26112. name: string;
  26113. shader: string;
  26114. };
  26115. }
  26116. declare module BABYLON {
  26117. /** @hidden */
  26118. export var pbrBlockNormalFinal: {
  26119. name: string;
  26120. shader: string;
  26121. };
  26122. }
  26123. declare module BABYLON {
  26124. /** @hidden */
  26125. export var pbrBlockLightmapInit: {
  26126. name: string;
  26127. shader: string;
  26128. };
  26129. }
  26130. declare module BABYLON {
  26131. /** @hidden */
  26132. export var pbrBlockGeometryInfo: {
  26133. name: string;
  26134. shader: string;
  26135. };
  26136. }
  26137. declare module BABYLON {
  26138. /** @hidden */
  26139. export var pbrBlockReflectance0: {
  26140. name: string;
  26141. shader: string;
  26142. };
  26143. }
  26144. declare module BABYLON {
  26145. /** @hidden */
  26146. export var pbrBlockReflectance: {
  26147. name: string;
  26148. shader: string;
  26149. };
  26150. }
  26151. declare module BABYLON {
  26152. /** @hidden */
  26153. export var pbrBlockDirectLighting: {
  26154. name: string;
  26155. shader: string;
  26156. };
  26157. }
  26158. declare module BABYLON {
  26159. /** @hidden */
  26160. export var pbrBlockFinalLitComponents: {
  26161. name: string;
  26162. shader: string;
  26163. };
  26164. }
  26165. declare module BABYLON {
  26166. /** @hidden */
  26167. export var pbrBlockFinalUnlitComponents: {
  26168. name: string;
  26169. shader: string;
  26170. };
  26171. }
  26172. declare module BABYLON {
  26173. /** @hidden */
  26174. export var pbrBlockFinalColorComposition: {
  26175. name: string;
  26176. shader: string;
  26177. };
  26178. }
  26179. declare module BABYLON {
  26180. /** @hidden */
  26181. export var pbrBlockImageProcessing: {
  26182. name: string;
  26183. shader: string;
  26184. };
  26185. }
  26186. declare module BABYLON {
  26187. /** @hidden */
  26188. export var pbrDebug: {
  26189. name: string;
  26190. shader: string;
  26191. };
  26192. }
  26193. declare module BABYLON {
  26194. /** @hidden */
  26195. export var pbrPixelShader: {
  26196. name: string;
  26197. shader: string;
  26198. };
  26199. }
  26200. declare module BABYLON {
  26201. /** @hidden */
  26202. export var pbrVertexDeclaration: {
  26203. name: string;
  26204. shader: string;
  26205. };
  26206. }
  26207. declare module BABYLON {
  26208. /** @hidden */
  26209. export var pbrVertexShader: {
  26210. name: string;
  26211. shader: string;
  26212. };
  26213. }
  26214. declare module BABYLON {
  26215. /**
  26216. * Manages the defines for the PBR Material.
  26217. * @hidden
  26218. */
  26219. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  26220. PBR: boolean;
  26221. NUM_SAMPLES: string;
  26222. REALTIME_FILTERING: boolean;
  26223. MAINUV1: boolean;
  26224. MAINUV2: boolean;
  26225. UV1: boolean;
  26226. UV2: boolean;
  26227. ALBEDO: boolean;
  26228. GAMMAALBEDO: boolean;
  26229. ALBEDODIRECTUV: number;
  26230. VERTEXCOLOR: boolean;
  26231. DETAIL: boolean;
  26232. DETAILDIRECTUV: number;
  26233. DETAIL_NORMALBLENDMETHOD: number;
  26234. AMBIENT: boolean;
  26235. AMBIENTDIRECTUV: number;
  26236. AMBIENTINGRAYSCALE: boolean;
  26237. OPACITY: boolean;
  26238. VERTEXALPHA: boolean;
  26239. OPACITYDIRECTUV: number;
  26240. OPACITYRGB: boolean;
  26241. ALPHATEST: boolean;
  26242. DEPTHPREPASS: boolean;
  26243. ALPHABLEND: boolean;
  26244. ALPHAFROMALBEDO: boolean;
  26245. ALPHATESTVALUE: string;
  26246. SPECULAROVERALPHA: boolean;
  26247. RADIANCEOVERALPHA: boolean;
  26248. ALPHAFRESNEL: boolean;
  26249. LINEARALPHAFRESNEL: boolean;
  26250. PREMULTIPLYALPHA: boolean;
  26251. EMISSIVE: boolean;
  26252. EMISSIVEDIRECTUV: number;
  26253. REFLECTIVITY: boolean;
  26254. REFLECTIVITYDIRECTUV: number;
  26255. SPECULARTERM: boolean;
  26256. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  26257. MICROSURFACEAUTOMATIC: boolean;
  26258. LODBASEDMICROSFURACE: boolean;
  26259. MICROSURFACEMAP: boolean;
  26260. MICROSURFACEMAPDIRECTUV: number;
  26261. METALLICWORKFLOW: boolean;
  26262. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  26263. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  26264. METALLNESSSTOREINMETALMAPBLUE: boolean;
  26265. AOSTOREINMETALMAPRED: boolean;
  26266. METALLIC_REFLECTANCE: boolean;
  26267. METALLIC_REFLECTANCEDIRECTUV: number;
  26268. ENVIRONMENTBRDF: boolean;
  26269. ENVIRONMENTBRDF_RGBD: boolean;
  26270. NORMAL: boolean;
  26271. TANGENT: boolean;
  26272. BUMP: boolean;
  26273. BUMPDIRECTUV: number;
  26274. OBJECTSPACE_NORMALMAP: boolean;
  26275. PARALLAX: boolean;
  26276. PARALLAXOCCLUSION: boolean;
  26277. NORMALXYSCALE: boolean;
  26278. LIGHTMAP: boolean;
  26279. LIGHTMAPDIRECTUV: number;
  26280. USELIGHTMAPASSHADOWMAP: boolean;
  26281. GAMMALIGHTMAP: boolean;
  26282. RGBDLIGHTMAP: boolean;
  26283. REFLECTION: boolean;
  26284. REFLECTIONMAP_3D: boolean;
  26285. REFLECTIONMAP_SPHERICAL: boolean;
  26286. REFLECTIONMAP_PLANAR: boolean;
  26287. REFLECTIONMAP_CUBIC: boolean;
  26288. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26289. REFLECTIONMAP_PROJECTION: boolean;
  26290. REFLECTIONMAP_SKYBOX: boolean;
  26291. REFLECTIONMAP_EXPLICIT: boolean;
  26292. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26293. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26294. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26295. INVERTCUBICMAP: boolean;
  26296. USESPHERICALFROMREFLECTIONMAP: boolean;
  26297. USEIRRADIANCEMAP: boolean;
  26298. SPHERICAL_HARMONICS: boolean;
  26299. USESPHERICALINVERTEX: boolean;
  26300. REFLECTIONMAP_OPPOSITEZ: boolean;
  26301. LODINREFLECTIONALPHA: boolean;
  26302. GAMMAREFLECTION: boolean;
  26303. RGBDREFLECTION: boolean;
  26304. LINEARSPECULARREFLECTION: boolean;
  26305. RADIANCEOCCLUSION: boolean;
  26306. HORIZONOCCLUSION: boolean;
  26307. INSTANCES: boolean;
  26308. THIN_INSTANCES: boolean;
  26309. PREPASS: boolean;
  26310. PREPASS_IRRADIANCE: boolean;
  26311. PREPASS_IRRADIANCE_INDEX: number;
  26312. PREPASS_ALBEDO: boolean;
  26313. PREPASS_ALBEDO_INDEX: number;
  26314. PREPASS_DEPTHNORMAL: boolean;
  26315. PREPASS_DEPTHNORMAL_INDEX: number;
  26316. PREPASS_POSITION: boolean;
  26317. PREPASS_POSITION_INDEX: number;
  26318. PREPASS_VELOCITY: boolean;
  26319. PREPASS_VELOCITY_INDEX: number;
  26320. PREPASS_REFLECTIVITY: boolean;
  26321. PREPASS_REFLECTIVITY_INDEX: number;
  26322. SCENE_MRT_COUNT: number;
  26323. NUM_BONE_INFLUENCERS: number;
  26324. BonesPerMesh: number;
  26325. BONETEXTURE: boolean;
  26326. BONES_VELOCITY_ENABLED: boolean;
  26327. NONUNIFORMSCALING: boolean;
  26328. MORPHTARGETS: boolean;
  26329. MORPHTARGETS_NORMAL: boolean;
  26330. MORPHTARGETS_TANGENT: boolean;
  26331. MORPHTARGETS_UV: boolean;
  26332. NUM_MORPH_INFLUENCERS: number;
  26333. IMAGEPROCESSING: boolean;
  26334. VIGNETTE: boolean;
  26335. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26336. VIGNETTEBLENDMODEOPAQUE: boolean;
  26337. TONEMAPPING: boolean;
  26338. TONEMAPPING_ACES: boolean;
  26339. CONTRAST: boolean;
  26340. COLORCURVES: boolean;
  26341. COLORGRADING: boolean;
  26342. COLORGRADING3D: boolean;
  26343. SAMPLER3DGREENDEPTH: boolean;
  26344. SAMPLER3DBGRMAP: boolean;
  26345. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26346. EXPOSURE: boolean;
  26347. MULTIVIEW: boolean;
  26348. USEPHYSICALLIGHTFALLOFF: boolean;
  26349. USEGLTFLIGHTFALLOFF: boolean;
  26350. TWOSIDEDLIGHTING: boolean;
  26351. SHADOWFLOAT: boolean;
  26352. CLIPPLANE: boolean;
  26353. CLIPPLANE2: boolean;
  26354. CLIPPLANE3: boolean;
  26355. CLIPPLANE4: boolean;
  26356. CLIPPLANE5: boolean;
  26357. CLIPPLANE6: boolean;
  26358. POINTSIZE: boolean;
  26359. FOG: boolean;
  26360. LOGARITHMICDEPTH: boolean;
  26361. FORCENORMALFORWARD: boolean;
  26362. SPECULARAA: boolean;
  26363. CLEARCOAT: boolean;
  26364. CLEARCOAT_DEFAULTIOR: boolean;
  26365. CLEARCOAT_TEXTURE: boolean;
  26366. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  26367. CLEARCOAT_TEXTUREDIRECTUV: number;
  26368. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  26369. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  26370. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  26371. CLEARCOAT_BUMP: boolean;
  26372. CLEARCOAT_BUMPDIRECTUV: number;
  26373. CLEARCOAT_REMAP_F0: boolean;
  26374. CLEARCOAT_TINT: boolean;
  26375. CLEARCOAT_TINT_TEXTURE: boolean;
  26376. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  26377. ANISOTROPIC: boolean;
  26378. ANISOTROPIC_TEXTURE: boolean;
  26379. ANISOTROPIC_TEXTUREDIRECTUV: number;
  26380. BRDF_V_HEIGHT_CORRELATED: boolean;
  26381. MS_BRDF_ENERGY_CONSERVATION: boolean;
  26382. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  26383. SHEEN: boolean;
  26384. SHEEN_TEXTURE: boolean;
  26385. SHEEN_TEXTURE_ROUGHNESS: boolean;
  26386. SHEEN_TEXTUREDIRECTUV: number;
  26387. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  26388. SHEEN_LINKWITHALBEDO: boolean;
  26389. SHEEN_ROUGHNESS: boolean;
  26390. SHEEN_ALBEDOSCALING: boolean;
  26391. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  26392. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  26393. SUBSURFACE: boolean;
  26394. SS_REFRACTION: boolean;
  26395. SS_TRANSLUCENCY: boolean;
  26396. SS_SCATTERING: boolean;
  26397. SS_THICKNESSANDMASK_TEXTURE: boolean;
  26398. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  26399. SS_REFRACTIONMAP_3D: boolean;
  26400. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  26401. SS_LODINREFRACTIONALPHA: boolean;
  26402. SS_GAMMAREFRACTION: boolean;
  26403. SS_RGBDREFRACTION: boolean;
  26404. SS_LINEARSPECULARREFRACTION: boolean;
  26405. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  26406. SS_ALBEDOFORREFRACTIONTINT: boolean;
  26407. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  26408. UNLIT: boolean;
  26409. DEBUGMODE: number;
  26410. /**
  26411. * Initializes the PBR Material defines.
  26412. */
  26413. constructor();
  26414. /**
  26415. * Resets the PBR Material defines.
  26416. */
  26417. reset(): void;
  26418. }
  26419. /**
  26420. * The Physically based material base class of BJS.
  26421. *
  26422. * This offers the main features of a standard PBR material.
  26423. * For more information, please refer to the documentation :
  26424. * https://doc.babylonjs.com/how_to/physically_based_rendering
  26425. */
  26426. export abstract class PBRBaseMaterial extends PushMaterial {
  26427. /**
  26428. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  26429. */
  26430. static readonly PBRMATERIAL_OPAQUE: number;
  26431. /**
  26432. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  26433. */
  26434. static readonly PBRMATERIAL_ALPHATEST: number;
  26435. /**
  26436. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26437. */
  26438. static readonly PBRMATERIAL_ALPHABLEND: number;
  26439. /**
  26440. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26441. * They are also discarded below the alpha cutoff threshold to improve performances.
  26442. */
  26443. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  26444. /**
  26445. * Defines the default value of how much AO map is occluding the analytical lights
  26446. * (point spot...).
  26447. */
  26448. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  26449. /**
  26450. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  26451. */
  26452. static readonly LIGHTFALLOFF_PHYSICAL: number;
  26453. /**
  26454. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  26455. * to enhance interoperability with other engines.
  26456. */
  26457. static readonly LIGHTFALLOFF_GLTF: number;
  26458. /**
  26459. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  26460. * to enhance interoperability with other materials.
  26461. */
  26462. static readonly LIGHTFALLOFF_STANDARD: number;
  26463. /**
  26464. * Intensity of the direct lights e.g. the four lights available in your scene.
  26465. * This impacts both the direct diffuse and specular highlights.
  26466. */
  26467. protected _directIntensity: number;
  26468. /**
  26469. * Intensity of the emissive part of the material.
  26470. * This helps controlling the emissive effect without modifying the emissive color.
  26471. */
  26472. protected _emissiveIntensity: number;
  26473. /**
  26474. * Intensity of the environment e.g. how much the environment will light the object
  26475. * either through harmonics for rough material or through the refelction for shiny ones.
  26476. */
  26477. protected _environmentIntensity: number;
  26478. /**
  26479. * This is a special control allowing the reduction of the specular highlights coming from the
  26480. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  26481. */
  26482. protected _specularIntensity: number;
  26483. /**
  26484. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  26485. */
  26486. private _lightingInfos;
  26487. /**
  26488. * Debug Control allowing disabling the bump map on this material.
  26489. */
  26490. protected _disableBumpMap: boolean;
  26491. /**
  26492. * AKA Diffuse Texture in standard nomenclature.
  26493. */
  26494. protected _albedoTexture: Nullable<BaseTexture>;
  26495. /**
  26496. * AKA Occlusion Texture in other nomenclature.
  26497. */
  26498. protected _ambientTexture: Nullable<BaseTexture>;
  26499. /**
  26500. * AKA Occlusion Texture Intensity in other nomenclature.
  26501. */
  26502. protected _ambientTextureStrength: number;
  26503. /**
  26504. * Defines how much the AO map is occluding the analytical lights (point spot...).
  26505. * 1 means it completely occludes it
  26506. * 0 mean it has no impact
  26507. */
  26508. protected _ambientTextureImpactOnAnalyticalLights: number;
  26509. /**
  26510. * Stores the alpha values in a texture.
  26511. */
  26512. protected _opacityTexture: Nullable<BaseTexture>;
  26513. /**
  26514. * Stores the reflection values in a texture.
  26515. */
  26516. protected _reflectionTexture: Nullable<BaseTexture>;
  26517. /**
  26518. * Stores the emissive values in a texture.
  26519. */
  26520. protected _emissiveTexture: Nullable<BaseTexture>;
  26521. /**
  26522. * AKA Specular texture in other nomenclature.
  26523. */
  26524. protected _reflectivityTexture: Nullable<BaseTexture>;
  26525. /**
  26526. * Used to switch from specular/glossiness to metallic/roughness workflow.
  26527. */
  26528. protected _metallicTexture: Nullable<BaseTexture>;
  26529. /**
  26530. * Specifies the metallic scalar of the metallic/roughness workflow.
  26531. * Can also be used to scale the metalness values of the metallic texture.
  26532. */
  26533. protected _metallic: Nullable<number>;
  26534. /**
  26535. * Specifies the roughness scalar of the metallic/roughness workflow.
  26536. * Can also be used to scale the roughness values of the metallic texture.
  26537. */
  26538. protected _roughness: Nullable<number>;
  26539. /**
  26540. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  26541. * By default the indexOfrefraction is used to compute F0;
  26542. *
  26543. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  26544. *
  26545. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  26546. * F90 = metallicReflectanceColor;
  26547. */
  26548. protected _metallicF0Factor: number;
  26549. /**
  26550. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  26551. * By default the F90 is always 1;
  26552. *
  26553. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  26554. *
  26555. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  26556. * F90 = metallicReflectanceColor;
  26557. */
  26558. protected _metallicReflectanceColor: Color3;
  26559. /**
  26560. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  26561. * This is multiply against the scalar values defined in the material.
  26562. */
  26563. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  26564. /**
  26565. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  26566. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  26567. */
  26568. protected _microSurfaceTexture: Nullable<BaseTexture>;
  26569. /**
  26570. * Stores surface normal data used to displace a mesh in a texture.
  26571. */
  26572. protected _bumpTexture: Nullable<BaseTexture>;
  26573. /**
  26574. * Stores the pre-calculated light information of a mesh in a texture.
  26575. */
  26576. protected _lightmapTexture: Nullable<BaseTexture>;
  26577. /**
  26578. * The color of a material in ambient lighting.
  26579. */
  26580. protected _ambientColor: Color3;
  26581. /**
  26582. * AKA Diffuse Color in other nomenclature.
  26583. */
  26584. protected _albedoColor: Color3;
  26585. /**
  26586. * AKA Specular Color in other nomenclature.
  26587. */
  26588. protected _reflectivityColor: Color3;
  26589. /**
  26590. * The color applied when light is reflected from a material.
  26591. */
  26592. protected _reflectionColor: Color3;
  26593. /**
  26594. * The color applied when light is emitted from a material.
  26595. */
  26596. protected _emissiveColor: Color3;
  26597. /**
  26598. * AKA Glossiness in other nomenclature.
  26599. */
  26600. protected _microSurface: number;
  26601. /**
  26602. * Specifies that the material will use the light map as a show map.
  26603. */
  26604. protected _useLightmapAsShadowmap: boolean;
  26605. /**
  26606. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  26607. * makes the reflect vector face the model (under horizon).
  26608. */
  26609. protected _useHorizonOcclusion: boolean;
  26610. /**
  26611. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  26612. * too much the area relying on ambient texture to define their ambient occlusion.
  26613. */
  26614. protected _useRadianceOcclusion: boolean;
  26615. /**
  26616. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  26617. */
  26618. protected _useAlphaFromAlbedoTexture: boolean;
  26619. /**
  26620. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  26621. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26622. */
  26623. protected _useSpecularOverAlpha: boolean;
  26624. /**
  26625. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  26626. */
  26627. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  26628. /**
  26629. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  26630. */
  26631. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  26632. /**
  26633. * Specifies if the metallic texture contains the roughness information in its green channel.
  26634. */
  26635. protected _useRoughnessFromMetallicTextureGreen: boolean;
  26636. /**
  26637. * Specifies if the metallic texture contains the metallness information in its blue channel.
  26638. */
  26639. protected _useMetallnessFromMetallicTextureBlue: boolean;
  26640. /**
  26641. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  26642. */
  26643. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  26644. /**
  26645. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  26646. */
  26647. protected _useAmbientInGrayScale: boolean;
  26648. /**
  26649. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  26650. * The material will try to infer what glossiness each pixel should be.
  26651. */
  26652. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  26653. /**
  26654. * Defines the falloff type used in this material.
  26655. * It by default is Physical.
  26656. */
  26657. protected _lightFalloff: number;
  26658. /**
  26659. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26660. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26661. */
  26662. protected _useRadianceOverAlpha: boolean;
  26663. /**
  26664. * Allows using an object space normal map (instead of tangent space).
  26665. */
  26666. protected _useObjectSpaceNormalMap: boolean;
  26667. /**
  26668. * Allows using the bump map in parallax mode.
  26669. */
  26670. protected _useParallax: boolean;
  26671. /**
  26672. * Allows using the bump map in parallax occlusion mode.
  26673. */
  26674. protected _useParallaxOcclusion: boolean;
  26675. /**
  26676. * Controls the scale bias of the parallax mode.
  26677. */
  26678. protected _parallaxScaleBias: number;
  26679. /**
  26680. * If sets to true, disables all the lights affecting the material.
  26681. */
  26682. protected _disableLighting: boolean;
  26683. /**
  26684. * Number of Simultaneous lights allowed on the material.
  26685. */
  26686. protected _maxSimultaneousLights: number;
  26687. /**
  26688. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  26689. */
  26690. protected _invertNormalMapX: boolean;
  26691. /**
  26692. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  26693. */
  26694. protected _invertNormalMapY: boolean;
  26695. /**
  26696. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26697. */
  26698. protected _twoSidedLighting: boolean;
  26699. /**
  26700. * Defines the alpha limits in alpha test mode.
  26701. */
  26702. protected _alphaCutOff: number;
  26703. /**
  26704. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  26705. */
  26706. protected _forceAlphaTest: boolean;
  26707. /**
  26708. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26709. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  26710. */
  26711. protected _useAlphaFresnel: boolean;
  26712. /**
  26713. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26714. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  26715. */
  26716. protected _useLinearAlphaFresnel: boolean;
  26717. /**
  26718. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  26719. * from cos thetav and roughness:
  26720. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  26721. */
  26722. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  26723. /**
  26724. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  26725. */
  26726. protected _forceIrradianceInFragment: boolean;
  26727. private _realTimeFiltering;
  26728. /**
  26729. * Enables realtime filtering on the texture.
  26730. */
  26731. get realTimeFiltering(): boolean;
  26732. set realTimeFiltering(b: boolean);
  26733. private _realTimeFilteringQuality;
  26734. /**
  26735. * Quality switch for realtime filtering
  26736. */
  26737. get realTimeFilteringQuality(): number;
  26738. set realTimeFilteringQuality(n: number);
  26739. /**
  26740. * Can this material render to several textures at once
  26741. */
  26742. get canRenderToMRT(): boolean;
  26743. /**
  26744. * Force normal to face away from face.
  26745. */
  26746. protected _forceNormalForward: boolean;
  26747. /**
  26748. * Enables specular anti aliasing in the PBR shader.
  26749. * It will both interacts on the Geometry for analytical and IBL lighting.
  26750. * It also prefilter the roughness map based on the bump values.
  26751. */
  26752. protected _enableSpecularAntiAliasing: boolean;
  26753. /**
  26754. * Default configuration related to image processing available in the PBR Material.
  26755. */
  26756. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26757. /**
  26758. * Keep track of the image processing observer to allow dispose and replace.
  26759. */
  26760. private _imageProcessingObserver;
  26761. /**
  26762. * Attaches a new image processing configuration to the PBR Material.
  26763. * @param configuration
  26764. */
  26765. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26766. /**
  26767. * Stores the available render targets.
  26768. */
  26769. private _renderTargets;
  26770. /**
  26771. * Sets the global ambient color for the material used in lighting calculations.
  26772. */
  26773. private _globalAmbientColor;
  26774. /**
  26775. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  26776. */
  26777. private _useLogarithmicDepth;
  26778. /**
  26779. * If set to true, no lighting calculations will be applied.
  26780. */
  26781. private _unlit;
  26782. private _debugMode;
  26783. /**
  26784. * @hidden
  26785. * This is reserved for the inspector.
  26786. * Defines the material debug mode.
  26787. * It helps seeing only some components of the material while troubleshooting.
  26788. */
  26789. debugMode: number;
  26790. /**
  26791. * @hidden
  26792. * This is reserved for the inspector.
  26793. * Specify from where on screen the debug mode should start.
  26794. * The value goes from -1 (full screen) to 1 (not visible)
  26795. * It helps with side by side comparison against the final render
  26796. * This defaults to -1
  26797. */
  26798. private debugLimit;
  26799. /**
  26800. * @hidden
  26801. * This is reserved for the inspector.
  26802. * As the default viewing range might not be enough (if the ambient is really small for instance)
  26803. * You can use the factor to better multiply the final value.
  26804. */
  26805. private debugFactor;
  26806. /**
  26807. * Defines the clear coat layer parameters for the material.
  26808. */
  26809. readonly clearCoat: PBRClearCoatConfiguration;
  26810. /**
  26811. * Defines the anisotropic parameters for the material.
  26812. */
  26813. readonly anisotropy: PBRAnisotropicConfiguration;
  26814. /**
  26815. * Defines the BRDF parameters for the material.
  26816. */
  26817. readonly brdf: PBRBRDFConfiguration;
  26818. /**
  26819. * Defines the Sheen parameters for the material.
  26820. */
  26821. readonly sheen: PBRSheenConfiguration;
  26822. /**
  26823. * Defines the SubSurface parameters for the material.
  26824. */
  26825. readonly subSurface: PBRSubSurfaceConfiguration;
  26826. /**
  26827. * Defines additionnal PrePass parameters for the material.
  26828. */
  26829. readonly prePassConfiguration: PrePassConfiguration;
  26830. /**
  26831. * Defines the detail map parameters for the material.
  26832. */
  26833. readonly detailMap: DetailMapConfiguration;
  26834. protected _rebuildInParallel: boolean;
  26835. /**
  26836. * Instantiates a new PBRMaterial instance.
  26837. *
  26838. * @param name The material name
  26839. * @param scene The scene the material will be use in.
  26840. */
  26841. constructor(name: string, scene: Scene);
  26842. /**
  26843. * Gets a boolean indicating that current material needs to register RTT
  26844. */
  26845. get hasRenderTargetTextures(): boolean;
  26846. /**
  26847. * Gets the name of the material class.
  26848. */
  26849. getClassName(): string;
  26850. /**
  26851. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  26852. */
  26853. get useLogarithmicDepth(): boolean;
  26854. /**
  26855. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  26856. */
  26857. set useLogarithmicDepth(value: boolean);
  26858. /**
  26859. * Returns true if alpha blending should be disabled.
  26860. */
  26861. protected get _disableAlphaBlending(): boolean;
  26862. /**
  26863. * Specifies whether or not this material should be rendered in alpha blend mode.
  26864. */
  26865. needAlphaBlending(): boolean;
  26866. /**
  26867. * Specifies whether or not this material should be rendered in alpha test mode.
  26868. */
  26869. needAlphaTesting(): boolean;
  26870. /**
  26871. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  26872. */
  26873. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  26874. /**
  26875. * Specifies whether or not there is a usable alpha channel for transparency.
  26876. */
  26877. protected _hasAlphaChannel(): boolean;
  26878. /**
  26879. * Gets the texture used for the alpha test.
  26880. */
  26881. getAlphaTestTexture(): Nullable<BaseTexture>;
  26882. /**
  26883. * Specifies that the submesh is ready to be used.
  26884. * @param mesh - BJS mesh.
  26885. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  26886. * @param useInstances - Specifies that instances should be used.
  26887. * @returns - boolean indicating that the submesh is ready or not.
  26888. */
  26889. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26890. /**
  26891. * Specifies if the material uses metallic roughness workflow.
  26892. * @returns boolean specifiying if the material uses metallic roughness workflow.
  26893. */
  26894. isMetallicWorkflow(): boolean;
  26895. private _prepareEffect;
  26896. private _prepareDefines;
  26897. /**
  26898. * Force shader compilation
  26899. */
  26900. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  26901. /**
  26902. * Initializes the uniform buffer layout for the shader.
  26903. */
  26904. buildUniformLayout(): void;
  26905. /**
  26906. * Unbinds the material from the mesh
  26907. */
  26908. unbind(): void;
  26909. /**
  26910. * Binds the submesh data.
  26911. * @param world - The world matrix.
  26912. * @param mesh - The BJS mesh.
  26913. * @param subMesh - A submesh of the BJS mesh.
  26914. */
  26915. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26916. /**
  26917. * Returns the animatable textures.
  26918. * @returns - Array of animatable textures.
  26919. */
  26920. getAnimatables(): IAnimatable[];
  26921. /**
  26922. * Returns the texture used for reflections.
  26923. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  26924. */
  26925. private _getReflectionTexture;
  26926. /**
  26927. * Returns an array of the actively used textures.
  26928. * @returns - Array of BaseTextures
  26929. */
  26930. getActiveTextures(): BaseTexture[];
  26931. /**
  26932. * Checks to see if a texture is used in the material.
  26933. * @param texture - Base texture to use.
  26934. * @returns - Boolean specifying if a texture is used in the material.
  26935. */
  26936. hasTexture(texture: BaseTexture): boolean;
  26937. /**
  26938. * Sets the required values to the prepass renderer.
  26939. * @param prePassRenderer defines the prepass renderer to setup
  26940. */
  26941. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  26942. /**
  26943. * Disposes the resources of the material.
  26944. * @param forceDisposeEffect - Forces the disposal of effects.
  26945. * @param forceDisposeTextures - Forces the disposal of all textures.
  26946. */
  26947. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26948. }
  26949. }
  26950. declare module BABYLON {
  26951. /**
  26952. * The Physically based material of BJS.
  26953. *
  26954. * This offers the main features of a standard PBR material.
  26955. * For more information, please refer to the documentation :
  26956. * https://doc.babylonjs.com/how_to/physically_based_rendering
  26957. */
  26958. export class PBRMaterial extends PBRBaseMaterial {
  26959. /**
  26960. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  26961. */
  26962. static readonly PBRMATERIAL_OPAQUE: number;
  26963. /**
  26964. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  26965. */
  26966. static readonly PBRMATERIAL_ALPHATEST: number;
  26967. /**
  26968. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26969. */
  26970. static readonly PBRMATERIAL_ALPHABLEND: number;
  26971. /**
  26972. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26973. * They are also discarded below the alpha cutoff threshold to improve performances.
  26974. */
  26975. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  26976. /**
  26977. * Defines the default value of how much AO map is occluding the analytical lights
  26978. * (point spot...).
  26979. */
  26980. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  26981. /**
  26982. * Intensity of the direct lights e.g. the four lights available in your scene.
  26983. * This impacts both the direct diffuse and specular highlights.
  26984. */
  26985. directIntensity: number;
  26986. /**
  26987. * Intensity of the emissive part of the material.
  26988. * This helps controlling the emissive effect without modifying the emissive color.
  26989. */
  26990. emissiveIntensity: number;
  26991. /**
  26992. * Intensity of the environment e.g. how much the environment will light the object
  26993. * either through harmonics for rough material or through the refelction for shiny ones.
  26994. */
  26995. environmentIntensity: number;
  26996. /**
  26997. * This is a special control allowing the reduction of the specular highlights coming from the
  26998. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  26999. */
  27000. specularIntensity: number;
  27001. /**
  27002. * Debug Control allowing disabling the bump map on this material.
  27003. */
  27004. disableBumpMap: boolean;
  27005. /**
  27006. * AKA Diffuse Texture in standard nomenclature.
  27007. */
  27008. albedoTexture: BaseTexture;
  27009. /**
  27010. * AKA Occlusion Texture in other nomenclature.
  27011. */
  27012. ambientTexture: BaseTexture;
  27013. /**
  27014. * AKA Occlusion Texture Intensity in other nomenclature.
  27015. */
  27016. ambientTextureStrength: number;
  27017. /**
  27018. * Defines how much the AO map is occluding the analytical lights (point spot...).
  27019. * 1 means it completely occludes it
  27020. * 0 mean it has no impact
  27021. */
  27022. ambientTextureImpactOnAnalyticalLights: number;
  27023. /**
  27024. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  27025. */
  27026. opacityTexture: BaseTexture;
  27027. /**
  27028. * Stores the reflection values in a texture.
  27029. */
  27030. reflectionTexture: Nullable<BaseTexture>;
  27031. /**
  27032. * Stores the emissive values in a texture.
  27033. */
  27034. emissiveTexture: BaseTexture;
  27035. /**
  27036. * AKA Specular texture in other nomenclature.
  27037. */
  27038. reflectivityTexture: BaseTexture;
  27039. /**
  27040. * Used to switch from specular/glossiness to metallic/roughness workflow.
  27041. */
  27042. metallicTexture: BaseTexture;
  27043. /**
  27044. * Specifies the metallic scalar of the metallic/roughness workflow.
  27045. * Can also be used to scale the metalness values of the metallic texture.
  27046. */
  27047. metallic: Nullable<number>;
  27048. /**
  27049. * Specifies the roughness scalar of the metallic/roughness workflow.
  27050. * Can also be used to scale the roughness values of the metallic texture.
  27051. */
  27052. roughness: Nullable<number>;
  27053. /**
  27054. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  27055. * By default the indexOfrefraction is used to compute F0;
  27056. *
  27057. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  27058. *
  27059. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  27060. * F90 = metallicReflectanceColor;
  27061. */
  27062. metallicF0Factor: number;
  27063. /**
  27064. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  27065. * By default the F90 is always 1;
  27066. *
  27067. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  27068. *
  27069. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  27070. * F90 = metallicReflectanceColor;
  27071. */
  27072. metallicReflectanceColor: Color3;
  27073. /**
  27074. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  27075. * This is multiply against the scalar values defined in the material.
  27076. */
  27077. metallicReflectanceTexture: Nullable<BaseTexture>;
  27078. /**
  27079. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  27080. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  27081. */
  27082. microSurfaceTexture: BaseTexture;
  27083. /**
  27084. * Stores surface normal data used to displace a mesh in a texture.
  27085. */
  27086. bumpTexture: BaseTexture;
  27087. /**
  27088. * Stores the pre-calculated light information of a mesh in a texture.
  27089. */
  27090. lightmapTexture: BaseTexture;
  27091. /**
  27092. * Stores the refracted light information in a texture.
  27093. */
  27094. get refractionTexture(): Nullable<BaseTexture>;
  27095. set refractionTexture(value: Nullable<BaseTexture>);
  27096. /**
  27097. * The color of a material in ambient lighting.
  27098. */
  27099. ambientColor: Color3;
  27100. /**
  27101. * AKA Diffuse Color in other nomenclature.
  27102. */
  27103. albedoColor: Color3;
  27104. /**
  27105. * AKA Specular Color in other nomenclature.
  27106. */
  27107. reflectivityColor: Color3;
  27108. /**
  27109. * The color reflected from the material.
  27110. */
  27111. reflectionColor: Color3;
  27112. /**
  27113. * The color emitted from the material.
  27114. */
  27115. emissiveColor: Color3;
  27116. /**
  27117. * AKA Glossiness in other nomenclature.
  27118. */
  27119. microSurface: number;
  27120. /**
  27121. * Index of refraction of the material base layer.
  27122. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  27123. *
  27124. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  27125. *
  27126. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  27127. */
  27128. get indexOfRefraction(): number;
  27129. set indexOfRefraction(value: number);
  27130. /**
  27131. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  27132. */
  27133. get invertRefractionY(): boolean;
  27134. set invertRefractionY(value: boolean);
  27135. /**
  27136. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  27137. * Materials half opaque for instance using refraction could benefit from this control.
  27138. */
  27139. get linkRefractionWithTransparency(): boolean;
  27140. set linkRefractionWithTransparency(value: boolean);
  27141. /**
  27142. * If true, the light map contains occlusion information instead of lighting info.
  27143. */
  27144. useLightmapAsShadowmap: boolean;
  27145. /**
  27146. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  27147. */
  27148. useAlphaFromAlbedoTexture: boolean;
  27149. /**
  27150. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  27151. */
  27152. forceAlphaTest: boolean;
  27153. /**
  27154. * Defines the alpha limits in alpha test mode.
  27155. */
  27156. alphaCutOff: number;
  27157. /**
  27158. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27159. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27160. */
  27161. useSpecularOverAlpha: boolean;
  27162. /**
  27163. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  27164. */
  27165. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  27166. /**
  27167. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  27168. */
  27169. useRoughnessFromMetallicTextureAlpha: boolean;
  27170. /**
  27171. * Specifies if the metallic texture contains the roughness information in its green channel.
  27172. */
  27173. useRoughnessFromMetallicTextureGreen: boolean;
  27174. /**
  27175. * Specifies if the metallic texture contains the metallness information in its blue channel.
  27176. */
  27177. useMetallnessFromMetallicTextureBlue: boolean;
  27178. /**
  27179. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  27180. */
  27181. useAmbientOcclusionFromMetallicTextureRed: boolean;
  27182. /**
  27183. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  27184. */
  27185. useAmbientInGrayScale: boolean;
  27186. /**
  27187. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  27188. * The material will try to infer what glossiness each pixel should be.
  27189. */
  27190. useAutoMicroSurfaceFromReflectivityMap: boolean;
  27191. /**
  27192. * BJS is using an harcoded light falloff based on a manually sets up range.
  27193. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  27194. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  27195. */
  27196. get usePhysicalLightFalloff(): boolean;
  27197. /**
  27198. * BJS is using an harcoded light falloff based on a manually sets up range.
  27199. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  27200. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  27201. */
  27202. set usePhysicalLightFalloff(value: boolean);
  27203. /**
  27204. * In order to support the falloff compatibility with gltf, a special mode has been added
  27205. * to reproduce the gltf light falloff.
  27206. */
  27207. get useGLTFLightFalloff(): boolean;
  27208. /**
  27209. * In order to support the falloff compatibility with gltf, a special mode has been added
  27210. * to reproduce the gltf light falloff.
  27211. */
  27212. set useGLTFLightFalloff(value: boolean);
  27213. /**
  27214. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27215. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27216. */
  27217. useRadianceOverAlpha: boolean;
  27218. /**
  27219. * Allows using an object space normal map (instead of tangent space).
  27220. */
  27221. useObjectSpaceNormalMap: boolean;
  27222. /**
  27223. * Allows using the bump map in parallax mode.
  27224. */
  27225. useParallax: boolean;
  27226. /**
  27227. * Allows using the bump map in parallax occlusion mode.
  27228. */
  27229. useParallaxOcclusion: boolean;
  27230. /**
  27231. * Controls the scale bias of the parallax mode.
  27232. */
  27233. parallaxScaleBias: number;
  27234. /**
  27235. * If sets to true, disables all the lights affecting the material.
  27236. */
  27237. disableLighting: boolean;
  27238. /**
  27239. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  27240. */
  27241. forceIrradianceInFragment: boolean;
  27242. /**
  27243. * Number of Simultaneous lights allowed on the material.
  27244. */
  27245. maxSimultaneousLights: number;
  27246. /**
  27247. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27248. */
  27249. invertNormalMapX: boolean;
  27250. /**
  27251. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27252. */
  27253. invertNormalMapY: boolean;
  27254. /**
  27255. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27256. */
  27257. twoSidedLighting: boolean;
  27258. /**
  27259. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  27260. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  27261. */
  27262. useAlphaFresnel: boolean;
  27263. /**
  27264. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  27265. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  27266. */
  27267. useLinearAlphaFresnel: boolean;
  27268. /**
  27269. * Let user defines the brdf lookup texture used for IBL.
  27270. * A default 8bit version is embedded but you could point at :
  27271. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  27272. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  27273. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  27274. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  27275. */
  27276. environmentBRDFTexture: Nullable<BaseTexture>;
  27277. /**
  27278. * Force normal to face away from face.
  27279. */
  27280. forceNormalForward: boolean;
  27281. /**
  27282. * Enables specular anti aliasing in the PBR shader.
  27283. * It will both interacts on the Geometry for analytical and IBL lighting.
  27284. * It also prefilter the roughness map based on the bump values.
  27285. */
  27286. enableSpecularAntiAliasing: boolean;
  27287. /**
  27288. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  27289. * makes the reflect vector face the model (under horizon).
  27290. */
  27291. useHorizonOcclusion: boolean;
  27292. /**
  27293. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  27294. * too much the area relying on ambient texture to define their ambient occlusion.
  27295. */
  27296. useRadianceOcclusion: boolean;
  27297. /**
  27298. * If set to true, no lighting calculations will be applied.
  27299. */
  27300. unlit: boolean;
  27301. /**
  27302. * Gets the image processing configuration used either in this material.
  27303. */
  27304. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27305. /**
  27306. * Sets the Default image processing configuration used either in the this material.
  27307. *
  27308. * If sets to null, the scene one is in use.
  27309. */
  27310. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27311. /**
  27312. * Gets wether the color curves effect is enabled.
  27313. */
  27314. get cameraColorCurvesEnabled(): boolean;
  27315. /**
  27316. * Sets wether the color curves effect is enabled.
  27317. */
  27318. set cameraColorCurvesEnabled(value: boolean);
  27319. /**
  27320. * Gets wether the color grading effect is enabled.
  27321. */
  27322. get cameraColorGradingEnabled(): boolean;
  27323. /**
  27324. * Gets wether the color grading effect is enabled.
  27325. */
  27326. set cameraColorGradingEnabled(value: boolean);
  27327. /**
  27328. * Gets wether tonemapping is enabled or not.
  27329. */
  27330. get cameraToneMappingEnabled(): boolean;
  27331. /**
  27332. * Sets wether tonemapping is enabled or not
  27333. */
  27334. set cameraToneMappingEnabled(value: boolean);
  27335. /**
  27336. * The camera exposure used on this material.
  27337. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27338. * This corresponds to a photographic exposure.
  27339. */
  27340. get cameraExposure(): number;
  27341. /**
  27342. * The camera exposure used on this material.
  27343. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27344. * This corresponds to a photographic exposure.
  27345. */
  27346. set cameraExposure(value: number);
  27347. /**
  27348. * Gets The camera contrast used on this material.
  27349. */
  27350. get cameraContrast(): number;
  27351. /**
  27352. * Sets The camera contrast used on this material.
  27353. */
  27354. set cameraContrast(value: number);
  27355. /**
  27356. * Gets the Color Grading 2D Lookup Texture.
  27357. */
  27358. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27359. /**
  27360. * Sets the Color Grading 2D Lookup Texture.
  27361. */
  27362. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27363. /**
  27364. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27365. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27366. * 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;
  27367. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27368. */
  27369. get cameraColorCurves(): Nullable<ColorCurves>;
  27370. /**
  27371. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27372. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27373. * 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;
  27374. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27375. */
  27376. set cameraColorCurves(value: Nullable<ColorCurves>);
  27377. /**
  27378. * Instantiates a new PBRMaterial instance.
  27379. *
  27380. * @param name The material name
  27381. * @param scene The scene the material will be use in.
  27382. */
  27383. constructor(name: string, scene: Scene);
  27384. /**
  27385. * Returns the name of this material class.
  27386. */
  27387. getClassName(): string;
  27388. /**
  27389. * Makes a duplicate of the current material.
  27390. * @param name - name to use for the new material.
  27391. */
  27392. clone(name: string): PBRMaterial;
  27393. /**
  27394. * Serializes this PBR Material.
  27395. * @returns - An object with the serialized material.
  27396. */
  27397. serialize(): any;
  27398. /**
  27399. * Parses a PBR Material from a serialized object.
  27400. * @param source - Serialized object.
  27401. * @param scene - BJS scene instance.
  27402. * @param rootUrl - url for the scene object
  27403. * @returns - PBRMaterial
  27404. */
  27405. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  27406. }
  27407. }
  27408. declare module BABYLON {
  27409. /** @hidden */
  27410. export var mrtFragmentDeclaration: {
  27411. name: string;
  27412. shader: string;
  27413. };
  27414. }
  27415. declare module BABYLON {
  27416. /** @hidden */
  27417. export var geometryPixelShader: {
  27418. name: string;
  27419. shader: string;
  27420. };
  27421. }
  27422. declare module BABYLON {
  27423. /** @hidden */
  27424. export var geometryVertexShader: {
  27425. name: string;
  27426. shader: string;
  27427. };
  27428. }
  27429. declare module BABYLON {
  27430. /** @hidden */
  27431. interface ISavedTransformationMatrix {
  27432. world: Matrix;
  27433. viewProjection: Matrix;
  27434. }
  27435. /**
  27436. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  27437. */
  27438. export class GeometryBufferRenderer {
  27439. /**
  27440. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  27441. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  27442. */
  27443. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  27444. /**
  27445. * Constant used to retrieve the position texture index in the G-Buffer textures array
  27446. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  27447. */
  27448. static readonly POSITION_TEXTURE_TYPE: number;
  27449. /**
  27450. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  27451. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  27452. */
  27453. static readonly VELOCITY_TEXTURE_TYPE: number;
  27454. /**
  27455. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  27456. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  27457. */
  27458. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  27459. /**
  27460. * Dictionary used to store the previous transformation matrices of each rendered mesh
  27461. * in order to compute objects velocities when enableVelocity is set to "true"
  27462. * @hidden
  27463. */
  27464. _previousTransformationMatrices: {
  27465. [index: number]: ISavedTransformationMatrix;
  27466. };
  27467. /**
  27468. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  27469. * in order to compute objects velocities when enableVelocity is set to "true"
  27470. * @hidden
  27471. */
  27472. _previousBonesTransformationMatrices: {
  27473. [index: number]: Float32Array;
  27474. };
  27475. /**
  27476. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  27477. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  27478. */
  27479. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  27480. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  27481. renderTransparentMeshes: boolean;
  27482. private _scene;
  27483. private _resizeObserver;
  27484. private _multiRenderTarget;
  27485. private _ratio;
  27486. private _enablePosition;
  27487. private _enableVelocity;
  27488. private _enableReflectivity;
  27489. private _positionIndex;
  27490. private _velocityIndex;
  27491. private _reflectivityIndex;
  27492. private _depthNormalIndex;
  27493. private _linkedWithPrePass;
  27494. private _prePassRenderer;
  27495. private _attachments;
  27496. protected _effect: Effect;
  27497. protected _cachedDefines: string;
  27498. /**
  27499. * @hidden
  27500. * Sets up internal structures to share outputs with PrePassRenderer
  27501. * This method should only be called by the PrePassRenderer itself
  27502. */
  27503. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  27504. /**
  27505. * @hidden
  27506. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  27507. * This method should only be called by the PrePassRenderer itself
  27508. */
  27509. _unlinkPrePassRenderer(): void;
  27510. /**
  27511. * @hidden
  27512. * Resets the geometry buffer layout
  27513. */
  27514. _resetLayout(): void;
  27515. /**
  27516. * @hidden
  27517. * Replaces a texture in the geometry buffer renderer
  27518. * Useful when linking textures of the prepass renderer
  27519. */
  27520. _forceTextureType(geometryBufferType: number, index: number): void;
  27521. /**
  27522. * @hidden
  27523. * Sets texture attachments
  27524. * Useful when linking textures of the prepass renderer
  27525. */
  27526. _setAttachments(attachments: number[]): void;
  27527. /**
  27528. * @hidden
  27529. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  27530. * Useful when linking textures of the prepass renderer
  27531. */
  27532. _linkInternalTexture(internalTexture: InternalTexture): void;
  27533. /**
  27534. * Gets the render list (meshes to be rendered) used in the G buffer.
  27535. */
  27536. get renderList(): Nullable<AbstractMesh[]>;
  27537. /**
  27538. * Set the render list (meshes to be rendered) used in the G buffer.
  27539. */
  27540. set renderList(meshes: Nullable<AbstractMesh[]>);
  27541. /**
  27542. * Gets wether or not G buffer are supported by the running hardware.
  27543. * This requires draw buffer supports
  27544. */
  27545. get isSupported(): boolean;
  27546. /**
  27547. * Returns the index of the given texture type in the G-Buffer textures array
  27548. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  27549. * @returns the index of the given texture type in the G-Buffer textures array
  27550. */
  27551. getTextureIndex(textureType: number): number;
  27552. /**
  27553. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  27554. */
  27555. get enablePosition(): boolean;
  27556. /**
  27557. * Sets whether or not objects positions are enabled for the G buffer.
  27558. */
  27559. set enablePosition(enable: boolean);
  27560. /**
  27561. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  27562. */
  27563. get enableVelocity(): boolean;
  27564. /**
  27565. * Sets wether or not objects velocities are enabled for the G buffer.
  27566. */
  27567. set enableVelocity(enable: boolean);
  27568. /**
  27569. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  27570. */
  27571. get enableReflectivity(): boolean;
  27572. /**
  27573. * Sets wether or not objects roughness are enabled for the G buffer.
  27574. */
  27575. set enableReflectivity(enable: boolean);
  27576. /**
  27577. * Gets the scene associated with the buffer.
  27578. */
  27579. get scene(): Scene;
  27580. /**
  27581. * Gets the ratio used by the buffer during its creation.
  27582. * How big is the buffer related to the main canvas.
  27583. */
  27584. get ratio(): number;
  27585. /** @hidden */
  27586. static _SceneComponentInitialization: (scene: Scene) => void;
  27587. /**
  27588. * Creates a new G Buffer for the scene
  27589. * @param scene The scene the buffer belongs to
  27590. * @param ratio How big is the buffer related to the main canvas.
  27591. */
  27592. constructor(scene: Scene, ratio?: number);
  27593. /**
  27594. * Checks wether everything is ready to render a submesh to the G buffer.
  27595. * @param subMesh the submesh to check readiness for
  27596. * @param useInstances is the mesh drawn using instance or not
  27597. * @returns true if ready otherwise false
  27598. */
  27599. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  27600. /**
  27601. * Gets the current underlying G Buffer.
  27602. * @returns the buffer
  27603. */
  27604. getGBuffer(): MultiRenderTarget;
  27605. /**
  27606. * Gets the number of samples used to render the buffer (anti aliasing).
  27607. */
  27608. get samples(): number;
  27609. /**
  27610. * Sets the number of samples used to render the buffer (anti aliasing).
  27611. */
  27612. set samples(value: number);
  27613. /**
  27614. * Disposes the renderer and frees up associated resources.
  27615. */
  27616. dispose(): void;
  27617. private _assignRenderTargetIndices;
  27618. protected _createRenderTargets(): void;
  27619. private _copyBonesTransformationMatrices;
  27620. }
  27621. }
  27622. declare module BABYLON {
  27623. /**
  27624. * Renders a pre pass of the scene
  27625. * This means every mesh in the scene will be rendered to a render target texture
  27626. * And then this texture will be composited to the rendering canvas with post processes
  27627. * It is necessary for effects like subsurface scattering or deferred shading
  27628. */
  27629. export class PrePassRenderer {
  27630. /** @hidden */
  27631. static _SceneComponentInitialization: (scene: Scene) => void;
  27632. private _textureFormats;
  27633. /**
  27634. * To save performance, we can excluded skinned meshes from the prepass
  27635. */
  27636. excludedSkinnedMesh: AbstractMesh[];
  27637. /**
  27638. * Force material to be excluded from the prepass
  27639. * Can be useful when `useGeometryBufferFallback` is set to `true`
  27640. * and you don't want a material to show in the effect.
  27641. */
  27642. excludedMaterials: Material[];
  27643. private _textureIndices;
  27644. private _scene;
  27645. private _engine;
  27646. private _isDirty;
  27647. /**
  27648. * Number of textures in the multi render target texture where the scene is directly rendered
  27649. */
  27650. mrtCount: number;
  27651. /**
  27652. * The render target where the scene is directly rendered
  27653. */
  27654. prePassRT: MultiRenderTarget;
  27655. private _multiRenderAttachments;
  27656. private _defaultAttachments;
  27657. private _clearAttachments;
  27658. private _postProcesses;
  27659. private readonly _clearColor;
  27660. /**
  27661. * Image processing post process for composition
  27662. */
  27663. imageProcessingPostProcess: ImageProcessingPostProcess;
  27664. /**
  27665. * Configuration for prepass effects
  27666. */
  27667. private _effectConfigurations;
  27668. private _mrtFormats;
  27669. private _mrtLayout;
  27670. private _enabled;
  27671. /**
  27672. * Indicates if the prepass is enabled
  27673. */
  27674. get enabled(): boolean;
  27675. /**
  27676. * How many samples are used for MSAA of the scene render target
  27677. */
  27678. get samples(): number;
  27679. set samples(n: number);
  27680. private _geometryBuffer;
  27681. private _useGeometryBufferFallback;
  27682. /**
  27683. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  27684. */
  27685. get useGeometryBufferFallback(): boolean;
  27686. set useGeometryBufferFallback(value: boolean);
  27687. /**
  27688. * Instanciates a prepass renderer
  27689. * @param scene The scene
  27690. */
  27691. constructor(scene: Scene);
  27692. private _initializeAttachments;
  27693. private _createCompositionEffect;
  27694. /**
  27695. * Indicates if rendering a prepass is supported
  27696. */
  27697. get isSupported(): boolean;
  27698. /**
  27699. * Sets the proper output textures to draw in the engine.
  27700. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  27701. * @param subMesh Submesh on which the effect is applied
  27702. */
  27703. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  27704. /**
  27705. * @hidden
  27706. */
  27707. _beforeCameraDraw(): void;
  27708. /**
  27709. * @hidden
  27710. */
  27711. _afterCameraDraw(): void;
  27712. private _checkRTSize;
  27713. private _bindFrameBuffer;
  27714. /**
  27715. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  27716. */
  27717. clear(): void;
  27718. private _setState;
  27719. private _updateGeometryBufferLayout;
  27720. /**
  27721. * Adds an effect configuration to the prepass.
  27722. * If an effect has already been added, it won't add it twice and will return the configuration
  27723. * already present.
  27724. * @param cfg the effect configuration
  27725. * @return the effect configuration now used by the prepass
  27726. */
  27727. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  27728. /**
  27729. * Returns the index of a texture in the multi render target texture array.
  27730. * @param type Texture type
  27731. * @return The index
  27732. */
  27733. getIndex(type: number): number;
  27734. private _enable;
  27735. private _disable;
  27736. private _resetLayout;
  27737. private _resetPostProcessChain;
  27738. private _bindPostProcessChain;
  27739. /**
  27740. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  27741. */
  27742. markAsDirty(): void;
  27743. /**
  27744. * Enables a texture on the MultiRenderTarget for prepass
  27745. */
  27746. private _enableTextures;
  27747. private _update;
  27748. private _markAllMaterialsAsPrePassDirty;
  27749. /**
  27750. * Disposes the prepass renderer.
  27751. */
  27752. dispose(): void;
  27753. }
  27754. }
  27755. declare module BABYLON {
  27756. /**
  27757. * Size options for a post process
  27758. */
  27759. export type PostProcessOptions = {
  27760. width: number;
  27761. height: number;
  27762. };
  27763. /**
  27764. * PostProcess can be used to apply a shader to a texture after it has been rendered
  27765. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  27766. */
  27767. export class PostProcess {
  27768. /**
  27769. * Gets or sets the unique id of the post process
  27770. */
  27771. uniqueId: number;
  27772. /** Name of the PostProcess. */
  27773. name: string;
  27774. /**
  27775. * Width of the texture to apply the post process on
  27776. */
  27777. width: number;
  27778. /**
  27779. * Height of the texture to apply the post process on
  27780. */
  27781. height: number;
  27782. /**
  27783. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  27784. */
  27785. nodeMaterialSource: Nullable<NodeMaterial>;
  27786. /**
  27787. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  27788. * @hidden
  27789. */
  27790. _outputTexture: Nullable<InternalTexture>;
  27791. /**
  27792. * Sampling mode used by the shader
  27793. * See https://doc.babylonjs.com/classes/3.1/texture
  27794. */
  27795. renderTargetSamplingMode: number;
  27796. /**
  27797. * Clear color to use when screen clearing
  27798. */
  27799. clearColor: Color4;
  27800. /**
  27801. * If the buffer needs to be cleared before applying the post process. (default: true)
  27802. * Should be set to false if shader will overwrite all previous pixels.
  27803. */
  27804. autoClear: boolean;
  27805. /**
  27806. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  27807. */
  27808. alphaMode: number;
  27809. /**
  27810. * Sets the setAlphaBlendConstants of the babylon engine
  27811. */
  27812. alphaConstants: Color4;
  27813. /**
  27814. * Animations to be used for the post processing
  27815. */
  27816. animations: Animation[];
  27817. /**
  27818. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  27819. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  27820. */
  27821. enablePixelPerfectMode: boolean;
  27822. /**
  27823. * Force the postprocess to be applied without taking in account viewport
  27824. */
  27825. forceFullscreenViewport: boolean;
  27826. /**
  27827. * List of inspectable custom properties (used by the Inspector)
  27828. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27829. */
  27830. inspectableCustomProperties: IInspectable[];
  27831. /**
  27832. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  27833. *
  27834. * | Value | Type | Description |
  27835. * | ----- | ----------------------------------- | ----------- |
  27836. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  27837. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  27838. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  27839. *
  27840. */
  27841. scaleMode: number;
  27842. /**
  27843. * Force textures to be a power of two (default: false)
  27844. */
  27845. alwaysForcePOT: boolean;
  27846. private _samples;
  27847. /**
  27848. * Number of sample textures (default: 1)
  27849. */
  27850. get samples(): number;
  27851. set samples(n: number);
  27852. /**
  27853. * Modify the scale of the post process to be the same as the viewport (default: false)
  27854. */
  27855. adaptScaleToCurrentViewport: boolean;
  27856. private _camera;
  27857. protected _scene: Scene;
  27858. private _engine;
  27859. private _options;
  27860. private _reusable;
  27861. private _textureType;
  27862. private _textureFormat;
  27863. /**
  27864. * Smart array of input and output textures for the post process.
  27865. * @hidden
  27866. */
  27867. _textures: SmartArray<InternalTexture>;
  27868. /**
  27869. * The index in _textures that corresponds to the output texture.
  27870. * @hidden
  27871. */
  27872. _currentRenderTextureInd: number;
  27873. private _effect;
  27874. private _samplers;
  27875. private _fragmentUrl;
  27876. private _vertexUrl;
  27877. private _parameters;
  27878. private _scaleRatio;
  27879. protected _indexParameters: any;
  27880. private _shareOutputWithPostProcess;
  27881. private _texelSize;
  27882. private _forcedOutputTexture;
  27883. /**
  27884. * Prepass configuration in case this post process needs a texture from prepass
  27885. * @hidden
  27886. */
  27887. _prePassEffectConfiguration: PrePassEffectConfiguration;
  27888. /**
  27889. * Returns the fragment url or shader name used in the post process.
  27890. * @returns the fragment url or name in the shader store.
  27891. */
  27892. getEffectName(): string;
  27893. /**
  27894. * An event triggered when the postprocess is activated.
  27895. */
  27896. onActivateObservable: Observable<Camera>;
  27897. private _onActivateObserver;
  27898. /**
  27899. * A function that is added to the onActivateObservable
  27900. */
  27901. set onActivate(callback: Nullable<(camera: Camera) => void>);
  27902. /**
  27903. * An event triggered when the postprocess changes its size.
  27904. */
  27905. onSizeChangedObservable: Observable<PostProcess>;
  27906. private _onSizeChangedObserver;
  27907. /**
  27908. * A function that is added to the onSizeChangedObservable
  27909. */
  27910. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  27911. /**
  27912. * An event triggered when the postprocess applies its effect.
  27913. */
  27914. onApplyObservable: Observable<Effect>;
  27915. private _onApplyObserver;
  27916. /**
  27917. * A function that is added to the onApplyObservable
  27918. */
  27919. set onApply(callback: (effect: Effect) => void);
  27920. /**
  27921. * An event triggered before rendering the postprocess
  27922. */
  27923. onBeforeRenderObservable: Observable<Effect>;
  27924. private _onBeforeRenderObserver;
  27925. /**
  27926. * A function that is added to the onBeforeRenderObservable
  27927. */
  27928. set onBeforeRender(callback: (effect: Effect) => void);
  27929. /**
  27930. * An event triggered after rendering the postprocess
  27931. */
  27932. onAfterRenderObservable: Observable<Effect>;
  27933. private _onAfterRenderObserver;
  27934. /**
  27935. * A function that is added to the onAfterRenderObservable
  27936. */
  27937. set onAfterRender(callback: (efect: Effect) => void);
  27938. /**
  27939. * 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
  27940. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  27941. */
  27942. get inputTexture(): InternalTexture;
  27943. set inputTexture(value: InternalTexture);
  27944. /**
  27945. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  27946. * the only way to unset it is to use this function to restore its internal state
  27947. */
  27948. restoreDefaultInputTexture(): void;
  27949. /**
  27950. * Gets the camera which post process is applied to.
  27951. * @returns The camera the post process is applied to.
  27952. */
  27953. getCamera(): Camera;
  27954. /**
  27955. * Gets the texel size of the postprocess.
  27956. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  27957. */
  27958. get texelSize(): Vector2;
  27959. /**
  27960. * Creates a new instance PostProcess
  27961. * @param name The name of the PostProcess.
  27962. * @param fragmentUrl The url of the fragment shader to be used.
  27963. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  27964. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  27965. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  27966. * @param camera The camera to apply the render pass to.
  27967. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27968. * @param engine The engine which the post process will be applied. (default: current engine)
  27969. * @param reusable If the post process can be reused on the same frame. (default: false)
  27970. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  27971. * @param textureType Type of textures used when performing the post process. (default: 0)
  27972. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  27973. * @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
  27974. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  27975. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  27976. */
  27977. 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);
  27978. /**
  27979. * Gets a string identifying the name of the class
  27980. * @returns "PostProcess" string
  27981. */
  27982. getClassName(): string;
  27983. /**
  27984. * Gets the engine which this post process belongs to.
  27985. * @returns The engine the post process was enabled with.
  27986. */
  27987. getEngine(): Engine;
  27988. /**
  27989. * The effect that is created when initializing the post process.
  27990. * @returns The created effect corresponding the the postprocess.
  27991. */
  27992. getEffect(): Effect;
  27993. /**
  27994. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  27995. * @param postProcess The post process to share the output with.
  27996. * @returns This post process.
  27997. */
  27998. shareOutputWith(postProcess: PostProcess): PostProcess;
  27999. /**
  28000. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  28001. * This should be called if the post process that shares output with this post process is disabled/disposed.
  28002. */
  28003. useOwnOutput(): void;
  28004. /**
  28005. * Updates the effect with the current post process compile time values and recompiles the shader.
  28006. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  28007. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  28008. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  28009. * @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
  28010. * @param onCompiled Called when the shader has been compiled.
  28011. * @param onError Called if there is an error when compiling a shader.
  28012. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  28013. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  28014. */
  28015. 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;
  28016. /**
  28017. * The post process is reusable if it can be used multiple times within one frame.
  28018. * @returns If the post process is reusable
  28019. */
  28020. isReusable(): boolean;
  28021. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  28022. markTextureDirty(): void;
  28023. /**
  28024. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  28025. * 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.
  28026. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  28027. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  28028. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  28029. * @returns The target texture that was bound to be written to.
  28030. */
  28031. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  28032. /**
  28033. * If the post process is supported.
  28034. */
  28035. get isSupported(): boolean;
  28036. /**
  28037. * The aspect ratio of the output texture.
  28038. */
  28039. get aspectRatio(): number;
  28040. /**
  28041. * Get a value indicating if the post-process is ready to be used
  28042. * @returns true if the post-process is ready (shader is compiled)
  28043. */
  28044. isReady(): boolean;
  28045. /**
  28046. * Binds all textures and uniforms to the shader, this will be run on every pass.
  28047. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  28048. */
  28049. apply(): Nullable<Effect>;
  28050. private _disposeTextures;
  28051. /**
  28052. * Sets the required values to the prepass renderer.
  28053. * @param prePassRenderer defines the prepass renderer to setup.
  28054. * @returns true if the pre pass is needed.
  28055. */
  28056. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  28057. /**
  28058. * Disposes the post process.
  28059. * @param camera The camera to dispose the post process on.
  28060. */
  28061. dispose(camera?: Camera): void;
  28062. /**
  28063. * Serializes the particle system to a JSON object
  28064. * @returns the JSON object
  28065. */
  28066. serialize(): any;
  28067. /**
  28068. * Creates a material from parsed material data
  28069. * @param parsedPostProcess defines parsed post process data
  28070. * @param scene defines the hosting scene
  28071. * @param rootUrl defines the root URL to use to load textures
  28072. * @returns a new post process
  28073. */
  28074. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  28075. }
  28076. }
  28077. declare module BABYLON {
  28078. /** @hidden */
  28079. export var kernelBlurVaryingDeclaration: {
  28080. name: string;
  28081. shader: string;
  28082. };
  28083. }
  28084. declare module BABYLON {
  28085. /** @hidden */
  28086. export var kernelBlurFragment: {
  28087. name: string;
  28088. shader: string;
  28089. };
  28090. }
  28091. declare module BABYLON {
  28092. /** @hidden */
  28093. export var kernelBlurFragment2: {
  28094. name: string;
  28095. shader: string;
  28096. };
  28097. }
  28098. declare module BABYLON {
  28099. /** @hidden */
  28100. export var kernelBlurPixelShader: {
  28101. name: string;
  28102. shader: string;
  28103. };
  28104. }
  28105. declare module BABYLON {
  28106. /** @hidden */
  28107. export var kernelBlurVertex: {
  28108. name: string;
  28109. shader: string;
  28110. };
  28111. }
  28112. declare module BABYLON {
  28113. /** @hidden */
  28114. export var kernelBlurVertexShader: {
  28115. name: string;
  28116. shader: string;
  28117. };
  28118. }
  28119. declare module BABYLON {
  28120. /**
  28121. * The Blur Post Process which blurs an image based on a kernel and direction.
  28122. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  28123. */
  28124. export class BlurPostProcess extends PostProcess {
  28125. private blockCompilation;
  28126. protected _kernel: number;
  28127. protected _idealKernel: number;
  28128. protected _packedFloat: boolean;
  28129. private _staticDefines;
  28130. /** The direction in which to blur the image. */
  28131. direction: Vector2;
  28132. /**
  28133. * Sets the length in pixels of the blur sample region
  28134. */
  28135. set kernel(v: number);
  28136. /**
  28137. * Gets the length in pixels of the blur sample region
  28138. */
  28139. get kernel(): number;
  28140. /**
  28141. * Sets wether or not the blur needs to unpack/repack floats
  28142. */
  28143. set packedFloat(v: boolean);
  28144. /**
  28145. * Gets wether or not the blur is unpacking/repacking floats
  28146. */
  28147. get packedFloat(): boolean;
  28148. /**
  28149. * Gets a string identifying the name of the class
  28150. * @returns "BlurPostProcess" string
  28151. */
  28152. getClassName(): string;
  28153. /**
  28154. * Creates a new instance BlurPostProcess
  28155. * @param name The name of the effect.
  28156. * @param direction The direction in which to blur the image.
  28157. * @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.
  28158. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  28159. * @param camera The camera to apply the render pass to.
  28160. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28161. * @param engine The engine which the post process will be applied. (default: current engine)
  28162. * @param reusable If the post process can be reused on the same frame. (default: false)
  28163. * @param textureType Type of textures used when performing the post process. (default: 0)
  28164. * @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)
  28165. */
  28166. 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);
  28167. /**
  28168. * Updates the effect with the current post process compile time values and recompiles the shader.
  28169. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  28170. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  28171. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  28172. * @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
  28173. * @param onCompiled Called when the shader has been compiled.
  28174. * @param onError Called if there is an error when compiling a shader.
  28175. */
  28176. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  28177. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  28178. /**
  28179. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  28180. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  28181. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  28182. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  28183. * The gaps between physical kernels are compensated for in the weighting of the samples
  28184. * @param idealKernel Ideal blur kernel.
  28185. * @return Nearest best kernel.
  28186. */
  28187. protected _nearestBestKernel(idealKernel: number): number;
  28188. /**
  28189. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  28190. * @param x The point on the Gaussian distribution to sample.
  28191. * @return the value of the Gaussian function at x.
  28192. */
  28193. protected _gaussianWeight(x: number): number;
  28194. /**
  28195. * Generates a string that can be used as a floating point number in GLSL.
  28196. * @param x Value to print.
  28197. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  28198. * @return GLSL float string.
  28199. */
  28200. protected _glslFloat(x: number, decimalFigures?: number): string;
  28201. /** @hidden */
  28202. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  28203. }
  28204. }
  28205. declare module BABYLON {
  28206. /**
  28207. * Mirror texture can be used to simulate the view from a mirror in a scene.
  28208. * It will dynamically be rendered every frame to adapt to the camera point of view.
  28209. * You can then easily use it as a reflectionTexture on a flat surface.
  28210. * In case the surface is not a plane, please consider relying on reflection probes.
  28211. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  28212. */
  28213. export class MirrorTexture extends RenderTargetTexture {
  28214. private scene;
  28215. /**
  28216. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  28217. * 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.
  28218. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  28219. */
  28220. mirrorPlane: Plane;
  28221. /**
  28222. * Define the blur ratio used to blur the reflection if needed.
  28223. */
  28224. set blurRatio(value: number);
  28225. get blurRatio(): number;
  28226. /**
  28227. * Define the adaptive blur kernel used to blur the reflection if needed.
  28228. * This will autocompute the closest best match for the `blurKernel`
  28229. */
  28230. set adaptiveBlurKernel(value: number);
  28231. /**
  28232. * Define the blur kernel used to blur the reflection if needed.
  28233. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  28234. */
  28235. set blurKernel(value: number);
  28236. /**
  28237. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  28238. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  28239. */
  28240. set blurKernelX(value: number);
  28241. get blurKernelX(): number;
  28242. /**
  28243. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  28244. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  28245. */
  28246. set blurKernelY(value: number);
  28247. get blurKernelY(): number;
  28248. private _autoComputeBlurKernel;
  28249. protected _onRatioRescale(): void;
  28250. private _updateGammaSpace;
  28251. private _imageProcessingConfigChangeObserver;
  28252. private _transformMatrix;
  28253. private _mirrorMatrix;
  28254. private _savedViewMatrix;
  28255. private _blurX;
  28256. private _blurY;
  28257. private _adaptiveBlurKernel;
  28258. private _blurKernelX;
  28259. private _blurKernelY;
  28260. private _blurRatio;
  28261. /**
  28262. * Instantiates a Mirror Texture.
  28263. * Mirror texture can be used to simulate the view from a mirror in a scene.
  28264. * It will dynamically be rendered every frame to adapt to the camera point of view.
  28265. * You can then easily use it as a reflectionTexture on a flat surface.
  28266. * In case the surface is not a plane, please consider relying on reflection probes.
  28267. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  28268. * @param name
  28269. * @param size
  28270. * @param scene
  28271. * @param generateMipMaps
  28272. * @param type
  28273. * @param samplingMode
  28274. * @param generateDepthBuffer
  28275. */
  28276. constructor(name: string, size: number | {
  28277. width: number;
  28278. height: number;
  28279. } | {
  28280. ratio: number;
  28281. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  28282. private _preparePostProcesses;
  28283. /**
  28284. * Clone the mirror texture.
  28285. * @returns the cloned texture
  28286. */
  28287. clone(): MirrorTexture;
  28288. /**
  28289. * Serialize the texture to a JSON representation you could use in Parse later on
  28290. * @returns the serialized JSON representation
  28291. */
  28292. serialize(): any;
  28293. /**
  28294. * Dispose the texture and release its associated resources.
  28295. */
  28296. dispose(): void;
  28297. }
  28298. }
  28299. declare module BABYLON {
  28300. /**
  28301. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  28302. * @see https://doc.babylonjs.com/babylon101/materials#texture
  28303. */
  28304. export class Texture extends BaseTexture {
  28305. /**
  28306. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  28307. */
  28308. static SerializeBuffers: boolean;
  28309. /**
  28310. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  28311. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  28312. */
  28313. static ForceSerializeBuffers: boolean;
  28314. /** @hidden */
  28315. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  28316. /** @hidden */
  28317. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  28318. /** @hidden */
  28319. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  28320. /** nearest is mag = nearest and min = nearest and mip = linear */
  28321. static readonly NEAREST_SAMPLINGMODE: number;
  28322. /** nearest is mag = nearest and min = nearest and mip = linear */
  28323. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  28324. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28325. static readonly BILINEAR_SAMPLINGMODE: number;
  28326. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28327. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  28328. /** Trilinear is mag = linear and min = linear and mip = linear */
  28329. static readonly TRILINEAR_SAMPLINGMODE: number;
  28330. /** Trilinear is mag = linear and min = linear and mip = linear */
  28331. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  28332. /** mag = nearest and min = nearest and mip = nearest */
  28333. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  28334. /** mag = nearest and min = linear and mip = nearest */
  28335. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  28336. /** mag = nearest and min = linear and mip = linear */
  28337. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  28338. /** mag = nearest and min = linear and mip = none */
  28339. static readonly NEAREST_LINEAR: number;
  28340. /** mag = nearest and min = nearest and mip = none */
  28341. static readonly NEAREST_NEAREST: number;
  28342. /** mag = linear and min = nearest and mip = nearest */
  28343. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  28344. /** mag = linear and min = nearest and mip = linear */
  28345. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  28346. /** mag = linear and min = linear and mip = none */
  28347. static readonly LINEAR_LINEAR: number;
  28348. /** mag = linear and min = nearest and mip = none */
  28349. static readonly LINEAR_NEAREST: number;
  28350. /** Explicit coordinates mode */
  28351. static readonly EXPLICIT_MODE: number;
  28352. /** Spherical coordinates mode */
  28353. static readonly SPHERICAL_MODE: number;
  28354. /** Planar coordinates mode */
  28355. static readonly PLANAR_MODE: number;
  28356. /** Cubic coordinates mode */
  28357. static readonly CUBIC_MODE: number;
  28358. /** Projection coordinates mode */
  28359. static readonly PROJECTION_MODE: number;
  28360. /** Inverse Cubic coordinates mode */
  28361. static readonly SKYBOX_MODE: number;
  28362. /** Inverse Cubic coordinates mode */
  28363. static readonly INVCUBIC_MODE: number;
  28364. /** Equirectangular coordinates mode */
  28365. static readonly EQUIRECTANGULAR_MODE: number;
  28366. /** Equirectangular Fixed coordinates mode */
  28367. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  28368. /** Equirectangular Fixed Mirrored coordinates mode */
  28369. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  28370. /** Texture is not repeating outside of 0..1 UVs */
  28371. static readonly CLAMP_ADDRESSMODE: number;
  28372. /** Texture is repeating outside of 0..1 UVs */
  28373. static readonly WRAP_ADDRESSMODE: number;
  28374. /** Texture is repeating and mirrored */
  28375. static readonly MIRROR_ADDRESSMODE: number;
  28376. /**
  28377. * 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
  28378. */
  28379. static UseSerializedUrlIfAny: boolean;
  28380. /**
  28381. * Define the url of the texture.
  28382. */
  28383. url: Nullable<string>;
  28384. /**
  28385. * Define an offset on the texture to offset the u coordinates of the UVs
  28386. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  28387. */
  28388. uOffset: number;
  28389. /**
  28390. * Define an offset on the texture to offset the v coordinates of the UVs
  28391. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  28392. */
  28393. vOffset: number;
  28394. /**
  28395. * Define an offset on the texture to scale the u coordinates of the UVs
  28396. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  28397. */
  28398. uScale: number;
  28399. /**
  28400. * Define an offset on the texture to scale the v coordinates of the UVs
  28401. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  28402. */
  28403. vScale: number;
  28404. /**
  28405. * Define an offset on the texture to rotate around the u coordinates of the UVs
  28406. * @see https://doc.babylonjs.com/how_to/more_materials
  28407. */
  28408. uAng: number;
  28409. /**
  28410. * Define an offset on the texture to rotate around the v coordinates of the UVs
  28411. * @see https://doc.babylonjs.com/how_to/more_materials
  28412. */
  28413. vAng: number;
  28414. /**
  28415. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  28416. * @see https://doc.babylonjs.com/how_to/more_materials
  28417. */
  28418. wAng: number;
  28419. /**
  28420. * Defines the center of rotation (U)
  28421. */
  28422. uRotationCenter: number;
  28423. /**
  28424. * Defines the center of rotation (V)
  28425. */
  28426. vRotationCenter: number;
  28427. /**
  28428. * Defines the center of rotation (W)
  28429. */
  28430. wRotationCenter: number;
  28431. /**
  28432. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  28433. */
  28434. homogeneousRotationInUVTransform: boolean;
  28435. /**
  28436. * Are mip maps generated for this texture or not.
  28437. */
  28438. get noMipmap(): boolean;
  28439. /**
  28440. * List of inspectable custom properties (used by the Inspector)
  28441. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28442. */
  28443. inspectableCustomProperties: Nullable<IInspectable[]>;
  28444. private _noMipmap;
  28445. /** @hidden */
  28446. _invertY: boolean;
  28447. private _rowGenerationMatrix;
  28448. private _cachedTextureMatrix;
  28449. private _projectionModeMatrix;
  28450. private _t0;
  28451. private _t1;
  28452. private _t2;
  28453. private _cachedUOffset;
  28454. private _cachedVOffset;
  28455. private _cachedUScale;
  28456. private _cachedVScale;
  28457. private _cachedUAng;
  28458. private _cachedVAng;
  28459. private _cachedWAng;
  28460. private _cachedProjectionMatrixId;
  28461. private _cachedURotationCenter;
  28462. private _cachedVRotationCenter;
  28463. private _cachedWRotationCenter;
  28464. private _cachedHomogeneousRotationInUVTransform;
  28465. private _cachedCoordinatesMode;
  28466. /** @hidden */
  28467. protected _initialSamplingMode: number;
  28468. /** @hidden */
  28469. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  28470. private _deleteBuffer;
  28471. protected _format: Nullable<number>;
  28472. private _delayedOnLoad;
  28473. private _delayedOnError;
  28474. private _mimeType?;
  28475. private _loaderOptions?;
  28476. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  28477. get mimeType(): string | undefined;
  28478. /**
  28479. * Observable triggered once the texture has been loaded.
  28480. */
  28481. onLoadObservable: Observable<Texture>;
  28482. protected _isBlocking: boolean;
  28483. /**
  28484. * Is the texture preventing material to render while loading.
  28485. * If false, a default texture will be used instead of the loading one during the preparation step.
  28486. */
  28487. set isBlocking(value: boolean);
  28488. get isBlocking(): boolean;
  28489. /**
  28490. * Get the current sampling mode associated with the texture.
  28491. */
  28492. get samplingMode(): number;
  28493. /**
  28494. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  28495. */
  28496. get invertY(): boolean;
  28497. /**
  28498. * Instantiates a new texture.
  28499. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  28500. * @see https://doc.babylonjs.com/babylon101/materials#texture
  28501. * @param url defines the url of the picture to load as a texture
  28502. * @param sceneOrEngine defines the scene or engine the texture will belong to
  28503. * @param noMipmap defines if the texture will require mip maps or not
  28504. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  28505. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  28506. * @param onLoad defines a callback triggered when the texture has been loaded
  28507. * @param onError defines a callback triggered when an error occurred during the loading session
  28508. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  28509. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  28510. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  28511. * @param mimeType defines an optional mime type information
  28512. * @param loaderOptions options to be passed to the loader
  28513. */
  28514. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string, loaderOptions?: any);
  28515. /**
  28516. * Update the url (and optional buffer) of this texture if url was null during construction.
  28517. * @param url the url of the texture
  28518. * @param buffer the buffer of the texture (defaults to null)
  28519. * @param onLoad callback called when the texture is loaded (defaults to null)
  28520. */
  28521. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  28522. /**
  28523. * Finish the loading sequence of a texture flagged as delayed load.
  28524. * @hidden
  28525. */
  28526. delayLoad(): void;
  28527. private _prepareRowForTextureGeneration;
  28528. /**
  28529. * Checks if the texture has the same transform matrix than another texture
  28530. * @param texture texture to check against
  28531. * @returns true if the transforms are the same, else false
  28532. */
  28533. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  28534. /**
  28535. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  28536. * @returns the transform matrix of the texture.
  28537. */
  28538. getTextureMatrix(uBase?: number): Matrix;
  28539. /**
  28540. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  28541. * @returns The reflection texture transform
  28542. */
  28543. getReflectionTextureMatrix(): Matrix;
  28544. /**
  28545. * Clones the texture.
  28546. * @returns the cloned texture
  28547. */
  28548. clone(): Texture;
  28549. /**
  28550. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  28551. * @returns The JSON representation of the texture
  28552. */
  28553. serialize(): any;
  28554. /**
  28555. * Get the current class name of the texture useful for serialization or dynamic coding.
  28556. * @returns "Texture"
  28557. */
  28558. getClassName(): string;
  28559. /**
  28560. * Dispose the texture and release its associated resources.
  28561. */
  28562. dispose(): void;
  28563. /**
  28564. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  28565. * @param parsedTexture Define the JSON representation of the texture
  28566. * @param scene Define the scene the parsed texture should be instantiated in
  28567. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  28568. * @returns The parsed texture if successful
  28569. */
  28570. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  28571. /**
  28572. * Creates a texture from its base 64 representation.
  28573. * @param data Define the base64 payload without the data: prefix
  28574. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  28575. * @param scene Define the scene the texture should belong to
  28576. * @param noMipmap Forces the texture to not create mip map information if true
  28577. * @param invertY define if the texture needs to be inverted on the y axis during loading
  28578. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  28579. * @param onLoad define a callback triggered when the texture has been loaded
  28580. * @param onError define a callback triggered when an error occurred during the loading session
  28581. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  28582. * @returns the created texture
  28583. */
  28584. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  28585. /**
  28586. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  28587. * @param data Define the base64 payload without the data: prefix
  28588. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  28589. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  28590. * @param scene Define the scene the texture should belong to
  28591. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  28592. * @param noMipmap Forces the texture to not create mip map information if true
  28593. * @param invertY define if the texture needs to be inverted on the y axis during loading
  28594. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  28595. * @param onLoad define a callback triggered when the texture has been loaded
  28596. * @param onError define a callback triggered when an error occurred during the loading session
  28597. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  28598. * @returns the created texture
  28599. */
  28600. 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;
  28601. }
  28602. }
  28603. declare module BABYLON {
  28604. /**
  28605. * PostProcessManager is used to manage one or more post processes or post process pipelines
  28606. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  28607. */
  28608. export class PostProcessManager {
  28609. private _scene;
  28610. private _indexBuffer;
  28611. private _vertexBuffers;
  28612. /**
  28613. * Creates a new instance PostProcess
  28614. * @param scene The scene that the post process is associated with.
  28615. */
  28616. constructor(scene: Scene);
  28617. private _prepareBuffers;
  28618. private _buildIndexBuffer;
  28619. /**
  28620. * Rebuilds the vertex buffers of the manager.
  28621. * @hidden
  28622. */
  28623. _rebuild(): void;
  28624. /**
  28625. * Prepares a frame to be run through a post process.
  28626. * @param sourceTexture The input texture to the post procesess. (default: null)
  28627. * @param postProcesses An array of post processes to be run. (default: null)
  28628. * @returns True if the post processes were able to be run.
  28629. * @hidden
  28630. */
  28631. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  28632. /**
  28633. * Manually render a set of post processes to a texture.
  28634. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  28635. * @param postProcesses An array of post processes to be run.
  28636. * @param targetTexture The target texture to render to.
  28637. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  28638. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  28639. * @param lodLevel defines which lod of the texture to render to
  28640. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  28641. */
  28642. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  28643. /**
  28644. * Finalize the result of the output of the postprocesses.
  28645. * @param doNotPresent If true the result will not be displayed to the screen.
  28646. * @param targetTexture The target texture to render to.
  28647. * @param faceIndex The index of the face to bind the target texture to.
  28648. * @param postProcesses The array of post processes to render.
  28649. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  28650. * @hidden
  28651. */
  28652. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  28653. /**
  28654. * Disposes of the post process manager.
  28655. */
  28656. dispose(): void;
  28657. }
  28658. }
  28659. declare module BABYLON {
  28660. /**
  28661. * This Helps creating a texture that will be created from a camera in your scene.
  28662. * It is basically a dynamic texture that could be used to create special effects for instance.
  28663. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  28664. */
  28665. export class RenderTargetTexture extends Texture {
  28666. /**
  28667. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  28668. */
  28669. static readonly REFRESHRATE_RENDER_ONCE: number;
  28670. /**
  28671. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  28672. */
  28673. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  28674. /**
  28675. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  28676. * the central point of your effect and can save a lot of performances.
  28677. */
  28678. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  28679. /**
  28680. * Use this predicate to dynamically define the list of mesh you want to render.
  28681. * If set, the renderList property will be overwritten.
  28682. */
  28683. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  28684. private _renderList;
  28685. /**
  28686. * Use this list to define the list of mesh you want to render.
  28687. */
  28688. get renderList(): Nullable<Array<AbstractMesh>>;
  28689. set renderList(value: Nullable<Array<AbstractMesh>>);
  28690. /**
  28691. * Use this function to overload the renderList array at rendering time.
  28692. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  28693. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  28694. * the cube (if the RTT is a cube, else layerOrFace=0).
  28695. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  28696. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  28697. * hold dummy elements!
  28698. */
  28699. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  28700. private _hookArray;
  28701. /**
  28702. * Define if particles should be rendered in your texture.
  28703. */
  28704. renderParticles: boolean;
  28705. /**
  28706. * Define if sprites should be rendered in your texture.
  28707. */
  28708. renderSprites: boolean;
  28709. /**
  28710. * Define the camera used to render the texture.
  28711. */
  28712. activeCamera: Nullable<Camera>;
  28713. /**
  28714. * Override the mesh isReady function with your own one.
  28715. */
  28716. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  28717. /**
  28718. * Override the render function of the texture with your own one.
  28719. */
  28720. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  28721. /**
  28722. * Define if camera post processes should be use while rendering the texture.
  28723. */
  28724. useCameraPostProcesses: boolean;
  28725. /**
  28726. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  28727. */
  28728. ignoreCameraViewport: boolean;
  28729. private _postProcessManager;
  28730. private _postProcesses;
  28731. private _resizeObserver;
  28732. /**
  28733. * An event triggered when the texture is unbind.
  28734. */
  28735. onBeforeBindObservable: Observable<RenderTargetTexture>;
  28736. /**
  28737. * An event triggered when the texture is unbind.
  28738. */
  28739. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  28740. private _onAfterUnbindObserver;
  28741. /**
  28742. * Set a after unbind callback in the texture.
  28743. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  28744. */
  28745. set onAfterUnbind(callback: () => void);
  28746. /**
  28747. * An event triggered before rendering the texture
  28748. */
  28749. onBeforeRenderObservable: Observable<number>;
  28750. private _onBeforeRenderObserver;
  28751. /**
  28752. * Set a before render callback in the texture.
  28753. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  28754. */
  28755. set onBeforeRender(callback: (faceIndex: number) => void);
  28756. /**
  28757. * An event triggered after rendering the texture
  28758. */
  28759. onAfterRenderObservable: Observable<number>;
  28760. private _onAfterRenderObserver;
  28761. /**
  28762. * Set a after render callback in the texture.
  28763. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  28764. */
  28765. set onAfterRender(callback: (faceIndex: number) => void);
  28766. /**
  28767. * An event triggered after the texture clear
  28768. */
  28769. onClearObservable: Observable<Engine>;
  28770. private _onClearObserver;
  28771. /**
  28772. * Set a clear callback in the texture.
  28773. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  28774. */
  28775. set onClear(callback: (Engine: Engine) => void);
  28776. /**
  28777. * An event triggered when the texture is resized.
  28778. */
  28779. onResizeObservable: Observable<RenderTargetTexture>;
  28780. /**
  28781. * Define the clear color of the Render Target if it should be different from the scene.
  28782. */
  28783. clearColor: Color4;
  28784. protected _size: number | {
  28785. width: number;
  28786. height: number;
  28787. layers?: number;
  28788. };
  28789. protected _initialSizeParameter: number | {
  28790. width: number;
  28791. height: number;
  28792. } | {
  28793. ratio: number;
  28794. };
  28795. protected _sizeRatio: Nullable<number>;
  28796. /** @hidden */
  28797. _generateMipMaps: boolean;
  28798. protected _renderingManager: RenderingManager;
  28799. /** @hidden */
  28800. _waitingRenderList?: string[];
  28801. protected _doNotChangeAspectRatio: boolean;
  28802. protected _currentRefreshId: number;
  28803. protected _refreshRate: number;
  28804. protected _textureMatrix: Matrix;
  28805. protected _samples: number;
  28806. protected _renderTargetOptions: RenderTargetCreationOptions;
  28807. /**
  28808. * Gets render target creation options that were used.
  28809. */
  28810. get renderTargetOptions(): RenderTargetCreationOptions;
  28811. protected _onRatioRescale(): void;
  28812. /**
  28813. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  28814. * It must define where the camera used to render the texture is set
  28815. */
  28816. boundingBoxPosition: Vector3;
  28817. private _boundingBoxSize;
  28818. /**
  28819. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  28820. * When defined, the cubemap will switch to local mode
  28821. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  28822. * @example https://www.babylonjs-playground.com/#RNASML
  28823. */
  28824. set boundingBoxSize(value: Vector3);
  28825. get boundingBoxSize(): Vector3;
  28826. /**
  28827. * In case the RTT has been created with a depth texture, get the associated
  28828. * depth texture.
  28829. * Otherwise, return null.
  28830. */
  28831. get depthStencilTexture(): Nullable<InternalTexture>;
  28832. /**
  28833. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  28834. * or used a shadow, depth texture...
  28835. * @param name The friendly name of the texture
  28836. * @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)
  28837. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  28838. * @param generateMipMaps True if mip maps need to be generated after render.
  28839. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  28840. * @param type The type of the buffer in the RTT (int, half float, float...)
  28841. * @param isCube True if a cube texture needs to be created
  28842. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  28843. * @param generateDepthBuffer True to generate a depth buffer
  28844. * @param generateStencilBuffer True to generate a stencil buffer
  28845. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  28846. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  28847. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28848. */
  28849. constructor(name: string, size: number | {
  28850. width: number;
  28851. height: number;
  28852. layers?: number;
  28853. } | {
  28854. ratio: number;
  28855. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  28856. /**
  28857. * Creates a depth stencil texture.
  28858. * This is only available in WebGL 2 or with the depth texture extension available.
  28859. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  28860. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  28861. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  28862. */
  28863. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  28864. private _processSizeParameter;
  28865. /**
  28866. * Define the number of samples to use in case of MSAA.
  28867. * It defaults to one meaning no MSAA has been enabled.
  28868. */
  28869. get samples(): number;
  28870. set samples(value: number);
  28871. /**
  28872. * Resets the refresh counter of the texture and start bak from scratch.
  28873. * Could be useful to regenerate the texture if it is setup to render only once.
  28874. */
  28875. resetRefreshCounter(): void;
  28876. /**
  28877. * Define the refresh rate of the texture or the rendering frequency.
  28878. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  28879. */
  28880. get refreshRate(): number;
  28881. set refreshRate(value: number);
  28882. /**
  28883. * Adds a post process to the render target rendering passes.
  28884. * @param postProcess define the post process to add
  28885. */
  28886. addPostProcess(postProcess: PostProcess): void;
  28887. /**
  28888. * Clear all the post processes attached to the render target
  28889. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  28890. */
  28891. clearPostProcesses(dispose?: boolean): void;
  28892. /**
  28893. * Remove one of the post process from the list of attached post processes to the texture
  28894. * @param postProcess define the post process to remove from the list
  28895. */
  28896. removePostProcess(postProcess: PostProcess): void;
  28897. /** @hidden */
  28898. _shouldRender(): boolean;
  28899. /**
  28900. * Gets the actual render size of the texture.
  28901. * @returns the width of the render size
  28902. */
  28903. getRenderSize(): number;
  28904. /**
  28905. * Gets the actual render width of the texture.
  28906. * @returns the width of the render size
  28907. */
  28908. getRenderWidth(): number;
  28909. /**
  28910. * Gets the actual render height of the texture.
  28911. * @returns the height of the render size
  28912. */
  28913. getRenderHeight(): number;
  28914. /**
  28915. * Gets the actual number of layers of the texture.
  28916. * @returns the number of layers
  28917. */
  28918. getRenderLayers(): number;
  28919. /**
  28920. * Get if the texture can be rescaled or not.
  28921. */
  28922. get canRescale(): boolean;
  28923. /**
  28924. * Resize the texture using a ratio.
  28925. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  28926. */
  28927. scale(ratio: number): void;
  28928. /**
  28929. * Get the texture reflection matrix used to rotate/transform the reflection.
  28930. * @returns the reflection matrix
  28931. */
  28932. getReflectionTextureMatrix(): Matrix;
  28933. /**
  28934. * Resize the texture to a new desired size.
  28935. * Be carrefull as it will recreate all the data in the new texture.
  28936. * @param size Define the new size. It can be:
  28937. * - a number for squared texture,
  28938. * - an object containing { width: number, height: number }
  28939. * - or an object containing a ratio { ratio: number }
  28940. */
  28941. resize(size: number | {
  28942. width: number;
  28943. height: number;
  28944. } | {
  28945. ratio: number;
  28946. }): void;
  28947. private _defaultRenderListPrepared;
  28948. /**
  28949. * Renders all the objects from the render list into the texture.
  28950. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  28951. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  28952. */
  28953. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  28954. private _bestReflectionRenderTargetDimension;
  28955. private _prepareRenderingManager;
  28956. /**
  28957. * @hidden
  28958. * @param faceIndex face index to bind to if this is a cubetexture
  28959. * @param layer defines the index of the texture to bind in the array
  28960. */
  28961. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  28962. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  28963. private renderToTarget;
  28964. /**
  28965. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  28966. * This allowed control for front to back rendering or reversly depending of the special needs.
  28967. *
  28968. * @param renderingGroupId The rendering group id corresponding to its index
  28969. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  28970. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  28971. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  28972. */
  28973. 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;
  28974. /**
  28975. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  28976. *
  28977. * @param renderingGroupId The rendering group id corresponding to its index
  28978. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  28979. */
  28980. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  28981. /**
  28982. * Clones the texture.
  28983. * @returns the cloned texture
  28984. */
  28985. clone(): RenderTargetTexture;
  28986. /**
  28987. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  28988. * @returns The JSON representation of the texture
  28989. */
  28990. serialize(): any;
  28991. /**
  28992. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  28993. */
  28994. disposeFramebufferObjects(): void;
  28995. /**
  28996. * Dispose the texture and release its associated resources.
  28997. */
  28998. dispose(): void;
  28999. /** @hidden */
  29000. _rebuild(): void;
  29001. /**
  29002. * Clear the info related to rendering groups preventing retention point in material dispose.
  29003. */
  29004. freeRenderingGroups(): void;
  29005. /**
  29006. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  29007. * @returns the view count
  29008. */
  29009. getViewCount(): number;
  29010. }
  29011. }
  29012. declare module BABYLON {
  29013. /**
  29014. * Class used to manipulate GUIDs
  29015. */
  29016. export class GUID {
  29017. /**
  29018. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29019. * Be aware Math.random() could cause collisions, but:
  29020. * "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"
  29021. * @returns a pseudo random id
  29022. */
  29023. static RandomId(): string;
  29024. }
  29025. }
  29026. declare module BABYLON {
  29027. /**
  29028. * Options to be used when creating a shadow depth material
  29029. */
  29030. export interface IIOptionShadowDepthMaterial {
  29031. /** Variables in the vertex shader code that need to have their names remapped.
  29032. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  29033. * "var_name" should be either: worldPos or vNormalW
  29034. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  29035. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  29036. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  29037. */
  29038. remappedVariables?: string[];
  29039. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  29040. standalone?: boolean;
  29041. }
  29042. /**
  29043. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  29044. */
  29045. export class ShadowDepthWrapper {
  29046. private _scene;
  29047. private _options?;
  29048. private _baseMaterial;
  29049. private _onEffectCreatedObserver;
  29050. private _subMeshToEffect;
  29051. private _subMeshToDepthEffect;
  29052. private _meshes;
  29053. /** @hidden */
  29054. _matriceNames: any;
  29055. /** Gets the standalone status of the wrapper */
  29056. get standalone(): boolean;
  29057. /** Gets the base material the wrapper is built upon */
  29058. get baseMaterial(): Material;
  29059. /**
  29060. * Instantiate a new shadow depth wrapper.
  29061. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  29062. * generate the shadow depth map. For more information, please refer to the documentation:
  29063. * https://doc.babylonjs.com/babylon101/shadows
  29064. * @param baseMaterial Material to wrap
  29065. * @param scene Define the scene the material belongs to
  29066. * @param options Options used to create the wrapper
  29067. */
  29068. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  29069. /**
  29070. * Gets the effect to use to generate the depth map
  29071. * @param subMesh subMesh to get the effect for
  29072. * @param shadowGenerator shadow generator to get the effect for
  29073. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  29074. */
  29075. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  29076. /**
  29077. * Specifies that the submesh is ready to be used for depth rendering
  29078. * @param subMesh submesh to check
  29079. * @param defines the list of defines to take into account when checking the effect
  29080. * @param shadowGenerator combined with subMesh, it defines the effect to check
  29081. * @param useInstances specifies that instances should be used
  29082. * @returns a boolean indicating that the submesh is ready or not
  29083. */
  29084. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  29085. /**
  29086. * Disposes the resources
  29087. */
  29088. dispose(): void;
  29089. private _makeEffect;
  29090. }
  29091. }
  29092. declare module BABYLON {
  29093. /**
  29094. * Options for compiling materials.
  29095. */
  29096. export interface IMaterialCompilationOptions {
  29097. /**
  29098. * Defines whether clip planes are enabled.
  29099. */
  29100. clipPlane: boolean;
  29101. /**
  29102. * Defines whether instances are enabled.
  29103. */
  29104. useInstances: boolean;
  29105. }
  29106. /**
  29107. * Options passed when calling customShaderNameResolve
  29108. */
  29109. export interface ICustomShaderNameResolveOptions {
  29110. /**
  29111. * 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
  29112. */
  29113. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  29114. }
  29115. /**
  29116. * Base class for the main features of a material in Babylon.js
  29117. */
  29118. export class Material implements IAnimatable {
  29119. /**
  29120. * Returns the triangle fill mode
  29121. */
  29122. static readonly TriangleFillMode: number;
  29123. /**
  29124. * Returns the wireframe mode
  29125. */
  29126. static readonly WireFrameFillMode: number;
  29127. /**
  29128. * Returns the point fill mode
  29129. */
  29130. static readonly PointFillMode: number;
  29131. /**
  29132. * Returns the point list draw mode
  29133. */
  29134. static readonly PointListDrawMode: number;
  29135. /**
  29136. * Returns the line list draw mode
  29137. */
  29138. static readonly LineListDrawMode: number;
  29139. /**
  29140. * Returns the line loop draw mode
  29141. */
  29142. static readonly LineLoopDrawMode: number;
  29143. /**
  29144. * Returns the line strip draw mode
  29145. */
  29146. static readonly LineStripDrawMode: number;
  29147. /**
  29148. * Returns the triangle strip draw mode
  29149. */
  29150. static readonly TriangleStripDrawMode: number;
  29151. /**
  29152. * Returns the triangle fan draw mode
  29153. */
  29154. static readonly TriangleFanDrawMode: number;
  29155. /**
  29156. * Stores the clock-wise side orientation
  29157. */
  29158. static readonly ClockWiseSideOrientation: number;
  29159. /**
  29160. * Stores the counter clock-wise side orientation
  29161. */
  29162. static readonly CounterClockWiseSideOrientation: number;
  29163. /**
  29164. * The dirty texture flag value
  29165. */
  29166. static readonly TextureDirtyFlag: number;
  29167. /**
  29168. * The dirty light flag value
  29169. */
  29170. static readonly LightDirtyFlag: number;
  29171. /**
  29172. * The dirty fresnel flag value
  29173. */
  29174. static readonly FresnelDirtyFlag: number;
  29175. /**
  29176. * The dirty attribute flag value
  29177. */
  29178. static readonly AttributesDirtyFlag: number;
  29179. /**
  29180. * The dirty misc flag value
  29181. */
  29182. static readonly MiscDirtyFlag: number;
  29183. /**
  29184. * The dirty prepass flag value
  29185. */
  29186. static readonly PrePassDirtyFlag: number;
  29187. /**
  29188. * The all dirty flag value
  29189. */
  29190. static readonly AllDirtyFlag: number;
  29191. /**
  29192. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  29193. */
  29194. static readonly MATERIAL_OPAQUE: number;
  29195. /**
  29196. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  29197. */
  29198. static readonly MATERIAL_ALPHATEST: number;
  29199. /**
  29200. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  29201. */
  29202. static readonly MATERIAL_ALPHABLEND: number;
  29203. /**
  29204. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  29205. * They are also discarded below the alpha cutoff threshold to improve performances.
  29206. */
  29207. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  29208. /**
  29209. * The Whiteout method is used to blend normals.
  29210. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  29211. */
  29212. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  29213. /**
  29214. * The Reoriented Normal Mapping method is used to blend normals.
  29215. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  29216. */
  29217. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  29218. /**
  29219. * Custom callback helping to override the default shader used in the material.
  29220. */
  29221. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  29222. /**
  29223. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  29224. */
  29225. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  29226. /**
  29227. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  29228. * This means that the material can keep using a previous shader while a new one is being compiled.
  29229. * This is mostly used when shader parallel compilation is supported (true by default)
  29230. */
  29231. allowShaderHotSwapping: boolean;
  29232. /**
  29233. * The ID of the material
  29234. */
  29235. id: string;
  29236. /**
  29237. * Gets or sets the unique id of the material
  29238. */
  29239. uniqueId: number;
  29240. /**
  29241. * The name of the material
  29242. */
  29243. name: string;
  29244. /**
  29245. * Gets or sets user defined metadata
  29246. */
  29247. metadata: any;
  29248. /**
  29249. * For internal use only. Please do not use.
  29250. */
  29251. reservedDataStore: any;
  29252. /**
  29253. * Specifies if the ready state should be checked on each call
  29254. */
  29255. checkReadyOnEveryCall: boolean;
  29256. /**
  29257. * Specifies if the ready state should be checked once
  29258. */
  29259. checkReadyOnlyOnce: boolean;
  29260. /**
  29261. * The state of the material
  29262. */
  29263. state: string;
  29264. /**
  29265. * If the material can be rendered to several textures with MRT extension
  29266. */
  29267. get canRenderToMRT(): boolean;
  29268. /**
  29269. * The alpha value of the material
  29270. */
  29271. protected _alpha: number;
  29272. /**
  29273. * List of inspectable custom properties (used by the Inspector)
  29274. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29275. */
  29276. inspectableCustomProperties: IInspectable[];
  29277. /**
  29278. * Sets the alpha value of the material
  29279. */
  29280. set alpha(value: number);
  29281. /**
  29282. * Gets the alpha value of the material
  29283. */
  29284. get alpha(): number;
  29285. /**
  29286. * Specifies if back face culling is enabled
  29287. */
  29288. protected _backFaceCulling: boolean;
  29289. /**
  29290. * Sets the back-face culling state
  29291. */
  29292. set backFaceCulling(value: boolean);
  29293. /**
  29294. * Gets the back-face culling state
  29295. */
  29296. get backFaceCulling(): boolean;
  29297. /**
  29298. * Stores the value for side orientation
  29299. */
  29300. sideOrientation: number;
  29301. /**
  29302. * Callback triggered when the material is compiled
  29303. */
  29304. onCompiled: Nullable<(effect: Effect) => void>;
  29305. /**
  29306. * Callback triggered when an error occurs
  29307. */
  29308. onError: Nullable<(effect: Effect, errors: string) => void>;
  29309. /**
  29310. * Callback triggered to get the render target textures
  29311. */
  29312. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  29313. /**
  29314. * Gets a boolean indicating that current material needs to register RTT
  29315. */
  29316. get hasRenderTargetTextures(): boolean;
  29317. /**
  29318. * Specifies if the material should be serialized
  29319. */
  29320. doNotSerialize: boolean;
  29321. /**
  29322. * @hidden
  29323. */
  29324. _storeEffectOnSubMeshes: boolean;
  29325. /**
  29326. * Stores the animations for the material
  29327. */
  29328. animations: Nullable<Array<Animation>>;
  29329. /**
  29330. * An event triggered when the material is disposed
  29331. */
  29332. onDisposeObservable: Observable<Material>;
  29333. /**
  29334. * An observer which watches for dispose events
  29335. */
  29336. private _onDisposeObserver;
  29337. private _onUnBindObservable;
  29338. /**
  29339. * Called during a dispose event
  29340. */
  29341. set onDispose(callback: () => void);
  29342. private _onBindObservable;
  29343. /**
  29344. * An event triggered when the material is bound
  29345. */
  29346. get onBindObservable(): Observable<AbstractMesh>;
  29347. /**
  29348. * An observer which watches for bind events
  29349. */
  29350. private _onBindObserver;
  29351. /**
  29352. * Called during a bind event
  29353. */
  29354. set onBind(callback: (Mesh: AbstractMesh) => void);
  29355. /**
  29356. * An event triggered when the material is unbound
  29357. */
  29358. get onUnBindObservable(): Observable<Material>;
  29359. protected _onEffectCreatedObservable: Nullable<Observable<{
  29360. effect: Effect;
  29361. subMesh: Nullable<SubMesh>;
  29362. }>>;
  29363. /**
  29364. * An event triggered when the effect is (re)created
  29365. */
  29366. get onEffectCreatedObservable(): Observable<{
  29367. effect: Effect;
  29368. subMesh: Nullable<SubMesh>;
  29369. }>;
  29370. /**
  29371. * Stores the value of the alpha mode
  29372. */
  29373. private _alphaMode;
  29374. /**
  29375. * Sets the value of the alpha mode.
  29376. *
  29377. * | Value | Type | Description |
  29378. * | --- | --- | --- |
  29379. * | 0 | ALPHA_DISABLE | |
  29380. * | 1 | ALPHA_ADD | |
  29381. * | 2 | ALPHA_COMBINE | |
  29382. * | 3 | ALPHA_SUBTRACT | |
  29383. * | 4 | ALPHA_MULTIPLY | |
  29384. * | 5 | ALPHA_MAXIMIZED | |
  29385. * | 6 | ALPHA_ONEONE | |
  29386. * | 7 | ALPHA_PREMULTIPLIED | |
  29387. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  29388. * | 9 | ALPHA_INTERPOLATE | |
  29389. * | 10 | ALPHA_SCREENMODE | |
  29390. *
  29391. */
  29392. set alphaMode(value: number);
  29393. /**
  29394. * Gets the value of the alpha mode
  29395. */
  29396. get alphaMode(): number;
  29397. /**
  29398. * Stores the state of the need depth pre-pass value
  29399. */
  29400. private _needDepthPrePass;
  29401. /**
  29402. * Sets the need depth pre-pass value
  29403. */
  29404. set needDepthPrePass(value: boolean);
  29405. /**
  29406. * Gets the depth pre-pass value
  29407. */
  29408. get needDepthPrePass(): boolean;
  29409. /**
  29410. * Specifies if depth writing should be disabled
  29411. */
  29412. disableDepthWrite: boolean;
  29413. /**
  29414. * Specifies if color writing should be disabled
  29415. */
  29416. disableColorWrite: boolean;
  29417. /**
  29418. * Specifies if depth writing should be forced
  29419. */
  29420. forceDepthWrite: boolean;
  29421. /**
  29422. * Specifies the depth function that should be used. 0 means the default engine function
  29423. */
  29424. depthFunction: number;
  29425. /**
  29426. * Specifies if there should be a separate pass for culling
  29427. */
  29428. separateCullingPass: boolean;
  29429. /**
  29430. * Stores the state specifing if fog should be enabled
  29431. */
  29432. private _fogEnabled;
  29433. /**
  29434. * Sets the state for enabling fog
  29435. */
  29436. set fogEnabled(value: boolean);
  29437. /**
  29438. * Gets the value of the fog enabled state
  29439. */
  29440. get fogEnabled(): boolean;
  29441. /**
  29442. * Stores the size of points
  29443. */
  29444. pointSize: number;
  29445. /**
  29446. * Stores the z offset value
  29447. */
  29448. zOffset: number;
  29449. get wireframe(): boolean;
  29450. /**
  29451. * Sets the state of wireframe mode
  29452. */
  29453. set wireframe(value: boolean);
  29454. /**
  29455. * Gets the value specifying if point clouds are enabled
  29456. */
  29457. get pointsCloud(): boolean;
  29458. /**
  29459. * Sets the state of point cloud mode
  29460. */
  29461. set pointsCloud(value: boolean);
  29462. /**
  29463. * Gets the material fill mode
  29464. */
  29465. get fillMode(): number;
  29466. /**
  29467. * Sets the material fill mode
  29468. */
  29469. set fillMode(value: number);
  29470. /**
  29471. * @hidden
  29472. * Stores the effects for the material
  29473. */
  29474. _effect: Nullable<Effect>;
  29475. /**
  29476. * Specifies if uniform buffers should be used
  29477. */
  29478. private _useUBO;
  29479. /**
  29480. * Stores a reference to the scene
  29481. */
  29482. private _scene;
  29483. /**
  29484. * Stores the fill mode state
  29485. */
  29486. private _fillMode;
  29487. /**
  29488. * Specifies if the depth write state should be cached
  29489. */
  29490. private _cachedDepthWriteState;
  29491. /**
  29492. * Specifies if the color write state should be cached
  29493. */
  29494. private _cachedColorWriteState;
  29495. /**
  29496. * Specifies if the depth function state should be cached
  29497. */
  29498. private _cachedDepthFunctionState;
  29499. /**
  29500. * Stores the uniform buffer
  29501. */
  29502. protected _uniformBuffer: UniformBuffer;
  29503. /** @hidden */
  29504. _indexInSceneMaterialArray: number;
  29505. /** @hidden */
  29506. meshMap: Nullable<{
  29507. [id: string]: AbstractMesh | undefined;
  29508. }>;
  29509. /**
  29510. * Creates a material instance
  29511. * @param name defines the name of the material
  29512. * @param scene defines the scene to reference
  29513. * @param doNotAdd specifies if the material should be added to the scene
  29514. */
  29515. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  29516. /**
  29517. * Returns a string representation of the current material
  29518. * @param fullDetails defines a boolean indicating which levels of logging is desired
  29519. * @returns a string with material information
  29520. */
  29521. toString(fullDetails?: boolean): string;
  29522. /**
  29523. * Gets the class name of the material
  29524. * @returns a string with the class name of the material
  29525. */
  29526. getClassName(): string;
  29527. /**
  29528. * Specifies if updates for the material been locked
  29529. */
  29530. get isFrozen(): boolean;
  29531. /**
  29532. * Locks updates for the material
  29533. */
  29534. freeze(): void;
  29535. /**
  29536. * Unlocks updates for the material
  29537. */
  29538. unfreeze(): void;
  29539. /**
  29540. * Specifies if the material is ready to be used
  29541. * @param mesh defines the mesh to check
  29542. * @param useInstances specifies if instances should be used
  29543. * @returns a boolean indicating if the material is ready to be used
  29544. */
  29545. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  29546. /**
  29547. * Specifies that the submesh is ready to be used
  29548. * @param mesh defines the mesh to check
  29549. * @param subMesh defines which submesh to check
  29550. * @param useInstances specifies that instances should be used
  29551. * @returns a boolean indicating that the submesh is ready or not
  29552. */
  29553. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29554. /**
  29555. * Returns the material effect
  29556. * @returns the effect associated with the material
  29557. */
  29558. getEffect(): Nullable<Effect>;
  29559. /**
  29560. * Returns the current scene
  29561. * @returns a Scene
  29562. */
  29563. getScene(): Scene;
  29564. /**
  29565. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  29566. */
  29567. protected _forceAlphaTest: boolean;
  29568. /**
  29569. * The transparency mode of the material.
  29570. */
  29571. protected _transparencyMode: Nullable<number>;
  29572. /**
  29573. * Gets the current transparency mode.
  29574. */
  29575. get transparencyMode(): Nullable<number>;
  29576. /**
  29577. * Sets the transparency mode of the material.
  29578. *
  29579. * | Value | Type | Description |
  29580. * | ----- | ----------------------------------- | ----------- |
  29581. * | 0 | OPAQUE | |
  29582. * | 1 | ALPHATEST | |
  29583. * | 2 | ALPHABLEND | |
  29584. * | 3 | ALPHATESTANDBLEND | |
  29585. *
  29586. */
  29587. set transparencyMode(value: Nullable<number>);
  29588. /**
  29589. * Returns true if alpha blending should be disabled.
  29590. */
  29591. protected get _disableAlphaBlending(): boolean;
  29592. /**
  29593. * Specifies whether or not this material should be rendered in alpha blend mode.
  29594. * @returns a boolean specifying if alpha blending is needed
  29595. */
  29596. needAlphaBlending(): boolean;
  29597. /**
  29598. * Specifies if the mesh will require alpha blending
  29599. * @param mesh defines the mesh to check
  29600. * @returns a boolean specifying if alpha blending is needed for the mesh
  29601. */
  29602. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  29603. /**
  29604. * Specifies whether or not this material should be rendered in alpha test mode.
  29605. * @returns a boolean specifying if an alpha test is needed.
  29606. */
  29607. needAlphaTesting(): boolean;
  29608. /**
  29609. * Specifies if material alpha testing should be turned on for the mesh
  29610. * @param mesh defines the mesh to check
  29611. */
  29612. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  29613. /**
  29614. * Gets the texture used for the alpha test
  29615. * @returns the texture to use for alpha testing
  29616. */
  29617. getAlphaTestTexture(): Nullable<BaseTexture>;
  29618. /**
  29619. * Marks the material to indicate that it needs to be re-calculated
  29620. */
  29621. markDirty(): void;
  29622. /** @hidden */
  29623. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  29624. /**
  29625. * Binds the material to the mesh
  29626. * @param world defines the world transformation matrix
  29627. * @param mesh defines the mesh to bind the material to
  29628. */
  29629. bind(world: Matrix, mesh?: Mesh): void;
  29630. /**
  29631. * Binds the submesh to the material
  29632. * @param world defines the world transformation matrix
  29633. * @param mesh defines the mesh containing the submesh
  29634. * @param subMesh defines the submesh to bind the material to
  29635. */
  29636. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29637. /**
  29638. * Binds the world matrix to the material
  29639. * @param world defines the world transformation matrix
  29640. */
  29641. bindOnlyWorldMatrix(world: Matrix): void;
  29642. /**
  29643. * Binds the scene's uniform buffer to the effect.
  29644. * @param effect defines the effect to bind to the scene uniform buffer
  29645. * @param sceneUbo defines the uniform buffer storing scene data
  29646. */
  29647. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  29648. /**
  29649. * Binds the view matrix to the effect
  29650. * @param effect defines the effect to bind the view matrix to
  29651. */
  29652. bindView(effect: Effect): void;
  29653. /**
  29654. * Binds the view projection matrix to the effect
  29655. * @param effect defines the effect to bind the view projection matrix to
  29656. */
  29657. bindViewProjection(effect: Effect): void;
  29658. /**
  29659. * Processes to execute after binding the material to a mesh
  29660. * @param mesh defines the rendered mesh
  29661. */
  29662. protected _afterBind(mesh?: Mesh): void;
  29663. /**
  29664. * Unbinds the material from the mesh
  29665. */
  29666. unbind(): void;
  29667. /**
  29668. * Gets the active textures from the material
  29669. * @returns an array of textures
  29670. */
  29671. getActiveTextures(): BaseTexture[];
  29672. /**
  29673. * Specifies if the material uses a texture
  29674. * @param texture defines the texture to check against the material
  29675. * @returns a boolean specifying if the material uses the texture
  29676. */
  29677. hasTexture(texture: BaseTexture): boolean;
  29678. /**
  29679. * Makes a duplicate of the material, and gives it a new name
  29680. * @param name defines the new name for the duplicated material
  29681. * @returns the cloned material
  29682. */
  29683. clone(name: string): Nullable<Material>;
  29684. /**
  29685. * Gets the meshes bound to the material
  29686. * @returns an array of meshes bound to the material
  29687. */
  29688. getBindedMeshes(): AbstractMesh[];
  29689. /**
  29690. * Force shader compilation
  29691. * @param mesh defines the mesh associated with this material
  29692. * @param onCompiled defines a function to execute once the material is compiled
  29693. * @param options defines the options to configure the compilation
  29694. * @param onError defines a function to execute if the material fails compiling
  29695. */
  29696. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  29697. /**
  29698. * Force shader compilation
  29699. * @param mesh defines the mesh that will use this material
  29700. * @param options defines additional options for compiling the shaders
  29701. * @returns a promise that resolves when the compilation completes
  29702. */
  29703. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  29704. private static readonly _AllDirtyCallBack;
  29705. private static readonly _ImageProcessingDirtyCallBack;
  29706. private static readonly _TextureDirtyCallBack;
  29707. private static readonly _FresnelDirtyCallBack;
  29708. private static readonly _MiscDirtyCallBack;
  29709. private static readonly _PrePassDirtyCallBack;
  29710. private static readonly _LightsDirtyCallBack;
  29711. private static readonly _AttributeDirtyCallBack;
  29712. private static _FresnelAndMiscDirtyCallBack;
  29713. private static _TextureAndMiscDirtyCallBack;
  29714. private static readonly _DirtyCallbackArray;
  29715. private static readonly _RunDirtyCallBacks;
  29716. /**
  29717. * Marks a define in the material to indicate that it needs to be re-computed
  29718. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  29719. */
  29720. markAsDirty(flag: number): void;
  29721. /**
  29722. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  29723. * @param func defines a function which checks material defines against the submeshes
  29724. */
  29725. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  29726. /**
  29727. * Indicates that the scene should check if the rendering now needs a prepass
  29728. */
  29729. protected _markScenePrePassDirty(): void;
  29730. /**
  29731. * Indicates that we need to re-calculated for all submeshes
  29732. */
  29733. protected _markAllSubMeshesAsAllDirty(): void;
  29734. /**
  29735. * Indicates that image processing needs to be re-calculated for all submeshes
  29736. */
  29737. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  29738. /**
  29739. * Indicates that textures need to be re-calculated for all submeshes
  29740. */
  29741. protected _markAllSubMeshesAsTexturesDirty(): void;
  29742. /**
  29743. * Indicates that fresnel needs to be re-calculated for all submeshes
  29744. */
  29745. protected _markAllSubMeshesAsFresnelDirty(): void;
  29746. /**
  29747. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  29748. */
  29749. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  29750. /**
  29751. * Indicates that lights need to be re-calculated for all submeshes
  29752. */
  29753. protected _markAllSubMeshesAsLightsDirty(): void;
  29754. /**
  29755. * Indicates that attributes need to be re-calculated for all submeshes
  29756. */
  29757. protected _markAllSubMeshesAsAttributesDirty(): void;
  29758. /**
  29759. * Indicates that misc needs to be re-calculated for all submeshes
  29760. */
  29761. protected _markAllSubMeshesAsMiscDirty(): void;
  29762. /**
  29763. * Indicates that prepass needs to be re-calculated for all submeshes
  29764. */
  29765. protected _markAllSubMeshesAsPrePassDirty(): void;
  29766. /**
  29767. * Indicates that textures and misc need to be re-calculated for all submeshes
  29768. */
  29769. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  29770. /**
  29771. * Sets the required values to the prepass renderer.
  29772. * @param prePassRenderer defines the prepass renderer to setup.
  29773. * @returns true if the pre pass is needed.
  29774. */
  29775. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  29776. /**
  29777. * Disposes the material
  29778. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29779. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29780. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  29781. */
  29782. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  29783. /** @hidden */
  29784. private releaseVertexArrayObject;
  29785. /**
  29786. * Serializes this material
  29787. * @returns the serialized material object
  29788. */
  29789. serialize(): any;
  29790. /**
  29791. * Creates a material from parsed material data
  29792. * @param parsedMaterial defines parsed material data
  29793. * @param scene defines the hosting scene
  29794. * @param rootUrl defines the root URL to use to load textures
  29795. * @returns a new material
  29796. */
  29797. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  29798. }
  29799. }
  29800. declare module BABYLON {
  29801. /**
  29802. * A multi-material is used to apply different materials to different parts of the same object without the need of
  29803. * separate meshes. This can be use to improve performances.
  29804. * @see https://doc.babylonjs.com/how_to/multi_materials
  29805. */
  29806. export class MultiMaterial extends Material {
  29807. private _subMaterials;
  29808. /**
  29809. * Gets or Sets the list of Materials used within the multi material.
  29810. * They need to be ordered according to the submeshes order in the associated mesh
  29811. */
  29812. get subMaterials(): Nullable<Material>[];
  29813. set subMaterials(value: Nullable<Material>[]);
  29814. /**
  29815. * Function used to align with Node.getChildren()
  29816. * @returns the list of Materials used within the multi material
  29817. */
  29818. getChildren(): Nullable<Material>[];
  29819. /**
  29820. * Instantiates a new Multi Material
  29821. * A multi-material is used to apply different materials to different parts of the same object without the need of
  29822. * separate meshes. This can be use to improve performances.
  29823. * @see https://doc.babylonjs.com/how_to/multi_materials
  29824. * @param name Define the name in the scene
  29825. * @param scene Define the scene the material belongs to
  29826. */
  29827. constructor(name: string, scene: Scene);
  29828. private _hookArray;
  29829. /**
  29830. * Get one of the submaterial by its index in the submaterials array
  29831. * @param index The index to look the sub material at
  29832. * @returns The Material if the index has been defined
  29833. */
  29834. getSubMaterial(index: number): Nullable<Material>;
  29835. /**
  29836. * Get the list of active textures for the whole sub materials list.
  29837. * @returns All the textures that will be used during the rendering
  29838. */
  29839. getActiveTextures(): BaseTexture[];
  29840. /**
  29841. * Gets the current class name of the material e.g. "MultiMaterial"
  29842. * Mainly use in serialization.
  29843. * @returns the class name
  29844. */
  29845. getClassName(): string;
  29846. /**
  29847. * Checks if the material is ready to render the requested sub mesh
  29848. * @param mesh Define the mesh the submesh belongs to
  29849. * @param subMesh Define the sub mesh to look readyness for
  29850. * @param useInstances Define whether or not the material is used with instances
  29851. * @returns true if ready, otherwise false
  29852. */
  29853. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29854. /**
  29855. * Clones the current material and its related sub materials
  29856. * @param name Define the name of the newly cloned material
  29857. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  29858. * @returns the cloned material
  29859. */
  29860. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  29861. /**
  29862. * Serializes the materials into a JSON representation.
  29863. * @returns the JSON representation
  29864. */
  29865. serialize(): any;
  29866. /**
  29867. * Dispose the material and release its associated resources
  29868. * @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)
  29869. * @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)
  29870. * @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)
  29871. */
  29872. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  29873. /**
  29874. * Creates a MultiMaterial from parsed MultiMaterial data.
  29875. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  29876. * @param scene defines the hosting scene
  29877. * @returns a new MultiMaterial
  29878. */
  29879. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  29880. }
  29881. }
  29882. declare module BABYLON {
  29883. /**
  29884. * Defines a subdivision inside a mesh
  29885. */
  29886. export class SubMesh implements ICullable {
  29887. /** the material index to use */
  29888. materialIndex: number;
  29889. /** vertex index start */
  29890. verticesStart: number;
  29891. /** vertices count */
  29892. verticesCount: number;
  29893. /** index start */
  29894. indexStart: number;
  29895. /** indices count */
  29896. indexCount: number;
  29897. /** @hidden */
  29898. _materialDefines: Nullable<MaterialDefines>;
  29899. /** @hidden */
  29900. _materialEffect: Nullable<Effect>;
  29901. /** @hidden */
  29902. _effectOverride: Nullable<Effect>;
  29903. /**
  29904. * Gets material defines used by the effect associated to the sub mesh
  29905. */
  29906. get materialDefines(): Nullable<MaterialDefines>;
  29907. /**
  29908. * Sets material defines used by the effect associated to the sub mesh
  29909. */
  29910. set materialDefines(defines: Nullable<MaterialDefines>);
  29911. /**
  29912. * Gets associated effect
  29913. */
  29914. get effect(): Nullable<Effect>;
  29915. /**
  29916. * Sets associated effect (effect used to render this submesh)
  29917. * @param effect defines the effect to associate with
  29918. * @param defines defines the set of defines used to compile this effect
  29919. */
  29920. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  29921. /** @hidden */
  29922. _linesIndexCount: number;
  29923. private _mesh;
  29924. private _renderingMesh;
  29925. private _boundingInfo;
  29926. private _linesIndexBuffer;
  29927. /** @hidden */
  29928. _lastColliderWorldVertices: Nullable<Vector3[]>;
  29929. /** @hidden */
  29930. _trianglePlanes: Plane[];
  29931. /** @hidden */
  29932. _lastColliderTransformMatrix: Nullable<Matrix>;
  29933. /** @hidden */
  29934. _renderId: number;
  29935. /** @hidden */
  29936. _alphaIndex: number;
  29937. /** @hidden */
  29938. _distanceToCamera: number;
  29939. /** @hidden */
  29940. _id: number;
  29941. private _currentMaterial;
  29942. /**
  29943. * Add a new submesh to a mesh
  29944. * @param materialIndex defines the material index to use
  29945. * @param verticesStart defines vertex index start
  29946. * @param verticesCount defines vertices count
  29947. * @param indexStart defines index start
  29948. * @param indexCount defines indices count
  29949. * @param mesh defines the parent mesh
  29950. * @param renderingMesh defines an optional rendering mesh
  29951. * @param createBoundingBox defines if bounding box should be created for this submesh
  29952. * @returns the new submesh
  29953. */
  29954. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  29955. /**
  29956. * Creates a new submesh
  29957. * @param materialIndex defines the material index to use
  29958. * @param verticesStart defines vertex index start
  29959. * @param verticesCount defines vertices count
  29960. * @param indexStart defines index start
  29961. * @param indexCount defines indices count
  29962. * @param mesh defines the parent mesh
  29963. * @param renderingMesh defines an optional rendering mesh
  29964. * @param createBoundingBox defines if bounding box should be created for this submesh
  29965. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  29966. */
  29967. constructor(
  29968. /** the material index to use */
  29969. materialIndex: number,
  29970. /** vertex index start */
  29971. verticesStart: number,
  29972. /** vertices count */
  29973. verticesCount: number,
  29974. /** index start */
  29975. indexStart: number,
  29976. /** indices count */
  29977. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  29978. /**
  29979. * Returns true if this submesh covers the entire parent mesh
  29980. * @ignorenaming
  29981. */
  29982. get IsGlobal(): boolean;
  29983. /**
  29984. * Returns the submesh BoudingInfo object
  29985. * @returns current bounding info (or mesh's one if the submesh is global)
  29986. */
  29987. getBoundingInfo(): BoundingInfo;
  29988. /**
  29989. * Sets the submesh BoundingInfo
  29990. * @param boundingInfo defines the new bounding info to use
  29991. * @returns the SubMesh
  29992. */
  29993. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  29994. /**
  29995. * Returns the mesh of the current submesh
  29996. * @return the parent mesh
  29997. */
  29998. getMesh(): AbstractMesh;
  29999. /**
  30000. * Returns the rendering mesh of the submesh
  30001. * @returns the rendering mesh (could be different from parent mesh)
  30002. */
  30003. getRenderingMesh(): Mesh;
  30004. /**
  30005. * Returns the replacement mesh of the submesh
  30006. * @returns the replacement mesh (could be different from parent mesh)
  30007. */
  30008. getReplacementMesh(): Nullable<AbstractMesh>;
  30009. /**
  30010. * Returns the effective mesh of the submesh
  30011. * @returns the effective mesh (could be different from parent mesh)
  30012. */
  30013. getEffectiveMesh(): AbstractMesh;
  30014. /**
  30015. * Returns the submesh material
  30016. * @returns null or the current material
  30017. */
  30018. getMaterial(): Nullable<Material>;
  30019. private _IsMultiMaterial;
  30020. /**
  30021. * Sets a new updated BoundingInfo object to the submesh
  30022. * @param data defines an optional position array to use to determine the bounding info
  30023. * @returns the SubMesh
  30024. */
  30025. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  30026. /** @hidden */
  30027. _checkCollision(collider: Collider): boolean;
  30028. /**
  30029. * Updates the submesh BoundingInfo
  30030. * @param world defines the world matrix to use to update the bounding info
  30031. * @returns the submesh
  30032. */
  30033. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  30034. /**
  30035. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  30036. * @param frustumPlanes defines the frustum planes
  30037. * @returns true if the submesh is intersecting with the frustum
  30038. */
  30039. isInFrustum(frustumPlanes: Plane[]): boolean;
  30040. /**
  30041. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  30042. * @param frustumPlanes defines the frustum planes
  30043. * @returns true if the submesh is inside the frustum
  30044. */
  30045. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  30046. /**
  30047. * Renders the submesh
  30048. * @param enableAlphaMode defines if alpha needs to be used
  30049. * @returns the submesh
  30050. */
  30051. render(enableAlphaMode: boolean): SubMesh;
  30052. /**
  30053. * @hidden
  30054. */
  30055. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  30056. /**
  30057. * Checks if the submesh intersects with a ray
  30058. * @param ray defines the ray to test
  30059. * @returns true is the passed ray intersects the submesh bounding box
  30060. */
  30061. canIntersects(ray: Ray): boolean;
  30062. /**
  30063. * Intersects current submesh with a ray
  30064. * @param ray defines the ray to test
  30065. * @param positions defines mesh's positions array
  30066. * @param indices defines mesh's indices array
  30067. * @param fastCheck defines if the first intersection will be used (and not the closest)
  30068. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  30069. * @returns intersection info or null if no intersection
  30070. */
  30071. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  30072. /** @hidden */
  30073. private _intersectLines;
  30074. /** @hidden */
  30075. private _intersectUnIndexedLines;
  30076. /** @hidden */
  30077. private _intersectTriangles;
  30078. /** @hidden */
  30079. private _intersectUnIndexedTriangles;
  30080. /** @hidden */
  30081. _rebuild(): void;
  30082. /**
  30083. * Creates a new submesh from the passed mesh
  30084. * @param newMesh defines the new hosting mesh
  30085. * @param newRenderingMesh defines an optional rendering mesh
  30086. * @returns the new submesh
  30087. */
  30088. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  30089. /**
  30090. * Release associated resources
  30091. */
  30092. dispose(): void;
  30093. /**
  30094. * Gets the class name
  30095. * @returns the string "SubMesh".
  30096. */
  30097. getClassName(): string;
  30098. /**
  30099. * Creates a new submesh from indices data
  30100. * @param materialIndex the index of the main mesh material
  30101. * @param startIndex the index where to start the copy in the mesh indices array
  30102. * @param indexCount the number of indices to copy then from the startIndex
  30103. * @param mesh the main mesh to create the submesh from
  30104. * @param renderingMesh the optional rendering mesh
  30105. * @returns a new submesh
  30106. */
  30107. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  30108. }
  30109. }
  30110. declare module BABYLON {
  30111. /**
  30112. * Class used to represent data loading progression
  30113. */
  30114. export class SceneLoaderFlags {
  30115. private static _ForceFullSceneLoadingForIncremental;
  30116. private static _ShowLoadingScreen;
  30117. private static _CleanBoneMatrixWeights;
  30118. private static _loggingLevel;
  30119. /**
  30120. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  30121. */
  30122. static get ForceFullSceneLoadingForIncremental(): boolean;
  30123. static set ForceFullSceneLoadingForIncremental(value: boolean);
  30124. /**
  30125. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  30126. */
  30127. static get ShowLoadingScreen(): boolean;
  30128. static set ShowLoadingScreen(value: boolean);
  30129. /**
  30130. * Defines the current logging level (while loading the scene)
  30131. * @ignorenaming
  30132. */
  30133. static get loggingLevel(): number;
  30134. static set loggingLevel(value: number);
  30135. /**
  30136. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  30137. */
  30138. static get CleanBoneMatrixWeights(): boolean;
  30139. static set CleanBoneMatrixWeights(value: boolean);
  30140. }
  30141. }
  30142. declare module BABYLON {
  30143. /**
  30144. * Class used to store geometry data (vertex buffers + index buffer)
  30145. */
  30146. export class Geometry implements IGetSetVerticesData {
  30147. /**
  30148. * Gets or sets the ID of the geometry
  30149. */
  30150. id: string;
  30151. /**
  30152. * Gets or sets the unique ID of the geometry
  30153. */
  30154. uniqueId: number;
  30155. /**
  30156. * Gets the delay loading state of the geometry (none by default which means not delayed)
  30157. */
  30158. delayLoadState: number;
  30159. /**
  30160. * Gets the file containing the data to load when running in delay load state
  30161. */
  30162. delayLoadingFile: Nullable<string>;
  30163. /**
  30164. * Callback called when the geometry is updated
  30165. */
  30166. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  30167. private _scene;
  30168. private _engine;
  30169. private _meshes;
  30170. private _totalVertices;
  30171. /** @hidden */
  30172. _indices: IndicesArray;
  30173. /** @hidden */
  30174. _vertexBuffers: {
  30175. [key: string]: VertexBuffer;
  30176. };
  30177. private _isDisposed;
  30178. private _extend;
  30179. private _boundingBias;
  30180. /** @hidden */
  30181. _delayInfo: Array<string>;
  30182. private _indexBuffer;
  30183. private _indexBufferIsUpdatable;
  30184. /** @hidden */
  30185. _boundingInfo: Nullable<BoundingInfo>;
  30186. /** @hidden */
  30187. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  30188. /** @hidden */
  30189. _softwareSkinningFrameId: number;
  30190. private _vertexArrayObjects;
  30191. private _updatable;
  30192. /** @hidden */
  30193. _positions: Nullable<Vector3[]>;
  30194. private _positionsCache;
  30195. /**
  30196. * 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
  30197. */
  30198. get boundingBias(): Vector2;
  30199. /**
  30200. * 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
  30201. */
  30202. set boundingBias(value: Vector2);
  30203. /**
  30204. * Static function used to attach a new empty geometry to a mesh
  30205. * @param mesh defines the mesh to attach the geometry to
  30206. * @returns the new Geometry
  30207. */
  30208. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  30209. /** Get the list of meshes using this geometry */
  30210. get meshes(): Mesh[];
  30211. /**
  30212. * 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
  30213. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  30214. */
  30215. useBoundingInfoFromGeometry: boolean;
  30216. /**
  30217. * Creates a new geometry
  30218. * @param id defines the unique ID
  30219. * @param scene defines the hosting scene
  30220. * @param vertexData defines the VertexData used to get geometry data
  30221. * @param updatable defines if geometry must be updatable (false by default)
  30222. * @param mesh defines the mesh that will be associated with the geometry
  30223. */
  30224. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  30225. /**
  30226. * Gets the current extend of the geometry
  30227. */
  30228. get extend(): {
  30229. minimum: Vector3;
  30230. maximum: Vector3;
  30231. };
  30232. /**
  30233. * Gets the hosting scene
  30234. * @returns the hosting Scene
  30235. */
  30236. getScene(): Scene;
  30237. /**
  30238. * Gets the hosting engine
  30239. * @returns the hosting Engine
  30240. */
  30241. getEngine(): Engine;
  30242. /**
  30243. * Defines if the geometry is ready to use
  30244. * @returns true if the geometry is ready to be used
  30245. */
  30246. isReady(): boolean;
  30247. /**
  30248. * Gets a value indicating that the geometry should not be serialized
  30249. */
  30250. get doNotSerialize(): boolean;
  30251. /** @hidden */
  30252. _rebuild(): void;
  30253. /**
  30254. * Affects all geometry data in one call
  30255. * @param vertexData defines the geometry data
  30256. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  30257. */
  30258. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  30259. /**
  30260. * Set specific vertex data
  30261. * @param kind defines the data kind (Position, normal, etc...)
  30262. * @param data defines the vertex data to use
  30263. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  30264. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  30265. */
  30266. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  30267. /**
  30268. * Removes a specific vertex data
  30269. * @param kind defines the data kind (Position, normal, etc...)
  30270. */
  30271. removeVerticesData(kind: string): void;
  30272. /**
  30273. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  30274. * @param buffer defines the vertex buffer to use
  30275. * @param totalVertices defines the total number of vertices for position kind (could be null)
  30276. */
  30277. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  30278. /**
  30279. * Update a specific vertex buffer
  30280. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  30281. * It will do nothing if the buffer is not updatable
  30282. * @param kind defines the data kind (Position, normal, etc...)
  30283. * @param data defines the data to use
  30284. * @param offset defines the offset in the target buffer where to store the data
  30285. * @param useBytes set to true if the offset is in bytes
  30286. */
  30287. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  30288. /**
  30289. * Update a specific vertex buffer
  30290. * This function will create a new buffer if the current one is not updatable
  30291. * @param kind defines the data kind (Position, normal, etc...)
  30292. * @param data defines the data to use
  30293. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  30294. */
  30295. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  30296. private _updateBoundingInfo;
  30297. /** @hidden */
  30298. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  30299. /**
  30300. * Gets total number of vertices
  30301. * @returns the total number of vertices
  30302. */
  30303. getTotalVertices(): number;
  30304. /**
  30305. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  30306. * @param kind defines the data kind (Position, normal, etc...)
  30307. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30308. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30309. * @returns a float array containing vertex data
  30310. */
  30311. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  30312. /**
  30313. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  30314. * @param kind defines the data kind (Position, normal, etc...)
  30315. * @returns true if the vertex buffer with the specified kind is updatable
  30316. */
  30317. isVertexBufferUpdatable(kind: string): boolean;
  30318. /**
  30319. * Gets a specific vertex buffer
  30320. * @param kind defines the data kind (Position, normal, etc...)
  30321. * @returns a VertexBuffer
  30322. */
  30323. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  30324. /**
  30325. * Returns all vertex buffers
  30326. * @return an object holding all vertex buffers indexed by kind
  30327. */
  30328. getVertexBuffers(): Nullable<{
  30329. [key: string]: VertexBuffer;
  30330. }>;
  30331. /**
  30332. * Gets a boolean indicating if specific vertex buffer is present
  30333. * @param kind defines the data kind (Position, normal, etc...)
  30334. * @returns true if data is present
  30335. */
  30336. isVerticesDataPresent(kind: string): boolean;
  30337. /**
  30338. * Gets a list of all attached data kinds (Position, normal, etc...)
  30339. * @returns a list of string containing all kinds
  30340. */
  30341. getVerticesDataKinds(): string[];
  30342. /**
  30343. * Update index buffer
  30344. * @param indices defines the indices to store in the index buffer
  30345. * @param offset defines the offset in the target buffer where to store the data
  30346. * @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)
  30347. */
  30348. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  30349. /**
  30350. * Creates a new index buffer
  30351. * @param indices defines the indices to store in the index buffer
  30352. * @param totalVertices defines the total number of vertices (could be null)
  30353. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  30354. */
  30355. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  30356. /**
  30357. * Return the total number of indices
  30358. * @returns the total number of indices
  30359. */
  30360. getTotalIndices(): number;
  30361. /**
  30362. * Gets the index buffer array
  30363. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30364. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30365. * @returns the index buffer array
  30366. */
  30367. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  30368. /**
  30369. * Gets the index buffer
  30370. * @return the index buffer
  30371. */
  30372. getIndexBuffer(): Nullable<DataBuffer>;
  30373. /** @hidden */
  30374. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  30375. /**
  30376. * Release the associated resources for a specific mesh
  30377. * @param mesh defines the source mesh
  30378. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  30379. */
  30380. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  30381. /**
  30382. * Apply current geometry to a given mesh
  30383. * @param mesh defines the mesh to apply geometry to
  30384. */
  30385. applyToMesh(mesh: Mesh): void;
  30386. private _updateExtend;
  30387. private _applyToMesh;
  30388. private notifyUpdate;
  30389. /**
  30390. * Load the geometry if it was flagged as delay loaded
  30391. * @param scene defines the hosting scene
  30392. * @param onLoaded defines a callback called when the geometry is loaded
  30393. */
  30394. load(scene: Scene, onLoaded?: () => void): void;
  30395. private _queueLoad;
  30396. /**
  30397. * Invert the geometry to move from a right handed system to a left handed one.
  30398. */
  30399. toLeftHanded(): void;
  30400. /** @hidden */
  30401. _resetPointsArrayCache(): void;
  30402. /** @hidden */
  30403. _generatePointsArray(): boolean;
  30404. /**
  30405. * Gets a value indicating if the geometry is disposed
  30406. * @returns true if the geometry was disposed
  30407. */
  30408. isDisposed(): boolean;
  30409. private _disposeVertexArrayObjects;
  30410. /**
  30411. * Free all associated resources
  30412. */
  30413. dispose(): void;
  30414. /**
  30415. * Clone the current geometry into a new geometry
  30416. * @param id defines the unique ID of the new geometry
  30417. * @returns a new geometry object
  30418. */
  30419. copy(id: string): Geometry;
  30420. /**
  30421. * Serialize the current geometry info (and not the vertices data) into a JSON object
  30422. * @return a JSON representation of the current geometry data (without the vertices data)
  30423. */
  30424. serialize(): any;
  30425. private toNumberArray;
  30426. /**
  30427. * Serialize all vertices data into a JSON oject
  30428. * @returns a JSON representation of the current geometry data
  30429. */
  30430. serializeVerticeData(): any;
  30431. /**
  30432. * Extracts a clone of a mesh geometry
  30433. * @param mesh defines the source mesh
  30434. * @param id defines the unique ID of the new geometry object
  30435. * @returns the new geometry object
  30436. */
  30437. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  30438. /**
  30439. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  30440. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30441. * Be aware Math.random() could cause collisions, but:
  30442. * "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"
  30443. * @returns a string containing a new GUID
  30444. */
  30445. static RandomId(): string;
  30446. /** @hidden */
  30447. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  30448. private static _CleanMatricesWeights;
  30449. /**
  30450. * Create a new geometry from persisted data (Using .babylon file format)
  30451. * @param parsedVertexData defines the persisted data
  30452. * @param scene defines the hosting scene
  30453. * @param rootUrl defines the root url to use to load assets (like delayed data)
  30454. * @returns the new geometry object
  30455. */
  30456. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  30457. }
  30458. }
  30459. declare module BABYLON {
  30460. /**
  30461. * Define an interface for all classes that will get and set the data on vertices
  30462. */
  30463. export interface IGetSetVerticesData {
  30464. /**
  30465. * Gets a boolean indicating if specific vertex data is present
  30466. * @param kind defines the vertex data kind to use
  30467. * @returns true is data kind is present
  30468. */
  30469. isVerticesDataPresent(kind: string): boolean;
  30470. /**
  30471. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  30472. * @param kind defines the data kind (Position, normal, etc...)
  30473. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30474. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30475. * @returns a float array containing vertex data
  30476. */
  30477. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  30478. /**
  30479. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  30480. * @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.
  30481. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30482. * @returns the indices array or an empty array if the mesh has no geometry
  30483. */
  30484. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  30485. /**
  30486. * Set specific vertex data
  30487. * @param kind defines the data kind (Position, normal, etc...)
  30488. * @param data defines the vertex data to use
  30489. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  30490. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  30491. */
  30492. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  30493. /**
  30494. * Update a specific associated vertex buffer
  30495. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  30496. * - VertexBuffer.PositionKind
  30497. * - VertexBuffer.UVKind
  30498. * - VertexBuffer.UV2Kind
  30499. * - VertexBuffer.UV3Kind
  30500. * - VertexBuffer.UV4Kind
  30501. * - VertexBuffer.UV5Kind
  30502. * - VertexBuffer.UV6Kind
  30503. * - VertexBuffer.ColorKind
  30504. * - VertexBuffer.MatricesIndicesKind
  30505. * - VertexBuffer.MatricesIndicesExtraKind
  30506. * - VertexBuffer.MatricesWeightsKind
  30507. * - VertexBuffer.MatricesWeightsExtraKind
  30508. * @param data defines the data source
  30509. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  30510. * @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)
  30511. */
  30512. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  30513. /**
  30514. * Creates a new index buffer
  30515. * @param indices defines the indices to store in the index buffer
  30516. * @param totalVertices defines the total number of vertices (could be null)
  30517. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  30518. */
  30519. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  30520. }
  30521. /**
  30522. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  30523. */
  30524. export class VertexData {
  30525. /**
  30526. * Mesh side orientation : usually the external or front surface
  30527. */
  30528. static readonly FRONTSIDE: number;
  30529. /**
  30530. * Mesh side orientation : usually the internal or back surface
  30531. */
  30532. static readonly BACKSIDE: number;
  30533. /**
  30534. * Mesh side orientation : both internal and external or front and back surfaces
  30535. */
  30536. static readonly DOUBLESIDE: number;
  30537. /**
  30538. * Mesh side orientation : by default, `FRONTSIDE`
  30539. */
  30540. static readonly DEFAULTSIDE: number;
  30541. /**
  30542. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  30543. */
  30544. positions: Nullable<FloatArray>;
  30545. /**
  30546. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  30547. */
  30548. normals: Nullable<FloatArray>;
  30549. /**
  30550. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  30551. */
  30552. tangents: Nullable<FloatArray>;
  30553. /**
  30554. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30555. */
  30556. uvs: Nullable<FloatArray>;
  30557. /**
  30558. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30559. */
  30560. uvs2: Nullable<FloatArray>;
  30561. /**
  30562. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30563. */
  30564. uvs3: Nullable<FloatArray>;
  30565. /**
  30566. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30567. */
  30568. uvs4: Nullable<FloatArray>;
  30569. /**
  30570. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30571. */
  30572. uvs5: Nullable<FloatArray>;
  30573. /**
  30574. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30575. */
  30576. uvs6: Nullable<FloatArray>;
  30577. /**
  30578. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  30579. */
  30580. colors: Nullable<FloatArray>;
  30581. /**
  30582. * 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).
  30583. */
  30584. matricesIndices: Nullable<FloatArray>;
  30585. /**
  30586. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  30587. */
  30588. matricesWeights: Nullable<FloatArray>;
  30589. /**
  30590. * An array extending the number of possible indices
  30591. */
  30592. matricesIndicesExtra: Nullable<FloatArray>;
  30593. /**
  30594. * An array extending the number of possible weights when the number of indices is extended
  30595. */
  30596. matricesWeightsExtra: Nullable<FloatArray>;
  30597. /**
  30598. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  30599. */
  30600. indices: Nullable<IndicesArray>;
  30601. /**
  30602. * Uses the passed data array to set the set the values for the specified kind of data
  30603. * @param data a linear array of floating numbers
  30604. * @param kind the type of data that is being set, eg positions, colors etc
  30605. */
  30606. set(data: FloatArray, kind: string): void;
  30607. /**
  30608. * Associates the vertexData to the passed Mesh.
  30609. * Sets it as updatable or not (default `false`)
  30610. * @param mesh the mesh the vertexData is applied to
  30611. * @param updatable when used and having the value true allows new data to update the vertexData
  30612. * @returns the VertexData
  30613. */
  30614. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  30615. /**
  30616. * Associates the vertexData to the passed Geometry.
  30617. * Sets it as updatable or not (default `false`)
  30618. * @param geometry the geometry the vertexData is applied to
  30619. * @param updatable when used and having the value true allows new data to update the vertexData
  30620. * @returns VertexData
  30621. */
  30622. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  30623. /**
  30624. * Updates the associated mesh
  30625. * @param mesh the mesh to be updated
  30626. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  30627. * @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
  30628. * @returns VertexData
  30629. */
  30630. updateMesh(mesh: Mesh): VertexData;
  30631. /**
  30632. * Updates the associated geometry
  30633. * @param geometry the geometry to be updated
  30634. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  30635. * @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
  30636. * @returns VertexData.
  30637. */
  30638. updateGeometry(geometry: Geometry): VertexData;
  30639. private _applyTo;
  30640. private _update;
  30641. /**
  30642. * Transforms each position and each normal of the vertexData according to the passed Matrix
  30643. * @param matrix the transforming matrix
  30644. * @returns the VertexData
  30645. */
  30646. transform(matrix: Matrix): VertexData;
  30647. /**
  30648. * Merges the passed VertexData into the current one
  30649. * @param other the VertexData to be merged into the current one
  30650. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  30651. * @returns the modified VertexData
  30652. */
  30653. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  30654. private _mergeElement;
  30655. private _validate;
  30656. /**
  30657. * Serializes the VertexData
  30658. * @returns a serialized object
  30659. */
  30660. serialize(): any;
  30661. /**
  30662. * Extracts the vertexData from a mesh
  30663. * @param mesh the mesh from which to extract the VertexData
  30664. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  30665. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  30666. * @returns the object VertexData associated to the passed mesh
  30667. */
  30668. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  30669. /**
  30670. * Extracts the vertexData from the geometry
  30671. * @param geometry the geometry from which to extract the VertexData
  30672. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  30673. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  30674. * @returns the object VertexData associated to the passed mesh
  30675. */
  30676. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  30677. private static _ExtractFrom;
  30678. /**
  30679. * Creates the VertexData for a Ribbon
  30680. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  30681. * * pathArray array of paths, each of which an array of successive Vector3
  30682. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  30683. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  30684. * * 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
  30685. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30686. * * 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)
  30687. * * 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)
  30688. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  30689. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  30690. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  30691. * @returns the VertexData of the ribbon
  30692. */
  30693. static CreateRibbon(options: {
  30694. pathArray: Vector3[][];
  30695. closeArray?: boolean;
  30696. closePath?: boolean;
  30697. offset?: number;
  30698. sideOrientation?: number;
  30699. frontUVs?: Vector4;
  30700. backUVs?: Vector4;
  30701. invertUV?: boolean;
  30702. uvs?: Vector2[];
  30703. colors?: Color4[];
  30704. }): VertexData;
  30705. /**
  30706. * Creates the VertexData for a box
  30707. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30708. * * size sets the width, height and depth of the box to the value of size, optional default 1
  30709. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  30710. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  30711. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  30712. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  30713. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  30714. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30715. * * 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)
  30716. * * 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)
  30717. * @returns the VertexData of the box
  30718. */
  30719. static CreateBox(options: {
  30720. size?: number;
  30721. width?: number;
  30722. height?: number;
  30723. depth?: number;
  30724. faceUV?: Vector4[];
  30725. faceColors?: Color4[];
  30726. sideOrientation?: number;
  30727. frontUVs?: Vector4;
  30728. backUVs?: Vector4;
  30729. }): VertexData;
  30730. /**
  30731. * Creates the VertexData for a tiled box
  30732. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30733. * * faceTiles sets the pattern, tile size and number of tiles for a face
  30734. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  30735. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  30736. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30737. * @returns the VertexData of the box
  30738. */
  30739. static CreateTiledBox(options: {
  30740. pattern?: number;
  30741. width?: number;
  30742. height?: number;
  30743. depth?: number;
  30744. tileSize?: number;
  30745. tileWidth?: number;
  30746. tileHeight?: number;
  30747. alignHorizontal?: number;
  30748. alignVertical?: number;
  30749. faceUV?: Vector4[];
  30750. faceColors?: Color4[];
  30751. sideOrientation?: number;
  30752. }): VertexData;
  30753. /**
  30754. * Creates the VertexData for a tiled plane
  30755. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30756. * * pattern a limited pattern arrangement depending on the number
  30757. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  30758. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  30759. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  30760. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30761. * * 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)
  30762. * * 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)
  30763. * @returns the VertexData of the tiled plane
  30764. */
  30765. static CreateTiledPlane(options: {
  30766. pattern?: number;
  30767. tileSize?: number;
  30768. tileWidth?: number;
  30769. tileHeight?: number;
  30770. size?: number;
  30771. width?: number;
  30772. height?: number;
  30773. alignHorizontal?: number;
  30774. alignVertical?: number;
  30775. sideOrientation?: number;
  30776. frontUVs?: Vector4;
  30777. backUVs?: Vector4;
  30778. }): VertexData;
  30779. /**
  30780. * Creates the VertexData for an ellipsoid, defaults to a sphere
  30781. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30782. * * segments sets the number of horizontal strips optional, default 32
  30783. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  30784. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  30785. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  30786. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  30787. * * 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
  30788. * * 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
  30789. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30790. * * 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)
  30791. * * 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)
  30792. * @returns the VertexData of the ellipsoid
  30793. */
  30794. static CreateSphere(options: {
  30795. segments?: number;
  30796. diameter?: number;
  30797. diameterX?: number;
  30798. diameterY?: number;
  30799. diameterZ?: number;
  30800. arc?: number;
  30801. slice?: number;
  30802. sideOrientation?: number;
  30803. frontUVs?: Vector4;
  30804. backUVs?: Vector4;
  30805. }): VertexData;
  30806. /**
  30807. * Creates the VertexData for a cylinder, cone or prism
  30808. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30809. * * height sets the height (y direction) of the cylinder, optional, default 2
  30810. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  30811. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  30812. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  30813. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  30814. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  30815. * * 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
  30816. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  30817. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  30818. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  30819. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  30820. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30821. * * 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)
  30822. * * 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)
  30823. * @returns the VertexData of the cylinder, cone or prism
  30824. */
  30825. static CreateCylinder(options: {
  30826. height?: number;
  30827. diameterTop?: number;
  30828. diameterBottom?: number;
  30829. diameter?: number;
  30830. tessellation?: number;
  30831. subdivisions?: number;
  30832. arc?: number;
  30833. faceColors?: Color4[];
  30834. faceUV?: Vector4[];
  30835. hasRings?: boolean;
  30836. enclose?: boolean;
  30837. sideOrientation?: number;
  30838. frontUVs?: Vector4;
  30839. backUVs?: Vector4;
  30840. }): VertexData;
  30841. /**
  30842. * Creates the VertexData for a torus
  30843. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30844. * * diameter the diameter of the torus, optional default 1
  30845. * * thickness the diameter of the tube forming the torus, optional default 0.5
  30846. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  30847. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30848. * * 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)
  30849. * * 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)
  30850. * @returns the VertexData of the torus
  30851. */
  30852. static CreateTorus(options: {
  30853. diameter?: number;
  30854. thickness?: number;
  30855. tessellation?: number;
  30856. sideOrientation?: number;
  30857. frontUVs?: Vector4;
  30858. backUVs?: Vector4;
  30859. }): VertexData;
  30860. /**
  30861. * Creates the VertexData of the LineSystem
  30862. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  30863. * - lines an array of lines, each line being an array of successive Vector3
  30864. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  30865. * @returns the VertexData of the LineSystem
  30866. */
  30867. static CreateLineSystem(options: {
  30868. lines: Vector3[][];
  30869. colors?: Nullable<Color4[][]>;
  30870. }): VertexData;
  30871. /**
  30872. * Create the VertexData for a DashedLines
  30873. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  30874. * - points an array successive Vector3
  30875. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  30876. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  30877. * - dashNb the intended total number of dashes, optional, default 200
  30878. * @returns the VertexData for the DashedLines
  30879. */
  30880. static CreateDashedLines(options: {
  30881. points: Vector3[];
  30882. dashSize?: number;
  30883. gapSize?: number;
  30884. dashNb?: number;
  30885. }): VertexData;
  30886. /**
  30887. * Creates the VertexData for a Ground
  30888. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  30889. * - width the width (x direction) of the ground, optional, default 1
  30890. * - height the height (z direction) of the ground, optional, default 1
  30891. * - subdivisions the number of subdivisions per side, optional, default 1
  30892. * @returns the VertexData of the Ground
  30893. */
  30894. static CreateGround(options: {
  30895. width?: number;
  30896. height?: number;
  30897. subdivisions?: number;
  30898. subdivisionsX?: number;
  30899. subdivisionsY?: number;
  30900. }): VertexData;
  30901. /**
  30902. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  30903. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  30904. * * xmin the ground minimum X coordinate, optional, default -1
  30905. * * zmin the ground minimum Z coordinate, optional, default -1
  30906. * * xmax the ground maximum X coordinate, optional, default 1
  30907. * * zmax the ground maximum Z coordinate, optional, default 1
  30908. * * 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}
  30909. * * 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}
  30910. * @returns the VertexData of the TiledGround
  30911. */
  30912. static CreateTiledGround(options: {
  30913. xmin: number;
  30914. zmin: number;
  30915. xmax: number;
  30916. zmax: number;
  30917. subdivisions?: {
  30918. w: number;
  30919. h: number;
  30920. };
  30921. precision?: {
  30922. w: number;
  30923. h: number;
  30924. };
  30925. }): VertexData;
  30926. /**
  30927. * Creates the VertexData of the Ground designed from a heightmap
  30928. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  30929. * * width the width (x direction) of the ground
  30930. * * height the height (z direction) of the ground
  30931. * * subdivisions the number of subdivisions per side
  30932. * * minHeight the minimum altitude on the ground, optional, default 0
  30933. * * maxHeight the maximum altitude on the ground, optional default 1
  30934. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  30935. * * buffer the array holding the image color data
  30936. * * bufferWidth the width of image
  30937. * * bufferHeight the height of image
  30938. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  30939. * @returns the VertexData of the Ground designed from a heightmap
  30940. */
  30941. static CreateGroundFromHeightMap(options: {
  30942. width: number;
  30943. height: number;
  30944. subdivisions: number;
  30945. minHeight: number;
  30946. maxHeight: number;
  30947. colorFilter: Color3;
  30948. buffer: Uint8Array;
  30949. bufferWidth: number;
  30950. bufferHeight: number;
  30951. alphaFilter: number;
  30952. }): VertexData;
  30953. /**
  30954. * Creates the VertexData for a Plane
  30955. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  30956. * * size sets the width and height of the plane to the value of size, optional default 1
  30957. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  30958. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  30959. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30960. * * 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)
  30961. * * 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)
  30962. * @returns the VertexData of the box
  30963. */
  30964. static CreatePlane(options: {
  30965. size?: number;
  30966. width?: number;
  30967. height?: number;
  30968. sideOrientation?: number;
  30969. frontUVs?: Vector4;
  30970. backUVs?: Vector4;
  30971. }): VertexData;
  30972. /**
  30973. * Creates the VertexData of the Disc or regular Polygon
  30974. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  30975. * * radius the radius of the disc, optional default 0.5
  30976. * * tessellation the number of polygon sides, optional, default 64
  30977. * * 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
  30978. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30979. * * 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)
  30980. * * 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)
  30981. * @returns the VertexData of the box
  30982. */
  30983. static CreateDisc(options: {
  30984. radius?: number;
  30985. tessellation?: number;
  30986. arc?: number;
  30987. sideOrientation?: number;
  30988. frontUVs?: Vector4;
  30989. backUVs?: Vector4;
  30990. }): VertexData;
  30991. /**
  30992. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  30993. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  30994. * @param polygon a mesh built from polygonTriangulation.build()
  30995. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30996. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  30997. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  30998. * @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)
  30999. * @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)
  31000. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  31001. * @returns the VertexData of the Polygon
  31002. */
  31003. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  31004. /**
  31005. * Creates the VertexData of the IcoSphere
  31006. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  31007. * * radius the radius of the IcoSphere, optional default 1
  31008. * * radiusX allows stretching in the x direction, optional, default radius
  31009. * * radiusY allows stretching in the y direction, optional, default radius
  31010. * * radiusZ allows stretching in the z direction, optional, default radius
  31011. * * flat when true creates a flat shaded mesh, optional, default true
  31012. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  31013. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31014. * * 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)
  31015. * * 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)
  31016. * @returns the VertexData of the IcoSphere
  31017. */
  31018. static CreateIcoSphere(options: {
  31019. radius?: number;
  31020. radiusX?: number;
  31021. radiusY?: number;
  31022. radiusZ?: number;
  31023. flat?: boolean;
  31024. subdivisions?: number;
  31025. sideOrientation?: number;
  31026. frontUVs?: Vector4;
  31027. backUVs?: Vector4;
  31028. }): VertexData;
  31029. /**
  31030. * Creates the VertexData for a Polyhedron
  31031. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  31032. * * type provided types are:
  31033. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  31034. * * 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)
  31035. * * size the size of the IcoSphere, optional default 1
  31036. * * sizeX allows stretching in the x direction, optional, default size
  31037. * * sizeY allows stretching in the y direction, optional, default size
  31038. * * sizeZ allows stretching in the z direction, optional, default size
  31039. * * 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
  31040. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  31041. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  31042. * * flat when true creates a flat shaded mesh, optional, default true
  31043. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  31044. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31045. * * 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)
  31046. * * 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)
  31047. * @returns the VertexData of the Polyhedron
  31048. */
  31049. static CreatePolyhedron(options: {
  31050. type?: number;
  31051. size?: number;
  31052. sizeX?: number;
  31053. sizeY?: number;
  31054. sizeZ?: number;
  31055. custom?: any;
  31056. faceUV?: Vector4[];
  31057. faceColors?: Color4[];
  31058. flat?: boolean;
  31059. sideOrientation?: number;
  31060. frontUVs?: Vector4;
  31061. backUVs?: Vector4;
  31062. }): VertexData;
  31063. /**
  31064. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  31065. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  31066. * @returns the VertexData of the Capsule
  31067. */
  31068. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  31069. /**
  31070. * Creates the VertexData for a TorusKnot
  31071. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  31072. * * radius the radius of the torus knot, optional, default 2
  31073. * * tube the thickness of the tube, optional, default 0.5
  31074. * * radialSegments the number of sides on each tube segments, optional, default 32
  31075. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  31076. * * p the number of windings around the z axis, optional, default 2
  31077. * * q the number of windings around the x axis, optional, default 3
  31078. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31079. * * 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)
  31080. * * 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)
  31081. * @returns the VertexData of the Torus Knot
  31082. */
  31083. static CreateTorusKnot(options: {
  31084. radius?: number;
  31085. tube?: number;
  31086. radialSegments?: number;
  31087. tubularSegments?: number;
  31088. p?: number;
  31089. q?: number;
  31090. sideOrientation?: number;
  31091. frontUVs?: Vector4;
  31092. backUVs?: Vector4;
  31093. }): VertexData;
  31094. /**
  31095. * Compute normals for given positions and indices
  31096. * @param positions an array of vertex positions, [...., x, y, z, ......]
  31097. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  31098. * @param normals an array of vertex normals, [...., x, y, z, ......]
  31099. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  31100. * * facetNormals : optional array of facet normals (vector3)
  31101. * * facetPositions : optional array of facet positions (vector3)
  31102. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  31103. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  31104. * * bInfo : optional bounding info, required for facetPartitioning computation
  31105. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  31106. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  31107. * * useRightHandedSystem: optional boolean to for right handed system computation
  31108. * * depthSort : optional boolean to enable the facet depth sort computation
  31109. * * distanceTo : optional Vector3 to compute the facet depth from this location
  31110. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  31111. */
  31112. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  31113. facetNormals?: any;
  31114. facetPositions?: any;
  31115. facetPartitioning?: any;
  31116. ratio?: number;
  31117. bInfo?: any;
  31118. bbSize?: Vector3;
  31119. subDiv?: any;
  31120. useRightHandedSystem?: boolean;
  31121. depthSort?: boolean;
  31122. distanceTo?: Vector3;
  31123. depthSortedFacets?: any;
  31124. }): void;
  31125. /** @hidden */
  31126. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  31127. /**
  31128. * Applies VertexData created from the imported parameters to the geometry
  31129. * @param parsedVertexData the parsed data from an imported file
  31130. * @param geometry the geometry to apply the VertexData to
  31131. */
  31132. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  31133. }
  31134. }
  31135. declare module BABYLON {
  31136. /**
  31137. * Defines a target to use with MorphTargetManager
  31138. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31139. */
  31140. export class MorphTarget implements IAnimatable {
  31141. /** defines the name of the target */
  31142. name: string;
  31143. /**
  31144. * Gets or sets the list of animations
  31145. */
  31146. animations: Animation[];
  31147. private _scene;
  31148. private _positions;
  31149. private _normals;
  31150. private _tangents;
  31151. private _uvs;
  31152. private _influence;
  31153. private _uniqueId;
  31154. /**
  31155. * Observable raised when the influence changes
  31156. */
  31157. onInfluenceChanged: Observable<boolean>;
  31158. /** @hidden */
  31159. _onDataLayoutChanged: Observable<void>;
  31160. /**
  31161. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  31162. */
  31163. get influence(): number;
  31164. set influence(influence: number);
  31165. /**
  31166. * Gets or sets the id of the morph Target
  31167. */
  31168. id: string;
  31169. private _animationPropertiesOverride;
  31170. /**
  31171. * Gets or sets the animation properties override
  31172. */
  31173. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  31174. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  31175. /**
  31176. * Creates a new MorphTarget
  31177. * @param name defines the name of the target
  31178. * @param influence defines the influence to use
  31179. * @param scene defines the scene the morphtarget belongs to
  31180. */
  31181. constructor(
  31182. /** defines the name of the target */
  31183. name: string, influence?: number, scene?: Nullable<Scene>);
  31184. /**
  31185. * Gets the unique ID of this manager
  31186. */
  31187. get uniqueId(): number;
  31188. /**
  31189. * Gets a boolean defining if the target contains position data
  31190. */
  31191. get hasPositions(): boolean;
  31192. /**
  31193. * Gets a boolean defining if the target contains normal data
  31194. */
  31195. get hasNormals(): boolean;
  31196. /**
  31197. * Gets a boolean defining if the target contains tangent data
  31198. */
  31199. get hasTangents(): boolean;
  31200. /**
  31201. * Gets a boolean defining if the target contains texture coordinates data
  31202. */
  31203. get hasUVs(): boolean;
  31204. /**
  31205. * Affects position data to this target
  31206. * @param data defines the position data to use
  31207. */
  31208. setPositions(data: Nullable<FloatArray>): void;
  31209. /**
  31210. * Gets the position data stored in this target
  31211. * @returns a FloatArray containing the position data (or null if not present)
  31212. */
  31213. getPositions(): Nullable<FloatArray>;
  31214. /**
  31215. * Affects normal data to this target
  31216. * @param data defines the normal data to use
  31217. */
  31218. setNormals(data: Nullable<FloatArray>): void;
  31219. /**
  31220. * Gets the normal data stored in this target
  31221. * @returns a FloatArray containing the normal data (or null if not present)
  31222. */
  31223. getNormals(): Nullable<FloatArray>;
  31224. /**
  31225. * Affects tangent data to this target
  31226. * @param data defines the tangent data to use
  31227. */
  31228. setTangents(data: Nullable<FloatArray>): void;
  31229. /**
  31230. * Gets the tangent data stored in this target
  31231. * @returns a FloatArray containing the tangent data (or null if not present)
  31232. */
  31233. getTangents(): Nullable<FloatArray>;
  31234. /**
  31235. * Affects texture coordinates data to this target
  31236. * @param data defines the texture coordinates data to use
  31237. */
  31238. setUVs(data: Nullable<FloatArray>): void;
  31239. /**
  31240. * Gets the texture coordinates data stored in this target
  31241. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  31242. */
  31243. getUVs(): Nullable<FloatArray>;
  31244. /**
  31245. * Clone the current target
  31246. * @returns a new MorphTarget
  31247. */
  31248. clone(): MorphTarget;
  31249. /**
  31250. * Serializes the current target into a Serialization object
  31251. * @returns the serialized object
  31252. */
  31253. serialize(): any;
  31254. /**
  31255. * Returns the string "MorphTarget"
  31256. * @returns "MorphTarget"
  31257. */
  31258. getClassName(): string;
  31259. /**
  31260. * Creates a new target from serialized data
  31261. * @param serializationObject defines the serialized data to use
  31262. * @returns a new MorphTarget
  31263. */
  31264. static Parse(serializationObject: any): MorphTarget;
  31265. /**
  31266. * Creates a MorphTarget from mesh data
  31267. * @param mesh defines the source mesh
  31268. * @param name defines the name to use for the new target
  31269. * @param influence defines the influence to attach to the target
  31270. * @returns a new MorphTarget
  31271. */
  31272. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  31273. }
  31274. }
  31275. declare module BABYLON {
  31276. /**
  31277. * This class is used to deform meshes using morphing between different targets
  31278. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31279. */
  31280. export class MorphTargetManager {
  31281. private _targets;
  31282. private _targetInfluenceChangedObservers;
  31283. private _targetDataLayoutChangedObservers;
  31284. private _activeTargets;
  31285. private _scene;
  31286. private _influences;
  31287. private _supportsNormals;
  31288. private _supportsTangents;
  31289. private _supportsUVs;
  31290. private _vertexCount;
  31291. private _uniqueId;
  31292. private _tempInfluences;
  31293. /**
  31294. * Gets or sets a boolean indicating if normals must be morphed
  31295. */
  31296. enableNormalMorphing: boolean;
  31297. /**
  31298. * Gets or sets a boolean indicating if tangents must be morphed
  31299. */
  31300. enableTangentMorphing: boolean;
  31301. /**
  31302. * Gets or sets a boolean indicating if UV must be morphed
  31303. */
  31304. enableUVMorphing: boolean;
  31305. /**
  31306. * Creates a new MorphTargetManager
  31307. * @param scene defines the current scene
  31308. */
  31309. constructor(scene?: Nullable<Scene>);
  31310. /**
  31311. * Gets the unique ID of this manager
  31312. */
  31313. get uniqueId(): number;
  31314. /**
  31315. * Gets the number of vertices handled by this manager
  31316. */
  31317. get vertexCount(): number;
  31318. /**
  31319. * Gets a boolean indicating if this manager supports morphing of normals
  31320. */
  31321. get supportsNormals(): boolean;
  31322. /**
  31323. * Gets a boolean indicating if this manager supports morphing of tangents
  31324. */
  31325. get supportsTangents(): boolean;
  31326. /**
  31327. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  31328. */
  31329. get supportsUVs(): boolean;
  31330. /**
  31331. * Gets the number of targets stored in this manager
  31332. */
  31333. get numTargets(): number;
  31334. /**
  31335. * Gets the number of influencers (ie. the number of targets with influences > 0)
  31336. */
  31337. get numInfluencers(): number;
  31338. /**
  31339. * Gets the list of influences (one per target)
  31340. */
  31341. get influences(): Float32Array;
  31342. /**
  31343. * Gets the active target at specified index. An active target is a target with an influence > 0
  31344. * @param index defines the index to check
  31345. * @returns the requested target
  31346. */
  31347. getActiveTarget(index: number): MorphTarget;
  31348. /**
  31349. * Gets the target at specified index
  31350. * @param index defines the index to check
  31351. * @returns the requested target
  31352. */
  31353. getTarget(index: number): MorphTarget;
  31354. /**
  31355. * Add a new target to this manager
  31356. * @param target defines the target to add
  31357. */
  31358. addTarget(target: MorphTarget): void;
  31359. /**
  31360. * Removes a target from the manager
  31361. * @param target defines the target to remove
  31362. */
  31363. removeTarget(target: MorphTarget): void;
  31364. /**
  31365. * Clone the current manager
  31366. * @returns a new MorphTargetManager
  31367. */
  31368. clone(): MorphTargetManager;
  31369. /**
  31370. * Serializes the current manager into a Serialization object
  31371. * @returns the serialized object
  31372. */
  31373. serialize(): any;
  31374. private _syncActiveTargets;
  31375. /**
  31376. * Syncrhonize the targets with all the meshes using this morph target manager
  31377. */
  31378. synchronize(): void;
  31379. /**
  31380. * Creates a new MorphTargetManager from serialized data
  31381. * @param serializationObject defines the serialized data
  31382. * @param scene defines the hosting scene
  31383. * @returns the new MorphTargetManager
  31384. */
  31385. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  31386. }
  31387. }
  31388. declare module BABYLON {
  31389. /**
  31390. * Class used to represent a specific level of detail of a mesh
  31391. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  31392. */
  31393. export class MeshLODLevel {
  31394. /** Defines the distance where this level should start being displayed */
  31395. distance: number;
  31396. /** Defines the mesh to use to render this level */
  31397. mesh: Nullable<Mesh>;
  31398. /**
  31399. * Creates a new LOD level
  31400. * @param distance defines the distance where this level should star being displayed
  31401. * @param mesh defines the mesh to use to render this level
  31402. */
  31403. constructor(
  31404. /** Defines the distance where this level should start being displayed */
  31405. distance: number,
  31406. /** Defines the mesh to use to render this level */
  31407. mesh: Nullable<Mesh>);
  31408. }
  31409. }
  31410. declare module BABYLON {
  31411. /**
  31412. * Helper class used to generate a canvas to manipulate images
  31413. */
  31414. export class CanvasGenerator {
  31415. /**
  31416. * Create a new canvas (or offscreen canvas depending on the context)
  31417. * @param width defines the expected width
  31418. * @param height defines the expected height
  31419. * @return a new canvas or offscreen canvas
  31420. */
  31421. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  31422. }
  31423. }
  31424. declare module BABYLON {
  31425. /**
  31426. * Mesh representing the gorund
  31427. */
  31428. export class GroundMesh extends Mesh {
  31429. /** If octree should be generated */
  31430. generateOctree: boolean;
  31431. private _heightQuads;
  31432. /** @hidden */
  31433. _subdivisionsX: number;
  31434. /** @hidden */
  31435. _subdivisionsY: number;
  31436. /** @hidden */
  31437. _width: number;
  31438. /** @hidden */
  31439. _height: number;
  31440. /** @hidden */
  31441. _minX: number;
  31442. /** @hidden */
  31443. _maxX: number;
  31444. /** @hidden */
  31445. _minZ: number;
  31446. /** @hidden */
  31447. _maxZ: number;
  31448. constructor(name: string, scene: Scene);
  31449. /**
  31450. * "GroundMesh"
  31451. * @returns "GroundMesh"
  31452. */
  31453. getClassName(): string;
  31454. /**
  31455. * The minimum of x and y subdivisions
  31456. */
  31457. get subdivisions(): number;
  31458. /**
  31459. * X subdivisions
  31460. */
  31461. get subdivisionsX(): number;
  31462. /**
  31463. * Y subdivisions
  31464. */
  31465. get subdivisionsY(): number;
  31466. /**
  31467. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  31468. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  31469. * @param chunksCount the number of subdivisions for x and y
  31470. * @param octreeBlocksSize (Default: 32)
  31471. */
  31472. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  31473. /**
  31474. * Returns a height (y) value in the Worl system :
  31475. * the ground altitude at the coordinates (x, z) expressed in the World system.
  31476. * @param x x coordinate
  31477. * @param z z coordinate
  31478. * @returns the ground y position if (x, z) are outside the ground surface.
  31479. */
  31480. getHeightAtCoordinates(x: number, z: number): number;
  31481. /**
  31482. * Returns a normalized vector (Vector3) orthogonal to the ground
  31483. * at the ground coordinates (x, z) expressed in the World system.
  31484. * @param x x coordinate
  31485. * @param z z coordinate
  31486. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  31487. */
  31488. getNormalAtCoordinates(x: number, z: number): Vector3;
  31489. /**
  31490. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  31491. * at the ground coordinates (x, z) expressed in the World system.
  31492. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  31493. * @param x x coordinate
  31494. * @param z z coordinate
  31495. * @param ref vector to store the result
  31496. * @returns the GroundMesh.
  31497. */
  31498. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  31499. /**
  31500. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  31501. * if the ground has been updated.
  31502. * This can be used in the render loop.
  31503. * @returns the GroundMesh.
  31504. */
  31505. updateCoordinateHeights(): GroundMesh;
  31506. private _getFacetAt;
  31507. private _initHeightQuads;
  31508. private _computeHeightQuads;
  31509. /**
  31510. * Serializes this ground mesh
  31511. * @param serializationObject object to write serialization to
  31512. */
  31513. serialize(serializationObject: any): void;
  31514. /**
  31515. * Parses a serialized ground mesh
  31516. * @param parsedMesh the serialized mesh
  31517. * @param scene the scene to create the ground mesh in
  31518. * @returns the created ground mesh
  31519. */
  31520. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  31521. }
  31522. }
  31523. declare module BABYLON {
  31524. /**
  31525. * Interface for Physics-Joint data
  31526. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31527. */
  31528. export interface PhysicsJointData {
  31529. /**
  31530. * The main pivot of the joint
  31531. */
  31532. mainPivot?: Vector3;
  31533. /**
  31534. * The connected pivot of the joint
  31535. */
  31536. connectedPivot?: Vector3;
  31537. /**
  31538. * The main axis of the joint
  31539. */
  31540. mainAxis?: Vector3;
  31541. /**
  31542. * The connected axis of the joint
  31543. */
  31544. connectedAxis?: Vector3;
  31545. /**
  31546. * The collision of the joint
  31547. */
  31548. collision?: boolean;
  31549. /**
  31550. * Native Oimo/Cannon/Energy data
  31551. */
  31552. nativeParams?: any;
  31553. }
  31554. /**
  31555. * This is a holder class for the physics joint created by the physics plugin
  31556. * It holds a set of functions to control the underlying joint
  31557. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31558. */
  31559. export class PhysicsJoint {
  31560. /**
  31561. * The type of the physics joint
  31562. */
  31563. type: number;
  31564. /**
  31565. * The data for the physics joint
  31566. */
  31567. jointData: PhysicsJointData;
  31568. private _physicsJoint;
  31569. protected _physicsPlugin: IPhysicsEnginePlugin;
  31570. /**
  31571. * Initializes the physics joint
  31572. * @param type The type of the physics joint
  31573. * @param jointData The data for the physics joint
  31574. */
  31575. constructor(
  31576. /**
  31577. * The type of the physics joint
  31578. */
  31579. type: number,
  31580. /**
  31581. * The data for the physics joint
  31582. */
  31583. jointData: PhysicsJointData);
  31584. /**
  31585. * Gets the physics joint
  31586. */
  31587. get physicsJoint(): any;
  31588. /**
  31589. * Sets the physics joint
  31590. */
  31591. set physicsJoint(newJoint: any);
  31592. /**
  31593. * Sets the physics plugin
  31594. */
  31595. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  31596. /**
  31597. * Execute a function that is physics-plugin specific.
  31598. * @param {Function} func the function that will be executed.
  31599. * It accepts two parameters: the physics world and the physics joint
  31600. */
  31601. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  31602. /**
  31603. * Distance-Joint type
  31604. */
  31605. static DistanceJoint: number;
  31606. /**
  31607. * Hinge-Joint type
  31608. */
  31609. static HingeJoint: number;
  31610. /**
  31611. * Ball-and-Socket joint type
  31612. */
  31613. static BallAndSocketJoint: number;
  31614. /**
  31615. * Wheel-Joint type
  31616. */
  31617. static WheelJoint: number;
  31618. /**
  31619. * Slider-Joint type
  31620. */
  31621. static SliderJoint: number;
  31622. /**
  31623. * Prismatic-Joint type
  31624. */
  31625. static PrismaticJoint: number;
  31626. /**
  31627. * Universal-Joint type
  31628. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  31629. */
  31630. static UniversalJoint: number;
  31631. /**
  31632. * Hinge-Joint 2 type
  31633. */
  31634. static Hinge2Joint: number;
  31635. /**
  31636. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  31637. */
  31638. static PointToPointJoint: number;
  31639. /**
  31640. * Spring-Joint type
  31641. */
  31642. static SpringJoint: number;
  31643. /**
  31644. * Lock-Joint type
  31645. */
  31646. static LockJoint: number;
  31647. }
  31648. /**
  31649. * A class representing a physics distance joint
  31650. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31651. */
  31652. export class DistanceJoint extends PhysicsJoint {
  31653. /**
  31654. *
  31655. * @param jointData The data for the Distance-Joint
  31656. */
  31657. constructor(jointData: DistanceJointData);
  31658. /**
  31659. * Update the predefined distance.
  31660. * @param maxDistance The maximum preferred distance
  31661. * @param minDistance The minimum preferred distance
  31662. */
  31663. updateDistance(maxDistance: number, minDistance?: number): void;
  31664. }
  31665. /**
  31666. * Represents a Motor-Enabled Joint
  31667. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31668. */
  31669. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  31670. /**
  31671. * Initializes the Motor-Enabled Joint
  31672. * @param type The type of the joint
  31673. * @param jointData The physica joint data for the joint
  31674. */
  31675. constructor(type: number, jointData: PhysicsJointData);
  31676. /**
  31677. * Set the motor values.
  31678. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31679. * @param force the force to apply
  31680. * @param maxForce max force for this motor.
  31681. */
  31682. setMotor(force?: number, maxForce?: number): void;
  31683. /**
  31684. * Set the motor's limits.
  31685. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31686. * @param upperLimit The upper limit of the motor
  31687. * @param lowerLimit The lower limit of the motor
  31688. */
  31689. setLimit(upperLimit: number, lowerLimit?: number): void;
  31690. }
  31691. /**
  31692. * This class represents a single physics Hinge-Joint
  31693. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31694. */
  31695. export class HingeJoint extends MotorEnabledJoint {
  31696. /**
  31697. * Initializes the Hinge-Joint
  31698. * @param jointData The joint data for the Hinge-Joint
  31699. */
  31700. constructor(jointData: PhysicsJointData);
  31701. /**
  31702. * Set the motor values.
  31703. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31704. * @param {number} force the force to apply
  31705. * @param {number} maxForce max force for this motor.
  31706. */
  31707. setMotor(force?: number, maxForce?: number): void;
  31708. /**
  31709. * Set the motor's limits.
  31710. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31711. * @param upperLimit The upper limit of the motor
  31712. * @param lowerLimit The lower limit of the motor
  31713. */
  31714. setLimit(upperLimit: number, lowerLimit?: number): void;
  31715. }
  31716. /**
  31717. * This class represents a dual hinge physics joint (same as wheel joint)
  31718. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31719. */
  31720. export class Hinge2Joint extends MotorEnabledJoint {
  31721. /**
  31722. * Initializes the Hinge2-Joint
  31723. * @param jointData The joint data for the Hinge2-Joint
  31724. */
  31725. constructor(jointData: PhysicsJointData);
  31726. /**
  31727. * Set the motor values.
  31728. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31729. * @param {number} targetSpeed the speed the motor is to reach
  31730. * @param {number} maxForce max force for this motor.
  31731. * @param {motorIndex} the motor's index, 0 or 1.
  31732. */
  31733. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  31734. /**
  31735. * Set the motor limits.
  31736. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31737. * @param {number} upperLimit the upper limit
  31738. * @param {number} lowerLimit lower limit
  31739. * @param {motorIndex} the motor's index, 0 or 1.
  31740. */
  31741. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31742. }
  31743. /**
  31744. * Interface for a motor enabled joint
  31745. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31746. */
  31747. export interface IMotorEnabledJoint {
  31748. /**
  31749. * Physics joint
  31750. */
  31751. physicsJoint: any;
  31752. /**
  31753. * Sets the motor of the motor-enabled joint
  31754. * @param force The force of the motor
  31755. * @param maxForce The maximum force of the motor
  31756. * @param motorIndex The index of the motor
  31757. */
  31758. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  31759. /**
  31760. * Sets the limit of the motor
  31761. * @param upperLimit The upper limit of the motor
  31762. * @param lowerLimit The lower limit of the motor
  31763. * @param motorIndex The index of the motor
  31764. */
  31765. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31766. }
  31767. /**
  31768. * Joint data for a Distance-Joint
  31769. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31770. */
  31771. export interface DistanceJointData extends PhysicsJointData {
  31772. /**
  31773. * Max distance the 2 joint objects can be apart
  31774. */
  31775. maxDistance: number;
  31776. }
  31777. /**
  31778. * Joint data from a spring joint
  31779. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31780. */
  31781. export interface SpringJointData extends PhysicsJointData {
  31782. /**
  31783. * Length of the spring
  31784. */
  31785. length: number;
  31786. /**
  31787. * Stiffness of the spring
  31788. */
  31789. stiffness: number;
  31790. /**
  31791. * Damping of the spring
  31792. */
  31793. damping: number;
  31794. /** this callback will be called when applying the force to the impostors. */
  31795. forceApplicationCallback: () => void;
  31796. }
  31797. }
  31798. declare module BABYLON {
  31799. /**
  31800. * Holds the data for the raycast result
  31801. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31802. */
  31803. export class PhysicsRaycastResult {
  31804. private _hasHit;
  31805. private _hitDistance;
  31806. private _hitNormalWorld;
  31807. private _hitPointWorld;
  31808. private _rayFromWorld;
  31809. private _rayToWorld;
  31810. /**
  31811. * Gets if there was a hit
  31812. */
  31813. get hasHit(): boolean;
  31814. /**
  31815. * Gets the distance from the hit
  31816. */
  31817. get hitDistance(): number;
  31818. /**
  31819. * Gets the hit normal/direction in the world
  31820. */
  31821. get hitNormalWorld(): Vector3;
  31822. /**
  31823. * Gets the hit point in the world
  31824. */
  31825. get hitPointWorld(): Vector3;
  31826. /**
  31827. * Gets the ray "start point" of the ray in the world
  31828. */
  31829. get rayFromWorld(): Vector3;
  31830. /**
  31831. * Gets the ray "end point" of the ray in the world
  31832. */
  31833. get rayToWorld(): Vector3;
  31834. /**
  31835. * Sets the hit data (normal & point in world space)
  31836. * @param hitNormalWorld defines the normal in world space
  31837. * @param hitPointWorld defines the point in world space
  31838. */
  31839. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  31840. /**
  31841. * Sets the distance from the start point to the hit point
  31842. * @param distance
  31843. */
  31844. setHitDistance(distance: number): void;
  31845. /**
  31846. * Calculates the distance manually
  31847. */
  31848. calculateHitDistance(): void;
  31849. /**
  31850. * Resets all the values to default
  31851. * @param from The from point on world space
  31852. * @param to The to point on world space
  31853. */
  31854. reset(from?: Vector3, to?: Vector3): void;
  31855. }
  31856. /**
  31857. * Interface for the size containing width and height
  31858. */
  31859. interface IXYZ {
  31860. /**
  31861. * X
  31862. */
  31863. x: number;
  31864. /**
  31865. * Y
  31866. */
  31867. y: number;
  31868. /**
  31869. * Z
  31870. */
  31871. z: number;
  31872. }
  31873. }
  31874. declare module BABYLON {
  31875. /**
  31876. * Interface used to describe a physics joint
  31877. */
  31878. export interface PhysicsImpostorJoint {
  31879. /** Defines the main impostor to which the joint is linked */
  31880. mainImpostor: PhysicsImpostor;
  31881. /** Defines the impostor that is connected to the main impostor using this joint */
  31882. connectedImpostor: PhysicsImpostor;
  31883. /** Defines the joint itself */
  31884. joint: PhysicsJoint;
  31885. }
  31886. /** @hidden */
  31887. export interface IPhysicsEnginePlugin {
  31888. world: any;
  31889. name: string;
  31890. setGravity(gravity: Vector3): void;
  31891. setTimeStep(timeStep: number): void;
  31892. getTimeStep(): number;
  31893. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  31894. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31895. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31896. generatePhysicsBody(impostor: PhysicsImpostor): void;
  31897. removePhysicsBody(impostor: PhysicsImpostor): void;
  31898. generateJoint(joint: PhysicsImpostorJoint): void;
  31899. removeJoint(joint: PhysicsImpostorJoint): void;
  31900. isSupported(): boolean;
  31901. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  31902. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  31903. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31904. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31905. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31906. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31907. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  31908. getBodyMass(impostor: PhysicsImpostor): number;
  31909. getBodyFriction(impostor: PhysicsImpostor): number;
  31910. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  31911. getBodyRestitution(impostor: PhysicsImpostor): number;
  31912. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  31913. getBodyPressure?(impostor: PhysicsImpostor): number;
  31914. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  31915. getBodyStiffness?(impostor: PhysicsImpostor): number;
  31916. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  31917. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  31918. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  31919. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  31920. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  31921. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  31922. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  31923. sleepBody(impostor: PhysicsImpostor): void;
  31924. wakeUpBody(impostor: PhysicsImpostor): void;
  31925. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  31926. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  31927. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  31928. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31929. getRadius(impostor: PhysicsImpostor): number;
  31930. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  31931. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  31932. dispose(): void;
  31933. }
  31934. /**
  31935. * Interface used to define a physics engine
  31936. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31937. */
  31938. export interface IPhysicsEngine {
  31939. /**
  31940. * Gets the gravity vector used by the simulation
  31941. */
  31942. gravity: Vector3;
  31943. /**
  31944. * Sets the gravity vector used by the simulation
  31945. * @param gravity defines the gravity vector to use
  31946. */
  31947. setGravity(gravity: Vector3): void;
  31948. /**
  31949. * Set the time step of the physics engine.
  31950. * Default is 1/60.
  31951. * To slow it down, enter 1/600 for example.
  31952. * To speed it up, 1/30
  31953. * @param newTimeStep the new timestep to apply to this world.
  31954. */
  31955. setTimeStep(newTimeStep: number): void;
  31956. /**
  31957. * Get the time step of the physics engine.
  31958. * @returns the current time step
  31959. */
  31960. getTimeStep(): number;
  31961. /**
  31962. * Set the sub time step of the physics engine.
  31963. * Default is 0 meaning there is no sub steps
  31964. * To increase physics resolution precision, set a small value (like 1 ms)
  31965. * @param subTimeStep defines the new sub timestep used for physics resolution.
  31966. */
  31967. setSubTimeStep(subTimeStep: number): void;
  31968. /**
  31969. * Get the sub time step of the physics engine.
  31970. * @returns the current sub time step
  31971. */
  31972. getSubTimeStep(): number;
  31973. /**
  31974. * Release all resources
  31975. */
  31976. dispose(): void;
  31977. /**
  31978. * Gets the name of the current physics plugin
  31979. * @returns the name of the plugin
  31980. */
  31981. getPhysicsPluginName(): string;
  31982. /**
  31983. * Adding a new impostor for the impostor tracking.
  31984. * This will be done by the impostor itself.
  31985. * @param impostor the impostor to add
  31986. */
  31987. addImpostor(impostor: PhysicsImpostor): void;
  31988. /**
  31989. * Remove an impostor from the engine.
  31990. * This impostor and its mesh will not longer be updated by the physics engine.
  31991. * @param impostor the impostor to remove
  31992. */
  31993. removeImpostor(impostor: PhysicsImpostor): void;
  31994. /**
  31995. * Add a joint to the physics engine
  31996. * @param mainImpostor defines the main impostor to which the joint is added.
  31997. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  31998. * @param joint defines the joint that will connect both impostors.
  31999. */
  32000. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32001. /**
  32002. * Removes a joint from the simulation
  32003. * @param mainImpostor defines the impostor used with the joint
  32004. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32005. * @param joint defines the joint to remove
  32006. */
  32007. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32008. /**
  32009. * Gets the current plugin used to run the simulation
  32010. * @returns current plugin
  32011. */
  32012. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32013. /**
  32014. * Gets the list of physic impostors
  32015. * @returns an array of PhysicsImpostor
  32016. */
  32017. getImpostors(): Array<PhysicsImpostor>;
  32018. /**
  32019. * Gets the impostor for a physics enabled object
  32020. * @param object defines the object impersonated by the impostor
  32021. * @returns the PhysicsImpostor or null if not found
  32022. */
  32023. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32024. /**
  32025. * Gets the impostor for a physics body object
  32026. * @param body defines physics body used by the impostor
  32027. * @returns the PhysicsImpostor or null if not found
  32028. */
  32029. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32030. /**
  32031. * Does a raycast in the physics world
  32032. * @param from when should the ray start?
  32033. * @param to when should the ray end?
  32034. * @returns PhysicsRaycastResult
  32035. */
  32036. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32037. /**
  32038. * Called by the scene. No need to call it.
  32039. * @param delta defines the timespam between frames
  32040. */
  32041. _step(delta: number): void;
  32042. }
  32043. }
  32044. declare module BABYLON {
  32045. /**
  32046. * The interface for the physics imposter parameters
  32047. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32048. */
  32049. export interface PhysicsImpostorParameters {
  32050. /**
  32051. * The mass of the physics imposter
  32052. */
  32053. mass: number;
  32054. /**
  32055. * The friction of the physics imposter
  32056. */
  32057. friction?: number;
  32058. /**
  32059. * The coefficient of restitution of the physics imposter
  32060. */
  32061. restitution?: number;
  32062. /**
  32063. * The native options of the physics imposter
  32064. */
  32065. nativeOptions?: any;
  32066. /**
  32067. * Specifies if the parent should be ignored
  32068. */
  32069. ignoreParent?: boolean;
  32070. /**
  32071. * Specifies if bi-directional transformations should be disabled
  32072. */
  32073. disableBidirectionalTransformation?: boolean;
  32074. /**
  32075. * The pressure inside the physics imposter, soft object only
  32076. */
  32077. pressure?: number;
  32078. /**
  32079. * The stiffness the physics imposter, soft object only
  32080. */
  32081. stiffness?: number;
  32082. /**
  32083. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  32084. */
  32085. velocityIterations?: number;
  32086. /**
  32087. * The number of iterations used in maintaining consistent vertex positions, soft object only
  32088. */
  32089. positionIterations?: number;
  32090. /**
  32091. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  32092. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  32093. * Add to fix multiple points
  32094. */
  32095. fixedPoints?: number;
  32096. /**
  32097. * The collision margin around a soft object
  32098. */
  32099. margin?: number;
  32100. /**
  32101. * The collision margin around a soft object
  32102. */
  32103. damping?: number;
  32104. /**
  32105. * The path for a rope based on an extrusion
  32106. */
  32107. path?: any;
  32108. /**
  32109. * The shape of an extrusion used for a rope based on an extrusion
  32110. */
  32111. shape?: any;
  32112. }
  32113. /**
  32114. * Interface for a physics-enabled object
  32115. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32116. */
  32117. export interface IPhysicsEnabledObject {
  32118. /**
  32119. * The position of the physics-enabled object
  32120. */
  32121. position: Vector3;
  32122. /**
  32123. * The rotation of the physics-enabled object
  32124. */
  32125. rotationQuaternion: Nullable<Quaternion>;
  32126. /**
  32127. * The scale of the physics-enabled object
  32128. */
  32129. scaling: Vector3;
  32130. /**
  32131. * The rotation of the physics-enabled object
  32132. */
  32133. rotation?: Vector3;
  32134. /**
  32135. * The parent of the physics-enabled object
  32136. */
  32137. parent?: any;
  32138. /**
  32139. * The bounding info of the physics-enabled object
  32140. * @returns The bounding info of the physics-enabled object
  32141. */
  32142. getBoundingInfo(): BoundingInfo;
  32143. /**
  32144. * Computes the world matrix
  32145. * @param force Specifies if the world matrix should be computed by force
  32146. * @returns A world matrix
  32147. */
  32148. computeWorldMatrix(force: boolean): Matrix;
  32149. /**
  32150. * Gets the world matrix
  32151. * @returns A world matrix
  32152. */
  32153. getWorldMatrix?(): Matrix;
  32154. /**
  32155. * Gets the child meshes
  32156. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  32157. * @returns An array of abstract meshes
  32158. */
  32159. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  32160. /**
  32161. * Gets the vertex data
  32162. * @param kind The type of vertex data
  32163. * @returns A nullable array of numbers, or a float32 array
  32164. */
  32165. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  32166. /**
  32167. * Gets the indices from the mesh
  32168. * @returns A nullable array of index arrays
  32169. */
  32170. getIndices?(): Nullable<IndicesArray>;
  32171. /**
  32172. * Gets the scene from the mesh
  32173. * @returns the indices array or null
  32174. */
  32175. getScene?(): Scene;
  32176. /**
  32177. * Gets the absolute position from the mesh
  32178. * @returns the absolute position
  32179. */
  32180. getAbsolutePosition(): Vector3;
  32181. /**
  32182. * Gets the absolute pivot point from the mesh
  32183. * @returns the absolute pivot point
  32184. */
  32185. getAbsolutePivotPoint(): Vector3;
  32186. /**
  32187. * Rotates the mesh
  32188. * @param axis The axis of rotation
  32189. * @param amount The amount of rotation
  32190. * @param space The space of the rotation
  32191. * @returns The rotation transform node
  32192. */
  32193. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  32194. /**
  32195. * Translates the mesh
  32196. * @param axis The axis of translation
  32197. * @param distance The distance of translation
  32198. * @param space The space of the translation
  32199. * @returns The transform node
  32200. */
  32201. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  32202. /**
  32203. * Sets the absolute position of the mesh
  32204. * @param absolutePosition The absolute position of the mesh
  32205. * @returns The transform node
  32206. */
  32207. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  32208. /**
  32209. * Gets the class name of the mesh
  32210. * @returns The class name
  32211. */
  32212. getClassName(): string;
  32213. }
  32214. /**
  32215. * Represents a physics imposter
  32216. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32217. */
  32218. export class PhysicsImpostor {
  32219. /**
  32220. * The physics-enabled object used as the physics imposter
  32221. */
  32222. object: IPhysicsEnabledObject;
  32223. /**
  32224. * The type of the physics imposter
  32225. */
  32226. type: number;
  32227. private _options;
  32228. private _scene?;
  32229. /**
  32230. * The default object size of the imposter
  32231. */
  32232. static DEFAULT_OBJECT_SIZE: Vector3;
  32233. /**
  32234. * The identity quaternion of the imposter
  32235. */
  32236. static IDENTITY_QUATERNION: Quaternion;
  32237. /** @hidden */
  32238. _pluginData: any;
  32239. private _physicsEngine;
  32240. private _physicsBody;
  32241. private _bodyUpdateRequired;
  32242. private _onBeforePhysicsStepCallbacks;
  32243. private _onAfterPhysicsStepCallbacks;
  32244. /** @hidden */
  32245. _onPhysicsCollideCallbacks: Array<{
  32246. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  32247. otherImpostors: Array<PhysicsImpostor>;
  32248. }>;
  32249. private _deltaPosition;
  32250. private _deltaRotation;
  32251. private _deltaRotationConjugated;
  32252. /** @hidden */
  32253. _isFromLine: boolean;
  32254. private _parent;
  32255. private _isDisposed;
  32256. private static _tmpVecs;
  32257. private static _tmpQuat;
  32258. /**
  32259. * Specifies if the physics imposter is disposed
  32260. */
  32261. get isDisposed(): boolean;
  32262. /**
  32263. * Gets the mass of the physics imposter
  32264. */
  32265. get mass(): number;
  32266. set mass(value: number);
  32267. /**
  32268. * Gets the coefficient of friction
  32269. */
  32270. get friction(): number;
  32271. /**
  32272. * Sets the coefficient of friction
  32273. */
  32274. set friction(value: number);
  32275. /**
  32276. * Gets the coefficient of restitution
  32277. */
  32278. get restitution(): number;
  32279. /**
  32280. * Sets the coefficient of restitution
  32281. */
  32282. set restitution(value: number);
  32283. /**
  32284. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  32285. */
  32286. get pressure(): number;
  32287. /**
  32288. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  32289. */
  32290. set pressure(value: number);
  32291. /**
  32292. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32293. */
  32294. get stiffness(): number;
  32295. /**
  32296. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32297. */
  32298. set stiffness(value: number);
  32299. /**
  32300. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32301. */
  32302. get velocityIterations(): number;
  32303. /**
  32304. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32305. */
  32306. set velocityIterations(value: number);
  32307. /**
  32308. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32309. */
  32310. get positionIterations(): number;
  32311. /**
  32312. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32313. */
  32314. set positionIterations(value: number);
  32315. /**
  32316. * The unique id of the physics imposter
  32317. * set by the physics engine when adding this impostor to the array
  32318. */
  32319. uniqueId: number;
  32320. /**
  32321. * @hidden
  32322. */
  32323. soft: boolean;
  32324. /**
  32325. * @hidden
  32326. */
  32327. segments: number;
  32328. private _joints;
  32329. /**
  32330. * Initializes the physics imposter
  32331. * @param object The physics-enabled object used as the physics imposter
  32332. * @param type The type of the physics imposter
  32333. * @param _options The options for the physics imposter
  32334. * @param _scene The Babylon scene
  32335. */
  32336. constructor(
  32337. /**
  32338. * The physics-enabled object used as the physics imposter
  32339. */
  32340. object: IPhysicsEnabledObject,
  32341. /**
  32342. * The type of the physics imposter
  32343. */
  32344. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  32345. /**
  32346. * This function will completly initialize this impostor.
  32347. * It will create a new body - but only if this mesh has no parent.
  32348. * If it has, this impostor will not be used other than to define the impostor
  32349. * of the child mesh.
  32350. * @hidden
  32351. */
  32352. _init(): void;
  32353. private _getPhysicsParent;
  32354. /**
  32355. * Should a new body be generated.
  32356. * @returns boolean specifying if body initialization is required
  32357. */
  32358. isBodyInitRequired(): boolean;
  32359. /**
  32360. * Sets the updated scaling
  32361. * @param updated Specifies if the scaling is updated
  32362. */
  32363. setScalingUpdated(): void;
  32364. /**
  32365. * Force a regeneration of this or the parent's impostor's body.
  32366. * Use under cautious - This will remove all joints already implemented.
  32367. */
  32368. forceUpdate(): void;
  32369. /**
  32370. * Gets the body that holds this impostor. Either its own, or its parent.
  32371. */
  32372. get physicsBody(): any;
  32373. /**
  32374. * Get the parent of the physics imposter
  32375. * @returns Physics imposter or null
  32376. */
  32377. get parent(): Nullable<PhysicsImpostor>;
  32378. /**
  32379. * Sets the parent of the physics imposter
  32380. */
  32381. set parent(value: Nullable<PhysicsImpostor>);
  32382. /**
  32383. * Set the physics body. Used mainly by the physics engine/plugin
  32384. */
  32385. set physicsBody(physicsBody: any);
  32386. /**
  32387. * Resets the update flags
  32388. */
  32389. resetUpdateFlags(): void;
  32390. /**
  32391. * Gets the object extend size
  32392. * @returns the object extend size
  32393. */
  32394. getObjectExtendSize(): Vector3;
  32395. /**
  32396. * Gets the object center
  32397. * @returns The object center
  32398. */
  32399. getObjectCenter(): Vector3;
  32400. /**
  32401. * Get a specific parameter from the options parameters
  32402. * @param paramName The object parameter name
  32403. * @returns The object parameter
  32404. */
  32405. getParam(paramName: string): any;
  32406. /**
  32407. * Sets a specific parameter in the options given to the physics plugin
  32408. * @param paramName The parameter name
  32409. * @param value The value of the parameter
  32410. */
  32411. setParam(paramName: string, value: number): void;
  32412. /**
  32413. * Specifically change the body's mass option. Won't recreate the physics body object
  32414. * @param mass The mass of the physics imposter
  32415. */
  32416. setMass(mass: number): void;
  32417. /**
  32418. * Gets the linear velocity
  32419. * @returns linear velocity or null
  32420. */
  32421. getLinearVelocity(): Nullable<Vector3>;
  32422. /**
  32423. * Sets the linear velocity
  32424. * @param velocity linear velocity or null
  32425. */
  32426. setLinearVelocity(velocity: Nullable<Vector3>): void;
  32427. /**
  32428. * Gets the angular velocity
  32429. * @returns angular velocity or null
  32430. */
  32431. getAngularVelocity(): Nullable<Vector3>;
  32432. /**
  32433. * Sets the angular velocity
  32434. * @param velocity The velocity or null
  32435. */
  32436. setAngularVelocity(velocity: Nullable<Vector3>): void;
  32437. /**
  32438. * Execute a function with the physics plugin native code
  32439. * Provide a function the will have two variables - the world object and the physics body object
  32440. * @param func The function to execute with the physics plugin native code
  32441. */
  32442. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  32443. /**
  32444. * Register a function that will be executed before the physics world is stepping forward
  32445. * @param func The function to execute before the physics world is stepped forward
  32446. */
  32447. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32448. /**
  32449. * Unregister a function that will be executed before the physics world is stepping forward
  32450. * @param func The function to execute before the physics world is stepped forward
  32451. */
  32452. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32453. /**
  32454. * Register a function that will be executed after the physics step
  32455. * @param func The function to execute after physics step
  32456. */
  32457. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32458. /**
  32459. * Unregisters a function that will be executed after the physics step
  32460. * @param func The function to execute after physics step
  32461. */
  32462. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32463. /**
  32464. * register a function that will be executed when this impostor collides against a different body
  32465. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  32466. * @param func Callback that is executed on collision
  32467. */
  32468. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  32469. /**
  32470. * Unregisters the physics imposter on contact
  32471. * @param collideAgainst The physics object to collide against
  32472. * @param func Callback to execute on collision
  32473. */
  32474. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  32475. private _tmpQuat;
  32476. private _tmpQuat2;
  32477. /**
  32478. * Get the parent rotation
  32479. * @returns The parent rotation
  32480. */
  32481. getParentsRotation(): Quaternion;
  32482. /**
  32483. * this function is executed by the physics engine.
  32484. */
  32485. beforeStep: () => void;
  32486. /**
  32487. * this function is executed by the physics engine
  32488. */
  32489. afterStep: () => void;
  32490. /**
  32491. * Legacy collision detection event support
  32492. */
  32493. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  32494. /**
  32495. * event and body object due to cannon's event-based architecture.
  32496. */
  32497. onCollide: (e: {
  32498. body: any;
  32499. point: Nullable<Vector3>;
  32500. }) => void;
  32501. /**
  32502. * Apply a force
  32503. * @param force The force to apply
  32504. * @param contactPoint The contact point for the force
  32505. * @returns The physics imposter
  32506. */
  32507. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32508. /**
  32509. * Apply an impulse
  32510. * @param force The impulse force
  32511. * @param contactPoint The contact point for the impulse force
  32512. * @returns The physics imposter
  32513. */
  32514. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32515. /**
  32516. * A help function to create a joint
  32517. * @param otherImpostor A physics imposter used to create a joint
  32518. * @param jointType The type of joint
  32519. * @param jointData The data for the joint
  32520. * @returns The physics imposter
  32521. */
  32522. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  32523. /**
  32524. * Add a joint to this impostor with a different impostor
  32525. * @param otherImpostor A physics imposter used to add a joint
  32526. * @param joint The joint to add
  32527. * @returns The physics imposter
  32528. */
  32529. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  32530. /**
  32531. * Add an anchor to a cloth impostor
  32532. * @param otherImpostor rigid impostor to anchor to
  32533. * @param width ratio across width from 0 to 1
  32534. * @param height ratio up height from 0 to 1
  32535. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  32536. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  32537. * @returns impostor the soft imposter
  32538. */
  32539. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32540. /**
  32541. * Add a hook to a rope impostor
  32542. * @param otherImpostor rigid impostor to anchor to
  32543. * @param length ratio across rope from 0 to 1
  32544. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  32545. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  32546. * @returns impostor the rope imposter
  32547. */
  32548. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32549. /**
  32550. * Will keep this body still, in a sleep mode.
  32551. * @returns the physics imposter
  32552. */
  32553. sleep(): PhysicsImpostor;
  32554. /**
  32555. * Wake the body up.
  32556. * @returns The physics imposter
  32557. */
  32558. wakeUp(): PhysicsImpostor;
  32559. /**
  32560. * Clones the physics imposter
  32561. * @param newObject The physics imposter clones to this physics-enabled object
  32562. * @returns A nullable physics imposter
  32563. */
  32564. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32565. /**
  32566. * Disposes the physics imposter
  32567. */
  32568. dispose(): void;
  32569. /**
  32570. * Sets the delta position
  32571. * @param position The delta position amount
  32572. */
  32573. setDeltaPosition(position: Vector3): void;
  32574. /**
  32575. * Sets the delta rotation
  32576. * @param rotation The delta rotation amount
  32577. */
  32578. setDeltaRotation(rotation: Quaternion): void;
  32579. /**
  32580. * Gets the box size of the physics imposter and stores the result in the input parameter
  32581. * @param result Stores the box size
  32582. * @returns The physics imposter
  32583. */
  32584. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  32585. /**
  32586. * Gets the radius of the physics imposter
  32587. * @returns Radius of the physics imposter
  32588. */
  32589. getRadius(): number;
  32590. /**
  32591. * Sync a bone with this impostor
  32592. * @param bone The bone to sync to the impostor.
  32593. * @param boneMesh The mesh that the bone is influencing.
  32594. * @param jointPivot The pivot of the joint / bone in local space.
  32595. * @param distToJoint Optional distance from the impostor to the joint.
  32596. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32597. */
  32598. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  32599. /**
  32600. * Sync impostor to a bone
  32601. * @param bone The bone that the impostor will be synced to.
  32602. * @param boneMesh The mesh that the bone is influencing.
  32603. * @param jointPivot The pivot of the joint / bone in local space.
  32604. * @param distToJoint Optional distance from the impostor to the joint.
  32605. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32606. * @param boneAxis Optional vector3 axis the bone is aligned with
  32607. */
  32608. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  32609. /**
  32610. * No-Imposter type
  32611. */
  32612. static NoImpostor: number;
  32613. /**
  32614. * Sphere-Imposter type
  32615. */
  32616. static SphereImpostor: number;
  32617. /**
  32618. * Box-Imposter type
  32619. */
  32620. static BoxImpostor: number;
  32621. /**
  32622. * Plane-Imposter type
  32623. */
  32624. static PlaneImpostor: number;
  32625. /**
  32626. * Mesh-imposter type
  32627. */
  32628. static MeshImpostor: number;
  32629. /**
  32630. * Capsule-Impostor type (Ammo.js plugin only)
  32631. */
  32632. static CapsuleImpostor: number;
  32633. /**
  32634. * Cylinder-Imposter type
  32635. */
  32636. static CylinderImpostor: number;
  32637. /**
  32638. * Particle-Imposter type
  32639. */
  32640. static ParticleImpostor: number;
  32641. /**
  32642. * Heightmap-Imposter type
  32643. */
  32644. static HeightmapImpostor: number;
  32645. /**
  32646. * ConvexHull-Impostor type (Ammo.js plugin only)
  32647. */
  32648. static ConvexHullImpostor: number;
  32649. /**
  32650. * Custom-Imposter type (Ammo.js plugin only)
  32651. */
  32652. static CustomImpostor: number;
  32653. /**
  32654. * Rope-Imposter type
  32655. */
  32656. static RopeImpostor: number;
  32657. /**
  32658. * Cloth-Imposter type
  32659. */
  32660. static ClothImpostor: number;
  32661. /**
  32662. * Softbody-Imposter type
  32663. */
  32664. static SoftbodyImpostor: number;
  32665. }
  32666. }
  32667. declare module BABYLON {
  32668. /**
  32669. * @hidden
  32670. **/
  32671. export class _CreationDataStorage {
  32672. closePath?: boolean;
  32673. closeArray?: boolean;
  32674. idx: number[];
  32675. dashSize: number;
  32676. gapSize: number;
  32677. path3D: Path3D;
  32678. pathArray: Vector3[][];
  32679. arc: number;
  32680. radius: number;
  32681. cap: number;
  32682. tessellation: number;
  32683. }
  32684. /**
  32685. * @hidden
  32686. **/
  32687. class _InstanceDataStorage {
  32688. visibleInstances: any;
  32689. batchCache: _InstancesBatch;
  32690. instancesBufferSize: number;
  32691. instancesBuffer: Nullable<Buffer>;
  32692. instancesData: Float32Array;
  32693. overridenInstanceCount: number;
  32694. isFrozen: boolean;
  32695. previousBatch: Nullable<_InstancesBatch>;
  32696. hardwareInstancedRendering: boolean;
  32697. sideOrientation: number;
  32698. manualUpdate: boolean;
  32699. previousRenderId: number;
  32700. }
  32701. /**
  32702. * @hidden
  32703. **/
  32704. export class _InstancesBatch {
  32705. mustReturn: boolean;
  32706. visibleInstances: Nullable<InstancedMesh[]>[];
  32707. renderSelf: boolean[];
  32708. hardwareInstancedRendering: boolean[];
  32709. }
  32710. /**
  32711. * @hidden
  32712. **/
  32713. class _ThinInstanceDataStorage {
  32714. instancesCount: number;
  32715. matrixBuffer: Nullable<Buffer>;
  32716. matrixBufferSize: number;
  32717. matrixData: Nullable<Float32Array>;
  32718. boundingVectors: Array<Vector3>;
  32719. worldMatrices: Nullable<Matrix[]>;
  32720. }
  32721. /**
  32722. * Class used to represent renderable models
  32723. */
  32724. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  32725. /**
  32726. * Mesh side orientation : usually the external or front surface
  32727. */
  32728. static readonly FRONTSIDE: number;
  32729. /**
  32730. * Mesh side orientation : usually the internal or back surface
  32731. */
  32732. static readonly BACKSIDE: number;
  32733. /**
  32734. * Mesh side orientation : both internal and external or front and back surfaces
  32735. */
  32736. static readonly DOUBLESIDE: number;
  32737. /**
  32738. * Mesh side orientation : by default, `FRONTSIDE`
  32739. */
  32740. static readonly DEFAULTSIDE: number;
  32741. /**
  32742. * Mesh cap setting : no cap
  32743. */
  32744. static readonly NO_CAP: number;
  32745. /**
  32746. * Mesh cap setting : one cap at the beginning of the mesh
  32747. */
  32748. static readonly CAP_START: number;
  32749. /**
  32750. * Mesh cap setting : one cap at the end of the mesh
  32751. */
  32752. static readonly CAP_END: number;
  32753. /**
  32754. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  32755. */
  32756. static readonly CAP_ALL: number;
  32757. /**
  32758. * Mesh pattern setting : no flip or rotate
  32759. */
  32760. static readonly NO_FLIP: number;
  32761. /**
  32762. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  32763. */
  32764. static readonly FLIP_TILE: number;
  32765. /**
  32766. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  32767. */
  32768. static readonly ROTATE_TILE: number;
  32769. /**
  32770. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  32771. */
  32772. static readonly FLIP_ROW: number;
  32773. /**
  32774. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  32775. */
  32776. static readonly ROTATE_ROW: number;
  32777. /**
  32778. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  32779. */
  32780. static readonly FLIP_N_ROTATE_TILE: number;
  32781. /**
  32782. * Mesh pattern setting : rotate pattern and rotate
  32783. */
  32784. static readonly FLIP_N_ROTATE_ROW: number;
  32785. /**
  32786. * Mesh tile positioning : part tiles same on left/right or top/bottom
  32787. */
  32788. static readonly CENTER: number;
  32789. /**
  32790. * Mesh tile positioning : part tiles on left
  32791. */
  32792. static readonly LEFT: number;
  32793. /**
  32794. * Mesh tile positioning : part tiles on right
  32795. */
  32796. static readonly RIGHT: number;
  32797. /**
  32798. * Mesh tile positioning : part tiles on top
  32799. */
  32800. static readonly TOP: number;
  32801. /**
  32802. * Mesh tile positioning : part tiles on bottom
  32803. */
  32804. static readonly BOTTOM: number;
  32805. /**
  32806. * Gets the default side orientation.
  32807. * @param orientation the orientation to value to attempt to get
  32808. * @returns the default orientation
  32809. * @hidden
  32810. */
  32811. static _GetDefaultSideOrientation(orientation?: number): number;
  32812. private _internalMeshDataInfo;
  32813. get computeBonesUsingShaders(): boolean;
  32814. set computeBonesUsingShaders(value: boolean);
  32815. /**
  32816. * An event triggered before rendering the mesh
  32817. */
  32818. get onBeforeRenderObservable(): Observable<Mesh>;
  32819. /**
  32820. * An event triggered before binding the mesh
  32821. */
  32822. get onBeforeBindObservable(): Observable<Mesh>;
  32823. /**
  32824. * An event triggered after rendering the mesh
  32825. */
  32826. get onAfterRenderObservable(): Observable<Mesh>;
  32827. /**
  32828. * An event triggered before drawing the mesh
  32829. */
  32830. get onBeforeDrawObservable(): Observable<Mesh>;
  32831. private _onBeforeDrawObserver;
  32832. /**
  32833. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  32834. */
  32835. set onBeforeDraw(callback: () => void);
  32836. get hasInstances(): boolean;
  32837. get hasThinInstances(): boolean;
  32838. /**
  32839. * Gets the delay loading state of the mesh (when delay loading is turned on)
  32840. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  32841. */
  32842. delayLoadState: number;
  32843. /**
  32844. * Gets the list of instances created from this mesh
  32845. * it is not supposed to be modified manually.
  32846. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  32847. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  32848. */
  32849. instances: InstancedMesh[];
  32850. /**
  32851. * Gets the file containing delay loading data for this mesh
  32852. */
  32853. delayLoadingFile: string;
  32854. /** @hidden */
  32855. _binaryInfo: any;
  32856. /**
  32857. * User defined function used to change how LOD level selection is done
  32858. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32859. */
  32860. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  32861. /**
  32862. * Gets or sets the morph target manager
  32863. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32864. */
  32865. get morphTargetManager(): Nullable<MorphTargetManager>;
  32866. set morphTargetManager(value: Nullable<MorphTargetManager>);
  32867. /** @hidden */
  32868. _creationDataStorage: Nullable<_CreationDataStorage>;
  32869. /** @hidden */
  32870. _geometry: Nullable<Geometry>;
  32871. /** @hidden */
  32872. _delayInfo: Array<string>;
  32873. /** @hidden */
  32874. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  32875. /** @hidden */
  32876. _instanceDataStorage: _InstanceDataStorage;
  32877. /** @hidden */
  32878. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  32879. private _effectiveMaterial;
  32880. /** @hidden */
  32881. _shouldGenerateFlatShading: boolean;
  32882. /** @hidden */
  32883. _originalBuilderSideOrientation: number;
  32884. /**
  32885. * Use this property to change the original side orientation defined at construction time
  32886. */
  32887. overrideMaterialSideOrientation: Nullable<number>;
  32888. /**
  32889. * Gets the source mesh (the one used to clone this one from)
  32890. */
  32891. get source(): Nullable<Mesh>;
  32892. /**
  32893. * Gets the list of clones of this mesh
  32894. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  32895. * Note that useClonedMeshMap=true is the default setting
  32896. */
  32897. get cloneMeshMap(): Nullable<{
  32898. [id: string]: Mesh | undefined;
  32899. }>;
  32900. /**
  32901. * Gets or sets a boolean indicating that this mesh does not use index buffer
  32902. */
  32903. get isUnIndexed(): boolean;
  32904. set isUnIndexed(value: boolean);
  32905. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  32906. get worldMatrixInstancedBuffer(): Float32Array;
  32907. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  32908. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  32909. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  32910. /**
  32911. * @constructor
  32912. * @param name The value used by scene.getMeshByName() to do a lookup.
  32913. * @param scene The scene to add this mesh to.
  32914. * @param parent The parent of this mesh, if it has one
  32915. * @param source An optional Mesh from which geometry is shared, cloned.
  32916. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  32917. * When false, achieved by calling a clone(), also passing False.
  32918. * This will make creation of children, recursive.
  32919. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  32920. */
  32921. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  32922. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  32923. doNotInstantiate: boolean;
  32924. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  32925. /**
  32926. * Gets the class name
  32927. * @returns the string "Mesh".
  32928. */
  32929. getClassName(): string;
  32930. /** @hidden */
  32931. get _isMesh(): boolean;
  32932. /**
  32933. * Returns a description of this mesh
  32934. * @param fullDetails define if full details about this mesh must be used
  32935. * @returns a descriptive string representing this mesh
  32936. */
  32937. toString(fullDetails?: boolean): string;
  32938. /** @hidden */
  32939. _unBindEffect(): void;
  32940. /**
  32941. * Gets a boolean indicating if this mesh has LOD
  32942. */
  32943. get hasLODLevels(): boolean;
  32944. /**
  32945. * Gets the list of MeshLODLevel associated with the current mesh
  32946. * @returns an array of MeshLODLevel
  32947. */
  32948. getLODLevels(): MeshLODLevel[];
  32949. private _sortLODLevels;
  32950. /**
  32951. * Add a mesh as LOD level triggered at the given distance.
  32952. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32953. * @param distance The distance from the center of the object to show this level
  32954. * @param mesh The mesh to be added as LOD level (can be null)
  32955. * @return This mesh (for chaining)
  32956. */
  32957. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  32958. /**
  32959. * Returns the LOD level mesh at the passed distance or null if not found.
  32960. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32961. * @param distance The distance from the center of the object to show this level
  32962. * @returns a Mesh or `null`
  32963. */
  32964. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  32965. /**
  32966. * Remove a mesh from the LOD array
  32967. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32968. * @param mesh defines the mesh to be removed
  32969. * @return This mesh (for chaining)
  32970. */
  32971. removeLODLevel(mesh: Mesh): Mesh;
  32972. /**
  32973. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  32974. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32975. * @param camera defines the camera to use to compute distance
  32976. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  32977. * @return This mesh (for chaining)
  32978. */
  32979. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  32980. /**
  32981. * Gets the mesh internal Geometry object
  32982. */
  32983. get geometry(): Nullable<Geometry>;
  32984. /**
  32985. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  32986. * @returns the total number of vertices
  32987. */
  32988. getTotalVertices(): number;
  32989. /**
  32990. * Returns the content of an associated vertex buffer
  32991. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32992. * - VertexBuffer.PositionKind
  32993. * - VertexBuffer.UVKind
  32994. * - VertexBuffer.UV2Kind
  32995. * - VertexBuffer.UV3Kind
  32996. * - VertexBuffer.UV4Kind
  32997. * - VertexBuffer.UV5Kind
  32998. * - VertexBuffer.UV6Kind
  32999. * - VertexBuffer.ColorKind
  33000. * - VertexBuffer.MatricesIndicesKind
  33001. * - VertexBuffer.MatricesIndicesExtraKind
  33002. * - VertexBuffer.MatricesWeightsKind
  33003. * - VertexBuffer.MatricesWeightsExtraKind
  33004. * @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
  33005. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  33006. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  33007. */
  33008. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  33009. /**
  33010. * Returns the mesh VertexBuffer object from the requested `kind`
  33011. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33012. * - VertexBuffer.PositionKind
  33013. * - VertexBuffer.NormalKind
  33014. * - VertexBuffer.UVKind
  33015. * - VertexBuffer.UV2Kind
  33016. * - VertexBuffer.UV3Kind
  33017. * - VertexBuffer.UV4Kind
  33018. * - VertexBuffer.UV5Kind
  33019. * - VertexBuffer.UV6Kind
  33020. * - VertexBuffer.ColorKind
  33021. * - VertexBuffer.MatricesIndicesKind
  33022. * - VertexBuffer.MatricesIndicesExtraKind
  33023. * - VertexBuffer.MatricesWeightsKind
  33024. * - VertexBuffer.MatricesWeightsExtraKind
  33025. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  33026. */
  33027. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  33028. /**
  33029. * Tests if a specific vertex buffer is associated with this mesh
  33030. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33031. * - VertexBuffer.PositionKind
  33032. * - VertexBuffer.NormalKind
  33033. * - VertexBuffer.UVKind
  33034. * - VertexBuffer.UV2Kind
  33035. * - VertexBuffer.UV3Kind
  33036. * - VertexBuffer.UV4Kind
  33037. * - VertexBuffer.UV5Kind
  33038. * - VertexBuffer.UV6Kind
  33039. * - VertexBuffer.ColorKind
  33040. * - VertexBuffer.MatricesIndicesKind
  33041. * - VertexBuffer.MatricesIndicesExtraKind
  33042. * - VertexBuffer.MatricesWeightsKind
  33043. * - VertexBuffer.MatricesWeightsExtraKind
  33044. * @returns a boolean
  33045. */
  33046. isVerticesDataPresent(kind: string): boolean;
  33047. /**
  33048. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  33049. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33050. * - VertexBuffer.PositionKind
  33051. * - VertexBuffer.UVKind
  33052. * - VertexBuffer.UV2Kind
  33053. * - VertexBuffer.UV3Kind
  33054. * - VertexBuffer.UV4Kind
  33055. * - VertexBuffer.UV5Kind
  33056. * - VertexBuffer.UV6Kind
  33057. * - VertexBuffer.ColorKind
  33058. * - VertexBuffer.MatricesIndicesKind
  33059. * - VertexBuffer.MatricesIndicesExtraKind
  33060. * - VertexBuffer.MatricesWeightsKind
  33061. * - VertexBuffer.MatricesWeightsExtraKind
  33062. * @returns a boolean
  33063. */
  33064. isVertexBufferUpdatable(kind: string): boolean;
  33065. /**
  33066. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  33067. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33068. * - VertexBuffer.PositionKind
  33069. * - VertexBuffer.NormalKind
  33070. * - VertexBuffer.UVKind
  33071. * - VertexBuffer.UV2Kind
  33072. * - VertexBuffer.UV3Kind
  33073. * - VertexBuffer.UV4Kind
  33074. * - VertexBuffer.UV5Kind
  33075. * - VertexBuffer.UV6Kind
  33076. * - VertexBuffer.ColorKind
  33077. * - VertexBuffer.MatricesIndicesKind
  33078. * - VertexBuffer.MatricesIndicesExtraKind
  33079. * - VertexBuffer.MatricesWeightsKind
  33080. * - VertexBuffer.MatricesWeightsExtraKind
  33081. * @returns an array of strings
  33082. */
  33083. getVerticesDataKinds(): string[];
  33084. /**
  33085. * Returns a positive integer : the total number of indices in this mesh geometry.
  33086. * @returns the numner of indices or zero if the mesh has no geometry.
  33087. */
  33088. getTotalIndices(): number;
  33089. /**
  33090. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  33091. * @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.
  33092. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  33093. * @returns the indices array or an empty array if the mesh has no geometry
  33094. */
  33095. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  33096. get isBlocked(): boolean;
  33097. /**
  33098. * Determine if the current mesh is ready to be rendered
  33099. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33100. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  33101. * @returns true if all associated assets are ready (material, textures, shaders)
  33102. */
  33103. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  33104. /**
  33105. * 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.
  33106. */
  33107. get areNormalsFrozen(): boolean;
  33108. /**
  33109. * 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.
  33110. * @returns the current mesh
  33111. */
  33112. freezeNormals(): Mesh;
  33113. /**
  33114. * 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
  33115. * @returns the current mesh
  33116. */
  33117. unfreezeNormals(): Mesh;
  33118. /**
  33119. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  33120. */
  33121. set overridenInstanceCount(count: number);
  33122. /** @hidden */
  33123. _preActivate(): Mesh;
  33124. /** @hidden */
  33125. _preActivateForIntermediateRendering(renderId: number): Mesh;
  33126. /** @hidden */
  33127. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  33128. protected _afterComputeWorldMatrix(): void;
  33129. /** @hidden */
  33130. _postActivate(): void;
  33131. /**
  33132. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33133. * This means the mesh underlying bounding box and sphere are recomputed.
  33134. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33135. * @returns the current mesh
  33136. */
  33137. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  33138. /** @hidden */
  33139. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  33140. /**
  33141. * This function will subdivide the mesh into multiple submeshes
  33142. * @param count defines the expected number of submeshes
  33143. */
  33144. subdivide(count: number): void;
  33145. /**
  33146. * Copy a FloatArray into a specific associated vertex buffer
  33147. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33148. * - VertexBuffer.PositionKind
  33149. * - VertexBuffer.UVKind
  33150. * - VertexBuffer.UV2Kind
  33151. * - VertexBuffer.UV3Kind
  33152. * - VertexBuffer.UV4Kind
  33153. * - VertexBuffer.UV5Kind
  33154. * - VertexBuffer.UV6Kind
  33155. * - VertexBuffer.ColorKind
  33156. * - VertexBuffer.MatricesIndicesKind
  33157. * - VertexBuffer.MatricesIndicesExtraKind
  33158. * - VertexBuffer.MatricesWeightsKind
  33159. * - VertexBuffer.MatricesWeightsExtraKind
  33160. * @param data defines the data source
  33161. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33162. * @param stride defines the data stride size (can be null)
  33163. * @returns the current mesh
  33164. */
  33165. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33166. /**
  33167. * Delete a vertex buffer associated with this mesh
  33168. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  33169. * - VertexBuffer.PositionKind
  33170. * - VertexBuffer.UVKind
  33171. * - VertexBuffer.UV2Kind
  33172. * - VertexBuffer.UV3Kind
  33173. * - VertexBuffer.UV4Kind
  33174. * - VertexBuffer.UV5Kind
  33175. * - VertexBuffer.UV6Kind
  33176. * - VertexBuffer.ColorKind
  33177. * - VertexBuffer.MatricesIndicesKind
  33178. * - VertexBuffer.MatricesIndicesExtraKind
  33179. * - VertexBuffer.MatricesWeightsKind
  33180. * - VertexBuffer.MatricesWeightsExtraKind
  33181. */
  33182. removeVerticesData(kind: string): void;
  33183. /**
  33184. * Flags an associated vertex buffer as updatable
  33185. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  33186. * - VertexBuffer.PositionKind
  33187. * - VertexBuffer.UVKind
  33188. * - VertexBuffer.UV2Kind
  33189. * - VertexBuffer.UV3Kind
  33190. * - VertexBuffer.UV4Kind
  33191. * - VertexBuffer.UV5Kind
  33192. * - VertexBuffer.UV6Kind
  33193. * - VertexBuffer.ColorKind
  33194. * - VertexBuffer.MatricesIndicesKind
  33195. * - VertexBuffer.MatricesIndicesExtraKind
  33196. * - VertexBuffer.MatricesWeightsKind
  33197. * - VertexBuffer.MatricesWeightsExtraKind
  33198. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33199. */
  33200. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  33201. /**
  33202. * Sets the mesh global Vertex Buffer
  33203. * @param buffer defines the buffer to use
  33204. * @returns the current mesh
  33205. */
  33206. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  33207. /**
  33208. * Update a specific associated vertex buffer
  33209. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33210. * - VertexBuffer.PositionKind
  33211. * - VertexBuffer.UVKind
  33212. * - VertexBuffer.UV2Kind
  33213. * - VertexBuffer.UV3Kind
  33214. * - VertexBuffer.UV4Kind
  33215. * - VertexBuffer.UV5Kind
  33216. * - VertexBuffer.UV6Kind
  33217. * - VertexBuffer.ColorKind
  33218. * - VertexBuffer.MatricesIndicesKind
  33219. * - VertexBuffer.MatricesIndicesExtraKind
  33220. * - VertexBuffer.MatricesWeightsKind
  33221. * - VertexBuffer.MatricesWeightsExtraKind
  33222. * @param data defines the data source
  33223. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  33224. * @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)
  33225. * @returns the current mesh
  33226. */
  33227. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  33228. /**
  33229. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  33230. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  33231. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  33232. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  33233. * @returns the current mesh
  33234. */
  33235. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  33236. /**
  33237. * Creates a un-shared specific occurence of the geometry for the mesh.
  33238. * @returns the current mesh
  33239. */
  33240. makeGeometryUnique(): Mesh;
  33241. /**
  33242. * Set the index buffer of this mesh
  33243. * @param indices defines the source data
  33244. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  33245. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  33246. * @returns the current mesh
  33247. */
  33248. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  33249. /**
  33250. * Update the current index buffer
  33251. * @param indices defines the source data
  33252. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  33253. * @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)
  33254. * @returns the current mesh
  33255. */
  33256. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  33257. /**
  33258. * Invert the geometry to move from a right handed system to a left handed one.
  33259. * @returns the current mesh
  33260. */
  33261. toLeftHanded(): Mesh;
  33262. /** @hidden */
  33263. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  33264. /** @hidden */
  33265. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  33266. /**
  33267. * Registers for this mesh a javascript function called just before the rendering process
  33268. * @param func defines the function to call before rendering this mesh
  33269. * @returns the current mesh
  33270. */
  33271. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  33272. /**
  33273. * Disposes a previously registered javascript function called before the rendering
  33274. * @param func defines the function to remove
  33275. * @returns the current mesh
  33276. */
  33277. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  33278. /**
  33279. * Registers for this mesh a javascript function called just after the rendering is complete
  33280. * @param func defines the function to call after rendering this mesh
  33281. * @returns the current mesh
  33282. */
  33283. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33284. /**
  33285. * Disposes a previously registered javascript function called after the rendering.
  33286. * @param func defines the function to remove
  33287. * @returns the current mesh
  33288. */
  33289. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33290. /** @hidden */
  33291. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  33292. /** @hidden */
  33293. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  33294. /** @hidden */
  33295. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  33296. /** @hidden */
  33297. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  33298. /** @hidden */
  33299. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  33300. /** @hidden */
  33301. _rebuild(): void;
  33302. /** @hidden */
  33303. _freeze(): void;
  33304. /** @hidden */
  33305. _unFreeze(): void;
  33306. /**
  33307. * 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
  33308. * @param subMesh defines the subMesh to render
  33309. * @param enableAlphaMode defines if alpha mode can be changed
  33310. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  33311. * @returns the current mesh
  33312. */
  33313. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  33314. private _onBeforeDraw;
  33315. /**
  33316. * Renormalize the mesh and patch it up if there are no weights
  33317. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  33318. * However in the case of zero weights then we set just a single influence to 1.
  33319. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  33320. */
  33321. cleanMatrixWeights(): void;
  33322. private normalizeSkinFourWeights;
  33323. private normalizeSkinWeightsAndExtra;
  33324. /**
  33325. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  33326. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  33327. * the user know there was an issue with importing the mesh
  33328. * @returns a validation object with skinned, valid and report string
  33329. */
  33330. validateSkinning(): {
  33331. skinned: boolean;
  33332. valid: boolean;
  33333. report: string;
  33334. };
  33335. /** @hidden */
  33336. _checkDelayState(): Mesh;
  33337. private _queueLoad;
  33338. /**
  33339. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  33340. * A mesh is in the frustum if its bounding box intersects the frustum
  33341. * @param frustumPlanes defines the frustum to test
  33342. * @returns true if the mesh is in the frustum planes
  33343. */
  33344. isInFrustum(frustumPlanes: Plane[]): boolean;
  33345. /**
  33346. * Sets the mesh material by the material or multiMaterial `id` property
  33347. * @param id is a string identifying the material or the multiMaterial
  33348. * @returns the current mesh
  33349. */
  33350. setMaterialByID(id: string): Mesh;
  33351. /**
  33352. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  33353. * @returns an array of IAnimatable
  33354. */
  33355. getAnimatables(): IAnimatable[];
  33356. /**
  33357. * Modifies the mesh geometry according to the passed transformation matrix.
  33358. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  33359. * The mesh normals are modified using the same transformation.
  33360. * Note that, under the hood, this method sets a new VertexBuffer each call.
  33361. * @param transform defines the transform matrix to use
  33362. * @see https://doc.babylonjs.com/resources/baking_transformations
  33363. * @returns the current mesh
  33364. */
  33365. bakeTransformIntoVertices(transform: Matrix): Mesh;
  33366. /**
  33367. * Modifies the mesh geometry according to its own current World Matrix.
  33368. * The mesh World Matrix is then reset.
  33369. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  33370. * Note that, under the hood, this method sets a new VertexBuffer each call.
  33371. * @see https://doc.babylonjs.com/resources/baking_transformations
  33372. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  33373. * @returns the current mesh
  33374. */
  33375. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  33376. /** @hidden */
  33377. get _positions(): Nullable<Vector3[]>;
  33378. /** @hidden */
  33379. _resetPointsArrayCache(): Mesh;
  33380. /** @hidden */
  33381. _generatePointsArray(): boolean;
  33382. /**
  33383. * Returns a new Mesh object generated from the current mesh properties.
  33384. * This method must not get confused with createInstance()
  33385. * @param name is a string, the name given to the new mesh
  33386. * @param newParent can be any Node object (default `null`)
  33387. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  33388. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  33389. * @returns a new mesh
  33390. */
  33391. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  33392. /**
  33393. * Releases resources associated with this mesh.
  33394. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33395. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33396. */
  33397. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33398. /** @hidden */
  33399. _disposeInstanceSpecificData(): void;
  33400. /** @hidden */
  33401. _disposeThinInstanceSpecificData(): void;
  33402. /**
  33403. * Modifies the mesh geometry according to a displacement map.
  33404. * 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.
  33405. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  33406. * @param url is a string, the URL from the image file is to be downloaded.
  33407. * @param minHeight is the lower limit of the displacement.
  33408. * @param maxHeight is the upper limit of the displacement.
  33409. * @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.
  33410. * @param uvOffset is an optional vector2 used to offset UV.
  33411. * @param uvScale is an optional vector2 used to scale UV.
  33412. * @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.
  33413. * @returns the Mesh.
  33414. */
  33415. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33416. /**
  33417. * Modifies the mesh geometry according to a displacementMap buffer.
  33418. * 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.
  33419. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  33420. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  33421. * @param heightMapWidth is the width of the buffer image.
  33422. * @param heightMapHeight is the height of the buffer image.
  33423. * @param minHeight is the lower limit of the displacement.
  33424. * @param maxHeight is the upper limit of the displacement.
  33425. * @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.
  33426. * @param uvOffset is an optional vector2 used to offset UV.
  33427. * @param uvScale is an optional vector2 used to scale UV.
  33428. * @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.
  33429. * @returns the Mesh.
  33430. */
  33431. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33432. /**
  33433. * Modify the mesh to get a flat shading rendering.
  33434. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  33435. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  33436. * @returns current mesh
  33437. */
  33438. convertToFlatShadedMesh(): Mesh;
  33439. /**
  33440. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  33441. * In other words, more vertices, no more indices and a single bigger VBO.
  33442. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  33443. * @returns current mesh
  33444. */
  33445. convertToUnIndexedMesh(): Mesh;
  33446. /**
  33447. * Inverses facet orientations.
  33448. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33449. * @param flipNormals will also inverts the normals
  33450. * @returns current mesh
  33451. */
  33452. flipFaces(flipNormals?: boolean): Mesh;
  33453. /**
  33454. * Increase the number of facets and hence vertices in a mesh
  33455. * Vertex normals are interpolated from existing vertex normals
  33456. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33457. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  33458. */
  33459. increaseVertices(numberPerEdge: number): void;
  33460. /**
  33461. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  33462. * This will undo any application of covertToFlatShadedMesh
  33463. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33464. */
  33465. forceSharedVertices(): void;
  33466. /** @hidden */
  33467. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  33468. /** @hidden */
  33469. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  33470. /**
  33471. * Creates a new InstancedMesh object from the mesh model.
  33472. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33473. * @param name defines the name of the new instance
  33474. * @returns a new InstancedMesh
  33475. */
  33476. createInstance(name: string): InstancedMesh;
  33477. /**
  33478. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  33479. * After this call, all the mesh instances have the same submeshes than the current mesh.
  33480. * @returns the current mesh
  33481. */
  33482. synchronizeInstances(): Mesh;
  33483. /**
  33484. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  33485. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  33486. * This should be used together with the simplification to avoid disappearing triangles.
  33487. * @param successCallback an optional success callback to be called after the optimization finished.
  33488. * @returns the current mesh
  33489. */
  33490. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  33491. /**
  33492. * Serialize current mesh
  33493. * @param serializationObject defines the object which will receive the serialization data
  33494. */
  33495. serialize(serializationObject: any): void;
  33496. /** @hidden */
  33497. _syncGeometryWithMorphTargetManager(): void;
  33498. /** @hidden */
  33499. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  33500. /**
  33501. * Returns a new Mesh object parsed from the source provided.
  33502. * @param parsedMesh is the source
  33503. * @param scene defines the hosting scene
  33504. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  33505. * @returns a new Mesh
  33506. */
  33507. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  33508. /**
  33509. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  33510. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33511. * @param name defines the name of the mesh to create
  33512. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  33513. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  33514. * @param closePath creates a seam between the first and the last points of each path of the path array
  33515. * @param offset is taken in account only if the `pathArray` is containing a single path
  33516. * @param scene defines the hosting scene
  33517. * @param updatable defines if the mesh must be flagged as updatable
  33518. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33519. * @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)
  33520. * @returns a new Mesh
  33521. */
  33522. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33523. /**
  33524. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  33525. * @param name defines the name of the mesh to create
  33526. * @param radius sets the radius size (float) of the polygon (default 0.5)
  33527. * @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
  33528. * @param scene defines the hosting scene
  33529. * @param updatable defines if the mesh must be flagged as updatable
  33530. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33531. * @returns a new Mesh
  33532. */
  33533. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33534. /**
  33535. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  33536. * @param name defines the name of the mesh to create
  33537. * @param size sets the size (float) of each box side (default 1)
  33538. * @param scene defines the hosting scene
  33539. * @param updatable defines if the mesh must be flagged as updatable
  33540. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33541. * @returns a new Mesh
  33542. */
  33543. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33544. /**
  33545. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  33546. * @param name defines the name of the mesh to create
  33547. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33548. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33549. * @param scene defines the hosting scene
  33550. * @param updatable defines if the mesh must be flagged as updatable
  33551. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33552. * @returns a new Mesh
  33553. */
  33554. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33555. /**
  33556. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  33557. * @param name defines the name of the mesh to create
  33558. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33559. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33560. * @param scene defines the hosting scene
  33561. * @returns a new Mesh
  33562. */
  33563. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  33564. /**
  33565. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  33566. * @param name defines the name of the mesh to create
  33567. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  33568. * @param diameterTop set the top cap diameter (floats, default 1)
  33569. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  33570. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  33571. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  33572. * @param scene defines the hosting scene
  33573. * @param updatable defines if the mesh must be flagged as updatable
  33574. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33575. * @returns a new Mesh
  33576. */
  33577. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  33578. /**
  33579. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  33580. * @param name defines the name of the mesh to create
  33581. * @param diameter sets the diameter size (float) of the torus (default 1)
  33582. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  33583. * @param tessellation sets the number of torus sides (postive integer, default 16)
  33584. * @param scene defines the hosting scene
  33585. * @param updatable defines if the mesh must be flagged as updatable
  33586. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33587. * @returns a new Mesh
  33588. */
  33589. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33590. /**
  33591. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  33592. * @param name defines the name of the mesh to create
  33593. * @param radius sets the global radius size (float) of the torus knot (default 2)
  33594. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  33595. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  33596. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  33597. * @param p the number of windings on X axis (positive integers, default 2)
  33598. * @param q the number of windings on Y axis (positive integers, default 3)
  33599. * @param scene defines the hosting scene
  33600. * @param updatable defines if the mesh must be flagged as updatable
  33601. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33602. * @returns a new Mesh
  33603. */
  33604. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33605. /**
  33606. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  33607. * @param name defines the name of the mesh to create
  33608. * @param points is an array successive Vector3
  33609. * @param scene defines the hosting scene
  33610. * @param updatable defines if the mesh must be flagged as updatable
  33611. * @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).
  33612. * @returns a new Mesh
  33613. */
  33614. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  33615. /**
  33616. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  33617. * @param name defines the name of the mesh to create
  33618. * @param points is an array successive Vector3
  33619. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  33620. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  33621. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  33622. * @param scene defines the hosting scene
  33623. * @param updatable defines if the mesh must be flagged as updatable
  33624. * @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)
  33625. * @returns a new Mesh
  33626. */
  33627. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  33628. /**
  33629. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  33630. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  33631. * 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.
  33632. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33633. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  33634. * Remember you can only change the shape positions, not their number when updating a polygon.
  33635. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  33636. * @param name defines the name of the mesh to create
  33637. * @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
  33638. * @param scene defines the hosting scene
  33639. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33640. * @param updatable defines if the mesh must be flagged as updatable
  33641. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33642. * @param earcutInjection can be used to inject your own earcut reference
  33643. * @returns a new Mesh
  33644. */
  33645. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33646. /**
  33647. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  33648. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  33649. * @param name defines the name of the mesh to create
  33650. * @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
  33651. * @param depth defines the height of extrusion
  33652. * @param scene defines the hosting scene
  33653. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33654. * @param updatable defines if the mesh must be flagged as updatable
  33655. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33656. * @param earcutInjection can be used to inject your own earcut reference
  33657. * @returns a new Mesh
  33658. */
  33659. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33660. /**
  33661. * Creates an extruded shape mesh.
  33662. * 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
  33663. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33664. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33665. * @param name defines the name of the mesh to create
  33666. * @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
  33667. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33668. * @param scale is the value to scale the shape
  33669. * @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
  33670. * @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
  33671. * @param scene defines the hosting scene
  33672. * @param updatable defines if the mesh must be flagged as updatable
  33673. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33674. * @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)
  33675. * @returns a new Mesh
  33676. */
  33677. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33678. /**
  33679. * Creates an custom extruded shape mesh.
  33680. * The custom extrusion is a parametric shape.
  33681. * It has no predefined shape. Its final shape will depend on the input parameters.
  33682. * Please consider using the same method from the MeshBuilder class instead
  33683. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33684. * @param name defines the name of the mesh to create
  33685. * @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
  33686. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33687. * @param scaleFunction is a custom Javascript function called on each path point
  33688. * @param rotationFunction is a custom Javascript function called on each path point
  33689. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  33690. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  33691. * @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
  33692. * @param scene defines the hosting scene
  33693. * @param updatable defines if the mesh must be flagged as updatable
  33694. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33695. * @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)
  33696. * @returns a new Mesh
  33697. */
  33698. 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;
  33699. /**
  33700. * Creates lathe mesh.
  33701. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  33702. * Please consider using the same method from the MeshBuilder class instead
  33703. * @param name defines the name of the mesh to create
  33704. * @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
  33705. * @param radius is the radius value of the lathe
  33706. * @param tessellation is the side number of the lathe.
  33707. * @param scene defines the hosting scene
  33708. * @param updatable defines if the mesh must be flagged as updatable
  33709. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33710. * @returns a new Mesh
  33711. */
  33712. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33713. /**
  33714. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  33715. * @param name defines the name of the mesh to create
  33716. * @param size sets the size (float) of both sides of the plane at once (default 1)
  33717. * @param scene defines the hosting scene
  33718. * @param updatable defines if the mesh must be flagged as updatable
  33719. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33720. * @returns a new Mesh
  33721. */
  33722. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33723. /**
  33724. * Creates a ground mesh.
  33725. * Please consider using the same method from the MeshBuilder class instead
  33726. * @param name defines the name of the mesh to create
  33727. * @param width set the width of the ground
  33728. * @param height set the height of the ground
  33729. * @param subdivisions sets the number of subdivisions per side
  33730. * @param scene defines the hosting scene
  33731. * @param updatable defines if the mesh must be flagged as updatable
  33732. * @returns a new Mesh
  33733. */
  33734. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  33735. /**
  33736. * Creates a tiled ground mesh.
  33737. * Please consider using the same method from the MeshBuilder class instead
  33738. * @param name defines the name of the mesh to create
  33739. * @param xmin set the ground minimum X coordinate
  33740. * @param zmin set the ground minimum Y coordinate
  33741. * @param xmax set the ground maximum X coordinate
  33742. * @param zmax set the ground maximum Z coordinate
  33743. * @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
  33744. * @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
  33745. * @param scene defines the hosting scene
  33746. * @param updatable defines if the mesh must be flagged as updatable
  33747. * @returns a new Mesh
  33748. */
  33749. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  33750. w: number;
  33751. h: number;
  33752. }, precision: {
  33753. w: number;
  33754. h: number;
  33755. }, scene: Scene, updatable?: boolean): Mesh;
  33756. /**
  33757. * Creates a ground mesh from a height map.
  33758. * Please consider using the same method from the MeshBuilder class instead
  33759. * @see https://doc.babylonjs.com/babylon101/height_map
  33760. * @param name defines the name of the mesh to create
  33761. * @param url sets the URL of the height map image resource
  33762. * @param width set the ground width size
  33763. * @param height set the ground height size
  33764. * @param subdivisions sets the number of subdivision per side
  33765. * @param minHeight is the minimum altitude on the ground
  33766. * @param maxHeight is the maximum altitude on the ground
  33767. * @param scene defines the hosting scene
  33768. * @param updatable defines if the mesh must be flagged as updatable
  33769. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  33770. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  33771. * @returns a new Mesh
  33772. */
  33773. 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;
  33774. /**
  33775. * Creates a tube mesh.
  33776. * The tube is a parametric shape.
  33777. * It has no predefined shape. Its final shape will depend on the input parameters.
  33778. * Please consider using the same method from the MeshBuilder class instead
  33779. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33780. * @param name defines the name of the mesh to create
  33781. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  33782. * @param radius sets the tube radius size
  33783. * @param tessellation is the number of sides on the tubular surface
  33784. * @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
  33785. * @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
  33786. * @param scene defines the hosting scene
  33787. * @param updatable defines if the mesh must be flagged as updatable
  33788. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33789. * @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)
  33790. * @returns a new Mesh
  33791. */
  33792. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  33793. (i: number, distance: number): number;
  33794. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33795. /**
  33796. * Creates a polyhedron mesh.
  33797. * Please consider using the same method from the MeshBuilder class instead.
  33798. * * 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
  33799. * * The parameter `size` (positive float, default 1) sets the polygon size
  33800. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  33801. * * 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`
  33802. * * 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
  33803. * * 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)`)
  33804. * * 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
  33805. * * 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
  33806. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33807. * * 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
  33808. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33809. * @param name defines the name of the mesh to create
  33810. * @param options defines the options used to create the mesh
  33811. * @param scene defines the hosting scene
  33812. * @returns a new Mesh
  33813. */
  33814. static CreatePolyhedron(name: string, options: {
  33815. type?: number;
  33816. size?: number;
  33817. sizeX?: number;
  33818. sizeY?: number;
  33819. sizeZ?: number;
  33820. custom?: any;
  33821. faceUV?: Vector4[];
  33822. faceColors?: Color4[];
  33823. updatable?: boolean;
  33824. sideOrientation?: number;
  33825. }, scene: Scene): Mesh;
  33826. /**
  33827. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  33828. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  33829. * * 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`)
  33830. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  33831. * * 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
  33832. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33833. * * 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
  33834. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33835. * @param name defines the name of the mesh
  33836. * @param options defines the options used to create the mesh
  33837. * @param scene defines the hosting scene
  33838. * @returns a new Mesh
  33839. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  33840. */
  33841. static CreateIcoSphere(name: string, options: {
  33842. radius?: number;
  33843. flat?: boolean;
  33844. subdivisions?: number;
  33845. sideOrientation?: number;
  33846. updatable?: boolean;
  33847. }, scene: Scene): Mesh;
  33848. /**
  33849. * Creates a decal mesh.
  33850. * Please consider using the same method from the MeshBuilder class instead.
  33851. * A decal is a mesh usually applied as a model onto the surface of another mesh
  33852. * @param name defines the name of the mesh
  33853. * @param sourceMesh defines the mesh receiving the decal
  33854. * @param position sets the position of the decal in world coordinates
  33855. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  33856. * @param size sets the decal scaling
  33857. * @param angle sets the angle to rotate the decal
  33858. * @returns a new Mesh
  33859. */
  33860. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  33861. /** Creates a Capsule Mesh
  33862. * @param name defines the name of the mesh.
  33863. * @param options the constructors options used to shape the mesh.
  33864. * @param scene defines the scene the mesh is scoped to.
  33865. * @returns the capsule mesh
  33866. * @see https://doc.babylonjs.com/how_to/capsule_shape
  33867. */
  33868. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  33869. /**
  33870. * Prepare internal position array for software CPU skinning
  33871. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  33872. */
  33873. setPositionsForCPUSkinning(): Float32Array;
  33874. /**
  33875. * Prepare internal normal array for software CPU skinning
  33876. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  33877. */
  33878. setNormalsForCPUSkinning(): Float32Array;
  33879. /**
  33880. * Updates the vertex buffer by applying transformation from the bones
  33881. * @param skeleton defines the skeleton to apply to current mesh
  33882. * @returns the current mesh
  33883. */
  33884. applySkeleton(skeleton: Skeleton): Mesh;
  33885. /**
  33886. * 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
  33887. * @param meshes defines the list of meshes to scan
  33888. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  33889. */
  33890. static MinMax(meshes: AbstractMesh[]): {
  33891. min: Vector3;
  33892. max: Vector3;
  33893. };
  33894. /**
  33895. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  33896. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  33897. * @returns a vector3
  33898. */
  33899. static Center(meshesOrMinMaxVector: {
  33900. min: Vector3;
  33901. max: Vector3;
  33902. } | AbstractMesh[]): Vector3;
  33903. /**
  33904. * Merge the array of meshes into a single mesh for performance reasons.
  33905. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  33906. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  33907. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  33908. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  33909. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  33910. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  33911. * @returns a new mesh
  33912. */
  33913. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  33914. /** @hidden */
  33915. addInstance(instance: InstancedMesh): void;
  33916. /** @hidden */
  33917. removeInstance(instance: InstancedMesh): void;
  33918. }
  33919. }
  33920. declare module BABYLON {
  33921. /**
  33922. * This is the base class of all the camera used in the application.
  33923. * @see https://doc.babylonjs.com/features/cameras
  33924. */
  33925. export class Camera extends Node {
  33926. /** @hidden */
  33927. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  33928. /**
  33929. * This is the default projection mode used by the cameras.
  33930. * It helps recreating a feeling of perspective and better appreciate depth.
  33931. * This is the best way to simulate real life cameras.
  33932. */
  33933. static readonly PERSPECTIVE_CAMERA: number;
  33934. /**
  33935. * This helps creating camera with an orthographic mode.
  33936. * 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.
  33937. */
  33938. static readonly ORTHOGRAPHIC_CAMERA: number;
  33939. /**
  33940. * This is the default FOV mode for perspective cameras.
  33941. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  33942. */
  33943. static readonly FOVMODE_VERTICAL_FIXED: number;
  33944. /**
  33945. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  33946. */
  33947. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  33948. /**
  33949. * This specifies ther is no need for a camera rig.
  33950. * Basically only one eye is rendered corresponding to the camera.
  33951. */
  33952. static readonly RIG_MODE_NONE: number;
  33953. /**
  33954. * Simulates a camera Rig with one blue eye and one red eye.
  33955. * This can be use with 3d blue and red glasses.
  33956. */
  33957. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  33958. /**
  33959. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  33960. */
  33961. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  33962. /**
  33963. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  33964. */
  33965. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  33966. /**
  33967. * Defines that both eyes of the camera will be rendered over under each other.
  33968. */
  33969. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  33970. /**
  33971. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  33972. */
  33973. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  33974. /**
  33975. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  33976. */
  33977. static readonly RIG_MODE_VR: number;
  33978. /**
  33979. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  33980. */
  33981. static readonly RIG_MODE_WEBVR: number;
  33982. /**
  33983. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  33984. */
  33985. static readonly RIG_MODE_CUSTOM: number;
  33986. /**
  33987. * Defines if by default attaching controls should prevent the default javascript event to continue.
  33988. */
  33989. static ForceAttachControlToAlwaysPreventDefault: boolean;
  33990. /**
  33991. * Define the input manager associated with the camera.
  33992. */
  33993. inputs: CameraInputsManager<Camera>;
  33994. /** @hidden */
  33995. _position: Vector3;
  33996. /**
  33997. * Define the current local position of the camera in the scene
  33998. */
  33999. get position(): Vector3;
  34000. set position(newPosition: Vector3);
  34001. protected _upVector: Vector3;
  34002. /**
  34003. * The vector the camera should consider as up.
  34004. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  34005. */
  34006. set upVector(vec: Vector3);
  34007. get upVector(): Vector3;
  34008. /**
  34009. * Define the current limit on the left side for an orthographic camera
  34010. * In scene unit
  34011. */
  34012. orthoLeft: Nullable<number>;
  34013. /**
  34014. * Define the current limit on the right side for an orthographic camera
  34015. * In scene unit
  34016. */
  34017. orthoRight: Nullable<number>;
  34018. /**
  34019. * Define the current limit on the bottom side for an orthographic camera
  34020. * In scene unit
  34021. */
  34022. orthoBottom: Nullable<number>;
  34023. /**
  34024. * Define the current limit on the top side for an orthographic camera
  34025. * In scene unit
  34026. */
  34027. orthoTop: Nullable<number>;
  34028. /**
  34029. * Field Of View is set in Radians. (default is 0.8)
  34030. */
  34031. fov: number;
  34032. /**
  34033. * Define the minimum distance the camera can see from.
  34034. * This is important to note that the depth buffer are not infinite and the closer it starts
  34035. * the more your scene might encounter depth fighting issue.
  34036. */
  34037. minZ: number;
  34038. /**
  34039. * Define the maximum distance the camera can see to.
  34040. * This is important to note that the depth buffer are not infinite and the further it end
  34041. * the more your scene might encounter depth fighting issue.
  34042. */
  34043. maxZ: number;
  34044. /**
  34045. * Define the default inertia of the camera.
  34046. * This helps giving a smooth feeling to the camera movement.
  34047. */
  34048. inertia: number;
  34049. /**
  34050. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  34051. */
  34052. mode: number;
  34053. /**
  34054. * Define whether the camera is intermediate.
  34055. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  34056. */
  34057. isIntermediate: boolean;
  34058. /**
  34059. * Define the viewport of the camera.
  34060. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  34061. */
  34062. viewport: Viewport;
  34063. /**
  34064. * Restricts the camera to viewing objects with the same layerMask.
  34065. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  34066. */
  34067. layerMask: number;
  34068. /**
  34069. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  34070. */
  34071. fovMode: number;
  34072. /**
  34073. * Rig mode of the camera.
  34074. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  34075. * This is normally controlled byt the camera themselves as internal use.
  34076. */
  34077. cameraRigMode: number;
  34078. /**
  34079. * Defines the distance between both "eyes" in case of a RIG
  34080. */
  34081. interaxialDistance: number;
  34082. /**
  34083. * Defines if stereoscopic rendering is done side by side or over under.
  34084. */
  34085. isStereoscopicSideBySide: boolean;
  34086. /**
  34087. * 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
  34088. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  34089. * else in the scene. (Eg. security camera)
  34090. *
  34091. * 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)
  34092. */
  34093. customRenderTargets: RenderTargetTexture[];
  34094. /**
  34095. * When set, the camera will render to this render target instead of the default canvas
  34096. *
  34097. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  34098. */
  34099. outputRenderTarget: Nullable<RenderTargetTexture>;
  34100. /**
  34101. * Observable triggered when the camera view matrix has changed.
  34102. */
  34103. onViewMatrixChangedObservable: Observable<Camera>;
  34104. /**
  34105. * Observable triggered when the camera Projection matrix has changed.
  34106. */
  34107. onProjectionMatrixChangedObservable: Observable<Camera>;
  34108. /**
  34109. * Observable triggered when the inputs have been processed.
  34110. */
  34111. onAfterCheckInputsObservable: Observable<Camera>;
  34112. /**
  34113. * Observable triggered when reset has been called and applied to the camera.
  34114. */
  34115. onRestoreStateObservable: Observable<Camera>;
  34116. /**
  34117. * Is this camera a part of a rig system?
  34118. */
  34119. isRigCamera: boolean;
  34120. /**
  34121. * If isRigCamera set to true this will be set with the parent camera.
  34122. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  34123. */
  34124. rigParent?: Camera;
  34125. /** @hidden */
  34126. _cameraRigParams: any;
  34127. /** @hidden */
  34128. _rigCameras: Camera[];
  34129. /** @hidden */
  34130. _rigPostProcess: Nullable<PostProcess>;
  34131. protected _webvrViewMatrix: Matrix;
  34132. /** @hidden */
  34133. _skipRendering: boolean;
  34134. /** @hidden */
  34135. _projectionMatrix: Matrix;
  34136. /** @hidden */
  34137. _postProcesses: Nullable<PostProcess>[];
  34138. /** @hidden */
  34139. _activeMeshes: SmartArray<AbstractMesh>;
  34140. protected _globalPosition: Vector3;
  34141. /** @hidden */
  34142. _computedViewMatrix: Matrix;
  34143. private _doNotComputeProjectionMatrix;
  34144. private _transformMatrix;
  34145. private _frustumPlanes;
  34146. private _refreshFrustumPlanes;
  34147. private _storedFov;
  34148. private _stateStored;
  34149. /**
  34150. * Instantiates a new camera object.
  34151. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  34152. * @see https://doc.babylonjs.com/features/cameras
  34153. * @param name Defines the name of the camera in the scene
  34154. * @param position Defines the position of the camera
  34155. * @param scene Defines the scene the camera belongs too
  34156. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  34157. */
  34158. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  34159. /**
  34160. * Store current camera state (fov, position, etc..)
  34161. * @returns the camera
  34162. */
  34163. storeState(): Camera;
  34164. /**
  34165. * Restores the camera state values if it has been stored. You must call storeState() first
  34166. */
  34167. protected _restoreStateValues(): boolean;
  34168. /**
  34169. * Restored camera state. You must call storeState() first.
  34170. * @returns true if restored and false otherwise
  34171. */
  34172. restoreState(): boolean;
  34173. /**
  34174. * Gets the class name of the camera.
  34175. * @returns the class name
  34176. */
  34177. getClassName(): string;
  34178. /** @hidden */
  34179. readonly _isCamera: boolean;
  34180. /**
  34181. * Gets a string representation of the camera useful for debug purpose.
  34182. * @param fullDetails Defines that a more verboe level of logging is required
  34183. * @returns the string representation
  34184. */
  34185. toString(fullDetails?: boolean): string;
  34186. /**
  34187. * Gets the current world space position of the camera.
  34188. */
  34189. get globalPosition(): Vector3;
  34190. /**
  34191. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  34192. * @returns the active meshe list
  34193. */
  34194. getActiveMeshes(): SmartArray<AbstractMesh>;
  34195. /**
  34196. * Check whether a mesh is part of the current active mesh list of the camera
  34197. * @param mesh Defines the mesh to check
  34198. * @returns true if active, false otherwise
  34199. */
  34200. isActiveMesh(mesh: Mesh): boolean;
  34201. /**
  34202. * Is this camera ready to be used/rendered
  34203. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  34204. * @return true if the camera is ready
  34205. */
  34206. isReady(completeCheck?: boolean): boolean;
  34207. /** @hidden */
  34208. _initCache(): void;
  34209. /** @hidden */
  34210. _updateCache(ignoreParentClass?: boolean): void;
  34211. /** @hidden */
  34212. _isSynchronized(): boolean;
  34213. /** @hidden */
  34214. _isSynchronizedViewMatrix(): boolean;
  34215. /** @hidden */
  34216. _isSynchronizedProjectionMatrix(): boolean;
  34217. /**
  34218. * Attach the input controls to a specific dom element to get the input from.
  34219. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34220. */
  34221. attachControl(noPreventDefault?: boolean): void;
  34222. /**
  34223. * Detach the current controls from the specified dom element.
  34224. */
  34225. detachControl(): void;
  34226. /**
  34227. * Update the camera state according to the different inputs gathered during the frame.
  34228. */
  34229. update(): void;
  34230. /** @hidden */
  34231. _checkInputs(): void;
  34232. /** @hidden */
  34233. get rigCameras(): Camera[];
  34234. /**
  34235. * Gets the post process used by the rig cameras
  34236. */
  34237. get rigPostProcess(): Nullable<PostProcess>;
  34238. /**
  34239. * Internal, gets the first post proces.
  34240. * @returns the first post process to be run on this camera.
  34241. */
  34242. _getFirstPostProcess(): Nullable<PostProcess>;
  34243. private _cascadePostProcessesToRigCams;
  34244. /**
  34245. * Attach a post process to the camera.
  34246. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  34247. * @param postProcess The post process to attach to the camera
  34248. * @param insertAt The position of the post process in case several of them are in use in the scene
  34249. * @returns the position the post process has been inserted at
  34250. */
  34251. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  34252. /**
  34253. * Detach a post process to the camera.
  34254. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  34255. * @param postProcess The post process to detach from the camera
  34256. */
  34257. detachPostProcess(postProcess: PostProcess): void;
  34258. /**
  34259. * Gets the current world matrix of the camera
  34260. */
  34261. getWorldMatrix(): Matrix;
  34262. /** @hidden */
  34263. _getViewMatrix(): Matrix;
  34264. /**
  34265. * Gets the current view matrix of the camera.
  34266. * @param force forces the camera to recompute the matrix without looking at the cached state
  34267. * @returns the view matrix
  34268. */
  34269. getViewMatrix(force?: boolean): Matrix;
  34270. /**
  34271. * Freeze the projection matrix.
  34272. * It will prevent the cache check of the camera projection compute and can speed up perf
  34273. * if no parameter of the camera are meant to change
  34274. * @param projection Defines manually a projection if necessary
  34275. */
  34276. freezeProjectionMatrix(projection?: Matrix): void;
  34277. /**
  34278. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  34279. */
  34280. unfreezeProjectionMatrix(): void;
  34281. /**
  34282. * Gets the current projection matrix of the camera.
  34283. * @param force forces the camera to recompute the matrix without looking at the cached state
  34284. * @returns the projection matrix
  34285. */
  34286. getProjectionMatrix(force?: boolean): Matrix;
  34287. /**
  34288. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  34289. * @returns a Matrix
  34290. */
  34291. getTransformationMatrix(): Matrix;
  34292. private _updateFrustumPlanes;
  34293. /**
  34294. * Checks if a cullable object (mesh...) is in the camera frustum
  34295. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  34296. * @param target The object to check
  34297. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  34298. * @returns true if the object is in frustum otherwise false
  34299. */
  34300. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  34301. /**
  34302. * Checks if a cullable object (mesh...) is in the camera frustum
  34303. * Unlike isInFrustum this cheks the full bounding box
  34304. * @param target The object to check
  34305. * @returns true if the object is in frustum otherwise false
  34306. */
  34307. isCompletelyInFrustum(target: ICullable): boolean;
  34308. /**
  34309. * Gets a ray in the forward direction from the camera.
  34310. * @param length Defines the length of the ray to create
  34311. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  34312. * @param origin Defines the start point of the ray which defaults to the camera position
  34313. * @returns the forward ray
  34314. */
  34315. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  34316. /**
  34317. * Gets a ray in the forward direction from the camera.
  34318. * @param refRay the ray to (re)use when setting the values
  34319. * @param length Defines the length of the ray to create
  34320. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  34321. * @param origin Defines the start point of the ray which defaults to the camera position
  34322. * @returns the forward ray
  34323. */
  34324. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  34325. /**
  34326. * Releases resources associated with this node.
  34327. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34328. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34329. */
  34330. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34331. /** @hidden */
  34332. _isLeftCamera: boolean;
  34333. /**
  34334. * Gets the left camera of a rig setup in case of Rigged Camera
  34335. */
  34336. get isLeftCamera(): boolean;
  34337. /** @hidden */
  34338. _isRightCamera: boolean;
  34339. /**
  34340. * Gets the right camera of a rig setup in case of Rigged Camera
  34341. */
  34342. get isRightCamera(): boolean;
  34343. /**
  34344. * Gets the left camera of a rig setup in case of Rigged Camera
  34345. */
  34346. get leftCamera(): Nullable<FreeCamera>;
  34347. /**
  34348. * Gets the right camera of a rig setup in case of Rigged Camera
  34349. */
  34350. get rightCamera(): Nullable<FreeCamera>;
  34351. /**
  34352. * Gets the left camera target of a rig setup in case of Rigged Camera
  34353. * @returns the target position
  34354. */
  34355. getLeftTarget(): Nullable<Vector3>;
  34356. /**
  34357. * Gets the right camera target of a rig setup in case of Rigged Camera
  34358. * @returns the target position
  34359. */
  34360. getRightTarget(): Nullable<Vector3>;
  34361. /**
  34362. * @hidden
  34363. */
  34364. setCameraRigMode(mode: number, rigParams: any): void;
  34365. /** @hidden */
  34366. static _setStereoscopicRigMode(camera: Camera): void;
  34367. /** @hidden */
  34368. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  34369. /** @hidden */
  34370. static _setVRRigMode(camera: Camera, rigParams: any): void;
  34371. /** @hidden */
  34372. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  34373. /** @hidden */
  34374. _getVRProjectionMatrix(): Matrix;
  34375. protected _updateCameraRotationMatrix(): void;
  34376. protected _updateWebVRCameraRotationMatrix(): void;
  34377. /**
  34378. * This function MUST be overwritten by the different WebVR cameras available.
  34379. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  34380. * @hidden
  34381. */
  34382. _getWebVRProjectionMatrix(): Matrix;
  34383. /**
  34384. * This function MUST be overwritten by the different WebVR cameras available.
  34385. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  34386. * @hidden
  34387. */
  34388. _getWebVRViewMatrix(): Matrix;
  34389. /** @hidden */
  34390. setCameraRigParameter(name: string, value: any): void;
  34391. /**
  34392. * needs to be overridden by children so sub has required properties to be copied
  34393. * @hidden
  34394. */
  34395. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  34396. /**
  34397. * May need to be overridden by children
  34398. * @hidden
  34399. */
  34400. _updateRigCameras(): void;
  34401. /** @hidden */
  34402. _setupInputs(): void;
  34403. /**
  34404. * Serialiaze the camera setup to a json represention
  34405. * @returns the JSON representation
  34406. */
  34407. serialize(): any;
  34408. /**
  34409. * Clones the current camera.
  34410. * @param name The cloned camera name
  34411. * @returns the cloned camera
  34412. */
  34413. clone(name: string): Camera;
  34414. /**
  34415. * Gets the direction of the camera relative to a given local axis.
  34416. * @param localAxis Defines the reference axis to provide a relative direction.
  34417. * @return the direction
  34418. */
  34419. getDirection(localAxis: Vector3): Vector3;
  34420. /**
  34421. * Returns the current camera absolute rotation
  34422. */
  34423. get absoluteRotation(): Quaternion;
  34424. /**
  34425. * Gets the direction of the camera relative to a given local axis into a passed vector.
  34426. * @param localAxis Defines the reference axis to provide a relative direction.
  34427. * @param result Defines the vector to store the result in
  34428. */
  34429. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  34430. /**
  34431. * Gets a camera constructor for a given camera type
  34432. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  34433. * @param name The name of the camera the result will be able to instantiate
  34434. * @param scene The scene the result will construct the camera in
  34435. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  34436. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  34437. * @returns a factory method to construc the camera
  34438. */
  34439. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  34440. /**
  34441. * Compute the world matrix of the camera.
  34442. * @returns the camera world matrix
  34443. */
  34444. computeWorldMatrix(): Matrix;
  34445. /**
  34446. * Parse a JSON and creates the camera from the parsed information
  34447. * @param parsedCamera The JSON to parse
  34448. * @param scene The scene to instantiate the camera in
  34449. * @returns the newly constructed camera
  34450. */
  34451. static Parse(parsedCamera: any, scene: Scene): Camera;
  34452. }
  34453. }
  34454. declare module BABYLON {
  34455. /**
  34456. * Class containing static functions to help procedurally build meshes
  34457. */
  34458. export class DiscBuilder {
  34459. /**
  34460. * Creates a plane polygonal mesh. By default, this is a disc
  34461. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  34462. * * 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
  34463. * * 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
  34464. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  34465. * * 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
  34466. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34467. * @param name defines the name of the mesh
  34468. * @param options defines the options used to create the mesh
  34469. * @param scene defines the hosting scene
  34470. * @returns the plane polygonal mesh
  34471. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  34472. */
  34473. static CreateDisc(name: string, options: {
  34474. radius?: number;
  34475. tessellation?: number;
  34476. arc?: number;
  34477. updatable?: boolean;
  34478. sideOrientation?: number;
  34479. frontUVs?: Vector4;
  34480. backUVs?: Vector4;
  34481. }, scene?: Nullable<Scene>): Mesh;
  34482. }
  34483. }
  34484. declare module BABYLON {
  34485. /**
  34486. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  34487. *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.
  34488. * The SPS is also a particle system. It provides some methods to manage the particles.
  34489. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  34490. *
  34491. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  34492. */
  34493. export class SolidParticleSystem implements IDisposable {
  34494. /**
  34495. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  34496. * Example : var p = SPS.particles[i];
  34497. */
  34498. particles: SolidParticle[];
  34499. /**
  34500. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  34501. */
  34502. nbParticles: number;
  34503. /**
  34504. * If the particles must ever face the camera (default false). Useful for planar particles.
  34505. */
  34506. billboard: boolean;
  34507. /**
  34508. * Recompute normals when adding a shape
  34509. */
  34510. recomputeNormals: boolean;
  34511. /**
  34512. * This a counter ofr your own usage. It's not set by any SPS functions.
  34513. */
  34514. counter: number;
  34515. /**
  34516. * The SPS name. This name is also given to the underlying mesh.
  34517. */
  34518. name: string;
  34519. /**
  34520. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  34521. */
  34522. mesh: Mesh;
  34523. /**
  34524. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  34525. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  34526. */
  34527. vars: any;
  34528. /**
  34529. * This array is populated when the SPS is set as 'pickable'.
  34530. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  34531. * Each element of this array is an object `{idx: int, faceId: int}`.
  34532. * `idx` is the picked particle index in the `SPS.particles` array
  34533. * `faceId` is the picked face index counted within this particle.
  34534. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  34535. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  34536. * Use the method SPS.pickedParticle(pickingInfo) instead.
  34537. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34538. */
  34539. pickedParticles: {
  34540. idx: number;
  34541. faceId: number;
  34542. }[];
  34543. /**
  34544. * This array is populated when the SPS is set as 'pickable'
  34545. * Each key of this array is a submesh index.
  34546. * Each element of this array is a second array defined like this :
  34547. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  34548. * Each element of this second array is an object `{idx: int, faceId: int}`.
  34549. * `idx` is the picked particle index in the `SPS.particles` array
  34550. * `faceId` is the picked face index counted within this particle.
  34551. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  34552. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34553. */
  34554. pickedBySubMesh: {
  34555. idx: number;
  34556. faceId: number;
  34557. }[][];
  34558. /**
  34559. * This array is populated when `enableDepthSort` is set to true.
  34560. * Each element of this array is an instance of the class DepthSortedParticle.
  34561. */
  34562. depthSortedParticles: DepthSortedParticle[];
  34563. /**
  34564. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  34565. * @hidden
  34566. */
  34567. _bSphereOnly: boolean;
  34568. /**
  34569. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  34570. * @hidden
  34571. */
  34572. _bSphereRadiusFactor: number;
  34573. private _scene;
  34574. private _positions;
  34575. private _indices;
  34576. private _normals;
  34577. private _colors;
  34578. private _uvs;
  34579. private _indices32;
  34580. private _positions32;
  34581. private _normals32;
  34582. private _fixedNormal32;
  34583. private _colors32;
  34584. private _uvs32;
  34585. private _index;
  34586. private _updatable;
  34587. private _pickable;
  34588. private _isVisibilityBoxLocked;
  34589. private _alwaysVisible;
  34590. private _depthSort;
  34591. private _expandable;
  34592. private _shapeCounter;
  34593. private _copy;
  34594. private _color;
  34595. private _computeParticleColor;
  34596. private _computeParticleTexture;
  34597. private _computeParticleRotation;
  34598. private _computeParticleVertex;
  34599. private _computeBoundingBox;
  34600. private _depthSortParticles;
  34601. private _camera;
  34602. private _mustUnrotateFixedNormals;
  34603. private _particlesIntersect;
  34604. private _needs32Bits;
  34605. private _isNotBuilt;
  34606. private _lastParticleId;
  34607. private _idxOfId;
  34608. private _multimaterialEnabled;
  34609. private _useModelMaterial;
  34610. private _indicesByMaterial;
  34611. private _materialIndexes;
  34612. private _depthSortFunction;
  34613. private _materialSortFunction;
  34614. private _materials;
  34615. private _multimaterial;
  34616. private _materialIndexesById;
  34617. private _defaultMaterial;
  34618. private _autoUpdateSubMeshes;
  34619. private _tmpVertex;
  34620. /**
  34621. * Creates a SPS (Solid Particle System) object.
  34622. * @param name (String) is the SPS name, this will be the underlying mesh name.
  34623. * @param scene (Scene) is the scene in which the SPS is added.
  34624. * @param options defines the options of the sps e.g.
  34625. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  34626. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  34627. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  34628. * * 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.
  34629. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  34630. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  34631. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  34632. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  34633. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  34634. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  34635. */
  34636. constructor(name: string, scene: Scene, options?: {
  34637. updatable?: boolean;
  34638. isPickable?: boolean;
  34639. enableDepthSort?: boolean;
  34640. particleIntersection?: boolean;
  34641. boundingSphereOnly?: boolean;
  34642. bSphereRadiusFactor?: number;
  34643. expandable?: boolean;
  34644. useModelMaterial?: boolean;
  34645. enableMultiMaterial?: boolean;
  34646. });
  34647. /**
  34648. * Builds the SPS underlying mesh. Returns a standard Mesh.
  34649. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  34650. * @returns the created mesh
  34651. */
  34652. buildMesh(): Mesh;
  34653. /**
  34654. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  34655. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  34656. * Thus the particles generated from `digest()` have their property `position` set yet.
  34657. * @param mesh ( Mesh ) is the mesh to be digested
  34658. * @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
  34659. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  34660. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  34661. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  34662. * @returns the current SPS
  34663. */
  34664. digest(mesh: Mesh, options?: {
  34665. facetNb?: number;
  34666. number?: number;
  34667. delta?: number;
  34668. storage?: [];
  34669. }): SolidParticleSystem;
  34670. /**
  34671. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  34672. * @hidden
  34673. */
  34674. private _unrotateFixedNormals;
  34675. /**
  34676. * Resets the temporary working copy particle
  34677. * @hidden
  34678. */
  34679. private _resetCopy;
  34680. /**
  34681. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  34682. * @param p the current index in the positions array to be updated
  34683. * @param ind the current index in the indices array
  34684. * @param shape a Vector3 array, the shape geometry
  34685. * @param positions the positions array to be updated
  34686. * @param meshInd the shape indices array
  34687. * @param indices the indices array to be updated
  34688. * @param meshUV the shape uv array
  34689. * @param uvs the uv array to be updated
  34690. * @param meshCol the shape color array
  34691. * @param colors the color array to be updated
  34692. * @param meshNor the shape normals array
  34693. * @param normals the normals array to be updated
  34694. * @param idx the particle index
  34695. * @param idxInShape the particle index in its shape
  34696. * @param options the addShape() method passed options
  34697. * @model the particle model
  34698. * @hidden
  34699. */
  34700. private _meshBuilder;
  34701. /**
  34702. * Returns a shape Vector3 array from positions float array
  34703. * @param positions float array
  34704. * @returns a vector3 array
  34705. * @hidden
  34706. */
  34707. private _posToShape;
  34708. /**
  34709. * Returns a shapeUV array from a float uvs (array deep copy)
  34710. * @param uvs as a float array
  34711. * @returns a shapeUV array
  34712. * @hidden
  34713. */
  34714. private _uvsToShapeUV;
  34715. /**
  34716. * Adds a new particle object in the particles array
  34717. * @param idx particle index in particles array
  34718. * @param id particle id
  34719. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  34720. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  34721. * @param model particle ModelShape object
  34722. * @param shapeId model shape identifier
  34723. * @param idxInShape index of the particle in the current model
  34724. * @param bInfo model bounding info object
  34725. * @param storage target storage array, if any
  34726. * @hidden
  34727. */
  34728. private _addParticle;
  34729. /**
  34730. * Adds some particles to the SPS from the model shape. Returns the shape id.
  34731. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  34732. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  34733. * @param nb (positive integer) the number of particles to be created from this model
  34734. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  34735. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  34736. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  34737. * @returns the number of shapes in the system
  34738. */
  34739. addShape(mesh: Mesh, nb: number, options?: {
  34740. positionFunction?: any;
  34741. vertexFunction?: any;
  34742. storage?: [];
  34743. }): number;
  34744. /**
  34745. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  34746. * @hidden
  34747. */
  34748. private _rebuildParticle;
  34749. /**
  34750. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  34751. * @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.
  34752. * @returns the SPS.
  34753. */
  34754. rebuildMesh(reset?: boolean): SolidParticleSystem;
  34755. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  34756. * Returns an array with the removed particles.
  34757. * 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.
  34758. * The SPS can't be empty so at least one particle needs to remain in place.
  34759. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  34760. * @param start index of the first particle to remove
  34761. * @param end index of the last particle to remove (included)
  34762. * @returns an array populated with the removed particles
  34763. */
  34764. removeParticles(start: number, end: number): SolidParticle[];
  34765. /**
  34766. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  34767. * @param solidParticleArray an array populated with Solid Particles objects
  34768. * @returns the SPS
  34769. */
  34770. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  34771. /**
  34772. * Creates a new particle and modifies the SPS mesh geometry :
  34773. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  34774. * - calls _addParticle() to populate the particle array
  34775. * factorized code from addShape() and insertParticlesFromArray()
  34776. * @param idx particle index in the particles array
  34777. * @param i particle index in its shape
  34778. * @param modelShape particle ModelShape object
  34779. * @param shape shape vertex array
  34780. * @param meshInd shape indices array
  34781. * @param meshUV shape uv array
  34782. * @param meshCol shape color array
  34783. * @param meshNor shape normals array
  34784. * @param bbInfo shape bounding info
  34785. * @param storage target particle storage
  34786. * @options addShape() passed options
  34787. * @hidden
  34788. */
  34789. private _insertNewParticle;
  34790. /**
  34791. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  34792. * This method calls `updateParticle()` for each particle of the SPS.
  34793. * For an animated SPS, it is usually called within the render loop.
  34794. * 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.
  34795. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  34796. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  34797. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  34798. * @returns the SPS.
  34799. */
  34800. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  34801. /**
  34802. * Disposes the SPS.
  34803. */
  34804. dispose(): void;
  34805. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  34806. * idx is the particle index in the SPS
  34807. * faceId is the picked face index counted within this particle.
  34808. * Returns null if the pickInfo can't identify a picked particle.
  34809. * @param pickingInfo (PickingInfo object)
  34810. * @returns {idx: number, faceId: number} or null
  34811. */
  34812. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  34813. idx: number;
  34814. faceId: number;
  34815. }>;
  34816. /**
  34817. * Returns a SolidParticle object from its identifier : particle.id
  34818. * @param id (integer) the particle Id
  34819. * @returns the searched particle or null if not found in the SPS.
  34820. */
  34821. getParticleById(id: number): Nullable<SolidParticle>;
  34822. /**
  34823. * Returns a new array populated with the particles having the passed shapeId.
  34824. * @param shapeId (integer) the shape identifier
  34825. * @returns a new solid particle array
  34826. */
  34827. getParticlesByShapeId(shapeId: number): SolidParticle[];
  34828. /**
  34829. * Populates the passed array "ref" with the particles having the passed shapeId.
  34830. * @param shapeId the shape identifier
  34831. * @returns the SPS
  34832. * @param ref
  34833. */
  34834. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  34835. /**
  34836. * Computes the required SubMeshes according the materials assigned to the particles.
  34837. * @returns the solid particle system.
  34838. * Does nothing if called before the SPS mesh is built.
  34839. */
  34840. computeSubMeshes(): SolidParticleSystem;
  34841. /**
  34842. * Sorts the solid particles by material when MultiMaterial is enabled.
  34843. * Updates the indices32 array.
  34844. * Updates the indicesByMaterial array.
  34845. * Updates the mesh indices array.
  34846. * @returns the SPS
  34847. * @hidden
  34848. */
  34849. private _sortParticlesByMaterial;
  34850. /**
  34851. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  34852. * @hidden
  34853. */
  34854. private _setMaterialIndexesById;
  34855. /**
  34856. * Returns an array with unique values of Materials from the passed array
  34857. * @param array the material array to be checked and filtered
  34858. * @hidden
  34859. */
  34860. private _filterUniqueMaterialId;
  34861. /**
  34862. * Sets a new Standard Material as _defaultMaterial if not already set.
  34863. * @hidden
  34864. */
  34865. private _setDefaultMaterial;
  34866. /**
  34867. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  34868. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34869. * @returns the SPS.
  34870. */
  34871. refreshVisibleSize(): SolidParticleSystem;
  34872. /**
  34873. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  34874. * @param size the size (float) of the visibility box
  34875. * note : this doesn't lock the SPS mesh bounding box.
  34876. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34877. */
  34878. setVisibilityBox(size: number): void;
  34879. /**
  34880. * Gets whether the SPS as always visible or not
  34881. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34882. */
  34883. get isAlwaysVisible(): boolean;
  34884. /**
  34885. * Sets the SPS as always visible or not
  34886. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34887. */
  34888. set isAlwaysVisible(val: boolean);
  34889. /**
  34890. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34891. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34892. */
  34893. set isVisibilityBoxLocked(val: boolean);
  34894. /**
  34895. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34896. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34897. */
  34898. get isVisibilityBoxLocked(): boolean;
  34899. /**
  34900. * Tells to `setParticles()` to compute the particle rotations or not.
  34901. * Default value : true. The SPS is faster when it's set to false.
  34902. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34903. */
  34904. set computeParticleRotation(val: boolean);
  34905. /**
  34906. * Tells to `setParticles()` to compute the particle colors or not.
  34907. * Default value : true. The SPS is faster when it's set to false.
  34908. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34909. */
  34910. set computeParticleColor(val: boolean);
  34911. set computeParticleTexture(val: boolean);
  34912. /**
  34913. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  34914. * Default value : false. The SPS is faster when it's set to false.
  34915. * Note : the particle custom vertex positions aren't stored values.
  34916. */
  34917. set computeParticleVertex(val: boolean);
  34918. /**
  34919. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  34920. */
  34921. set computeBoundingBox(val: boolean);
  34922. /**
  34923. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  34924. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34925. * Default : `true`
  34926. */
  34927. set depthSortParticles(val: boolean);
  34928. /**
  34929. * Gets if `setParticles()` computes the particle rotations or not.
  34930. * Default value : true. The SPS is faster when it's set to false.
  34931. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34932. */
  34933. get computeParticleRotation(): boolean;
  34934. /**
  34935. * Gets if `setParticles()` computes the particle colors or not.
  34936. * Default value : true. The SPS is faster when it's set to false.
  34937. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34938. */
  34939. get computeParticleColor(): boolean;
  34940. /**
  34941. * Gets if `setParticles()` computes the particle textures or not.
  34942. * Default value : true. The SPS is faster when it's set to false.
  34943. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  34944. */
  34945. get computeParticleTexture(): boolean;
  34946. /**
  34947. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  34948. * Default value : false. The SPS is faster when it's set to false.
  34949. * Note : the particle custom vertex positions aren't stored values.
  34950. */
  34951. get computeParticleVertex(): boolean;
  34952. /**
  34953. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  34954. */
  34955. get computeBoundingBox(): boolean;
  34956. /**
  34957. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  34958. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34959. * Default : `true`
  34960. */
  34961. get depthSortParticles(): boolean;
  34962. /**
  34963. * Gets if the SPS is created as expandable at construction time.
  34964. * Default : `false`
  34965. */
  34966. get expandable(): boolean;
  34967. /**
  34968. * Gets if the SPS supports the Multi Materials
  34969. */
  34970. get multimaterialEnabled(): boolean;
  34971. /**
  34972. * Gets if the SPS uses the model materials for its own multimaterial.
  34973. */
  34974. get useModelMaterial(): boolean;
  34975. /**
  34976. * The SPS used material array.
  34977. */
  34978. get materials(): Material[];
  34979. /**
  34980. * Sets the SPS MultiMaterial from the passed materials.
  34981. * Note : the passed array is internally copied and not used then by reference.
  34982. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  34983. */
  34984. setMultiMaterial(materials: Material[]): void;
  34985. /**
  34986. * The SPS computed multimaterial object
  34987. */
  34988. get multimaterial(): MultiMaterial;
  34989. set multimaterial(mm: MultiMaterial);
  34990. /**
  34991. * If the subMeshes must be updated on the next call to setParticles()
  34992. */
  34993. get autoUpdateSubMeshes(): boolean;
  34994. set autoUpdateSubMeshes(val: boolean);
  34995. /**
  34996. * This function does nothing. It may be overwritten to set all the particle first values.
  34997. * The SPS doesn't call this function, you may have to call it by your own.
  34998. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34999. */
  35000. initParticles(): void;
  35001. /**
  35002. * This function does nothing. It may be overwritten to recycle a particle.
  35003. * The SPS doesn't call this function, you may have to call it by your own.
  35004. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35005. * @param particle The particle to recycle
  35006. * @returns the recycled particle
  35007. */
  35008. recycleParticle(particle: SolidParticle): SolidParticle;
  35009. /**
  35010. * Updates a particle : this function should be overwritten by the user.
  35011. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  35012. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35013. * @example : just set a particle position or velocity and recycle conditions
  35014. * @param particle The particle to update
  35015. * @returns the updated particle
  35016. */
  35017. updateParticle(particle: SolidParticle): SolidParticle;
  35018. /**
  35019. * Updates a vertex of a particle : it can be overwritten by the user.
  35020. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  35021. * @param particle the current particle
  35022. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  35023. * @param pt the index of the current vertex in the particle shape
  35024. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  35025. * @example : just set a vertex particle position or color
  35026. * @returns the sps
  35027. */
  35028. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  35029. /**
  35030. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  35031. * This does nothing and may be overwritten by the user.
  35032. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35033. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35034. * @param update the boolean update value actually passed to setParticles()
  35035. */
  35036. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  35037. /**
  35038. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  35039. * This will be passed three parameters.
  35040. * This does nothing and may be overwritten by the user.
  35041. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35042. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35043. * @param update the boolean update value actually passed to setParticles()
  35044. */
  35045. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  35046. }
  35047. }
  35048. declare module BABYLON {
  35049. /**
  35050. * Represents one particle of a solid particle system.
  35051. */
  35052. export class SolidParticle {
  35053. /**
  35054. * particle global index
  35055. */
  35056. idx: number;
  35057. /**
  35058. * particle identifier
  35059. */
  35060. id: number;
  35061. /**
  35062. * The color of the particle
  35063. */
  35064. color: Nullable<Color4>;
  35065. /**
  35066. * The world space position of the particle.
  35067. */
  35068. position: Vector3;
  35069. /**
  35070. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  35071. */
  35072. rotation: Vector3;
  35073. /**
  35074. * The world space rotation quaternion of the particle.
  35075. */
  35076. rotationQuaternion: Nullable<Quaternion>;
  35077. /**
  35078. * The scaling of the particle.
  35079. */
  35080. scaling: Vector3;
  35081. /**
  35082. * The uvs of the particle.
  35083. */
  35084. uvs: Vector4;
  35085. /**
  35086. * The current speed of the particle.
  35087. */
  35088. velocity: Vector3;
  35089. /**
  35090. * The pivot point in the particle local space.
  35091. */
  35092. pivot: Vector3;
  35093. /**
  35094. * Must the particle be translated from its pivot point in its local space ?
  35095. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  35096. * Default : false
  35097. */
  35098. translateFromPivot: boolean;
  35099. /**
  35100. * Is the particle active or not ?
  35101. */
  35102. alive: boolean;
  35103. /**
  35104. * Is the particle visible or not ?
  35105. */
  35106. isVisible: boolean;
  35107. /**
  35108. * Index of this particle in the global "positions" array (Internal use)
  35109. * @hidden
  35110. */
  35111. _pos: number;
  35112. /**
  35113. * @hidden Index of this particle in the global "indices" array (Internal use)
  35114. */
  35115. _ind: number;
  35116. /**
  35117. * @hidden ModelShape of this particle (Internal use)
  35118. */
  35119. _model: ModelShape;
  35120. /**
  35121. * ModelShape id of this particle
  35122. */
  35123. shapeId: number;
  35124. /**
  35125. * Index of the particle in its shape id
  35126. */
  35127. idxInShape: number;
  35128. /**
  35129. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  35130. */
  35131. _modelBoundingInfo: BoundingInfo;
  35132. /**
  35133. * @hidden Particle BoundingInfo object (Internal use)
  35134. */
  35135. _boundingInfo: BoundingInfo;
  35136. /**
  35137. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  35138. */
  35139. _sps: SolidParticleSystem;
  35140. /**
  35141. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  35142. */
  35143. _stillInvisible: boolean;
  35144. /**
  35145. * @hidden Last computed particle rotation matrix
  35146. */
  35147. _rotationMatrix: number[];
  35148. /**
  35149. * Parent particle Id, if any.
  35150. * Default null.
  35151. */
  35152. parentId: Nullable<number>;
  35153. /**
  35154. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  35155. */
  35156. materialIndex: Nullable<number>;
  35157. /**
  35158. * Custom object or properties.
  35159. */
  35160. props: Nullable<any>;
  35161. /**
  35162. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  35163. * The possible values are :
  35164. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35165. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35166. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  35167. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  35168. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35169. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  35170. * */
  35171. cullingStrategy: number;
  35172. /**
  35173. * @hidden Internal global position in the SPS.
  35174. */
  35175. _globalPosition: Vector3;
  35176. /**
  35177. * Creates a Solid Particle object.
  35178. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  35179. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  35180. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  35181. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  35182. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  35183. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  35184. * @param shapeId (integer) is the model shape identifier in the SPS.
  35185. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  35186. * @param sps defines the sps it is associated to
  35187. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  35188. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  35189. */
  35190. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  35191. /**
  35192. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  35193. * @param target the particle target
  35194. * @returns the current particle
  35195. */
  35196. copyToRef(target: SolidParticle): SolidParticle;
  35197. /**
  35198. * Legacy support, changed scale to scaling
  35199. */
  35200. get scale(): Vector3;
  35201. /**
  35202. * Legacy support, changed scale to scaling
  35203. */
  35204. set scale(scale: Vector3);
  35205. /**
  35206. * Legacy support, changed quaternion to rotationQuaternion
  35207. */
  35208. get quaternion(): Nullable<Quaternion>;
  35209. /**
  35210. * Legacy support, changed quaternion to rotationQuaternion
  35211. */
  35212. set quaternion(q: Nullable<Quaternion>);
  35213. /**
  35214. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  35215. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  35216. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  35217. * @returns true if it intersects
  35218. */
  35219. intersectsMesh(target: Mesh | SolidParticle): boolean;
  35220. /**
  35221. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  35222. * A particle is in the frustum if its bounding box intersects the frustum
  35223. * @param frustumPlanes defines the frustum to test
  35224. * @returns true if the particle is in the frustum planes
  35225. */
  35226. isInFrustum(frustumPlanes: Plane[]): boolean;
  35227. /**
  35228. * get the rotation matrix of the particle
  35229. * @hidden
  35230. */
  35231. getRotationMatrix(m: Matrix): void;
  35232. }
  35233. /**
  35234. * Represents the shape of the model used by one particle of a solid particle system.
  35235. * SPS internal tool, don't use it manually.
  35236. */
  35237. export class ModelShape {
  35238. /**
  35239. * The shape id
  35240. * @hidden
  35241. */
  35242. shapeID: number;
  35243. /**
  35244. * flat array of model positions (internal use)
  35245. * @hidden
  35246. */
  35247. _shape: Vector3[];
  35248. /**
  35249. * flat array of model UVs (internal use)
  35250. * @hidden
  35251. */
  35252. _shapeUV: number[];
  35253. /**
  35254. * color array of the model
  35255. * @hidden
  35256. */
  35257. _shapeColors: number[];
  35258. /**
  35259. * indices array of the model
  35260. * @hidden
  35261. */
  35262. _indices: number[];
  35263. /**
  35264. * normals array of the model
  35265. * @hidden
  35266. */
  35267. _normals: number[];
  35268. /**
  35269. * length of the shape in the model indices array (internal use)
  35270. * @hidden
  35271. */
  35272. _indicesLength: number;
  35273. /**
  35274. * Custom position function (internal use)
  35275. * @hidden
  35276. */
  35277. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  35278. /**
  35279. * Custom vertex function (internal use)
  35280. * @hidden
  35281. */
  35282. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  35283. /**
  35284. * Model material (internal use)
  35285. * @hidden
  35286. */
  35287. _material: Nullable<Material>;
  35288. /**
  35289. * 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.
  35290. * SPS internal tool, don't use it manually.
  35291. * @hidden
  35292. */
  35293. 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>);
  35294. }
  35295. /**
  35296. * Represents a Depth Sorted Particle in the solid particle system.
  35297. * @hidden
  35298. */
  35299. export class DepthSortedParticle {
  35300. /**
  35301. * Particle index
  35302. */
  35303. idx: number;
  35304. /**
  35305. * Index of the particle in the "indices" array
  35306. */
  35307. ind: number;
  35308. /**
  35309. * Length of the particle shape in the "indices" array
  35310. */
  35311. indicesLength: number;
  35312. /**
  35313. * Squared distance from the particle to the camera
  35314. */
  35315. sqDistance: number;
  35316. /**
  35317. * Material index when used with MultiMaterials
  35318. */
  35319. materialIndex: number;
  35320. /**
  35321. * Creates a new sorted particle
  35322. * @param materialIndex
  35323. */
  35324. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  35325. }
  35326. /**
  35327. * Represents a solid particle vertex
  35328. */
  35329. export class SolidParticleVertex {
  35330. /**
  35331. * Vertex position
  35332. */
  35333. position: Vector3;
  35334. /**
  35335. * Vertex color
  35336. */
  35337. color: Color4;
  35338. /**
  35339. * Vertex UV
  35340. */
  35341. uv: Vector2;
  35342. /**
  35343. * Creates a new solid particle vertex
  35344. */
  35345. constructor();
  35346. /** Vertex x coordinate */
  35347. get x(): number;
  35348. set x(val: number);
  35349. /** Vertex y coordinate */
  35350. get y(): number;
  35351. set y(val: number);
  35352. /** Vertex z coordinate */
  35353. get z(): number;
  35354. set z(val: number);
  35355. }
  35356. }
  35357. declare module BABYLON {
  35358. /**
  35359. * @hidden
  35360. */
  35361. export class _MeshCollisionData {
  35362. _checkCollisions: boolean;
  35363. _collisionMask: number;
  35364. _collisionGroup: number;
  35365. _surroundingMeshes: Nullable<AbstractMesh[]>;
  35366. _collider: Nullable<Collider>;
  35367. _oldPositionForCollisions: Vector3;
  35368. _diffPositionForCollisions: Vector3;
  35369. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  35370. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  35371. _collisionResponse: boolean;
  35372. }
  35373. }
  35374. declare module BABYLON {
  35375. /** @hidden */
  35376. class _FacetDataStorage {
  35377. facetPositions: Vector3[];
  35378. facetNormals: Vector3[];
  35379. facetPartitioning: number[][];
  35380. facetNb: number;
  35381. partitioningSubdivisions: number;
  35382. partitioningBBoxRatio: number;
  35383. facetDataEnabled: boolean;
  35384. facetParameters: any;
  35385. bbSize: Vector3;
  35386. subDiv: {
  35387. max: number;
  35388. X: number;
  35389. Y: number;
  35390. Z: number;
  35391. };
  35392. facetDepthSort: boolean;
  35393. facetDepthSortEnabled: boolean;
  35394. depthSortedIndices: IndicesArray;
  35395. depthSortedFacets: {
  35396. ind: number;
  35397. sqDistance: number;
  35398. }[];
  35399. facetDepthSortFunction: (f1: {
  35400. ind: number;
  35401. sqDistance: number;
  35402. }, f2: {
  35403. ind: number;
  35404. sqDistance: number;
  35405. }) => number;
  35406. facetDepthSortFrom: Vector3;
  35407. facetDepthSortOrigin: Vector3;
  35408. invertedMatrix: Matrix;
  35409. }
  35410. /**
  35411. * @hidden
  35412. **/
  35413. class _InternalAbstractMeshDataInfo {
  35414. _hasVertexAlpha: boolean;
  35415. _useVertexColors: boolean;
  35416. _numBoneInfluencers: number;
  35417. _applyFog: boolean;
  35418. _receiveShadows: boolean;
  35419. _facetData: _FacetDataStorage;
  35420. _visibility: number;
  35421. _skeleton: Nullable<Skeleton>;
  35422. _layerMask: number;
  35423. _computeBonesUsingShaders: boolean;
  35424. _isActive: boolean;
  35425. _onlyForInstances: boolean;
  35426. _isActiveIntermediate: boolean;
  35427. _onlyForInstancesIntermediate: boolean;
  35428. _actAsRegularMesh: boolean;
  35429. _currentLOD: Nullable<AbstractMesh>;
  35430. }
  35431. /**
  35432. * Class used to store all common mesh properties
  35433. */
  35434. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  35435. /** No occlusion */
  35436. static OCCLUSION_TYPE_NONE: number;
  35437. /** Occlusion set to optimisitic */
  35438. static OCCLUSION_TYPE_OPTIMISTIC: number;
  35439. /** Occlusion set to strict */
  35440. static OCCLUSION_TYPE_STRICT: number;
  35441. /** Use an accurante occlusion algorithm */
  35442. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  35443. /** Use a conservative occlusion algorithm */
  35444. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  35445. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  35446. * Test order :
  35447. * Is the bounding sphere outside the frustum ?
  35448. * If not, are the bounding box vertices outside the frustum ?
  35449. * It not, then the cullable object is in the frustum.
  35450. */
  35451. static readonly CULLINGSTRATEGY_STANDARD: number;
  35452. /** Culling strategy : Bounding Sphere Only.
  35453. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  35454. * It's also less accurate than the standard because some not visible objects can still be selected.
  35455. * Test : is the bounding sphere outside the frustum ?
  35456. * If not, then the cullable object is in the frustum.
  35457. */
  35458. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  35459. /** Culling strategy : Optimistic Inclusion.
  35460. * This in an inclusion test first, then the standard exclusion test.
  35461. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  35462. * 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.
  35463. * Anyway, it's as accurate as the standard strategy.
  35464. * Test :
  35465. * Is the cullable object bounding sphere center in the frustum ?
  35466. * If not, apply the default culling strategy.
  35467. */
  35468. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  35469. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  35470. * This in an inclusion test first, then the bounding sphere only exclusion test.
  35471. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  35472. * 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.
  35473. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  35474. * Test :
  35475. * Is the cullable object bounding sphere center in the frustum ?
  35476. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  35477. */
  35478. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  35479. /**
  35480. * No billboard
  35481. */
  35482. static get BILLBOARDMODE_NONE(): number;
  35483. /** Billboard on X axis */
  35484. static get BILLBOARDMODE_X(): number;
  35485. /** Billboard on Y axis */
  35486. static get BILLBOARDMODE_Y(): number;
  35487. /** Billboard on Z axis */
  35488. static get BILLBOARDMODE_Z(): number;
  35489. /** Billboard on all axes */
  35490. static get BILLBOARDMODE_ALL(): number;
  35491. /** Billboard on using position instead of orientation */
  35492. static get BILLBOARDMODE_USE_POSITION(): number;
  35493. /** @hidden */
  35494. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  35495. /**
  35496. * The culling strategy to use to check whether the mesh must be rendered or not.
  35497. * This value can be changed at any time and will be used on the next render mesh selection.
  35498. * The possible values are :
  35499. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35500. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35501. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  35502. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  35503. * Please read each static variable documentation to get details about the culling process.
  35504. * */
  35505. cullingStrategy: number;
  35506. /**
  35507. * Gets the number of facets in the mesh
  35508. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35509. */
  35510. get facetNb(): number;
  35511. /**
  35512. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  35513. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35514. */
  35515. get partitioningSubdivisions(): number;
  35516. set partitioningSubdivisions(nb: number);
  35517. /**
  35518. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  35519. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  35520. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35521. */
  35522. get partitioningBBoxRatio(): number;
  35523. set partitioningBBoxRatio(ratio: number);
  35524. /**
  35525. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  35526. * Works only for updatable meshes.
  35527. * Doesn't work with multi-materials
  35528. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35529. */
  35530. get mustDepthSortFacets(): boolean;
  35531. set mustDepthSortFacets(sort: boolean);
  35532. /**
  35533. * The location (Vector3) where the facet depth sort must be computed from.
  35534. * By default, the active camera position.
  35535. * Used only when facet depth sort is enabled
  35536. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35537. */
  35538. get facetDepthSortFrom(): Vector3;
  35539. set facetDepthSortFrom(location: Vector3);
  35540. /**
  35541. * gets a boolean indicating if facetData is enabled
  35542. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35543. */
  35544. get isFacetDataEnabled(): boolean;
  35545. /** @hidden */
  35546. _updateNonUniformScalingState(value: boolean): boolean;
  35547. /**
  35548. * An event triggered when this mesh collides with another one
  35549. */
  35550. onCollideObservable: Observable<AbstractMesh>;
  35551. /** Set a function to call when this mesh collides with another one */
  35552. set onCollide(callback: () => void);
  35553. /**
  35554. * An event triggered when the collision's position changes
  35555. */
  35556. onCollisionPositionChangeObservable: Observable<Vector3>;
  35557. /** Set a function to call when the collision's position changes */
  35558. set onCollisionPositionChange(callback: () => void);
  35559. /**
  35560. * An event triggered when material is changed
  35561. */
  35562. onMaterialChangedObservable: Observable<AbstractMesh>;
  35563. /**
  35564. * Gets or sets the orientation for POV movement & rotation
  35565. */
  35566. definedFacingForward: boolean;
  35567. /** @hidden */
  35568. _occlusionQuery: Nullable<WebGLQuery>;
  35569. /** @hidden */
  35570. _renderingGroup: Nullable<RenderingGroup>;
  35571. /**
  35572. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  35573. */
  35574. get visibility(): number;
  35575. /**
  35576. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  35577. */
  35578. set visibility(value: number);
  35579. /** Gets or sets the alpha index used to sort transparent meshes
  35580. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  35581. */
  35582. alphaIndex: number;
  35583. /**
  35584. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  35585. */
  35586. isVisible: boolean;
  35587. /**
  35588. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  35589. */
  35590. isPickable: boolean;
  35591. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  35592. showSubMeshesBoundingBox: boolean;
  35593. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  35594. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  35595. */
  35596. isBlocker: boolean;
  35597. /**
  35598. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  35599. */
  35600. enablePointerMoveEvents: boolean;
  35601. private _renderingGroupId;
  35602. /**
  35603. * Specifies the rendering group id for this mesh (0 by default)
  35604. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  35605. */
  35606. get renderingGroupId(): number;
  35607. set renderingGroupId(value: number);
  35608. private _material;
  35609. /** Gets or sets current material */
  35610. get material(): Nullable<Material>;
  35611. set material(value: Nullable<Material>);
  35612. /**
  35613. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  35614. * @see https://doc.babylonjs.com/babylon101/shadows
  35615. */
  35616. get receiveShadows(): boolean;
  35617. set receiveShadows(value: boolean);
  35618. /** Defines color to use when rendering outline */
  35619. outlineColor: Color3;
  35620. /** Define width to use when rendering outline */
  35621. outlineWidth: number;
  35622. /** Defines color to use when rendering overlay */
  35623. overlayColor: Color3;
  35624. /** Defines alpha to use when rendering overlay */
  35625. overlayAlpha: number;
  35626. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  35627. get hasVertexAlpha(): boolean;
  35628. set hasVertexAlpha(value: boolean);
  35629. /** 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) */
  35630. get useVertexColors(): boolean;
  35631. set useVertexColors(value: boolean);
  35632. /**
  35633. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  35634. */
  35635. get computeBonesUsingShaders(): boolean;
  35636. set computeBonesUsingShaders(value: boolean);
  35637. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  35638. get numBoneInfluencers(): number;
  35639. set numBoneInfluencers(value: number);
  35640. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  35641. get applyFog(): boolean;
  35642. set applyFog(value: boolean);
  35643. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  35644. useOctreeForRenderingSelection: boolean;
  35645. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  35646. useOctreeForPicking: boolean;
  35647. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  35648. useOctreeForCollisions: boolean;
  35649. /**
  35650. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  35651. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  35652. */
  35653. get layerMask(): number;
  35654. set layerMask(value: number);
  35655. /**
  35656. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  35657. */
  35658. alwaysSelectAsActiveMesh: boolean;
  35659. /**
  35660. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  35661. */
  35662. doNotSyncBoundingInfo: boolean;
  35663. /**
  35664. * Gets or sets the current action manager
  35665. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  35666. */
  35667. actionManager: Nullable<AbstractActionManager>;
  35668. private _meshCollisionData;
  35669. /**
  35670. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  35671. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35672. */
  35673. ellipsoid: Vector3;
  35674. /**
  35675. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  35676. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35677. */
  35678. ellipsoidOffset: Vector3;
  35679. /**
  35680. * Gets or sets a collision mask used to mask collisions (default is -1).
  35681. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  35682. */
  35683. get collisionMask(): number;
  35684. set collisionMask(mask: number);
  35685. /**
  35686. * Gets or sets a collision response flag (default is true).
  35687. * when collisionResponse is false, events are still triggered but colliding entity has no response
  35688. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  35689. * to respond to the collision.
  35690. */
  35691. get collisionResponse(): boolean;
  35692. set collisionResponse(response: boolean);
  35693. /**
  35694. * Gets or sets the current collision group mask (-1 by default).
  35695. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  35696. */
  35697. get collisionGroup(): number;
  35698. set collisionGroup(mask: number);
  35699. /**
  35700. * Gets or sets current surrounding meshes (null by default).
  35701. *
  35702. * By default collision detection is tested against every mesh in the scene.
  35703. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  35704. * meshes will be tested for the collision.
  35705. *
  35706. * Note: if set to an empty array no collision will happen when this mesh is moved.
  35707. */
  35708. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  35709. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  35710. /**
  35711. * Defines edge width used when edgesRenderer is enabled
  35712. * @see https://www.babylonjs-playground.com/#10OJSG#13
  35713. */
  35714. edgesWidth: number;
  35715. /**
  35716. * Defines edge color used when edgesRenderer is enabled
  35717. * @see https://www.babylonjs-playground.com/#10OJSG#13
  35718. */
  35719. edgesColor: Color4;
  35720. /** @hidden */
  35721. _edgesRenderer: Nullable<IEdgesRenderer>;
  35722. /** @hidden */
  35723. _masterMesh: Nullable<AbstractMesh>;
  35724. /** @hidden */
  35725. _boundingInfo: Nullable<BoundingInfo>;
  35726. /** @hidden */
  35727. _renderId: number;
  35728. /**
  35729. * Gets or sets the list of subMeshes
  35730. * @see https://doc.babylonjs.com/how_to/multi_materials
  35731. */
  35732. subMeshes: SubMesh[];
  35733. /** @hidden */
  35734. _intersectionsInProgress: AbstractMesh[];
  35735. /** @hidden */
  35736. _unIndexed: boolean;
  35737. /** @hidden */
  35738. _lightSources: Light[];
  35739. /** Gets the list of lights affecting that mesh */
  35740. get lightSources(): Light[];
  35741. /** @hidden */
  35742. get _positions(): Nullable<Vector3[]>;
  35743. /** @hidden */
  35744. _waitingData: {
  35745. lods: Nullable<any>;
  35746. actions: Nullable<any>;
  35747. freezeWorldMatrix: Nullable<boolean>;
  35748. };
  35749. /** @hidden */
  35750. _bonesTransformMatrices: Nullable<Float32Array>;
  35751. /** @hidden */
  35752. _transformMatrixTexture: Nullable<RawTexture>;
  35753. /**
  35754. * Gets or sets a skeleton to apply skining transformations
  35755. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35756. */
  35757. set skeleton(value: Nullable<Skeleton>);
  35758. get skeleton(): Nullable<Skeleton>;
  35759. /**
  35760. * An event triggered when the mesh is rebuilt.
  35761. */
  35762. onRebuildObservable: Observable<AbstractMesh>;
  35763. /**
  35764. * Creates a new AbstractMesh
  35765. * @param name defines the name of the mesh
  35766. * @param scene defines the hosting scene
  35767. */
  35768. constructor(name: string, scene?: Nullable<Scene>);
  35769. /**
  35770. * Returns the string "AbstractMesh"
  35771. * @returns "AbstractMesh"
  35772. */
  35773. getClassName(): string;
  35774. /**
  35775. * Gets a string representation of the current mesh
  35776. * @param fullDetails defines a boolean indicating if full details must be included
  35777. * @returns a string representation of the current mesh
  35778. */
  35779. toString(fullDetails?: boolean): string;
  35780. /**
  35781. * @hidden
  35782. */
  35783. protected _getEffectiveParent(): Nullable<Node>;
  35784. /** @hidden */
  35785. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  35786. /** @hidden */
  35787. _rebuild(): void;
  35788. /** @hidden */
  35789. _resyncLightSources(): void;
  35790. /** @hidden */
  35791. _resyncLightSource(light: Light): void;
  35792. /** @hidden */
  35793. _unBindEffect(): void;
  35794. /** @hidden */
  35795. _removeLightSource(light: Light, dispose: boolean): void;
  35796. private _markSubMeshesAsDirty;
  35797. /** @hidden */
  35798. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  35799. /** @hidden */
  35800. _markSubMeshesAsAttributesDirty(): void;
  35801. /** @hidden */
  35802. _markSubMeshesAsMiscDirty(): void;
  35803. /**
  35804. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  35805. */
  35806. get scaling(): Vector3;
  35807. set scaling(newScaling: Vector3);
  35808. /**
  35809. * Returns true if the mesh is blocked. Implemented by child classes
  35810. */
  35811. get isBlocked(): boolean;
  35812. /**
  35813. * Returns the mesh itself by default. Implemented by child classes
  35814. * @param camera defines the camera to use to pick the right LOD level
  35815. * @returns the currentAbstractMesh
  35816. */
  35817. getLOD(camera: Camera): Nullable<AbstractMesh>;
  35818. /**
  35819. * Returns 0 by default. Implemented by child classes
  35820. * @returns an integer
  35821. */
  35822. getTotalVertices(): number;
  35823. /**
  35824. * Returns a positive integer : the total number of indices in this mesh geometry.
  35825. * @returns the numner of indices or zero if the mesh has no geometry.
  35826. */
  35827. getTotalIndices(): number;
  35828. /**
  35829. * Returns null by default. Implemented by child classes
  35830. * @returns null
  35831. */
  35832. getIndices(): Nullable<IndicesArray>;
  35833. /**
  35834. * Returns the array of the requested vertex data kind. Implemented by child classes
  35835. * @param kind defines the vertex data kind to use
  35836. * @returns null
  35837. */
  35838. getVerticesData(kind: string): Nullable<FloatArray>;
  35839. /**
  35840. * Sets the vertex data of the mesh geometry for the requested `kind`.
  35841. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  35842. * Note that a new underlying VertexBuffer object is created each call.
  35843. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  35844. * @param kind defines vertex data kind:
  35845. * * VertexBuffer.PositionKind
  35846. * * VertexBuffer.UVKind
  35847. * * VertexBuffer.UV2Kind
  35848. * * VertexBuffer.UV3Kind
  35849. * * VertexBuffer.UV4Kind
  35850. * * VertexBuffer.UV5Kind
  35851. * * VertexBuffer.UV6Kind
  35852. * * VertexBuffer.ColorKind
  35853. * * VertexBuffer.MatricesIndicesKind
  35854. * * VertexBuffer.MatricesIndicesExtraKind
  35855. * * VertexBuffer.MatricesWeightsKind
  35856. * * VertexBuffer.MatricesWeightsExtraKind
  35857. * @param data defines the data source
  35858. * @param updatable defines if the data must be flagged as updatable (or static)
  35859. * @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
  35860. * @returns the current mesh
  35861. */
  35862. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  35863. /**
  35864. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  35865. * If the mesh has no geometry, it is simply returned as it is.
  35866. * @param kind defines vertex data kind:
  35867. * * VertexBuffer.PositionKind
  35868. * * VertexBuffer.UVKind
  35869. * * VertexBuffer.UV2Kind
  35870. * * VertexBuffer.UV3Kind
  35871. * * VertexBuffer.UV4Kind
  35872. * * VertexBuffer.UV5Kind
  35873. * * VertexBuffer.UV6Kind
  35874. * * VertexBuffer.ColorKind
  35875. * * VertexBuffer.MatricesIndicesKind
  35876. * * VertexBuffer.MatricesIndicesExtraKind
  35877. * * VertexBuffer.MatricesWeightsKind
  35878. * * VertexBuffer.MatricesWeightsExtraKind
  35879. * @param data defines the data source
  35880. * @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
  35881. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  35882. * @returns the current mesh
  35883. */
  35884. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  35885. /**
  35886. * Sets the mesh indices,
  35887. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  35888. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  35889. * @param totalVertices Defines the total number of vertices
  35890. * @returns the current mesh
  35891. */
  35892. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  35893. /**
  35894. * Gets a boolean indicating if specific vertex data is present
  35895. * @param kind defines the vertex data kind to use
  35896. * @returns true is data kind is present
  35897. */
  35898. isVerticesDataPresent(kind: string): boolean;
  35899. /**
  35900. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  35901. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  35902. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  35903. * @returns a BoundingInfo
  35904. */
  35905. getBoundingInfo(): BoundingInfo;
  35906. /**
  35907. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  35908. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  35909. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  35910. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  35911. * @returns the current mesh
  35912. */
  35913. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  35914. /**
  35915. * Overwrite the current bounding info
  35916. * @param boundingInfo defines the new bounding info
  35917. * @returns the current mesh
  35918. */
  35919. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  35920. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  35921. get useBones(): boolean;
  35922. /** @hidden */
  35923. _preActivate(): void;
  35924. /** @hidden */
  35925. _preActivateForIntermediateRendering(renderId: number): void;
  35926. /** @hidden */
  35927. _activate(renderId: number, intermediateRendering: boolean): boolean;
  35928. /** @hidden */
  35929. _postActivate(): void;
  35930. /** @hidden */
  35931. _freeze(): void;
  35932. /** @hidden */
  35933. _unFreeze(): void;
  35934. /**
  35935. * Gets the current world matrix
  35936. * @returns a Matrix
  35937. */
  35938. getWorldMatrix(): Matrix;
  35939. /** @hidden */
  35940. _getWorldMatrixDeterminant(): number;
  35941. /**
  35942. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  35943. */
  35944. get isAnInstance(): boolean;
  35945. /**
  35946. * Gets a boolean indicating if this mesh has instances
  35947. */
  35948. get hasInstances(): boolean;
  35949. /**
  35950. * Gets a boolean indicating if this mesh has thin instances
  35951. */
  35952. get hasThinInstances(): boolean;
  35953. /**
  35954. * Perform relative position change from the point of view of behind the front of the mesh.
  35955. * This is performed taking into account the meshes current rotation, so you do not have to care.
  35956. * Supports definition of mesh facing forward or backward
  35957. * @param amountRight defines the distance on the right axis
  35958. * @param amountUp defines the distance on the up axis
  35959. * @param amountForward defines the distance on the forward axis
  35960. * @returns the current mesh
  35961. */
  35962. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  35963. /**
  35964. * Calculate relative position change from the point of view of behind the front of the mesh.
  35965. * This is performed taking into account the meshes current rotation, so you do not have to care.
  35966. * Supports definition of mesh facing forward or backward
  35967. * @param amountRight defines the distance on the right axis
  35968. * @param amountUp defines the distance on the up axis
  35969. * @param amountForward defines the distance on the forward axis
  35970. * @returns the new displacement vector
  35971. */
  35972. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  35973. /**
  35974. * Perform relative rotation change from the point of view of behind the front of the mesh.
  35975. * Supports definition of mesh facing forward or backward
  35976. * @param flipBack defines the flip
  35977. * @param twirlClockwise defines the twirl
  35978. * @param tiltRight defines the tilt
  35979. * @returns the current mesh
  35980. */
  35981. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  35982. /**
  35983. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  35984. * Supports definition of mesh facing forward or backward.
  35985. * @param flipBack defines the flip
  35986. * @param twirlClockwise defines the twirl
  35987. * @param tiltRight defines the tilt
  35988. * @returns the new rotation vector
  35989. */
  35990. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  35991. /**
  35992. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  35993. * This means the mesh underlying bounding box and sphere are recomputed.
  35994. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  35995. * @returns the current mesh
  35996. */
  35997. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  35998. /** @hidden */
  35999. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  36000. /** @hidden */
  36001. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  36002. /** @hidden */
  36003. _updateBoundingInfo(): AbstractMesh;
  36004. /** @hidden */
  36005. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  36006. /** @hidden */
  36007. protected _afterComputeWorldMatrix(): void;
  36008. /** @hidden */
  36009. get _effectiveMesh(): AbstractMesh;
  36010. /**
  36011. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  36012. * A mesh is in the frustum if its bounding box intersects the frustum
  36013. * @param frustumPlanes defines the frustum to test
  36014. * @returns true if the mesh is in the frustum planes
  36015. */
  36016. isInFrustum(frustumPlanes: Plane[]): boolean;
  36017. /**
  36018. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  36019. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  36020. * @param frustumPlanes defines the frustum to test
  36021. * @returns true if the mesh is completely in the frustum planes
  36022. */
  36023. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  36024. /**
  36025. * True if the mesh intersects another mesh or a SolidParticle object
  36026. * @param mesh defines a target mesh or SolidParticle to test
  36027. * @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)
  36028. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  36029. * @returns true if there is an intersection
  36030. */
  36031. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  36032. /**
  36033. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  36034. * @param point defines the point to test
  36035. * @returns true if there is an intersection
  36036. */
  36037. intersectsPoint(point: Vector3): boolean;
  36038. /**
  36039. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  36040. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36041. */
  36042. get checkCollisions(): boolean;
  36043. set checkCollisions(collisionEnabled: boolean);
  36044. /**
  36045. * Gets Collider object used to compute collisions (not physics)
  36046. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36047. */
  36048. get collider(): Nullable<Collider>;
  36049. /**
  36050. * Move the mesh using collision engine
  36051. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36052. * @param displacement defines the requested displacement vector
  36053. * @returns the current mesh
  36054. */
  36055. moveWithCollisions(displacement: Vector3): AbstractMesh;
  36056. private _onCollisionPositionChange;
  36057. /** @hidden */
  36058. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  36059. /** @hidden */
  36060. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  36061. /** @hidden */
  36062. _checkCollision(collider: Collider): AbstractMesh;
  36063. /** @hidden */
  36064. _generatePointsArray(): boolean;
  36065. /**
  36066. * Checks if the passed Ray intersects with the mesh
  36067. * @param ray defines the ray to use
  36068. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  36069. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36070. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  36071. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  36072. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  36073. * @returns the picking info
  36074. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  36075. */
  36076. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  36077. /**
  36078. * Clones the current mesh
  36079. * @param name defines the mesh name
  36080. * @param newParent defines the new mesh parent
  36081. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  36082. * @returns the new mesh
  36083. */
  36084. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  36085. /**
  36086. * Disposes all the submeshes of the current meshnp
  36087. * @returns the current mesh
  36088. */
  36089. releaseSubMeshes(): AbstractMesh;
  36090. /**
  36091. * Releases resources associated with this abstract mesh.
  36092. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  36093. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  36094. */
  36095. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  36096. /**
  36097. * Adds the passed mesh as a child to the current mesh
  36098. * @param mesh defines the child mesh
  36099. * @returns the current mesh
  36100. */
  36101. addChild(mesh: AbstractMesh): AbstractMesh;
  36102. /**
  36103. * Removes the passed mesh from the current mesh children list
  36104. * @param mesh defines the child mesh
  36105. * @returns the current mesh
  36106. */
  36107. removeChild(mesh: AbstractMesh): AbstractMesh;
  36108. /** @hidden */
  36109. private _initFacetData;
  36110. /**
  36111. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  36112. * This method can be called within the render loop.
  36113. * 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
  36114. * @returns the current mesh
  36115. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36116. */
  36117. updateFacetData(): AbstractMesh;
  36118. /**
  36119. * Returns the facetLocalNormals array.
  36120. * The normals are expressed in the mesh local spac
  36121. * @returns an array of Vector3
  36122. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36123. */
  36124. getFacetLocalNormals(): Vector3[];
  36125. /**
  36126. * Returns the facetLocalPositions array.
  36127. * The facet positions are expressed in the mesh local space
  36128. * @returns an array of Vector3
  36129. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36130. */
  36131. getFacetLocalPositions(): Vector3[];
  36132. /**
  36133. * Returns the facetLocalPartioning array
  36134. * @returns an array of array of numbers
  36135. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36136. */
  36137. getFacetLocalPartitioning(): number[][];
  36138. /**
  36139. * Returns the i-th facet position in the world system.
  36140. * This method allocates a new Vector3 per call
  36141. * @param i defines the facet index
  36142. * @returns a new Vector3
  36143. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36144. */
  36145. getFacetPosition(i: number): Vector3;
  36146. /**
  36147. * Sets the reference Vector3 with the i-th facet position in the world system
  36148. * @param i defines the facet index
  36149. * @param ref defines the target vector
  36150. * @returns the current mesh
  36151. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36152. */
  36153. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  36154. /**
  36155. * Returns the i-th facet normal in the world system.
  36156. * This method allocates a new Vector3 per call
  36157. * @param i defines the facet index
  36158. * @returns a new Vector3
  36159. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36160. */
  36161. getFacetNormal(i: number): Vector3;
  36162. /**
  36163. * Sets the reference Vector3 with the i-th facet normal in the world system
  36164. * @param i defines the facet index
  36165. * @param ref defines the target vector
  36166. * @returns the current mesh
  36167. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36168. */
  36169. getFacetNormalToRef(i: number, ref: Vector3): this;
  36170. /**
  36171. * 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)
  36172. * @param x defines x coordinate
  36173. * @param y defines y coordinate
  36174. * @param z defines z coordinate
  36175. * @returns the array of facet indexes
  36176. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36177. */
  36178. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  36179. /**
  36180. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  36181. * @param projected sets as the (x,y,z) world projection on the facet
  36182. * @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
  36183. * @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
  36184. * @param x defines x coordinate
  36185. * @param y defines y coordinate
  36186. * @param z defines z coordinate
  36187. * @returns the face index if found (or null instead)
  36188. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36189. */
  36190. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  36191. /**
  36192. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  36193. * @param projected sets as the (x,y,z) local projection on the facet
  36194. * @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
  36195. * @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
  36196. * @param x defines x coordinate
  36197. * @param y defines y coordinate
  36198. * @param z defines z coordinate
  36199. * @returns the face index if found (or null instead)
  36200. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36201. */
  36202. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  36203. /**
  36204. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  36205. * @returns the parameters
  36206. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36207. */
  36208. getFacetDataParameters(): any;
  36209. /**
  36210. * Disables the feature FacetData and frees the related memory
  36211. * @returns the current mesh
  36212. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36213. */
  36214. disableFacetData(): AbstractMesh;
  36215. /**
  36216. * Updates the AbstractMesh indices array
  36217. * @param indices defines the data source
  36218. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  36219. * @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)
  36220. * @returns the current mesh
  36221. */
  36222. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  36223. /**
  36224. * Creates new normals data for the mesh
  36225. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  36226. * @returns the current mesh
  36227. */
  36228. createNormals(updatable: boolean): AbstractMesh;
  36229. /**
  36230. * Align the mesh with a normal
  36231. * @param normal defines the normal to use
  36232. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  36233. * @returns the current mesh
  36234. */
  36235. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  36236. /** @hidden */
  36237. _checkOcclusionQuery(): boolean;
  36238. /**
  36239. * Disables the mesh edge rendering mode
  36240. * @returns the currentAbstractMesh
  36241. */
  36242. disableEdgesRendering(): AbstractMesh;
  36243. /**
  36244. * Enables the edge rendering mode on the mesh.
  36245. * This mode makes the mesh edges visible
  36246. * @param epsilon defines the maximal distance between two angles to detect a face
  36247. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  36248. * @returns the currentAbstractMesh
  36249. * @see https://www.babylonjs-playground.com/#19O9TU#0
  36250. */
  36251. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  36252. /**
  36253. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  36254. * @returns an array of particle systems in the scene that use the mesh as an emitter
  36255. */
  36256. getConnectedParticleSystems(): IParticleSystem[];
  36257. }
  36258. }
  36259. declare module BABYLON {
  36260. /**
  36261. * Interface used to define ActionEvent
  36262. */
  36263. export interface IActionEvent {
  36264. /** The mesh or sprite that triggered the action */
  36265. source: any;
  36266. /** The X mouse cursor position at the time of the event */
  36267. pointerX: number;
  36268. /** The Y mouse cursor position at the time of the event */
  36269. pointerY: number;
  36270. /** The mesh that is currently pointed at (can be null) */
  36271. meshUnderPointer: Nullable<AbstractMesh>;
  36272. /** the original (browser) event that triggered the ActionEvent */
  36273. sourceEvent?: any;
  36274. /** additional data for the event */
  36275. additionalData?: any;
  36276. }
  36277. /**
  36278. * ActionEvent is the event being sent when an action is triggered.
  36279. */
  36280. export class ActionEvent implements IActionEvent {
  36281. /** The mesh or sprite that triggered the action */
  36282. source: any;
  36283. /** The X mouse cursor position at the time of the event */
  36284. pointerX: number;
  36285. /** The Y mouse cursor position at the time of the event */
  36286. pointerY: number;
  36287. /** The mesh that is currently pointed at (can be null) */
  36288. meshUnderPointer: Nullable<AbstractMesh>;
  36289. /** the original (browser) event that triggered the ActionEvent */
  36290. sourceEvent?: any;
  36291. /** additional data for the event */
  36292. additionalData?: any;
  36293. /**
  36294. * Creates a new ActionEvent
  36295. * @param source The mesh or sprite that triggered the action
  36296. * @param pointerX The X mouse cursor position at the time of the event
  36297. * @param pointerY The Y mouse cursor position at the time of the event
  36298. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  36299. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  36300. * @param additionalData additional data for the event
  36301. */
  36302. constructor(
  36303. /** The mesh or sprite that triggered the action */
  36304. source: any,
  36305. /** The X mouse cursor position at the time of the event */
  36306. pointerX: number,
  36307. /** The Y mouse cursor position at the time of the event */
  36308. pointerY: number,
  36309. /** The mesh that is currently pointed at (can be null) */
  36310. meshUnderPointer: Nullable<AbstractMesh>,
  36311. /** the original (browser) event that triggered the ActionEvent */
  36312. sourceEvent?: any,
  36313. /** additional data for the event */
  36314. additionalData?: any);
  36315. /**
  36316. * Helper function to auto-create an ActionEvent from a source mesh.
  36317. * @param source The source mesh that triggered the event
  36318. * @param evt The original (browser) event
  36319. * @param additionalData additional data for the event
  36320. * @returns the new ActionEvent
  36321. */
  36322. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  36323. /**
  36324. * Helper function to auto-create an ActionEvent from a source sprite
  36325. * @param source The source sprite that triggered the event
  36326. * @param scene Scene associated with the sprite
  36327. * @param evt The original (browser) event
  36328. * @param additionalData additional data for the event
  36329. * @returns the new ActionEvent
  36330. */
  36331. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  36332. /**
  36333. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  36334. * @param scene the scene where the event occurred
  36335. * @param evt The original (browser) event
  36336. * @returns the new ActionEvent
  36337. */
  36338. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  36339. /**
  36340. * Helper function to auto-create an ActionEvent from a primitive
  36341. * @param prim defines the target primitive
  36342. * @param pointerPos defines the pointer position
  36343. * @param evt The original (browser) event
  36344. * @param additionalData additional data for the event
  36345. * @returns the new ActionEvent
  36346. */
  36347. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  36348. }
  36349. }
  36350. declare module BABYLON {
  36351. /**
  36352. * Abstract class used to decouple action Manager from scene and meshes.
  36353. * Do not instantiate.
  36354. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36355. */
  36356. export abstract class AbstractActionManager implements IDisposable {
  36357. /** Gets the list of active triggers */
  36358. static Triggers: {
  36359. [key: string]: number;
  36360. };
  36361. /** Gets the cursor to use when hovering items */
  36362. hoverCursor: string;
  36363. /** Gets the list of actions */
  36364. actions: IAction[];
  36365. /**
  36366. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  36367. */
  36368. isRecursive: boolean;
  36369. /**
  36370. * Releases all associated resources
  36371. */
  36372. abstract dispose(): void;
  36373. /**
  36374. * Does this action manager has pointer triggers
  36375. */
  36376. abstract get hasPointerTriggers(): boolean;
  36377. /**
  36378. * Does this action manager has pick triggers
  36379. */
  36380. abstract get hasPickTriggers(): boolean;
  36381. /**
  36382. * Process a specific trigger
  36383. * @param trigger defines the trigger to process
  36384. * @param evt defines the event details to be processed
  36385. */
  36386. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  36387. /**
  36388. * Does this action manager handles actions of any of the given triggers
  36389. * @param triggers defines the triggers to be tested
  36390. * @return a boolean indicating whether one (or more) of the triggers is handled
  36391. */
  36392. abstract hasSpecificTriggers(triggers: number[]): boolean;
  36393. /**
  36394. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  36395. * speed.
  36396. * @param triggerA defines the trigger to be tested
  36397. * @param triggerB defines the trigger to be tested
  36398. * @return a boolean indicating whether one (or more) of the triggers is handled
  36399. */
  36400. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  36401. /**
  36402. * Does this action manager handles actions of a given trigger
  36403. * @param trigger defines the trigger to be tested
  36404. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  36405. * @return whether the trigger is handled
  36406. */
  36407. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  36408. /**
  36409. * Serialize this manager to a JSON object
  36410. * @param name defines the property name to store this manager
  36411. * @returns a JSON representation of this manager
  36412. */
  36413. abstract serialize(name: string): any;
  36414. /**
  36415. * Registers an action to this action manager
  36416. * @param action defines the action to be registered
  36417. * @return the action amended (prepared) after registration
  36418. */
  36419. abstract registerAction(action: IAction): Nullable<IAction>;
  36420. /**
  36421. * Unregisters an action to this action manager
  36422. * @param action defines the action to be unregistered
  36423. * @return a boolean indicating whether the action has been unregistered
  36424. */
  36425. abstract unregisterAction(action: IAction): Boolean;
  36426. /**
  36427. * Does exist one action manager with at least one trigger
  36428. **/
  36429. static get HasTriggers(): boolean;
  36430. /**
  36431. * Does exist one action manager with at least one pick trigger
  36432. **/
  36433. static get HasPickTriggers(): boolean;
  36434. /**
  36435. * Does exist one action manager that handles actions of a given trigger
  36436. * @param trigger defines the trigger to be tested
  36437. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  36438. **/
  36439. static HasSpecificTrigger(trigger: number): boolean;
  36440. }
  36441. }
  36442. declare module BABYLON {
  36443. /**
  36444. * Defines how a node can be built from a string name.
  36445. */
  36446. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  36447. /**
  36448. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  36449. */
  36450. export class Node implements IBehaviorAware<Node> {
  36451. /** @hidden */
  36452. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  36453. private static _NodeConstructors;
  36454. /**
  36455. * Add a new node constructor
  36456. * @param type defines the type name of the node to construct
  36457. * @param constructorFunc defines the constructor function
  36458. */
  36459. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  36460. /**
  36461. * Returns a node constructor based on type name
  36462. * @param type defines the type name
  36463. * @param name defines the new node name
  36464. * @param scene defines the hosting scene
  36465. * @param options defines optional options to transmit to constructors
  36466. * @returns the new constructor or null
  36467. */
  36468. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  36469. /**
  36470. * Gets or sets the name of the node
  36471. */
  36472. name: string;
  36473. /**
  36474. * Gets or sets the id of the node
  36475. */
  36476. id: string;
  36477. /**
  36478. * Gets or sets the unique id of the node
  36479. */
  36480. uniqueId: number;
  36481. /**
  36482. * Gets or sets a string used to store user defined state for the node
  36483. */
  36484. state: string;
  36485. /**
  36486. * Gets or sets an object used to store user defined information for the node
  36487. */
  36488. metadata: any;
  36489. /**
  36490. * For internal use only. Please do not use.
  36491. */
  36492. reservedDataStore: any;
  36493. /**
  36494. * List of inspectable custom properties (used by the Inspector)
  36495. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  36496. */
  36497. inspectableCustomProperties: IInspectable[];
  36498. private _doNotSerialize;
  36499. /**
  36500. * Gets or sets a boolean used to define if the node must be serialized
  36501. */
  36502. get doNotSerialize(): boolean;
  36503. set doNotSerialize(value: boolean);
  36504. /** @hidden */
  36505. _isDisposed: boolean;
  36506. /**
  36507. * Gets a list of Animations associated with the node
  36508. */
  36509. animations: Animation[];
  36510. protected _ranges: {
  36511. [name: string]: Nullable<AnimationRange>;
  36512. };
  36513. /**
  36514. * Callback raised when the node is ready to be used
  36515. */
  36516. onReady: Nullable<(node: Node) => void>;
  36517. private _isEnabled;
  36518. private _isParentEnabled;
  36519. private _isReady;
  36520. /** @hidden */
  36521. _currentRenderId: number;
  36522. private _parentUpdateId;
  36523. /** @hidden */
  36524. _childUpdateId: number;
  36525. /** @hidden */
  36526. _waitingParentId: Nullable<string>;
  36527. /** @hidden */
  36528. _scene: Scene;
  36529. /** @hidden */
  36530. _cache: any;
  36531. private _parentNode;
  36532. private _children;
  36533. /** @hidden */
  36534. _worldMatrix: Matrix;
  36535. /** @hidden */
  36536. _worldMatrixDeterminant: number;
  36537. /** @hidden */
  36538. _worldMatrixDeterminantIsDirty: boolean;
  36539. /** @hidden */
  36540. private _sceneRootNodesIndex;
  36541. /**
  36542. * Gets a boolean indicating if the node has been disposed
  36543. * @returns true if the node was disposed
  36544. */
  36545. isDisposed(): boolean;
  36546. /**
  36547. * Gets or sets the parent of the node (without keeping the current position in the scene)
  36548. * @see https://doc.babylonjs.com/how_to/parenting
  36549. */
  36550. set parent(parent: Nullable<Node>);
  36551. get parent(): Nullable<Node>;
  36552. /** @hidden */
  36553. _addToSceneRootNodes(): void;
  36554. /** @hidden */
  36555. _removeFromSceneRootNodes(): void;
  36556. private _animationPropertiesOverride;
  36557. /**
  36558. * Gets or sets the animation properties override
  36559. */
  36560. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36561. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36562. /**
  36563. * Gets a string identifying the name of the class
  36564. * @returns "Node" string
  36565. */
  36566. getClassName(): string;
  36567. /** @hidden */
  36568. readonly _isNode: boolean;
  36569. /**
  36570. * An event triggered when the mesh is disposed
  36571. */
  36572. onDisposeObservable: Observable<Node>;
  36573. private _onDisposeObserver;
  36574. /**
  36575. * Sets a callback that will be raised when the node will be disposed
  36576. */
  36577. set onDispose(callback: () => void);
  36578. /**
  36579. * Creates a new Node
  36580. * @param name the name and id to be given to this node
  36581. * @param scene the scene this node will be added to
  36582. */
  36583. constructor(name: string, scene?: Nullable<Scene>);
  36584. /**
  36585. * Gets the scene of the node
  36586. * @returns a scene
  36587. */
  36588. getScene(): Scene;
  36589. /**
  36590. * Gets the engine of the node
  36591. * @returns a Engine
  36592. */
  36593. getEngine(): Engine;
  36594. private _behaviors;
  36595. /**
  36596. * Attach a behavior to the node
  36597. * @see https://doc.babylonjs.com/features/behaviour
  36598. * @param behavior defines the behavior to attach
  36599. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  36600. * @returns the current Node
  36601. */
  36602. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  36603. /**
  36604. * Remove an attached behavior
  36605. * @see https://doc.babylonjs.com/features/behaviour
  36606. * @param behavior defines the behavior to attach
  36607. * @returns the current Node
  36608. */
  36609. removeBehavior(behavior: Behavior<Node>): Node;
  36610. /**
  36611. * Gets the list of attached behaviors
  36612. * @see https://doc.babylonjs.com/features/behaviour
  36613. */
  36614. get behaviors(): Behavior<Node>[];
  36615. /**
  36616. * Gets an attached behavior by name
  36617. * @param name defines the name of the behavior to look for
  36618. * @see https://doc.babylonjs.com/features/behaviour
  36619. * @returns null if behavior was not found else the requested behavior
  36620. */
  36621. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  36622. /**
  36623. * Returns the latest update of the World matrix
  36624. * @returns a Matrix
  36625. */
  36626. getWorldMatrix(): Matrix;
  36627. /** @hidden */
  36628. _getWorldMatrixDeterminant(): number;
  36629. /**
  36630. * Returns directly the latest state of the mesh World matrix.
  36631. * A Matrix is returned.
  36632. */
  36633. get worldMatrixFromCache(): Matrix;
  36634. /** @hidden */
  36635. _initCache(): void;
  36636. /** @hidden */
  36637. updateCache(force?: boolean): void;
  36638. /** @hidden */
  36639. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36640. /** @hidden */
  36641. _updateCache(ignoreParentClass?: boolean): void;
  36642. /** @hidden */
  36643. _isSynchronized(): boolean;
  36644. /** @hidden */
  36645. _markSyncedWithParent(): void;
  36646. /** @hidden */
  36647. isSynchronizedWithParent(): boolean;
  36648. /** @hidden */
  36649. isSynchronized(): boolean;
  36650. /**
  36651. * Is this node ready to be used/rendered
  36652. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  36653. * @return true if the node is ready
  36654. */
  36655. isReady(completeCheck?: boolean): boolean;
  36656. /**
  36657. * Is this node enabled?
  36658. * 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
  36659. * @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
  36660. * @return whether this node (and its parent) is enabled
  36661. */
  36662. isEnabled(checkAncestors?: boolean): boolean;
  36663. /** @hidden */
  36664. protected _syncParentEnabledState(): void;
  36665. /**
  36666. * Set the enabled state of this node
  36667. * @param value defines the new enabled state
  36668. */
  36669. setEnabled(value: boolean): void;
  36670. /**
  36671. * Is this node a descendant of the given node?
  36672. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  36673. * @param ancestor defines the parent node to inspect
  36674. * @returns a boolean indicating if this node is a descendant of the given node
  36675. */
  36676. isDescendantOf(ancestor: Node): boolean;
  36677. /** @hidden */
  36678. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  36679. /**
  36680. * Will return all nodes that have this node as ascendant
  36681. * @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
  36682. * @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
  36683. * @return all children nodes of all types
  36684. */
  36685. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  36686. /**
  36687. * Get all child-meshes of this node
  36688. * @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)
  36689. * @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
  36690. * @returns an array of AbstractMesh
  36691. */
  36692. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  36693. /**
  36694. * Get all direct children of this node
  36695. * @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
  36696. * @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)
  36697. * @returns an array of Node
  36698. */
  36699. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  36700. /** @hidden */
  36701. _setReady(state: boolean): void;
  36702. /**
  36703. * Get an animation by name
  36704. * @param name defines the name of the animation to look for
  36705. * @returns null if not found else the requested animation
  36706. */
  36707. getAnimationByName(name: string): Nullable<Animation>;
  36708. /**
  36709. * Creates an animation range for this node
  36710. * @param name defines the name of the range
  36711. * @param from defines the starting key
  36712. * @param to defines the end key
  36713. */
  36714. createAnimationRange(name: string, from: number, to: number): void;
  36715. /**
  36716. * Delete a specific animation range
  36717. * @param name defines the name of the range to delete
  36718. * @param deleteFrames defines if animation frames from the range must be deleted as well
  36719. */
  36720. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  36721. /**
  36722. * Get an animation range by name
  36723. * @param name defines the name of the animation range to look for
  36724. * @returns null if not found else the requested animation range
  36725. */
  36726. getAnimationRange(name: string): Nullable<AnimationRange>;
  36727. /**
  36728. * Gets the list of all animation ranges defined on this node
  36729. * @returns an array
  36730. */
  36731. getAnimationRanges(): Nullable<AnimationRange>[];
  36732. /**
  36733. * Will start the animation sequence
  36734. * @param name defines the range frames for animation sequence
  36735. * @param loop defines if the animation should loop (false by default)
  36736. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  36737. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  36738. * @returns the object created for this animation. If range does not exist, it will return null
  36739. */
  36740. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  36741. /**
  36742. * Serialize animation ranges into a JSON compatible object
  36743. * @returns serialization object
  36744. */
  36745. serializeAnimationRanges(): any;
  36746. /**
  36747. * Computes the world matrix of the node
  36748. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  36749. * @returns the world matrix
  36750. */
  36751. computeWorldMatrix(force?: boolean): Matrix;
  36752. /**
  36753. * Releases resources associated with this node.
  36754. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  36755. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  36756. */
  36757. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  36758. /**
  36759. * Parse animation range data from a serialization object and store them into a given node
  36760. * @param node defines where to store the animation ranges
  36761. * @param parsedNode defines the serialization object to read data from
  36762. * @param scene defines the hosting scene
  36763. */
  36764. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  36765. /**
  36766. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  36767. * @param includeDescendants Include bounding info from descendants as well (true by default)
  36768. * @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
  36769. * @returns the new bounding vectors
  36770. */
  36771. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  36772. min: Vector3;
  36773. max: Vector3;
  36774. };
  36775. }
  36776. }
  36777. declare module BABYLON {
  36778. /**
  36779. * @hidden
  36780. */
  36781. export class _IAnimationState {
  36782. key: number;
  36783. repeatCount: number;
  36784. workValue?: any;
  36785. loopMode?: number;
  36786. offsetValue?: any;
  36787. highLimitValue?: any;
  36788. }
  36789. /**
  36790. * Class used to store any kind of animation
  36791. */
  36792. export class Animation {
  36793. /**Name of the animation */
  36794. name: string;
  36795. /**Property to animate */
  36796. targetProperty: string;
  36797. /**The frames per second of the animation */
  36798. framePerSecond: number;
  36799. /**The data type of the animation */
  36800. dataType: number;
  36801. /**The loop mode of the animation */
  36802. loopMode?: number | undefined;
  36803. /**Specifies if blending should be enabled */
  36804. enableBlending?: boolean | undefined;
  36805. /**
  36806. * Use matrix interpolation instead of using direct key value when animating matrices
  36807. */
  36808. static AllowMatricesInterpolation: boolean;
  36809. /**
  36810. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  36811. */
  36812. static AllowMatrixDecomposeForInterpolation: boolean;
  36813. /** Define the Url to load snippets */
  36814. static SnippetUrl: string;
  36815. /** Snippet ID if the animation was created from the snippet server */
  36816. snippetId: string;
  36817. /**
  36818. * Stores the key frames of the animation
  36819. */
  36820. private _keys;
  36821. /**
  36822. * Stores the easing function of the animation
  36823. */
  36824. private _easingFunction;
  36825. /**
  36826. * @hidden Internal use only
  36827. */
  36828. _runtimeAnimations: RuntimeAnimation[];
  36829. /**
  36830. * The set of event that will be linked to this animation
  36831. */
  36832. private _events;
  36833. /**
  36834. * Stores an array of target property paths
  36835. */
  36836. targetPropertyPath: string[];
  36837. /**
  36838. * Stores the blending speed of the animation
  36839. */
  36840. blendingSpeed: number;
  36841. /**
  36842. * Stores the animation ranges for the animation
  36843. */
  36844. private _ranges;
  36845. /**
  36846. * @hidden Internal use
  36847. */
  36848. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  36849. /**
  36850. * Sets up an animation
  36851. * @param property The property to animate
  36852. * @param animationType The animation type to apply
  36853. * @param framePerSecond The frames per second of the animation
  36854. * @param easingFunction The easing function used in the animation
  36855. * @returns The created animation
  36856. */
  36857. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  36858. /**
  36859. * Create and start an animation on a node
  36860. * @param name defines the name of the global animation that will be run on all nodes
  36861. * @param node defines the root node where the animation will take place
  36862. * @param targetProperty defines property to animate
  36863. * @param framePerSecond defines the number of frame per second yo use
  36864. * @param totalFrame defines the number of frames in total
  36865. * @param from defines the initial value
  36866. * @param to defines the final value
  36867. * @param loopMode defines which loop mode you want to use (off by default)
  36868. * @param easingFunction defines the easing function to use (linear by default)
  36869. * @param onAnimationEnd defines the callback to call when animation end
  36870. * @returns the animatable created for this animation
  36871. */
  36872. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  36873. /**
  36874. * Create and start an animation on a node and its descendants
  36875. * @param name defines the name of the global animation that will be run on all nodes
  36876. * @param node defines the root node where the animation will take place
  36877. * @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
  36878. * @param targetProperty defines property to animate
  36879. * @param framePerSecond defines the number of frame per second to use
  36880. * @param totalFrame defines the number of frames in total
  36881. * @param from defines the initial value
  36882. * @param to defines the final value
  36883. * @param loopMode defines which loop mode you want to use (off by default)
  36884. * @param easingFunction defines the easing function to use (linear by default)
  36885. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  36886. * @returns the list of animatables created for all nodes
  36887. * @example https://www.babylonjs-playground.com/#MH0VLI
  36888. */
  36889. 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[]>;
  36890. /**
  36891. * Creates a new animation, merges it with the existing animations and starts it
  36892. * @param name Name of the animation
  36893. * @param node Node which contains the scene that begins the animations
  36894. * @param targetProperty Specifies which property to animate
  36895. * @param framePerSecond The frames per second of the animation
  36896. * @param totalFrame The total number of frames
  36897. * @param from The frame at the beginning of the animation
  36898. * @param to The frame at the end of the animation
  36899. * @param loopMode Specifies the loop mode of the animation
  36900. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  36901. * @param onAnimationEnd Callback to run once the animation is complete
  36902. * @returns Nullable animation
  36903. */
  36904. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  36905. /**
  36906. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  36907. * @param sourceAnimation defines the Animation containing keyframes to convert
  36908. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  36909. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  36910. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  36911. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  36912. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  36913. */
  36914. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  36915. /**
  36916. * Transition property of an host to the target Value
  36917. * @param property The property to transition
  36918. * @param targetValue The target Value of the property
  36919. * @param host The object where the property to animate belongs
  36920. * @param scene Scene used to run the animation
  36921. * @param frameRate Framerate (in frame/s) to use
  36922. * @param transition The transition type we want to use
  36923. * @param duration The duration of the animation, in milliseconds
  36924. * @param onAnimationEnd Callback trigger at the end of the animation
  36925. * @returns Nullable animation
  36926. */
  36927. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  36928. /**
  36929. * Return the array of runtime animations currently using this animation
  36930. */
  36931. get runtimeAnimations(): RuntimeAnimation[];
  36932. /**
  36933. * Specifies if any of the runtime animations are currently running
  36934. */
  36935. get hasRunningRuntimeAnimations(): boolean;
  36936. /**
  36937. * Initializes the animation
  36938. * @param name Name of the animation
  36939. * @param targetProperty Property to animate
  36940. * @param framePerSecond The frames per second of the animation
  36941. * @param dataType The data type of the animation
  36942. * @param loopMode The loop mode of the animation
  36943. * @param enableBlending Specifies if blending should be enabled
  36944. */
  36945. constructor(
  36946. /**Name of the animation */
  36947. name: string,
  36948. /**Property to animate */
  36949. targetProperty: string,
  36950. /**The frames per second of the animation */
  36951. framePerSecond: number,
  36952. /**The data type of the animation */
  36953. dataType: number,
  36954. /**The loop mode of the animation */
  36955. loopMode?: number | undefined,
  36956. /**Specifies if blending should be enabled */
  36957. enableBlending?: boolean | undefined);
  36958. /**
  36959. * Converts the animation to a string
  36960. * @param fullDetails support for multiple levels of logging within scene loading
  36961. * @returns String form of the animation
  36962. */
  36963. toString(fullDetails?: boolean): string;
  36964. /**
  36965. * Add an event to this animation
  36966. * @param event Event to add
  36967. */
  36968. addEvent(event: AnimationEvent): void;
  36969. /**
  36970. * Remove all events found at the given frame
  36971. * @param frame The frame to remove events from
  36972. */
  36973. removeEvents(frame: number): void;
  36974. /**
  36975. * Retrieves all the events from the animation
  36976. * @returns Events from the animation
  36977. */
  36978. getEvents(): AnimationEvent[];
  36979. /**
  36980. * Creates an animation range
  36981. * @param name Name of the animation range
  36982. * @param from Starting frame of the animation range
  36983. * @param to Ending frame of the animation
  36984. */
  36985. createRange(name: string, from: number, to: number): void;
  36986. /**
  36987. * Deletes an animation range by name
  36988. * @param name Name of the animation range to delete
  36989. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  36990. */
  36991. deleteRange(name: string, deleteFrames?: boolean): void;
  36992. /**
  36993. * Gets the animation range by name, or null if not defined
  36994. * @param name Name of the animation range
  36995. * @returns Nullable animation range
  36996. */
  36997. getRange(name: string): Nullable<AnimationRange>;
  36998. /**
  36999. * Gets the key frames from the animation
  37000. * @returns The key frames of the animation
  37001. */
  37002. getKeys(): Array<IAnimationKey>;
  37003. /**
  37004. * Gets the highest frame rate of the animation
  37005. * @returns Highest frame rate of the animation
  37006. */
  37007. getHighestFrame(): number;
  37008. /**
  37009. * Gets the easing function of the animation
  37010. * @returns Easing function of the animation
  37011. */
  37012. getEasingFunction(): IEasingFunction;
  37013. /**
  37014. * Sets the easing function of the animation
  37015. * @param easingFunction A custom mathematical formula for animation
  37016. */
  37017. setEasingFunction(easingFunction: EasingFunction): void;
  37018. /**
  37019. * Interpolates a scalar linearly
  37020. * @param startValue Start value of the animation curve
  37021. * @param endValue End value of the animation curve
  37022. * @param gradient Scalar amount to interpolate
  37023. * @returns Interpolated scalar value
  37024. */
  37025. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  37026. /**
  37027. * Interpolates a scalar cubically
  37028. * @param startValue Start value of the animation curve
  37029. * @param outTangent End tangent of the animation
  37030. * @param endValue End value of the animation curve
  37031. * @param inTangent Start tangent of the animation curve
  37032. * @param gradient Scalar amount to interpolate
  37033. * @returns Interpolated scalar value
  37034. */
  37035. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  37036. /**
  37037. * Interpolates a quaternion using a spherical linear interpolation
  37038. * @param startValue Start value of the animation curve
  37039. * @param endValue End value of the animation curve
  37040. * @param gradient Scalar amount to interpolate
  37041. * @returns Interpolated quaternion value
  37042. */
  37043. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  37044. /**
  37045. * Interpolates a quaternion cubically
  37046. * @param startValue Start value of the animation curve
  37047. * @param outTangent End tangent of the animation curve
  37048. * @param endValue End value of the animation curve
  37049. * @param inTangent Start tangent of the animation curve
  37050. * @param gradient Scalar amount to interpolate
  37051. * @returns Interpolated quaternion value
  37052. */
  37053. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  37054. /**
  37055. * Interpolates a Vector3 linearl
  37056. * @param startValue Start value of the animation curve
  37057. * @param endValue End value of the animation curve
  37058. * @param gradient Scalar amount to interpolate
  37059. * @returns Interpolated scalar value
  37060. */
  37061. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  37062. /**
  37063. * Interpolates a Vector3 cubically
  37064. * @param startValue Start value of the animation curve
  37065. * @param outTangent End tangent of the animation
  37066. * @param endValue End value of the animation curve
  37067. * @param inTangent Start tangent of the animation curve
  37068. * @param gradient Scalar amount to interpolate
  37069. * @returns InterpolatedVector3 value
  37070. */
  37071. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  37072. /**
  37073. * Interpolates a Vector2 linearly
  37074. * @param startValue Start value of the animation curve
  37075. * @param endValue End value of the animation curve
  37076. * @param gradient Scalar amount to interpolate
  37077. * @returns Interpolated Vector2 value
  37078. */
  37079. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  37080. /**
  37081. * Interpolates a Vector2 cubically
  37082. * @param startValue Start value of the animation curve
  37083. * @param outTangent End tangent of the animation
  37084. * @param endValue End value of the animation curve
  37085. * @param inTangent Start tangent of the animation curve
  37086. * @param gradient Scalar amount to interpolate
  37087. * @returns Interpolated Vector2 value
  37088. */
  37089. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  37090. /**
  37091. * Interpolates a size linearly
  37092. * @param startValue Start value of the animation curve
  37093. * @param endValue End value of the animation curve
  37094. * @param gradient Scalar amount to interpolate
  37095. * @returns Interpolated Size value
  37096. */
  37097. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  37098. /**
  37099. * Interpolates a Color3 linearly
  37100. * @param startValue Start value of the animation curve
  37101. * @param endValue End value of the animation curve
  37102. * @param gradient Scalar amount to interpolate
  37103. * @returns Interpolated Color3 value
  37104. */
  37105. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  37106. /**
  37107. * Interpolates a Color4 linearly
  37108. * @param startValue Start value of the animation curve
  37109. * @param endValue End value of the animation curve
  37110. * @param gradient Scalar amount to interpolate
  37111. * @returns Interpolated Color3 value
  37112. */
  37113. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  37114. /**
  37115. * @hidden Internal use only
  37116. */
  37117. _getKeyValue(value: any): any;
  37118. /**
  37119. * @hidden Internal use only
  37120. */
  37121. _interpolate(currentFrame: number, state: _IAnimationState): any;
  37122. /**
  37123. * Defines the function to use to interpolate matrices
  37124. * @param startValue defines the start matrix
  37125. * @param endValue defines the end matrix
  37126. * @param gradient defines the gradient between both matrices
  37127. * @param result defines an optional target matrix where to store the interpolation
  37128. * @returns the interpolated matrix
  37129. */
  37130. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  37131. /**
  37132. * Makes a copy of the animation
  37133. * @returns Cloned animation
  37134. */
  37135. clone(): Animation;
  37136. /**
  37137. * Sets the key frames of the animation
  37138. * @param values The animation key frames to set
  37139. */
  37140. setKeys(values: Array<IAnimationKey>): void;
  37141. /**
  37142. * Serializes the animation to an object
  37143. * @returns Serialized object
  37144. */
  37145. serialize(): any;
  37146. /**
  37147. * Float animation type
  37148. */
  37149. static readonly ANIMATIONTYPE_FLOAT: number;
  37150. /**
  37151. * Vector3 animation type
  37152. */
  37153. static readonly ANIMATIONTYPE_VECTOR3: number;
  37154. /**
  37155. * Quaternion animation type
  37156. */
  37157. static readonly ANIMATIONTYPE_QUATERNION: number;
  37158. /**
  37159. * Matrix animation type
  37160. */
  37161. static readonly ANIMATIONTYPE_MATRIX: number;
  37162. /**
  37163. * Color3 animation type
  37164. */
  37165. static readonly ANIMATIONTYPE_COLOR3: number;
  37166. /**
  37167. * Color3 animation type
  37168. */
  37169. static readonly ANIMATIONTYPE_COLOR4: number;
  37170. /**
  37171. * Vector2 animation type
  37172. */
  37173. static readonly ANIMATIONTYPE_VECTOR2: number;
  37174. /**
  37175. * Size animation type
  37176. */
  37177. static readonly ANIMATIONTYPE_SIZE: number;
  37178. /**
  37179. * Relative Loop Mode
  37180. */
  37181. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  37182. /**
  37183. * Cycle Loop Mode
  37184. */
  37185. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  37186. /**
  37187. * Constant Loop Mode
  37188. */
  37189. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  37190. /** @hidden */
  37191. static _UniversalLerp(left: any, right: any, amount: number): any;
  37192. /**
  37193. * Parses an animation object and creates an animation
  37194. * @param parsedAnimation Parsed animation object
  37195. * @returns Animation object
  37196. */
  37197. static Parse(parsedAnimation: any): Animation;
  37198. /**
  37199. * Appends the serialized animations from the source animations
  37200. * @param source Source containing the animations
  37201. * @param destination Target to store the animations
  37202. */
  37203. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  37204. /**
  37205. * Creates a new animation or an array of animations from a snippet saved in a remote file
  37206. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  37207. * @param url defines the url to load from
  37208. * @returns a promise that will resolve to the new animation or an array of animations
  37209. */
  37210. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  37211. /**
  37212. * Creates an animation or an array of animations from a snippet saved by the Inspector
  37213. * @param snippetId defines the snippet to load
  37214. * @returns a promise that will resolve to the new animation or a new array of animations
  37215. */
  37216. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  37217. }
  37218. }
  37219. declare module BABYLON {
  37220. /**
  37221. * Interface containing an array of animations
  37222. */
  37223. export interface IAnimatable {
  37224. /**
  37225. * Array of animations
  37226. */
  37227. animations: Nullable<Array<Animation>>;
  37228. }
  37229. }
  37230. declare module BABYLON {
  37231. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  37232. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37233. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37234. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37235. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37236. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37237. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37238. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37239. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37240. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37241. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37242. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37243. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37244. /**
  37245. * Decorator used to define property that can be serialized as reference to a camera
  37246. * @param sourceName defines the name of the property to decorate
  37247. */
  37248. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37249. /**
  37250. * Class used to help serialization objects
  37251. */
  37252. export class SerializationHelper {
  37253. /** @hidden */
  37254. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  37255. /** @hidden */
  37256. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  37257. /** @hidden */
  37258. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  37259. /** @hidden */
  37260. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  37261. /**
  37262. * Appends the serialized animations from the source animations
  37263. * @param source Source containing the animations
  37264. * @param destination Target to store the animations
  37265. */
  37266. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  37267. /**
  37268. * Static function used to serialized a specific entity
  37269. * @param entity defines the entity to serialize
  37270. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  37271. * @returns a JSON compatible object representing the serialization of the entity
  37272. */
  37273. static Serialize<T>(entity: T, serializationObject?: any): any;
  37274. /**
  37275. * Creates a new entity from a serialization data object
  37276. * @param creationFunction defines a function used to instanciated the new entity
  37277. * @param source defines the source serialization data
  37278. * @param scene defines the hosting scene
  37279. * @param rootUrl defines the root url for resources
  37280. * @returns a new entity
  37281. */
  37282. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  37283. /**
  37284. * Clones an object
  37285. * @param creationFunction defines the function used to instanciate the new object
  37286. * @param source defines the source object
  37287. * @returns the cloned object
  37288. */
  37289. static Clone<T>(creationFunction: () => T, source: T): T;
  37290. /**
  37291. * Instanciates a new object based on a source one (some data will be shared between both object)
  37292. * @param creationFunction defines the function used to instanciate the new object
  37293. * @param source defines the source object
  37294. * @returns the new object
  37295. */
  37296. static Instanciate<T>(creationFunction: () => T, source: T): T;
  37297. }
  37298. }
  37299. declare module BABYLON {
  37300. /**
  37301. * Base class of all the textures in babylon.
  37302. * It groups all the common properties the materials, post process, lights... might need
  37303. * in order to make a correct use of the texture.
  37304. */
  37305. export class BaseTexture implements IAnimatable {
  37306. /**
  37307. * Default anisotropic filtering level for the application.
  37308. * It is set to 4 as a good tradeoff between perf and quality.
  37309. */
  37310. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  37311. /**
  37312. * Gets or sets the unique id of the texture
  37313. */
  37314. uniqueId: number;
  37315. /**
  37316. * Define the name of the texture.
  37317. */
  37318. name: string;
  37319. /**
  37320. * Gets or sets an object used to store user defined information.
  37321. */
  37322. metadata: any;
  37323. /**
  37324. * For internal use only. Please do not use.
  37325. */
  37326. reservedDataStore: any;
  37327. private _hasAlpha;
  37328. /**
  37329. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  37330. */
  37331. set hasAlpha(value: boolean);
  37332. get hasAlpha(): boolean;
  37333. /**
  37334. * Defines if the alpha value should be determined via the rgb values.
  37335. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  37336. */
  37337. getAlphaFromRGB: boolean;
  37338. /**
  37339. * Intensity or strength of the texture.
  37340. * It is commonly used by materials to fine tune the intensity of the texture
  37341. */
  37342. level: number;
  37343. /**
  37344. * Define the UV chanel to use starting from 0 and defaulting to 0.
  37345. * This is part of the texture as textures usually maps to one uv set.
  37346. */
  37347. coordinatesIndex: number;
  37348. protected _coordinatesMode: number;
  37349. /**
  37350. * How a texture is mapped.
  37351. *
  37352. * | Value | Type | Description |
  37353. * | ----- | ----------------------------------- | ----------- |
  37354. * | 0 | EXPLICIT_MODE | |
  37355. * | 1 | SPHERICAL_MODE | |
  37356. * | 2 | PLANAR_MODE | |
  37357. * | 3 | CUBIC_MODE | |
  37358. * | 4 | PROJECTION_MODE | |
  37359. * | 5 | SKYBOX_MODE | |
  37360. * | 6 | INVCUBIC_MODE | |
  37361. * | 7 | EQUIRECTANGULAR_MODE | |
  37362. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  37363. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  37364. */
  37365. set coordinatesMode(value: number);
  37366. get coordinatesMode(): number;
  37367. private _wrapU;
  37368. /**
  37369. * | Value | Type | Description |
  37370. * | ----- | ------------------ | ----------- |
  37371. * | 0 | CLAMP_ADDRESSMODE | |
  37372. * | 1 | WRAP_ADDRESSMODE | |
  37373. * | 2 | MIRROR_ADDRESSMODE | |
  37374. */
  37375. get wrapU(): number;
  37376. set wrapU(value: number);
  37377. private _wrapV;
  37378. /**
  37379. * | Value | Type | Description |
  37380. * | ----- | ------------------ | ----------- |
  37381. * | 0 | CLAMP_ADDRESSMODE | |
  37382. * | 1 | WRAP_ADDRESSMODE | |
  37383. * | 2 | MIRROR_ADDRESSMODE | |
  37384. */
  37385. get wrapV(): number;
  37386. set wrapV(value: number);
  37387. /**
  37388. * | Value | Type | Description |
  37389. * | ----- | ------------------ | ----------- |
  37390. * | 0 | CLAMP_ADDRESSMODE | |
  37391. * | 1 | WRAP_ADDRESSMODE | |
  37392. * | 2 | MIRROR_ADDRESSMODE | |
  37393. */
  37394. wrapR: number;
  37395. /**
  37396. * With compliant hardware and browser (supporting anisotropic filtering)
  37397. * this defines the level of anisotropic filtering in the texture.
  37398. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  37399. */
  37400. anisotropicFilteringLevel: number;
  37401. /**
  37402. * Define if the texture is a cube texture or if false a 2d texture.
  37403. */
  37404. get isCube(): boolean;
  37405. set isCube(value: boolean);
  37406. /**
  37407. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  37408. */
  37409. get is3D(): boolean;
  37410. set is3D(value: boolean);
  37411. /**
  37412. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  37413. */
  37414. get is2DArray(): boolean;
  37415. set is2DArray(value: boolean);
  37416. private _gammaSpace;
  37417. /**
  37418. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  37419. * HDR texture are usually stored in linear space.
  37420. * This only impacts the PBR and Background materials
  37421. */
  37422. get gammaSpace(): boolean;
  37423. set gammaSpace(gamma: boolean);
  37424. /**
  37425. * Gets or sets whether or not the texture contains RGBD data.
  37426. */
  37427. get isRGBD(): boolean;
  37428. set isRGBD(value: boolean);
  37429. /**
  37430. * Is Z inverted in the texture (useful in a cube texture).
  37431. */
  37432. invertZ: boolean;
  37433. /**
  37434. * Are mip maps generated for this texture or not.
  37435. */
  37436. get noMipmap(): boolean;
  37437. /**
  37438. * @hidden
  37439. */
  37440. lodLevelInAlpha: boolean;
  37441. /**
  37442. * With prefiltered texture, defined the offset used during the prefiltering steps.
  37443. */
  37444. get lodGenerationOffset(): number;
  37445. set lodGenerationOffset(value: number);
  37446. /**
  37447. * With prefiltered texture, defined the scale used during the prefiltering steps.
  37448. */
  37449. get lodGenerationScale(): number;
  37450. set lodGenerationScale(value: number);
  37451. /**
  37452. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  37453. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  37454. * average roughness values.
  37455. */
  37456. get linearSpecularLOD(): boolean;
  37457. set linearSpecularLOD(value: boolean);
  37458. /**
  37459. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  37460. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  37461. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  37462. */
  37463. get irradianceTexture(): Nullable<BaseTexture>;
  37464. set irradianceTexture(value: Nullable<BaseTexture>);
  37465. /**
  37466. * Define if the texture is a render target.
  37467. */
  37468. isRenderTarget: boolean;
  37469. /**
  37470. * Define the unique id of the texture in the scene.
  37471. */
  37472. get uid(): string;
  37473. /** @hidden */
  37474. _prefiltered: boolean;
  37475. /**
  37476. * Return a string representation of the texture.
  37477. * @returns the texture as a string
  37478. */
  37479. toString(): string;
  37480. /**
  37481. * Get the class name of the texture.
  37482. * @returns "BaseTexture"
  37483. */
  37484. getClassName(): string;
  37485. /**
  37486. * Define the list of animation attached to the texture.
  37487. */
  37488. animations: Animation[];
  37489. /**
  37490. * An event triggered when the texture is disposed.
  37491. */
  37492. onDisposeObservable: Observable<BaseTexture>;
  37493. private _onDisposeObserver;
  37494. /**
  37495. * Callback triggered when the texture has been disposed.
  37496. * Kept for back compatibility, you can use the onDisposeObservable instead.
  37497. */
  37498. set onDispose(callback: () => void);
  37499. /**
  37500. * Define the current state of the loading sequence when in delayed load mode.
  37501. */
  37502. delayLoadState: number;
  37503. protected _scene: Nullable<Scene>;
  37504. protected _engine: Nullable<ThinEngine>;
  37505. /** @hidden */
  37506. _texture: Nullable<InternalTexture>;
  37507. private _uid;
  37508. /**
  37509. * Define if the texture is preventinga material to render or not.
  37510. * If not and the texture is not ready, the engine will use a default black texture instead.
  37511. */
  37512. get isBlocking(): boolean;
  37513. /**
  37514. * Instantiates a new BaseTexture.
  37515. * Base class of all the textures in babylon.
  37516. * It groups all the common properties the materials, post process, lights... might need
  37517. * in order to make a correct use of the texture.
  37518. * @param sceneOrEngine Define the scene or engine the texture blongs to
  37519. */
  37520. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  37521. /**
  37522. * Get the scene the texture belongs to.
  37523. * @returns the scene or null if undefined
  37524. */
  37525. getScene(): Nullable<Scene>;
  37526. /** @hidden */
  37527. protected _getEngine(): Nullable<ThinEngine>;
  37528. /**
  37529. * Checks if the texture has the same transform matrix than another texture
  37530. * @param texture texture to check against
  37531. * @returns true if the transforms are the same, else false
  37532. */
  37533. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  37534. /**
  37535. * Get the texture transform matrix used to offset tile the texture for istance.
  37536. * @returns the transformation matrix
  37537. */
  37538. getTextureMatrix(): Matrix;
  37539. /**
  37540. * Get the texture reflection matrix used to rotate/transform the reflection.
  37541. * @returns the reflection matrix
  37542. */
  37543. getReflectionTextureMatrix(): Matrix;
  37544. /**
  37545. * Get the underlying lower level texture from Babylon.
  37546. * @returns the insternal texture
  37547. */
  37548. getInternalTexture(): Nullable<InternalTexture>;
  37549. /**
  37550. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  37551. * @returns true if ready or not blocking
  37552. */
  37553. isReadyOrNotBlocking(): boolean;
  37554. /**
  37555. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  37556. * @returns true if fully ready
  37557. */
  37558. isReady(): boolean;
  37559. private _cachedSize;
  37560. /**
  37561. * Get the size of the texture.
  37562. * @returns the texture size.
  37563. */
  37564. getSize(): ISize;
  37565. /**
  37566. * Get the base size of the texture.
  37567. * It can be different from the size if the texture has been resized for POT for instance
  37568. * @returns the base size
  37569. */
  37570. getBaseSize(): ISize;
  37571. /**
  37572. * Update the sampling mode of the texture.
  37573. * Default is Trilinear mode.
  37574. *
  37575. * | Value | Type | Description |
  37576. * | ----- | ------------------ | ----------- |
  37577. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  37578. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  37579. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  37580. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  37581. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  37582. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  37583. * | 7 | NEAREST_LINEAR | |
  37584. * | 8 | NEAREST_NEAREST | |
  37585. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  37586. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  37587. * | 11 | LINEAR_LINEAR | |
  37588. * | 12 | LINEAR_NEAREST | |
  37589. *
  37590. * > _mag_: magnification filter (close to the viewer)
  37591. * > _min_: minification filter (far from the viewer)
  37592. * > _mip_: filter used between mip map levels
  37593. *@param samplingMode Define the new sampling mode of the texture
  37594. */
  37595. updateSamplingMode(samplingMode: number): void;
  37596. /**
  37597. * Scales the texture if is `canRescale()`
  37598. * @param ratio the resize factor we want to use to rescale
  37599. */
  37600. scale(ratio: number): void;
  37601. /**
  37602. * Get if the texture can rescale.
  37603. */
  37604. get canRescale(): boolean;
  37605. /** @hidden */
  37606. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  37607. /** @hidden */
  37608. _rebuild(): void;
  37609. /**
  37610. * Triggers the load sequence in delayed load mode.
  37611. */
  37612. delayLoad(): void;
  37613. /**
  37614. * Clones the texture.
  37615. * @returns the cloned texture
  37616. */
  37617. clone(): Nullable<BaseTexture>;
  37618. /**
  37619. * Get the texture underlying type (INT, FLOAT...)
  37620. */
  37621. get textureType(): number;
  37622. /**
  37623. * Get the texture underlying format (RGB, RGBA...)
  37624. */
  37625. get textureFormat(): number;
  37626. /**
  37627. * Indicates that textures need to be re-calculated for all materials
  37628. */
  37629. protected _markAllSubMeshesAsTexturesDirty(): void;
  37630. /**
  37631. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  37632. * This will returns an RGBA array buffer containing either in values (0-255) or
  37633. * float values (0-1) depending of the underlying buffer type.
  37634. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  37635. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  37636. * @param buffer defines a user defined buffer to fill with data (can be null)
  37637. * @returns The Array buffer containing the pixels data.
  37638. */
  37639. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  37640. /**
  37641. * Release and destroy the underlying lower level texture aka internalTexture.
  37642. */
  37643. releaseInternalTexture(): void;
  37644. /** @hidden */
  37645. get _lodTextureHigh(): Nullable<BaseTexture>;
  37646. /** @hidden */
  37647. get _lodTextureMid(): Nullable<BaseTexture>;
  37648. /** @hidden */
  37649. get _lodTextureLow(): Nullable<BaseTexture>;
  37650. /**
  37651. * Dispose the texture and release its associated resources.
  37652. */
  37653. dispose(): void;
  37654. /**
  37655. * Serialize the texture into a JSON representation that can be parsed later on.
  37656. * @returns the JSON representation of the texture
  37657. */
  37658. serialize(): any;
  37659. /**
  37660. * Helper function to be called back once a list of texture contains only ready textures.
  37661. * @param textures Define the list of textures to wait for
  37662. * @param callback Define the callback triggered once the entire list will be ready
  37663. */
  37664. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  37665. private static _isScene;
  37666. }
  37667. }
  37668. declare module BABYLON {
  37669. /**
  37670. * Options to be used when creating an effect.
  37671. */
  37672. export interface IEffectCreationOptions {
  37673. /**
  37674. * Atrributes that will be used in the shader.
  37675. */
  37676. attributes: string[];
  37677. /**
  37678. * Uniform varible names that will be set in the shader.
  37679. */
  37680. uniformsNames: string[];
  37681. /**
  37682. * Uniform buffer variable names that will be set in the shader.
  37683. */
  37684. uniformBuffersNames: string[];
  37685. /**
  37686. * Sampler texture variable names that will be set in the shader.
  37687. */
  37688. samplers: string[];
  37689. /**
  37690. * Define statements that will be set in the shader.
  37691. */
  37692. defines: any;
  37693. /**
  37694. * Possible fallbacks for this effect to improve performance when needed.
  37695. */
  37696. fallbacks: Nullable<IEffectFallbacks>;
  37697. /**
  37698. * Callback that will be called when the shader is compiled.
  37699. */
  37700. onCompiled: Nullable<(effect: Effect) => void>;
  37701. /**
  37702. * Callback that will be called if an error occurs during shader compilation.
  37703. */
  37704. onError: Nullable<(effect: Effect, errors: string) => void>;
  37705. /**
  37706. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  37707. */
  37708. indexParameters?: any;
  37709. /**
  37710. * Max number of lights that can be used in the shader.
  37711. */
  37712. maxSimultaneousLights?: number;
  37713. /**
  37714. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  37715. */
  37716. transformFeedbackVaryings?: Nullable<string[]>;
  37717. /**
  37718. * 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
  37719. */
  37720. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  37721. /**
  37722. * Is this effect rendering to several color attachments ?
  37723. */
  37724. multiTarget?: boolean;
  37725. }
  37726. /**
  37727. * Effect containing vertex and fragment shader that can be executed on an object.
  37728. */
  37729. export class Effect implements IDisposable {
  37730. /**
  37731. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  37732. */
  37733. static ShadersRepository: string;
  37734. /**
  37735. * Enable logging of the shader code when a compilation error occurs
  37736. */
  37737. static LogShaderCodeOnCompilationError: boolean;
  37738. /**
  37739. * Name of the effect.
  37740. */
  37741. name: any;
  37742. /**
  37743. * String container all the define statements that should be set on the shader.
  37744. */
  37745. defines: string;
  37746. /**
  37747. * Callback that will be called when the shader is compiled.
  37748. */
  37749. onCompiled: Nullable<(effect: Effect) => void>;
  37750. /**
  37751. * Callback that will be called if an error occurs during shader compilation.
  37752. */
  37753. onError: Nullable<(effect: Effect, errors: string) => void>;
  37754. /**
  37755. * Callback that will be called when effect is bound.
  37756. */
  37757. onBind: Nullable<(effect: Effect) => void>;
  37758. /**
  37759. * Unique ID of the effect.
  37760. */
  37761. uniqueId: number;
  37762. /**
  37763. * Observable that will be called when the shader is compiled.
  37764. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  37765. */
  37766. onCompileObservable: Observable<Effect>;
  37767. /**
  37768. * Observable that will be called if an error occurs during shader compilation.
  37769. */
  37770. onErrorObservable: Observable<Effect>;
  37771. /** @hidden */
  37772. _onBindObservable: Nullable<Observable<Effect>>;
  37773. /**
  37774. * @hidden
  37775. * Specifies if the effect was previously ready
  37776. */
  37777. _wasPreviouslyReady: boolean;
  37778. /**
  37779. * Observable that will be called when effect is bound.
  37780. */
  37781. get onBindObservable(): Observable<Effect>;
  37782. /** @hidden */
  37783. _bonesComputationForcedToCPU: boolean;
  37784. /** @hidden */
  37785. _multiTarget: boolean;
  37786. private static _uniqueIdSeed;
  37787. private _engine;
  37788. private _uniformBuffersNames;
  37789. private _uniformBuffersNamesList;
  37790. private _uniformsNames;
  37791. private _samplerList;
  37792. private _samplers;
  37793. private _isReady;
  37794. private _compilationError;
  37795. private _allFallbacksProcessed;
  37796. private _attributesNames;
  37797. private _attributes;
  37798. private _attributeLocationByName;
  37799. private _uniforms;
  37800. /**
  37801. * Key for the effect.
  37802. * @hidden
  37803. */
  37804. _key: string;
  37805. private _indexParameters;
  37806. private _fallbacks;
  37807. private _vertexSourceCode;
  37808. private _fragmentSourceCode;
  37809. private _vertexSourceCodeOverride;
  37810. private _fragmentSourceCodeOverride;
  37811. private _transformFeedbackVaryings;
  37812. private _rawVertexSourceCode;
  37813. private _rawFragmentSourceCode;
  37814. /**
  37815. * Compiled shader to webGL program.
  37816. * @hidden
  37817. */
  37818. _pipelineContext: Nullable<IPipelineContext>;
  37819. private _valueCache;
  37820. private static _baseCache;
  37821. /**
  37822. * Instantiates an effect.
  37823. * An effect can be used to create/manage/execute vertex and fragment shaders.
  37824. * @param baseName Name of the effect.
  37825. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  37826. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  37827. * @param samplers List of sampler variables that will be passed to the shader.
  37828. * @param engine Engine to be used to render the effect
  37829. * @param defines Define statements to be added to the shader.
  37830. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  37831. * @param onCompiled Callback that will be called when the shader is compiled.
  37832. * @param onError Callback that will be called if an error occurs during shader compilation.
  37833. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  37834. */
  37835. 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);
  37836. private _useFinalCode;
  37837. /**
  37838. * Unique key for this effect
  37839. */
  37840. get key(): string;
  37841. /**
  37842. * If the effect has been compiled and prepared.
  37843. * @returns if the effect is compiled and prepared.
  37844. */
  37845. isReady(): boolean;
  37846. private _isReadyInternal;
  37847. /**
  37848. * The engine the effect was initialized with.
  37849. * @returns the engine.
  37850. */
  37851. getEngine(): Engine;
  37852. /**
  37853. * The pipeline context for this effect
  37854. * @returns the associated pipeline context
  37855. */
  37856. getPipelineContext(): Nullable<IPipelineContext>;
  37857. /**
  37858. * The set of names of attribute variables for the shader.
  37859. * @returns An array of attribute names.
  37860. */
  37861. getAttributesNames(): string[];
  37862. /**
  37863. * Returns the attribute at the given index.
  37864. * @param index The index of the attribute.
  37865. * @returns The location of the attribute.
  37866. */
  37867. getAttributeLocation(index: number): number;
  37868. /**
  37869. * Returns the attribute based on the name of the variable.
  37870. * @param name of the attribute to look up.
  37871. * @returns the attribute location.
  37872. */
  37873. getAttributeLocationByName(name: string): number;
  37874. /**
  37875. * The number of attributes.
  37876. * @returns the numnber of attributes.
  37877. */
  37878. getAttributesCount(): number;
  37879. /**
  37880. * Gets the index of a uniform variable.
  37881. * @param uniformName of the uniform to look up.
  37882. * @returns the index.
  37883. */
  37884. getUniformIndex(uniformName: string): number;
  37885. /**
  37886. * Returns the attribute based on the name of the variable.
  37887. * @param uniformName of the uniform to look up.
  37888. * @returns the location of the uniform.
  37889. */
  37890. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  37891. /**
  37892. * Returns an array of sampler variable names
  37893. * @returns The array of sampler variable names.
  37894. */
  37895. getSamplers(): string[];
  37896. /**
  37897. * Returns an array of uniform variable names
  37898. * @returns The array of uniform variable names.
  37899. */
  37900. getUniformNames(): string[];
  37901. /**
  37902. * Returns an array of uniform buffer variable names
  37903. * @returns The array of uniform buffer variable names.
  37904. */
  37905. getUniformBuffersNames(): string[];
  37906. /**
  37907. * Returns the index parameters used to create the effect
  37908. * @returns The index parameters object
  37909. */
  37910. getIndexParameters(): any;
  37911. /**
  37912. * The error from the last compilation.
  37913. * @returns the error string.
  37914. */
  37915. getCompilationError(): string;
  37916. /**
  37917. * Gets a boolean indicating that all fallbacks were used during compilation
  37918. * @returns true if all fallbacks were used
  37919. */
  37920. allFallbacksProcessed(): boolean;
  37921. /**
  37922. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  37923. * @param func The callback to be used.
  37924. */
  37925. executeWhenCompiled(func: (effect: Effect) => void): void;
  37926. private _checkIsReady;
  37927. private _loadShader;
  37928. /**
  37929. * Gets the vertex shader source code of this effect
  37930. */
  37931. get vertexSourceCode(): string;
  37932. /**
  37933. * Gets the fragment shader source code of this effect
  37934. */
  37935. get fragmentSourceCode(): string;
  37936. /**
  37937. * Gets the vertex shader source code before it has been processed by the preprocessor
  37938. */
  37939. get rawVertexSourceCode(): string;
  37940. /**
  37941. * Gets the fragment shader source code before it has been processed by the preprocessor
  37942. */
  37943. get rawFragmentSourceCode(): string;
  37944. /**
  37945. * Recompiles the webGL program
  37946. * @param vertexSourceCode The source code for the vertex shader.
  37947. * @param fragmentSourceCode The source code for the fragment shader.
  37948. * @param onCompiled Callback called when completed.
  37949. * @param onError Callback called on error.
  37950. * @hidden
  37951. */
  37952. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  37953. /**
  37954. * Prepares the effect
  37955. * @hidden
  37956. */
  37957. _prepareEffect(): void;
  37958. private _getShaderCodeAndErrorLine;
  37959. private _processCompilationErrors;
  37960. /**
  37961. * Checks if the effect is supported. (Must be called after compilation)
  37962. */
  37963. get isSupported(): boolean;
  37964. /**
  37965. * Binds a texture to the engine to be used as output of the shader.
  37966. * @param channel Name of the output variable.
  37967. * @param texture Texture to bind.
  37968. * @hidden
  37969. */
  37970. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  37971. /**
  37972. * Sets a texture on the engine to be used in the shader.
  37973. * @param channel Name of the sampler variable.
  37974. * @param texture Texture to set.
  37975. */
  37976. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  37977. /**
  37978. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  37979. * @param channel Name of the sampler variable.
  37980. * @param texture Texture to set.
  37981. */
  37982. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  37983. /**
  37984. * Sets an array of textures on the engine to be used in the shader.
  37985. * @param channel Name of the variable.
  37986. * @param textures Textures to set.
  37987. */
  37988. setTextureArray(channel: string, textures: BaseTexture[]): void;
  37989. /**
  37990. * 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)
  37991. * @param channel Name of the sampler variable.
  37992. * @param postProcess Post process to get the input texture from.
  37993. */
  37994. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  37995. /**
  37996. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  37997. * 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)
  37998. * @param channel Name of the sampler variable.
  37999. * @param postProcess Post process to get the output texture from.
  38000. */
  38001. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  38002. /** @hidden */
  38003. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  38004. /** @hidden */
  38005. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  38006. /** @hidden */
  38007. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  38008. /** @hidden */
  38009. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  38010. /**
  38011. * Binds a buffer to a uniform.
  38012. * @param buffer Buffer to bind.
  38013. * @param name Name of the uniform variable to bind to.
  38014. */
  38015. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  38016. /**
  38017. * Binds block to a uniform.
  38018. * @param blockName Name of the block to bind.
  38019. * @param index Index to bind.
  38020. */
  38021. bindUniformBlock(blockName: string, index: number): void;
  38022. /**
  38023. * Sets an interger value on a uniform variable.
  38024. * @param uniformName Name of the variable.
  38025. * @param value Value to be set.
  38026. * @returns this effect.
  38027. */
  38028. setInt(uniformName: string, value: number): Effect;
  38029. /**
  38030. * Sets an int array on a uniform variable.
  38031. * @param uniformName Name of the variable.
  38032. * @param array array to be set.
  38033. * @returns this effect.
  38034. */
  38035. setIntArray(uniformName: string, array: Int32Array): Effect;
  38036. /**
  38037. * 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)
  38038. * @param uniformName Name of the variable.
  38039. * @param array array to be set.
  38040. * @returns this effect.
  38041. */
  38042. setIntArray2(uniformName: string, array: Int32Array): Effect;
  38043. /**
  38044. * 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)
  38045. * @param uniformName Name of the variable.
  38046. * @param array array to be set.
  38047. * @returns this effect.
  38048. */
  38049. setIntArray3(uniformName: string, array: Int32Array): Effect;
  38050. /**
  38051. * 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)
  38052. * @param uniformName Name of the variable.
  38053. * @param array array to be set.
  38054. * @returns this effect.
  38055. */
  38056. setIntArray4(uniformName: string, array: Int32Array): Effect;
  38057. /**
  38058. * Sets an float array on a uniform variable.
  38059. * @param uniformName Name of the variable.
  38060. * @param array array to be set.
  38061. * @returns this effect.
  38062. */
  38063. setFloatArray(uniformName: string, array: Float32Array): Effect;
  38064. /**
  38065. * 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)
  38066. * @param uniformName Name of the variable.
  38067. * @param array array to be set.
  38068. * @returns this effect.
  38069. */
  38070. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  38071. /**
  38072. * 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)
  38073. * @param uniformName Name of the variable.
  38074. * @param array array to be set.
  38075. * @returns this effect.
  38076. */
  38077. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  38078. /**
  38079. * 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)
  38080. * @param uniformName Name of the variable.
  38081. * @param array array to be set.
  38082. * @returns this effect.
  38083. */
  38084. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  38085. /**
  38086. * Sets an array on a uniform variable.
  38087. * @param uniformName Name of the variable.
  38088. * @param array array to be set.
  38089. * @returns this effect.
  38090. */
  38091. setArray(uniformName: string, array: number[]): Effect;
  38092. /**
  38093. * 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)
  38094. * @param uniformName Name of the variable.
  38095. * @param array array to be set.
  38096. * @returns this effect.
  38097. */
  38098. setArray2(uniformName: string, array: number[]): Effect;
  38099. /**
  38100. * 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)
  38101. * @param uniformName Name of the variable.
  38102. * @param array array to be set.
  38103. * @returns this effect.
  38104. */
  38105. setArray3(uniformName: string, array: number[]): Effect;
  38106. /**
  38107. * 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)
  38108. * @param uniformName Name of the variable.
  38109. * @param array array to be set.
  38110. * @returns this effect.
  38111. */
  38112. setArray4(uniformName: string, array: number[]): Effect;
  38113. /**
  38114. * Sets matrices on a uniform variable.
  38115. * @param uniformName Name of the variable.
  38116. * @param matrices matrices to be set.
  38117. * @returns this effect.
  38118. */
  38119. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  38120. /**
  38121. * Sets matrix on a uniform variable.
  38122. * @param uniformName Name of the variable.
  38123. * @param matrix matrix to be set.
  38124. * @returns this effect.
  38125. */
  38126. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  38127. /**
  38128. * 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)
  38129. * @param uniformName Name of the variable.
  38130. * @param matrix matrix to be set.
  38131. * @returns this effect.
  38132. */
  38133. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  38134. /**
  38135. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  38136. * @param uniformName Name of the variable.
  38137. * @param matrix matrix to be set.
  38138. * @returns this effect.
  38139. */
  38140. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  38141. /**
  38142. * Sets a float on a uniform variable.
  38143. * @param uniformName Name of the variable.
  38144. * @param value value to be set.
  38145. * @returns this effect.
  38146. */
  38147. setFloat(uniformName: string, value: number): Effect;
  38148. /**
  38149. * Sets a boolean on a uniform variable.
  38150. * @param uniformName Name of the variable.
  38151. * @param bool value to be set.
  38152. * @returns this effect.
  38153. */
  38154. setBool(uniformName: string, bool: boolean): Effect;
  38155. /**
  38156. * Sets a Vector2 on a uniform variable.
  38157. * @param uniformName Name of the variable.
  38158. * @param vector2 vector2 to be set.
  38159. * @returns this effect.
  38160. */
  38161. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  38162. /**
  38163. * Sets a float2 on a uniform variable.
  38164. * @param uniformName Name of the variable.
  38165. * @param x First float in float2.
  38166. * @param y Second float in float2.
  38167. * @returns this effect.
  38168. */
  38169. setFloat2(uniformName: string, x: number, y: number): Effect;
  38170. /**
  38171. * Sets a Vector3 on a uniform variable.
  38172. * @param uniformName Name of the variable.
  38173. * @param vector3 Value to be set.
  38174. * @returns this effect.
  38175. */
  38176. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  38177. /**
  38178. * Sets a float3 on a uniform variable.
  38179. * @param uniformName Name of the variable.
  38180. * @param x First float in float3.
  38181. * @param y Second float in float3.
  38182. * @param z Third float in float3.
  38183. * @returns this effect.
  38184. */
  38185. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  38186. /**
  38187. * Sets a Vector4 on a uniform variable.
  38188. * @param uniformName Name of the variable.
  38189. * @param vector4 Value to be set.
  38190. * @returns this effect.
  38191. */
  38192. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  38193. /**
  38194. * Sets a float4 on a uniform variable.
  38195. * @param uniformName Name of the variable.
  38196. * @param x First float in float4.
  38197. * @param y Second float in float4.
  38198. * @param z Third float in float4.
  38199. * @param w Fourth float in float4.
  38200. * @returns this effect.
  38201. */
  38202. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  38203. /**
  38204. * Sets a Color3 on a uniform variable.
  38205. * @param uniformName Name of the variable.
  38206. * @param color3 Value to be set.
  38207. * @returns this effect.
  38208. */
  38209. setColor3(uniformName: string, color3: IColor3Like): Effect;
  38210. /**
  38211. * Sets a Color4 on a uniform variable.
  38212. * @param uniformName Name of the variable.
  38213. * @param color3 Value to be set.
  38214. * @param alpha Alpha value to be set.
  38215. * @returns this effect.
  38216. */
  38217. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  38218. /**
  38219. * Sets a Color4 on a uniform variable
  38220. * @param uniformName defines the name of the variable
  38221. * @param color4 defines the value to be set
  38222. * @returns this effect.
  38223. */
  38224. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  38225. /** Release all associated resources */
  38226. dispose(): void;
  38227. /**
  38228. * This function will add a new shader to the shader store
  38229. * @param name the name of the shader
  38230. * @param pixelShader optional pixel shader content
  38231. * @param vertexShader optional vertex shader content
  38232. */
  38233. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  38234. /**
  38235. * Store of each shader (The can be looked up using effect.key)
  38236. */
  38237. static ShadersStore: {
  38238. [key: string]: string;
  38239. };
  38240. /**
  38241. * Store of each included file for a shader (The can be looked up using effect.key)
  38242. */
  38243. static IncludesShadersStore: {
  38244. [key: string]: string;
  38245. };
  38246. /**
  38247. * Resets the cache of effects.
  38248. */
  38249. static ResetCache(): void;
  38250. }
  38251. }
  38252. declare module BABYLON {
  38253. /**
  38254. * Interface used to describe the capabilities of the engine relatively to the current browser
  38255. */
  38256. export interface EngineCapabilities {
  38257. /** Maximum textures units per fragment shader */
  38258. maxTexturesImageUnits: number;
  38259. /** Maximum texture units per vertex shader */
  38260. maxVertexTextureImageUnits: number;
  38261. /** Maximum textures units in the entire pipeline */
  38262. maxCombinedTexturesImageUnits: number;
  38263. /** Maximum texture size */
  38264. maxTextureSize: number;
  38265. /** Maximum texture samples */
  38266. maxSamples?: number;
  38267. /** Maximum cube texture size */
  38268. maxCubemapTextureSize: number;
  38269. /** Maximum render texture size */
  38270. maxRenderTextureSize: number;
  38271. /** Maximum number of vertex attributes */
  38272. maxVertexAttribs: number;
  38273. /** Maximum number of varyings */
  38274. maxVaryingVectors: number;
  38275. /** Maximum number of uniforms per vertex shader */
  38276. maxVertexUniformVectors: number;
  38277. /** Maximum number of uniforms per fragment shader */
  38278. maxFragmentUniformVectors: number;
  38279. /** Defines if standard derivates (dx/dy) are supported */
  38280. standardDerivatives: boolean;
  38281. /** Defines if s3tc texture compression is supported */
  38282. s3tc?: WEBGL_compressed_texture_s3tc;
  38283. /** Defines if pvrtc texture compression is supported */
  38284. pvrtc: any;
  38285. /** Defines if etc1 texture compression is supported */
  38286. etc1: any;
  38287. /** Defines if etc2 texture compression is supported */
  38288. etc2: any;
  38289. /** Defines if astc texture compression is supported */
  38290. astc: any;
  38291. /** Defines if bptc texture compression is supported */
  38292. bptc: any;
  38293. /** Defines if float textures are supported */
  38294. textureFloat: boolean;
  38295. /** Defines if vertex array objects are supported */
  38296. vertexArrayObject: boolean;
  38297. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  38298. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  38299. /** Gets the maximum level of anisotropy supported */
  38300. maxAnisotropy: number;
  38301. /** Defines if instancing is supported */
  38302. instancedArrays: boolean;
  38303. /** Defines if 32 bits indices are supported */
  38304. uintIndices: boolean;
  38305. /** Defines if high precision shaders are supported */
  38306. highPrecisionShaderSupported: boolean;
  38307. /** Defines if depth reading in the fragment shader is supported */
  38308. fragmentDepthSupported: boolean;
  38309. /** Defines if float texture linear filtering is supported*/
  38310. textureFloatLinearFiltering: boolean;
  38311. /** Defines if rendering to float textures is supported */
  38312. textureFloatRender: boolean;
  38313. /** Defines if half float textures are supported*/
  38314. textureHalfFloat: boolean;
  38315. /** Defines if half float texture linear filtering is supported*/
  38316. textureHalfFloatLinearFiltering: boolean;
  38317. /** Defines if rendering to half float textures is supported */
  38318. textureHalfFloatRender: boolean;
  38319. /** Defines if textureLOD shader command is supported */
  38320. textureLOD: boolean;
  38321. /** Defines if draw buffers extension is supported */
  38322. drawBuffersExtension: boolean;
  38323. /** Defines if depth textures are supported */
  38324. depthTextureExtension: boolean;
  38325. /** Defines if float color buffer are supported */
  38326. colorBufferFloat: boolean;
  38327. /** Gets disjoint timer query extension (null if not supported) */
  38328. timerQuery?: EXT_disjoint_timer_query;
  38329. /** Defines if timestamp can be used with timer query */
  38330. canUseTimestampForTimerQuery: boolean;
  38331. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  38332. multiview?: any;
  38333. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  38334. oculusMultiview?: any;
  38335. /** Function used to let the system compiles shaders in background */
  38336. parallelShaderCompile?: {
  38337. COMPLETION_STATUS_KHR: number;
  38338. };
  38339. /** Max number of texture samples for MSAA */
  38340. maxMSAASamples: number;
  38341. /** Defines if the blend min max extension is supported */
  38342. blendMinMax: boolean;
  38343. }
  38344. }
  38345. declare module BABYLON {
  38346. /**
  38347. * @hidden
  38348. **/
  38349. export class DepthCullingState {
  38350. private _isDepthTestDirty;
  38351. private _isDepthMaskDirty;
  38352. private _isDepthFuncDirty;
  38353. private _isCullFaceDirty;
  38354. private _isCullDirty;
  38355. private _isZOffsetDirty;
  38356. private _isFrontFaceDirty;
  38357. private _depthTest;
  38358. private _depthMask;
  38359. private _depthFunc;
  38360. private _cull;
  38361. private _cullFace;
  38362. private _zOffset;
  38363. private _frontFace;
  38364. /**
  38365. * Initializes the state.
  38366. */
  38367. constructor();
  38368. get isDirty(): boolean;
  38369. get zOffset(): number;
  38370. set zOffset(value: number);
  38371. get cullFace(): Nullable<number>;
  38372. set cullFace(value: Nullable<number>);
  38373. get cull(): Nullable<boolean>;
  38374. set cull(value: Nullable<boolean>);
  38375. get depthFunc(): Nullable<number>;
  38376. set depthFunc(value: Nullable<number>);
  38377. get depthMask(): boolean;
  38378. set depthMask(value: boolean);
  38379. get depthTest(): boolean;
  38380. set depthTest(value: boolean);
  38381. get frontFace(): Nullable<number>;
  38382. set frontFace(value: Nullable<number>);
  38383. reset(): void;
  38384. apply(gl: WebGLRenderingContext): void;
  38385. }
  38386. }
  38387. declare module BABYLON {
  38388. /**
  38389. * @hidden
  38390. **/
  38391. export class StencilState {
  38392. /** 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 */
  38393. static readonly ALWAYS: number;
  38394. /** Passed to stencilOperation to specify that stencil value must be kept */
  38395. static readonly KEEP: number;
  38396. /** Passed to stencilOperation to specify that stencil value must be replaced */
  38397. static readonly REPLACE: number;
  38398. private _isStencilTestDirty;
  38399. private _isStencilMaskDirty;
  38400. private _isStencilFuncDirty;
  38401. private _isStencilOpDirty;
  38402. private _stencilTest;
  38403. private _stencilMask;
  38404. private _stencilFunc;
  38405. private _stencilFuncRef;
  38406. private _stencilFuncMask;
  38407. private _stencilOpStencilFail;
  38408. private _stencilOpDepthFail;
  38409. private _stencilOpStencilDepthPass;
  38410. get isDirty(): boolean;
  38411. get stencilFunc(): number;
  38412. set stencilFunc(value: number);
  38413. get stencilFuncRef(): number;
  38414. set stencilFuncRef(value: number);
  38415. get stencilFuncMask(): number;
  38416. set stencilFuncMask(value: number);
  38417. get stencilOpStencilFail(): number;
  38418. set stencilOpStencilFail(value: number);
  38419. get stencilOpDepthFail(): number;
  38420. set stencilOpDepthFail(value: number);
  38421. get stencilOpStencilDepthPass(): number;
  38422. set stencilOpStencilDepthPass(value: number);
  38423. get stencilMask(): number;
  38424. set stencilMask(value: number);
  38425. get stencilTest(): boolean;
  38426. set stencilTest(value: boolean);
  38427. constructor();
  38428. reset(): void;
  38429. apply(gl: WebGLRenderingContext): void;
  38430. }
  38431. }
  38432. declare module BABYLON {
  38433. /**
  38434. * @hidden
  38435. **/
  38436. export class AlphaState {
  38437. private _isAlphaBlendDirty;
  38438. private _isBlendFunctionParametersDirty;
  38439. private _isBlendEquationParametersDirty;
  38440. private _isBlendConstantsDirty;
  38441. private _alphaBlend;
  38442. private _blendFunctionParameters;
  38443. private _blendEquationParameters;
  38444. private _blendConstants;
  38445. /**
  38446. * Initializes the state.
  38447. */
  38448. constructor();
  38449. get isDirty(): boolean;
  38450. get alphaBlend(): boolean;
  38451. set alphaBlend(value: boolean);
  38452. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  38453. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  38454. setAlphaEquationParameters(rgb: number, alpha: number): void;
  38455. reset(): void;
  38456. apply(gl: WebGLRenderingContext): void;
  38457. }
  38458. }
  38459. declare module BABYLON {
  38460. /** @hidden */
  38461. export class WebGLShaderProcessor implements IShaderProcessor {
  38462. postProcessor(code: string, defines: string[], isFragment: boolean, engine: ThinEngine): string;
  38463. }
  38464. }
  38465. declare module BABYLON {
  38466. /** @hidden */
  38467. export class WebGL2ShaderProcessor implements IShaderProcessor {
  38468. attributeProcessor(attribute: string): string;
  38469. varyingProcessor(varying: string, isFragment: boolean): string;
  38470. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  38471. }
  38472. }
  38473. declare module BABYLON {
  38474. /**
  38475. * Interface for attribute information associated with buffer instanciation
  38476. */
  38477. export interface InstancingAttributeInfo {
  38478. /**
  38479. * Name of the GLSL attribute
  38480. * if attribute index is not specified, this is used to retrieve the index from the effect
  38481. */
  38482. attributeName: string;
  38483. /**
  38484. * Index/offset of the attribute in the vertex shader
  38485. * if not specified, this will be computes from the name.
  38486. */
  38487. index?: number;
  38488. /**
  38489. * size of the attribute, 1, 2, 3 or 4
  38490. */
  38491. attributeSize: number;
  38492. /**
  38493. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  38494. */
  38495. offset: number;
  38496. /**
  38497. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  38498. * default to 1
  38499. */
  38500. divisor?: number;
  38501. /**
  38502. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  38503. * default is FLOAT
  38504. */
  38505. attributeType?: number;
  38506. /**
  38507. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  38508. */
  38509. normalized?: boolean;
  38510. }
  38511. }
  38512. declare module BABYLON {
  38513. interface ThinEngine {
  38514. /**
  38515. * Update a video texture
  38516. * @param texture defines the texture to update
  38517. * @param video defines the video element to use
  38518. * @param invertY defines if data must be stored with Y axis inverted
  38519. */
  38520. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  38521. }
  38522. }
  38523. declare module BABYLON {
  38524. interface ThinEngine {
  38525. /**
  38526. * Creates a dynamic texture
  38527. * @param width defines the width of the texture
  38528. * @param height defines the height of the texture
  38529. * @param generateMipMaps defines if the engine should generate the mip levels
  38530. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  38531. * @returns the dynamic texture inside an InternalTexture
  38532. */
  38533. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  38534. /**
  38535. * Update the content of a dynamic texture
  38536. * @param texture defines the texture to update
  38537. * @param canvas defines the canvas containing the source
  38538. * @param invertY defines if data must be stored with Y axis inverted
  38539. * @param premulAlpha defines if alpha is stored as premultiplied
  38540. * @param format defines the format of the data
  38541. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  38542. */
  38543. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  38544. }
  38545. }
  38546. declare module BABYLON {
  38547. /**
  38548. * Settings for finer control over video usage
  38549. */
  38550. export interface VideoTextureSettings {
  38551. /**
  38552. * Applies `autoplay` to video, if specified
  38553. */
  38554. autoPlay?: boolean;
  38555. /**
  38556. * Applies `muted` to video, if specified
  38557. */
  38558. muted?: boolean;
  38559. /**
  38560. * Applies `loop` to video, if specified
  38561. */
  38562. loop?: boolean;
  38563. /**
  38564. * Automatically updates internal texture from video at every frame in the render loop
  38565. */
  38566. autoUpdateTexture: boolean;
  38567. /**
  38568. * Image src displayed during the video loading or until the user interacts with the video.
  38569. */
  38570. poster?: string;
  38571. }
  38572. /**
  38573. * If you want to display a video in your scene, this is the special texture for that.
  38574. * This special texture works similar to other textures, with the exception of a few parameters.
  38575. * @see https://doc.babylonjs.com/how_to/video_texture
  38576. */
  38577. export class VideoTexture extends Texture {
  38578. /**
  38579. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  38580. */
  38581. readonly autoUpdateTexture: boolean;
  38582. /**
  38583. * The video instance used by the texture internally
  38584. */
  38585. readonly video: HTMLVideoElement;
  38586. private _onUserActionRequestedObservable;
  38587. /**
  38588. * Event triggerd when a dom action is required by the user to play the video.
  38589. * This happens due to recent changes in browser policies preventing video to auto start.
  38590. */
  38591. get onUserActionRequestedObservable(): Observable<Texture>;
  38592. private _generateMipMaps;
  38593. private _stillImageCaptured;
  38594. private _displayingPosterTexture;
  38595. private _settings;
  38596. private _createInternalTextureOnEvent;
  38597. private _frameId;
  38598. private _currentSrc;
  38599. /**
  38600. * Creates a video texture.
  38601. * If you want to display a video in your scene, this is the special texture for that.
  38602. * This special texture works similar to other textures, with the exception of a few parameters.
  38603. * @see https://doc.babylonjs.com/how_to/video_texture
  38604. * @param name optional name, will detect from video source, if not defined
  38605. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  38606. * @param scene is obviously the current scene.
  38607. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  38608. * @param invertY is false by default but can be used to invert video on Y axis
  38609. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  38610. * @param settings allows finer control over video usage
  38611. */
  38612. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  38613. private _getName;
  38614. private _getVideo;
  38615. private _createInternalTexture;
  38616. private reset;
  38617. /**
  38618. * @hidden Internal method to initiate `update`.
  38619. */
  38620. _rebuild(): void;
  38621. /**
  38622. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  38623. */
  38624. update(): void;
  38625. /**
  38626. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  38627. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  38628. */
  38629. updateTexture(isVisible: boolean): void;
  38630. protected _updateInternalTexture: () => void;
  38631. /**
  38632. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  38633. * @param url New url.
  38634. */
  38635. updateURL(url: string): void;
  38636. /**
  38637. * Clones the texture.
  38638. * @returns the cloned texture
  38639. */
  38640. clone(): VideoTexture;
  38641. /**
  38642. * Dispose the texture and release its associated resources.
  38643. */
  38644. dispose(): void;
  38645. /**
  38646. * Creates a video texture straight from a stream.
  38647. * @param scene Define the scene the texture should be created in
  38648. * @param stream Define the stream the texture should be created from
  38649. * @returns The created video texture as a promise
  38650. */
  38651. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  38652. /**
  38653. * Creates a video texture straight from your WebCam video feed.
  38654. * @param scene Define the scene the texture should be created in
  38655. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  38656. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  38657. * @returns The created video texture as a promise
  38658. */
  38659. static CreateFromWebCamAsync(scene: Scene, constraints: {
  38660. minWidth: number;
  38661. maxWidth: number;
  38662. minHeight: number;
  38663. maxHeight: number;
  38664. deviceId: string;
  38665. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  38666. /**
  38667. * Creates a video texture straight from your WebCam video feed.
  38668. * @param scene Define the scene the texture should be created in
  38669. * @param onReady Define a callback to triggered once the texture will be ready
  38670. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  38671. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  38672. */
  38673. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  38674. minWidth: number;
  38675. maxWidth: number;
  38676. minHeight: number;
  38677. maxHeight: number;
  38678. deviceId: string;
  38679. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  38680. }
  38681. }
  38682. declare module BABYLON {
  38683. /**
  38684. * Defines the interface used by objects working like Scene
  38685. * @hidden
  38686. */
  38687. export interface ISceneLike {
  38688. _addPendingData(data: any): void;
  38689. _removePendingData(data: any): void;
  38690. offlineProvider: IOfflineProvider;
  38691. }
  38692. /**
  38693. * Information about the current host
  38694. */
  38695. export interface HostInformation {
  38696. /**
  38697. * Defines if the current host is a mobile
  38698. */
  38699. isMobile: boolean;
  38700. }
  38701. /** Interface defining initialization parameters for Engine class */
  38702. export interface EngineOptions extends WebGLContextAttributes {
  38703. /**
  38704. * Defines if the engine should no exceed a specified device ratio
  38705. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  38706. */
  38707. limitDeviceRatio?: number;
  38708. /**
  38709. * Defines if webvr should be enabled automatically
  38710. * @see https://doc.babylonjs.com/how_to/webvr_camera
  38711. */
  38712. autoEnableWebVR?: boolean;
  38713. /**
  38714. * Defines if webgl2 should be turned off even if supported
  38715. * @see https://doc.babylonjs.com/features/webgl2
  38716. */
  38717. disableWebGL2Support?: boolean;
  38718. /**
  38719. * Defines if webaudio should be initialized as well
  38720. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38721. */
  38722. audioEngine?: boolean;
  38723. /**
  38724. * Defines if animations should run using a deterministic lock step
  38725. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38726. */
  38727. deterministicLockstep?: boolean;
  38728. /** Defines the maximum steps to use with deterministic lock step mode */
  38729. lockstepMaxSteps?: number;
  38730. /** Defines the seconds between each deterministic lock step */
  38731. timeStep?: number;
  38732. /**
  38733. * Defines that engine should ignore context lost events
  38734. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  38735. */
  38736. doNotHandleContextLost?: boolean;
  38737. /**
  38738. * Defines that engine should ignore modifying touch action attribute and style
  38739. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  38740. */
  38741. doNotHandleTouchAction?: boolean;
  38742. /**
  38743. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  38744. */
  38745. useHighPrecisionFloats?: boolean;
  38746. /**
  38747. * Make the canvas XR Compatible for XR sessions
  38748. */
  38749. xrCompatible?: boolean;
  38750. /**
  38751. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  38752. */
  38753. useHighPrecisionMatrix?: boolean;
  38754. /**
  38755. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  38756. */
  38757. failIfMajorPerformanceCaveat?: boolean;
  38758. }
  38759. /**
  38760. * The base engine class (root of all engines)
  38761. */
  38762. export class ThinEngine {
  38763. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  38764. static ExceptionList: ({
  38765. key: string;
  38766. capture: string;
  38767. captureConstraint: number;
  38768. targets: string[];
  38769. } | {
  38770. key: string;
  38771. capture: null;
  38772. captureConstraint: null;
  38773. targets: string[];
  38774. })[];
  38775. /** @hidden */
  38776. static _TextureLoaders: IInternalTextureLoader[];
  38777. /**
  38778. * Returns the current npm package of the sdk
  38779. */
  38780. static get NpmPackage(): string;
  38781. /**
  38782. * Returns the current version of the framework
  38783. */
  38784. static get Version(): string;
  38785. /**
  38786. * Returns a string describing the current engine
  38787. */
  38788. get description(): string;
  38789. /**
  38790. * Gets or sets the epsilon value used by collision engine
  38791. */
  38792. static CollisionsEpsilon: number;
  38793. /**
  38794. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  38795. */
  38796. static get ShadersRepository(): string;
  38797. static set ShadersRepository(value: string);
  38798. /** @hidden */
  38799. _shaderProcessor: IShaderProcessor;
  38800. /**
  38801. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  38802. */
  38803. forcePOTTextures: boolean;
  38804. /**
  38805. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  38806. */
  38807. isFullscreen: boolean;
  38808. /**
  38809. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  38810. */
  38811. cullBackFaces: boolean;
  38812. /**
  38813. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  38814. */
  38815. renderEvenInBackground: boolean;
  38816. /**
  38817. * Gets or sets a boolean indicating that cache can be kept between frames
  38818. */
  38819. preventCacheWipeBetweenFrames: boolean;
  38820. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  38821. validateShaderPrograms: boolean;
  38822. /**
  38823. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  38824. * This can provide greater z depth for distant objects.
  38825. */
  38826. useReverseDepthBuffer: boolean;
  38827. /**
  38828. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  38829. */
  38830. disableUniformBuffers: boolean;
  38831. /** @hidden */
  38832. _uniformBuffers: UniformBuffer[];
  38833. /**
  38834. * Gets a boolean indicating that the engine supports uniform buffers
  38835. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  38836. */
  38837. get supportsUniformBuffers(): boolean;
  38838. /** @hidden */
  38839. _gl: WebGLRenderingContext;
  38840. /** @hidden */
  38841. _webGLVersion: number;
  38842. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  38843. protected _windowIsBackground: boolean;
  38844. protected _creationOptions: EngineOptions;
  38845. protected _highPrecisionShadersAllowed: boolean;
  38846. /** @hidden */
  38847. get _shouldUseHighPrecisionShader(): boolean;
  38848. /**
  38849. * Gets a boolean indicating that only power of 2 textures are supported
  38850. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  38851. */
  38852. get needPOTTextures(): boolean;
  38853. /** @hidden */
  38854. _badOS: boolean;
  38855. /** @hidden */
  38856. _badDesktopOS: boolean;
  38857. private _hardwareScalingLevel;
  38858. /** @hidden */
  38859. _caps: EngineCapabilities;
  38860. private _isStencilEnable;
  38861. private _glVersion;
  38862. private _glRenderer;
  38863. private _glVendor;
  38864. /** @hidden */
  38865. _videoTextureSupported: boolean;
  38866. protected _renderingQueueLaunched: boolean;
  38867. protected _activeRenderLoops: (() => void)[];
  38868. /**
  38869. * Observable signaled when a context lost event is raised
  38870. */
  38871. onContextLostObservable: Observable<ThinEngine>;
  38872. /**
  38873. * Observable signaled when a context restored event is raised
  38874. */
  38875. onContextRestoredObservable: Observable<ThinEngine>;
  38876. private _onContextLost;
  38877. private _onContextRestored;
  38878. protected _contextWasLost: boolean;
  38879. /** @hidden */
  38880. _doNotHandleContextLost: boolean;
  38881. /**
  38882. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  38883. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  38884. */
  38885. get doNotHandleContextLost(): boolean;
  38886. set doNotHandleContextLost(value: boolean);
  38887. /**
  38888. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  38889. */
  38890. disableVertexArrayObjects: boolean;
  38891. /** @hidden */
  38892. protected _colorWrite: boolean;
  38893. /** @hidden */
  38894. protected _colorWriteChanged: boolean;
  38895. /** @hidden */
  38896. protected _depthCullingState: DepthCullingState;
  38897. /** @hidden */
  38898. protected _stencilState: StencilState;
  38899. /** @hidden */
  38900. _alphaState: AlphaState;
  38901. /** @hidden */
  38902. _alphaMode: number;
  38903. /** @hidden */
  38904. _alphaEquation: number;
  38905. /** @hidden */
  38906. _internalTexturesCache: InternalTexture[];
  38907. /** @hidden */
  38908. protected _activeChannel: number;
  38909. private _currentTextureChannel;
  38910. /** @hidden */
  38911. protected _boundTexturesCache: {
  38912. [key: string]: Nullable<InternalTexture>;
  38913. };
  38914. /** @hidden */
  38915. protected _currentEffect: Nullable<Effect>;
  38916. /** @hidden */
  38917. protected _currentProgram: Nullable<WebGLProgram>;
  38918. private _compiledEffects;
  38919. private _vertexAttribArraysEnabled;
  38920. /** @hidden */
  38921. protected _cachedViewport: Nullable<IViewportLike>;
  38922. private _cachedVertexArrayObject;
  38923. /** @hidden */
  38924. protected _cachedVertexBuffers: any;
  38925. /** @hidden */
  38926. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  38927. /** @hidden */
  38928. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  38929. /** @hidden */
  38930. _currentRenderTarget: Nullable<InternalTexture>;
  38931. private _uintIndicesCurrentlySet;
  38932. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  38933. /** @hidden */
  38934. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  38935. /** @hidden */
  38936. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  38937. private _currentBufferPointers;
  38938. private _currentInstanceLocations;
  38939. private _currentInstanceBuffers;
  38940. private _textureUnits;
  38941. /** @hidden */
  38942. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  38943. /** @hidden */
  38944. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  38945. /** @hidden */
  38946. _boundRenderFunction: any;
  38947. private _vaoRecordInProgress;
  38948. private _mustWipeVertexAttributes;
  38949. private _emptyTexture;
  38950. private _emptyCubeTexture;
  38951. private _emptyTexture3D;
  38952. private _emptyTexture2DArray;
  38953. /** @hidden */
  38954. _frameHandler: number;
  38955. private _nextFreeTextureSlots;
  38956. private _maxSimultaneousTextures;
  38957. private _activeRequests;
  38958. /** @hidden */
  38959. _transformTextureUrl: Nullable<(url: string) => string>;
  38960. /**
  38961. * Gets information about the current host
  38962. */
  38963. hostInformation: HostInformation;
  38964. protected get _supportsHardwareTextureRescaling(): boolean;
  38965. private _framebufferDimensionsObject;
  38966. /**
  38967. * sets the object from which width and height will be taken from when getting render width and height
  38968. * Will fallback to the gl object
  38969. * @param dimensions the framebuffer width and height that will be used.
  38970. */
  38971. set framebufferDimensionsObject(dimensions: Nullable<{
  38972. framebufferWidth: number;
  38973. framebufferHeight: number;
  38974. }>);
  38975. /**
  38976. * Gets the current viewport
  38977. */
  38978. get currentViewport(): Nullable<IViewportLike>;
  38979. /**
  38980. * Gets the default empty texture
  38981. */
  38982. get emptyTexture(): InternalTexture;
  38983. /**
  38984. * Gets the default empty 3D texture
  38985. */
  38986. get emptyTexture3D(): InternalTexture;
  38987. /**
  38988. * Gets the default empty 2D array texture
  38989. */
  38990. get emptyTexture2DArray(): InternalTexture;
  38991. /**
  38992. * Gets the default empty cube texture
  38993. */
  38994. get emptyCubeTexture(): InternalTexture;
  38995. /**
  38996. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  38997. */
  38998. readonly premultipliedAlpha: boolean;
  38999. /**
  39000. * Observable event triggered before each texture is initialized
  39001. */
  39002. onBeforeTextureInitObservable: Observable<Texture>;
  39003. /**
  39004. * Creates a new engine
  39005. * @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
  39006. * @param antialias defines enable antialiasing (default: false)
  39007. * @param options defines further options to be sent to the getContext() function
  39008. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  39009. */
  39010. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  39011. private _rebuildInternalTextures;
  39012. private _rebuildEffects;
  39013. /**
  39014. * Gets a boolean indicating if all created effects are ready
  39015. * @returns true if all effects are ready
  39016. */
  39017. areAllEffectsReady(): boolean;
  39018. protected _rebuildBuffers(): void;
  39019. protected _initGLContext(): void;
  39020. /**
  39021. * Gets version of the current webGL context
  39022. */
  39023. get webGLVersion(): number;
  39024. /**
  39025. * Gets a string identifying the name of the class
  39026. * @returns "Engine" string
  39027. */
  39028. getClassName(): string;
  39029. /**
  39030. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  39031. */
  39032. get isStencilEnable(): boolean;
  39033. /** @hidden */
  39034. _prepareWorkingCanvas(): void;
  39035. /**
  39036. * Reset the texture cache to empty state
  39037. */
  39038. resetTextureCache(): void;
  39039. /**
  39040. * Gets an object containing information about the current webGL context
  39041. * @returns an object containing the vender, the renderer and the version of the current webGL context
  39042. */
  39043. getGlInfo(): {
  39044. vendor: string;
  39045. renderer: string;
  39046. version: string;
  39047. };
  39048. /**
  39049. * Defines the hardware scaling level.
  39050. * By default the hardware scaling level is computed from the window device ratio.
  39051. * 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.
  39052. * @param level defines the level to use
  39053. */
  39054. setHardwareScalingLevel(level: number): void;
  39055. /**
  39056. * Gets the current hardware scaling level.
  39057. * By default the hardware scaling level is computed from the window device ratio.
  39058. * 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.
  39059. * @returns a number indicating the current hardware scaling level
  39060. */
  39061. getHardwareScalingLevel(): number;
  39062. /**
  39063. * Gets the list of loaded textures
  39064. * @returns an array containing all loaded textures
  39065. */
  39066. getLoadedTexturesCache(): InternalTexture[];
  39067. /**
  39068. * Gets the object containing all engine capabilities
  39069. * @returns the EngineCapabilities object
  39070. */
  39071. getCaps(): EngineCapabilities;
  39072. /**
  39073. * stop executing a render loop function and remove it from the execution array
  39074. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  39075. */
  39076. stopRenderLoop(renderFunction?: () => void): void;
  39077. /** @hidden */
  39078. _renderLoop(): void;
  39079. /**
  39080. * Gets the HTML canvas attached with the current webGL context
  39081. * @returns a HTML canvas
  39082. */
  39083. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  39084. /**
  39085. * Gets host window
  39086. * @returns the host window object
  39087. */
  39088. getHostWindow(): Nullable<Window>;
  39089. /**
  39090. * Gets the current render width
  39091. * @param useScreen defines if screen size must be used (or the current render target if any)
  39092. * @returns a number defining the current render width
  39093. */
  39094. getRenderWidth(useScreen?: boolean): number;
  39095. /**
  39096. * Gets the current render height
  39097. * @param useScreen defines if screen size must be used (or the current render target if any)
  39098. * @returns a number defining the current render height
  39099. */
  39100. getRenderHeight(useScreen?: boolean): number;
  39101. /**
  39102. * Can be used to override the current requestAnimationFrame requester.
  39103. * @hidden
  39104. */
  39105. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  39106. /**
  39107. * Register and execute a render loop. The engine can have more than one render function
  39108. * @param renderFunction defines the function to continuously execute
  39109. */
  39110. runRenderLoop(renderFunction: () => void): void;
  39111. /**
  39112. * Clear the current render buffer or the current render target (if any is set up)
  39113. * @param color defines the color to use
  39114. * @param backBuffer defines if the back buffer must be cleared
  39115. * @param depth defines if the depth buffer must be cleared
  39116. * @param stencil defines if the stencil buffer must be cleared
  39117. */
  39118. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  39119. private _viewportCached;
  39120. /** @hidden */
  39121. _viewport(x: number, y: number, width: number, height: number): void;
  39122. /**
  39123. * Set the WebGL's viewport
  39124. * @param viewport defines the viewport element to be used
  39125. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  39126. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  39127. */
  39128. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  39129. /**
  39130. * Begin a new frame
  39131. */
  39132. beginFrame(): void;
  39133. /**
  39134. * Enf the current frame
  39135. */
  39136. endFrame(): void;
  39137. /**
  39138. * Resize the view according to the canvas' size
  39139. */
  39140. resize(): void;
  39141. /**
  39142. * Force a specific size of the canvas
  39143. * @param width defines the new canvas' width
  39144. * @param height defines the new canvas' height
  39145. * @returns true if the size was changed
  39146. */
  39147. setSize(width: number, height: number): boolean;
  39148. /**
  39149. * Binds the frame buffer to the specified texture.
  39150. * @param texture The texture to render to or null for the default canvas
  39151. * @param faceIndex The face of the texture to render to in case of cube texture
  39152. * @param requiredWidth The width of the target to render to
  39153. * @param requiredHeight The height of the target to render to
  39154. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  39155. * @param lodLevel defines the lod level to bind to the frame buffer
  39156. * @param layer defines the 2d array index to bind to frame buffer to
  39157. */
  39158. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  39159. /** @hidden */
  39160. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  39161. /**
  39162. * Unbind the current render target texture from the webGL context
  39163. * @param texture defines the render target texture to unbind
  39164. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  39165. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  39166. */
  39167. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  39168. /**
  39169. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  39170. */
  39171. flushFramebuffer(): void;
  39172. /**
  39173. * Unbind the current render target and bind the default framebuffer
  39174. */
  39175. restoreDefaultFramebuffer(): void;
  39176. /** @hidden */
  39177. protected _resetVertexBufferBinding(): void;
  39178. /**
  39179. * Creates a vertex buffer
  39180. * @param data the data for the vertex buffer
  39181. * @returns the new WebGL static buffer
  39182. */
  39183. createVertexBuffer(data: DataArray): DataBuffer;
  39184. private _createVertexBuffer;
  39185. /**
  39186. * Creates a dynamic vertex buffer
  39187. * @param data the data for the dynamic vertex buffer
  39188. * @returns the new WebGL dynamic buffer
  39189. */
  39190. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  39191. protected _resetIndexBufferBinding(): void;
  39192. /**
  39193. * Creates a new index buffer
  39194. * @param indices defines the content of the index buffer
  39195. * @param updatable defines if the index buffer must be updatable
  39196. * @returns a new webGL buffer
  39197. */
  39198. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  39199. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  39200. /**
  39201. * Bind a webGL buffer to the webGL context
  39202. * @param buffer defines the buffer to bind
  39203. */
  39204. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  39205. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  39206. private bindBuffer;
  39207. /**
  39208. * update the bound buffer with the given data
  39209. * @param data defines the data to update
  39210. */
  39211. updateArrayBuffer(data: Float32Array): void;
  39212. private _vertexAttribPointer;
  39213. /** @hidden */
  39214. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  39215. private _bindVertexBuffersAttributes;
  39216. /**
  39217. * Records a vertex array object
  39218. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  39219. * @param vertexBuffers defines the list of vertex buffers to store
  39220. * @param indexBuffer defines the index buffer to store
  39221. * @param effect defines the effect to store
  39222. * @returns the new vertex array object
  39223. */
  39224. recordVertexArrayObject(vertexBuffers: {
  39225. [key: string]: VertexBuffer;
  39226. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  39227. /**
  39228. * Bind a specific vertex array object
  39229. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  39230. * @param vertexArrayObject defines the vertex array object to bind
  39231. * @param indexBuffer defines the index buffer to bind
  39232. */
  39233. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  39234. /**
  39235. * Bind webGl buffers directly to the webGL context
  39236. * @param vertexBuffer defines the vertex buffer to bind
  39237. * @param indexBuffer defines the index buffer to bind
  39238. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  39239. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  39240. * @param effect defines the effect associated with the vertex buffer
  39241. */
  39242. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  39243. private _unbindVertexArrayObject;
  39244. /**
  39245. * Bind a list of vertex buffers to the webGL context
  39246. * @param vertexBuffers defines the list of vertex buffers to bind
  39247. * @param indexBuffer defines the index buffer to bind
  39248. * @param effect defines the effect associated with the vertex buffers
  39249. */
  39250. bindBuffers(vertexBuffers: {
  39251. [key: string]: Nullable<VertexBuffer>;
  39252. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  39253. /**
  39254. * Unbind all instance attributes
  39255. */
  39256. unbindInstanceAttributes(): void;
  39257. /**
  39258. * Release and free the memory of a vertex array object
  39259. * @param vao defines the vertex array object to delete
  39260. */
  39261. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  39262. /** @hidden */
  39263. _releaseBuffer(buffer: DataBuffer): boolean;
  39264. protected _deleteBuffer(buffer: DataBuffer): void;
  39265. /**
  39266. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  39267. * @param instancesBuffer defines the webGL buffer to update and bind
  39268. * @param data defines the data to store in the buffer
  39269. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  39270. */
  39271. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  39272. /**
  39273. * Bind the content of a webGL buffer used with instantiation
  39274. * @param instancesBuffer defines the webGL buffer to bind
  39275. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  39276. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  39277. */
  39278. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  39279. /**
  39280. * Disable the instance attribute corresponding to the name in parameter
  39281. * @param name defines the name of the attribute to disable
  39282. */
  39283. disableInstanceAttributeByName(name: string): void;
  39284. /**
  39285. * Disable the instance attribute corresponding to the location in parameter
  39286. * @param attributeLocation defines the attribute location of the attribute to disable
  39287. */
  39288. disableInstanceAttribute(attributeLocation: number): void;
  39289. /**
  39290. * Disable the attribute corresponding to the location in parameter
  39291. * @param attributeLocation defines the attribute location of the attribute to disable
  39292. */
  39293. disableAttributeByIndex(attributeLocation: number): void;
  39294. /**
  39295. * Send a draw order
  39296. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  39297. * @param indexStart defines the starting index
  39298. * @param indexCount defines the number of index to draw
  39299. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39300. */
  39301. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  39302. /**
  39303. * Draw a list of points
  39304. * @param verticesStart defines the index of first vertex to draw
  39305. * @param verticesCount defines the count of vertices to draw
  39306. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39307. */
  39308. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39309. /**
  39310. * Draw a list of unindexed primitives
  39311. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  39312. * @param verticesStart defines the index of first vertex to draw
  39313. * @param verticesCount defines the count of vertices to draw
  39314. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39315. */
  39316. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39317. /**
  39318. * Draw a list of indexed primitives
  39319. * @param fillMode defines the primitive to use
  39320. * @param indexStart defines the starting index
  39321. * @param indexCount defines the number of index to draw
  39322. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39323. */
  39324. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  39325. /**
  39326. * Draw a list of unindexed primitives
  39327. * @param fillMode defines the primitive to use
  39328. * @param verticesStart defines the index of first vertex to draw
  39329. * @param verticesCount defines the count of vertices to draw
  39330. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39331. */
  39332. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39333. private _drawMode;
  39334. /** @hidden */
  39335. protected _reportDrawCall(): void;
  39336. /** @hidden */
  39337. _releaseEffect(effect: Effect): void;
  39338. /** @hidden */
  39339. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  39340. /**
  39341. * Create a new effect (used to store vertex/fragment shaders)
  39342. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  39343. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  39344. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  39345. * @param samplers defines an array of string used to represent textures
  39346. * @param defines defines the string containing the defines to use to compile the shaders
  39347. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  39348. * @param onCompiled defines a function to call when the effect creation is successful
  39349. * @param onError defines a function to call when the effect creation has failed
  39350. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  39351. * @returns the new Effect
  39352. */
  39353. 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;
  39354. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  39355. private _compileShader;
  39356. private _compileRawShader;
  39357. /** @hidden */
  39358. _getShaderSource(shader: WebGLShader): Nullable<string>;
  39359. /**
  39360. * Directly creates a webGL program
  39361. * @param pipelineContext defines the pipeline context to attach to
  39362. * @param vertexCode defines the vertex shader code to use
  39363. * @param fragmentCode defines the fragment shader code to use
  39364. * @param context defines the webGL context to use (if not set, the current one will be used)
  39365. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  39366. * @returns the new webGL program
  39367. */
  39368. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39369. /**
  39370. * Creates a webGL program
  39371. * @param pipelineContext defines the pipeline context to attach to
  39372. * @param vertexCode defines the vertex shader code to use
  39373. * @param fragmentCode defines the fragment shader code to use
  39374. * @param defines defines the string containing the defines to use to compile the shaders
  39375. * @param context defines the webGL context to use (if not set, the current one will be used)
  39376. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  39377. * @returns the new webGL program
  39378. */
  39379. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39380. /**
  39381. * Creates a new pipeline context
  39382. * @returns the new pipeline
  39383. */
  39384. createPipelineContext(): IPipelineContext;
  39385. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39386. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  39387. /** @hidden */
  39388. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  39389. /** @hidden */
  39390. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  39391. /** @hidden */
  39392. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  39393. /**
  39394. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  39395. * @param pipelineContext defines the pipeline context to use
  39396. * @param uniformsNames defines the list of uniform names
  39397. * @returns an array of webGL uniform locations
  39398. */
  39399. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  39400. /**
  39401. * Gets the lsit of active attributes for a given webGL program
  39402. * @param pipelineContext defines the pipeline context to use
  39403. * @param attributesNames defines the list of attribute names to get
  39404. * @returns an array of indices indicating the offset of each attribute
  39405. */
  39406. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  39407. /**
  39408. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  39409. * @param effect defines the effect to activate
  39410. */
  39411. enableEffect(effect: Nullable<Effect>): void;
  39412. /**
  39413. * Set the value of an uniform to a number (int)
  39414. * @param uniform defines the webGL uniform location where to store the value
  39415. * @param value defines the int number to store
  39416. * @returns true if the value was set
  39417. */
  39418. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  39419. /**
  39420. * Set the value of an uniform to an array of int32
  39421. * @param uniform defines the webGL uniform location where to store the value
  39422. * @param array defines the array of int32 to store
  39423. * @returns true if the value was set
  39424. */
  39425. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39426. /**
  39427. * Set the value of an uniform to an array of int32 (stored as vec2)
  39428. * @param uniform defines the webGL uniform location where to store the value
  39429. * @param array defines the array of int32 to store
  39430. * @returns true if the value was set
  39431. */
  39432. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39433. /**
  39434. * Set the value of an uniform to an array of int32 (stored as vec3)
  39435. * @param uniform defines the webGL uniform location where to store the value
  39436. * @param array defines the array of int32 to store
  39437. * @returns true if the value was set
  39438. */
  39439. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39440. /**
  39441. * Set the value of an uniform to an array of int32 (stored as vec4)
  39442. * @param uniform defines the webGL uniform location where to store the value
  39443. * @param array defines the array of int32 to store
  39444. * @returns true if the value was set
  39445. */
  39446. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39447. /**
  39448. * Set the value of an uniform to an array of number
  39449. * @param uniform defines the webGL uniform location where to store the value
  39450. * @param array defines the array of number to store
  39451. * @returns true if the value was set
  39452. */
  39453. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39454. /**
  39455. * Set the value of an uniform to an array of number (stored as vec2)
  39456. * @param uniform defines the webGL uniform location where to store the value
  39457. * @param array defines the array of number to store
  39458. * @returns true if the value was set
  39459. */
  39460. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39461. /**
  39462. * Set the value of an uniform to an array of number (stored as vec3)
  39463. * @param uniform defines the webGL uniform location where to store the value
  39464. * @param array defines the array of number to store
  39465. * @returns true if the value was set
  39466. */
  39467. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39468. /**
  39469. * Set the value of an uniform to an array of number (stored as vec4)
  39470. * @param uniform defines the webGL uniform location where to store the value
  39471. * @param array defines the array of number to store
  39472. * @returns true if the value was set
  39473. */
  39474. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39475. /**
  39476. * Set the value of an uniform to an array of float32 (stored as matrices)
  39477. * @param uniform defines the webGL uniform location where to store the value
  39478. * @param matrices defines the array of float32 to store
  39479. * @returns true if the value was set
  39480. */
  39481. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  39482. /**
  39483. * Set the value of an uniform to a matrix (3x3)
  39484. * @param uniform defines the webGL uniform location where to store the value
  39485. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  39486. * @returns true if the value was set
  39487. */
  39488. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  39489. /**
  39490. * Set the value of an uniform to a matrix (2x2)
  39491. * @param uniform defines the webGL uniform location where to store the value
  39492. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  39493. * @returns true if the value was set
  39494. */
  39495. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  39496. /**
  39497. * Set the value of an uniform to a number (float)
  39498. * @param uniform defines the webGL uniform location where to store the value
  39499. * @param value defines the float number to store
  39500. * @returns true if the value was transfered
  39501. */
  39502. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  39503. /**
  39504. * Set the value of an uniform to a vec2
  39505. * @param uniform defines the webGL uniform location where to store the value
  39506. * @param x defines the 1st component of the value
  39507. * @param y defines the 2nd component of the value
  39508. * @returns true if the value was set
  39509. */
  39510. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  39511. /**
  39512. * Set the value of an uniform to a vec3
  39513. * @param uniform defines the webGL uniform location where to store the value
  39514. * @param x defines the 1st component of the value
  39515. * @param y defines the 2nd component of the value
  39516. * @param z defines the 3rd component of the value
  39517. * @returns true if the value was set
  39518. */
  39519. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  39520. /**
  39521. * Set the value of an uniform to a vec4
  39522. * @param uniform defines the webGL uniform location where to store the value
  39523. * @param x defines the 1st component of the value
  39524. * @param y defines the 2nd component of the value
  39525. * @param z defines the 3rd component of the value
  39526. * @param w defines the 4th component of the value
  39527. * @returns true if the value was set
  39528. */
  39529. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  39530. /**
  39531. * Apply all cached states (depth, culling, stencil and alpha)
  39532. */
  39533. applyStates(): void;
  39534. /**
  39535. * Enable or disable color writing
  39536. * @param enable defines the state to set
  39537. */
  39538. setColorWrite(enable: boolean): void;
  39539. /**
  39540. * Gets a boolean indicating if color writing is enabled
  39541. * @returns the current color writing state
  39542. */
  39543. getColorWrite(): boolean;
  39544. /**
  39545. * Gets the depth culling state manager
  39546. */
  39547. get depthCullingState(): DepthCullingState;
  39548. /**
  39549. * Gets the alpha state manager
  39550. */
  39551. get alphaState(): AlphaState;
  39552. /**
  39553. * Gets the stencil state manager
  39554. */
  39555. get stencilState(): StencilState;
  39556. /**
  39557. * Clears the list of texture accessible through engine.
  39558. * This can help preventing texture load conflict due to name collision.
  39559. */
  39560. clearInternalTexturesCache(): void;
  39561. /**
  39562. * Force the entire cache to be cleared
  39563. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  39564. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  39565. */
  39566. wipeCaches(bruteForce?: boolean): void;
  39567. /** @hidden */
  39568. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  39569. min: number;
  39570. mag: number;
  39571. };
  39572. /** @hidden */
  39573. _createTexture(): WebGLTexture;
  39574. /**
  39575. * Usually called from Texture.ts.
  39576. * Passed information to create a WebGLTexture
  39577. * @param url defines a value which contains one of the following:
  39578. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  39579. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  39580. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  39581. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  39582. * @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)
  39583. * @param scene needed for loading to the correct scene
  39584. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  39585. * @param onLoad optional callback to be called upon successful completion
  39586. * @param onError optional callback to be called upon failure
  39587. * @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
  39588. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  39589. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  39590. * @param forcedExtension defines the extension to use to pick the right loader
  39591. * @param mimeType defines an optional mime type
  39592. * @param loaderOptions options to be passed to the loader
  39593. * @returns a InternalTexture for assignment back into BABYLON.Texture
  39594. */
  39595. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string, loaderOptions?: any): InternalTexture;
  39596. /**
  39597. * Loads an image as an HTMLImageElement.
  39598. * @param input url string, ArrayBuffer, or Blob to load
  39599. * @param onLoad callback called when the image successfully loads
  39600. * @param onError callback called when the image fails to load
  39601. * @param offlineProvider offline provider for caching
  39602. * @param mimeType optional mime type
  39603. * @returns the HTMLImageElement of the loaded image
  39604. * @hidden
  39605. */
  39606. 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>;
  39607. /**
  39608. * @hidden
  39609. */
  39610. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  39611. private _unpackFlipYCached;
  39612. /**
  39613. * In case you are sharing the context with other applications, it might
  39614. * be interested to not cache the unpack flip y state to ensure a consistent
  39615. * value would be set.
  39616. */
  39617. enableUnpackFlipYCached: boolean;
  39618. /** @hidden */
  39619. _unpackFlipY(value: boolean): void;
  39620. /** @hidden */
  39621. _getUnpackAlignement(): number;
  39622. private _getTextureTarget;
  39623. /**
  39624. * Update the sampling mode of a given texture
  39625. * @param samplingMode defines the required sampling mode
  39626. * @param texture defines the texture to update
  39627. * @param generateMipMaps defines whether to generate mipmaps for the texture
  39628. */
  39629. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  39630. /**
  39631. * Update the sampling mode of a given texture
  39632. * @param texture defines the texture to update
  39633. * @param wrapU defines the texture wrap mode of the u coordinates
  39634. * @param wrapV defines the texture wrap mode of the v coordinates
  39635. * @param wrapR defines the texture wrap mode of the r coordinates
  39636. */
  39637. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  39638. /** @hidden */
  39639. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  39640. width: number;
  39641. height: number;
  39642. layers?: number;
  39643. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  39644. /** @hidden */
  39645. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39646. /** @hidden */
  39647. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  39648. /**
  39649. * Update a portion of an internal texture
  39650. * @param texture defines the texture to update
  39651. * @param imageData defines the data to store into the texture
  39652. * @param xOffset defines the x coordinates of the update rectangle
  39653. * @param yOffset defines the y coordinates of the update rectangle
  39654. * @param width defines the width of the update rectangle
  39655. * @param height defines the height of the update rectangle
  39656. * @param faceIndex defines the face index if texture is a cube (0 by default)
  39657. * @param lod defines the lod level to update (0 by default)
  39658. */
  39659. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  39660. /** @hidden */
  39661. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39662. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  39663. private _prepareWebGLTexture;
  39664. /** @hidden */
  39665. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  39666. private _getDepthStencilBuffer;
  39667. /** @hidden */
  39668. _releaseFramebufferObjects(texture: InternalTexture): void;
  39669. /** @hidden */
  39670. _releaseTexture(texture: InternalTexture): void;
  39671. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  39672. protected _setProgram(program: WebGLProgram): void;
  39673. protected _boundUniforms: {
  39674. [key: number]: WebGLUniformLocation;
  39675. };
  39676. /**
  39677. * Binds an effect to the webGL context
  39678. * @param effect defines the effect to bind
  39679. */
  39680. bindSamplers(effect: Effect): void;
  39681. private _activateCurrentTexture;
  39682. /** @hidden */
  39683. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  39684. /** @hidden */
  39685. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  39686. /**
  39687. * Unbind all textures from the webGL context
  39688. */
  39689. unbindAllTextures(): void;
  39690. /**
  39691. * Sets a texture to the according uniform.
  39692. * @param channel The texture channel
  39693. * @param uniform The uniform to set
  39694. * @param texture The texture to apply
  39695. */
  39696. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  39697. private _bindSamplerUniformToChannel;
  39698. private _getTextureWrapMode;
  39699. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  39700. /**
  39701. * Sets an array of texture to the webGL context
  39702. * @param channel defines the channel where the texture array must be set
  39703. * @param uniform defines the associated uniform location
  39704. * @param textures defines the array of textures to bind
  39705. */
  39706. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  39707. /** @hidden */
  39708. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  39709. private _setTextureParameterFloat;
  39710. private _setTextureParameterInteger;
  39711. /**
  39712. * Unbind all vertex attributes from the webGL context
  39713. */
  39714. unbindAllAttributes(): void;
  39715. /**
  39716. * 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
  39717. */
  39718. releaseEffects(): void;
  39719. /**
  39720. * Dispose and release all associated resources
  39721. */
  39722. dispose(): void;
  39723. /**
  39724. * Attach a new callback raised when context lost event is fired
  39725. * @param callback defines the callback to call
  39726. */
  39727. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  39728. /**
  39729. * Attach a new callback raised when context restored event is fired
  39730. * @param callback defines the callback to call
  39731. */
  39732. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  39733. /**
  39734. * Get the current error code of the webGL context
  39735. * @returns the error code
  39736. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  39737. */
  39738. getError(): number;
  39739. private _canRenderToFloatFramebuffer;
  39740. private _canRenderToHalfFloatFramebuffer;
  39741. private _canRenderToFramebuffer;
  39742. /** @hidden */
  39743. _getWebGLTextureType(type: number): number;
  39744. /** @hidden */
  39745. _getInternalFormat(format: number): number;
  39746. /** @hidden */
  39747. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  39748. /** @hidden */
  39749. _getRGBAMultiSampleBufferFormat(type: number): number;
  39750. /** @hidden */
  39751. _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;
  39752. /**
  39753. * Loads a file from a url
  39754. * @param url url to load
  39755. * @param onSuccess callback called when the file successfully loads
  39756. * @param onProgress callback called while file is loading (if the server supports this mode)
  39757. * @param offlineProvider defines the offline provider for caching
  39758. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39759. * @param onError callback called when the file fails to load
  39760. * @returns a file request object
  39761. * @hidden
  39762. */
  39763. 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;
  39764. /**
  39765. * Reads pixels from the current frame buffer. Please note that this function can be slow
  39766. * @param x defines the x coordinate of the rectangle where pixels must be read
  39767. * @param y defines the y coordinate of the rectangle where pixels must be read
  39768. * @param width defines the width of the rectangle where pixels must be read
  39769. * @param height defines the height of the rectangle where pixels must be read
  39770. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  39771. * @returns a Uint8Array containing RGBA colors
  39772. */
  39773. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  39774. private static _IsSupported;
  39775. private static _HasMajorPerformanceCaveat;
  39776. /**
  39777. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  39778. */
  39779. static get IsSupported(): boolean;
  39780. /**
  39781. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  39782. * @returns true if the engine can be created
  39783. * @ignorenaming
  39784. */
  39785. static isSupported(): boolean;
  39786. /**
  39787. * Gets a boolean indicating if the engine can be instanciated on a performant device (ie. if a webGL context can be found and it does not use a slow implementation)
  39788. */
  39789. static get HasMajorPerformanceCaveat(): boolean;
  39790. /**
  39791. * Find the next highest power of two.
  39792. * @param x Number to start search from.
  39793. * @return Next highest power of two.
  39794. */
  39795. static CeilingPOT(x: number): number;
  39796. /**
  39797. * Find the next lowest power of two.
  39798. * @param x Number to start search from.
  39799. * @return Next lowest power of two.
  39800. */
  39801. static FloorPOT(x: number): number;
  39802. /**
  39803. * Find the nearest power of two.
  39804. * @param x Number to start search from.
  39805. * @return Next nearest power of two.
  39806. */
  39807. static NearestPOT(x: number): number;
  39808. /**
  39809. * Get the closest exponent of two
  39810. * @param value defines the value to approximate
  39811. * @param max defines the maximum value to return
  39812. * @param mode defines how to define the closest value
  39813. * @returns closest exponent of two of the given value
  39814. */
  39815. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  39816. /**
  39817. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  39818. * @param func - the function to be called
  39819. * @param requester - the object that will request the next frame. Falls back to window.
  39820. * @returns frame number
  39821. */
  39822. static QueueNewFrame(func: () => void, requester?: any): number;
  39823. /**
  39824. * Gets host document
  39825. * @returns the host document object
  39826. */
  39827. getHostDocument(): Nullable<Document>;
  39828. }
  39829. }
  39830. declare module BABYLON {
  39831. /**
  39832. * Defines the source of the internal texture
  39833. */
  39834. export enum InternalTextureSource {
  39835. /**
  39836. * The source of the texture data is unknown
  39837. */
  39838. Unknown = 0,
  39839. /**
  39840. * Texture data comes from an URL
  39841. */
  39842. Url = 1,
  39843. /**
  39844. * Texture data is only used for temporary storage
  39845. */
  39846. Temp = 2,
  39847. /**
  39848. * Texture data comes from raw data (ArrayBuffer)
  39849. */
  39850. Raw = 3,
  39851. /**
  39852. * Texture content is dynamic (video or dynamic texture)
  39853. */
  39854. Dynamic = 4,
  39855. /**
  39856. * Texture content is generated by rendering to it
  39857. */
  39858. RenderTarget = 5,
  39859. /**
  39860. * Texture content is part of a multi render target process
  39861. */
  39862. MultiRenderTarget = 6,
  39863. /**
  39864. * Texture data comes from a cube data file
  39865. */
  39866. Cube = 7,
  39867. /**
  39868. * Texture data comes from a raw cube data
  39869. */
  39870. CubeRaw = 8,
  39871. /**
  39872. * Texture data come from a prefiltered cube data file
  39873. */
  39874. CubePrefiltered = 9,
  39875. /**
  39876. * Texture content is raw 3D data
  39877. */
  39878. Raw3D = 10,
  39879. /**
  39880. * Texture content is raw 2D array data
  39881. */
  39882. Raw2DArray = 11,
  39883. /**
  39884. * Texture content is a depth texture
  39885. */
  39886. Depth = 12,
  39887. /**
  39888. * Texture data comes from a raw cube data encoded with RGBD
  39889. */
  39890. CubeRawRGBD = 13
  39891. }
  39892. /**
  39893. * Class used to store data associated with WebGL texture data for the engine
  39894. * This class should not be used directly
  39895. */
  39896. export class InternalTexture {
  39897. /** @hidden */
  39898. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  39899. /**
  39900. * Defines if the texture is ready
  39901. */
  39902. isReady: boolean;
  39903. /**
  39904. * Defines if the texture is a cube texture
  39905. */
  39906. isCube: boolean;
  39907. /**
  39908. * Defines if the texture contains 3D data
  39909. */
  39910. is3D: boolean;
  39911. /**
  39912. * Defines if the texture contains 2D array data
  39913. */
  39914. is2DArray: boolean;
  39915. /**
  39916. * Defines if the texture contains multiview data
  39917. */
  39918. isMultiview: boolean;
  39919. /**
  39920. * Gets the URL used to load this texture
  39921. */
  39922. url: string;
  39923. /**
  39924. * Gets the sampling mode of the texture
  39925. */
  39926. samplingMode: number;
  39927. /**
  39928. * Gets a boolean indicating if the texture needs mipmaps generation
  39929. */
  39930. generateMipMaps: boolean;
  39931. /**
  39932. * Gets the number of samples used by the texture (WebGL2+ only)
  39933. */
  39934. samples: number;
  39935. /**
  39936. * Gets the type of the texture (int, float...)
  39937. */
  39938. type: number;
  39939. /**
  39940. * Gets the format of the texture (RGB, RGBA...)
  39941. */
  39942. format: number;
  39943. /**
  39944. * Observable called when the texture is loaded
  39945. */
  39946. onLoadedObservable: Observable<InternalTexture>;
  39947. /**
  39948. * Gets the width of the texture
  39949. */
  39950. width: number;
  39951. /**
  39952. * Gets the height of the texture
  39953. */
  39954. height: number;
  39955. /**
  39956. * Gets the depth of the texture
  39957. */
  39958. depth: number;
  39959. /**
  39960. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  39961. */
  39962. baseWidth: number;
  39963. /**
  39964. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  39965. */
  39966. baseHeight: number;
  39967. /**
  39968. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  39969. */
  39970. baseDepth: number;
  39971. /**
  39972. * Gets a boolean indicating if the texture is inverted on Y axis
  39973. */
  39974. invertY: boolean;
  39975. /** @hidden */
  39976. _invertVScale: boolean;
  39977. /** @hidden */
  39978. _associatedChannel: number;
  39979. /** @hidden */
  39980. _source: InternalTextureSource;
  39981. /** @hidden */
  39982. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  39983. /** @hidden */
  39984. _bufferView: Nullable<ArrayBufferView>;
  39985. /** @hidden */
  39986. _bufferViewArray: Nullable<ArrayBufferView[]>;
  39987. /** @hidden */
  39988. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  39989. /** @hidden */
  39990. _size: number;
  39991. /** @hidden */
  39992. _extension: string;
  39993. /** @hidden */
  39994. _files: Nullable<string[]>;
  39995. /** @hidden */
  39996. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  39997. /** @hidden */
  39998. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  39999. /** @hidden */
  40000. _framebuffer: Nullable<WebGLFramebuffer>;
  40001. /** @hidden */
  40002. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  40003. /** @hidden */
  40004. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  40005. /** @hidden */
  40006. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  40007. /** @hidden */
  40008. _attachments: Nullable<number[]>;
  40009. /** @hidden */
  40010. _textureArray: Nullable<InternalTexture[]>;
  40011. /** @hidden */
  40012. _cachedCoordinatesMode: Nullable<number>;
  40013. /** @hidden */
  40014. _cachedWrapU: Nullable<number>;
  40015. /** @hidden */
  40016. _cachedWrapV: Nullable<number>;
  40017. /** @hidden */
  40018. _cachedWrapR: Nullable<number>;
  40019. /** @hidden */
  40020. _cachedAnisotropicFilteringLevel: Nullable<number>;
  40021. /** @hidden */
  40022. _isDisabled: boolean;
  40023. /** @hidden */
  40024. _compression: Nullable<string>;
  40025. /** @hidden */
  40026. _generateStencilBuffer: boolean;
  40027. /** @hidden */
  40028. _generateDepthBuffer: boolean;
  40029. /** @hidden */
  40030. _comparisonFunction: number;
  40031. /** @hidden */
  40032. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  40033. /** @hidden */
  40034. _lodGenerationScale: number;
  40035. /** @hidden */
  40036. _lodGenerationOffset: number;
  40037. /** @hidden */
  40038. _depthStencilTexture: Nullable<InternalTexture>;
  40039. /** @hidden */
  40040. _colorTextureArray: Nullable<WebGLTexture>;
  40041. /** @hidden */
  40042. _depthStencilTextureArray: Nullable<WebGLTexture>;
  40043. /** @hidden */
  40044. _lodTextureHigh: Nullable<BaseTexture>;
  40045. /** @hidden */
  40046. _lodTextureMid: Nullable<BaseTexture>;
  40047. /** @hidden */
  40048. _lodTextureLow: Nullable<BaseTexture>;
  40049. /** @hidden */
  40050. _isRGBD: boolean;
  40051. /** @hidden */
  40052. _linearSpecularLOD: boolean;
  40053. /** @hidden */
  40054. _irradianceTexture: Nullable<BaseTexture>;
  40055. /** @hidden */
  40056. _webGLTexture: Nullable<WebGLTexture>;
  40057. /** @hidden */
  40058. _references: number;
  40059. /** @hidden */
  40060. _gammaSpace: Nullable<boolean>;
  40061. private _engine;
  40062. /**
  40063. * Gets the Engine the texture belongs to.
  40064. * @returns The babylon engine
  40065. */
  40066. getEngine(): ThinEngine;
  40067. /**
  40068. * Gets the data source type of the texture
  40069. */
  40070. get source(): InternalTextureSource;
  40071. /**
  40072. * Creates a new InternalTexture
  40073. * @param engine defines the engine to use
  40074. * @param source defines the type of data that will be used
  40075. * @param delayAllocation if the texture allocation should be delayed (default: false)
  40076. */
  40077. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  40078. /**
  40079. * Increments the number of references (ie. the number of Texture that point to it)
  40080. */
  40081. incrementReferences(): void;
  40082. /**
  40083. * Change the size of the texture (not the size of the content)
  40084. * @param width defines the new width
  40085. * @param height defines the new height
  40086. * @param depth defines the new depth (1 by default)
  40087. */
  40088. updateSize(width: int, height: int, depth?: int): void;
  40089. /** @hidden */
  40090. _rebuild(): void;
  40091. /** @hidden */
  40092. _swapAndDie(target: InternalTexture): void;
  40093. /**
  40094. * Dispose the current allocated resources
  40095. */
  40096. dispose(): void;
  40097. }
  40098. }
  40099. declare module BABYLON {
  40100. /**
  40101. * Interface used to present a loading screen while loading a scene
  40102. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  40103. */
  40104. export interface ILoadingScreen {
  40105. /**
  40106. * Function called to display the loading screen
  40107. */
  40108. displayLoadingUI: () => void;
  40109. /**
  40110. * Function called to hide the loading screen
  40111. */
  40112. hideLoadingUI: () => void;
  40113. /**
  40114. * Gets or sets the color to use for the background
  40115. */
  40116. loadingUIBackgroundColor: string;
  40117. /**
  40118. * Gets or sets the text to display while loading
  40119. */
  40120. loadingUIText: string;
  40121. }
  40122. /**
  40123. * Class used for the default loading screen
  40124. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  40125. */
  40126. export class DefaultLoadingScreen implements ILoadingScreen {
  40127. private _renderingCanvas;
  40128. private _loadingText;
  40129. private _loadingDivBackgroundColor;
  40130. private _loadingDiv;
  40131. private _loadingTextDiv;
  40132. /** Gets or sets the logo url to use for the default loading screen */
  40133. static DefaultLogoUrl: string;
  40134. /** Gets or sets the spinner url to use for the default loading screen */
  40135. static DefaultSpinnerUrl: string;
  40136. /**
  40137. * Creates a new default loading screen
  40138. * @param _renderingCanvas defines the canvas used to render the scene
  40139. * @param _loadingText defines the default text to display
  40140. * @param _loadingDivBackgroundColor defines the default background color
  40141. */
  40142. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  40143. /**
  40144. * Function called to display the loading screen
  40145. */
  40146. displayLoadingUI(): void;
  40147. /**
  40148. * Function called to hide the loading screen
  40149. */
  40150. hideLoadingUI(): void;
  40151. /**
  40152. * Gets or sets the text to display while loading
  40153. */
  40154. set loadingUIText(text: string);
  40155. get loadingUIText(): string;
  40156. /**
  40157. * Gets or sets the color to use for the background
  40158. */
  40159. get loadingUIBackgroundColor(): string;
  40160. set loadingUIBackgroundColor(color: string);
  40161. private _resizeLoadingUI;
  40162. }
  40163. }
  40164. declare module BABYLON {
  40165. /**
  40166. * Interface for any object that can request an animation frame
  40167. */
  40168. export interface ICustomAnimationFrameRequester {
  40169. /**
  40170. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  40171. */
  40172. renderFunction?: Function;
  40173. /**
  40174. * Called to request the next frame to render to
  40175. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  40176. */
  40177. requestAnimationFrame: Function;
  40178. /**
  40179. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  40180. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  40181. */
  40182. requestID?: number;
  40183. }
  40184. }
  40185. declare module BABYLON {
  40186. /**
  40187. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  40188. */
  40189. export class PerformanceMonitor {
  40190. private _enabled;
  40191. private _rollingFrameTime;
  40192. private _lastFrameTimeMs;
  40193. /**
  40194. * constructor
  40195. * @param frameSampleSize The number of samples required to saturate the sliding window
  40196. */
  40197. constructor(frameSampleSize?: number);
  40198. /**
  40199. * Samples current frame
  40200. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  40201. */
  40202. sampleFrame(timeMs?: number): void;
  40203. /**
  40204. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  40205. */
  40206. get averageFrameTime(): number;
  40207. /**
  40208. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  40209. */
  40210. get averageFrameTimeVariance(): number;
  40211. /**
  40212. * Returns the frame time of the most recent frame
  40213. */
  40214. get instantaneousFrameTime(): number;
  40215. /**
  40216. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  40217. */
  40218. get averageFPS(): number;
  40219. /**
  40220. * Returns the average framerate in frames per second using the most recent frame time
  40221. */
  40222. get instantaneousFPS(): number;
  40223. /**
  40224. * Returns true if enough samples have been taken to completely fill the sliding window
  40225. */
  40226. get isSaturated(): boolean;
  40227. /**
  40228. * Enables contributions to the sliding window sample set
  40229. */
  40230. enable(): void;
  40231. /**
  40232. * Disables contributions to the sliding window sample set
  40233. * Samples will not be interpolated over the disabled period
  40234. */
  40235. disable(): void;
  40236. /**
  40237. * Returns true if sampling is enabled
  40238. */
  40239. get isEnabled(): boolean;
  40240. /**
  40241. * Resets performance monitor
  40242. */
  40243. reset(): void;
  40244. }
  40245. /**
  40246. * RollingAverage
  40247. *
  40248. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  40249. */
  40250. export class RollingAverage {
  40251. /**
  40252. * Current average
  40253. */
  40254. average: number;
  40255. /**
  40256. * Current variance
  40257. */
  40258. variance: number;
  40259. protected _samples: Array<number>;
  40260. protected _sampleCount: number;
  40261. protected _pos: number;
  40262. protected _m2: number;
  40263. /**
  40264. * constructor
  40265. * @param length The number of samples required to saturate the sliding window
  40266. */
  40267. constructor(length: number);
  40268. /**
  40269. * Adds a sample to the sample set
  40270. * @param v The sample value
  40271. */
  40272. add(v: number): void;
  40273. /**
  40274. * Returns previously added values or null if outside of history or outside the sliding window domain
  40275. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  40276. * @return Value previously recorded with add() or null if outside of range
  40277. */
  40278. history(i: number): number;
  40279. /**
  40280. * Returns true if enough samples have been taken to completely fill the sliding window
  40281. * @return true if sample-set saturated
  40282. */
  40283. isSaturated(): boolean;
  40284. /**
  40285. * Resets the rolling average (equivalent to 0 samples taken so far)
  40286. */
  40287. reset(): void;
  40288. /**
  40289. * Wraps a value around the sample range boundaries
  40290. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  40291. * @return Wrapped position in sample range
  40292. */
  40293. protected _wrapPosition(i: number): number;
  40294. }
  40295. }
  40296. declare module BABYLON {
  40297. /**
  40298. * This class is used to track a performance counter which is number based.
  40299. * The user has access to many properties which give statistics of different nature.
  40300. *
  40301. * The implementer can track two kinds of Performance Counter: time and count.
  40302. * 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.
  40303. * 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.
  40304. */
  40305. export class PerfCounter {
  40306. /**
  40307. * Gets or sets a global boolean to turn on and off all the counters
  40308. */
  40309. static Enabled: boolean;
  40310. /**
  40311. * Returns the smallest value ever
  40312. */
  40313. get min(): number;
  40314. /**
  40315. * Returns the biggest value ever
  40316. */
  40317. get max(): number;
  40318. /**
  40319. * Returns the average value since the performance counter is running
  40320. */
  40321. get average(): number;
  40322. /**
  40323. * Returns the average value of the last second the counter was monitored
  40324. */
  40325. get lastSecAverage(): number;
  40326. /**
  40327. * Returns the current value
  40328. */
  40329. get current(): number;
  40330. /**
  40331. * Gets the accumulated total
  40332. */
  40333. get total(): number;
  40334. /**
  40335. * Gets the total value count
  40336. */
  40337. get count(): number;
  40338. /**
  40339. * Creates a new counter
  40340. */
  40341. constructor();
  40342. /**
  40343. * Call this method to start monitoring a new frame.
  40344. * 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.
  40345. */
  40346. fetchNewFrame(): void;
  40347. /**
  40348. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  40349. * @param newCount the count value to add to the monitored count
  40350. * @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.
  40351. */
  40352. addCount(newCount: number, fetchResult: boolean): void;
  40353. /**
  40354. * Start monitoring this performance counter
  40355. */
  40356. beginMonitoring(): void;
  40357. /**
  40358. * Compute the time lapsed since the previous beginMonitoring() call.
  40359. * @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
  40360. */
  40361. endMonitoring(newFrame?: boolean): void;
  40362. private _fetchResult;
  40363. private _startMonitoringTime;
  40364. private _min;
  40365. private _max;
  40366. private _average;
  40367. private _current;
  40368. private _totalValueCount;
  40369. private _totalAccumulated;
  40370. private _lastSecAverage;
  40371. private _lastSecAccumulated;
  40372. private _lastSecTime;
  40373. private _lastSecValueCount;
  40374. }
  40375. }
  40376. declare module BABYLON {
  40377. interface ThinEngine {
  40378. /** @hidden */
  40379. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  40380. }
  40381. }
  40382. declare module BABYLON {
  40383. /**
  40384. * Class used to work with sound analyzer using fast fourier transform (FFT)
  40385. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40386. */
  40387. export class Analyser {
  40388. /**
  40389. * Gets or sets the smoothing
  40390. * @ignorenaming
  40391. */
  40392. SMOOTHING: number;
  40393. /**
  40394. * Gets or sets the FFT table size
  40395. * @ignorenaming
  40396. */
  40397. FFT_SIZE: number;
  40398. /**
  40399. * Gets or sets the bar graph amplitude
  40400. * @ignorenaming
  40401. */
  40402. BARGRAPHAMPLITUDE: number;
  40403. /**
  40404. * Gets or sets the position of the debug canvas
  40405. * @ignorenaming
  40406. */
  40407. DEBUGCANVASPOS: {
  40408. x: number;
  40409. y: number;
  40410. };
  40411. /**
  40412. * Gets or sets the debug canvas size
  40413. * @ignorenaming
  40414. */
  40415. DEBUGCANVASSIZE: {
  40416. width: number;
  40417. height: number;
  40418. };
  40419. private _byteFreqs;
  40420. private _byteTime;
  40421. private _floatFreqs;
  40422. private _webAudioAnalyser;
  40423. private _debugCanvas;
  40424. private _debugCanvasContext;
  40425. private _scene;
  40426. private _registerFunc;
  40427. private _audioEngine;
  40428. /**
  40429. * Creates a new analyser
  40430. * @param scene defines hosting scene
  40431. */
  40432. constructor(scene: Scene);
  40433. /**
  40434. * Get the number of data values you will have to play with for the visualization
  40435. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  40436. * @returns a number
  40437. */
  40438. getFrequencyBinCount(): number;
  40439. /**
  40440. * Gets the current frequency data as a byte array
  40441. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  40442. * @returns a Uint8Array
  40443. */
  40444. getByteFrequencyData(): Uint8Array;
  40445. /**
  40446. * Gets the current waveform as a byte array
  40447. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  40448. * @returns a Uint8Array
  40449. */
  40450. getByteTimeDomainData(): Uint8Array;
  40451. /**
  40452. * Gets the current frequency data as a float array
  40453. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  40454. * @returns a Float32Array
  40455. */
  40456. getFloatFrequencyData(): Float32Array;
  40457. /**
  40458. * Renders the debug canvas
  40459. */
  40460. drawDebugCanvas(): void;
  40461. /**
  40462. * Stops rendering the debug canvas and removes it
  40463. */
  40464. stopDebugCanvas(): void;
  40465. /**
  40466. * Connects two audio nodes
  40467. * @param inputAudioNode defines first node to connect
  40468. * @param outputAudioNode defines second node to connect
  40469. */
  40470. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  40471. /**
  40472. * Releases all associated resources
  40473. */
  40474. dispose(): void;
  40475. }
  40476. }
  40477. declare module BABYLON {
  40478. /**
  40479. * This represents an audio engine and it is responsible
  40480. * to play, synchronize and analyse sounds throughout the application.
  40481. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40482. */
  40483. export interface IAudioEngine extends IDisposable {
  40484. /**
  40485. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  40486. */
  40487. readonly canUseWebAudio: boolean;
  40488. /**
  40489. * Gets the current AudioContext if available.
  40490. */
  40491. readonly audioContext: Nullable<AudioContext>;
  40492. /**
  40493. * The master gain node defines the global audio volume of your audio engine.
  40494. */
  40495. readonly masterGain: GainNode;
  40496. /**
  40497. * Gets whether or not mp3 are supported by your browser.
  40498. */
  40499. readonly isMP3supported: boolean;
  40500. /**
  40501. * Gets whether or not ogg are supported by your browser.
  40502. */
  40503. readonly isOGGsupported: boolean;
  40504. /**
  40505. * Defines if Babylon should emit a warning if WebAudio is not supported.
  40506. * @ignoreNaming
  40507. */
  40508. WarnedWebAudioUnsupported: boolean;
  40509. /**
  40510. * Defines if the audio engine relies on a custom unlocked button.
  40511. * In this case, the embedded button will not be displayed.
  40512. */
  40513. useCustomUnlockedButton: boolean;
  40514. /**
  40515. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  40516. */
  40517. readonly unlocked: boolean;
  40518. /**
  40519. * Event raised when audio has been unlocked on the browser.
  40520. */
  40521. onAudioUnlockedObservable: Observable<IAudioEngine>;
  40522. /**
  40523. * Event raised when audio has been locked on the browser.
  40524. */
  40525. onAudioLockedObservable: Observable<IAudioEngine>;
  40526. /**
  40527. * Flags the audio engine in Locked state.
  40528. * This happens due to new browser policies preventing audio to autoplay.
  40529. */
  40530. lock(): void;
  40531. /**
  40532. * Unlocks the audio engine once a user action has been done on the dom.
  40533. * This is helpful to resume play once browser policies have been satisfied.
  40534. */
  40535. unlock(): void;
  40536. /**
  40537. * Gets the global volume sets on the master gain.
  40538. * @returns the global volume if set or -1 otherwise
  40539. */
  40540. getGlobalVolume(): number;
  40541. /**
  40542. * Sets the global volume of your experience (sets on the master gain).
  40543. * @param newVolume Defines the new global volume of the application
  40544. */
  40545. setGlobalVolume(newVolume: number): void;
  40546. /**
  40547. * Connect the audio engine to an audio analyser allowing some amazing
  40548. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  40549. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  40550. * @param analyser The analyser to connect to the engine
  40551. */
  40552. connectToAnalyser(analyser: Analyser): void;
  40553. }
  40554. }
  40555. declare module BABYLON {
  40556. /**
  40557. * Defines the interface used by display changed events
  40558. */
  40559. export interface IDisplayChangedEventArgs {
  40560. /** Gets the vrDisplay object (if any) */
  40561. vrDisplay: Nullable<any>;
  40562. /** Gets a boolean indicating if webVR is supported */
  40563. vrSupported: boolean;
  40564. }
  40565. /**
  40566. * Defines the interface used by objects containing a viewport (like a camera)
  40567. */
  40568. interface IViewportOwnerLike {
  40569. /**
  40570. * Gets or sets the viewport
  40571. */
  40572. viewport: IViewportLike;
  40573. }
  40574. /**
  40575. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  40576. */
  40577. export class Engine extends ThinEngine {
  40578. /** Defines that alpha blending is disabled */
  40579. static readonly ALPHA_DISABLE: number;
  40580. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  40581. static readonly ALPHA_ADD: number;
  40582. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  40583. static readonly ALPHA_COMBINE: number;
  40584. /** Defines that alpha blending to DEST - SRC * DEST */
  40585. static readonly ALPHA_SUBTRACT: number;
  40586. /** Defines that alpha blending to SRC * DEST */
  40587. static readonly ALPHA_MULTIPLY: number;
  40588. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  40589. static readonly ALPHA_MAXIMIZED: number;
  40590. /** Defines that alpha blending to SRC + DEST */
  40591. static readonly ALPHA_ONEONE: number;
  40592. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  40593. static readonly ALPHA_PREMULTIPLIED: number;
  40594. /**
  40595. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  40596. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  40597. */
  40598. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  40599. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  40600. static readonly ALPHA_INTERPOLATE: number;
  40601. /**
  40602. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  40603. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  40604. */
  40605. static readonly ALPHA_SCREENMODE: number;
  40606. /** Defines that the ressource is not delayed*/
  40607. static readonly DELAYLOADSTATE_NONE: number;
  40608. /** Defines that the ressource was successfully delay loaded */
  40609. static readonly DELAYLOADSTATE_LOADED: number;
  40610. /** Defines that the ressource is currently delay loading */
  40611. static readonly DELAYLOADSTATE_LOADING: number;
  40612. /** Defines that the ressource is delayed and has not started loading */
  40613. static readonly DELAYLOADSTATE_NOTLOADED: number;
  40614. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  40615. static readonly NEVER: number;
  40616. /** 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 */
  40617. static readonly ALWAYS: number;
  40618. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  40619. static readonly LESS: number;
  40620. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  40621. static readonly EQUAL: number;
  40622. /** 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 */
  40623. static readonly LEQUAL: number;
  40624. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  40625. static readonly GREATER: number;
  40626. /** 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 */
  40627. static readonly GEQUAL: number;
  40628. /** 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 */
  40629. static readonly NOTEQUAL: number;
  40630. /** Passed to stencilOperation to specify that stencil value must be kept */
  40631. static readonly KEEP: number;
  40632. /** Passed to stencilOperation to specify that stencil value must be replaced */
  40633. static readonly REPLACE: number;
  40634. /** Passed to stencilOperation to specify that stencil value must be incremented */
  40635. static readonly INCR: number;
  40636. /** Passed to stencilOperation to specify that stencil value must be decremented */
  40637. static readonly DECR: number;
  40638. /** Passed to stencilOperation to specify that stencil value must be inverted */
  40639. static readonly INVERT: number;
  40640. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  40641. static readonly INCR_WRAP: number;
  40642. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  40643. static readonly DECR_WRAP: number;
  40644. /** Texture is not repeating outside of 0..1 UVs */
  40645. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  40646. /** Texture is repeating outside of 0..1 UVs */
  40647. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  40648. /** Texture is repeating and mirrored */
  40649. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  40650. /** ALPHA */
  40651. static readonly TEXTUREFORMAT_ALPHA: number;
  40652. /** LUMINANCE */
  40653. static readonly TEXTUREFORMAT_LUMINANCE: number;
  40654. /** LUMINANCE_ALPHA */
  40655. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  40656. /** RGB */
  40657. static readonly TEXTUREFORMAT_RGB: number;
  40658. /** RGBA */
  40659. static readonly TEXTUREFORMAT_RGBA: number;
  40660. /** RED */
  40661. static readonly TEXTUREFORMAT_RED: number;
  40662. /** RED (2nd reference) */
  40663. static readonly TEXTUREFORMAT_R: number;
  40664. /** RG */
  40665. static readonly TEXTUREFORMAT_RG: number;
  40666. /** RED_INTEGER */
  40667. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  40668. /** RED_INTEGER (2nd reference) */
  40669. static readonly TEXTUREFORMAT_R_INTEGER: number;
  40670. /** RG_INTEGER */
  40671. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  40672. /** RGB_INTEGER */
  40673. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  40674. /** RGBA_INTEGER */
  40675. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  40676. /** UNSIGNED_BYTE */
  40677. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  40678. /** UNSIGNED_BYTE (2nd reference) */
  40679. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  40680. /** FLOAT */
  40681. static readonly TEXTURETYPE_FLOAT: number;
  40682. /** HALF_FLOAT */
  40683. static readonly TEXTURETYPE_HALF_FLOAT: number;
  40684. /** BYTE */
  40685. static readonly TEXTURETYPE_BYTE: number;
  40686. /** SHORT */
  40687. static readonly TEXTURETYPE_SHORT: number;
  40688. /** UNSIGNED_SHORT */
  40689. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  40690. /** INT */
  40691. static readonly TEXTURETYPE_INT: number;
  40692. /** UNSIGNED_INT */
  40693. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  40694. /** UNSIGNED_SHORT_4_4_4_4 */
  40695. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  40696. /** UNSIGNED_SHORT_5_5_5_1 */
  40697. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  40698. /** UNSIGNED_SHORT_5_6_5 */
  40699. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  40700. /** UNSIGNED_INT_2_10_10_10_REV */
  40701. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  40702. /** UNSIGNED_INT_24_8 */
  40703. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  40704. /** UNSIGNED_INT_10F_11F_11F_REV */
  40705. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  40706. /** UNSIGNED_INT_5_9_9_9_REV */
  40707. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  40708. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  40709. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  40710. /** nearest is mag = nearest and min = nearest and mip = linear */
  40711. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  40712. /** Bilinear is mag = linear and min = linear and mip = nearest */
  40713. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  40714. /** Trilinear is mag = linear and min = linear and mip = linear */
  40715. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  40716. /** nearest is mag = nearest and min = nearest and mip = linear */
  40717. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  40718. /** Bilinear is mag = linear and min = linear and mip = nearest */
  40719. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  40720. /** Trilinear is mag = linear and min = linear and mip = linear */
  40721. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  40722. /** mag = nearest and min = nearest and mip = nearest */
  40723. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  40724. /** mag = nearest and min = linear and mip = nearest */
  40725. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  40726. /** mag = nearest and min = linear and mip = linear */
  40727. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  40728. /** mag = nearest and min = linear and mip = none */
  40729. static readonly TEXTURE_NEAREST_LINEAR: number;
  40730. /** mag = nearest and min = nearest and mip = none */
  40731. static readonly TEXTURE_NEAREST_NEAREST: number;
  40732. /** mag = linear and min = nearest and mip = nearest */
  40733. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  40734. /** mag = linear and min = nearest and mip = linear */
  40735. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  40736. /** mag = linear and min = linear and mip = none */
  40737. static readonly TEXTURE_LINEAR_LINEAR: number;
  40738. /** mag = linear and min = nearest and mip = none */
  40739. static readonly TEXTURE_LINEAR_NEAREST: number;
  40740. /** Explicit coordinates mode */
  40741. static readonly TEXTURE_EXPLICIT_MODE: number;
  40742. /** Spherical coordinates mode */
  40743. static readonly TEXTURE_SPHERICAL_MODE: number;
  40744. /** Planar coordinates mode */
  40745. static readonly TEXTURE_PLANAR_MODE: number;
  40746. /** Cubic coordinates mode */
  40747. static readonly TEXTURE_CUBIC_MODE: number;
  40748. /** Projection coordinates mode */
  40749. static readonly TEXTURE_PROJECTION_MODE: number;
  40750. /** Skybox coordinates mode */
  40751. static readonly TEXTURE_SKYBOX_MODE: number;
  40752. /** Inverse Cubic coordinates mode */
  40753. static readonly TEXTURE_INVCUBIC_MODE: number;
  40754. /** Equirectangular coordinates mode */
  40755. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  40756. /** Equirectangular Fixed coordinates mode */
  40757. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  40758. /** Equirectangular Fixed Mirrored coordinates mode */
  40759. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  40760. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  40761. static readonly SCALEMODE_FLOOR: number;
  40762. /** Defines that texture rescaling will look for the nearest power of 2 size */
  40763. static readonly SCALEMODE_NEAREST: number;
  40764. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  40765. static readonly SCALEMODE_CEILING: number;
  40766. /**
  40767. * Returns the current npm package of the sdk
  40768. */
  40769. static get NpmPackage(): string;
  40770. /**
  40771. * Returns the current version of the framework
  40772. */
  40773. static get Version(): string;
  40774. /** Gets the list of created engines */
  40775. static get Instances(): Engine[];
  40776. /**
  40777. * Gets the latest created engine
  40778. */
  40779. static get LastCreatedEngine(): Nullable<Engine>;
  40780. /**
  40781. * Gets the latest created scene
  40782. */
  40783. static get LastCreatedScene(): Nullable<Scene>;
  40784. /**
  40785. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  40786. * @param flag defines which part of the materials must be marked as dirty
  40787. * @param predicate defines a predicate used to filter which materials should be affected
  40788. */
  40789. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  40790. /**
  40791. * Method called to create the default loading screen.
  40792. * This can be overriden in your own app.
  40793. * @param canvas The rendering canvas element
  40794. * @returns The loading screen
  40795. */
  40796. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  40797. /**
  40798. * Method called to create the default rescale post process on each engine.
  40799. */
  40800. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  40801. /**
  40802. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  40803. **/
  40804. enableOfflineSupport: boolean;
  40805. /**
  40806. * 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)
  40807. **/
  40808. disableManifestCheck: boolean;
  40809. /**
  40810. * Gets the list of created scenes
  40811. */
  40812. scenes: Scene[];
  40813. /**
  40814. * Event raised when a new scene is created
  40815. */
  40816. onNewSceneAddedObservable: Observable<Scene>;
  40817. /**
  40818. * Gets the list of created postprocesses
  40819. */
  40820. postProcesses: PostProcess[];
  40821. /**
  40822. * Gets a boolean indicating if the pointer is currently locked
  40823. */
  40824. isPointerLock: boolean;
  40825. /**
  40826. * Observable event triggered each time the rendering canvas is resized
  40827. */
  40828. onResizeObservable: Observable<Engine>;
  40829. /**
  40830. * Observable event triggered each time the canvas loses focus
  40831. */
  40832. onCanvasBlurObservable: Observable<Engine>;
  40833. /**
  40834. * Observable event triggered each time the canvas gains focus
  40835. */
  40836. onCanvasFocusObservable: Observable<Engine>;
  40837. /**
  40838. * Observable event triggered each time the canvas receives pointerout event
  40839. */
  40840. onCanvasPointerOutObservable: Observable<PointerEvent>;
  40841. /**
  40842. * Observable raised when the engine begins a new frame
  40843. */
  40844. onBeginFrameObservable: Observable<Engine>;
  40845. /**
  40846. * If set, will be used to request the next animation frame for the render loop
  40847. */
  40848. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  40849. /**
  40850. * Observable raised when the engine ends the current frame
  40851. */
  40852. onEndFrameObservable: Observable<Engine>;
  40853. /**
  40854. * Observable raised when the engine is about to compile a shader
  40855. */
  40856. onBeforeShaderCompilationObservable: Observable<Engine>;
  40857. /**
  40858. * Observable raised when the engine has jsut compiled a shader
  40859. */
  40860. onAfterShaderCompilationObservable: Observable<Engine>;
  40861. /**
  40862. * Gets the audio engine
  40863. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40864. * @ignorenaming
  40865. */
  40866. static audioEngine: IAudioEngine;
  40867. /**
  40868. * Default AudioEngine factory responsible of creating the Audio Engine.
  40869. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  40870. */
  40871. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  40872. /**
  40873. * Default offline support factory responsible of creating a tool used to store data locally.
  40874. * By default, this will create a Database object if the workload has been embedded.
  40875. */
  40876. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  40877. private _loadingScreen;
  40878. private _pointerLockRequested;
  40879. private _rescalePostProcess;
  40880. private _deterministicLockstep;
  40881. private _lockstepMaxSteps;
  40882. private _timeStep;
  40883. protected get _supportsHardwareTextureRescaling(): boolean;
  40884. private _fps;
  40885. private _deltaTime;
  40886. /** @hidden */
  40887. _drawCalls: PerfCounter;
  40888. /** 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 */
  40889. canvasTabIndex: number;
  40890. /**
  40891. * Turn this value on if you want to pause FPS computation when in background
  40892. */
  40893. disablePerformanceMonitorInBackground: boolean;
  40894. private _performanceMonitor;
  40895. /**
  40896. * Gets the performance monitor attached to this engine
  40897. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  40898. */
  40899. get performanceMonitor(): PerformanceMonitor;
  40900. private _onFocus;
  40901. private _onBlur;
  40902. private _onCanvasPointerOut;
  40903. private _onCanvasBlur;
  40904. private _onCanvasFocus;
  40905. private _onFullscreenChange;
  40906. private _onPointerLockChange;
  40907. /**
  40908. * Gets the HTML element used to attach event listeners
  40909. * @returns a HTML element
  40910. */
  40911. getInputElement(): Nullable<HTMLElement>;
  40912. /**
  40913. * Creates a new engine
  40914. * @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
  40915. * @param antialias defines enable antialiasing (default: false)
  40916. * @param options defines further options to be sent to the getContext() function
  40917. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  40918. */
  40919. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  40920. /**
  40921. * Gets current aspect ratio
  40922. * @param viewportOwner defines the camera to use to get the aspect ratio
  40923. * @param useScreen defines if screen size must be used (or the current render target if any)
  40924. * @returns a number defining the aspect ratio
  40925. */
  40926. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  40927. /**
  40928. * Gets current screen aspect ratio
  40929. * @returns a number defining the aspect ratio
  40930. */
  40931. getScreenAspectRatio(): number;
  40932. /**
  40933. * Gets the client rect of the HTML canvas attached with the current webGL context
  40934. * @returns a client rectanglee
  40935. */
  40936. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  40937. /**
  40938. * Gets the client rect of the HTML element used for events
  40939. * @returns a client rectanglee
  40940. */
  40941. getInputElementClientRect(): Nullable<ClientRect>;
  40942. /**
  40943. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  40944. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40945. * @returns true if engine is in deterministic lock step mode
  40946. */
  40947. isDeterministicLockStep(): boolean;
  40948. /**
  40949. * Gets the max steps when engine is running in deterministic lock step
  40950. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40951. * @returns the max steps
  40952. */
  40953. getLockstepMaxSteps(): number;
  40954. /**
  40955. * Returns the time in ms between steps when using deterministic lock step.
  40956. * @returns time step in (ms)
  40957. */
  40958. getTimeStep(): number;
  40959. /**
  40960. * Force the mipmap generation for the given render target texture
  40961. * @param texture defines the render target texture to use
  40962. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  40963. */
  40964. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  40965. /** States */
  40966. /**
  40967. * Set various states to the webGL context
  40968. * @param culling defines backface culling state
  40969. * @param zOffset defines the value to apply to zOffset (0 by default)
  40970. * @param force defines if states must be applied even if cache is up to date
  40971. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  40972. */
  40973. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  40974. /**
  40975. * Set the z offset to apply to current rendering
  40976. * @param value defines the offset to apply
  40977. */
  40978. setZOffset(value: number): void;
  40979. /**
  40980. * Gets the current value of the zOffset
  40981. * @returns the current zOffset state
  40982. */
  40983. getZOffset(): number;
  40984. /**
  40985. * Enable or disable depth buffering
  40986. * @param enable defines the state to set
  40987. */
  40988. setDepthBuffer(enable: boolean): void;
  40989. /**
  40990. * Gets a boolean indicating if depth writing is enabled
  40991. * @returns the current depth writing state
  40992. */
  40993. getDepthWrite(): boolean;
  40994. /**
  40995. * Enable or disable depth writing
  40996. * @param enable defines the state to set
  40997. */
  40998. setDepthWrite(enable: boolean): void;
  40999. /**
  41000. * Gets a boolean indicating if stencil buffer is enabled
  41001. * @returns the current stencil buffer state
  41002. */
  41003. getStencilBuffer(): boolean;
  41004. /**
  41005. * Enable or disable the stencil buffer
  41006. * @param enable defines if the stencil buffer must be enabled or disabled
  41007. */
  41008. setStencilBuffer(enable: boolean): void;
  41009. /**
  41010. * Gets the current stencil mask
  41011. * @returns a number defining the new stencil mask to use
  41012. */
  41013. getStencilMask(): number;
  41014. /**
  41015. * Sets the current stencil mask
  41016. * @param mask defines the new stencil mask to use
  41017. */
  41018. setStencilMask(mask: number): void;
  41019. /**
  41020. * Gets the current stencil function
  41021. * @returns a number defining the stencil function to use
  41022. */
  41023. getStencilFunction(): number;
  41024. /**
  41025. * Gets the current stencil reference value
  41026. * @returns a number defining the stencil reference value to use
  41027. */
  41028. getStencilFunctionReference(): number;
  41029. /**
  41030. * Gets the current stencil mask
  41031. * @returns a number defining the stencil mask to use
  41032. */
  41033. getStencilFunctionMask(): number;
  41034. /**
  41035. * Sets the current stencil function
  41036. * @param stencilFunc defines the new stencil function to use
  41037. */
  41038. setStencilFunction(stencilFunc: number): void;
  41039. /**
  41040. * Sets the current stencil reference
  41041. * @param reference defines the new stencil reference to use
  41042. */
  41043. setStencilFunctionReference(reference: number): void;
  41044. /**
  41045. * Sets the current stencil mask
  41046. * @param mask defines the new stencil mask to use
  41047. */
  41048. setStencilFunctionMask(mask: number): void;
  41049. /**
  41050. * Gets the current stencil operation when stencil fails
  41051. * @returns a number defining stencil operation to use when stencil fails
  41052. */
  41053. getStencilOperationFail(): number;
  41054. /**
  41055. * Gets the current stencil operation when depth fails
  41056. * @returns a number defining stencil operation to use when depth fails
  41057. */
  41058. getStencilOperationDepthFail(): number;
  41059. /**
  41060. * Gets the current stencil operation when stencil passes
  41061. * @returns a number defining stencil operation to use when stencil passes
  41062. */
  41063. getStencilOperationPass(): number;
  41064. /**
  41065. * Sets the stencil operation to use when stencil fails
  41066. * @param operation defines the stencil operation to use when stencil fails
  41067. */
  41068. setStencilOperationFail(operation: number): void;
  41069. /**
  41070. * Sets the stencil operation to use when depth fails
  41071. * @param operation defines the stencil operation to use when depth fails
  41072. */
  41073. setStencilOperationDepthFail(operation: number): void;
  41074. /**
  41075. * Sets the stencil operation to use when stencil passes
  41076. * @param operation defines the stencil operation to use when stencil passes
  41077. */
  41078. setStencilOperationPass(operation: number): void;
  41079. /**
  41080. * Sets a boolean indicating if the dithering state is enabled or disabled
  41081. * @param value defines the dithering state
  41082. */
  41083. setDitheringState(value: boolean): void;
  41084. /**
  41085. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  41086. * @param value defines the rasterizer state
  41087. */
  41088. setRasterizerState(value: boolean): void;
  41089. /**
  41090. * Gets the current depth function
  41091. * @returns a number defining the depth function
  41092. */
  41093. getDepthFunction(): Nullable<number>;
  41094. /**
  41095. * Sets the current depth function
  41096. * @param depthFunc defines the function to use
  41097. */
  41098. setDepthFunction(depthFunc: number): void;
  41099. /**
  41100. * Sets the current depth function to GREATER
  41101. */
  41102. setDepthFunctionToGreater(): void;
  41103. /**
  41104. * Sets the current depth function to GEQUAL
  41105. */
  41106. setDepthFunctionToGreaterOrEqual(): void;
  41107. /**
  41108. * Sets the current depth function to LESS
  41109. */
  41110. setDepthFunctionToLess(): void;
  41111. /**
  41112. * Sets the current depth function to LEQUAL
  41113. */
  41114. setDepthFunctionToLessOrEqual(): void;
  41115. private _cachedStencilBuffer;
  41116. private _cachedStencilFunction;
  41117. private _cachedStencilMask;
  41118. private _cachedStencilOperationPass;
  41119. private _cachedStencilOperationFail;
  41120. private _cachedStencilOperationDepthFail;
  41121. private _cachedStencilReference;
  41122. /**
  41123. * Caches the the state of the stencil buffer
  41124. */
  41125. cacheStencilState(): void;
  41126. /**
  41127. * Restores the state of the stencil buffer
  41128. */
  41129. restoreStencilState(): void;
  41130. /**
  41131. * Directly set the WebGL Viewport
  41132. * @param x defines the x coordinate of the viewport (in screen space)
  41133. * @param y defines the y coordinate of the viewport (in screen space)
  41134. * @param width defines the width of the viewport (in screen space)
  41135. * @param height defines the height of the viewport (in screen space)
  41136. * @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
  41137. */
  41138. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  41139. /**
  41140. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  41141. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  41142. * @param y defines the y-coordinate of the corner of the clear rectangle
  41143. * @param width defines the width of the clear rectangle
  41144. * @param height defines the height of the clear rectangle
  41145. * @param clearColor defines the clear color
  41146. */
  41147. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  41148. /**
  41149. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  41150. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  41151. * @param y defines the y-coordinate of the corner of the clear rectangle
  41152. * @param width defines the width of the clear rectangle
  41153. * @param height defines the height of the clear rectangle
  41154. */
  41155. enableScissor(x: number, y: number, width: number, height: number): void;
  41156. /**
  41157. * Disable previously set scissor test rectangle
  41158. */
  41159. disableScissor(): void;
  41160. protected _reportDrawCall(): void;
  41161. /**
  41162. * Initializes a webVR display and starts listening to display change events
  41163. * The onVRDisplayChangedObservable will be notified upon these changes
  41164. * @returns The onVRDisplayChangedObservable
  41165. */
  41166. initWebVR(): Observable<IDisplayChangedEventArgs>;
  41167. /** @hidden */
  41168. _prepareVRComponent(): void;
  41169. /** @hidden */
  41170. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  41171. /** @hidden */
  41172. _submitVRFrame(): void;
  41173. /**
  41174. * Call this function to leave webVR mode
  41175. * Will do nothing if webVR is not supported or if there is no webVR device
  41176. * @see https://doc.babylonjs.com/how_to/webvr_camera
  41177. */
  41178. disableVR(): void;
  41179. /**
  41180. * Gets a boolean indicating that the system is in VR mode and is presenting
  41181. * @returns true if VR mode is engaged
  41182. */
  41183. isVRPresenting(): boolean;
  41184. /** @hidden */
  41185. _requestVRFrame(): void;
  41186. /** @hidden */
  41187. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41188. /**
  41189. * Gets the source code of the vertex shader associated with a specific webGL program
  41190. * @param program defines the program to use
  41191. * @returns a string containing the source code of the vertex shader associated with the program
  41192. */
  41193. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  41194. /**
  41195. * Gets the source code of the fragment shader associated with a specific webGL program
  41196. * @param program defines the program to use
  41197. * @returns a string containing the source code of the fragment shader associated with the program
  41198. */
  41199. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  41200. /**
  41201. * Sets a depth stencil texture from a render target to the according uniform.
  41202. * @param channel The texture channel
  41203. * @param uniform The uniform to set
  41204. * @param texture The render target texture containing the depth stencil texture to apply
  41205. */
  41206. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  41207. /**
  41208. * Sets a texture to the webGL context from a postprocess
  41209. * @param channel defines the channel to use
  41210. * @param postProcess defines the source postprocess
  41211. */
  41212. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  41213. /**
  41214. * Binds the output of the passed in post process to the texture channel specified
  41215. * @param channel The channel the texture should be bound to
  41216. * @param postProcess The post process which's output should be bound
  41217. */
  41218. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  41219. protected _rebuildBuffers(): void;
  41220. /** @hidden */
  41221. _renderFrame(): void;
  41222. _renderLoop(): void;
  41223. /** @hidden */
  41224. _renderViews(): boolean;
  41225. /**
  41226. * Toggle full screen mode
  41227. * @param requestPointerLock defines if a pointer lock should be requested from the user
  41228. */
  41229. switchFullscreen(requestPointerLock: boolean): void;
  41230. /**
  41231. * Enters full screen mode
  41232. * @param requestPointerLock defines if a pointer lock should be requested from the user
  41233. */
  41234. enterFullscreen(requestPointerLock: boolean): void;
  41235. /**
  41236. * Exits full screen mode
  41237. */
  41238. exitFullscreen(): void;
  41239. /**
  41240. * Enters Pointerlock mode
  41241. */
  41242. enterPointerlock(): void;
  41243. /**
  41244. * Exits Pointerlock mode
  41245. */
  41246. exitPointerlock(): void;
  41247. /**
  41248. * Begin a new frame
  41249. */
  41250. beginFrame(): void;
  41251. /**
  41252. * Enf the current frame
  41253. */
  41254. endFrame(): void;
  41255. resize(): void;
  41256. /**
  41257. * Force a specific size of the canvas
  41258. * @param width defines the new canvas' width
  41259. * @param height defines the new canvas' height
  41260. * @returns true if the size was changed
  41261. */
  41262. setSize(width: number, height: number): boolean;
  41263. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  41264. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41265. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41266. _releaseTexture(texture: InternalTexture): void;
  41267. /**
  41268. * @hidden
  41269. * Rescales a texture
  41270. * @param source input texutre
  41271. * @param destination destination texture
  41272. * @param scene scene to use to render the resize
  41273. * @param internalFormat format to use when resizing
  41274. * @param onComplete callback to be called when resize has completed
  41275. */
  41276. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  41277. /**
  41278. * Gets the current framerate
  41279. * @returns a number representing the framerate
  41280. */
  41281. getFps(): number;
  41282. /**
  41283. * Gets the time spent between current and previous frame
  41284. * @returns a number representing the delta time in ms
  41285. */
  41286. getDeltaTime(): number;
  41287. private _measureFps;
  41288. /** @hidden */
  41289. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  41290. /**
  41291. * Updates the sample count of a render target texture
  41292. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  41293. * @param texture defines the texture to update
  41294. * @param samples defines the sample count to set
  41295. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  41296. */
  41297. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  41298. /**
  41299. * Updates a depth texture Comparison Mode and Function.
  41300. * If the comparison Function is equal to 0, the mode will be set to none.
  41301. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  41302. * @param texture The texture to set the comparison function for
  41303. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  41304. */
  41305. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  41306. /**
  41307. * Creates a webGL buffer to use with instanciation
  41308. * @param capacity defines the size of the buffer
  41309. * @returns the webGL buffer
  41310. */
  41311. createInstancesBuffer(capacity: number): DataBuffer;
  41312. /**
  41313. * Delete a webGL buffer used with instanciation
  41314. * @param buffer defines the webGL buffer to delete
  41315. */
  41316. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  41317. private _clientWaitAsync;
  41318. /** @hidden */
  41319. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  41320. dispose(): void;
  41321. private _disableTouchAction;
  41322. /**
  41323. * Display the loading screen
  41324. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41325. */
  41326. displayLoadingUI(): void;
  41327. /**
  41328. * Hide the loading screen
  41329. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41330. */
  41331. hideLoadingUI(): void;
  41332. /**
  41333. * Gets the current loading screen object
  41334. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41335. */
  41336. get loadingScreen(): ILoadingScreen;
  41337. /**
  41338. * Sets the current loading screen object
  41339. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41340. */
  41341. set loadingScreen(loadingScreen: ILoadingScreen);
  41342. /**
  41343. * Sets the current loading screen text
  41344. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41345. */
  41346. set loadingUIText(text: string);
  41347. /**
  41348. * Sets the current loading screen background color
  41349. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41350. */
  41351. set loadingUIBackgroundColor(color: string);
  41352. /** Pointerlock and fullscreen */
  41353. /**
  41354. * Ask the browser to promote the current element to pointerlock mode
  41355. * @param element defines the DOM element to promote
  41356. */
  41357. static _RequestPointerlock(element: HTMLElement): void;
  41358. /**
  41359. * Asks the browser to exit pointerlock mode
  41360. */
  41361. static _ExitPointerlock(): void;
  41362. /**
  41363. * Ask the browser to promote the current element to fullscreen rendering mode
  41364. * @param element defines the DOM element to promote
  41365. */
  41366. static _RequestFullscreen(element: HTMLElement): void;
  41367. /**
  41368. * Asks the browser to exit fullscreen mode
  41369. */
  41370. static _ExitFullscreen(): void;
  41371. }
  41372. }
  41373. declare module BABYLON {
  41374. /**
  41375. * The engine store class is responsible to hold all the instances of Engine and Scene created
  41376. * during the life time of the application.
  41377. */
  41378. export class EngineStore {
  41379. /** Gets the list of created engines */
  41380. static Instances: Engine[];
  41381. /** @hidden */
  41382. static _LastCreatedScene: Nullable<Scene>;
  41383. /**
  41384. * Gets the latest created engine
  41385. */
  41386. static get LastCreatedEngine(): Nullable<Engine>;
  41387. /**
  41388. * Gets the latest created scene
  41389. */
  41390. static get LastCreatedScene(): Nullable<Scene>;
  41391. /**
  41392. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  41393. * @ignorenaming
  41394. */
  41395. static UseFallbackTexture: boolean;
  41396. /**
  41397. * Texture content used if a texture cannot loaded
  41398. * @ignorenaming
  41399. */
  41400. static FallbackTexture: string;
  41401. }
  41402. }
  41403. declare module BABYLON {
  41404. /**
  41405. * Helper class that provides a small promise polyfill
  41406. */
  41407. export class PromisePolyfill {
  41408. /**
  41409. * Static function used to check if the polyfill is required
  41410. * If this is the case then the function will inject the polyfill to window.Promise
  41411. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  41412. */
  41413. static Apply(force?: boolean): void;
  41414. }
  41415. }
  41416. declare module BABYLON {
  41417. /**
  41418. * Interface for screenshot methods with describe argument called `size` as object with options
  41419. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  41420. */
  41421. export interface IScreenshotSize {
  41422. /**
  41423. * number in pixels for canvas height
  41424. */
  41425. height?: number;
  41426. /**
  41427. * multiplier allowing render at a higher or lower resolution
  41428. * If value is defined then height and width will be ignored and taken from camera
  41429. */
  41430. precision?: number;
  41431. /**
  41432. * number in pixels for canvas width
  41433. */
  41434. width?: number;
  41435. }
  41436. }
  41437. declare module BABYLON {
  41438. interface IColor4Like {
  41439. r: float;
  41440. g: float;
  41441. b: float;
  41442. a: float;
  41443. }
  41444. /**
  41445. * Class containing a set of static utilities functions
  41446. */
  41447. export class Tools {
  41448. /**
  41449. * Gets or sets the base URL to use to load assets
  41450. */
  41451. static get BaseUrl(): string;
  41452. static set BaseUrl(value: string);
  41453. /**
  41454. * Enable/Disable Custom HTTP Request Headers globally.
  41455. * default = false
  41456. * @see CustomRequestHeaders
  41457. */
  41458. static UseCustomRequestHeaders: boolean;
  41459. /**
  41460. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  41461. * i.e. when loading files, where the server/service expects an Authorization header
  41462. */
  41463. static CustomRequestHeaders: {
  41464. [key: string]: string;
  41465. };
  41466. /**
  41467. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  41468. */
  41469. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  41470. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  41471. /**
  41472. * Default behaviour for cors in the application.
  41473. * It can be a string if the expected behavior is identical in the entire app.
  41474. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  41475. */
  41476. static get CorsBehavior(): string | ((url: string | string[]) => string);
  41477. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  41478. /**
  41479. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  41480. * @ignorenaming
  41481. */
  41482. static get UseFallbackTexture(): boolean;
  41483. static set UseFallbackTexture(value: boolean);
  41484. /**
  41485. * Use this object to register external classes like custom textures or material
  41486. * to allow the laoders to instantiate them
  41487. */
  41488. static get RegisteredExternalClasses(): {
  41489. [key: string]: Object;
  41490. };
  41491. static set RegisteredExternalClasses(classes: {
  41492. [key: string]: Object;
  41493. });
  41494. /**
  41495. * Texture content used if a texture cannot loaded
  41496. * @ignorenaming
  41497. */
  41498. static get fallbackTexture(): string;
  41499. static set fallbackTexture(value: string);
  41500. /**
  41501. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  41502. * @param u defines the coordinate on X axis
  41503. * @param v defines the coordinate on Y axis
  41504. * @param width defines the width of the source data
  41505. * @param height defines the height of the source data
  41506. * @param pixels defines the source byte array
  41507. * @param color defines the output color
  41508. */
  41509. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  41510. /**
  41511. * Interpolates between a and b via alpha
  41512. * @param a The lower value (returned when alpha = 0)
  41513. * @param b The upper value (returned when alpha = 1)
  41514. * @param alpha The interpolation-factor
  41515. * @return The mixed value
  41516. */
  41517. static Mix(a: number, b: number, alpha: number): number;
  41518. /**
  41519. * Tries to instantiate a new object from a given class name
  41520. * @param className defines the class name to instantiate
  41521. * @returns the new object or null if the system was not able to do the instantiation
  41522. */
  41523. static Instantiate(className: string): any;
  41524. /**
  41525. * Provides a slice function that will work even on IE
  41526. * @param data defines the array to slice
  41527. * @param start defines the start of the data (optional)
  41528. * @param end defines the end of the data (optional)
  41529. * @returns the new sliced array
  41530. */
  41531. static Slice<T>(data: T, start?: number, end?: number): T;
  41532. /**
  41533. * Provides a slice function that will work even on IE
  41534. * The difference between this and Slice is that this will force-convert to array
  41535. * @param data defines the array to slice
  41536. * @param start defines the start of the data (optional)
  41537. * @param end defines the end of the data (optional)
  41538. * @returns the new sliced array
  41539. */
  41540. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  41541. /**
  41542. * Polyfill for setImmediate
  41543. * @param action defines the action to execute after the current execution block
  41544. */
  41545. static SetImmediate(action: () => void): void;
  41546. /**
  41547. * Function indicating if a number is an exponent of 2
  41548. * @param value defines the value to test
  41549. * @returns true if the value is an exponent of 2
  41550. */
  41551. static IsExponentOfTwo(value: number): boolean;
  41552. private static _tmpFloatArray;
  41553. /**
  41554. * Returns the nearest 32-bit single precision float representation of a Number
  41555. * @param value A Number. If the parameter is of a different type, it will get converted
  41556. * to a number or to NaN if it cannot be converted
  41557. * @returns number
  41558. */
  41559. static FloatRound(value: number): number;
  41560. /**
  41561. * Extracts the filename from a path
  41562. * @param path defines the path to use
  41563. * @returns the filename
  41564. */
  41565. static GetFilename(path: string): string;
  41566. /**
  41567. * Extracts the "folder" part of a path (everything before the filename).
  41568. * @param uri The URI to extract the info from
  41569. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  41570. * @returns The "folder" part of the path
  41571. */
  41572. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  41573. /**
  41574. * Extracts text content from a DOM element hierarchy
  41575. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  41576. */
  41577. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  41578. /**
  41579. * Convert an angle in radians to degrees
  41580. * @param angle defines the angle to convert
  41581. * @returns the angle in degrees
  41582. */
  41583. static ToDegrees(angle: number): number;
  41584. /**
  41585. * Convert an angle in degrees to radians
  41586. * @param angle defines the angle to convert
  41587. * @returns the angle in radians
  41588. */
  41589. static ToRadians(angle: number): number;
  41590. /**
  41591. * Returns an array if obj is not an array
  41592. * @param obj defines the object to evaluate as an array
  41593. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  41594. * @returns either obj directly if obj is an array or a new array containing obj
  41595. */
  41596. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  41597. /**
  41598. * Gets the pointer prefix to use
  41599. * @param engine defines the engine we are finding the prefix for
  41600. * @returns "pointer" if touch is enabled. Else returns "mouse"
  41601. */
  41602. static GetPointerPrefix(engine: Engine): string;
  41603. /**
  41604. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  41605. * @param url define the url we are trying
  41606. * @param element define the dom element where to configure the cors policy
  41607. */
  41608. static SetCorsBehavior(url: string | string[], element: {
  41609. crossOrigin: string | null;
  41610. }): void;
  41611. /**
  41612. * Removes unwanted characters from an url
  41613. * @param url defines the url to clean
  41614. * @returns the cleaned url
  41615. */
  41616. static CleanUrl(url: string): string;
  41617. /**
  41618. * Gets or sets a function used to pre-process url before using them to load assets
  41619. */
  41620. static get PreprocessUrl(): (url: string) => string;
  41621. static set PreprocessUrl(processor: (url: string) => string);
  41622. /**
  41623. * Loads an image as an HTMLImageElement.
  41624. * @param input url string, ArrayBuffer, or Blob to load
  41625. * @param onLoad callback called when the image successfully loads
  41626. * @param onError callback called when the image fails to load
  41627. * @param offlineProvider offline provider for caching
  41628. * @param mimeType optional mime type
  41629. * @returns the HTMLImageElement of the loaded image
  41630. */
  41631. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  41632. /**
  41633. * Loads a file from a url
  41634. * @param url url string, ArrayBuffer, or Blob to load
  41635. * @param onSuccess callback called when the file successfully loads
  41636. * @param onProgress callback called while file is loading (if the server supports this mode)
  41637. * @param offlineProvider defines the offline provider for caching
  41638. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41639. * @param onError callback called when the file fails to load
  41640. * @returns a file request object
  41641. */
  41642. 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;
  41643. /**
  41644. * Loads a file from a url
  41645. * @param url the file url to load
  41646. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41647. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  41648. */
  41649. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  41650. /**
  41651. * Load a script (identified by an url). When the url returns, the
  41652. * content of this file is added into a new script element, attached to the DOM (body element)
  41653. * @param scriptUrl defines the url of the script to laod
  41654. * @param onSuccess defines the callback called when the script is loaded
  41655. * @param onError defines the callback to call if an error occurs
  41656. * @param scriptId defines the id of the script element
  41657. */
  41658. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  41659. /**
  41660. * Load an asynchronous script (identified by an url). When the url returns, the
  41661. * content of this file is added into a new script element, attached to the DOM (body element)
  41662. * @param scriptUrl defines the url of the script to laod
  41663. * @param scriptId defines the id of the script element
  41664. * @returns a promise request object
  41665. */
  41666. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  41667. /**
  41668. * Loads a file from a blob
  41669. * @param fileToLoad defines the blob to use
  41670. * @param callback defines the callback to call when data is loaded
  41671. * @param progressCallback defines the callback to call during loading process
  41672. * @returns a file request object
  41673. */
  41674. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  41675. /**
  41676. * Reads a file from a File object
  41677. * @param file defines the file to load
  41678. * @param onSuccess defines the callback to call when data is loaded
  41679. * @param onProgress defines the callback to call during loading process
  41680. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  41681. * @param onError defines the callback to call when an error occurs
  41682. * @returns a file request object
  41683. */
  41684. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41685. /**
  41686. * Creates a data url from a given string content
  41687. * @param content defines the content to convert
  41688. * @returns the new data url link
  41689. */
  41690. static FileAsURL(content: string): string;
  41691. /**
  41692. * Format the given number to a specific decimal format
  41693. * @param value defines the number to format
  41694. * @param decimals defines the number of decimals to use
  41695. * @returns the formatted string
  41696. */
  41697. static Format(value: number, decimals?: number): string;
  41698. /**
  41699. * Tries to copy an object by duplicating every property
  41700. * @param source defines the source object
  41701. * @param destination defines the target object
  41702. * @param doNotCopyList defines a list of properties to avoid
  41703. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  41704. */
  41705. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  41706. /**
  41707. * Gets a boolean indicating if the given object has no own property
  41708. * @param obj defines the object to test
  41709. * @returns true if object has no own property
  41710. */
  41711. static IsEmpty(obj: any): boolean;
  41712. /**
  41713. * Function used to register events at window level
  41714. * @param windowElement defines the Window object to use
  41715. * @param events defines the events to register
  41716. */
  41717. static RegisterTopRootEvents(windowElement: Window, events: {
  41718. name: string;
  41719. handler: Nullable<(e: FocusEvent) => any>;
  41720. }[]): void;
  41721. /**
  41722. * Function used to unregister events from window level
  41723. * @param windowElement defines the Window object to use
  41724. * @param events defines the events to unregister
  41725. */
  41726. static UnregisterTopRootEvents(windowElement: Window, events: {
  41727. name: string;
  41728. handler: Nullable<(e: FocusEvent) => any>;
  41729. }[]): void;
  41730. /**
  41731. * @ignore
  41732. */
  41733. static _ScreenshotCanvas: HTMLCanvasElement;
  41734. /**
  41735. * Dumps the current bound framebuffer
  41736. * @param width defines the rendering width
  41737. * @param height defines the rendering height
  41738. * @param engine defines the hosting engine
  41739. * @param successCallback defines the callback triggered once the data are available
  41740. * @param mimeType defines the mime type of the result
  41741. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  41742. */
  41743. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  41744. /**
  41745. * Converts the canvas data to blob.
  41746. * This acts as a polyfill for browsers not supporting the to blob function.
  41747. * @param canvas Defines the canvas to extract the data from
  41748. * @param successCallback Defines the callback triggered once the data are available
  41749. * @param mimeType Defines the mime type of the result
  41750. */
  41751. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  41752. /**
  41753. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  41754. * @param successCallback defines the callback triggered once the data are available
  41755. * @param mimeType defines the mime type of the result
  41756. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  41757. */
  41758. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  41759. /**
  41760. * Downloads a blob in the browser
  41761. * @param blob defines the blob to download
  41762. * @param fileName defines the name of the downloaded file
  41763. */
  41764. static Download(blob: Blob, fileName: string): void;
  41765. /**
  41766. * Will return the right value of the noPreventDefault variable
  41767. * Needed to keep backwards compatibility to the old API.
  41768. *
  41769. * @param args arguments passed to the attachControl function
  41770. * @returns the correct value for noPreventDefault
  41771. */
  41772. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  41773. /**
  41774. * Captures a screenshot of the current rendering
  41775. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41776. * @param engine defines the rendering engine
  41777. * @param camera defines the source camera
  41778. * @param size This parameter can be set to a single number or to an object with the
  41779. * following (optional) properties: precision, width, height. If a single number is passed,
  41780. * it will be used for both width and height. If an object is passed, the screenshot size
  41781. * will be derived from the parameters. The precision property is a multiplier allowing
  41782. * rendering at a higher or lower resolution
  41783. * @param successCallback defines the callback receives a single parameter which contains the
  41784. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  41785. * src parameter of an <img> to display it
  41786. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  41787. * Check your browser for supported MIME types
  41788. */
  41789. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  41790. /**
  41791. * Captures a screenshot of the current rendering
  41792. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41793. * @param engine defines the rendering engine
  41794. * @param camera defines the source camera
  41795. * @param size This parameter can be set to a single number or to an object with the
  41796. * following (optional) properties: precision, width, height. If a single number is passed,
  41797. * it will be used for both width and height. If an object is passed, the screenshot size
  41798. * will be derived from the parameters. The precision property is a multiplier allowing
  41799. * rendering at a higher or lower resolution
  41800. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  41801. * Check your browser for supported MIME types
  41802. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  41803. * to the src parameter of an <img> to display it
  41804. */
  41805. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  41806. /**
  41807. * Generates an image screenshot from the specified camera.
  41808. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41809. * @param engine The engine to use for rendering
  41810. * @param camera The camera to use for rendering
  41811. * @param size This parameter can be set to a single number or to an object with the
  41812. * following (optional) properties: precision, width, height. If a single number is passed,
  41813. * it will be used for both width and height. If an object is passed, the screenshot size
  41814. * will be derived from the parameters. The precision property is a multiplier allowing
  41815. * rendering at a higher or lower resolution
  41816. * @param successCallback The callback receives a single parameter which contains the
  41817. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  41818. * src parameter of an <img> to display it
  41819. * @param mimeType The MIME type of the screenshot image (default: image/png).
  41820. * Check your browser for supported MIME types
  41821. * @param samples Texture samples (default: 1)
  41822. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  41823. * @param fileName A name for for the downloaded file.
  41824. */
  41825. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  41826. /**
  41827. * Generates an image screenshot from the specified camera.
  41828. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41829. * @param engine The engine to use for rendering
  41830. * @param camera The camera to use for rendering
  41831. * @param size This parameter can be set to a single number or to an object with the
  41832. * following (optional) properties: precision, width, height. If a single number is passed,
  41833. * it will be used for both width and height. If an object is passed, the screenshot size
  41834. * will be derived from the parameters. The precision property is a multiplier allowing
  41835. * rendering at a higher or lower resolution
  41836. * @param mimeType The MIME type of the screenshot image (default: image/png).
  41837. * Check your browser for supported MIME types
  41838. * @param samples Texture samples (default: 1)
  41839. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  41840. * @param fileName A name for for the downloaded file.
  41841. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  41842. * to the src parameter of an <img> to display it
  41843. */
  41844. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  41845. /**
  41846. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  41847. * Be aware Math.random() could cause collisions, but:
  41848. * "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"
  41849. * @returns a pseudo random id
  41850. */
  41851. static RandomId(): string;
  41852. /**
  41853. * Test if the given uri is a base64 string
  41854. * @param uri The uri to test
  41855. * @return True if the uri is a base64 string or false otherwise
  41856. */
  41857. static IsBase64(uri: string): boolean;
  41858. /**
  41859. * Decode the given base64 uri.
  41860. * @param uri The uri to decode
  41861. * @return The decoded base64 data.
  41862. */
  41863. static DecodeBase64(uri: string): ArrayBuffer;
  41864. /**
  41865. * Gets the absolute url.
  41866. * @param url the input url
  41867. * @return the absolute url
  41868. */
  41869. static GetAbsoluteUrl(url: string): string;
  41870. /**
  41871. * No log
  41872. */
  41873. static readonly NoneLogLevel: number;
  41874. /**
  41875. * Only message logs
  41876. */
  41877. static readonly MessageLogLevel: number;
  41878. /**
  41879. * Only warning logs
  41880. */
  41881. static readonly WarningLogLevel: number;
  41882. /**
  41883. * Only error logs
  41884. */
  41885. static readonly ErrorLogLevel: number;
  41886. /**
  41887. * All logs
  41888. */
  41889. static readonly AllLogLevel: number;
  41890. /**
  41891. * Gets a value indicating the number of loading errors
  41892. * @ignorenaming
  41893. */
  41894. static get errorsCount(): number;
  41895. /**
  41896. * Callback called when a new log is added
  41897. */
  41898. static OnNewCacheEntry: (entry: string) => void;
  41899. /**
  41900. * Log a message to the console
  41901. * @param message defines the message to log
  41902. */
  41903. static Log(message: string): void;
  41904. /**
  41905. * Write a warning message to the console
  41906. * @param message defines the message to log
  41907. */
  41908. static Warn(message: string): void;
  41909. /**
  41910. * Write an error message to the console
  41911. * @param message defines the message to log
  41912. */
  41913. static Error(message: string): void;
  41914. /**
  41915. * Gets current log cache (list of logs)
  41916. */
  41917. static get LogCache(): string;
  41918. /**
  41919. * Clears the log cache
  41920. */
  41921. static ClearLogCache(): void;
  41922. /**
  41923. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  41924. */
  41925. static set LogLevels(level: number);
  41926. /**
  41927. * Checks if the window object exists
  41928. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  41929. */
  41930. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  41931. /**
  41932. * No performance log
  41933. */
  41934. static readonly PerformanceNoneLogLevel: number;
  41935. /**
  41936. * Use user marks to log performance
  41937. */
  41938. static readonly PerformanceUserMarkLogLevel: number;
  41939. /**
  41940. * Log performance to the console
  41941. */
  41942. static readonly PerformanceConsoleLogLevel: number;
  41943. private static _performance;
  41944. /**
  41945. * Sets the current performance log level
  41946. */
  41947. static set PerformanceLogLevel(level: number);
  41948. private static _StartPerformanceCounterDisabled;
  41949. private static _EndPerformanceCounterDisabled;
  41950. private static _StartUserMark;
  41951. private static _EndUserMark;
  41952. private static _StartPerformanceConsole;
  41953. private static _EndPerformanceConsole;
  41954. /**
  41955. * Starts a performance counter
  41956. */
  41957. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  41958. /**
  41959. * Ends a specific performance coutner
  41960. */
  41961. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  41962. /**
  41963. * Gets either window.performance.now() if supported or Date.now() else
  41964. */
  41965. static get Now(): number;
  41966. /**
  41967. * This method will return the name of the class used to create the instance of the given object.
  41968. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  41969. * @param object the object to get the class name from
  41970. * @param isType defines if the object is actually a type
  41971. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  41972. */
  41973. static GetClassName(object: any, isType?: boolean): string;
  41974. /**
  41975. * Gets the first element of an array satisfying a given predicate
  41976. * @param array defines the array to browse
  41977. * @param predicate defines the predicate to use
  41978. * @returns null if not found or the element
  41979. */
  41980. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  41981. /**
  41982. * This method will return the name of the full name of the class, including its owning module (if any).
  41983. * 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).
  41984. * @param object the object to get the class name from
  41985. * @param isType defines if the object is actually a type
  41986. * @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.
  41987. * @ignorenaming
  41988. */
  41989. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  41990. /**
  41991. * Returns a promise that resolves after the given amount of time.
  41992. * @param delay Number of milliseconds to delay
  41993. * @returns Promise that resolves after the given amount of time
  41994. */
  41995. static DelayAsync(delay: number): Promise<void>;
  41996. /**
  41997. * Utility function to detect if the current user agent is Safari
  41998. * @returns whether or not the current user agent is safari
  41999. */
  42000. static IsSafari(): boolean;
  42001. }
  42002. /**
  42003. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  42004. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  42005. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  42006. * @param name The name of the class, case should be preserved
  42007. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  42008. */
  42009. export function className(name: string, module?: string): (target: Object) => void;
  42010. /**
  42011. * An implementation of a loop for asynchronous functions.
  42012. */
  42013. export class AsyncLoop {
  42014. /**
  42015. * Defines the number of iterations for the loop
  42016. */
  42017. iterations: number;
  42018. /**
  42019. * Defines the current index of the loop.
  42020. */
  42021. index: number;
  42022. private _done;
  42023. private _fn;
  42024. private _successCallback;
  42025. /**
  42026. * Constructor.
  42027. * @param iterations the number of iterations.
  42028. * @param func the function to run each iteration
  42029. * @param successCallback the callback that will be called upon succesful execution
  42030. * @param offset starting offset.
  42031. */
  42032. constructor(
  42033. /**
  42034. * Defines the number of iterations for the loop
  42035. */
  42036. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  42037. /**
  42038. * Execute the next iteration. Must be called after the last iteration was finished.
  42039. */
  42040. executeNext(): void;
  42041. /**
  42042. * Break the loop and run the success callback.
  42043. */
  42044. breakLoop(): void;
  42045. /**
  42046. * Create and run an async loop.
  42047. * @param iterations the number of iterations.
  42048. * @param fn the function to run each iteration
  42049. * @param successCallback the callback that will be called upon succesful execution
  42050. * @param offset starting offset.
  42051. * @returns the created async loop object
  42052. */
  42053. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  42054. /**
  42055. * A for-loop that will run a given number of iterations synchronous and the rest async.
  42056. * @param iterations total number of iterations
  42057. * @param syncedIterations number of synchronous iterations in each async iteration.
  42058. * @param fn the function to call each iteration.
  42059. * @param callback a success call back that will be called when iterating stops.
  42060. * @param breakFunction a break condition (optional)
  42061. * @param timeout timeout settings for the setTimeout function. default - 0.
  42062. * @returns the created async loop object
  42063. */
  42064. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  42065. }
  42066. }
  42067. declare module BABYLON {
  42068. /**
  42069. * This class implement a typical dictionary using a string as key and the generic type T as value.
  42070. * The underlying implementation relies on an associative array to ensure the best performances.
  42071. * The value can be anything including 'null' but except 'undefined'
  42072. */
  42073. export class StringDictionary<T> {
  42074. /**
  42075. * This will clear this dictionary and copy the content from the 'source' one.
  42076. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  42077. * @param source the dictionary to take the content from and copy to this dictionary
  42078. */
  42079. copyFrom(source: StringDictionary<T>): void;
  42080. /**
  42081. * Get a value based from its key
  42082. * @param key the given key to get the matching value from
  42083. * @return the value if found, otherwise undefined is returned
  42084. */
  42085. get(key: string): T | undefined;
  42086. /**
  42087. * Get a value from its key or add it if it doesn't exist.
  42088. * This method will ensure you that a given key/data will be present in the dictionary.
  42089. * @param key the given key to get the matching value from
  42090. * @param factory the factory that will create the value if the key is not present in the dictionary.
  42091. * The factory will only be invoked if there's no data for the given key.
  42092. * @return the value corresponding to the key.
  42093. */
  42094. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  42095. /**
  42096. * Get a value from its key if present in the dictionary otherwise add it
  42097. * @param key the key to get the value from
  42098. * @param val if there's no such key/value pair in the dictionary add it with this value
  42099. * @return the value corresponding to the key
  42100. */
  42101. getOrAdd(key: string, val: T): T;
  42102. /**
  42103. * Check if there's a given key in the dictionary
  42104. * @param key the key to check for
  42105. * @return true if the key is present, false otherwise
  42106. */
  42107. contains(key: string): boolean;
  42108. /**
  42109. * Add a new key and its corresponding value
  42110. * @param key the key to add
  42111. * @param value the value corresponding to the key
  42112. * @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
  42113. */
  42114. add(key: string, value: T): boolean;
  42115. /**
  42116. * Update a specific value associated to a key
  42117. * @param key defines the key to use
  42118. * @param value defines the value to store
  42119. * @returns true if the value was updated (or false if the key was not found)
  42120. */
  42121. set(key: string, value: T): boolean;
  42122. /**
  42123. * Get the element of the given key and remove it from the dictionary
  42124. * @param key defines the key to search
  42125. * @returns the value associated with the key or null if not found
  42126. */
  42127. getAndRemove(key: string): Nullable<T>;
  42128. /**
  42129. * Remove a key/value from the dictionary.
  42130. * @param key the key to remove
  42131. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  42132. */
  42133. remove(key: string): boolean;
  42134. /**
  42135. * Clear the whole content of the dictionary
  42136. */
  42137. clear(): void;
  42138. /**
  42139. * Gets the current count
  42140. */
  42141. get count(): number;
  42142. /**
  42143. * Execute a callback on each key/val of the dictionary.
  42144. * Note that you can remove any element in this dictionary in the callback implementation
  42145. * @param callback the callback to execute on a given key/value pair
  42146. */
  42147. forEach(callback: (key: string, val: T) => void): void;
  42148. /**
  42149. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  42150. * If the callback returns null or undefined the method will iterate to the next key/value pair
  42151. * Note that you can remove any element in this dictionary in the callback implementation
  42152. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  42153. * @returns the first item
  42154. */
  42155. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  42156. private _count;
  42157. private _data;
  42158. }
  42159. }
  42160. declare module BABYLON {
  42161. /** @hidden */
  42162. export interface ICollisionCoordinator {
  42163. createCollider(): Collider;
  42164. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  42165. init(scene: Scene): void;
  42166. }
  42167. /** @hidden */
  42168. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  42169. private _scene;
  42170. private _scaledPosition;
  42171. private _scaledVelocity;
  42172. private _finalPosition;
  42173. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  42174. createCollider(): Collider;
  42175. init(scene: Scene): void;
  42176. private _collideWithWorld;
  42177. }
  42178. }
  42179. declare module BABYLON {
  42180. /**
  42181. * Class used to manage all inputs for the scene.
  42182. */
  42183. export class InputManager {
  42184. /** The distance in pixel that you have to move to prevent some events */
  42185. static DragMovementThreshold: number;
  42186. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  42187. static LongPressDelay: number;
  42188. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  42189. static DoubleClickDelay: number;
  42190. /** If you need to check double click without raising a single click at first click, enable this flag */
  42191. static ExclusiveDoubleClickMode: boolean;
  42192. /** 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. */
  42193. private _alreadyAttached;
  42194. private _alreadyAttachedTo;
  42195. private _wheelEventName;
  42196. private _onPointerMove;
  42197. private _onPointerDown;
  42198. private _onPointerUp;
  42199. private _initClickEvent;
  42200. private _initActionManager;
  42201. private _delayedSimpleClick;
  42202. private _delayedSimpleClickTimeout;
  42203. private _previousDelayedSimpleClickTimeout;
  42204. private _meshPickProceed;
  42205. private _previousButtonPressed;
  42206. private _currentPickResult;
  42207. private _previousPickResult;
  42208. private _totalPointersPressed;
  42209. private _doubleClickOccured;
  42210. private _pointerOverMesh;
  42211. private _pickedDownMesh;
  42212. private _pickedUpMesh;
  42213. private _pointerX;
  42214. private _pointerY;
  42215. private _unTranslatedPointerX;
  42216. private _unTranslatedPointerY;
  42217. private _startingPointerPosition;
  42218. private _previousStartingPointerPosition;
  42219. private _startingPointerTime;
  42220. private _previousStartingPointerTime;
  42221. private _pointerCaptures;
  42222. private _meshUnderPointerId;
  42223. private _onKeyDown;
  42224. private _onKeyUp;
  42225. private _keyboardIsAttached;
  42226. private _onCanvasFocusObserver;
  42227. private _onCanvasBlurObserver;
  42228. private _scene;
  42229. /**
  42230. * Creates a new InputManager
  42231. * @param scene defines the hosting scene
  42232. */
  42233. constructor(scene: Scene);
  42234. /**
  42235. * Gets the mesh that is currently under the pointer
  42236. */
  42237. get meshUnderPointer(): Nullable<AbstractMesh>;
  42238. /**
  42239. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  42240. * @param pointerId the pointer id to use
  42241. * @returns The mesh under this pointer id or null if not found
  42242. */
  42243. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  42244. /**
  42245. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  42246. */
  42247. get unTranslatedPointer(): Vector2;
  42248. /**
  42249. * Gets or sets the current on-screen X position of the pointer
  42250. */
  42251. get pointerX(): number;
  42252. set pointerX(value: number);
  42253. /**
  42254. * Gets or sets the current on-screen Y position of the pointer
  42255. */
  42256. get pointerY(): number;
  42257. set pointerY(value: number);
  42258. private _updatePointerPosition;
  42259. private _processPointerMove;
  42260. private _setRayOnPointerInfo;
  42261. private _checkPrePointerObservable;
  42262. /**
  42263. * Use this method to simulate a pointer move on a mesh
  42264. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42265. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42266. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42267. */
  42268. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  42269. /**
  42270. * Use this method to simulate a pointer down on a mesh
  42271. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42272. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42273. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42274. */
  42275. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  42276. private _processPointerDown;
  42277. /** @hidden */
  42278. _isPointerSwiping(): boolean;
  42279. /**
  42280. * Use this method to simulate a pointer up on a mesh
  42281. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42282. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42283. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42284. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  42285. */
  42286. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  42287. private _processPointerUp;
  42288. /**
  42289. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  42290. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  42291. * @returns true if the pointer was captured
  42292. */
  42293. isPointerCaptured(pointerId?: number): boolean;
  42294. /**
  42295. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  42296. * @param attachUp defines if you want to attach events to pointerup
  42297. * @param attachDown defines if you want to attach events to pointerdown
  42298. * @param attachMove defines if you want to attach events to pointermove
  42299. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  42300. */
  42301. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  42302. /**
  42303. * Detaches all event handlers
  42304. */
  42305. detachControl(): void;
  42306. /**
  42307. * Force the value of meshUnderPointer
  42308. * @param mesh defines the mesh to use
  42309. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  42310. */
  42311. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  42312. /**
  42313. * Gets the mesh under the pointer
  42314. * @returns a Mesh or null if no mesh is under the pointer
  42315. */
  42316. getPointerOverMesh(): Nullable<AbstractMesh>;
  42317. }
  42318. }
  42319. declare module BABYLON {
  42320. /**
  42321. * This class defines the direct association between an animation and a target
  42322. */
  42323. export class TargetedAnimation {
  42324. /**
  42325. * Animation to perform
  42326. */
  42327. animation: Animation;
  42328. /**
  42329. * Target to animate
  42330. */
  42331. target: any;
  42332. /**
  42333. * Returns the string "TargetedAnimation"
  42334. * @returns "TargetedAnimation"
  42335. */
  42336. getClassName(): string;
  42337. /**
  42338. * Serialize the object
  42339. * @returns the JSON object representing the current entity
  42340. */
  42341. serialize(): any;
  42342. }
  42343. /**
  42344. * Use this class to create coordinated animations on multiple targets
  42345. */
  42346. export class AnimationGroup implements IDisposable {
  42347. /** The name of the animation group */
  42348. name: string;
  42349. private _scene;
  42350. private _targetedAnimations;
  42351. private _animatables;
  42352. private _from;
  42353. private _to;
  42354. private _isStarted;
  42355. private _isPaused;
  42356. private _speedRatio;
  42357. private _loopAnimation;
  42358. private _isAdditive;
  42359. /**
  42360. * Gets or sets the unique id of the node
  42361. */
  42362. uniqueId: number;
  42363. /**
  42364. * This observable will notify when one animation have ended
  42365. */
  42366. onAnimationEndObservable: Observable<TargetedAnimation>;
  42367. /**
  42368. * Observer raised when one animation loops
  42369. */
  42370. onAnimationLoopObservable: Observable<TargetedAnimation>;
  42371. /**
  42372. * Observer raised when all animations have looped
  42373. */
  42374. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  42375. /**
  42376. * This observable will notify when all animations have ended.
  42377. */
  42378. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  42379. /**
  42380. * This observable will notify when all animations have paused.
  42381. */
  42382. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  42383. /**
  42384. * This observable will notify when all animations are playing.
  42385. */
  42386. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  42387. /**
  42388. * Gets the first frame
  42389. */
  42390. get from(): number;
  42391. /**
  42392. * Gets the last frame
  42393. */
  42394. get to(): number;
  42395. /**
  42396. * Define if the animations are started
  42397. */
  42398. get isStarted(): boolean;
  42399. /**
  42400. * Gets a value indicating that the current group is playing
  42401. */
  42402. get isPlaying(): boolean;
  42403. /**
  42404. * Gets or sets the speed ratio to use for all animations
  42405. */
  42406. get speedRatio(): number;
  42407. /**
  42408. * Gets or sets the speed ratio to use for all animations
  42409. */
  42410. set speedRatio(value: number);
  42411. /**
  42412. * Gets or sets if all animations should loop or not
  42413. */
  42414. get loopAnimation(): boolean;
  42415. set loopAnimation(value: boolean);
  42416. /**
  42417. * Gets or sets if all animations should be evaluated additively
  42418. */
  42419. get isAdditive(): boolean;
  42420. set isAdditive(value: boolean);
  42421. /**
  42422. * Gets the targeted animations for this animation group
  42423. */
  42424. get targetedAnimations(): Array<TargetedAnimation>;
  42425. /**
  42426. * returning the list of animatables controlled by this animation group.
  42427. */
  42428. get animatables(): Array<Animatable>;
  42429. /**
  42430. * Gets the list of target animations
  42431. */
  42432. get children(): TargetedAnimation[];
  42433. /**
  42434. * Instantiates a new Animation Group.
  42435. * This helps managing several animations at once.
  42436. * @see https://doc.babylonjs.com/how_to/group
  42437. * @param name Defines the name of the group
  42438. * @param scene Defines the scene the group belongs to
  42439. */
  42440. constructor(
  42441. /** The name of the animation group */
  42442. name: string, scene?: Nullable<Scene>);
  42443. /**
  42444. * Add an animation (with its target) in the group
  42445. * @param animation defines the animation we want to add
  42446. * @param target defines the target of the animation
  42447. * @returns the TargetedAnimation object
  42448. */
  42449. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  42450. /**
  42451. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  42452. * It can add constant keys at begin or end
  42453. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  42454. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  42455. * @returns the animation group
  42456. */
  42457. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  42458. private _animationLoopCount;
  42459. private _animationLoopFlags;
  42460. private _processLoop;
  42461. /**
  42462. * Start all animations on given targets
  42463. * @param loop defines if animations must loop
  42464. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  42465. * @param from defines the from key (optional)
  42466. * @param to defines the to key (optional)
  42467. * @param isAdditive defines the additive state for the resulting animatables (optional)
  42468. * @returns the current animation group
  42469. */
  42470. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  42471. /**
  42472. * Pause all animations
  42473. * @returns the animation group
  42474. */
  42475. pause(): AnimationGroup;
  42476. /**
  42477. * Play all animations to initial state
  42478. * This function will start() the animations if they were not started or will restart() them if they were paused
  42479. * @param loop defines if animations must loop
  42480. * @returns the animation group
  42481. */
  42482. play(loop?: boolean): AnimationGroup;
  42483. /**
  42484. * Reset all animations to initial state
  42485. * @returns the animation group
  42486. */
  42487. reset(): AnimationGroup;
  42488. /**
  42489. * Restart animations from key 0
  42490. * @returns the animation group
  42491. */
  42492. restart(): AnimationGroup;
  42493. /**
  42494. * Stop all animations
  42495. * @returns the animation group
  42496. */
  42497. stop(): AnimationGroup;
  42498. /**
  42499. * Set animation weight for all animatables
  42500. * @param weight defines the weight to use
  42501. * @return the animationGroup
  42502. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  42503. */
  42504. setWeightForAllAnimatables(weight: number): AnimationGroup;
  42505. /**
  42506. * Synchronize and normalize all animatables with a source animatable
  42507. * @param root defines the root animatable to synchronize with
  42508. * @return the animationGroup
  42509. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  42510. */
  42511. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  42512. /**
  42513. * Goes to a specific frame in this animation group
  42514. * @param frame the frame number to go to
  42515. * @return the animationGroup
  42516. */
  42517. goToFrame(frame: number): AnimationGroup;
  42518. /**
  42519. * Dispose all associated resources
  42520. */
  42521. dispose(): void;
  42522. private _checkAnimationGroupEnded;
  42523. /**
  42524. * Clone the current animation group and returns a copy
  42525. * @param newName defines the name of the new group
  42526. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  42527. * @returns the new aniamtion group
  42528. */
  42529. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  42530. /**
  42531. * Serializes the animationGroup to an object
  42532. * @returns Serialized object
  42533. */
  42534. serialize(): any;
  42535. /**
  42536. * Returns a new AnimationGroup object parsed from the source provided.
  42537. * @param parsedAnimationGroup defines the source
  42538. * @param scene defines the scene that will receive the animationGroup
  42539. * @returns a new AnimationGroup
  42540. */
  42541. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  42542. /**
  42543. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  42544. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  42545. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  42546. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  42547. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  42548. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  42549. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  42550. */
  42551. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  42552. /**
  42553. * Returns the string "AnimationGroup"
  42554. * @returns "AnimationGroup"
  42555. */
  42556. getClassName(): string;
  42557. /**
  42558. * Creates a detailled string about the object
  42559. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  42560. * @returns a string representing the object
  42561. */
  42562. toString(fullDetails?: boolean): string;
  42563. }
  42564. }
  42565. declare module BABYLON {
  42566. /**
  42567. * Define an interface for all classes that will hold resources
  42568. */
  42569. export interface IDisposable {
  42570. /**
  42571. * Releases all held resources
  42572. */
  42573. dispose(): void;
  42574. }
  42575. /** Interface defining initialization parameters for Scene class */
  42576. export interface SceneOptions {
  42577. /**
  42578. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  42579. * It will improve performance when the number of geometries becomes important.
  42580. */
  42581. useGeometryUniqueIdsMap?: boolean;
  42582. /**
  42583. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  42584. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  42585. */
  42586. useMaterialMeshMap?: boolean;
  42587. /**
  42588. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  42589. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  42590. */
  42591. useClonedMeshMap?: boolean;
  42592. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  42593. virtual?: boolean;
  42594. }
  42595. /**
  42596. * Represents a scene to be rendered by the engine.
  42597. * @see https://doc.babylonjs.com/features/scene
  42598. */
  42599. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  42600. /** The fog is deactivated */
  42601. static readonly FOGMODE_NONE: number;
  42602. /** The fog density is following an exponential function */
  42603. static readonly FOGMODE_EXP: number;
  42604. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  42605. static readonly FOGMODE_EXP2: number;
  42606. /** The fog density is following a linear function. */
  42607. static readonly FOGMODE_LINEAR: number;
  42608. /**
  42609. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  42610. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42611. */
  42612. static MinDeltaTime: number;
  42613. /**
  42614. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  42615. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42616. */
  42617. static MaxDeltaTime: number;
  42618. /**
  42619. * Factory used to create the default material.
  42620. * @param name The name of the material to create
  42621. * @param scene The scene to create the material for
  42622. * @returns The default material
  42623. */
  42624. static DefaultMaterialFactory(scene: Scene): Material;
  42625. /**
  42626. * Factory used to create the a collision coordinator.
  42627. * @returns The collision coordinator
  42628. */
  42629. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  42630. /** @hidden */
  42631. _inputManager: InputManager;
  42632. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  42633. cameraToUseForPointers: Nullable<Camera>;
  42634. /** @hidden */
  42635. readonly _isScene: boolean;
  42636. /** @hidden */
  42637. _blockEntityCollection: boolean;
  42638. /**
  42639. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  42640. */
  42641. autoClear: boolean;
  42642. /**
  42643. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  42644. */
  42645. autoClearDepthAndStencil: boolean;
  42646. /**
  42647. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  42648. */
  42649. clearColor: Color4;
  42650. /**
  42651. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  42652. */
  42653. ambientColor: Color3;
  42654. /**
  42655. * This is use to store the default BRDF lookup for PBR materials in your scene.
  42656. * It should only be one of the following (if not the default embedded one):
  42657. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  42658. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  42659. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  42660. * The material properties need to be setup according to the type of texture in use.
  42661. */
  42662. environmentBRDFTexture: BaseTexture;
  42663. /**
  42664. * Texture used in all pbr material as the reflection texture.
  42665. * As in the majority of the scene they are the same (exception for multi room and so on),
  42666. * this is easier to reference from here than from all the materials.
  42667. */
  42668. get environmentTexture(): Nullable<BaseTexture>;
  42669. /**
  42670. * Texture used in all pbr material as the reflection texture.
  42671. * As in the majority of the scene they are the same (exception for multi room and so on),
  42672. * this is easier to set here than in all the materials.
  42673. */
  42674. set environmentTexture(value: Nullable<BaseTexture>);
  42675. /** @hidden */
  42676. protected _environmentIntensity: number;
  42677. /**
  42678. * Intensity of the environment in all pbr material.
  42679. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  42680. * As in the majority of the scene they are the same (exception for multi room and so on),
  42681. * this is easier to reference from here than from all the materials.
  42682. */
  42683. get environmentIntensity(): number;
  42684. /**
  42685. * Intensity of the environment in all pbr material.
  42686. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  42687. * As in the majority of the scene they are the same (exception for multi room and so on),
  42688. * this is easier to set here than in all the materials.
  42689. */
  42690. set environmentIntensity(value: number);
  42691. /** @hidden */
  42692. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42693. /**
  42694. * Default image processing configuration used either in the rendering
  42695. * Forward main pass or through the imageProcessingPostProcess if present.
  42696. * As in the majority of the scene they are the same (exception for multi camera),
  42697. * this is easier to reference from here than from all the materials and post process.
  42698. *
  42699. * No setter as we it is a shared configuration, you can set the values instead.
  42700. */
  42701. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42702. private _forceWireframe;
  42703. /**
  42704. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  42705. */
  42706. set forceWireframe(value: boolean);
  42707. get forceWireframe(): boolean;
  42708. private _skipFrustumClipping;
  42709. /**
  42710. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  42711. */
  42712. set skipFrustumClipping(value: boolean);
  42713. get skipFrustumClipping(): boolean;
  42714. private _forcePointsCloud;
  42715. /**
  42716. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  42717. */
  42718. set forcePointsCloud(value: boolean);
  42719. get forcePointsCloud(): boolean;
  42720. /**
  42721. * Gets or sets the active clipplane 1
  42722. */
  42723. clipPlane: Nullable<Plane>;
  42724. /**
  42725. * Gets or sets the active clipplane 2
  42726. */
  42727. clipPlane2: Nullable<Plane>;
  42728. /**
  42729. * Gets or sets the active clipplane 3
  42730. */
  42731. clipPlane3: Nullable<Plane>;
  42732. /**
  42733. * Gets or sets the active clipplane 4
  42734. */
  42735. clipPlane4: Nullable<Plane>;
  42736. /**
  42737. * Gets or sets the active clipplane 5
  42738. */
  42739. clipPlane5: Nullable<Plane>;
  42740. /**
  42741. * Gets or sets the active clipplane 6
  42742. */
  42743. clipPlane6: Nullable<Plane>;
  42744. /**
  42745. * Gets or sets a boolean indicating if animations are enabled
  42746. */
  42747. animationsEnabled: boolean;
  42748. private _animationPropertiesOverride;
  42749. /**
  42750. * Gets or sets the animation properties override
  42751. */
  42752. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  42753. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  42754. /**
  42755. * Gets or sets a boolean indicating if a constant deltatime has to be used
  42756. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  42757. */
  42758. useConstantAnimationDeltaTime: boolean;
  42759. /**
  42760. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  42761. * Please note that it requires to run a ray cast through the scene on every frame
  42762. */
  42763. constantlyUpdateMeshUnderPointer: boolean;
  42764. /**
  42765. * Defines the HTML cursor to use when hovering over interactive elements
  42766. */
  42767. hoverCursor: string;
  42768. /**
  42769. * Defines the HTML default cursor to use (empty by default)
  42770. */
  42771. defaultCursor: string;
  42772. /**
  42773. * Defines whether cursors are handled by the scene.
  42774. */
  42775. doNotHandleCursors: boolean;
  42776. /**
  42777. * This is used to call preventDefault() on pointer down
  42778. * in order to block unwanted artifacts like system double clicks
  42779. */
  42780. preventDefaultOnPointerDown: boolean;
  42781. /**
  42782. * This is used to call preventDefault() on pointer up
  42783. * in order to block unwanted artifacts like system double clicks
  42784. */
  42785. preventDefaultOnPointerUp: boolean;
  42786. /**
  42787. * Gets or sets user defined metadata
  42788. */
  42789. metadata: any;
  42790. /**
  42791. * For internal use only. Please do not use.
  42792. */
  42793. reservedDataStore: any;
  42794. /**
  42795. * Gets the name of the plugin used to load this scene (null by default)
  42796. */
  42797. loadingPluginName: string;
  42798. /**
  42799. * Use this array to add regular expressions used to disable offline support for specific urls
  42800. */
  42801. disableOfflineSupportExceptionRules: RegExp[];
  42802. /**
  42803. * An event triggered when the scene is disposed.
  42804. */
  42805. onDisposeObservable: Observable<Scene>;
  42806. private _onDisposeObserver;
  42807. /** Sets a function to be executed when this scene is disposed. */
  42808. set onDispose(callback: () => void);
  42809. /**
  42810. * An event triggered before rendering the scene (right after animations and physics)
  42811. */
  42812. onBeforeRenderObservable: Observable<Scene>;
  42813. private _onBeforeRenderObserver;
  42814. /** Sets a function to be executed before rendering this scene */
  42815. set beforeRender(callback: Nullable<() => void>);
  42816. /**
  42817. * An event triggered after rendering the scene
  42818. */
  42819. onAfterRenderObservable: Observable<Scene>;
  42820. /**
  42821. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  42822. */
  42823. onAfterRenderCameraObservable: Observable<Camera>;
  42824. private _onAfterRenderObserver;
  42825. /** Sets a function to be executed after rendering this scene */
  42826. set afterRender(callback: Nullable<() => void>);
  42827. /**
  42828. * An event triggered before animating the scene
  42829. */
  42830. onBeforeAnimationsObservable: Observable<Scene>;
  42831. /**
  42832. * An event triggered after animations processing
  42833. */
  42834. onAfterAnimationsObservable: Observable<Scene>;
  42835. /**
  42836. * An event triggered before draw calls are ready to be sent
  42837. */
  42838. onBeforeDrawPhaseObservable: Observable<Scene>;
  42839. /**
  42840. * An event triggered after draw calls have been sent
  42841. */
  42842. onAfterDrawPhaseObservable: Observable<Scene>;
  42843. /**
  42844. * An event triggered when the scene is ready
  42845. */
  42846. onReadyObservable: Observable<Scene>;
  42847. /**
  42848. * An event triggered before rendering a camera
  42849. */
  42850. onBeforeCameraRenderObservable: Observable<Camera>;
  42851. private _onBeforeCameraRenderObserver;
  42852. /** Sets a function to be executed before rendering a camera*/
  42853. set beforeCameraRender(callback: () => void);
  42854. /**
  42855. * An event triggered after rendering a camera
  42856. */
  42857. onAfterCameraRenderObservable: Observable<Camera>;
  42858. private _onAfterCameraRenderObserver;
  42859. /** Sets a function to be executed after rendering a camera*/
  42860. set afterCameraRender(callback: () => void);
  42861. /**
  42862. * An event triggered when active meshes evaluation is about to start
  42863. */
  42864. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  42865. /**
  42866. * An event triggered when active meshes evaluation is done
  42867. */
  42868. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  42869. /**
  42870. * An event triggered when particles rendering is about to start
  42871. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  42872. */
  42873. onBeforeParticlesRenderingObservable: Observable<Scene>;
  42874. /**
  42875. * An event triggered when particles rendering is done
  42876. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  42877. */
  42878. onAfterParticlesRenderingObservable: Observable<Scene>;
  42879. /**
  42880. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  42881. */
  42882. onDataLoadedObservable: Observable<Scene>;
  42883. /**
  42884. * An event triggered when a camera is created
  42885. */
  42886. onNewCameraAddedObservable: Observable<Camera>;
  42887. /**
  42888. * An event triggered when a camera is removed
  42889. */
  42890. onCameraRemovedObservable: Observable<Camera>;
  42891. /**
  42892. * An event triggered when a light is created
  42893. */
  42894. onNewLightAddedObservable: Observable<Light>;
  42895. /**
  42896. * An event triggered when a light is removed
  42897. */
  42898. onLightRemovedObservable: Observable<Light>;
  42899. /**
  42900. * An event triggered when a geometry is created
  42901. */
  42902. onNewGeometryAddedObservable: Observable<Geometry>;
  42903. /**
  42904. * An event triggered when a geometry is removed
  42905. */
  42906. onGeometryRemovedObservable: Observable<Geometry>;
  42907. /**
  42908. * An event triggered when a transform node is created
  42909. */
  42910. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  42911. /**
  42912. * An event triggered when a transform node is removed
  42913. */
  42914. onTransformNodeRemovedObservable: Observable<TransformNode>;
  42915. /**
  42916. * An event triggered when a mesh is created
  42917. */
  42918. onNewMeshAddedObservable: Observable<AbstractMesh>;
  42919. /**
  42920. * An event triggered when a mesh is removed
  42921. */
  42922. onMeshRemovedObservable: Observable<AbstractMesh>;
  42923. /**
  42924. * An event triggered when a skeleton is created
  42925. */
  42926. onNewSkeletonAddedObservable: Observable<Skeleton>;
  42927. /**
  42928. * An event triggered when a skeleton is removed
  42929. */
  42930. onSkeletonRemovedObservable: Observable<Skeleton>;
  42931. /**
  42932. * An event triggered when a material is created
  42933. */
  42934. onNewMaterialAddedObservable: Observable<Material>;
  42935. /**
  42936. * An event triggered when a material is removed
  42937. */
  42938. onMaterialRemovedObservable: Observable<Material>;
  42939. /**
  42940. * An event triggered when a texture is created
  42941. */
  42942. onNewTextureAddedObservable: Observable<BaseTexture>;
  42943. /**
  42944. * An event triggered when a texture is removed
  42945. */
  42946. onTextureRemovedObservable: Observable<BaseTexture>;
  42947. /**
  42948. * An event triggered when render targets are about to be rendered
  42949. * Can happen multiple times per frame.
  42950. */
  42951. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  42952. /**
  42953. * An event triggered when render targets were rendered.
  42954. * Can happen multiple times per frame.
  42955. */
  42956. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  42957. /**
  42958. * An event triggered before calculating deterministic simulation step
  42959. */
  42960. onBeforeStepObservable: Observable<Scene>;
  42961. /**
  42962. * An event triggered after calculating deterministic simulation step
  42963. */
  42964. onAfterStepObservable: Observable<Scene>;
  42965. /**
  42966. * An event triggered when the activeCamera property is updated
  42967. */
  42968. onActiveCameraChanged: Observable<Scene>;
  42969. /**
  42970. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  42971. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  42972. * 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)
  42973. */
  42974. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  42975. /**
  42976. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  42977. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  42978. * 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)
  42979. */
  42980. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  42981. /**
  42982. * This Observable will when a mesh has been imported into the scene.
  42983. */
  42984. onMeshImportedObservable: Observable<AbstractMesh>;
  42985. /**
  42986. * This Observable will when an animation file has been imported into the scene.
  42987. */
  42988. onAnimationFileImportedObservable: Observable<Scene>;
  42989. /**
  42990. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  42991. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  42992. */
  42993. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  42994. /** @hidden */
  42995. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  42996. /**
  42997. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  42998. */
  42999. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  43000. /**
  43001. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  43002. */
  43003. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  43004. /**
  43005. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  43006. */
  43007. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  43008. /** Callback called when a pointer move is detected */
  43009. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  43010. /** Callback called when a pointer down is detected */
  43011. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  43012. /** Callback called when a pointer up is detected */
  43013. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  43014. /** Callback called when a pointer pick is detected */
  43015. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  43016. /**
  43017. * 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).
  43018. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  43019. */
  43020. onPrePointerObservable: Observable<PointerInfoPre>;
  43021. /**
  43022. * Observable event triggered each time an input event is received from the rendering canvas
  43023. */
  43024. onPointerObservable: Observable<PointerInfo>;
  43025. /**
  43026. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  43027. */
  43028. get unTranslatedPointer(): Vector2;
  43029. /**
  43030. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  43031. */
  43032. static get DragMovementThreshold(): number;
  43033. static set DragMovementThreshold(value: number);
  43034. /**
  43035. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  43036. */
  43037. static get LongPressDelay(): number;
  43038. static set LongPressDelay(value: number);
  43039. /**
  43040. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  43041. */
  43042. static get DoubleClickDelay(): number;
  43043. static set DoubleClickDelay(value: number);
  43044. /** If you need to check double click without raising a single click at first click, enable this flag */
  43045. static get ExclusiveDoubleClickMode(): boolean;
  43046. static set ExclusiveDoubleClickMode(value: boolean);
  43047. /** @hidden */
  43048. _mirroredCameraPosition: Nullable<Vector3>;
  43049. /**
  43050. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  43051. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  43052. */
  43053. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  43054. /**
  43055. * Observable event triggered each time an keyboard event is received from the hosting window
  43056. */
  43057. onKeyboardObservable: Observable<KeyboardInfo>;
  43058. private _useRightHandedSystem;
  43059. /**
  43060. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  43061. */
  43062. set useRightHandedSystem(value: boolean);
  43063. get useRightHandedSystem(): boolean;
  43064. private _timeAccumulator;
  43065. private _currentStepId;
  43066. private _currentInternalStep;
  43067. /**
  43068. * Sets the step Id used by deterministic lock step
  43069. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43070. * @param newStepId defines the step Id
  43071. */
  43072. setStepId(newStepId: number): void;
  43073. /**
  43074. * Gets the step Id used by deterministic lock step
  43075. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43076. * @returns the step Id
  43077. */
  43078. getStepId(): number;
  43079. /**
  43080. * Gets the internal step used by deterministic lock step
  43081. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43082. * @returns the internal step
  43083. */
  43084. getInternalStep(): number;
  43085. private _fogEnabled;
  43086. /**
  43087. * Gets or sets a boolean indicating if fog is enabled on this scene
  43088. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43089. * (Default is true)
  43090. */
  43091. set fogEnabled(value: boolean);
  43092. get fogEnabled(): boolean;
  43093. private _fogMode;
  43094. /**
  43095. * Gets or sets the fog mode to use
  43096. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43097. * | mode | value |
  43098. * | --- | --- |
  43099. * | FOGMODE_NONE | 0 |
  43100. * | FOGMODE_EXP | 1 |
  43101. * | FOGMODE_EXP2 | 2 |
  43102. * | FOGMODE_LINEAR | 3 |
  43103. */
  43104. set fogMode(value: number);
  43105. get fogMode(): number;
  43106. /**
  43107. * Gets or sets the fog color to use
  43108. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43109. * (Default is Color3(0.2, 0.2, 0.3))
  43110. */
  43111. fogColor: Color3;
  43112. /**
  43113. * Gets or sets the fog density to use
  43114. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43115. * (Default is 0.1)
  43116. */
  43117. fogDensity: number;
  43118. /**
  43119. * Gets or sets the fog start distance to use
  43120. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43121. * (Default is 0)
  43122. */
  43123. fogStart: number;
  43124. /**
  43125. * Gets or sets the fog end distance to use
  43126. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43127. * (Default is 1000)
  43128. */
  43129. fogEnd: number;
  43130. /**
  43131. * Flag indicating that the frame buffer binding is handled by another component
  43132. */
  43133. prePass: boolean;
  43134. private _shadowsEnabled;
  43135. /**
  43136. * Gets or sets a boolean indicating if shadows are enabled on this scene
  43137. */
  43138. set shadowsEnabled(value: boolean);
  43139. get shadowsEnabled(): boolean;
  43140. private _lightsEnabled;
  43141. /**
  43142. * Gets or sets a boolean indicating if lights are enabled on this scene
  43143. */
  43144. set lightsEnabled(value: boolean);
  43145. get lightsEnabled(): boolean;
  43146. /** All of the active cameras added to this scene. */
  43147. activeCameras: Camera[];
  43148. /** @hidden */
  43149. _activeCamera: Nullable<Camera>;
  43150. /** Gets or sets the current active camera */
  43151. get activeCamera(): Nullable<Camera>;
  43152. set activeCamera(value: Nullable<Camera>);
  43153. private _defaultMaterial;
  43154. /** The default material used on meshes when no material is affected */
  43155. get defaultMaterial(): Material;
  43156. /** The default material used on meshes when no material is affected */
  43157. set defaultMaterial(value: Material);
  43158. private _texturesEnabled;
  43159. /**
  43160. * Gets or sets a boolean indicating if textures are enabled on this scene
  43161. */
  43162. set texturesEnabled(value: boolean);
  43163. get texturesEnabled(): boolean;
  43164. /**
  43165. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  43166. */
  43167. physicsEnabled: boolean;
  43168. /**
  43169. * Gets or sets a boolean indicating if particles are enabled on this scene
  43170. */
  43171. particlesEnabled: boolean;
  43172. /**
  43173. * Gets or sets a boolean indicating if sprites are enabled on this scene
  43174. */
  43175. spritesEnabled: boolean;
  43176. private _skeletonsEnabled;
  43177. /**
  43178. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  43179. */
  43180. set skeletonsEnabled(value: boolean);
  43181. get skeletonsEnabled(): boolean;
  43182. /**
  43183. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  43184. */
  43185. lensFlaresEnabled: boolean;
  43186. /**
  43187. * Gets or sets a boolean indicating if collisions are enabled on this scene
  43188. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  43189. */
  43190. collisionsEnabled: boolean;
  43191. private _collisionCoordinator;
  43192. /** @hidden */
  43193. get collisionCoordinator(): ICollisionCoordinator;
  43194. /**
  43195. * Defines the gravity applied to this scene (used only for collisions)
  43196. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  43197. */
  43198. gravity: Vector3;
  43199. /**
  43200. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  43201. */
  43202. postProcessesEnabled: boolean;
  43203. /**
  43204. * Gets the current postprocess manager
  43205. */
  43206. postProcessManager: PostProcessManager;
  43207. /**
  43208. * Gets or sets a boolean indicating if render targets are enabled on this scene
  43209. */
  43210. renderTargetsEnabled: boolean;
  43211. /**
  43212. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  43213. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  43214. */
  43215. dumpNextRenderTargets: boolean;
  43216. /**
  43217. * The list of user defined render targets added to the scene
  43218. */
  43219. customRenderTargets: RenderTargetTexture[];
  43220. /**
  43221. * Defines if texture loading must be delayed
  43222. * If true, textures will only be loaded when they need to be rendered
  43223. */
  43224. useDelayedTextureLoading: boolean;
  43225. /**
  43226. * Gets the list of meshes imported to the scene through SceneLoader
  43227. */
  43228. importedMeshesFiles: String[];
  43229. /**
  43230. * Gets or sets a boolean indicating if probes are enabled on this scene
  43231. */
  43232. probesEnabled: boolean;
  43233. /**
  43234. * Gets or sets the current offline provider to use to store scene data
  43235. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  43236. */
  43237. offlineProvider: IOfflineProvider;
  43238. /**
  43239. * Gets or sets the action manager associated with the scene
  43240. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  43241. */
  43242. actionManager: AbstractActionManager;
  43243. private _meshesForIntersections;
  43244. /**
  43245. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  43246. */
  43247. proceduralTexturesEnabled: boolean;
  43248. private _engine;
  43249. private _totalVertices;
  43250. /** @hidden */
  43251. _activeIndices: PerfCounter;
  43252. /** @hidden */
  43253. _activeParticles: PerfCounter;
  43254. /** @hidden */
  43255. _activeBones: PerfCounter;
  43256. private _animationRatio;
  43257. /** @hidden */
  43258. _animationTimeLast: number;
  43259. /** @hidden */
  43260. _animationTime: number;
  43261. /**
  43262. * Gets or sets a general scale for animation speed
  43263. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  43264. */
  43265. animationTimeScale: number;
  43266. /** @hidden */
  43267. _cachedMaterial: Nullable<Material>;
  43268. /** @hidden */
  43269. _cachedEffect: Nullable<Effect>;
  43270. /** @hidden */
  43271. _cachedVisibility: Nullable<number>;
  43272. private _renderId;
  43273. private _frameId;
  43274. private _executeWhenReadyTimeoutId;
  43275. private _intermediateRendering;
  43276. private _viewUpdateFlag;
  43277. private _projectionUpdateFlag;
  43278. /** @hidden */
  43279. _toBeDisposed: Nullable<IDisposable>[];
  43280. private _activeRequests;
  43281. /** @hidden */
  43282. _pendingData: any[];
  43283. private _isDisposed;
  43284. /**
  43285. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  43286. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  43287. */
  43288. dispatchAllSubMeshesOfActiveMeshes: boolean;
  43289. private _activeMeshes;
  43290. private _processedMaterials;
  43291. private _renderTargets;
  43292. /** @hidden */
  43293. _activeParticleSystems: SmartArray<IParticleSystem>;
  43294. private _activeSkeletons;
  43295. private _softwareSkinnedMeshes;
  43296. private _renderingManager;
  43297. /** @hidden */
  43298. _activeAnimatables: Animatable[];
  43299. private _transformMatrix;
  43300. private _sceneUbo;
  43301. /** @hidden */
  43302. _viewMatrix: Matrix;
  43303. private _projectionMatrix;
  43304. /** @hidden */
  43305. _forcedViewPosition: Nullable<Vector3>;
  43306. /** @hidden */
  43307. _frustumPlanes: Plane[];
  43308. /**
  43309. * Gets the list of frustum planes (built from the active camera)
  43310. */
  43311. get frustumPlanes(): Plane[];
  43312. /**
  43313. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  43314. * This is useful if there are more lights that the maximum simulteanous authorized
  43315. */
  43316. requireLightSorting: boolean;
  43317. /** @hidden */
  43318. readonly useMaterialMeshMap: boolean;
  43319. /** @hidden */
  43320. readonly useClonedMeshMap: boolean;
  43321. private _externalData;
  43322. private _uid;
  43323. /**
  43324. * @hidden
  43325. * Backing store of defined scene components.
  43326. */
  43327. _components: ISceneComponent[];
  43328. /**
  43329. * @hidden
  43330. * Backing store of defined scene components.
  43331. */
  43332. _serializableComponents: ISceneSerializableComponent[];
  43333. /**
  43334. * List of components to register on the next registration step.
  43335. */
  43336. private _transientComponents;
  43337. /**
  43338. * Registers the transient components if needed.
  43339. */
  43340. private _registerTransientComponents;
  43341. /**
  43342. * @hidden
  43343. * Add a component to the scene.
  43344. * Note that the ccomponent could be registered on th next frame if this is called after
  43345. * the register component stage.
  43346. * @param component Defines the component to add to the scene
  43347. */
  43348. _addComponent(component: ISceneComponent): void;
  43349. /**
  43350. * @hidden
  43351. * Gets a component from the scene.
  43352. * @param name defines the name of the component to retrieve
  43353. * @returns the component or null if not present
  43354. */
  43355. _getComponent(name: string): Nullable<ISceneComponent>;
  43356. /**
  43357. * @hidden
  43358. * Defines the actions happening before camera updates.
  43359. */
  43360. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  43361. /**
  43362. * @hidden
  43363. * Defines the actions happening before clear the canvas.
  43364. */
  43365. _beforeClearStage: Stage<SimpleStageAction>;
  43366. /**
  43367. * @hidden
  43368. * Defines the actions when collecting render targets for the frame.
  43369. */
  43370. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  43371. /**
  43372. * @hidden
  43373. * Defines the actions happening for one camera in the frame.
  43374. */
  43375. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  43376. /**
  43377. * @hidden
  43378. * Defines the actions happening during the per mesh ready checks.
  43379. */
  43380. _isReadyForMeshStage: Stage<MeshStageAction>;
  43381. /**
  43382. * @hidden
  43383. * Defines the actions happening before evaluate active mesh checks.
  43384. */
  43385. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  43386. /**
  43387. * @hidden
  43388. * Defines the actions happening during the evaluate sub mesh checks.
  43389. */
  43390. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  43391. /**
  43392. * @hidden
  43393. * Defines the actions happening during the active mesh stage.
  43394. */
  43395. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  43396. /**
  43397. * @hidden
  43398. * Defines the actions happening during the per camera render target step.
  43399. */
  43400. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  43401. /**
  43402. * @hidden
  43403. * Defines the actions happening just before the active camera is drawing.
  43404. */
  43405. _beforeCameraDrawStage: Stage<CameraStageAction>;
  43406. /**
  43407. * @hidden
  43408. * Defines the actions happening just before a render target is drawing.
  43409. */
  43410. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  43411. /**
  43412. * @hidden
  43413. * Defines the actions happening just before a rendering group is drawing.
  43414. */
  43415. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  43416. /**
  43417. * @hidden
  43418. * Defines the actions happening just before a mesh is drawing.
  43419. */
  43420. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  43421. /**
  43422. * @hidden
  43423. * Defines the actions happening just after a mesh has been drawn.
  43424. */
  43425. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  43426. /**
  43427. * @hidden
  43428. * Defines the actions happening just after a rendering group has been drawn.
  43429. */
  43430. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  43431. /**
  43432. * @hidden
  43433. * Defines the actions happening just after the active camera has been drawn.
  43434. */
  43435. _afterCameraDrawStage: Stage<CameraStageAction>;
  43436. /**
  43437. * @hidden
  43438. * Defines the actions happening just after a render target has been drawn.
  43439. */
  43440. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  43441. /**
  43442. * @hidden
  43443. * Defines the actions happening just after rendering all cameras and computing intersections.
  43444. */
  43445. _afterRenderStage: Stage<SimpleStageAction>;
  43446. /**
  43447. * @hidden
  43448. * Defines the actions happening when a pointer move event happens.
  43449. */
  43450. _pointerMoveStage: Stage<PointerMoveStageAction>;
  43451. /**
  43452. * @hidden
  43453. * Defines the actions happening when a pointer down event happens.
  43454. */
  43455. _pointerDownStage: Stage<PointerUpDownStageAction>;
  43456. /**
  43457. * @hidden
  43458. * Defines the actions happening when a pointer up event happens.
  43459. */
  43460. _pointerUpStage: Stage<PointerUpDownStageAction>;
  43461. /**
  43462. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  43463. */
  43464. private geometriesByUniqueId;
  43465. /**
  43466. * Creates a new Scene
  43467. * @param engine defines the engine to use to render this scene
  43468. * @param options defines the scene options
  43469. */
  43470. constructor(engine: Engine, options?: SceneOptions);
  43471. /**
  43472. * Gets a string identifying the name of the class
  43473. * @returns "Scene" string
  43474. */
  43475. getClassName(): string;
  43476. private _defaultMeshCandidates;
  43477. /**
  43478. * @hidden
  43479. */
  43480. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43481. private _defaultSubMeshCandidates;
  43482. /**
  43483. * @hidden
  43484. */
  43485. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43486. /**
  43487. * Sets the default candidate providers for the scene.
  43488. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  43489. * and getCollidingSubMeshCandidates to their default function
  43490. */
  43491. setDefaultCandidateProviders(): void;
  43492. /**
  43493. * Gets the mesh that is currently under the pointer
  43494. */
  43495. get meshUnderPointer(): Nullable<AbstractMesh>;
  43496. /**
  43497. * Gets or sets the current on-screen X position of the pointer
  43498. */
  43499. get pointerX(): number;
  43500. set pointerX(value: number);
  43501. /**
  43502. * Gets or sets the current on-screen Y position of the pointer
  43503. */
  43504. get pointerY(): number;
  43505. set pointerY(value: number);
  43506. /**
  43507. * Gets the cached material (ie. the latest rendered one)
  43508. * @returns the cached material
  43509. */
  43510. getCachedMaterial(): Nullable<Material>;
  43511. /**
  43512. * Gets the cached effect (ie. the latest rendered one)
  43513. * @returns the cached effect
  43514. */
  43515. getCachedEffect(): Nullable<Effect>;
  43516. /**
  43517. * Gets the cached visibility state (ie. the latest rendered one)
  43518. * @returns the cached visibility state
  43519. */
  43520. getCachedVisibility(): Nullable<number>;
  43521. /**
  43522. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  43523. * @param material defines the current material
  43524. * @param effect defines the current effect
  43525. * @param visibility defines the current visibility state
  43526. * @returns true if one parameter is not cached
  43527. */
  43528. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  43529. /**
  43530. * Gets the engine associated with the scene
  43531. * @returns an Engine
  43532. */
  43533. getEngine(): Engine;
  43534. /**
  43535. * Gets the total number of vertices rendered per frame
  43536. * @returns the total number of vertices rendered per frame
  43537. */
  43538. getTotalVertices(): number;
  43539. /**
  43540. * Gets the performance counter for total vertices
  43541. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43542. */
  43543. get totalVerticesPerfCounter(): PerfCounter;
  43544. /**
  43545. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  43546. * @returns the total number of active indices rendered per frame
  43547. */
  43548. getActiveIndices(): number;
  43549. /**
  43550. * Gets the performance counter for active indices
  43551. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43552. */
  43553. get totalActiveIndicesPerfCounter(): PerfCounter;
  43554. /**
  43555. * Gets the total number of active particles rendered per frame
  43556. * @returns the total number of active particles rendered per frame
  43557. */
  43558. getActiveParticles(): number;
  43559. /**
  43560. * Gets the performance counter for active particles
  43561. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43562. */
  43563. get activeParticlesPerfCounter(): PerfCounter;
  43564. /**
  43565. * Gets the total number of active bones rendered per frame
  43566. * @returns the total number of active bones rendered per frame
  43567. */
  43568. getActiveBones(): number;
  43569. /**
  43570. * Gets the performance counter for active bones
  43571. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43572. */
  43573. get activeBonesPerfCounter(): PerfCounter;
  43574. /**
  43575. * Gets the array of active meshes
  43576. * @returns an array of AbstractMesh
  43577. */
  43578. getActiveMeshes(): SmartArray<AbstractMesh>;
  43579. /**
  43580. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  43581. * @returns a number
  43582. */
  43583. getAnimationRatio(): number;
  43584. /**
  43585. * Gets an unique Id for the current render phase
  43586. * @returns a number
  43587. */
  43588. getRenderId(): number;
  43589. /**
  43590. * Gets an unique Id for the current frame
  43591. * @returns a number
  43592. */
  43593. getFrameId(): number;
  43594. /** Call this function if you want to manually increment the render Id*/
  43595. incrementRenderId(): void;
  43596. private _createUbo;
  43597. /**
  43598. * Use this method to simulate a pointer move on a mesh
  43599. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43600. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43601. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43602. * @returns the current scene
  43603. */
  43604. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  43605. /**
  43606. * Use this method to simulate a pointer down on a mesh
  43607. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43608. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43609. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43610. * @returns the current scene
  43611. */
  43612. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  43613. /**
  43614. * Use this method to simulate a pointer up on a mesh
  43615. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43616. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43617. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43618. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43619. * @returns the current scene
  43620. */
  43621. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  43622. /**
  43623. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  43624. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  43625. * @returns true if the pointer was captured
  43626. */
  43627. isPointerCaptured(pointerId?: number): boolean;
  43628. /**
  43629. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  43630. * @param attachUp defines if you want to attach events to pointerup
  43631. * @param attachDown defines if you want to attach events to pointerdown
  43632. * @param attachMove defines if you want to attach events to pointermove
  43633. */
  43634. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  43635. /** Detaches all event handlers*/
  43636. detachControl(): void;
  43637. /**
  43638. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  43639. * Delay loaded resources are not taking in account
  43640. * @return true if all required resources are ready
  43641. */
  43642. isReady(): boolean;
  43643. /** Resets all cached information relative to material (including effect and visibility) */
  43644. resetCachedMaterial(): void;
  43645. /**
  43646. * Registers a function to be called before every frame render
  43647. * @param func defines the function to register
  43648. */
  43649. registerBeforeRender(func: () => void): void;
  43650. /**
  43651. * Unregisters a function called before every frame render
  43652. * @param func defines the function to unregister
  43653. */
  43654. unregisterBeforeRender(func: () => void): void;
  43655. /**
  43656. * Registers a function to be called after every frame render
  43657. * @param func defines the function to register
  43658. */
  43659. registerAfterRender(func: () => void): void;
  43660. /**
  43661. * Unregisters a function called after every frame render
  43662. * @param func defines the function to unregister
  43663. */
  43664. unregisterAfterRender(func: () => void): void;
  43665. private _executeOnceBeforeRender;
  43666. /**
  43667. * The provided function will run before render once and will be disposed afterwards.
  43668. * A timeout delay can be provided so that the function will be executed in N ms.
  43669. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  43670. * @param func The function to be executed.
  43671. * @param timeout optional delay in ms
  43672. */
  43673. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  43674. /** @hidden */
  43675. _addPendingData(data: any): void;
  43676. /** @hidden */
  43677. _removePendingData(data: any): void;
  43678. /**
  43679. * Returns the number of items waiting to be loaded
  43680. * @returns the number of items waiting to be loaded
  43681. */
  43682. getWaitingItemsCount(): number;
  43683. /**
  43684. * Returns a boolean indicating if the scene is still loading data
  43685. */
  43686. get isLoading(): boolean;
  43687. /**
  43688. * Registers a function to be executed when the scene is ready
  43689. * @param {Function} func - the function to be executed
  43690. */
  43691. executeWhenReady(func: () => void): void;
  43692. /**
  43693. * Returns a promise that resolves when the scene is ready
  43694. * @returns A promise that resolves when the scene is ready
  43695. */
  43696. whenReadyAsync(): Promise<void>;
  43697. /** @hidden */
  43698. _checkIsReady(): void;
  43699. /**
  43700. * Gets all animatable attached to the scene
  43701. */
  43702. get animatables(): Animatable[];
  43703. /**
  43704. * Resets the last animation time frame.
  43705. * Useful to override when animations start running when loading a scene for the first time.
  43706. */
  43707. resetLastAnimationTimeFrame(): void;
  43708. /**
  43709. * Gets the current view matrix
  43710. * @returns a Matrix
  43711. */
  43712. getViewMatrix(): Matrix;
  43713. /**
  43714. * Gets the current projection matrix
  43715. * @returns a Matrix
  43716. */
  43717. getProjectionMatrix(): Matrix;
  43718. /**
  43719. * Gets the current transform matrix
  43720. * @returns a Matrix made of View * Projection
  43721. */
  43722. getTransformMatrix(): Matrix;
  43723. /**
  43724. * Sets the current transform matrix
  43725. * @param viewL defines the View matrix to use
  43726. * @param projectionL defines the Projection matrix to use
  43727. * @param viewR defines the right View matrix to use (if provided)
  43728. * @param projectionR defines the right Projection matrix to use (if provided)
  43729. */
  43730. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  43731. /**
  43732. * Gets the uniform buffer used to store scene data
  43733. * @returns a UniformBuffer
  43734. */
  43735. getSceneUniformBuffer(): UniformBuffer;
  43736. /**
  43737. * Gets an unique (relatively to the current scene) Id
  43738. * @returns an unique number for the scene
  43739. */
  43740. getUniqueId(): number;
  43741. /**
  43742. * Add a mesh to the list of scene's meshes
  43743. * @param newMesh defines the mesh to add
  43744. * @param recursive if all child meshes should also be added to the scene
  43745. */
  43746. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  43747. /**
  43748. * Remove a mesh for the list of scene's meshes
  43749. * @param toRemove defines the mesh to remove
  43750. * @param recursive if all child meshes should also be removed from the scene
  43751. * @returns the index where the mesh was in the mesh list
  43752. */
  43753. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  43754. /**
  43755. * Add a transform node to the list of scene's transform nodes
  43756. * @param newTransformNode defines the transform node to add
  43757. */
  43758. addTransformNode(newTransformNode: TransformNode): void;
  43759. /**
  43760. * Remove a transform node for the list of scene's transform nodes
  43761. * @param toRemove defines the transform node to remove
  43762. * @returns the index where the transform node was in the transform node list
  43763. */
  43764. removeTransformNode(toRemove: TransformNode): number;
  43765. /**
  43766. * Remove a skeleton for the list of scene's skeletons
  43767. * @param toRemove defines the skeleton to remove
  43768. * @returns the index where the skeleton was in the skeleton list
  43769. */
  43770. removeSkeleton(toRemove: Skeleton): number;
  43771. /**
  43772. * Remove a morph target for the list of scene's morph targets
  43773. * @param toRemove defines the morph target to remove
  43774. * @returns the index where the morph target was in the morph target list
  43775. */
  43776. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  43777. /**
  43778. * Remove a light for the list of scene's lights
  43779. * @param toRemove defines the light to remove
  43780. * @returns the index where the light was in the light list
  43781. */
  43782. removeLight(toRemove: Light): number;
  43783. /**
  43784. * Remove a camera for the list of scene's cameras
  43785. * @param toRemove defines the camera to remove
  43786. * @returns the index where the camera was in the camera list
  43787. */
  43788. removeCamera(toRemove: Camera): number;
  43789. /**
  43790. * Remove a particle system for the list of scene's particle systems
  43791. * @param toRemove defines the particle system to remove
  43792. * @returns the index where the particle system was in the particle system list
  43793. */
  43794. removeParticleSystem(toRemove: IParticleSystem): number;
  43795. /**
  43796. * Remove a animation for the list of scene's animations
  43797. * @param toRemove defines the animation to remove
  43798. * @returns the index where the animation was in the animation list
  43799. */
  43800. removeAnimation(toRemove: Animation): number;
  43801. /**
  43802. * Will stop the animation of the given target
  43803. * @param target - the target
  43804. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  43805. * @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)
  43806. */
  43807. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  43808. /**
  43809. * Removes the given animation group from this scene.
  43810. * @param toRemove The animation group to remove
  43811. * @returns The index of the removed animation group
  43812. */
  43813. removeAnimationGroup(toRemove: AnimationGroup): number;
  43814. /**
  43815. * Removes the given multi-material from this scene.
  43816. * @param toRemove The multi-material to remove
  43817. * @returns The index of the removed multi-material
  43818. */
  43819. removeMultiMaterial(toRemove: MultiMaterial): number;
  43820. /**
  43821. * Removes the given material from this scene.
  43822. * @param toRemove The material to remove
  43823. * @returns The index of the removed material
  43824. */
  43825. removeMaterial(toRemove: Material): number;
  43826. /**
  43827. * Removes the given action manager from this scene.
  43828. * @param toRemove The action manager to remove
  43829. * @returns The index of the removed action manager
  43830. */
  43831. removeActionManager(toRemove: AbstractActionManager): number;
  43832. /**
  43833. * Removes the given texture from this scene.
  43834. * @param toRemove The texture to remove
  43835. * @returns The index of the removed texture
  43836. */
  43837. removeTexture(toRemove: BaseTexture): number;
  43838. /**
  43839. * Adds the given light to this scene
  43840. * @param newLight The light to add
  43841. */
  43842. addLight(newLight: Light): void;
  43843. /**
  43844. * Sorts the list list based on light priorities
  43845. */
  43846. sortLightsByPriority(): void;
  43847. /**
  43848. * Adds the given camera to this scene
  43849. * @param newCamera The camera to add
  43850. */
  43851. addCamera(newCamera: Camera): void;
  43852. /**
  43853. * Adds the given skeleton to this scene
  43854. * @param newSkeleton The skeleton to add
  43855. */
  43856. addSkeleton(newSkeleton: Skeleton): void;
  43857. /**
  43858. * Adds the given particle system to this scene
  43859. * @param newParticleSystem The particle system to add
  43860. */
  43861. addParticleSystem(newParticleSystem: IParticleSystem): void;
  43862. /**
  43863. * Adds the given animation to this scene
  43864. * @param newAnimation The animation to add
  43865. */
  43866. addAnimation(newAnimation: Animation): void;
  43867. /**
  43868. * Adds the given animation group to this scene.
  43869. * @param newAnimationGroup The animation group to add
  43870. */
  43871. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  43872. /**
  43873. * Adds the given multi-material to this scene
  43874. * @param newMultiMaterial The multi-material to add
  43875. */
  43876. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  43877. /**
  43878. * Adds the given material to this scene
  43879. * @param newMaterial The material to add
  43880. */
  43881. addMaterial(newMaterial: Material): void;
  43882. /**
  43883. * Adds the given morph target to this scene
  43884. * @param newMorphTargetManager The morph target to add
  43885. */
  43886. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  43887. /**
  43888. * Adds the given geometry to this scene
  43889. * @param newGeometry The geometry to add
  43890. */
  43891. addGeometry(newGeometry: Geometry): void;
  43892. /**
  43893. * Adds the given action manager to this scene
  43894. * @param newActionManager The action manager to add
  43895. */
  43896. addActionManager(newActionManager: AbstractActionManager): void;
  43897. /**
  43898. * Adds the given texture to this scene.
  43899. * @param newTexture The texture to add
  43900. */
  43901. addTexture(newTexture: BaseTexture): void;
  43902. /**
  43903. * Switch active camera
  43904. * @param newCamera defines the new active camera
  43905. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  43906. */
  43907. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  43908. /**
  43909. * sets the active camera of the scene using its ID
  43910. * @param id defines the camera's ID
  43911. * @return the new active camera or null if none found.
  43912. */
  43913. setActiveCameraByID(id: string): Nullable<Camera>;
  43914. /**
  43915. * sets the active camera of the scene using its name
  43916. * @param name defines the camera's name
  43917. * @returns the new active camera or null if none found.
  43918. */
  43919. setActiveCameraByName(name: string): Nullable<Camera>;
  43920. /**
  43921. * get an animation group using its name
  43922. * @param name defines the material's name
  43923. * @return the animation group or null if none found.
  43924. */
  43925. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  43926. /**
  43927. * Get a material using its unique id
  43928. * @param uniqueId defines the material's unique id
  43929. * @return the material or null if none found.
  43930. */
  43931. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  43932. /**
  43933. * get a material using its id
  43934. * @param id defines the material's ID
  43935. * @return the material or null if none found.
  43936. */
  43937. getMaterialByID(id: string): Nullable<Material>;
  43938. /**
  43939. * Gets a the last added material using a given id
  43940. * @param id defines the material's ID
  43941. * @return the last material with the given id or null if none found.
  43942. */
  43943. getLastMaterialByID(id: string): Nullable<Material>;
  43944. /**
  43945. * Gets a material using its name
  43946. * @param name defines the material's name
  43947. * @return the material or null if none found.
  43948. */
  43949. getMaterialByName(name: string): Nullable<Material>;
  43950. /**
  43951. * Get a texture using its unique id
  43952. * @param uniqueId defines the texture's unique id
  43953. * @return the texture or null if none found.
  43954. */
  43955. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  43956. /**
  43957. * Gets a camera using its id
  43958. * @param id defines the id to look for
  43959. * @returns the camera or null if not found
  43960. */
  43961. getCameraByID(id: string): Nullable<Camera>;
  43962. /**
  43963. * Gets a camera using its unique id
  43964. * @param uniqueId defines the unique id to look for
  43965. * @returns the camera or null if not found
  43966. */
  43967. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  43968. /**
  43969. * Gets a camera using its name
  43970. * @param name defines the camera's name
  43971. * @return the camera or null if none found.
  43972. */
  43973. getCameraByName(name: string): Nullable<Camera>;
  43974. /**
  43975. * Gets a bone using its id
  43976. * @param id defines the bone's id
  43977. * @return the bone or null if not found
  43978. */
  43979. getBoneByID(id: string): Nullable<Bone>;
  43980. /**
  43981. * Gets a bone using its id
  43982. * @param name defines the bone's name
  43983. * @return the bone or null if not found
  43984. */
  43985. getBoneByName(name: string): Nullable<Bone>;
  43986. /**
  43987. * Gets a light node using its name
  43988. * @param name defines the the light's name
  43989. * @return the light or null if none found.
  43990. */
  43991. getLightByName(name: string): Nullable<Light>;
  43992. /**
  43993. * Gets a light node using its id
  43994. * @param id defines the light's id
  43995. * @return the light or null if none found.
  43996. */
  43997. getLightByID(id: string): Nullable<Light>;
  43998. /**
  43999. * Gets a light node using its scene-generated unique ID
  44000. * @param uniqueId defines the light's unique id
  44001. * @return the light or null if none found.
  44002. */
  44003. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  44004. /**
  44005. * Gets a particle system by id
  44006. * @param id defines the particle system id
  44007. * @return the corresponding system or null if none found
  44008. */
  44009. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  44010. /**
  44011. * Gets a geometry using its ID
  44012. * @param id defines the geometry's id
  44013. * @return the geometry or null if none found.
  44014. */
  44015. getGeometryByID(id: string): Nullable<Geometry>;
  44016. private _getGeometryByUniqueID;
  44017. /**
  44018. * Add a new geometry to this scene
  44019. * @param geometry defines the geometry to be added to the scene.
  44020. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  44021. * @return a boolean defining if the geometry was added or not
  44022. */
  44023. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  44024. /**
  44025. * Removes an existing geometry
  44026. * @param geometry defines the geometry to be removed from the scene
  44027. * @return a boolean defining if the geometry was removed or not
  44028. */
  44029. removeGeometry(geometry: Geometry): boolean;
  44030. /**
  44031. * Gets the list of geometries attached to the scene
  44032. * @returns an array of Geometry
  44033. */
  44034. getGeometries(): Geometry[];
  44035. /**
  44036. * Gets the first added mesh found of a given ID
  44037. * @param id defines the id to search for
  44038. * @return the mesh found or null if not found at all
  44039. */
  44040. getMeshByID(id: string): Nullable<AbstractMesh>;
  44041. /**
  44042. * Gets a list of meshes using their id
  44043. * @param id defines the id to search for
  44044. * @returns a list of meshes
  44045. */
  44046. getMeshesByID(id: string): Array<AbstractMesh>;
  44047. /**
  44048. * Gets the first added transform node found of a given ID
  44049. * @param id defines the id to search for
  44050. * @return the found transform node or null if not found at all.
  44051. */
  44052. getTransformNodeByID(id: string): Nullable<TransformNode>;
  44053. /**
  44054. * Gets a transform node with its auto-generated unique id
  44055. * @param uniqueId efines the unique id to search for
  44056. * @return the found transform node or null if not found at all.
  44057. */
  44058. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  44059. /**
  44060. * Gets a list of transform nodes using their id
  44061. * @param id defines the id to search for
  44062. * @returns a list of transform nodes
  44063. */
  44064. getTransformNodesByID(id: string): Array<TransformNode>;
  44065. /**
  44066. * Gets a mesh with its auto-generated unique id
  44067. * @param uniqueId defines the unique id to search for
  44068. * @return the found mesh or null if not found at all.
  44069. */
  44070. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  44071. /**
  44072. * Gets a the last added mesh using a given id
  44073. * @param id defines the id to search for
  44074. * @return the found mesh or null if not found at all.
  44075. */
  44076. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  44077. /**
  44078. * Gets a the last added node (Mesh, Camera, Light) using a given id
  44079. * @param id defines the id to search for
  44080. * @return the found node or null if not found at all
  44081. */
  44082. getLastEntryByID(id: string): Nullable<Node>;
  44083. /**
  44084. * Gets a node (Mesh, Camera, Light) using a given id
  44085. * @param id defines the id to search for
  44086. * @return the found node or null if not found at all
  44087. */
  44088. getNodeByID(id: string): Nullable<Node>;
  44089. /**
  44090. * Gets a node (Mesh, Camera, Light) using a given name
  44091. * @param name defines the name to search for
  44092. * @return the found node or null if not found at all.
  44093. */
  44094. getNodeByName(name: string): Nullable<Node>;
  44095. /**
  44096. * Gets a mesh using a given name
  44097. * @param name defines the name to search for
  44098. * @return the found mesh or null if not found at all.
  44099. */
  44100. getMeshByName(name: string): Nullable<AbstractMesh>;
  44101. /**
  44102. * Gets a transform node using a given name
  44103. * @param name defines the name to search for
  44104. * @return the found transform node or null if not found at all.
  44105. */
  44106. getTransformNodeByName(name: string): Nullable<TransformNode>;
  44107. /**
  44108. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  44109. * @param id defines the id to search for
  44110. * @return the found skeleton or null if not found at all.
  44111. */
  44112. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  44113. /**
  44114. * Gets a skeleton using a given auto generated unique id
  44115. * @param uniqueId defines the unique id to search for
  44116. * @return the found skeleton or null if not found at all.
  44117. */
  44118. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  44119. /**
  44120. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  44121. * @param id defines the id to search for
  44122. * @return the found skeleton or null if not found at all.
  44123. */
  44124. getSkeletonById(id: string): Nullable<Skeleton>;
  44125. /**
  44126. * Gets a skeleton using a given name
  44127. * @param name defines the name to search for
  44128. * @return the found skeleton or null if not found at all.
  44129. */
  44130. getSkeletonByName(name: string): Nullable<Skeleton>;
  44131. /**
  44132. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  44133. * @param id defines the id to search for
  44134. * @return the found morph target manager or null if not found at all.
  44135. */
  44136. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  44137. /**
  44138. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  44139. * @param id defines the id to search for
  44140. * @return the found morph target or null if not found at all.
  44141. */
  44142. getMorphTargetById(id: string): Nullable<MorphTarget>;
  44143. /**
  44144. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  44145. * @param name defines the name to search for
  44146. * @return the found morph target or null if not found at all.
  44147. */
  44148. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  44149. /**
  44150. * Gets a post process using a given name (if many are found, this function will pick the first one)
  44151. * @param name defines the name to search for
  44152. * @return the found post process or null if not found at all.
  44153. */
  44154. getPostProcessByName(name: string): Nullable<PostProcess>;
  44155. /**
  44156. * Gets a boolean indicating if the given mesh is active
  44157. * @param mesh defines the mesh to look for
  44158. * @returns true if the mesh is in the active list
  44159. */
  44160. isActiveMesh(mesh: AbstractMesh): boolean;
  44161. /**
  44162. * Return a unique id as a string which can serve as an identifier for the scene
  44163. */
  44164. get uid(): string;
  44165. /**
  44166. * Add an externaly attached data from its key.
  44167. * This method call will fail and return false, if such key already exists.
  44168. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  44169. * @param key the unique key that identifies the data
  44170. * @param data the data object to associate to the key for this Engine instance
  44171. * @return true if no such key were already present and the data was added successfully, false otherwise
  44172. */
  44173. addExternalData<T>(key: string, data: T): boolean;
  44174. /**
  44175. * Get an externaly attached data from its key
  44176. * @param key the unique key that identifies the data
  44177. * @return the associated data, if present (can be null), or undefined if not present
  44178. */
  44179. getExternalData<T>(key: string): Nullable<T>;
  44180. /**
  44181. * Get an externaly attached data from its key, create it using a factory if it's not already present
  44182. * @param key the unique key that identifies the data
  44183. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  44184. * @return the associated data, can be null if the factory returned null.
  44185. */
  44186. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  44187. /**
  44188. * Remove an externaly attached data from the Engine instance
  44189. * @param key the unique key that identifies the data
  44190. * @return true if the data was successfully removed, false if it doesn't exist
  44191. */
  44192. removeExternalData(key: string): boolean;
  44193. private _evaluateSubMesh;
  44194. /**
  44195. * Clear the processed materials smart array preventing retention point in material dispose.
  44196. */
  44197. freeProcessedMaterials(): void;
  44198. private _preventFreeActiveMeshesAndRenderingGroups;
  44199. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  44200. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  44201. * when disposing several meshes in a row or a hierarchy of meshes.
  44202. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  44203. */
  44204. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  44205. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  44206. /**
  44207. * Clear the active meshes smart array preventing retention point in mesh dispose.
  44208. */
  44209. freeActiveMeshes(): void;
  44210. /**
  44211. * Clear the info related to rendering groups preventing retention points during dispose.
  44212. */
  44213. freeRenderingGroups(): void;
  44214. /** @hidden */
  44215. _isInIntermediateRendering(): boolean;
  44216. /**
  44217. * Lambda returning the list of potentially active meshes.
  44218. */
  44219. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  44220. /**
  44221. * Lambda returning the list of potentially active sub meshes.
  44222. */
  44223. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  44224. /**
  44225. * Lambda returning the list of potentially intersecting sub meshes.
  44226. */
  44227. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  44228. /**
  44229. * Lambda returning the list of potentially colliding sub meshes.
  44230. */
  44231. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  44232. private _activeMeshesFrozen;
  44233. private _skipEvaluateActiveMeshesCompletely;
  44234. /**
  44235. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  44236. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  44237. * @param onSuccess optional success callback
  44238. * @param onError optional error callback
  44239. * @returns the current scene
  44240. */
  44241. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  44242. /**
  44243. * Use this function to restart evaluating active meshes on every frame
  44244. * @returns the current scene
  44245. */
  44246. unfreezeActiveMeshes(): Scene;
  44247. private _evaluateActiveMeshes;
  44248. private _activeMesh;
  44249. /**
  44250. * Update the transform matrix to update from the current active camera
  44251. * @param force defines a boolean used to force the update even if cache is up to date
  44252. */
  44253. updateTransformMatrix(force?: boolean): void;
  44254. private _bindFrameBuffer;
  44255. /** @hidden */
  44256. _allowPostProcessClearColor: boolean;
  44257. /** @hidden */
  44258. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  44259. private _processSubCameras;
  44260. private _checkIntersections;
  44261. /** @hidden */
  44262. _advancePhysicsEngineStep(step: number): void;
  44263. /**
  44264. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  44265. */
  44266. getDeterministicFrameTime: () => number;
  44267. /** @hidden */
  44268. _animate(): void;
  44269. /** Execute all animations (for a frame) */
  44270. animate(): void;
  44271. /**
  44272. * Render the scene
  44273. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  44274. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  44275. */
  44276. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  44277. /**
  44278. * Freeze all materials
  44279. * A frozen material will not be updatable but should be faster to render
  44280. */
  44281. freezeMaterials(): void;
  44282. /**
  44283. * Unfreeze all materials
  44284. * A frozen material will not be updatable but should be faster to render
  44285. */
  44286. unfreezeMaterials(): void;
  44287. /**
  44288. * Releases all held ressources
  44289. */
  44290. dispose(): void;
  44291. /**
  44292. * Gets if the scene is already disposed
  44293. */
  44294. get isDisposed(): boolean;
  44295. /**
  44296. * Call this function to reduce memory footprint of the scene.
  44297. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  44298. */
  44299. clearCachedVertexData(): void;
  44300. /**
  44301. * This function will remove the local cached buffer data from texture.
  44302. * It will save memory but will prevent the texture from being rebuilt
  44303. */
  44304. cleanCachedTextureBuffer(): void;
  44305. /**
  44306. * Get the world extend vectors with an optional filter
  44307. *
  44308. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  44309. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  44310. */
  44311. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  44312. min: Vector3;
  44313. max: Vector3;
  44314. };
  44315. /**
  44316. * Creates a ray that can be used to pick in the scene
  44317. * @param x defines the x coordinate of the origin (on-screen)
  44318. * @param y defines the y coordinate of the origin (on-screen)
  44319. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  44320. * @param camera defines the camera to use for the picking
  44321. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  44322. * @returns a Ray
  44323. */
  44324. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  44325. /**
  44326. * Creates a ray that can be used to pick in the scene
  44327. * @param x defines the x coordinate of the origin (on-screen)
  44328. * @param y defines the y coordinate of the origin (on-screen)
  44329. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  44330. * @param result defines the ray where to store the picking ray
  44331. * @param camera defines the camera to use for the picking
  44332. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  44333. * @returns the current scene
  44334. */
  44335. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  44336. /**
  44337. * Creates a ray that can be used to pick in the scene
  44338. * @param x defines the x coordinate of the origin (on-screen)
  44339. * @param y defines the y coordinate of the origin (on-screen)
  44340. * @param camera defines the camera to use for the picking
  44341. * @returns a Ray
  44342. */
  44343. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  44344. /**
  44345. * Creates a ray that can be used to pick in the scene
  44346. * @param x defines the x coordinate of the origin (on-screen)
  44347. * @param y defines the y coordinate of the origin (on-screen)
  44348. * @param result defines the ray where to store the picking ray
  44349. * @param camera defines the camera to use for the picking
  44350. * @returns the current scene
  44351. */
  44352. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  44353. /** Launch a ray to try to pick a mesh in the scene
  44354. * @param x position on screen
  44355. * @param y position on screen
  44356. * @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
  44357. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44358. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44359. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44360. * @returns a PickingInfo
  44361. */
  44362. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  44363. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  44364. * @param x position on screen
  44365. * @param y position on screen
  44366. * @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
  44367. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44368. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44369. * @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)
  44370. */
  44371. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  44372. /** Use the given ray to pick a mesh in the scene
  44373. * @param ray The ray to use to pick meshes
  44374. * @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
  44375. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44376. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44377. * @returns a PickingInfo
  44378. */
  44379. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  44380. /**
  44381. * Launch a ray to try to pick a mesh in the scene
  44382. * @param x X position on screen
  44383. * @param y Y position on screen
  44384. * @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
  44385. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44386. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44387. * @returns an array of PickingInfo
  44388. */
  44389. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  44390. /**
  44391. * Launch a ray to try to pick a mesh in the scene
  44392. * @param ray Ray to use
  44393. * @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
  44394. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44395. * @returns an array of PickingInfo
  44396. */
  44397. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  44398. /**
  44399. * Force the value of meshUnderPointer
  44400. * @param mesh defines the mesh to use
  44401. * @param pointerId optional pointer id when using more than one pointer
  44402. */
  44403. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  44404. /**
  44405. * Gets the mesh under the pointer
  44406. * @returns a Mesh or null if no mesh is under the pointer
  44407. */
  44408. getPointerOverMesh(): Nullable<AbstractMesh>;
  44409. /** @hidden */
  44410. _rebuildGeometries(): void;
  44411. /** @hidden */
  44412. _rebuildTextures(): void;
  44413. private _getByTags;
  44414. /**
  44415. * Get a list of meshes by tags
  44416. * @param tagsQuery defines the tags query to use
  44417. * @param forEach defines a predicate used to filter results
  44418. * @returns an array of Mesh
  44419. */
  44420. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  44421. /**
  44422. * Get a list of cameras by tags
  44423. * @param tagsQuery defines the tags query to use
  44424. * @param forEach defines a predicate used to filter results
  44425. * @returns an array of Camera
  44426. */
  44427. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  44428. /**
  44429. * Get a list of lights by tags
  44430. * @param tagsQuery defines the tags query to use
  44431. * @param forEach defines a predicate used to filter results
  44432. * @returns an array of Light
  44433. */
  44434. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  44435. /**
  44436. * Get a list of materials by tags
  44437. * @param tagsQuery defines the tags query to use
  44438. * @param forEach defines a predicate used to filter results
  44439. * @returns an array of Material
  44440. */
  44441. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  44442. /**
  44443. * Get a list of transform nodes by tags
  44444. * @param tagsQuery defines the tags query to use
  44445. * @param forEach defines a predicate used to filter results
  44446. * @returns an array of TransformNode
  44447. */
  44448. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  44449. /**
  44450. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  44451. * This allowed control for front to back rendering or reversly depending of the special needs.
  44452. *
  44453. * @param renderingGroupId The rendering group id corresponding to its index
  44454. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  44455. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  44456. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  44457. */
  44458. 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;
  44459. /**
  44460. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  44461. *
  44462. * @param renderingGroupId The rendering group id corresponding to its index
  44463. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  44464. * @param depth Automatically clears depth between groups if true and autoClear is true.
  44465. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  44466. */
  44467. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  44468. /**
  44469. * Gets the current auto clear configuration for one rendering group of the rendering
  44470. * manager.
  44471. * @param index the rendering group index to get the information for
  44472. * @returns The auto clear setup for the requested rendering group
  44473. */
  44474. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  44475. private _blockMaterialDirtyMechanism;
  44476. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  44477. get blockMaterialDirtyMechanism(): boolean;
  44478. set blockMaterialDirtyMechanism(value: boolean);
  44479. /**
  44480. * Will flag all materials as dirty to trigger new shader compilation
  44481. * @param flag defines the flag used to specify which material part must be marked as dirty
  44482. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  44483. */
  44484. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  44485. /** @hidden */
  44486. _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;
  44487. /** @hidden */
  44488. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44489. /** @hidden */
  44490. _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;
  44491. /** @hidden */
  44492. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  44493. /** @hidden */
  44494. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  44495. /** @hidden */
  44496. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44497. }
  44498. }
  44499. declare module BABYLON {
  44500. /**
  44501. * Set of assets to keep when moving a scene into an asset container.
  44502. */
  44503. export class KeepAssets extends AbstractScene {
  44504. }
  44505. /**
  44506. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  44507. */
  44508. export class InstantiatedEntries {
  44509. /**
  44510. * List of new root nodes (eg. nodes with no parent)
  44511. */
  44512. rootNodes: TransformNode[];
  44513. /**
  44514. * List of new skeletons
  44515. */
  44516. skeletons: Skeleton[];
  44517. /**
  44518. * List of new animation groups
  44519. */
  44520. animationGroups: AnimationGroup[];
  44521. }
  44522. /**
  44523. * Container with a set of assets that can be added or removed from a scene.
  44524. */
  44525. export class AssetContainer extends AbstractScene {
  44526. private _wasAddedToScene;
  44527. /**
  44528. * The scene the AssetContainer belongs to.
  44529. */
  44530. scene: Scene;
  44531. /**
  44532. * Instantiates an AssetContainer.
  44533. * @param scene The scene the AssetContainer belongs to.
  44534. */
  44535. constructor(scene: Scene);
  44536. /**
  44537. * Instantiate or clone all meshes and add the new ones to the scene.
  44538. * Skeletons and animation groups will all be cloned
  44539. * @param nameFunction defines an optional function used to get new names for clones
  44540. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  44541. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  44542. */
  44543. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  44544. /**
  44545. * Adds all the assets from the container to the scene.
  44546. */
  44547. addAllToScene(): void;
  44548. /**
  44549. * Removes all the assets in the container from the scene
  44550. */
  44551. removeAllFromScene(): void;
  44552. /**
  44553. * Disposes all the assets in the container
  44554. */
  44555. dispose(): void;
  44556. private _moveAssets;
  44557. /**
  44558. * Removes all the assets contained in the scene and adds them to the container.
  44559. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  44560. */
  44561. moveAllFromScene(keepAssets?: KeepAssets): void;
  44562. /**
  44563. * 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.
  44564. * @returns the root mesh
  44565. */
  44566. createRootMesh(): Mesh;
  44567. /**
  44568. * Merge animations (direct and animation groups) from this asset container into a scene
  44569. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44570. * @param animatables set of animatables to retarget to a node from the scene
  44571. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  44572. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  44573. */
  44574. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  44575. }
  44576. }
  44577. declare module BABYLON {
  44578. /**
  44579. * Defines how the parser contract is defined.
  44580. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  44581. */
  44582. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  44583. /**
  44584. * Defines how the individual parser contract is defined.
  44585. * These parser can parse an individual asset
  44586. */
  44587. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  44588. /**
  44589. * Base class of the scene acting as a container for the different elements composing a scene.
  44590. * This class is dynamically extended by the different components of the scene increasing
  44591. * flexibility and reducing coupling
  44592. */
  44593. export abstract class AbstractScene {
  44594. /**
  44595. * Stores the list of available parsers in the application.
  44596. */
  44597. private static _BabylonFileParsers;
  44598. /**
  44599. * Stores the list of available individual parsers in the application.
  44600. */
  44601. private static _IndividualBabylonFileParsers;
  44602. /**
  44603. * Adds a parser in the list of available ones
  44604. * @param name Defines the name of the parser
  44605. * @param parser Defines the parser to add
  44606. */
  44607. static AddParser(name: string, parser: BabylonFileParser): void;
  44608. /**
  44609. * Gets a general parser from the list of avaialble ones
  44610. * @param name Defines the name of the parser
  44611. * @returns the requested parser or null
  44612. */
  44613. static GetParser(name: string): Nullable<BabylonFileParser>;
  44614. /**
  44615. * Adds n individual parser in the list of available ones
  44616. * @param name Defines the name of the parser
  44617. * @param parser Defines the parser to add
  44618. */
  44619. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  44620. /**
  44621. * Gets an individual parser from the list of avaialble ones
  44622. * @param name Defines the name of the parser
  44623. * @returns the requested parser or null
  44624. */
  44625. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  44626. /**
  44627. * Parser json data and populate both a scene and its associated container object
  44628. * @param jsonData Defines the data to parse
  44629. * @param scene Defines the scene to parse the data for
  44630. * @param container Defines the container attached to the parsing sequence
  44631. * @param rootUrl Defines the root url of the data
  44632. */
  44633. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  44634. /**
  44635. * Gets the list of root nodes (ie. nodes with no parent)
  44636. */
  44637. rootNodes: Node[];
  44638. /** All of the cameras added to this scene
  44639. * @see https://doc.babylonjs.com/babylon101/cameras
  44640. */
  44641. cameras: Camera[];
  44642. /**
  44643. * All of the lights added to this scene
  44644. * @see https://doc.babylonjs.com/babylon101/lights
  44645. */
  44646. lights: Light[];
  44647. /**
  44648. * All of the (abstract) meshes added to this scene
  44649. */
  44650. meshes: AbstractMesh[];
  44651. /**
  44652. * The list of skeletons added to the scene
  44653. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  44654. */
  44655. skeletons: Skeleton[];
  44656. /**
  44657. * All of the particle systems added to this scene
  44658. * @see https://doc.babylonjs.com/babylon101/particles
  44659. */
  44660. particleSystems: IParticleSystem[];
  44661. /**
  44662. * Gets a list of Animations associated with the scene
  44663. */
  44664. animations: Animation[];
  44665. /**
  44666. * All of the animation groups added to this scene
  44667. * @see https://doc.babylonjs.com/how_to/group
  44668. */
  44669. animationGroups: AnimationGroup[];
  44670. /**
  44671. * All of the multi-materials added to this scene
  44672. * @see https://doc.babylonjs.com/how_to/multi_materials
  44673. */
  44674. multiMaterials: MultiMaterial[];
  44675. /**
  44676. * All of the materials added to this scene
  44677. * In the context of a Scene, it is not supposed to be modified manually.
  44678. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  44679. * Note also that the order of the Material within the array is not significant and might change.
  44680. * @see https://doc.babylonjs.com/babylon101/materials
  44681. */
  44682. materials: Material[];
  44683. /**
  44684. * The list of morph target managers added to the scene
  44685. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  44686. */
  44687. morphTargetManagers: MorphTargetManager[];
  44688. /**
  44689. * The list of geometries used in the scene.
  44690. */
  44691. geometries: Geometry[];
  44692. /**
  44693. * All of the tranform nodes added to this scene
  44694. * In the context of a Scene, it is not supposed to be modified manually.
  44695. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  44696. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  44697. * @see https://doc.babylonjs.com/how_to/transformnode
  44698. */
  44699. transformNodes: TransformNode[];
  44700. /**
  44701. * ActionManagers available on the scene.
  44702. */
  44703. actionManagers: AbstractActionManager[];
  44704. /**
  44705. * Textures to keep.
  44706. */
  44707. textures: BaseTexture[];
  44708. /** @hidden */
  44709. protected _environmentTexture: Nullable<BaseTexture>;
  44710. /**
  44711. * Texture used in all pbr material as the reflection texture.
  44712. * As in the majority of the scene they are the same (exception for multi room and so on),
  44713. * this is easier to reference from here than from all the materials.
  44714. */
  44715. get environmentTexture(): Nullable<BaseTexture>;
  44716. set environmentTexture(value: Nullable<BaseTexture>);
  44717. /**
  44718. * The list of postprocesses added to the scene
  44719. */
  44720. postProcesses: PostProcess[];
  44721. /**
  44722. * @returns all meshes, lights, cameras, transformNodes and bones
  44723. */
  44724. getNodes(): Array<Node>;
  44725. }
  44726. }
  44727. declare module BABYLON {
  44728. /**
  44729. * Interface used to define options for Sound class
  44730. */
  44731. export interface ISoundOptions {
  44732. /**
  44733. * Does the sound autoplay once loaded.
  44734. */
  44735. autoplay?: boolean;
  44736. /**
  44737. * Does the sound loop after it finishes playing once.
  44738. */
  44739. loop?: boolean;
  44740. /**
  44741. * Sound's volume
  44742. */
  44743. volume?: number;
  44744. /**
  44745. * Is it a spatial sound?
  44746. */
  44747. spatialSound?: boolean;
  44748. /**
  44749. * Maximum distance to hear that sound
  44750. */
  44751. maxDistance?: number;
  44752. /**
  44753. * Uses user defined attenuation function
  44754. */
  44755. useCustomAttenuation?: boolean;
  44756. /**
  44757. * Define the roll off factor of spatial sounds.
  44758. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44759. */
  44760. rolloffFactor?: number;
  44761. /**
  44762. * Define the reference distance the sound should be heard perfectly.
  44763. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44764. */
  44765. refDistance?: number;
  44766. /**
  44767. * Define the distance attenuation model the sound will follow.
  44768. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44769. */
  44770. distanceModel?: string;
  44771. /**
  44772. * Defines the playback speed (1 by default)
  44773. */
  44774. playbackRate?: number;
  44775. /**
  44776. * Defines if the sound is from a streaming source
  44777. */
  44778. streaming?: boolean;
  44779. /**
  44780. * Defines an optional length (in seconds) inside the sound file
  44781. */
  44782. length?: number;
  44783. /**
  44784. * Defines an optional offset (in seconds) inside the sound file
  44785. */
  44786. offset?: number;
  44787. /**
  44788. * If true, URLs will not be required to state the audio file codec to use.
  44789. */
  44790. skipCodecCheck?: boolean;
  44791. }
  44792. }
  44793. declare module BABYLON {
  44794. /**
  44795. * Defines a sound that can be played in the application.
  44796. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  44797. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  44798. */
  44799. export class Sound {
  44800. /**
  44801. * The name of the sound in the scene.
  44802. */
  44803. name: string;
  44804. /**
  44805. * Does the sound autoplay once loaded.
  44806. */
  44807. autoplay: boolean;
  44808. /**
  44809. * Does the sound loop after it finishes playing once.
  44810. */
  44811. loop: boolean;
  44812. /**
  44813. * Does the sound use a custom attenuation curve to simulate the falloff
  44814. * happening when the source gets further away from the camera.
  44815. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  44816. */
  44817. useCustomAttenuation: boolean;
  44818. /**
  44819. * The sound track id this sound belongs to.
  44820. */
  44821. soundTrackId: number;
  44822. /**
  44823. * Is this sound currently played.
  44824. */
  44825. isPlaying: boolean;
  44826. /**
  44827. * Is this sound currently paused.
  44828. */
  44829. isPaused: boolean;
  44830. /**
  44831. * Does this sound enables spatial sound.
  44832. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44833. */
  44834. spatialSound: boolean;
  44835. /**
  44836. * Define the reference distance the sound should be heard perfectly.
  44837. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44838. */
  44839. refDistance: number;
  44840. /**
  44841. * Define the roll off factor of spatial sounds.
  44842. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44843. */
  44844. rolloffFactor: number;
  44845. /**
  44846. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  44847. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44848. */
  44849. maxDistance: number;
  44850. /**
  44851. * Define the distance attenuation model the sound will follow.
  44852. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44853. */
  44854. distanceModel: string;
  44855. /**
  44856. * @hidden
  44857. * Back Compat
  44858. **/
  44859. onended: () => any;
  44860. /**
  44861. * Gets or sets an object used to store user defined information for the sound.
  44862. */
  44863. metadata: any;
  44864. /**
  44865. * Observable event when the current playing sound finishes.
  44866. */
  44867. onEndedObservable: Observable<Sound>;
  44868. /**
  44869. * Gets the current time for the sound.
  44870. */
  44871. get currentTime(): number;
  44872. private _panningModel;
  44873. private _playbackRate;
  44874. private _streaming;
  44875. private _startTime;
  44876. private _startOffset;
  44877. private _position;
  44878. /** @hidden */
  44879. _positionInEmitterSpace: boolean;
  44880. private _localDirection;
  44881. private _volume;
  44882. private _isReadyToPlay;
  44883. private _isDirectional;
  44884. private _readyToPlayCallback;
  44885. private _audioBuffer;
  44886. private _soundSource;
  44887. private _streamingSource;
  44888. private _soundPanner;
  44889. private _soundGain;
  44890. private _inputAudioNode;
  44891. private _outputAudioNode;
  44892. private _coneInnerAngle;
  44893. private _coneOuterAngle;
  44894. private _coneOuterGain;
  44895. private _scene;
  44896. private _connectedTransformNode;
  44897. private _customAttenuationFunction;
  44898. private _registerFunc;
  44899. private _isOutputConnected;
  44900. private _htmlAudioElement;
  44901. private _urlType;
  44902. private _length?;
  44903. private _offset?;
  44904. /** @hidden */
  44905. static _SceneComponentInitialization: (scene: Scene) => void;
  44906. /**
  44907. * Create a sound and attach it to a scene
  44908. * @param name Name of your sound
  44909. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  44910. * @param scene defines the scene the sound belongs to
  44911. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  44912. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  44913. */
  44914. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  44915. /**
  44916. * Release the sound and its associated resources
  44917. */
  44918. dispose(): void;
  44919. /**
  44920. * Gets if the sounds is ready to be played or not.
  44921. * @returns true if ready, otherwise false
  44922. */
  44923. isReady(): boolean;
  44924. private _soundLoaded;
  44925. /**
  44926. * Sets the data of the sound from an audiobuffer
  44927. * @param audioBuffer The audioBuffer containing the data
  44928. */
  44929. setAudioBuffer(audioBuffer: AudioBuffer): void;
  44930. /**
  44931. * Updates the current sounds options such as maxdistance, loop...
  44932. * @param options A JSON object containing values named as the object properties
  44933. */
  44934. updateOptions(options: ISoundOptions): void;
  44935. private _createSpatialParameters;
  44936. private _updateSpatialParameters;
  44937. /**
  44938. * Switch the panning model to HRTF:
  44939. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  44940. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44941. */
  44942. switchPanningModelToHRTF(): void;
  44943. /**
  44944. * Switch the panning model to Equal Power:
  44945. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  44946. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44947. */
  44948. switchPanningModelToEqualPower(): void;
  44949. private _switchPanningModel;
  44950. /**
  44951. * Connect this sound to a sound track audio node like gain...
  44952. * @param soundTrackAudioNode the sound track audio node to connect to
  44953. */
  44954. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  44955. /**
  44956. * Transform this sound into a directional source
  44957. * @param coneInnerAngle Size of the inner cone in degree
  44958. * @param coneOuterAngle Size of the outer cone in degree
  44959. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  44960. */
  44961. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  44962. /**
  44963. * Gets or sets the inner angle for the directional cone.
  44964. */
  44965. get directionalConeInnerAngle(): number;
  44966. /**
  44967. * Gets or sets the inner angle for the directional cone.
  44968. */
  44969. set directionalConeInnerAngle(value: number);
  44970. /**
  44971. * Gets or sets the outer angle for the directional cone.
  44972. */
  44973. get directionalConeOuterAngle(): number;
  44974. /**
  44975. * Gets or sets the outer angle for the directional cone.
  44976. */
  44977. set directionalConeOuterAngle(value: number);
  44978. /**
  44979. * Sets the position of the emitter if spatial sound is enabled
  44980. * @param newPosition Defines the new posisiton
  44981. */
  44982. setPosition(newPosition: Vector3): void;
  44983. /**
  44984. * Sets the local direction of the emitter if spatial sound is enabled
  44985. * @param newLocalDirection Defines the new local direction
  44986. */
  44987. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  44988. private _updateDirection;
  44989. /** @hidden */
  44990. updateDistanceFromListener(): void;
  44991. /**
  44992. * Sets a new custom attenuation function for the sound.
  44993. * @param callback Defines the function used for the attenuation
  44994. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  44995. */
  44996. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  44997. /**
  44998. * Play the sound
  44999. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  45000. * @param offset (optional) Start the sound at a specific time in seconds
  45001. * @param length (optional) Sound duration (in seconds)
  45002. */
  45003. play(time?: number, offset?: number, length?: number): void;
  45004. private _onended;
  45005. /**
  45006. * Stop the sound
  45007. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  45008. */
  45009. stop(time?: number): void;
  45010. /**
  45011. * Put the sound in pause
  45012. */
  45013. pause(): void;
  45014. /**
  45015. * Sets a dedicated volume for this sounds
  45016. * @param newVolume Define the new volume of the sound
  45017. * @param time Define time for gradual change to new volume
  45018. */
  45019. setVolume(newVolume: number, time?: number): void;
  45020. /**
  45021. * Set the sound play back rate
  45022. * @param newPlaybackRate Define the playback rate the sound should be played at
  45023. */
  45024. setPlaybackRate(newPlaybackRate: number): void;
  45025. /**
  45026. * Gets the volume of the sound.
  45027. * @returns the volume of the sound
  45028. */
  45029. getVolume(): number;
  45030. /**
  45031. * Attach the sound to a dedicated mesh
  45032. * @param transformNode The transform node to connect the sound with
  45033. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  45034. */
  45035. attachToMesh(transformNode: TransformNode): void;
  45036. /**
  45037. * Detach the sound from the previously attached mesh
  45038. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  45039. */
  45040. detachFromMesh(): void;
  45041. private _onRegisterAfterWorldMatrixUpdate;
  45042. /**
  45043. * Clone the current sound in the scene.
  45044. * @returns the new sound clone
  45045. */
  45046. clone(): Nullable<Sound>;
  45047. /**
  45048. * Gets the current underlying audio buffer containing the data
  45049. * @returns the audio buffer
  45050. */
  45051. getAudioBuffer(): Nullable<AudioBuffer>;
  45052. /**
  45053. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  45054. * @returns the source node
  45055. */
  45056. getSoundSource(): Nullable<AudioBufferSourceNode>;
  45057. /**
  45058. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  45059. * @returns the gain node
  45060. */
  45061. getSoundGain(): Nullable<GainNode>;
  45062. /**
  45063. * Serializes the Sound in a JSON representation
  45064. * @returns the JSON representation of the sound
  45065. */
  45066. serialize(): any;
  45067. /**
  45068. * Parse a JSON representation of a sound to innstantiate in a given scene
  45069. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  45070. * @param scene Define the scene the new parsed sound should be created in
  45071. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  45072. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  45073. * @returns the newly parsed sound
  45074. */
  45075. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  45076. }
  45077. }
  45078. declare module BABYLON {
  45079. /**
  45080. * This defines an action helpful to play a defined sound on a triggered action.
  45081. */
  45082. export class PlaySoundAction extends Action {
  45083. private _sound;
  45084. /**
  45085. * Instantiate the action
  45086. * @param triggerOptions defines the trigger options
  45087. * @param sound defines the sound to play
  45088. * @param condition defines the trigger related conditions
  45089. */
  45090. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  45091. /** @hidden */
  45092. _prepare(): void;
  45093. /**
  45094. * Execute the action and play the sound.
  45095. */
  45096. execute(): void;
  45097. /**
  45098. * Serializes the actions and its related information.
  45099. * @param parent defines the object to serialize in
  45100. * @returns the serialized object
  45101. */
  45102. serialize(parent: any): any;
  45103. }
  45104. /**
  45105. * This defines an action helpful to stop a defined sound on a triggered action.
  45106. */
  45107. export class StopSoundAction extends Action {
  45108. private _sound;
  45109. /**
  45110. * Instantiate the action
  45111. * @param triggerOptions defines the trigger options
  45112. * @param sound defines the sound to stop
  45113. * @param condition defines the trigger related conditions
  45114. */
  45115. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  45116. /** @hidden */
  45117. _prepare(): void;
  45118. /**
  45119. * Execute the action and stop the sound.
  45120. */
  45121. execute(): void;
  45122. /**
  45123. * Serializes the actions and its related information.
  45124. * @param parent defines the object to serialize in
  45125. * @returns the serialized object
  45126. */
  45127. serialize(parent: any): any;
  45128. }
  45129. }
  45130. declare module BABYLON {
  45131. /**
  45132. * This defines an action responsible to change the value of a property
  45133. * by interpolating between its current value and the newly set one once triggered.
  45134. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  45135. */
  45136. export class InterpolateValueAction extends Action {
  45137. /**
  45138. * Defines the path of the property where the value should be interpolated
  45139. */
  45140. propertyPath: string;
  45141. /**
  45142. * Defines the target value at the end of the interpolation.
  45143. */
  45144. value: any;
  45145. /**
  45146. * Defines the time it will take for the property to interpolate to the value.
  45147. */
  45148. duration: number;
  45149. /**
  45150. * Defines if the other scene animations should be stopped when the action has been triggered
  45151. */
  45152. stopOtherAnimations?: boolean;
  45153. /**
  45154. * Defines a callback raised once the interpolation animation has been done.
  45155. */
  45156. onInterpolationDone?: () => void;
  45157. /**
  45158. * Observable triggered once the interpolation animation has been done.
  45159. */
  45160. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  45161. private _target;
  45162. private _effectiveTarget;
  45163. private _property;
  45164. /**
  45165. * Instantiate the action
  45166. * @param triggerOptions defines the trigger options
  45167. * @param target defines the object containing the value to interpolate
  45168. * @param propertyPath defines the path to the property in the target object
  45169. * @param value defines the target value at the end of the interpolation
  45170. * @param duration deines the time it will take for the property to interpolate to the value.
  45171. * @param condition defines the trigger related conditions
  45172. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  45173. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  45174. */
  45175. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  45176. /** @hidden */
  45177. _prepare(): void;
  45178. /**
  45179. * Execute the action starts the value interpolation.
  45180. */
  45181. execute(): void;
  45182. /**
  45183. * Serializes the actions and its related information.
  45184. * @param parent defines the object to serialize in
  45185. * @returns the serialized object
  45186. */
  45187. serialize(parent: any): any;
  45188. }
  45189. }
  45190. declare module BABYLON {
  45191. /**
  45192. * This represents the default audio engine used in babylon.
  45193. * It is responsible to play, synchronize and analyse sounds throughout the application.
  45194. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45195. */
  45196. export class AudioEngine implements IAudioEngine {
  45197. private _audioContext;
  45198. private _audioContextInitialized;
  45199. private _muteButton;
  45200. private _hostElement;
  45201. /**
  45202. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  45203. */
  45204. canUseWebAudio: boolean;
  45205. /**
  45206. * The master gain node defines the global audio volume of your audio engine.
  45207. */
  45208. masterGain: GainNode;
  45209. /**
  45210. * Defines if Babylon should emit a warning if WebAudio is not supported.
  45211. * @ignoreNaming
  45212. */
  45213. WarnedWebAudioUnsupported: boolean;
  45214. /**
  45215. * Gets whether or not mp3 are supported by your browser.
  45216. */
  45217. isMP3supported: boolean;
  45218. /**
  45219. * Gets whether or not ogg are supported by your browser.
  45220. */
  45221. isOGGsupported: boolean;
  45222. /**
  45223. * Gets whether audio has been unlocked on the device.
  45224. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  45225. * a user interaction has happened.
  45226. */
  45227. unlocked: boolean;
  45228. /**
  45229. * Defines if the audio engine relies on a custom unlocked button.
  45230. * In this case, the embedded button will not be displayed.
  45231. */
  45232. useCustomUnlockedButton: boolean;
  45233. /**
  45234. * Event raised when audio has been unlocked on the browser.
  45235. */
  45236. onAudioUnlockedObservable: Observable<IAudioEngine>;
  45237. /**
  45238. * Event raised when audio has been locked on the browser.
  45239. */
  45240. onAudioLockedObservable: Observable<IAudioEngine>;
  45241. /**
  45242. * Gets the current AudioContext if available.
  45243. */
  45244. get audioContext(): Nullable<AudioContext>;
  45245. private _connectedAnalyser;
  45246. /**
  45247. * Instantiates a new audio engine.
  45248. *
  45249. * There should be only one per page as some browsers restrict the number
  45250. * of audio contexts you can create.
  45251. * @param hostElement defines the host element where to display the mute icon if necessary
  45252. */
  45253. constructor(hostElement?: Nullable<HTMLElement>);
  45254. /**
  45255. * Flags the audio engine in Locked state.
  45256. * This happens due to new browser policies preventing audio to autoplay.
  45257. */
  45258. lock(): void;
  45259. /**
  45260. * Unlocks the audio engine once a user action has been done on the dom.
  45261. * This is helpful to resume play once browser policies have been satisfied.
  45262. */
  45263. unlock(): void;
  45264. private _resumeAudioContext;
  45265. private _initializeAudioContext;
  45266. private _tryToRun;
  45267. private _triggerRunningState;
  45268. private _triggerSuspendedState;
  45269. private _displayMuteButton;
  45270. private _moveButtonToTopLeft;
  45271. private _onResize;
  45272. private _hideMuteButton;
  45273. /**
  45274. * Destroy and release the resources associated with the audio ccontext.
  45275. */
  45276. dispose(): void;
  45277. /**
  45278. * Gets the global volume sets on the master gain.
  45279. * @returns the global volume if set or -1 otherwise
  45280. */
  45281. getGlobalVolume(): number;
  45282. /**
  45283. * Sets the global volume of your experience (sets on the master gain).
  45284. * @param newVolume Defines the new global volume of the application
  45285. */
  45286. setGlobalVolume(newVolume: number): void;
  45287. /**
  45288. * Connect the audio engine to an audio analyser allowing some amazing
  45289. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  45290. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  45291. * @param analyser The analyser to connect to the engine
  45292. */
  45293. connectToAnalyser(analyser: Analyser): void;
  45294. }
  45295. }
  45296. declare module BABYLON {
  45297. /**
  45298. * Options allowed during the creation of a sound track.
  45299. */
  45300. export interface ISoundTrackOptions {
  45301. /**
  45302. * The volume the sound track should take during creation
  45303. */
  45304. volume?: number;
  45305. /**
  45306. * Define if the sound track is the main sound track of the scene
  45307. */
  45308. mainTrack?: boolean;
  45309. }
  45310. /**
  45311. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  45312. * It will be also used in a future release to apply effects on a specific track.
  45313. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  45314. */
  45315. export class SoundTrack {
  45316. /**
  45317. * The unique identifier of the sound track in the scene.
  45318. */
  45319. id: number;
  45320. /**
  45321. * The list of sounds included in the sound track.
  45322. */
  45323. soundCollection: Array<Sound>;
  45324. private _outputAudioNode;
  45325. private _scene;
  45326. private _connectedAnalyser;
  45327. private _options;
  45328. private _isInitialized;
  45329. /**
  45330. * Creates a new sound track.
  45331. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  45332. * @param scene Define the scene the sound track belongs to
  45333. * @param options
  45334. */
  45335. constructor(scene: Scene, options?: ISoundTrackOptions);
  45336. private _initializeSoundTrackAudioGraph;
  45337. /**
  45338. * Release the sound track and its associated resources
  45339. */
  45340. dispose(): void;
  45341. /**
  45342. * Adds a sound to this sound track
  45343. * @param sound define the cound to add
  45344. * @ignoreNaming
  45345. */
  45346. addSound(sound: Sound): void;
  45347. /**
  45348. * Removes a sound to this sound track
  45349. * @param sound define the cound to remove
  45350. * @ignoreNaming
  45351. */
  45352. removeSound(sound: Sound): void;
  45353. /**
  45354. * Set a global volume for the full sound track.
  45355. * @param newVolume Define the new volume of the sound track
  45356. */
  45357. setVolume(newVolume: number): void;
  45358. /**
  45359. * Switch the panning model to HRTF:
  45360. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  45361. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45362. */
  45363. switchPanningModelToHRTF(): void;
  45364. /**
  45365. * Switch the panning model to Equal Power:
  45366. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  45367. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45368. */
  45369. switchPanningModelToEqualPower(): void;
  45370. /**
  45371. * Connect the sound track to an audio analyser allowing some amazing
  45372. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  45373. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  45374. * @param analyser The analyser to connect to the engine
  45375. */
  45376. connectToAnalyser(analyser: Analyser): void;
  45377. }
  45378. }
  45379. declare module BABYLON {
  45380. interface AbstractScene {
  45381. /**
  45382. * The list of sounds used in the scene.
  45383. */
  45384. sounds: Nullable<Array<Sound>>;
  45385. }
  45386. interface Scene {
  45387. /**
  45388. * @hidden
  45389. * Backing field
  45390. */
  45391. _mainSoundTrack: SoundTrack;
  45392. /**
  45393. * The main sound track played by the scene.
  45394. * It cotains your primary collection of sounds.
  45395. */
  45396. mainSoundTrack: SoundTrack;
  45397. /**
  45398. * The list of sound tracks added to the scene
  45399. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45400. */
  45401. soundTracks: Nullable<Array<SoundTrack>>;
  45402. /**
  45403. * Gets a sound using a given name
  45404. * @param name defines the name to search for
  45405. * @return the found sound or null if not found at all.
  45406. */
  45407. getSoundByName(name: string): Nullable<Sound>;
  45408. /**
  45409. * Gets or sets if audio support is enabled
  45410. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45411. */
  45412. audioEnabled: boolean;
  45413. /**
  45414. * Gets or sets if audio will be output to headphones
  45415. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45416. */
  45417. headphone: boolean;
  45418. /**
  45419. * Gets or sets custom audio listener position provider
  45420. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45421. */
  45422. audioListenerPositionProvider: Nullable<() => Vector3>;
  45423. /**
  45424. * Gets or sets a refresh rate when using 3D audio positioning
  45425. */
  45426. audioPositioningRefreshRate: number;
  45427. }
  45428. /**
  45429. * Defines the sound scene component responsible to manage any sounds
  45430. * in a given scene.
  45431. */
  45432. export class AudioSceneComponent implements ISceneSerializableComponent {
  45433. private static _CameraDirectionLH;
  45434. private static _CameraDirectionRH;
  45435. /**
  45436. * The component name helpfull to identify the component in the list of scene components.
  45437. */
  45438. readonly name: string;
  45439. /**
  45440. * The scene the component belongs to.
  45441. */
  45442. scene: Scene;
  45443. private _audioEnabled;
  45444. /**
  45445. * Gets whether audio is enabled or not.
  45446. * Please use related enable/disable method to switch state.
  45447. */
  45448. get audioEnabled(): boolean;
  45449. private _headphone;
  45450. /**
  45451. * Gets whether audio is outputing to headphone or not.
  45452. * Please use the according Switch methods to change output.
  45453. */
  45454. get headphone(): boolean;
  45455. /**
  45456. * Gets or sets a refresh rate when using 3D audio positioning
  45457. */
  45458. audioPositioningRefreshRate: number;
  45459. private _audioListenerPositionProvider;
  45460. /**
  45461. * Gets the current audio listener position provider
  45462. */
  45463. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  45464. /**
  45465. * Sets a custom listener position for all sounds in the scene
  45466. * By default, this is the position of the first active camera
  45467. */
  45468. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  45469. /**
  45470. * Creates a new instance of the component for the given scene
  45471. * @param scene Defines the scene to register the component in
  45472. */
  45473. constructor(scene: Scene);
  45474. /**
  45475. * Registers the component in a given scene
  45476. */
  45477. register(): void;
  45478. /**
  45479. * Rebuilds the elements related to this component in case of
  45480. * context lost for instance.
  45481. */
  45482. rebuild(): void;
  45483. /**
  45484. * Serializes the component data to the specified json object
  45485. * @param serializationObject The object to serialize to
  45486. */
  45487. serialize(serializationObject: any): void;
  45488. /**
  45489. * Adds all the elements from the container to the scene
  45490. * @param container the container holding the elements
  45491. */
  45492. addFromContainer(container: AbstractScene): void;
  45493. /**
  45494. * Removes all the elements in the container from the scene
  45495. * @param container contains the elements to remove
  45496. * @param dispose if the removed element should be disposed (default: false)
  45497. */
  45498. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  45499. /**
  45500. * Disposes the component and the associated ressources.
  45501. */
  45502. dispose(): void;
  45503. /**
  45504. * Disables audio in the associated scene.
  45505. */
  45506. disableAudio(): void;
  45507. /**
  45508. * Enables audio in the associated scene.
  45509. */
  45510. enableAudio(): void;
  45511. /**
  45512. * Switch audio to headphone output.
  45513. */
  45514. switchAudioModeForHeadphones(): void;
  45515. /**
  45516. * Switch audio to normal speakers.
  45517. */
  45518. switchAudioModeForNormalSpeakers(): void;
  45519. private _cachedCameraDirection;
  45520. private _cachedCameraPosition;
  45521. private _lastCheck;
  45522. private _afterRender;
  45523. }
  45524. }
  45525. declare module BABYLON {
  45526. /**
  45527. * Wraps one or more Sound objects and selects one with random weight for playback.
  45528. */
  45529. export class WeightedSound {
  45530. /** When true a Sound will be selected and played when the current playing Sound completes. */
  45531. loop: boolean;
  45532. private _coneInnerAngle;
  45533. private _coneOuterAngle;
  45534. private _volume;
  45535. /** A Sound is currently playing. */
  45536. isPlaying: boolean;
  45537. /** A Sound is currently paused. */
  45538. isPaused: boolean;
  45539. private _sounds;
  45540. private _weights;
  45541. private _currentIndex?;
  45542. /**
  45543. * Creates a new WeightedSound from the list of sounds given.
  45544. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  45545. * @param sounds Array of Sounds that will be selected from.
  45546. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  45547. */
  45548. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  45549. /**
  45550. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  45551. */
  45552. get directionalConeInnerAngle(): number;
  45553. /**
  45554. * The size of cone in degress for a directional sound in which there will be no attenuation.
  45555. */
  45556. set directionalConeInnerAngle(value: number);
  45557. /**
  45558. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  45559. * Listener angles between innerAngle and outerAngle will falloff linearly.
  45560. */
  45561. get directionalConeOuterAngle(): number;
  45562. /**
  45563. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  45564. * Listener angles between innerAngle and outerAngle will falloff linearly.
  45565. */
  45566. set directionalConeOuterAngle(value: number);
  45567. /**
  45568. * Playback volume.
  45569. */
  45570. get volume(): number;
  45571. /**
  45572. * Playback volume.
  45573. */
  45574. set volume(value: number);
  45575. private _onended;
  45576. /**
  45577. * Suspend playback
  45578. */
  45579. pause(): void;
  45580. /**
  45581. * Stop playback
  45582. */
  45583. stop(): void;
  45584. /**
  45585. * Start playback.
  45586. * @param startOffset Position the clip head at a specific time in seconds.
  45587. */
  45588. play(startOffset?: number): void;
  45589. }
  45590. }
  45591. declare module BABYLON {
  45592. /**
  45593. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  45594. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  45595. */
  45596. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  45597. /**
  45598. * Gets the name of the behavior.
  45599. */
  45600. get name(): string;
  45601. /**
  45602. * The easing function used by animations
  45603. */
  45604. static EasingFunction: BackEase;
  45605. /**
  45606. * The easing mode used by animations
  45607. */
  45608. static EasingMode: number;
  45609. /**
  45610. * The duration of the animation, in milliseconds
  45611. */
  45612. transitionDuration: number;
  45613. /**
  45614. * Length of the distance animated by the transition when lower radius is reached
  45615. */
  45616. lowerRadiusTransitionRange: number;
  45617. /**
  45618. * Length of the distance animated by the transition when upper radius is reached
  45619. */
  45620. upperRadiusTransitionRange: number;
  45621. private _autoTransitionRange;
  45622. /**
  45623. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  45624. */
  45625. get autoTransitionRange(): boolean;
  45626. /**
  45627. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  45628. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  45629. */
  45630. set autoTransitionRange(value: boolean);
  45631. private _attachedCamera;
  45632. private _onAfterCheckInputsObserver;
  45633. private _onMeshTargetChangedObserver;
  45634. /**
  45635. * Initializes the behavior.
  45636. */
  45637. init(): void;
  45638. /**
  45639. * Attaches the behavior to its arc rotate camera.
  45640. * @param camera Defines the camera to attach the behavior to
  45641. */
  45642. attach(camera: ArcRotateCamera): void;
  45643. /**
  45644. * Detaches the behavior from its current arc rotate camera.
  45645. */
  45646. detach(): void;
  45647. private _radiusIsAnimating;
  45648. private _radiusBounceTransition;
  45649. private _animatables;
  45650. private _cachedWheelPrecision;
  45651. /**
  45652. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  45653. * @param radiusLimit The limit to check against.
  45654. * @return Bool to indicate if at limit.
  45655. */
  45656. private _isRadiusAtLimit;
  45657. /**
  45658. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  45659. * @param radiusDelta The delta by which to animate to. Can be negative.
  45660. */
  45661. private _applyBoundRadiusAnimation;
  45662. /**
  45663. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  45664. */
  45665. protected _clearAnimationLocks(): void;
  45666. /**
  45667. * Stops and removes all animations that have been applied to the camera
  45668. */
  45669. stopAllAnimations(): void;
  45670. }
  45671. }
  45672. declare module BABYLON {
  45673. /**
  45674. * 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.
  45675. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  45676. */
  45677. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  45678. /**
  45679. * Gets the name of the behavior.
  45680. */
  45681. get name(): string;
  45682. private _mode;
  45683. private _radiusScale;
  45684. private _positionScale;
  45685. private _defaultElevation;
  45686. private _elevationReturnTime;
  45687. private _elevationReturnWaitTime;
  45688. private _zoomStopsAnimation;
  45689. private _framingTime;
  45690. /**
  45691. * The easing function used by animations
  45692. */
  45693. static EasingFunction: ExponentialEase;
  45694. /**
  45695. * The easing mode used by animations
  45696. */
  45697. static EasingMode: number;
  45698. /**
  45699. * Sets the current mode used by the behavior
  45700. */
  45701. set mode(mode: number);
  45702. /**
  45703. * Gets current mode used by the behavior.
  45704. */
  45705. get mode(): number;
  45706. /**
  45707. * Sets the scale applied to the radius (1 by default)
  45708. */
  45709. set radiusScale(radius: number);
  45710. /**
  45711. * Gets the scale applied to the radius
  45712. */
  45713. get radiusScale(): number;
  45714. /**
  45715. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  45716. */
  45717. set positionScale(scale: number);
  45718. /**
  45719. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  45720. */
  45721. get positionScale(): number;
  45722. /**
  45723. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  45724. * behaviour is triggered, in radians.
  45725. */
  45726. set defaultElevation(elevation: number);
  45727. /**
  45728. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  45729. * behaviour is triggered, in radians.
  45730. */
  45731. get defaultElevation(): number;
  45732. /**
  45733. * Sets the time (in milliseconds) taken to return to the default beta position.
  45734. * Negative value indicates camera should not return to default.
  45735. */
  45736. set elevationReturnTime(speed: number);
  45737. /**
  45738. * Gets the time (in milliseconds) taken to return to the default beta position.
  45739. * Negative value indicates camera should not return to default.
  45740. */
  45741. get elevationReturnTime(): number;
  45742. /**
  45743. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  45744. */
  45745. set elevationReturnWaitTime(time: number);
  45746. /**
  45747. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  45748. */
  45749. get elevationReturnWaitTime(): number;
  45750. /**
  45751. * Sets the flag that indicates if user zooming should stop animation.
  45752. */
  45753. set zoomStopsAnimation(flag: boolean);
  45754. /**
  45755. * Gets the flag that indicates if user zooming should stop animation.
  45756. */
  45757. get zoomStopsAnimation(): boolean;
  45758. /**
  45759. * Sets the transition time when framing the mesh, in milliseconds
  45760. */
  45761. set framingTime(time: number);
  45762. /**
  45763. * Gets the transition time when framing the mesh, in milliseconds
  45764. */
  45765. get framingTime(): number;
  45766. /**
  45767. * Define if the behavior should automatically change the configured
  45768. * camera limits and sensibilities.
  45769. */
  45770. autoCorrectCameraLimitsAndSensibility: boolean;
  45771. private _onPrePointerObservableObserver;
  45772. private _onAfterCheckInputsObserver;
  45773. private _onMeshTargetChangedObserver;
  45774. private _attachedCamera;
  45775. private _isPointerDown;
  45776. private _lastInteractionTime;
  45777. /**
  45778. * Initializes the behavior.
  45779. */
  45780. init(): void;
  45781. /**
  45782. * Attaches the behavior to its arc rotate camera.
  45783. * @param camera Defines the camera to attach the behavior to
  45784. */
  45785. attach(camera: ArcRotateCamera): void;
  45786. /**
  45787. * Detaches the behavior from its current arc rotate camera.
  45788. */
  45789. detach(): void;
  45790. private _animatables;
  45791. private _betaIsAnimating;
  45792. private _betaTransition;
  45793. private _radiusTransition;
  45794. private _vectorTransition;
  45795. /**
  45796. * Targets the given mesh and updates zoom level accordingly.
  45797. * @param mesh The mesh to target.
  45798. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45799. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45800. */
  45801. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45802. /**
  45803. * Targets the given mesh with its children and updates zoom level accordingly.
  45804. * @param mesh The mesh to target.
  45805. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45806. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45807. */
  45808. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45809. /**
  45810. * Targets the given meshes with their children and updates zoom level accordingly.
  45811. * @param meshes The mesh to target.
  45812. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45813. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45814. */
  45815. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45816. /**
  45817. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  45818. * @param minimumWorld Determines the smaller position of the bounding box extend
  45819. * @param maximumWorld Determines the bigger position of the bounding box extend
  45820. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45821. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45822. */
  45823. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45824. /**
  45825. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  45826. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  45827. * frustum width.
  45828. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  45829. * to fully enclose the mesh in the viewing frustum.
  45830. */
  45831. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  45832. /**
  45833. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  45834. * is automatically returned to its default position (expected to be above ground plane).
  45835. */
  45836. private _maintainCameraAboveGround;
  45837. /**
  45838. * Returns the frustum slope based on the canvas ratio and camera FOV
  45839. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  45840. */
  45841. private _getFrustumSlope;
  45842. /**
  45843. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  45844. */
  45845. private _clearAnimationLocks;
  45846. /**
  45847. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  45848. */
  45849. private _applyUserInteraction;
  45850. /**
  45851. * Stops and removes all animations that have been applied to the camera
  45852. */
  45853. stopAllAnimations(): void;
  45854. /**
  45855. * Gets a value indicating if the user is moving the camera
  45856. */
  45857. get isUserIsMoving(): boolean;
  45858. /**
  45859. * The camera can move all the way towards the mesh.
  45860. */
  45861. static IgnoreBoundsSizeMode: number;
  45862. /**
  45863. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  45864. */
  45865. static FitFrustumSidesMode: number;
  45866. }
  45867. }
  45868. declare module BABYLON {
  45869. /**
  45870. * Base class for Camera Pointer Inputs.
  45871. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  45872. * for example usage.
  45873. */
  45874. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  45875. /**
  45876. * Defines the camera the input is attached to.
  45877. */
  45878. abstract camera: Camera;
  45879. /**
  45880. * Whether keyboard modifier keys are pressed at time of last mouse event.
  45881. */
  45882. protected _altKey: boolean;
  45883. protected _ctrlKey: boolean;
  45884. protected _metaKey: boolean;
  45885. protected _shiftKey: boolean;
  45886. /**
  45887. * Which mouse buttons were pressed at time of last mouse event.
  45888. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  45889. */
  45890. protected _buttonsPressed: number;
  45891. /**
  45892. * Defines the buttons associated with the input to handle camera move.
  45893. */
  45894. buttons: number[];
  45895. /**
  45896. * Attach the input controls to a specific dom element to get the input from.
  45897. * @param element Defines the element the controls should be listened from
  45898. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45899. */
  45900. attachControl(noPreventDefault?: boolean): void;
  45901. /**
  45902. * Detach the current controls from the specified dom element.
  45903. */
  45904. detachControl(): void;
  45905. /**
  45906. * Gets the class name of the current input.
  45907. * @returns the class name
  45908. */
  45909. getClassName(): string;
  45910. /**
  45911. * Get the friendly name associated with the input class.
  45912. * @returns the input friendly name
  45913. */
  45914. getSimpleName(): string;
  45915. /**
  45916. * Called on pointer POINTERDOUBLETAP event.
  45917. * Override this method to provide functionality on POINTERDOUBLETAP event.
  45918. */
  45919. protected onDoubleTap(type: string): void;
  45920. /**
  45921. * Called on pointer POINTERMOVE event if only a single touch is active.
  45922. * Override this method to provide functionality.
  45923. */
  45924. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  45925. /**
  45926. * Called on pointer POINTERMOVE event if multiple touches are active.
  45927. * Override this method to provide functionality.
  45928. */
  45929. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  45930. /**
  45931. * Called on JS contextmenu event.
  45932. * Override this method to provide functionality.
  45933. */
  45934. protected onContextMenu(evt: PointerEvent): void;
  45935. /**
  45936. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  45937. * press.
  45938. * Override this method to provide functionality.
  45939. */
  45940. protected onButtonDown(evt: PointerEvent): void;
  45941. /**
  45942. * Called each time a new POINTERUP event occurs. Ie, for each button
  45943. * release.
  45944. * Override this method to provide functionality.
  45945. */
  45946. protected onButtonUp(evt: PointerEvent): void;
  45947. /**
  45948. * Called when window becomes inactive.
  45949. * Override this method to provide functionality.
  45950. */
  45951. protected onLostFocus(): void;
  45952. private _pointerInput;
  45953. private _observer;
  45954. private _onLostFocus;
  45955. private pointA;
  45956. private pointB;
  45957. }
  45958. }
  45959. declare module BABYLON {
  45960. /**
  45961. * Manage the pointers inputs to control an arc rotate camera.
  45962. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45963. */
  45964. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  45965. /**
  45966. * Defines the camera the input is attached to.
  45967. */
  45968. camera: ArcRotateCamera;
  45969. /**
  45970. * Gets the class name of the current input.
  45971. * @returns the class name
  45972. */
  45973. getClassName(): string;
  45974. /**
  45975. * Defines the buttons associated with the input to handle camera move.
  45976. */
  45977. buttons: number[];
  45978. /**
  45979. * Defines the pointer angular sensibility along the X axis or how fast is
  45980. * the camera rotating.
  45981. */
  45982. angularSensibilityX: number;
  45983. /**
  45984. * Defines the pointer angular sensibility along the Y axis or how fast is
  45985. * the camera rotating.
  45986. */
  45987. angularSensibilityY: number;
  45988. /**
  45989. * Defines the pointer pinch precision or how fast is the camera zooming.
  45990. */
  45991. pinchPrecision: number;
  45992. /**
  45993. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  45994. * from 0.
  45995. * It defines the percentage of current camera.radius to use as delta when
  45996. * pinch zoom is used.
  45997. */
  45998. pinchDeltaPercentage: number;
  45999. /**
  46000. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  46001. * that any object in the plane at the camera's target point will scale
  46002. * perfectly with finger motion.
  46003. * Overrides pinchDeltaPercentage and pinchPrecision.
  46004. */
  46005. useNaturalPinchZoom: boolean;
  46006. /**
  46007. * Defines the pointer panning sensibility or how fast is the camera moving.
  46008. */
  46009. panningSensibility: number;
  46010. /**
  46011. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  46012. */
  46013. multiTouchPanning: boolean;
  46014. /**
  46015. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  46016. * zoom (pinch) through multitouch.
  46017. */
  46018. multiTouchPanAndZoom: boolean;
  46019. /**
  46020. * Revers pinch action direction.
  46021. */
  46022. pinchInwards: boolean;
  46023. private _isPanClick;
  46024. private _twoFingerActivityCount;
  46025. private _isPinching;
  46026. /**
  46027. * Called on pointer POINTERMOVE event if only a single touch is active.
  46028. */
  46029. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  46030. /**
  46031. * Called on pointer POINTERDOUBLETAP event.
  46032. */
  46033. protected onDoubleTap(type: string): void;
  46034. /**
  46035. * Called on pointer POINTERMOVE event if multiple touches are active.
  46036. */
  46037. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  46038. /**
  46039. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  46040. * press.
  46041. */
  46042. protected onButtonDown(evt: PointerEvent): void;
  46043. /**
  46044. * Called each time a new POINTERUP event occurs. Ie, for each button
  46045. * release.
  46046. */
  46047. protected onButtonUp(evt: PointerEvent): void;
  46048. /**
  46049. * Called when window becomes inactive.
  46050. */
  46051. protected onLostFocus(): void;
  46052. }
  46053. }
  46054. declare module BABYLON {
  46055. /**
  46056. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  46057. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46058. */
  46059. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  46060. /**
  46061. * Defines the camera the input is attached to.
  46062. */
  46063. camera: ArcRotateCamera;
  46064. /**
  46065. * Defines the list of key codes associated with the up action (increase alpha)
  46066. */
  46067. keysUp: number[];
  46068. /**
  46069. * Defines the list of key codes associated with the down action (decrease alpha)
  46070. */
  46071. keysDown: number[];
  46072. /**
  46073. * Defines the list of key codes associated with the left action (increase beta)
  46074. */
  46075. keysLeft: number[];
  46076. /**
  46077. * Defines the list of key codes associated with the right action (decrease beta)
  46078. */
  46079. keysRight: number[];
  46080. /**
  46081. * Defines the list of key codes associated with the reset action.
  46082. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  46083. */
  46084. keysReset: number[];
  46085. /**
  46086. * Defines the panning sensibility of the inputs.
  46087. * (How fast is the camera panning)
  46088. */
  46089. panningSensibility: number;
  46090. /**
  46091. * Defines the zooming sensibility of the inputs.
  46092. * (How fast is the camera zooming)
  46093. */
  46094. zoomingSensibility: number;
  46095. /**
  46096. * Defines whether maintaining the alt key down switch the movement mode from
  46097. * orientation to zoom.
  46098. */
  46099. useAltToZoom: boolean;
  46100. /**
  46101. * Rotation speed of the camera
  46102. */
  46103. angularSpeed: number;
  46104. private _keys;
  46105. private _ctrlPressed;
  46106. private _altPressed;
  46107. private _onCanvasBlurObserver;
  46108. private _onKeyboardObserver;
  46109. private _engine;
  46110. private _scene;
  46111. /**
  46112. * Attach the input controls to a specific dom element to get the input from.
  46113. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46114. */
  46115. attachControl(noPreventDefault?: boolean): void;
  46116. /**
  46117. * Detach the current controls from the specified dom element.
  46118. */
  46119. detachControl(): void;
  46120. /**
  46121. * Update the current camera state depending on the inputs that have been used this frame.
  46122. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46123. */
  46124. checkInputs(): void;
  46125. /**
  46126. * Gets the class name of the current intput.
  46127. * @returns the class name
  46128. */
  46129. getClassName(): string;
  46130. /**
  46131. * Get the friendly name associated with the input class.
  46132. * @returns the input friendly name
  46133. */
  46134. getSimpleName(): string;
  46135. }
  46136. }
  46137. declare module BABYLON {
  46138. /**
  46139. * Manage the mouse wheel inputs to control an arc rotate camera.
  46140. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46141. */
  46142. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  46143. /**
  46144. * Defines the camera the input is attached to.
  46145. */
  46146. camera: ArcRotateCamera;
  46147. /**
  46148. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  46149. */
  46150. wheelPrecision: number;
  46151. /**
  46152. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  46153. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  46154. */
  46155. wheelDeltaPercentage: number;
  46156. private _wheel;
  46157. private _observer;
  46158. private computeDeltaFromMouseWheelLegacyEvent;
  46159. /**
  46160. * Attach the input controls to a specific dom element to get the input from.
  46161. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46162. */
  46163. attachControl(noPreventDefault?: boolean): void;
  46164. /**
  46165. * Detach the current controls from the specified dom element.
  46166. */
  46167. detachControl(): void;
  46168. /**
  46169. * Gets the class name of the current intput.
  46170. * @returns the class name
  46171. */
  46172. getClassName(): string;
  46173. /**
  46174. * Get the friendly name associated with the input class.
  46175. * @returns the input friendly name
  46176. */
  46177. getSimpleName(): string;
  46178. }
  46179. }
  46180. declare module BABYLON {
  46181. /**
  46182. * Default Inputs manager for the ArcRotateCamera.
  46183. * It groups all the default supported inputs for ease of use.
  46184. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46185. */
  46186. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  46187. /**
  46188. * Instantiates a new ArcRotateCameraInputsManager.
  46189. * @param camera Defines the camera the inputs belong to
  46190. */
  46191. constructor(camera: ArcRotateCamera);
  46192. /**
  46193. * Add mouse wheel input support to the input manager.
  46194. * @returns the current input manager
  46195. */
  46196. addMouseWheel(): ArcRotateCameraInputsManager;
  46197. /**
  46198. * Add pointers input support to the input manager.
  46199. * @returns the current input manager
  46200. */
  46201. addPointers(): ArcRotateCameraInputsManager;
  46202. /**
  46203. * Add keyboard input support to the input manager.
  46204. * @returns the current input manager
  46205. */
  46206. addKeyboard(): ArcRotateCameraInputsManager;
  46207. }
  46208. }
  46209. declare module BABYLON {
  46210. /**
  46211. * This represents an orbital type of camera.
  46212. *
  46213. * 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.
  46214. * 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.
  46215. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  46216. */
  46217. export class ArcRotateCamera extends TargetCamera {
  46218. /**
  46219. * Defines the rotation angle of the camera along the longitudinal axis.
  46220. */
  46221. alpha: number;
  46222. /**
  46223. * Defines the rotation angle of the camera along the latitudinal axis.
  46224. */
  46225. beta: number;
  46226. /**
  46227. * Defines the radius of the camera from it s target point.
  46228. */
  46229. radius: number;
  46230. protected _target: Vector3;
  46231. protected _targetHost: Nullable<AbstractMesh>;
  46232. /**
  46233. * Defines the target point of the camera.
  46234. * The camera looks towards it form the radius distance.
  46235. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  46236. */
  46237. get target(): Vector3;
  46238. set target(value: Vector3);
  46239. /**
  46240. * Define the current local position of the camera in the scene
  46241. */
  46242. get position(): Vector3;
  46243. set position(newPosition: Vector3);
  46244. protected _upToYMatrix: Matrix;
  46245. protected _YToUpMatrix: Matrix;
  46246. /**
  46247. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  46248. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  46249. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  46250. */
  46251. set upVector(vec: Vector3);
  46252. get upVector(): Vector3;
  46253. /**
  46254. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  46255. */
  46256. setMatUp(): void;
  46257. /**
  46258. * Current inertia value on the longitudinal axis.
  46259. * The bigger this number the longer it will take for the camera to stop.
  46260. */
  46261. inertialAlphaOffset: number;
  46262. /**
  46263. * Current inertia value on the latitudinal axis.
  46264. * The bigger this number the longer it will take for the camera to stop.
  46265. */
  46266. inertialBetaOffset: number;
  46267. /**
  46268. * Current inertia value on the radius axis.
  46269. * The bigger this number the longer it will take for the camera to stop.
  46270. */
  46271. inertialRadiusOffset: number;
  46272. /**
  46273. * Minimum allowed angle on the longitudinal axis.
  46274. * This can help limiting how the Camera is able to move in the scene.
  46275. */
  46276. lowerAlphaLimit: Nullable<number>;
  46277. /**
  46278. * Maximum allowed angle on the longitudinal axis.
  46279. * This can help limiting how the Camera is able to move in the scene.
  46280. */
  46281. upperAlphaLimit: Nullable<number>;
  46282. /**
  46283. * Minimum allowed angle on the latitudinal axis.
  46284. * This can help limiting how the Camera is able to move in the scene.
  46285. */
  46286. lowerBetaLimit: number;
  46287. /**
  46288. * Maximum allowed angle on the latitudinal axis.
  46289. * This can help limiting how the Camera is able to move in the scene.
  46290. */
  46291. upperBetaLimit: number;
  46292. /**
  46293. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  46294. * This can help limiting how the Camera is able to move in the scene.
  46295. */
  46296. lowerRadiusLimit: Nullable<number>;
  46297. /**
  46298. * Maximum allowed distance of the camera to the target (The camera can not get further).
  46299. * This can help limiting how the Camera is able to move in the scene.
  46300. */
  46301. upperRadiusLimit: Nullable<number>;
  46302. /**
  46303. * Defines the current inertia value used during panning of the camera along the X axis.
  46304. */
  46305. inertialPanningX: number;
  46306. /**
  46307. * Defines the current inertia value used during panning of the camera along the Y axis.
  46308. */
  46309. inertialPanningY: number;
  46310. /**
  46311. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  46312. * Basically if your fingers moves away from more than this distance you will be considered
  46313. * in pinch mode.
  46314. */
  46315. pinchToPanMaxDistance: number;
  46316. /**
  46317. * Defines the maximum distance the camera can pan.
  46318. * This could help keeping the cammera always in your scene.
  46319. */
  46320. panningDistanceLimit: Nullable<number>;
  46321. /**
  46322. * Defines the target of the camera before paning.
  46323. */
  46324. panningOriginTarget: Vector3;
  46325. /**
  46326. * Defines the value of the inertia used during panning.
  46327. * 0 would mean stop inertia and one would mean no decelleration at all.
  46328. */
  46329. panningInertia: number;
  46330. /**
  46331. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  46332. */
  46333. get angularSensibilityX(): number;
  46334. set angularSensibilityX(value: number);
  46335. /**
  46336. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  46337. */
  46338. get angularSensibilityY(): number;
  46339. set angularSensibilityY(value: number);
  46340. /**
  46341. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  46342. */
  46343. get pinchPrecision(): number;
  46344. set pinchPrecision(value: number);
  46345. /**
  46346. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  46347. * It will be used instead of pinchDeltaPrecision if different from 0.
  46348. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  46349. */
  46350. get pinchDeltaPercentage(): number;
  46351. set pinchDeltaPercentage(value: number);
  46352. /**
  46353. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  46354. * and pinch delta percentage.
  46355. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  46356. * that any object in the plane at the camera's target point will scale
  46357. * perfectly with finger motion.
  46358. */
  46359. get useNaturalPinchZoom(): boolean;
  46360. set useNaturalPinchZoom(value: boolean);
  46361. /**
  46362. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  46363. */
  46364. get panningSensibility(): number;
  46365. set panningSensibility(value: number);
  46366. /**
  46367. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  46368. */
  46369. get keysUp(): number[];
  46370. set keysUp(value: number[]);
  46371. /**
  46372. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  46373. */
  46374. get keysDown(): number[];
  46375. set keysDown(value: number[]);
  46376. /**
  46377. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  46378. */
  46379. get keysLeft(): number[];
  46380. set keysLeft(value: number[]);
  46381. /**
  46382. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  46383. */
  46384. get keysRight(): number[];
  46385. set keysRight(value: number[]);
  46386. /**
  46387. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  46388. */
  46389. get wheelPrecision(): number;
  46390. set wheelPrecision(value: number);
  46391. /**
  46392. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  46393. * It will be used instead of pinchDeltaPrecision if different from 0.
  46394. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  46395. */
  46396. get wheelDeltaPercentage(): number;
  46397. set wheelDeltaPercentage(value: number);
  46398. /**
  46399. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  46400. */
  46401. zoomOnFactor: number;
  46402. /**
  46403. * Defines a screen offset for the camera position.
  46404. */
  46405. targetScreenOffset: Vector2;
  46406. /**
  46407. * Allows the camera to be completely reversed.
  46408. * If false the camera can not arrive upside down.
  46409. */
  46410. allowUpsideDown: boolean;
  46411. /**
  46412. * Define if double tap/click is used to restore the previously saved state of the camera.
  46413. */
  46414. useInputToRestoreState: boolean;
  46415. /** @hidden */
  46416. _viewMatrix: Matrix;
  46417. /** @hidden */
  46418. _useCtrlForPanning: boolean;
  46419. /** @hidden */
  46420. _panningMouseButton: number;
  46421. /**
  46422. * Defines the input associated to the camera.
  46423. */
  46424. inputs: ArcRotateCameraInputsManager;
  46425. /** @hidden */
  46426. _reset: () => void;
  46427. /**
  46428. * Defines the allowed panning axis.
  46429. */
  46430. panningAxis: Vector3;
  46431. protected _localDirection: Vector3;
  46432. protected _transformedDirection: Vector3;
  46433. private _bouncingBehavior;
  46434. /**
  46435. * Gets the bouncing behavior of the camera if it has been enabled.
  46436. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46437. */
  46438. get bouncingBehavior(): Nullable<BouncingBehavior>;
  46439. /**
  46440. * Defines if the bouncing behavior of the camera is enabled on the camera.
  46441. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46442. */
  46443. get useBouncingBehavior(): boolean;
  46444. set useBouncingBehavior(value: boolean);
  46445. private _framingBehavior;
  46446. /**
  46447. * Gets the framing behavior of the camera if it has been enabled.
  46448. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46449. */
  46450. get framingBehavior(): Nullable<FramingBehavior>;
  46451. /**
  46452. * Defines if the framing behavior of the camera is enabled on the camera.
  46453. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46454. */
  46455. get useFramingBehavior(): boolean;
  46456. set useFramingBehavior(value: boolean);
  46457. private _autoRotationBehavior;
  46458. /**
  46459. * Gets the auto rotation behavior of the camera if it has been enabled.
  46460. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46461. */
  46462. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  46463. /**
  46464. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  46465. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46466. */
  46467. get useAutoRotationBehavior(): boolean;
  46468. set useAutoRotationBehavior(value: boolean);
  46469. /**
  46470. * Observable triggered when the mesh target has been changed on the camera.
  46471. */
  46472. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  46473. /**
  46474. * Event raised when the camera is colliding with a mesh.
  46475. */
  46476. onCollide: (collidedMesh: AbstractMesh) => void;
  46477. /**
  46478. * Defines whether the camera should check collision with the objects oh the scene.
  46479. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  46480. */
  46481. checkCollisions: boolean;
  46482. /**
  46483. * Defines the collision radius of the camera.
  46484. * This simulates a sphere around the camera.
  46485. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  46486. */
  46487. collisionRadius: Vector3;
  46488. protected _collider: Collider;
  46489. protected _previousPosition: Vector3;
  46490. protected _collisionVelocity: Vector3;
  46491. protected _newPosition: Vector3;
  46492. protected _previousAlpha: number;
  46493. protected _previousBeta: number;
  46494. protected _previousRadius: number;
  46495. protected _collisionTriggered: boolean;
  46496. protected _targetBoundingCenter: Nullable<Vector3>;
  46497. private _computationVector;
  46498. /**
  46499. * Instantiates a new ArcRotateCamera in a given scene
  46500. * @param name Defines the name of the camera
  46501. * @param alpha Defines the camera rotation along the logitudinal axis
  46502. * @param beta Defines the camera rotation along the latitudinal axis
  46503. * @param radius Defines the camera distance from its target
  46504. * @param target Defines the camera target
  46505. * @param scene Defines the scene the camera belongs to
  46506. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  46507. */
  46508. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  46509. /** @hidden */
  46510. _initCache(): void;
  46511. /** @hidden */
  46512. _updateCache(ignoreParentClass?: boolean): void;
  46513. protected _getTargetPosition(): Vector3;
  46514. private _storedAlpha;
  46515. private _storedBeta;
  46516. private _storedRadius;
  46517. private _storedTarget;
  46518. private _storedTargetScreenOffset;
  46519. /**
  46520. * Stores the current state of the camera (alpha, beta, radius and target)
  46521. * @returns the camera itself
  46522. */
  46523. storeState(): Camera;
  46524. /**
  46525. * @hidden
  46526. * Restored camera state. You must call storeState() first
  46527. */
  46528. _restoreStateValues(): boolean;
  46529. /** @hidden */
  46530. _isSynchronizedViewMatrix(): boolean;
  46531. /**
  46532. * Attached controls to the current camera.
  46533. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46534. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  46535. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  46536. */
  46537. attachControl(noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  46538. /**
  46539. * Detach the current controls from the camera.
  46540. * The camera will stop reacting to inputs.
  46541. */
  46542. detachControl(): void;
  46543. /** @hidden */
  46544. _checkInputs(): void;
  46545. protected _checkLimits(): void;
  46546. /**
  46547. * Rebuilds angles (alpha, beta) and radius from the give position and target
  46548. */
  46549. rebuildAnglesAndRadius(): void;
  46550. /**
  46551. * Use a position to define the current camera related information like alpha, beta and radius
  46552. * @param position Defines the position to set the camera at
  46553. */
  46554. setPosition(position: Vector3): void;
  46555. /**
  46556. * Defines the target the camera should look at.
  46557. * This will automatically adapt alpha beta and radius to fit within the new target.
  46558. * @param target Defines the new target as a Vector or a mesh
  46559. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  46560. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  46561. */
  46562. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  46563. /** @hidden */
  46564. _getViewMatrix(): Matrix;
  46565. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  46566. /**
  46567. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  46568. * @param meshes Defines the mesh to zoom on
  46569. * @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)
  46570. */
  46571. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  46572. /**
  46573. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  46574. * The target will be changed but the radius
  46575. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  46576. * @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)
  46577. */
  46578. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  46579. min: Vector3;
  46580. max: Vector3;
  46581. distance: number;
  46582. }, doNotUpdateMaxZ?: boolean): void;
  46583. /**
  46584. * @override
  46585. * Override Camera.createRigCamera
  46586. */
  46587. createRigCamera(name: string, cameraIndex: number): Camera;
  46588. /**
  46589. * @hidden
  46590. * @override
  46591. * Override Camera._updateRigCameras
  46592. */
  46593. _updateRigCameras(): void;
  46594. /**
  46595. * Destroy the camera and release the current resources hold by it.
  46596. */
  46597. dispose(): void;
  46598. /**
  46599. * Gets the current object class name.
  46600. * @return the class name
  46601. */
  46602. getClassName(): string;
  46603. }
  46604. }
  46605. declare module BABYLON {
  46606. /**
  46607. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  46608. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46609. */
  46610. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  46611. /**
  46612. * Gets the name of the behavior.
  46613. */
  46614. get name(): string;
  46615. private _zoomStopsAnimation;
  46616. private _idleRotationSpeed;
  46617. private _idleRotationWaitTime;
  46618. private _idleRotationSpinupTime;
  46619. /**
  46620. * Sets the flag that indicates if user zooming should stop animation.
  46621. */
  46622. set zoomStopsAnimation(flag: boolean);
  46623. /**
  46624. * Gets the flag that indicates if user zooming should stop animation.
  46625. */
  46626. get zoomStopsAnimation(): boolean;
  46627. /**
  46628. * Sets the default speed at which the camera rotates around the model.
  46629. */
  46630. set idleRotationSpeed(speed: number);
  46631. /**
  46632. * Gets the default speed at which the camera rotates around the model.
  46633. */
  46634. get idleRotationSpeed(): number;
  46635. /**
  46636. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  46637. */
  46638. set idleRotationWaitTime(time: number);
  46639. /**
  46640. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  46641. */
  46642. get idleRotationWaitTime(): number;
  46643. /**
  46644. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  46645. */
  46646. set idleRotationSpinupTime(time: number);
  46647. /**
  46648. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  46649. */
  46650. get idleRotationSpinupTime(): number;
  46651. /**
  46652. * Gets a value indicating if the camera is currently rotating because of this behavior
  46653. */
  46654. get rotationInProgress(): boolean;
  46655. private _onPrePointerObservableObserver;
  46656. private _onAfterCheckInputsObserver;
  46657. private _attachedCamera;
  46658. private _isPointerDown;
  46659. private _lastFrameTime;
  46660. private _lastInteractionTime;
  46661. private _cameraRotationSpeed;
  46662. /**
  46663. * Initializes the behavior.
  46664. */
  46665. init(): void;
  46666. /**
  46667. * Attaches the behavior to its arc rotate camera.
  46668. * @param camera Defines the camera to attach the behavior to
  46669. */
  46670. attach(camera: ArcRotateCamera): void;
  46671. /**
  46672. * Detaches the behavior from its current arc rotate camera.
  46673. */
  46674. detach(): void;
  46675. /**
  46676. * Returns true if user is scrolling.
  46677. * @return true if user is scrolling.
  46678. */
  46679. private _userIsZooming;
  46680. private _lastFrameRadius;
  46681. private _shouldAnimationStopForInteraction;
  46682. /**
  46683. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  46684. */
  46685. private _applyUserInteraction;
  46686. private _userIsMoving;
  46687. }
  46688. }
  46689. declare module BABYLON {
  46690. /**
  46691. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  46692. */
  46693. export class AttachToBoxBehavior implements Behavior<Mesh> {
  46694. private ui;
  46695. /**
  46696. * The name of the behavior
  46697. */
  46698. name: string;
  46699. /**
  46700. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  46701. */
  46702. distanceAwayFromFace: number;
  46703. /**
  46704. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  46705. */
  46706. distanceAwayFromBottomOfFace: number;
  46707. private _faceVectors;
  46708. private _target;
  46709. private _scene;
  46710. private _onRenderObserver;
  46711. private _tmpMatrix;
  46712. private _tmpVector;
  46713. /**
  46714. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  46715. * @param ui The transform node that should be attched to the mesh
  46716. */
  46717. constructor(ui: TransformNode);
  46718. /**
  46719. * Initializes the behavior
  46720. */
  46721. init(): void;
  46722. private _closestFace;
  46723. private _zeroVector;
  46724. private _lookAtTmpMatrix;
  46725. private _lookAtToRef;
  46726. /**
  46727. * Attaches the AttachToBoxBehavior to the passed in mesh
  46728. * @param target The mesh that the specified node will be attached to
  46729. */
  46730. attach(target: Mesh): void;
  46731. /**
  46732. * Detaches the behavior from the mesh
  46733. */
  46734. detach(): void;
  46735. }
  46736. }
  46737. declare module BABYLON {
  46738. /**
  46739. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  46740. */
  46741. export class FadeInOutBehavior implements Behavior<Mesh> {
  46742. /**
  46743. * Time in milliseconds to delay before fading in (Default: 0)
  46744. */
  46745. delay: number;
  46746. /**
  46747. * Time in milliseconds for the mesh to fade in (Default: 300)
  46748. */
  46749. fadeInTime: number;
  46750. private _millisecondsPerFrame;
  46751. private _hovered;
  46752. private _hoverValue;
  46753. private _ownerNode;
  46754. /**
  46755. * Instatiates the FadeInOutBehavior
  46756. */
  46757. constructor();
  46758. /**
  46759. * The name of the behavior
  46760. */
  46761. get name(): string;
  46762. /**
  46763. * Initializes the behavior
  46764. */
  46765. init(): void;
  46766. /**
  46767. * Attaches the fade behavior on the passed in mesh
  46768. * @param ownerNode The mesh that will be faded in/out once attached
  46769. */
  46770. attach(ownerNode: Mesh): void;
  46771. /**
  46772. * Detaches the behavior from the mesh
  46773. */
  46774. detach(): void;
  46775. /**
  46776. * Triggers the mesh to begin fading in or out
  46777. * @param value if the object should fade in or out (true to fade in)
  46778. */
  46779. fadeIn(value: boolean): void;
  46780. private _update;
  46781. private _setAllVisibility;
  46782. }
  46783. }
  46784. declare module BABYLON {
  46785. /**
  46786. * Class containing a set of static utilities functions for managing Pivots
  46787. * @hidden
  46788. */
  46789. export class PivotTools {
  46790. private static _PivotCached;
  46791. private static _OldPivotPoint;
  46792. private static _PivotTranslation;
  46793. private static _PivotTmpVector;
  46794. private static _PivotPostMultiplyPivotMatrix;
  46795. /** @hidden */
  46796. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  46797. /** @hidden */
  46798. static _RestorePivotPoint(mesh: AbstractMesh): void;
  46799. }
  46800. }
  46801. declare module BABYLON {
  46802. /**
  46803. * Class containing static functions to help procedurally build meshes
  46804. */
  46805. export class PlaneBuilder {
  46806. /**
  46807. * Creates a plane mesh
  46808. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  46809. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  46810. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  46811. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46812. * * 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
  46813. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46814. * @param name defines the name of the mesh
  46815. * @param options defines the options used to create the mesh
  46816. * @param scene defines the hosting scene
  46817. * @returns the plane mesh
  46818. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  46819. */
  46820. static CreatePlane(name: string, options: {
  46821. size?: number;
  46822. width?: number;
  46823. height?: number;
  46824. sideOrientation?: number;
  46825. frontUVs?: Vector4;
  46826. backUVs?: Vector4;
  46827. updatable?: boolean;
  46828. sourcePlane?: Plane;
  46829. }, scene?: Nullable<Scene>): Mesh;
  46830. }
  46831. }
  46832. declare module BABYLON {
  46833. /**
  46834. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  46835. */
  46836. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  46837. private static _AnyMouseID;
  46838. /**
  46839. * Abstract mesh the behavior is set on
  46840. */
  46841. attachedNode: AbstractMesh;
  46842. private _dragPlane;
  46843. private _scene;
  46844. private _pointerObserver;
  46845. private _beforeRenderObserver;
  46846. private static _planeScene;
  46847. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  46848. /**
  46849. * 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)
  46850. */
  46851. maxDragAngle: number;
  46852. /**
  46853. * @hidden
  46854. */
  46855. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  46856. /**
  46857. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  46858. */
  46859. currentDraggingPointerID: number;
  46860. /**
  46861. * The last position where the pointer hit the drag plane in world space
  46862. */
  46863. lastDragPosition: Vector3;
  46864. /**
  46865. * If the behavior is currently in a dragging state
  46866. */
  46867. dragging: boolean;
  46868. /**
  46869. * 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)
  46870. */
  46871. dragDeltaRatio: number;
  46872. /**
  46873. * If the drag plane orientation should be updated during the dragging (Default: true)
  46874. */
  46875. updateDragPlane: boolean;
  46876. private _debugMode;
  46877. private _moving;
  46878. /**
  46879. * Fires each time the attached mesh is dragged with the pointer
  46880. * * delta between last drag position and current drag position in world space
  46881. * * dragDistance along the drag axis
  46882. * * dragPlaneNormal normal of the current drag plane used during the drag
  46883. * * dragPlanePoint in world space where the drag intersects the drag plane
  46884. */
  46885. onDragObservable: Observable<{
  46886. delta: Vector3;
  46887. dragPlanePoint: Vector3;
  46888. dragPlaneNormal: Vector3;
  46889. dragDistance: number;
  46890. pointerId: number;
  46891. }>;
  46892. /**
  46893. * Fires each time a drag begins (eg. mouse down on mesh)
  46894. */
  46895. onDragStartObservable: Observable<{
  46896. dragPlanePoint: Vector3;
  46897. pointerId: number;
  46898. }>;
  46899. /**
  46900. * Fires each time a drag ends (eg. mouse release after drag)
  46901. */
  46902. onDragEndObservable: Observable<{
  46903. dragPlanePoint: Vector3;
  46904. pointerId: number;
  46905. }>;
  46906. /**
  46907. * If the attached mesh should be moved when dragged
  46908. */
  46909. moveAttached: boolean;
  46910. /**
  46911. * If the drag behavior will react to drag events (Default: true)
  46912. */
  46913. enabled: boolean;
  46914. /**
  46915. * If pointer events should start and release the drag (Default: true)
  46916. */
  46917. startAndReleaseDragOnPointerEvents: boolean;
  46918. /**
  46919. * If camera controls should be detached during the drag
  46920. */
  46921. detachCameraControls: boolean;
  46922. /**
  46923. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  46924. */
  46925. useObjectOrientationForDragging: boolean;
  46926. private _options;
  46927. /**
  46928. * Gets the options used by the behavior
  46929. */
  46930. get options(): {
  46931. dragAxis?: Vector3;
  46932. dragPlaneNormal?: Vector3;
  46933. };
  46934. /**
  46935. * Sets the options used by the behavior
  46936. */
  46937. set options(options: {
  46938. dragAxis?: Vector3;
  46939. dragPlaneNormal?: Vector3;
  46940. });
  46941. /**
  46942. * Creates a pointer drag behavior that can be attached to a mesh
  46943. * @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)
  46944. */
  46945. constructor(options?: {
  46946. dragAxis?: Vector3;
  46947. dragPlaneNormal?: Vector3;
  46948. });
  46949. /**
  46950. * Predicate to determine if it is valid to move the object to a new position when it is moved
  46951. */
  46952. validateDrag: (targetPosition: Vector3) => boolean;
  46953. /**
  46954. * The name of the behavior
  46955. */
  46956. get name(): string;
  46957. /**
  46958. * Initializes the behavior
  46959. */
  46960. init(): void;
  46961. private _tmpVector;
  46962. private _alternatePickedPoint;
  46963. private _worldDragAxis;
  46964. private _targetPosition;
  46965. private _attachedToElement;
  46966. /**
  46967. * Attaches the drag behavior the passed in mesh
  46968. * @param ownerNode The mesh that will be dragged around once attached
  46969. * @param predicate Predicate to use for pick filtering
  46970. */
  46971. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  46972. /**
  46973. * Force relase the drag action by code.
  46974. */
  46975. releaseDrag(): void;
  46976. private _startDragRay;
  46977. private _lastPointerRay;
  46978. /**
  46979. * Simulates the start of a pointer drag event on the behavior
  46980. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  46981. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  46982. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  46983. */
  46984. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  46985. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  46986. private _dragDelta;
  46987. protected _moveDrag(ray: Ray): void;
  46988. private _pickWithRayOnDragPlane;
  46989. private _pointA;
  46990. private _pointC;
  46991. private _localAxis;
  46992. private _lookAt;
  46993. private _updateDragPlanePosition;
  46994. /**
  46995. * Detaches the behavior from the mesh
  46996. */
  46997. detach(): void;
  46998. }
  46999. }
  47000. declare module BABYLON {
  47001. /**
  47002. * A behavior that when attached to a mesh will allow the mesh to be scaled
  47003. */
  47004. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  47005. private _dragBehaviorA;
  47006. private _dragBehaviorB;
  47007. private _startDistance;
  47008. private _initialScale;
  47009. private _targetScale;
  47010. private _ownerNode;
  47011. private _sceneRenderObserver;
  47012. /**
  47013. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  47014. */
  47015. constructor();
  47016. /**
  47017. * The name of the behavior
  47018. */
  47019. get name(): string;
  47020. /**
  47021. * Initializes the behavior
  47022. */
  47023. init(): void;
  47024. private _getCurrentDistance;
  47025. /**
  47026. * Attaches the scale behavior the passed in mesh
  47027. * @param ownerNode The mesh that will be scaled around once attached
  47028. */
  47029. attach(ownerNode: Mesh): void;
  47030. /**
  47031. * Detaches the behavior from the mesh
  47032. */
  47033. detach(): void;
  47034. }
  47035. }
  47036. declare module BABYLON {
  47037. /**
  47038. * 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
  47039. */
  47040. export class SixDofDragBehavior implements Behavior<Mesh> {
  47041. private static _virtualScene;
  47042. private _ownerNode;
  47043. private _sceneRenderObserver;
  47044. private _scene;
  47045. private _targetPosition;
  47046. private _virtualOriginMesh;
  47047. private _virtualDragMesh;
  47048. private _pointerObserver;
  47049. private _moving;
  47050. private _startingOrientation;
  47051. private _attachedToElement;
  47052. /**
  47053. * 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)
  47054. */
  47055. private zDragFactor;
  47056. /**
  47057. * If the object should rotate to face the drag origin
  47058. */
  47059. rotateDraggedObject: boolean;
  47060. /**
  47061. * If the behavior is currently in a dragging state
  47062. */
  47063. dragging: boolean;
  47064. /**
  47065. * 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)
  47066. */
  47067. dragDeltaRatio: number;
  47068. /**
  47069. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  47070. */
  47071. currentDraggingPointerID: number;
  47072. /**
  47073. * If camera controls should be detached during the drag
  47074. */
  47075. detachCameraControls: boolean;
  47076. /**
  47077. * Fires each time a drag starts
  47078. */
  47079. onDragStartObservable: Observable<{}>;
  47080. /**
  47081. * Fires each time a drag ends (eg. mouse release after drag)
  47082. */
  47083. onDragEndObservable: Observable<{}>;
  47084. /**
  47085. * 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
  47086. */
  47087. constructor();
  47088. /**
  47089. * The name of the behavior
  47090. */
  47091. get name(): string;
  47092. /**
  47093. * Initializes the behavior
  47094. */
  47095. init(): void;
  47096. /**
  47097. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  47098. */
  47099. private get _pointerCamera();
  47100. /**
  47101. * Attaches the scale behavior the passed in mesh
  47102. * @param ownerNode The mesh that will be scaled around once attached
  47103. */
  47104. attach(ownerNode: Mesh): void;
  47105. /**
  47106. * Detaches the behavior from the mesh
  47107. */
  47108. detach(): void;
  47109. }
  47110. }
  47111. declare module BABYLON {
  47112. /**
  47113. * Class used to apply inverse kinematics to bones
  47114. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  47115. */
  47116. export class BoneIKController {
  47117. private static _tmpVecs;
  47118. private static _tmpQuat;
  47119. private static _tmpMats;
  47120. /**
  47121. * Gets or sets the target mesh
  47122. */
  47123. targetMesh: AbstractMesh;
  47124. /** Gets or sets the mesh used as pole */
  47125. poleTargetMesh: AbstractMesh;
  47126. /**
  47127. * Gets or sets the bone used as pole
  47128. */
  47129. poleTargetBone: Nullable<Bone>;
  47130. /**
  47131. * Gets or sets the target position
  47132. */
  47133. targetPosition: Vector3;
  47134. /**
  47135. * Gets or sets the pole target position
  47136. */
  47137. poleTargetPosition: Vector3;
  47138. /**
  47139. * Gets or sets the pole target local offset
  47140. */
  47141. poleTargetLocalOffset: Vector3;
  47142. /**
  47143. * Gets or sets the pole angle
  47144. */
  47145. poleAngle: number;
  47146. /**
  47147. * Gets or sets the mesh associated with the controller
  47148. */
  47149. mesh: AbstractMesh;
  47150. /**
  47151. * 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)
  47152. */
  47153. slerpAmount: number;
  47154. private _bone1Quat;
  47155. private _bone1Mat;
  47156. private _bone2Ang;
  47157. private _bone1;
  47158. private _bone2;
  47159. private _bone1Length;
  47160. private _bone2Length;
  47161. private _maxAngle;
  47162. private _maxReach;
  47163. private _rightHandedSystem;
  47164. private _bendAxis;
  47165. private _slerping;
  47166. private _adjustRoll;
  47167. /**
  47168. * Gets or sets maximum allowed angle
  47169. */
  47170. get maxAngle(): number;
  47171. set maxAngle(value: number);
  47172. /**
  47173. * Creates a new BoneIKController
  47174. * @param mesh defines the mesh to control
  47175. * @param bone defines the bone to control
  47176. * @param options defines options to set up the controller
  47177. */
  47178. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  47179. targetMesh?: AbstractMesh;
  47180. poleTargetMesh?: AbstractMesh;
  47181. poleTargetBone?: Bone;
  47182. poleTargetLocalOffset?: Vector3;
  47183. poleAngle?: number;
  47184. bendAxis?: Vector3;
  47185. maxAngle?: number;
  47186. slerpAmount?: number;
  47187. });
  47188. private _setMaxAngle;
  47189. /**
  47190. * Force the controller to update the bones
  47191. */
  47192. update(): void;
  47193. }
  47194. }
  47195. declare module BABYLON {
  47196. /**
  47197. * Class used to make a bone look toward a point in space
  47198. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  47199. */
  47200. export class BoneLookController {
  47201. private static _tmpVecs;
  47202. private static _tmpQuat;
  47203. private static _tmpMats;
  47204. /**
  47205. * The target Vector3 that the bone will look at
  47206. */
  47207. target: Vector3;
  47208. /**
  47209. * The mesh that the bone is attached to
  47210. */
  47211. mesh: AbstractMesh;
  47212. /**
  47213. * The bone that will be looking to the target
  47214. */
  47215. bone: Bone;
  47216. /**
  47217. * The up axis of the coordinate system that is used when the bone is rotated
  47218. */
  47219. upAxis: Vector3;
  47220. /**
  47221. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  47222. */
  47223. upAxisSpace: Space;
  47224. /**
  47225. * Used to make an adjustment to the yaw of the bone
  47226. */
  47227. adjustYaw: number;
  47228. /**
  47229. * Used to make an adjustment to the pitch of the bone
  47230. */
  47231. adjustPitch: number;
  47232. /**
  47233. * Used to make an adjustment to the roll of the bone
  47234. */
  47235. adjustRoll: number;
  47236. /**
  47237. * 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)
  47238. */
  47239. slerpAmount: number;
  47240. private _minYaw;
  47241. private _maxYaw;
  47242. private _minPitch;
  47243. private _maxPitch;
  47244. private _minYawSin;
  47245. private _minYawCos;
  47246. private _maxYawSin;
  47247. private _maxYawCos;
  47248. private _midYawConstraint;
  47249. private _minPitchTan;
  47250. private _maxPitchTan;
  47251. private _boneQuat;
  47252. private _slerping;
  47253. private _transformYawPitch;
  47254. private _transformYawPitchInv;
  47255. private _firstFrameSkipped;
  47256. private _yawRange;
  47257. private _fowardAxis;
  47258. /**
  47259. * Gets or sets the minimum yaw angle that the bone can look to
  47260. */
  47261. get minYaw(): number;
  47262. set minYaw(value: number);
  47263. /**
  47264. * Gets or sets the maximum yaw angle that the bone can look to
  47265. */
  47266. get maxYaw(): number;
  47267. set maxYaw(value: number);
  47268. /**
  47269. * Gets or sets the minimum pitch angle that the bone can look to
  47270. */
  47271. get minPitch(): number;
  47272. set minPitch(value: number);
  47273. /**
  47274. * Gets or sets the maximum pitch angle that the bone can look to
  47275. */
  47276. get maxPitch(): number;
  47277. set maxPitch(value: number);
  47278. /**
  47279. * Create a BoneLookController
  47280. * @param mesh the mesh that the bone belongs to
  47281. * @param bone the bone that will be looking to the target
  47282. * @param target the target Vector3 to look at
  47283. * @param options optional settings:
  47284. * * maxYaw: the maximum angle the bone will yaw to
  47285. * * minYaw: the minimum angle the bone will yaw to
  47286. * * maxPitch: the maximum angle the bone will pitch to
  47287. * * minPitch: the minimum angle the bone will yaw to
  47288. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  47289. * * upAxis: the up axis of the coordinate system
  47290. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  47291. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  47292. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  47293. * * adjustYaw: used to make an adjustment to the yaw of the bone
  47294. * * adjustPitch: used to make an adjustment to the pitch of the bone
  47295. * * adjustRoll: used to make an adjustment to the roll of the bone
  47296. **/
  47297. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  47298. maxYaw?: number;
  47299. minYaw?: number;
  47300. maxPitch?: number;
  47301. minPitch?: number;
  47302. slerpAmount?: number;
  47303. upAxis?: Vector3;
  47304. upAxisSpace?: Space;
  47305. yawAxis?: Vector3;
  47306. pitchAxis?: Vector3;
  47307. adjustYaw?: number;
  47308. adjustPitch?: number;
  47309. adjustRoll?: number;
  47310. });
  47311. /**
  47312. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  47313. */
  47314. update(): void;
  47315. private _getAngleDiff;
  47316. private _getAngleBetween;
  47317. private _isAngleBetween;
  47318. }
  47319. }
  47320. declare module BABYLON {
  47321. /**
  47322. * Manage the gamepad inputs to control an arc rotate camera.
  47323. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47324. */
  47325. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  47326. /**
  47327. * Defines the camera the input is attached to.
  47328. */
  47329. camera: ArcRotateCamera;
  47330. /**
  47331. * Defines the gamepad the input is gathering event from.
  47332. */
  47333. gamepad: Nullable<Gamepad>;
  47334. /**
  47335. * Defines the gamepad rotation sensiblity.
  47336. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  47337. */
  47338. gamepadRotationSensibility: number;
  47339. /**
  47340. * Defines the gamepad move sensiblity.
  47341. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  47342. */
  47343. gamepadMoveSensibility: number;
  47344. private _yAxisScale;
  47345. /**
  47346. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  47347. */
  47348. get invertYAxis(): boolean;
  47349. set invertYAxis(value: boolean);
  47350. private _onGamepadConnectedObserver;
  47351. private _onGamepadDisconnectedObserver;
  47352. /**
  47353. * Attach the input controls to a specific dom element to get the input from.
  47354. */
  47355. attachControl(): void;
  47356. /**
  47357. * Detach the current controls from the specified dom element.
  47358. * @param element Defines the element to stop listening the inputs from
  47359. */
  47360. detachControl(): void;
  47361. /**
  47362. * Update the current camera state depending on the inputs that have been used this frame.
  47363. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47364. */
  47365. checkInputs(): void;
  47366. /**
  47367. * Gets the class name of the current intput.
  47368. * @returns the class name
  47369. */
  47370. getClassName(): string;
  47371. /**
  47372. * Get the friendly name associated with the input class.
  47373. * @returns the input friendly name
  47374. */
  47375. getSimpleName(): string;
  47376. }
  47377. }
  47378. declare module BABYLON {
  47379. interface ArcRotateCameraInputsManager {
  47380. /**
  47381. * Add orientation input support to the input manager.
  47382. * @returns the current input manager
  47383. */
  47384. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  47385. }
  47386. /**
  47387. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  47388. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47389. */
  47390. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  47391. /**
  47392. * Defines the camera the input is attached to.
  47393. */
  47394. camera: ArcRotateCamera;
  47395. /**
  47396. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  47397. */
  47398. alphaCorrection: number;
  47399. /**
  47400. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  47401. */
  47402. gammaCorrection: number;
  47403. private _alpha;
  47404. private _gamma;
  47405. private _dirty;
  47406. private _deviceOrientationHandler;
  47407. /**
  47408. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  47409. */
  47410. constructor();
  47411. /**
  47412. * Attach the input controls to a specific dom element to get the input from.
  47413. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47414. */
  47415. attachControl(noPreventDefault?: boolean): void;
  47416. /** @hidden */
  47417. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  47418. /**
  47419. * Update the current camera state depending on the inputs that have been used this frame.
  47420. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47421. */
  47422. checkInputs(): void;
  47423. /**
  47424. * Detach the current controls from the specified dom element.
  47425. */
  47426. detachControl(): void;
  47427. /**
  47428. * Gets the class name of the current intput.
  47429. * @returns the class name
  47430. */
  47431. getClassName(): string;
  47432. /**
  47433. * Get the friendly name associated with the input class.
  47434. * @returns the input friendly name
  47435. */
  47436. getSimpleName(): string;
  47437. }
  47438. }
  47439. declare module BABYLON {
  47440. /**
  47441. * Listen to mouse events to control the camera.
  47442. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47443. */
  47444. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  47445. /**
  47446. * Defines the camera the input is attached to.
  47447. */
  47448. camera: FlyCamera;
  47449. /**
  47450. * Defines if touch is enabled. (Default is true.)
  47451. */
  47452. touchEnabled: boolean;
  47453. /**
  47454. * Defines the buttons associated with the input to handle camera rotation.
  47455. */
  47456. buttons: number[];
  47457. /**
  47458. * Assign buttons for Yaw control.
  47459. */
  47460. buttonsYaw: number[];
  47461. /**
  47462. * Assign buttons for Pitch control.
  47463. */
  47464. buttonsPitch: number[];
  47465. /**
  47466. * Assign buttons for Roll control.
  47467. */
  47468. buttonsRoll: number[];
  47469. /**
  47470. * Detect if any button is being pressed while mouse is moved.
  47471. * -1 = Mouse locked.
  47472. * 0 = Left button.
  47473. * 1 = Middle Button.
  47474. * 2 = Right Button.
  47475. */
  47476. activeButton: number;
  47477. /**
  47478. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  47479. * Higher values reduce its sensitivity.
  47480. */
  47481. angularSensibility: number;
  47482. private _observer;
  47483. private _rollObserver;
  47484. private previousPosition;
  47485. private noPreventDefault;
  47486. private element;
  47487. /**
  47488. * Listen to mouse events to control the camera.
  47489. * @param touchEnabled Define if touch is enabled. (Default is true.)
  47490. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47491. */
  47492. constructor(touchEnabled?: boolean);
  47493. /**
  47494. * Attach the mouse control to the HTML DOM element.
  47495. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  47496. */
  47497. attachControl(noPreventDefault?: boolean): void;
  47498. /**
  47499. * Detach the current controls from the specified dom element.
  47500. */
  47501. detachControl(): void;
  47502. /**
  47503. * Gets the class name of the current input.
  47504. * @returns the class name.
  47505. */
  47506. getClassName(): string;
  47507. /**
  47508. * Get the friendly name associated with the input class.
  47509. * @returns the input's friendly name.
  47510. */
  47511. getSimpleName(): string;
  47512. private _pointerInput;
  47513. private _onMouseMove;
  47514. /**
  47515. * Rotate camera by mouse offset.
  47516. */
  47517. private rotateCamera;
  47518. }
  47519. }
  47520. declare module BABYLON {
  47521. /**
  47522. * Default Inputs manager for the FlyCamera.
  47523. * It groups all the default supported inputs for ease of use.
  47524. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47525. */
  47526. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  47527. /**
  47528. * Instantiates a new FlyCameraInputsManager.
  47529. * @param camera Defines the camera the inputs belong to.
  47530. */
  47531. constructor(camera: FlyCamera);
  47532. /**
  47533. * Add keyboard input support to the input manager.
  47534. * @returns the new FlyCameraKeyboardMoveInput().
  47535. */
  47536. addKeyboard(): FlyCameraInputsManager;
  47537. /**
  47538. * Add mouse input support to the input manager.
  47539. * @param touchEnabled Enable touch screen support.
  47540. * @returns the new FlyCameraMouseInput().
  47541. */
  47542. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  47543. }
  47544. }
  47545. declare module BABYLON {
  47546. /**
  47547. * This is a flying camera, designed for 3D movement and rotation in all directions,
  47548. * such as in a 3D Space Shooter or a Flight Simulator.
  47549. */
  47550. export class FlyCamera extends TargetCamera {
  47551. /**
  47552. * Define the collision ellipsoid of the camera.
  47553. * This is helpful for simulating a camera body, like a player's body.
  47554. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  47555. */
  47556. ellipsoid: Vector3;
  47557. /**
  47558. * Define an offset for the position of the ellipsoid around the camera.
  47559. * This can be helpful if the camera is attached away from the player's body center,
  47560. * such as at its head.
  47561. */
  47562. ellipsoidOffset: Vector3;
  47563. /**
  47564. * Enable or disable collisions of the camera with the rest of the scene objects.
  47565. */
  47566. checkCollisions: boolean;
  47567. /**
  47568. * Enable or disable gravity on the camera.
  47569. */
  47570. applyGravity: boolean;
  47571. /**
  47572. * Define the current direction the camera is moving to.
  47573. */
  47574. cameraDirection: Vector3;
  47575. /**
  47576. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  47577. * This overrides and empties cameraRotation.
  47578. */
  47579. rotationQuaternion: Quaternion;
  47580. /**
  47581. * Track Roll to maintain the wanted Rolling when looking around.
  47582. */
  47583. _trackRoll: number;
  47584. /**
  47585. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  47586. */
  47587. rollCorrect: number;
  47588. /**
  47589. * Mimic a banked turn, Rolling the camera when Yawing.
  47590. * It's recommended to use rollCorrect = 10 for faster banking correction.
  47591. */
  47592. bankedTurn: boolean;
  47593. /**
  47594. * Limit in radians for how much Roll banking will add. (Default: 90°)
  47595. */
  47596. bankedTurnLimit: number;
  47597. /**
  47598. * Value of 0 disables the banked Roll.
  47599. * Value of 1 is equal to the Yaw angle in radians.
  47600. */
  47601. bankedTurnMultiplier: number;
  47602. /**
  47603. * The inputs manager loads all the input sources, such as keyboard and mouse.
  47604. */
  47605. inputs: FlyCameraInputsManager;
  47606. /**
  47607. * Gets the input sensibility for mouse input.
  47608. * Higher values reduce sensitivity.
  47609. */
  47610. get angularSensibility(): number;
  47611. /**
  47612. * Sets the input sensibility for a mouse input.
  47613. * Higher values reduce sensitivity.
  47614. */
  47615. set angularSensibility(value: number);
  47616. /**
  47617. * Get the keys for camera movement forward.
  47618. */
  47619. get keysForward(): number[];
  47620. /**
  47621. * Set the keys for camera movement forward.
  47622. */
  47623. set keysForward(value: number[]);
  47624. /**
  47625. * Get the keys for camera movement backward.
  47626. */
  47627. get keysBackward(): number[];
  47628. set keysBackward(value: number[]);
  47629. /**
  47630. * Get the keys for camera movement up.
  47631. */
  47632. get keysUp(): number[];
  47633. /**
  47634. * Set the keys for camera movement up.
  47635. */
  47636. set keysUp(value: number[]);
  47637. /**
  47638. * Get the keys for camera movement down.
  47639. */
  47640. get keysDown(): number[];
  47641. /**
  47642. * Set the keys for camera movement down.
  47643. */
  47644. set keysDown(value: number[]);
  47645. /**
  47646. * Get the keys for camera movement left.
  47647. */
  47648. get keysLeft(): number[];
  47649. /**
  47650. * Set the keys for camera movement left.
  47651. */
  47652. set keysLeft(value: number[]);
  47653. /**
  47654. * Set the keys for camera movement right.
  47655. */
  47656. get keysRight(): number[];
  47657. /**
  47658. * Set the keys for camera movement right.
  47659. */
  47660. set keysRight(value: number[]);
  47661. /**
  47662. * Event raised when the camera collides with a mesh in the scene.
  47663. */
  47664. onCollide: (collidedMesh: AbstractMesh) => void;
  47665. private _collider;
  47666. private _needMoveForGravity;
  47667. private _oldPosition;
  47668. private _diffPosition;
  47669. private _newPosition;
  47670. /** @hidden */
  47671. _localDirection: Vector3;
  47672. /** @hidden */
  47673. _transformedDirection: Vector3;
  47674. /**
  47675. * Instantiates a FlyCamera.
  47676. * This is a flying camera, designed for 3D movement and rotation in all directions,
  47677. * such as in a 3D Space Shooter or a Flight Simulator.
  47678. * @param name Define the name of the camera in the scene.
  47679. * @param position Define the starting position of the camera in the scene.
  47680. * @param scene Define the scene the camera belongs to.
  47681. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  47682. */
  47683. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  47684. /**
  47685. * Attach a control to the HTML DOM element.
  47686. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  47687. */
  47688. attachControl(noPreventDefault?: boolean): void;
  47689. /**
  47690. * Detach a control from the HTML DOM element.
  47691. * The camera will stop reacting to that input.
  47692. */
  47693. detachControl(): void;
  47694. private _collisionMask;
  47695. /**
  47696. * Get the mask that the camera ignores in collision events.
  47697. */
  47698. get collisionMask(): number;
  47699. /**
  47700. * Set the mask that the camera ignores in collision events.
  47701. */
  47702. set collisionMask(mask: number);
  47703. /** @hidden */
  47704. _collideWithWorld(displacement: Vector3): void;
  47705. /** @hidden */
  47706. private _onCollisionPositionChange;
  47707. /** @hidden */
  47708. _checkInputs(): void;
  47709. /** @hidden */
  47710. _decideIfNeedsToMove(): boolean;
  47711. /** @hidden */
  47712. _updatePosition(): void;
  47713. /**
  47714. * Restore the Roll to its target value at the rate specified.
  47715. * @param rate - Higher means slower restoring.
  47716. * @hidden
  47717. */
  47718. restoreRoll(rate: number): void;
  47719. /**
  47720. * Destroy the camera and release the current resources held by it.
  47721. */
  47722. dispose(): void;
  47723. /**
  47724. * Get the current object class name.
  47725. * @returns the class name.
  47726. */
  47727. getClassName(): string;
  47728. }
  47729. }
  47730. declare module BABYLON {
  47731. /**
  47732. * Listen to keyboard events to control the camera.
  47733. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47734. */
  47735. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  47736. /**
  47737. * Defines the camera the input is attached to.
  47738. */
  47739. camera: FlyCamera;
  47740. /**
  47741. * The list of keyboard keys used to control the forward move of the camera.
  47742. */
  47743. keysForward: number[];
  47744. /**
  47745. * The list of keyboard keys used to control the backward move of the camera.
  47746. */
  47747. keysBackward: number[];
  47748. /**
  47749. * The list of keyboard keys used to control the forward move of the camera.
  47750. */
  47751. keysUp: number[];
  47752. /**
  47753. * The list of keyboard keys used to control the backward move of the camera.
  47754. */
  47755. keysDown: number[];
  47756. /**
  47757. * The list of keyboard keys used to control the right strafe move of the camera.
  47758. */
  47759. keysRight: number[];
  47760. /**
  47761. * The list of keyboard keys used to control the left strafe move of the camera.
  47762. */
  47763. keysLeft: number[];
  47764. private _keys;
  47765. private _onCanvasBlurObserver;
  47766. private _onKeyboardObserver;
  47767. private _engine;
  47768. private _scene;
  47769. /**
  47770. * Attach the input controls to a specific dom element to get the input from.
  47771. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47772. */
  47773. attachControl(noPreventDefault?: boolean): void;
  47774. /**
  47775. * Detach the current controls from the specified dom element.
  47776. */
  47777. detachControl(): void;
  47778. /**
  47779. * Gets the class name of the current intput.
  47780. * @returns the class name
  47781. */
  47782. getClassName(): string;
  47783. /** @hidden */
  47784. _onLostFocus(e: FocusEvent): void;
  47785. /**
  47786. * Get the friendly name associated with the input class.
  47787. * @returns the input friendly name
  47788. */
  47789. getSimpleName(): string;
  47790. /**
  47791. * Update the current camera state depending on the inputs that have been used this frame.
  47792. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47793. */
  47794. checkInputs(): void;
  47795. }
  47796. }
  47797. declare module BABYLON {
  47798. /**
  47799. * Manage the mouse wheel inputs to control a follow camera.
  47800. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47801. */
  47802. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  47803. /**
  47804. * Defines the camera the input is attached to.
  47805. */
  47806. camera: FollowCamera;
  47807. /**
  47808. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  47809. */
  47810. axisControlRadius: boolean;
  47811. /**
  47812. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  47813. */
  47814. axisControlHeight: boolean;
  47815. /**
  47816. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  47817. */
  47818. axisControlRotation: boolean;
  47819. /**
  47820. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  47821. * relation to mouseWheel events.
  47822. */
  47823. wheelPrecision: number;
  47824. /**
  47825. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  47826. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  47827. */
  47828. wheelDeltaPercentage: number;
  47829. private _wheel;
  47830. private _observer;
  47831. /**
  47832. * Attach the input controls to a specific dom element to get the input from.
  47833. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47834. */
  47835. attachControl(noPreventDefault?: boolean): void;
  47836. /**
  47837. * Detach the current controls from the specified dom element.
  47838. */
  47839. detachControl(): void;
  47840. /**
  47841. * Gets the class name of the current intput.
  47842. * @returns the class name
  47843. */
  47844. getClassName(): string;
  47845. /**
  47846. * Get the friendly name associated with the input class.
  47847. * @returns the input friendly name
  47848. */
  47849. getSimpleName(): string;
  47850. }
  47851. }
  47852. declare module BABYLON {
  47853. /**
  47854. * Manage the pointers inputs to control an follow camera.
  47855. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47856. */
  47857. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  47858. /**
  47859. * Defines the camera the input is attached to.
  47860. */
  47861. camera: FollowCamera;
  47862. /**
  47863. * Gets the class name of the current input.
  47864. * @returns the class name
  47865. */
  47866. getClassName(): string;
  47867. /**
  47868. * Defines the pointer angular sensibility along the X axis or how fast is
  47869. * the camera rotating.
  47870. * A negative number will reverse the axis direction.
  47871. */
  47872. angularSensibilityX: number;
  47873. /**
  47874. * Defines the pointer angular sensibility along the Y axis or how fast is
  47875. * the camera rotating.
  47876. * A negative number will reverse the axis direction.
  47877. */
  47878. angularSensibilityY: number;
  47879. /**
  47880. * Defines the pointer pinch precision or how fast is the camera zooming.
  47881. * A negative number will reverse the axis direction.
  47882. */
  47883. pinchPrecision: number;
  47884. /**
  47885. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  47886. * from 0.
  47887. * It defines the percentage of current camera.radius to use as delta when
  47888. * pinch zoom is used.
  47889. */
  47890. pinchDeltaPercentage: number;
  47891. /**
  47892. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  47893. */
  47894. axisXControlRadius: boolean;
  47895. /**
  47896. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  47897. */
  47898. axisXControlHeight: boolean;
  47899. /**
  47900. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  47901. */
  47902. axisXControlRotation: boolean;
  47903. /**
  47904. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  47905. */
  47906. axisYControlRadius: boolean;
  47907. /**
  47908. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  47909. */
  47910. axisYControlHeight: boolean;
  47911. /**
  47912. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  47913. */
  47914. axisYControlRotation: boolean;
  47915. /**
  47916. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  47917. */
  47918. axisPinchControlRadius: boolean;
  47919. /**
  47920. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  47921. */
  47922. axisPinchControlHeight: boolean;
  47923. /**
  47924. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  47925. */
  47926. axisPinchControlRotation: boolean;
  47927. /**
  47928. * Log error messages if basic misconfiguration has occurred.
  47929. */
  47930. warningEnable: boolean;
  47931. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  47932. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  47933. private _warningCounter;
  47934. private _warning;
  47935. }
  47936. }
  47937. declare module BABYLON {
  47938. /**
  47939. * Default Inputs manager for the FollowCamera.
  47940. * It groups all the default supported inputs for ease of use.
  47941. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47942. */
  47943. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  47944. /**
  47945. * Instantiates a new FollowCameraInputsManager.
  47946. * @param camera Defines the camera the inputs belong to
  47947. */
  47948. constructor(camera: FollowCamera);
  47949. /**
  47950. * Add keyboard input support to the input manager.
  47951. * @returns the current input manager
  47952. */
  47953. addKeyboard(): FollowCameraInputsManager;
  47954. /**
  47955. * Add mouse wheel input support to the input manager.
  47956. * @returns the current input manager
  47957. */
  47958. addMouseWheel(): FollowCameraInputsManager;
  47959. /**
  47960. * Add pointers input support to the input manager.
  47961. * @returns the current input manager
  47962. */
  47963. addPointers(): FollowCameraInputsManager;
  47964. /**
  47965. * Add orientation input support to the input manager.
  47966. * @returns the current input manager
  47967. */
  47968. addVRDeviceOrientation(): FollowCameraInputsManager;
  47969. }
  47970. }
  47971. declare module BABYLON {
  47972. /**
  47973. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  47974. * an arc rotate version arcFollowCamera are available.
  47975. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  47976. */
  47977. export class FollowCamera extends TargetCamera {
  47978. /**
  47979. * Distance the follow camera should follow an object at
  47980. */
  47981. radius: number;
  47982. /**
  47983. * Minimum allowed distance of the camera to the axis of rotation
  47984. * (The camera can not get closer).
  47985. * This can help limiting how the Camera is able to move in the scene.
  47986. */
  47987. lowerRadiusLimit: Nullable<number>;
  47988. /**
  47989. * Maximum allowed distance of the camera to the axis of rotation
  47990. * (The camera can not get further).
  47991. * This can help limiting how the Camera is able to move in the scene.
  47992. */
  47993. upperRadiusLimit: Nullable<number>;
  47994. /**
  47995. * Define a rotation offset between the camera and the object it follows
  47996. */
  47997. rotationOffset: number;
  47998. /**
  47999. * Minimum allowed angle to camera position relative to target object.
  48000. * This can help limiting how the Camera is able to move in the scene.
  48001. */
  48002. lowerRotationOffsetLimit: Nullable<number>;
  48003. /**
  48004. * Maximum allowed angle to camera position relative to target object.
  48005. * This can help limiting how the Camera is able to move in the scene.
  48006. */
  48007. upperRotationOffsetLimit: Nullable<number>;
  48008. /**
  48009. * Define a height offset between the camera and the object it follows.
  48010. * It can help following an object from the top (like a car chaing a plane)
  48011. */
  48012. heightOffset: number;
  48013. /**
  48014. * Minimum allowed height of camera position relative to target object.
  48015. * This can help limiting how the Camera is able to move in the scene.
  48016. */
  48017. lowerHeightOffsetLimit: Nullable<number>;
  48018. /**
  48019. * Maximum allowed height of camera position relative to target object.
  48020. * This can help limiting how the Camera is able to move in the scene.
  48021. */
  48022. upperHeightOffsetLimit: Nullable<number>;
  48023. /**
  48024. * Define how fast the camera can accelerate to follow it s target.
  48025. */
  48026. cameraAcceleration: number;
  48027. /**
  48028. * Define the speed limit of the camera following an object.
  48029. */
  48030. maxCameraSpeed: number;
  48031. /**
  48032. * Define the target of the camera.
  48033. */
  48034. lockedTarget: Nullable<AbstractMesh>;
  48035. /**
  48036. * Defines the input associated with the camera.
  48037. */
  48038. inputs: FollowCameraInputsManager;
  48039. /**
  48040. * Instantiates the follow camera.
  48041. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48042. * @param name Define the name of the camera in the scene
  48043. * @param position Define the position of the camera
  48044. * @param scene Define the scene the camera belong to
  48045. * @param lockedTarget Define the target of the camera
  48046. */
  48047. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  48048. private _follow;
  48049. /**
  48050. * Attached controls to the current camera.
  48051. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48052. */
  48053. attachControl(noPreventDefault?: boolean): void;
  48054. /**
  48055. * Detach the current controls from the camera.
  48056. * The camera will stop reacting to inputs.
  48057. */
  48058. detachControl(): void;
  48059. /** @hidden */
  48060. _checkInputs(): void;
  48061. private _checkLimits;
  48062. /**
  48063. * Gets the camera class name.
  48064. * @returns the class name
  48065. */
  48066. getClassName(): string;
  48067. }
  48068. /**
  48069. * Arc Rotate version of the follow camera.
  48070. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  48071. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48072. */
  48073. export class ArcFollowCamera extends TargetCamera {
  48074. /** The longitudinal angle of the camera */
  48075. alpha: number;
  48076. /** The latitudinal angle of the camera */
  48077. beta: number;
  48078. /** The radius of the camera from its target */
  48079. radius: number;
  48080. private _cartesianCoordinates;
  48081. /** Define the camera target (the mesh it should follow) */
  48082. private _meshTarget;
  48083. /**
  48084. * Instantiates a new ArcFollowCamera
  48085. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48086. * @param name Define the name of the camera
  48087. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  48088. * @param beta Define the rotation angle of the camera around the elevation axis
  48089. * @param radius Define the radius of the camera from its target point
  48090. * @param target Define the target of the camera
  48091. * @param scene Define the scene the camera belongs to
  48092. */
  48093. constructor(name: string,
  48094. /** The longitudinal angle of the camera */
  48095. alpha: number,
  48096. /** The latitudinal angle of the camera */
  48097. beta: number,
  48098. /** The radius of the camera from its target */
  48099. radius: number,
  48100. /** Define the camera target (the mesh it should follow) */
  48101. target: Nullable<AbstractMesh>, scene: Scene);
  48102. private _follow;
  48103. /** @hidden */
  48104. _checkInputs(): void;
  48105. /**
  48106. * Returns the class name of the object.
  48107. * It is mostly used internally for serialization purposes.
  48108. */
  48109. getClassName(): string;
  48110. }
  48111. }
  48112. declare module BABYLON {
  48113. /**
  48114. * Manage the keyboard inputs to control the movement of a follow camera.
  48115. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48116. */
  48117. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  48118. /**
  48119. * Defines the camera the input is attached to.
  48120. */
  48121. camera: FollowCamera;
  48122. /**
  48123. * Defines the list of key codes associated with the up action (increase heightOffset)
  48124. */
  48125. keysHeightOffsetIncr: number[];
  48126. /**
  48127. * Defines the list of key codes associated with the down action (decrease heightOffset)
  48128. */
  48129. keysHeightOffsetDecr: number[];
  48130. /**
  48131. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  48132. */
  48133. keysHeightOffsetModifierAlt: boolean;
  48134. /**
  48135. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  48136. */
  48137. keysHeightOffsetModifierCtrl: boolean;
  48138. /**
  48139. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  48140. */
  48141. keysHeightOffsetModifierShift: boolean;
  48142. /**
  48143. * Defines the list of key codes associated with the left action (increase rotationOffset)
  48144. */
  48145. keysRotationOffsetIncr: number[];
  48146. /**
  48147. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  48148. */
  48149. keysRotationOffsetDecr: number[];
  48150. /**
  48151. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  48152. */
  48153. keysRotationOffsetModifierAlt: boolean;
  48154. /**
  48155. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  48156. */
  48157. keysRotationOffsetModifierCtrl: boolean;
  48158. /**
  48159. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  48160. */
  48161. keysRotationOffsetModifierShift: boolean;
  48162. /**
  48163. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  48164. */
  48165. keysRadiusIncr: number[];
  48166. /**
  48167. * Defines the list of key codes associated with the zoom-out action (increase radius)
  48168. */
  48169. keysRadiusDecr: number[];
  48170. /**
  48171. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  48172. */
  48173. keysRadiusModifierAlt: boolean;
  48174. /**
  48175. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  48176. */
  48177. keysRadiusModifierCtrl: boolean;
  48178. /**
  48179. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  48180. */
  48181. keysRadiusModifierShift: boolean;
  48182. /**
  48183. * Defines the rate of change of heightOffset.
  48184. */
  48185. heightSensibility: number;
  48186. /**
  48187. * Defines the rate of change of rotationOffset.
  48188. */
  48189. rotationSensibility: number;
  48190. /**
  48191. * Defines the rate of change of radius.
  48192. */
  48193. radiusSensibility: number;
  48194. private _keys;
  48195. private _ctrlPressed;
  48196. private _altPressed;
  48197. private _shiftPressed;
  48198. private _onCanvasBlurObserver;
  48199. private _onKeyboardObserver;
  48200. private _engine;
  48201. private _scene;
  48202. /**
  48203. * Attach the input controls to a specific dom element to get the input from.
  48204. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48205. */
  48206. attachControl(noPreventDefault?: boolean): void;
  48207. /**
  48208. * Detach the current controls from the specified dom element.
  48209. */
  48210. detachControl(): void;
  48211. /**
  48212. * Update the current camera state depending on the inputs that have been used this frame.
  48213. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48214. */
  48215. checkInputs(): void;
  48216. /**
  48217. * Gets the class name of the current input.
  48218. * @returns the class name
  48219. */
  48220. getClassName(): string;
  48221. /**
  48222. * Get the friendly name associated with the input class.
  48223. * @returns the input friendly name
  48224. */
  48225. getSimpleName(): string;
  48226. /**
  48227. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48228. * allow modification of the heightOffset value.
  48229. */
  48230. private _modifierHeightOffset;
  48231. /**
  48232. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48233. * allow modification of the rotationOffset value.
  48234. */
  48235. private _modifierRotationOffset;
  48236. /**
  48237. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48238. * allow modification of the radius value.
  48239. */
  48240. private _modifierRadius;
  48241. }
  48242. }
  48243. declare module BABYLON {
  48244. interface FreeCameraInputsManager {
  48245. /**
  48246. * @hidden
  48247. */
  48248. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  48249. /**
  48250. * Add orientation input support to the input manager.
  48251. * @returns the current input manager
  48252. */
  48253. addDeviceOrientation(): FreeCameraInputsManager;
  48254. }
  48255. /**
  48256. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  48257. * Screen rotation is taken into account.
  48258. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48259. */
  48260. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  48261. private _camera;
  48262. private _screenOrientationAngle;
  48263. private _constantTranform;
  48264. private _screenQuaternion;
  48265. private _alpha;
  48266. private _beta;
  48267. private _gamma;
  48268. /**
  48269. * Can be used to detect if a device orientation sensor is available on a device
  48270. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  48271. * @returns a promise that will resolve on orientation change
  48272. */
  48273. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  48274. /**
  48275. * @hidden
  48276. */
  48277. _onDeviceOrientationChangedObservable: Observable<void>;
  48278. /**
  48279. * Instantiates a new input
  48280. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48281. */
  48282. constructor();
  48283. /**
  48284. * Define the camera controlled by the input.
  48285. */
  48286. get camera(): FreeCamera;
  48287. set camera(camera: FreeCamera);
  48288. /**
  48289. * Attach the input controls to a specific dom element to get the input from.
  48290. */
  48291. attachControl(): void;
  48292. private _orientationChanged;
  48293. private _deviceOrientation;
  48294. /**
  48295. * Detach the current controls from the specified dom element.
  48296. */
  48297. detachControl(): void;
  48298. /**
  48299. * Update the current camera state depending on the inputs that have been used this frame.
  48300. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48301. */
  48302. checkInputs(): void;
  48303. /**
  48304. * Gets the class name of the current intput.
  48305. * @returns the class name
  48306. */
  48307. getClassName(): string;
  48308. /**
  48309. * Get the friendly name associated with the input class.
  48310. * @returns the input friendly name
  48311. */
  48312. getSimpleName(): string;
  48313. }
  48314. }
  48315. declare module BABYLON {
  48316. /**
  48317. * Manage the gamepad inputs to control a free camera.
  48318. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48319. */
  48320. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  48321. /**
  48322. * Define the camera the input is attached to.
  48323. */
  48324. camera: FreeCamera;
  48325. /**
  48326. * Define the Gamepad controlling the input
  48327. */
  48328. gamepad: Nullable<Gamepad>;
  48329. /**
  48330. * Defines the gamepad rotation sensiblity.
  48331. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  48332. */
  48333. gamepadAngularSensibility: number;
  48334. /**
  48335. * Defines the gamepad move sensiblity.
  48336. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  48337. */
  48338. gamepadMoveSensibility: number;
  48339. private _yAxisScale;
  48340. /**
  48341. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  48342. */
  48343. get invertYAxis(): boolean;
  48344. set invertYAxis(value: boolean);
  48345. private _onGamepadConnectedObserver;
  48346. private _onGamepadDisconnectedObserver;
  48347. private _cameraTransform;
  48348. private _deltaTransform;
  48349. private _vector3;
  48350. private _vector2;
  48351. /**
  48352. * Attach the input controls to a specific dom element to get the input from.
  48353. */
  48354. attachControl(): void;
  48355. /**
  48356. * Detach the current controls from the specified dom element.
  48357. */
  48358. detachControl(): void;
  48359. /**
  48360. * Update the current camera state depending on the inputs that have been used this frame.
  48361. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48362. */
  48363. checkInputs(): void;
  48364. /**
  48365. * Gets the class name of the current intput.
  48366. * @returns the class name
  48367. */
  48368. getClassName(): string;
  48369. /**
  48370. * Get the friendly name associated with the input class.
  48371. * @returns the input friendly name
  48372. */
  48373. getSimpleName(): string;
  48374. }
  48375. }
  48376. declare module BABYLON {
  48377. /**
  48378. * Defines the potential axis of a Joystick
  48379. */
  48380. export enum JoystickAxis {
  48381. /** X axis */
  48382. X = 0,
  48383. /** Y axis */
  48384. Y = 1,
  48385. /** Z axis */
  48386. Z = 2
  48387. }
  48388. /**
  48389. * Represents the different customization options available
  48390. * for VirtualJoystick
  48391. */
  48392. interface VirtualJoystickCustomizations {
  48393. /**
  48394. * Size of the joystick's puck
  48395. */
  48396. puckSize: number;
  48397. /**
  48398. * Size of the joystick's container
  48399. */
  48400. containerSize: number;
  48401. /**
  48402. * Color of the joystick && puck
  48403. */
  48404. color: string;
  48405. /**
  48406. * Image URL for the joystick's puck
  48407. */
  48408. puckImage?: string;
  48409. /**
  48410. * Image URL for the joystick's container
  48411. */
  48412. containerImage?: string;
  48413. /**
  48414. * Defines the unmoving position of the joystick container
  48415. */
  48416. position?: {
  48417. x: number;
  48418. y: number;
  48419. };
  48420. /**
  48421. * Defines whether or not the joystick container is always visible
  48422. */
  48423. alwaysVisible: boolean;
  48424. /**
  48425. * Defines whether or not to limit the movement of the puck to the joystick's container
  48426. */
  48427. limitToContainer: boolean;
  48428. }
  48429. /**
  48430. * Class used to define virtual joystick (used in touch mode)
  48431. */
  48432. export class VirtualJoystick {
  48433. /**
  48434. * Gets or sets a boolean indicating that left and right values must be inverted
  48435. */
  48436. reverseLeftRight: boolean;
  48437. /**
  48438. * Gets or sets a boolean indicating that up and down values must be inverted
  48439. */
  48440. reverseUpDown: boolean;
  48441. /**
  48442. * Gets the offset value for the position (ie. the change of the position value)
  48443. */
  48444. deltaPosition: Vector3;
  48445. /**
  48446. * Gets a boolean indicating if the virtual joystick was pressed
  48447. */
  48448. pressed: boolean;
  48449. /**
  48450. * Canvas the virtual joystick will render onto, default z-index of this is 5
  48451. */
  48452. static Canvas: Nullable<HTMLCanvasElement>;
  48453. /**
  48454. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  48455. */
  48456. limitToContainer: boolean;
  48457. private static _globalJoystickIndex;
  48458. private static _alwaysVisibleSticks;
  48459. private static vjCanvasContext;
  48460. private static vjCanvasWidth;
  48461. private static vjCanvasHeight;
  48462. private static halfWidth;
  48463. private static _GetDefaultOptions;
  48464. private _action;
  48465. private _axisTargetedByLeftAndRight;
  48466. private _axisTargetedByUpAndDown;
  48467. private _joystickSensibility;
  48468. private _inversedSensibility;
  48469. private _joystickPointerID;
  48470. private _joystickColor;
  48471. private _joystickPointerPos;
  48472. private _joystickPreviousPointerPos;
  48473. private _joystickPointerStartPos;
  48474. private _deltaJoystickVector;
  48475. private _leftJoystick;
  48476. private _touches;
  48477. private _joystickPosition;
  48478. private _alwaysVisible;
  48479. private _puckImage;
  48480. private _containerImage;
  48481. private _joystickPuckSize;
  48482. private _joystickContainerSize;
  48483. private _clearPuckSize;
  48484. private _clearContainerSize;
  48485. private _clearPuckSizeOffset;
  48486. private _clearContainerSizeOffset;
  48487. private _onPointerDownHandlerRef;
  48488. private _onPointerMoveHandlerRef;
  48489. private _onPointerUpHandlerRef;
  48490. private _onResize;
  48491. /**
  48492. * Creates a new virtual joystick
  48493. * @param leftJoystick defines that the joystick is for left hand (false by default)
  48494. * @param customizations Defines the options we want to customize the VirtualJoystick
  48495. */
  48496. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  48497. /**
  48498. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  48499. * @param newJoystickSensibility defines the new sensibility
  48500. */
  48501. setJoystickSensibility(newJoystickSensibility: number): void;
  48502. private _onPointerDown;
  48503. private _onPointerMove;
  48504. private _onPointerUp;
  48505. /**
  48506. * Change the color of the virtual joystick
  48507. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  48508. */
  48509. setJoystickColor(newColor: string): void;
  48510. /**
  48511. * Size of the joystick's container
  48512. */
  48513. set containerSize(newSize: number);
  48514. get containerSize(): number;
  48515. /**
  48516. * Size of the joystick's puck
  48517. */
  48518. set puckSize(newSize: number);
  48519. get puckSize(): number;
  48520. /**
  48521. * Clears the set position of the joystick
  48522. */
  48523. clearPosition(): void;
  48524. /**
  48525. * Defines whether or not the joystick container is always visible
  48526. */
  48527. set alwaysVisible(value: boolean);
  48528. get alwaysVisible(): boolean;
  48529. /**
  48530. * Sets the constant position of the Joystick container
  48531. * @param x X axis coordinate
  48532. * @param y Y axis coordinate
  48533. */
  48534. setPosition(x: number, y: number): void;
  48535. /**
  48536. * Defines a callback to call when the joystick is touched
  48537. * @param action defines the callback
  48538. */
  48539. setActionOnTouch(action: () => any): void;
  48540. /**
  48541. * Defines which axis you'd like to control for left & right
  48542. * @param axis defines the axis to use
  48543. */
  48544. setAxisForLeftRight(axis: JoystickAxis): void;
  48545. /**
  48546. * Defines which axis you'd like to control for up & down
  48547. * @param axis defines the axis to use
  48548. */
  48549. setAxisForUpDown(axis: JoystickAxis): void;
  48550. /**
  48551. * Clears the canvas from the previous puck / container draw
  48552. */
  48553. private _clearPreviousDraw;
  48554. /**
  48555. * Loads `urlPath` to be used for the container's image
  48556. * @param urlPath defines the urlPath of an image to use
  48557. */
  48558. setContainerImage(urlPath: string): void;
  48559. /**
  48560. * Loads `urlPath` to be used for the puck's image
  48561. * @param urlPath defines the urlPath of an image to use
  48562. */
  48563. setPuckImage(urlPath: string): void;
  48564. /**
  48565. * Draws the Virtual Joystick's container
  48566. */
  48567. private _drawContainer;
  48568. /**
  48569. * Draws the Virtual Joystick's puck
  48570. */
  48571. private _drawPuck;
  48572. private _drawVirtualJoystick;
  48573. /**
  48574. * Release internal HTML canvas
  48575. */
  48576. releaseCanvas(): void;
  48577. }
  48578. }
  48579. declare module BABYLON {
  48580. interface FreeCameraInputsManager {
  48581. /**
  48582. * Add virtual joystick input support to the input manager.
  48583. * @returns the current input manager
  48584. */
  48585. addVirtualJoystick(): FreeCameraInputsManager;
  48586. }
  48587. /**
  48588. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  48589. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48590. */
  48591. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  48592. /**
  48593. * Defines the camera the input is attached to.
  48594. */
  48595. camera: FreeCamera;
  48596. private _leftjoystick;
  48597. private _rightjoystick;
  48598. /**
  48599. * Gets the left stick of the virtual joystick.
  48600. * @returns The virtual Joystick
  48601. */
  48602. getLeftJoystick(): VirtualJoystick;
  48603. /**
  48604. * Gets the right stick of the virtual joystick.
  48605. * @returns The virtual Joystick
  48606. */
  48607. getRightJoystick(): VirtualJoystick;
  48608. /**
  48609. * Update the current camera state depending on the inputs that have been used this frame.
  48610. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48611. */
  48612. checkInputs(): void;
  48613. /**
  48614. * Attach the input controls to a specific dom element to get the input from.
  48615. */
  48616. attachControl(): void;
  48617. /**
  48618. * Detach the current controls from the specified dom element.
  48619. */
  48620. detachControl(): void;
  48621. /**
  48622. * Gets the class name of the current intput.
  48623. * @returns the class name
  48624. */
  48625. getClassName(): string;
  48626. /**
  48627. * Get the friendly name associated with the input class.
  48628. * @returns the input friendly name
  48629. */
  48630. getSimpleName(): string;
  48631. }
  48632. }
  48633. declare module BABYLON {
  48634. /**
  48635. * This represents a FPS type of camera controlled by touch.
  48636. * This is like a universal camera minus the Gamepad controls.
  48637. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48638. */
  48639. export class TouchCamera extends FreeCamera {
  48640. /**
  48641. * Defines the touch sensibility for rotation.
  48642. * The higher the faster.
  48643. */
  48644. get touchAngularSensibility(): number;
  48645. set touchAngularSensibility(value: number);
  48646. /**
  48647. * Defines the touch sensibility for move.
  48648. * The higher the faster.
  48649. */
  48650. get touchMoveSensibility(): number;
  48651. set touchMoveSensibility(value: number);
  48652. /**
  48653. * Instantiates a new touch camera.
  48654. * This represents a FPS type of camera controlled by touch.
  48655. * This is like a universal camera minus the Gamepad controls.
  48656. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48657. * @param name Define the name of the camera in the scene
  48658. * @param position Define the start position of the camera in the scene
  48659. * @param scene Define the scene the camera belongs to
  48660. */
  48661. constructor(name: string, position: Vector3, scene: Scene);
  48662. /**
  48663. * Gets the current object class name.
  48664. * @return the class name
  48665. */
  48666. getClassName(): string;
  48667. /** @hidden */
  48668. _setupInputs(): void;
  48669. }
  48670. }
  48671. declare module BABYLON {
  48672. /**
  48673. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  48674. * being tilted forward or back and left or right.
  48675. */
  48676. export class DeviceOrientationCamera extends FreeCamera {
  48677. private _initialQuaternion;
  48678. private _quaternionCache;
  48679. private _tmpDragQuaternion;
  48680. private _disablePointerInputWhenUsingDeviceOrientation;
  48681. /**
  48682. * Creates a new device orientation camera
  48683. * @param name The name of the camera
  48684. * @param position The start position camera
  48685. * @param scene The scene the camera belongs to
  48686. */
  48687. constructor(name: string, position: Vector3, scene: Scene);
  48688. /**
  48689. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  48690. */
  48691. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  48692. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  48693. private _dragFactor;
  48694. /**
  48695. * Enabled turning on the y axis when the orientation sensor is active
  48696. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  48697. */
  48698. enableHorizontalDragging(dragFactor?: number): void;
  48699. /**
  48700. * Gets the current instance class name ("DeviceOrientationCamera").
  48701. * This helps avoiding instanceof at run time.
  48702. * @returns the class name
  48703. */
  48704. getClassName(): string;
  48705. /**
  48706. * @hidden
  48707. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  48708. */
  48709. _checkInputs(): void;
  48710. /**
  48711. * Reset the camera to its default orientation on the specified axis only.
  48712. * @param axis The axis to reset
  48713. */
  48714. resetToCurrentRotation(axis?: Axis): void;
  48715. }
  48716. }
  48717. declare module BABYLON {
  48718. /**
  48719. * Defines supported buttons for XBox360 compatible gamepads
  48720. */
  48721. export enum Xbox360Button {
  48722. /** A */
  48723. A = 0,
  48724. /** B */
  48725. B = 1,
  48726. /** X */
  48727. X = 2,
  48728. /** Y */
  48729. Y = 3,
  48730. /** Left button */
  48731. LB = 4,
  48732. /** Right button */
  48733. RB = 5,
  48734. /** Back */
  48735. Back = 8,
  48736. /** Start */
  48737. Start = 9,
  48738. /** Left stick */
  48739. LeftStick = 10,
  48740. /** Right stick */
  48741. RightStick = 11
  48742. }
  48743. /** Defines values for XBox360 DPad */
  48744. export enum Xbox360Dpad {
  48745. /** Up */
  48746. Up = 12,
  48747. /** Down */
  48748. Down = 13,
  48749. /** Left */
  48750. Left = 14,
  48751. /** Right */
  48752. Right = 15
  48753. }
  48754. /**
  48755. * Defines a XBox360 gamepad
  48756. */
  48757. export class Xbox360Pad extends Gamepad {
  48758. private _leftTrigger;
  48759. private _rightTrigger;
  48760. private _onlefttriggerchanged;
  48761. private _onrighttriggerchanged;
  48762. private _onbuttondown;
  48763. private _onbuttonup;
  48764. private _ondpaddown;
  48765. private _ondpadup;
  48766. /** Observable raised when a button is pressed */
  48767. onButtonDownObservable: Observable<Xbox360Button>;
  48768. /** Observable raised when a button is released */
  48769. onButtonUpObservable: Observable<Xbox360Button>;
  48770. /** Observable raised when a pad is pressed */
  48771. onPadDownObservable: Observable<Xbox360Dpad>;
  48772. /** Observable raised when a pad is released */
  48773. onPadUpObservable: Observable<Xbox360Dpad>;
  48774. private _buttonA;
  48775. private _buttonB;
  48776. private _buttonX;
  48777. private _buttonY;
  48778. private _buttonBack;
  48779. private _buttonStart;
  48780. private _buttonLB;
  48781. private _buttonRB;
  48782. private _buttonLeftStick;
  48783. private _buttonRightStick;
  48784. private _dPadUp;
  48785. private _dPadDown;
  48786. private _dPadLeft;
  48787. private _dPadRight;
  48788. private _isXboxOnePad;
  48789. /**
  48790. * Creates a new XBox360 gamepad object
  48791. * @param id defines the id of this gamepad
  48792. * @param index defines its index
  48793. * @param gamepad defines the internal HTML gamepad object
  48794. * @param xboxOne defines if it is a XBox One gamepad
  48795. */
  48796. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  48797. /**
  48798. * Defines the callback to call when left trigger is pressed
  48799. * @param callback defines the callback to use
  48800. */
  48801. onlefttriggerchanged(callback: (value: number) => void): void;
  48802. /**
  48803. * Defines the callback to call when right trigger is pressed
  48804. * @param callback defines the callback to use
  48805. */
  48806. onrighttriggerchanged(callback: (value: number) => void): void;
  48807. /**
  48808. * Gets the left trigger value
  48809. */
  48810. get leftTrigger(): number;
  48811. /**
  48812. * Sets the left trigger value
  48813. */
  48814. set leftTrigger(newValue: number);
  48815. /**
  48816. * Gets the right trigger value
  48817. */
  48818. get rightTrigger(): number;
  48819. /**
  48820. * Sets the right trigger value
  48821. */
  48822. set rightTrigger(newValue: number);
  48823. /**
  48824. * Defines the callback to call when a button is pressed
  48825. * @param callback defines the callback to use
  48826. */
  48827. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  48828. /**
  48829. * Defines the callback to call when a button is released
  48830. * @param callback defines the callback to use
  48831. */
  48832. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  48833. /**
  48834. * Defines the callback to call when a pad is pressed
  48835. * @param callback defines the callback to use
  48836. */
  48837. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  48838. /**
  48839. * Defines the callback to call when a pad is released
  48840. * @param callback defines the callback to use
  48841. */
  48842. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  48843. private _setButtonValue;
  48844. private _setDPadValue;
  48845. /**
  48846. * Gets the value of the `A` button
  48847. */
  48848. get buttonA(): number;
  48849. /**
  48850. * Sets the value of the `A` button
  48851. */
  48852. set buttonA(value: number);
  48853. /**
  48854. * Gets the value of the `B` button
  48855. */
  48856. get buttonB(): number;
  48857. /**
  48858. * Sets the value of the `B` button
  48859. */
  48860. set buttonB(value: number);
  48861. /**
  48862. * Gets the value of the `X` button
  48863. */
  48864. get buttonX(): number;
  48865. /**
  48866. * Sets the value of the `X` button
  48867. */
  48868. set buttonX(value: number);
  48869. /**
  48870. * Gets the value of the `Y` button
  48871. */
  48872. get buttonY(): number;
  48873. /**
  48874. * Sets the value of the `Y` button
  48875. */
  48876. set buttonY(value: number);
  48877. /**
  48878. * Gets the value of the `Start` button
  48879. */
  48880. get buttonStart(): number;
  48881. /**
  48882. * Sets the value of the `Start` button
  48883. */
  48884. set buttonStart(value: number);
  48885. /**
  48886. * Gets the value of the `Back` button
  48887. */
  48888. get buttonBack(): number;
  48889. /**
  48890. * Sets the value of the `Back` button
  48891. */
  48892. set buttonBack(value: number);
  48893. /**
  48894. * Gets the value of the `Left` button
  48895. */
  48896. get buttonLB(): number;
  48897. /**
  48898. * Sets the value of the `Left` button
  48899. */
  48900. set buttonLB(value: number);
  48901. /**
  48902. * Gets the value of the `Right` button
  48903. */
  48904. get buttonRB(): number;
  48905. /**
  48906. * Sets the value of the `Right` button
  48907. */
  48908. set buttonRB(value: number);
  48909. /**
  48910. * Gets the value of the Left joystick
  48911. */
  48912. get buttonLeftStick(): number;
  48913. /**
  48914. * Sets the value of the Left joystick
  48915. */
  48916. set buttonLeftStick(value: number);
  48917. /**
  48918. * Gets the value of the Right joystick
  48919. */
  48920. get buttonRightStick(): number;
  48921. /**
  48922. * Sets the value of the Right joystick
  48923. */
  48924. set buttonRightStick(value: number);
  48925. /**
  48926. * Gets the value of D-pad up
  48927. */
  48928. get dPadUp(): number;
  48929. /**
  48930. * Sets the value of D-pad up
  48931. */
  48932. set dPadUp(value: number);
  48933. /**
  48934. * Gets the value of D-pad down
  48935. */
  48936. get dPadDown(): number;
  48937. /**
  48938. * Sets the value of D-pad down
  48939. */
  48940. set dPadDown(value: number);
  48941. /**
  48942. * Gets the value of D-pad left
  48943. */
  48944. get dPadLeft(): number;
  48945. /**
  48946. * Sets the value of D-pad left
  48947. */
  48948. set dPadLeft(value: number);
  48949. /**
  48950. * Gets the value of D-pad right
  48951. */
  48952. get dPadRight(): number;
  48953. /**
  48954. * Sets the value of D-pad right
  48955. */
  48956. set dPadRight(value: number);
  48957. /**
  48958. * Force the gamepad to synchronize with device values
  48959. */
  48960. update(): void;
  48961. /**
  48962. * Disposes the gamepad
  48963. */
  48964. dispose(): void;
  48965. }
  48966. }
  48967. declare module BABYLON {
  48968. /**
  48969. * Defines supported buttons for DualShock compatible gamepads
  48970. */
  48971. export enum DualShockButton {
  48972. /** Cross */
  48973. Cross = 0,
  48974. /** Circle */
  48975. Circle = 1,
  48976. /** Square */
  48977. Square = 2,
  48978. /** Triangle */
  48979. Triangle = 3,
  48980. /** L1 */
  48981. L1 = 4,
  48982. /** R1 */
  48983. R1 = 5,
  48984. /** Share */
  48985. Share = 8,
  48986. /** Options */
  48987. Options = 9,
  48988. /** Left stick */
  48989. LeftStick = 10,
  48990. /** Right stick */
  48991. RightStick = 11
  48992. }
  48993. /** Defines values for DualShock DPad */
  48994. export enum DualShockDpad {
  48995. /** Up */
  48996. Up = 12,
  48997. /** Down */
  48998. Down = 13,
  48999. /** Left */
  49000. Left = 14,
  49001. /** Right */
  49002. Right = 15
  49003. }
  49004. /**
  49005. * Defines a DualShock gamepad
  49006. */
  49007. export class DualShockPad extends Gamepad {
  49008. private _leftTrigger;
  49009. private _rightTrigger;
  49010. private _onlefttriggerchanged;
  49011. private _onrighttriggerchanged;
  49012. private _onbuttondown;
  49013. private _onbuttonup;
  49014. private _ondpaddown;
  49015. private _ondpadup;
  49016. /** Observable raised when a button is pressed */
  49017. onButtonDownObservable: Observable<DualShockButton>;
  49018. /** Observable raised when a button is released */
  49019. onButtonUpObservable: Observable<DualShockButton>;
  49020. /** Observable raised when a pad is pressed */
  49021. onPadDownObservable: Observable<DualShockDpad>;
  49022. /** Observable raised when a pad is released */
  49023. onPadUpObservable: Observable<DualShockDpad>;
  49024. private _buttonCross;
  49025. private _buttonCircle;
  49026. private _buttonSquare;
  49027. private _buttonTriangle;
  49028. private _buttonShare;
  49029. private _buttonOptions;
  49030. private _buttonL1;
  49031. private _buttonR1;
  49032. private _buttonLeftStick;
  49033. private _buttonRightStick;
  49034. private _dPadUp;
  49035. private _dPadDown;
  49036. private _dPadLeft;
  49037. private _dPadRight;
  49038. /**
  49039. * Creates a new DualShock gamepad object
  49040. * @param id defines the id of this gamepad
  49041. * @param index defines its index
  49042. * @param gamepad defines the internal HTML gamepad object
  49043. */
  49044. constructor(id: string, index: number, gamepad: any);
  49045. /**
  49046. * Defines the callback to call when left trigger is pressed
  49047. * @param callback defines the callback to use
  49048. */
  49049. onlefttriggerchanged(callback: (value: number) => void): void;
  49050. /**
  49051. * Defines the callback to call when right trigger is pressed
  49052. * @param callback defines the callback to use
  49053. */
  49054. onrighttriggerchanged(callback: (value: number) => void): void;
  49055. /**
  49056. * Gets the left trigger value
  49057. */
  49058. get leftTrigger(): number;
  49059. /**
  49060. * Sets the left trigger value
  49061. */
  49062. set leftTrigger(newValue: number);
  49063. /**
  49064. * Gets the right trigger value
  49065. */
  49066. get rightTrigger(): number;
  49067. /**
  49068. * Sets the right trigger value
  49069. */
  49070. set rightTrigger(newValue: number);
  49071. /**
  49072. * Defines the callback to call when a button is pressed
  49073. * @param callback defines the callback to use
  49074. */
  49075. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  49076. /**
  49077. * Defines the callback to call when a button is released
  49078. * @param callback defines the callback to use
  49079. */
  49080. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  49081. /**
  49082. * Defines the callback to call when a pad is pressed
  49083. * @param callback defines the callback to use
  49084. */
  49085. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  49086. /**
  49087. * Defines the callback to call when a pad is released
  49088. * @param callback defines the callback to use
  49089. */
  49090. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  49091. private _setButtonValue;
  49092. private _setDPadValue;
  49093. /**
  49094. * Gets the value of the `Cross` button
  49095. */
  49096. get buttonCross(): number;
  49097. /**
  49098. * Sets the value of the `Cross` button
  49099. */
  49100. set buttonCross(value: number);
  49101. /**
  49102. * Gets the value of the `Circle` button
  49103. */
  49104. get buttonCircle(): number;
  49105. /**
  49106. * Sets the value of the `Circle` button
  49107. */
  49108. set buttonCircle(value: number);
  49109. /**
  49110. * Gets the value of the `Square` button
  49111. */
  49112. get buttonSquare(): number;
  49113. /**
  49114. * Sets the value of the `Square` button
  49115. */
  49116. set buttonSquare(value: number);
  49117. /**
  49118. * Gets the value of the `Triangle` button
  49119. */
  49120. get buttonTriangle(): number;
  49121. /**
  49122. * Sets the value of the `Triangle` button
  49123. */
  49124. set buttonTriangle(value: number);
  49125. /**
  49126. * Gets the value of the `Options` button
  49127. */
  49128. get buttonOptions(): number;
  49129. /**
  49130. * Sets the value of the `Options` button
  49131. */
  49132. set buttonOptions(value: number);
  49133. /**
  49134. * Gets the value of the `Share` button
  49135. */
  49136. get buttonShare(): number;
  49137. /**
  49138. * Sets the value of the `Share` button
  49139. */
  49140. set buttonShare(value: number);
  49141. /**
  49142. * Gets the value of the `L1` button
  49143. */
  49144. get buttonL1(): number;
  49145. /**
  49146. * Sets the value of the `L1` button
  49147. */
  49148. set buttonL1(value: number);
  49149. /**
  49150. * Gets the value of the `R1` button
  49151. */
  49152. get buttonR1(): number;
  49153. /**
  49154. * Sets the value of the `R1` button
  49155. */
  49156. set buttonR1(value: number);
  49157. /**
  49158. * Gets the value of the Left joystick
  49159. */
  49160. get buttonLeftStick(): number;
  49161. /**
  49162. * Sets the value of the Left joystick
  49163. */
  49164. set buttonLeftStick(value: number);
  49165. /**
  49166. * Gets the value of the Right joystick
  49167. */
  49168. get buttonRightStick(): number;
  49169. /**
  49170. * Sets the value of the Right joystick
  49171. */
  49172. set buttonRightStick(value: number);
  49173. /**
  49174. * Gets the value of D-pad up
  49175. */
  49176. get dPadUp(): number;
  49177. /**
  49178. * Sets the value of D-pad up
  49179. */
  49180. set dPadUp(value: number);
  49181. /**
  49182. * Gets the value of D-pad down
  49183. */
  49184. get dPadDown(): number;
  49185. /**
  49186. * Sets the value of D-pad down
  49187. */
  49188. set dPadDown(value: number);
  49189. /**
  49190. * Gets the value of D-pad left
  49191. */
  49192. get dPadLeft(): number;
  49193. /**
  49194. * Sets the value of D-pad left
  49195. */
  49196. set dPadLeft(value: number);
  49197. /**
  49198. * Gets the value of D-pad right
  49199. */
  49200. get dPadRight(): number;
  49201. /**
  49202. * Sets the value of D-pad right
  49203. */
  49204. set dPadRight(value: number);
  49205. /**
  49206. * Force the gamepad to synchronize with device values
  49207. */
  49208. update(): void;
  49209. /**
  49210. * Disposes the gamepad
  49211. */
  49212. dispose(): void;
  49213. }
  49214. }
  49215. declare module BABYLON {
  49216. /**
  49217. * Manager for handling gamepads
  49218. */
  49219. export class GamepadManager {
  49220. private _scene?;
  49221. private _babylonGamepads;
  49222. private _oneGamepadConnected;
  49223. /** @hidden */
  49224. _isMonitoring: boolean;
  49225. private _gamepadEventSupported;
  49226. private _gamepadSupport?;
  49227. /**
  49228. * observable to be triggered when the gamepad controller has been connected
  49229. */
  49230. onGamepadConnectedObservable: Observable<Gamepad>;
  49231. /**
  49232. * observable to be triggered when the gamepad controller has been disconnected
  49233. */
  49234. onGamepadDisconnectedObservable: Observable<Gamepad>;
  49235. private _onGamepadConnectedEvent;
  49236. private _onGamepadDisconnectedEvent;
  49237. /**
  49238. * Initializes the gamepad manager
  49239. * @param _scene BabylonJS scene
  49240. */
  49241. constructor(_scene?: Scene | undefined);
  49242. /**
  49243. * The gamepads in the game pad manager
  49244. */
  49245. get gamepads(): Gamepad[];
  49246. /**
  49247. * Get the gamepad controllers based on type
  49248. * @param type The type of gamepad controller
  49249. * @returns Nullable gamepad
  49250. */
  49251. getGamepadByType(type?: number): Nullable<Gamepad>;
  49252. /**
  49253. * Disposes the gamepad manager
  49254. */
  49255. dispose(): void;
  49256. private _addNewGamepad;
  49257. private _startMonitoringGamepads;
  49258. private _stopMonitoringGamepads;
  49259. /** @hidden */
  49260. _checkGamepadsStatus(): void;
  49261. private _updateGamepadObjects;
  49262. }
  49263. }
  49264. declare module BABYLON {
  49265. interface Scene {
  49266. /** @hidden */
  49267. _gamepadManager: Nullable<GamepadManager>;
  49268. /**
  49269. * Gets the gamepad manager associated with the scene
  49270. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  49271. */
  49272. gamepadManager: GamepadManager;
  49273. }
  49274. /**
  49275. * Interface representing a free camera inputs manager
  49276. */
  49277. interface FreeCameraInputsManager {
  49278. /**
  49279. * Adds gamepad input support to the FreeCameraInputsManager.
  49280. * @returns the FreeCameraInputsManager
  49281. */
  49282. addGamepad(): FreeCameraInputsManager;
  49283. }
  49284. /**
  49285. * Interface representing an arc rotate camera inputs manager
  49286. */
  49287. interface ArcRotateCameraInputsManager {
  49288. /**
  49289. * Adds gamepad input support to the ArcRotateCamera InputManager.
  49290. * @returns the camera inputs manager
  49291. */
  49292. addGamepad(): ArcRotateCameraInputsManager;
  49293. }
  49294. /**
  49295. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  49296. */
  49297. export class GamepadSystemSceneComponent implements ISceneComponent {
  49298. /**
  49299. * The component name helpfull to identify the component in the list of scene components.
  49300. */
  49301. readonly name: string;
  49302. /**
  49303. * The scene the component belongs to.
  49304. */
  49305. scene: Scene;
  49306. /**
  49307. * Creates a new instance of the component for the given scene
  49308. * @param scene Defines the scene to register the component in
  49309. */
  49310. constructor(scene: Scene);
  49311. /**
  49312. * Registers the component in a given scene
  49313. */
  49314. register(): void;
  49315. /**
  49316. * Rebuilds the elements related to this component in case of
  49317. * context lost for instance.
  49318. */
  49319. rebuild(): void;
  49320. /**
  49321. * Disposes the component and the associated ressources
  49322. */
  49323. dispose(): void;
  49324. private _beforeCameraUpdate;
  49325. }
  49326. }
  49327. declare module BABYLON {
  49328. /**
  49329. * 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,
  49330. * which still works and will still be found in many Playgrounds.
  49331. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49332. */
  49333. export class UniversalCamera extends TouchCamera {
  49334. /**
  49335. * Defines the gamepad rotation sensiblity.
  49336. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  49337. */
  49338. get gamepadAngularSensibility(): number;
  49339. set gamepadAngularSensibility(value: number);
  49340. /**
  49341. * Defines the gamepad move sensiblity.
  49342. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  49343. */
  49344. get gamepadMoveSensibility(): number;
  49345. set gamepadMoveSensibility(value: number);
  49346. /**
  49347. * 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,
  49348. * which still works and will still be found in many Playgrounds.
  49349. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49350. * @param name Define the name of the camera in the scene
  49351. * @param position Define the start position of the camera in the scene
  49352. * @param scene Define the scene the camera belongs to
  49353. */
  49354. constructor(name: string, position: Vector3, scene: Scene);
  49355. /**
  49356. * Gets the current object class name.
  49357. * @return the class name
  49358. */
  49359. getClassName(): string;
  49360. }
  49361. }
  49362. declare module BABYLON {
  49363. /**
  49364. * This represents a FPS type of camera. This is only here for back compat purpose.
  49365. * Please use the UniversalCamera instead as both are identical.
  49366. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49367. */
  49368. export class GamepadCamera extends UniversalCamera {
  49369. /**
  49370. * Instantiates a new Gamepad Camera
  49371. * This represents a FPS type of camera. This is only here for back compat purpose.
  49372. * Please use the UniversalCamera instead as both are identical.
  49373. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49374. * @param name Define the name of the camera in the scene
  49375. * @param position Define the start position of the camera in the scene
  49376. * @param scene Define the scene the camera belongs to
  49377. */
  49378. constructor(name: string, position: Vector3, scene: Scene);
  49379. /**
  49380. * Gets the current object class name.
  49381. * @return the class name
  49382. */
  49383. getClassName(): string;
  49384. }
  49385. }
  49386. declare module BABYLON {
  49387. /** @hidden */
  49388. export var passPixelShader: {
  49389. name: string;
  49390. shader: string;
  49391. };
  49392. }
  49393. declare module BABYLON {
  49394. /** @hidden */
  49395. export var passCubePixelShader: {
  49396. name: string;
  49397. shader: string;
  49398. };
  49399. }
  49400. declare module BABYLON {
  49401. /**
  49402. * PassPostProcess which produces an output the same as it's input
  49403. */
  49404. export class PassPostProcess extends PostProcess {
  49405. /**
  49406. * Gets a string identifying the name of the class
  49407. * @returns "PassPostProcess" string
  49408. */
  49409. getClassName(): string;
  49410. /**
  49411. * Creates the PassPostProcess
  49412. * @param name The name of the effect.
  49413. * @param options The required width/height ratio to downsize to before computing the render pass.
  49414. * @param camera The camera to apply the render pass to.
  49415. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49416. * @param engine The engine which the post process will be applied. (default: current engine)
  49417. * @param reusable If the post process can be reused on the same frame. (default: false)
  49418. * @param textureType The type of texture to be used when performing the post processing.
  49419. * @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)
  49420. */
  49421. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49422. /** @hidden */
  49423. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  49424. }
  49425. /**
  49426. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  49427. */
  49428. export class PassCubePostProcess extends PostProcess {
  49429. private _face;
  49430. /**
  49431. * Gets or sets the cube face to display.
  49432. * * 0 is +X
  49433. * * 1 is -X
  49434. * * 2 is +Y
  49435. * * 3 is -Y
  49436. * * 4 is +Z
  49437. * * 5 is -Z
  49438. */
  49439. get face(): number;
  49440. set face(value: number);
  49441. /**
  49442. * Gets a string identifying the name of the class
  49443. * @returns "PassCubePostProcess" string
  49444. */
  49445. getClassName(): string;
  49446. /**
  49447. * Creates the PassCubePostProcess
  49448. * @param name The name of the effect.
  49449. * @param options The required width/height ratio to downsize to before computing the render pass.
  49450. * @param camera The camera to apply the render pass to.
  49451. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49452. * @param engine The engine which the post process will be applied. (default: current engine)
  49453. * @param reusable If the post process can be reused on the same frame. (default: false)
  49454. * @param textureType The type of texture to be used when performing the post processing.
  49455. * @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)
  49456. */
  49457. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49458. /** @hidden */
  49459. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  49460. }
  49461. }
  49462. declare module BABYLON {
  49463. /** @hidden */
  49464. export var anaglyphPixelShader: {
  49465. name: string;
  49466. shader: string;
  49467. };
  49468. }
  49469. declare module BABYLON {
  49470. /**
  49471. * Postprocess used to generate anaglyphic rendering
  49472. */
  49473. export class AnaglyphPostProcess extends PostProcess {
  49474. private _passedProcess;
  49475. /**
  49476. * Gets a string identifying the name of the class
  49477. * @returns "AnaglyphPostProcess" string
  49478. */
  49479. getClassName(): string;
  49480. /**
  49481. * Creates a new AnaglyphPostProcess
  49482. * @param name defines postprocess name
  49483. * @param options defines creation options or target ratio scale
  49484. * @param rigCameras defines cameras using this postprocess
  49485. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  49486. * @param engine defines hosting engine
  49487. * @param reusable defines if the postprocess will be reused multiple times per frame
  49488. */
  49489. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  49490. }
  49491. }
  49492. declare module BABYLON {
  49493. /**
  49494. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  49495. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49496. */
  49497. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  49498. /**
  49499. * Creates a new AnaglyphArcRotateCamera
  49500. * @param name defines camera name
  49501. * @param alpha defines alpha angle (in radians)
  49502. * @param beta defines beta angle (in radians)
  49503. * @param radius defines radius
  49504. * @param target defines camera target
  49505. * @param interaxialDistance defines distance between each color axis
  49506. * @param scene defines the hosting scene
  49507. */
  49508. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  49509. /**
  49510. * Gets camera class name
  49511. * @returns AnaglyphArcRotateCamera
  49512. */
  49513. getClassName(): string;
  49514. }
  49515. }
  49516. declare module BABYLON {
  49517. /**
  49518. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  49519. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49520. */
  49521. export class AnaglyphFreeCamera extends FreeCamera {
  49522. /**
  49523. * Creates a new AnaglyphFreeCamera
  49524. * @param name defines camera name
  49525. * @param position defines initial position
  49526. * @param interaxialDistance defines distance between each color axis
  49527. * @param scene defines the hosting scene
  49528. */
  49529. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49530. /**
  49531. * Gets camera class name
  49532. * @returns AnaglyphFreeCamera
  49533. */
  49534. getClassName(): string;
  49535. }
  49536. }
  49537. declare module BABYLON {
  49538. /**
  49539. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  49540. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49541. */
  49542. export class AnaglyphGamepadCamera extends GamepadCamera {
  49543. /**
  49544. * Creates a new AnaglyphGamepadCamera
  49545. * @param name defines camera name
  49546. * @param position defines initial position
  49547. * @param interaxialDistance defines distance between each color axis
  49548. * @param scene defines the hosting scene
  49549. */
  49550. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49551. /**
  49552. * Gets camera class name
  49553. * @returns AnaglyphGamepadCamera
  49554. */
  49555. getClassName(): string;
  49556. }
  49557. }
  49558. declare module BABYLON {
  49559. /**
  49560. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  49561. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49562. */
  49563. export class AnaglyphUniversalCamera extends UniversalCamera {
  49564. /**
  49565. * Creates a new AnaglyphUniversalCamera
  49566. * @param name defines camera name
  49567. * @param position defines initial position
  49568. * @param interaxialDistance defines distance between each color axis
  49569. * @param scene defines the hosting scene
  49570. */
  49571. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49572. /**
  49573. * Gets camera class name
  49574. * @returns AnaglyphUniversalCamera
  49575. */
  49576. getClassName(): string;
  49577. }
  49578. }
  49579. declare module BABYLON {
  49580. /**
  49581. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  49582. * @see https://doc.babylonjs.com/features/cameras
  49583. */
  49584. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  49585. /**
  49586. * Creates a new StereoscopicArcRotateCamera
  49587. * @param name defines camera name
  49588. * @param alpha defines alpha angle (in radians)
  49589. * @param beta defines beta angle (in radians)
  49590. * @param radius defines radius
  49591. * @param target defines camera target
  49592. * @param interaxialDistance defines distance between each color axis
  49593. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49594. * @param scene defines the hosting scene
  49595. */
  49596. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49597. /**
  49598. * Gets camera class name
  49599. * @returns StereoscopicArcRotateCamera
  49600. */
  49601. getClassName(): string;
  49602. }
  49603. }
  49604. declare module BABYLON {
  49605. /**
  49606. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  49607. * @see https://doc.babylonjs.com/features/cameras
  49608. */
  49609. export class StereoscopicFreeCamera extends FreeCamera {
  49610. /**
  49611. * Creates a new StereoscopicFreeCamera
  49612. * @param name defines camera name
  49613. * @param position defines initial position
  49614. * @param interaxialDistance defines distance between each color axis
  49615. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49616. * @param scene defines the hosting scene
  49617. */
  49618. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49619. /**
  49620. * Gets camera class name
  49621. * @returns StereoscopicFreeCamera
  49622. */
  49623. getClassName(): string;
  49624. }
  49625. }
  49626. declare module BABYLON {
  49627. /**
  49628. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  49629. * @see https://doc.babylonjs.com/features/cameras
  49630. */
  49631. export class StereoscopicGamepadCamera extends GamepadCamera {
  49632. /**
  49633. * Creates a new StereoscopicGamepadCamera
  49634. * @param name defines camera name
  49635. * @param position defines initial position
  49636. * @param interaxialDistance defines distance between each color axis
  49637. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49638. * @param scene defines the hosting scene
  49639. */
  49640. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49641. /**
  49642. * Gets camera class name
  49643. * @returns StereoscopicGamepadCamera
  49644. */
  49645. getClassName(): string;
  49646. }
  49647. }
  49648. declare module BABYLON {
  49649. /**
  49650. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  49651. * @see https://doc.babylonjs.com/features/cameras
  49652. */
  49653. export class StereoscopicUniversalCamera extends UniversalCamera {
  49654. /**
  49655. * Creates a new StereoscopicUniversalCamera
  49656. * @param name defines camera name
  49657. * @param position defines initial position
  49658. * @param interaxialDistance defines distance between each color axis
  49659. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49660. * @param scene defines the hosting scene
  49661. */
  49662. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49663. /**
  49664. * Gets camera class name
  49665. * @returns StereoscopicUniversalCamera
  49666. */
  49667. getClassName(): string;
  49668. }
  49669. }
  49670. declare module BABYLON {
  49671. /**
  49672. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  49673. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  49674. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  49675. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  49676. */
  49677. export class VirtualJoysticksCamera extends FreeCamera {
  49678. /**
  49679. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  49680. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  49681. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  49682. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  49683. * @param name Define the name of the camera in the scene
  49684. * @param position Define the start position of the camera in the scene
  49685. * @param scene Define the scene the camera belongs to
  49686. */
  49687. constructor(name: string, position: Vector3, scene: Scene);
  49688. /**
  49689. * Gets the current object class name.
  49690. * @return the class name
  49691. */
  49692. getClassName(): string;
  49693. }
  49694. }
  49695. declare module BABYLON {
  49696. /**
  49697. * This represents all the required metrics to create a VR camera.
  49698. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  49699. */
  49700. export class VRCameraMetrics {
  49701. /**
  49702. * Define the horizontal resolution off the screen.
  49703. */
  49704. hResolution: number;
  49705. /**
  49706. * Define the vertical resolution off the screen.
  49707. */
  49708. vResolution: number;
  49709. /**
  49710. * Define the horizontal screen size.
  49711. */
  49712. hScreenSize: number;
  49713. /**
  49714. * Define the vertical screen size.
  49715. */
  49716. vScreenSize: number;
  49717. /**
  49718. * Define the vertical screen center position.
  49719. */
  49720. vScreenCenter: number;
  49721. /**
  49722. * Define the distance of the eyes to the screen.
  49723. */
  49724. eyeToScreenDistance: number;
  49725. /**
  49726. * Define the distance between both lenses
  49727. */
  49728. lensSeparationDistance: number;
  49729. /**
  49730. * Define the distance between both viewer's eyes.
  49731. */
  49732. interpupillaryDistance: number;
  49733. /**
  49734. * Define the distortion factor of the VR postprocess.
  49735. * Please, touch with care.
  49736. */
  49737. distortionK: number[];
  49738. /**
  49739. * Define the chromatic aberration correction factors for the VR post process.
  49740. */
  49741. chromaAbCorrection: number[];
  49742. /**
  49743. * Define the scale factor of the post process.
  49744. * The smaller the better but the slower.
  49745. */
  49746. postProcessScaleFactor: number;
  49747. /**
  49748. * Define an offset for the lens center.
  49749. */
  49750. lensCenterOffset: number;
  49751. /**
  49752. * Define if the current vr camera should compensate the distortion of the lense or not.
  49753. */
  49754. compensateDistortion: boolean;
  49755. /**
  49756. * Defines if multiview should be enabled when rendering (Default: false)
  49757. */
  49758. multiviewEnabled: boolean;
  49759. /**
  49760. * Gets the rendering aspect ratio based on the provided resolutions.
  49761. */
  49762. get aspectRatio(): number;
  49763. /**
  49764. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  49765. */
  49766. get aspectRatioFov(): number;
  49767. /**
  49768. * @hidden
  49769. */
  49770. get leftHMatrix(): Matrix;
  49771. /**
  49772. * @hidden
  49773. */
  49774. get rightHMatrix(): Matrix;
  49775. /**
  49776. * @hidden
  49777. */
  49778. get leftPreViewMatrix(): Matrix;
  49779. /**
  49780. * @hidden
  49781. */
  49782. get rightPreViewMatrix(): Matrix;
  49783. /**
  49784. * Get the default VRMetrics based on the most generic setup.
  49785. * @returns the default vr metrics
  49786. */
  49787. static GetDefault(): VRCameraMetrics;
  49788. }
  49789. }
  49790. declare module BABYLON {
  49791. /** @hidden */
  49792. export var vrDistortionCorrectionPixelShader: {
  49793. name: string;
  49794. shader: string;
  49795. };
  49796. }
  49797. declare module BABYLON {
  49798. /**
  49799. * VRDistortionCorrectionPostProcess used for mobile VR
  49800. */
  49801. export class VRDistortionCorrectionPostProcess extends PostProcess {
  49802. private _isRightEye;
  49803. private _distortionFactors;
  49804. private _postProcessScaleFactor;
  49805. private _lensCenterOffset;
  49806. private _scaleIn;
  49807. private _scaleFactor;
  49808. private _lensCenter;
  49809. /**
  49810. * Gets a string identifying the name of the class
  49811. * @returns "VRDistortionCorrectionPostProcess" string
  49812. */
  49813. getClassName(): string;
  49814. /**
  49815. * Initializes the VRDistortionCorrectionPostProcess
  49816. * @param name The name of the effect.
  49817. * @param camera The camera to apply the render pass to.
  49818. * @param isRightEye If this is for the right eye distortion
  49819. * @param vrMetrics All the required metrics for the VR camera
  49820. */
  49821. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  49822. }
  49823. }
  49824. declare module BABYLON {
  49825. /**
  49826. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  49827. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  49828. */
  49829. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  49830. /**
  49831. * Creates a new VRDeviceOrientationArcRotateCamera
  49832. * @param name defines camera name
  49833. * @param alpha defines the camera rotation along the logitudinal axis
  49834. * @param beta defines the camera rotation along the latitudinal axis
  49835. * @param radius defines the camera distance from its target
  49836. * @param target defines the camera target
  49837. * @param scene defines the scene the camera belongs to
  49838. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  49839. * @param vrCameraMetrics defines the vr metrics associated to the camera
  49840. */
  49841. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  49842. /**
  49843. * Gets camera class name
  49844. * @returns VRDeviceOrientationArcRotateCamera
  49845. */
  49846. getClassName(): string;
  49847. }
  49848. }
  49849. declare module BABYLON {
  49850. /**
  49851. * Camera used to simulate VR rendering (based on FreeCamera)
  49852. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  49853. */
  49854. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  49855. /**
  49856. * Creates a new VRDeviceOrientationFreeCamera
  49857. * @param name defines camera name
  49858. * @param position defines the start position of the camera
  49859. * @param scene defines the scene the camera belongs to
  49860. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  49861. * @param vrCameraMetrics defines the vr metrics associated to the camera
  49862. */
  49863. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  49864. /**
  49865. * Gets camera class name
  49866. * @returns VRDeviceOrientationFreeCamera
  49867. */
  49868. getClassName(): string;
  49869. }
  49870. }
  49871. declare module BABYLON {
  49872. /**
  49873. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  49874. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  49875. */
  49876. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  49877. /**
  49878. * Creates a new VRDeviceOrientationGamepadCamera
  49879. * @param name defines camera name
  49880. * @param position defines the start position of the camera
  49881. * @param scene defines the scene the camera belongs to
  49882. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  49883. * @param vrCameraMetrics defines the vr metrics associated to the camera
  49884. */
  49885. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  49886. /**
  49887. * Gets camera class name
  49888. * @returns VRDeviceOrientationGamepadCamera
  49889. */
  49890. getClassName(): string;
  49891. }
  49892. }
  49893. declare module BABYLON {
  49894. /**
  49895. * A class extending Texture allowing drawing on a texture
  49896. * @see https://doc.babylonjs.com/how_to/dynamictexture
  49897. */
  49898. export class DynamicTexture extends Texture {
  49899. private _generateMipMaps;
  49900. private _canvas;
  49901. private _context;
  49902. /**
  49903. * Creates a DynamicTexture
  49904. * @param name defines the name of the texture
  49905. * @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
  49906. * @param scene defines the scene where you want the texture
  49907. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  49908. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  49909. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  49910. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  49911. */
  49912. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  49913. /**
  49914. * Get the current class name of the texture useful for serialization or dynamic coding.
  49915. * @returns "DynamicTexture"
  49916. */
  49917. getClassName(): string;
  49918. /**
  49919. * Gets the current state of canRescale
  49920. */
  49921. get canRescale(): boolean;
  49922. private _recreate;
  49923. /**
  49924. * Scales the texture
  49925. * @param ratio the scale factor to apply to both width and height
  49926. */
  49927. scale(ratio: number): void;
  49928. /**
  49929. * Resizes the texture
  49930. * @param width the new width
  49931. * @param height the new height
  49932. */
  49933. scaleTo(width: number, height: number): void;
  49934. /**
  49935. * Gets the context of the canvas used by the texture
  49936. * @returns the canvas context of the dynamic texture
  49937. */
  49938. getContext(): CanvasRenderingContext2D;
  49939. /**
  49940. * Clears the texture
  49941. */
  49942. clear(): void;
  49943. /**
  49944. * Updates the texture
  49945. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  49946. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  49947. */
  49948. update(invertY?: boolean, premulAlpha?: boolean): void;
  49949. /**
  49950. * Draws text onto the texture
  49951. * @param text defines the text to be drawn
  49952. * @param x defines the placement of the text from the left
  49953. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  49954. * @param font defines the font to be used with font-style, font-size, font-name
  49955. * @param color defines the color used for the text
  49956. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  49957. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  49958. * @param update defines whether texture is immediately update (default is true)
  49959. */
  49960. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  49961. /**
  49962. * Clones the texture
  49963. * @returns the clone of the texture.
  49964. */
  49965. clone(): DynamicTexture;
  49966. /**
  49967. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  49968. * @returns a serialized dynamic texture object
  49969. */
  49970. serialize(): any;
  49971. private _IsCanvasElement;
  49972. /** @hidden */
  49973. _rebuild(): void;
  49974. }
  49975. }
  49976. declare module BABYLON {
  49977. /**
  49978. * Class containing static functions to help procedurally build meshes
  49979. */
  49980. export class GroundBuilder {
  49981. /**
  49982. * Creates a ground mesh
  49983. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  49984. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  49985. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49986. * @param name defines the name of the mesh
  49987. * @param options defines the options used to create the mesh
  49988. * @param scene defines the hosting scene
  49989. * @returns the ground mesh
  49990. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  49991. */
  49992. static CreateGround(name: string, options: {
  49993. width?: number;
  49994. height?: number;
  49995. subdivisions?: number;
  49996. subdivisionsX?: number;
  49997. subdivisionsY?: number;
  49998. updatable?: boolean;
  49999. }, scene: any): Mesh;
  50000. /**
  50001. * Creates a tiled ground mesh
  50002. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  50003. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  50004. * * 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
  50005. * * 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
  50006. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50007. * @param name defines the name of the mesh
  50008. * @param options defines the options used to create the mesh
  50009. * @param scene defines the hosting scene
  50010. * @returns the tiled ground mesh
  50011. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  50012. */
  50013. static CreateTiledGround(name: string, options: {
  50014. xmin: number;
  50015. zmin: number;
  50016. xmax: number;
  50017. zmax: number;
  50018. subdivisions?: {
  50019. w: number;
  50020. h: number;
  50021. };
  50022. precision?: {
  50023. w: number;
  50024. h: number;
  50025. };
  50026. updatable?: boolean;
  50027. }, scene?: Nullable<Scene>): Mesh;
  50028. /**
  50029. * Creates a ground mesh from a height map
  50030. * * The parameter `url` sets the URL of the height map image resource.
  50031. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  50032. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  50033. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  50034. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  50035. * * 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.
  50036. * * 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).
  50037. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  50038. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50039. * @param name defines the name of the mesh
  50040. * @param url defines the url to the height map
  50041. * @param options defines the options used to create the mesh
  50042. * @param scene defines the hosting scene
  50043. * @returns the ground mesh
  50044. * @see https://doc.babylonjs.com/babylon101/height_map
  50045. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  50046. */
  50047. static CreateGroundFromHeightMap(name: string, url: string, options: {
  50048. width?: number;
  50049. height?: number;
  50050. subdivisions?: number;
  50051. minHeight?: number;
  50052. maxHeight?: number;
  50053. colorFilter?: Color3;
  50054. alphaFilter?: number;
  50055. updatable?: boolean;
  50056. onReady?: (mesh: GroundMesh) => void;
  50057. }, scene?: Nullable<Scene>): GroundMesh;
  50058. }
  50059. }
  50060. declare module BABYLON {
  50061. /**
  50062. * Class containing static functions to help procedurally build meshes
  50063. */
  50064. export class TorusBuilder {
  50065. /**
  50066. * Creates a torus mesh
  50067. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  50068. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  50069. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  50070. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50071. * * 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
  50072. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50073. * @param name defines the name of the mesh
  50074. * @param options defines the options used to create the mesh
  50075. * @param scene defines the hosting scene
  50076. * @returns the torus mesh
  50077. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  50078. */
  50079. static CreateTorus(name: string, options: {
  50080. diameter?: number;
  50081. thickness?: number;
  50082. tessellation?: number;
  50083. updatable?: boolean;
  50084. sideOrientation?: number;
  50085. frontUVs?: Vector4;
  50086. backUVs?: Vector4;
  50087. }, scene: any): Mesh;
  50088. }
  50089. }
  50090. declare module BABYLON {
  50091. /**
  50092. * Class containing static functions to help procedurally build meshes
  50093. */
  50094. export class CylinderBuilder {
  50095. /**
  50096. * Creates a cylinder or a cone mesh
  50097. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  50098. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  50099. * * 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.
  50100. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  50101. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  50102. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  50103. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  50104. * * 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).
  50105. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  50106. * * 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).
  50107. * * 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
  50108. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  50109. * * 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
  50110. * * 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.
  50111. * * If `enclose` is false, a ring surface is one element.
  50112. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  50113. * * 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
  50114. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50115. * * 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
  50116. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50117. * @param name defines the name of the mesh
  50118. * @param options defines the options used to create the mesh
  50119. * @param scene defines the hosting scene
  50120. * @returns the cylinder mesh
  50121. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  50122. */
  50123. static CreateCylinder(name: string, options: {
  50124. height?: number;
  50125. diameterTop?: number;
  50126. diameterBottom?: number;
  50127. diameter?: number;
  50128. tessellation?: number;
  50129. subdivisions?: number;
  50130. arc?: number;
  50131. faceColors?: Color4[];
  50132. faceUV?: Vector4[];
  50133. updatable?: boolean;
  50134. hasRings?: boolean;
  50135. enclose?: boolean;
  50136. cap?: number;
  50137. sideOrientation?: number;
  50138. frontUVs?: Vector4;
  50139. backUVs?: Vector4;
  50140. }, scene: any): Mesh;
  50141. }
  50142. }
  50143. declare module BABYLON {
  50144. /**
  50145. * States of the webXR experience
  50146. */
  50147. export enum WebXRState {
  50148. /**
  50149. * Transitioning to being in XR mode
  50150. */
  50151. ENTERING_XR = 0,
  50152. /**
  50153. * Transitioning to non XR mode
  50154. */
  50155. EXITING_XR = 1,
  50156. /**
  50157. * In XR mode and presenting
  50158. */
  50159. IN_XR = 2,
  50160. /**
  50161. * Not entered XR mode
  50162. */
  50163. NOT_IN_XR = 3
  50164. }
  50165. /**
  50166. * The state of the XR camera's tracking
  50167. */
  50168. export enum WebXRTrackingState {
  50169. /**
  50170. * No transformation received, device is not being tracked
  50171. */
  50172. NOT_TRACKING = 0,
  50173. /**
  50174. * Tracking lost - using emulated position
  50175. */
  50176. TRACKING_LOST = 1,
  50177. /**
  50178. * Transformation tracking works normally
  50179. */
  50180. TRACKING = 2
  50181. }
  50182. /**
  50183. * Abstraction of the XR render target
  50184. */
  50185. export interface WebXRRenderTarget extends IDisposable {
  50186. /**
  50187. * xrpresent context of the canvas which can be used to display/mirror xr content
  50188. */
  50189. canvasContext: WebGLRenderingContext;
  50190. /**
  50191. * xr layer for the canvas
  50192. */
  50193. xrLayer: Nullable<XRWebGLLayer>;
  50194. /**
  50195. * Initializes the xr layer for the session
  50196. * @param xrSession xr session
  50197. * @returns a promise that will resolve once the XR Layer has been created
  50198. */
  50199. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  50200. }
  50201. }
  50202. declare module BABYLON {
  50203. /**
  50204. * COnfiguration object for WebXR output canvas
  50205. */
  50206. export class WebXRManagedOutputCanvasOptions {
  50207. /**
  50208. * An optional canvas in case you wish to create it yourself and provide it here.
  50209. * If not provided, a new canvas will be created
  50210. */
  50211. canvasElement?: HTMLCanvasElement;
  50212. /**
  50213. * Options for this XR Layer output
  50214. */
  50215. canvasOptions?: XRWebGLLayerInit;
  50216. /**
  50217. * CSS styling for a newly created canvas (if not provided)
  50218. */
  50219. newCanvasCssStyle?: string;
  50220. /**
  50221. * Get the default values of the configuration object
  50222. * @param engine defines the engine to use (can be null)
  50223. * @returns default values of this configuration object
  50224. */
  50225. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  50226. }
  50227. /**
  50228. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  50229. */
  50230. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  50231. private _options;
  50232. private _canvas;
  50233. private _engine;
  50234. private _originalCanvasSize;
  50235. /**
  50236. * Rendering context of the canvas which can be used to display/mirror xr content
  50237. */
  50238. canvasContext: WebGLRenderingContext;
  50239. /**
  50240. * xr layer for the canvas
  50241. */
  50242. xrLayer: Nullable<XRWebGLLayer>;
  50243. /**
  50244. * Obseervers registered here will be triggered when the xr layer was initialized
  50245. */
  50246. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  50247. /**
  50248. * Initializes the canvas to be added/removed upon entering/exiting xr
  50249. * @param _xrSessionManager The XR Session manager
  50250. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  50251. */
  50252. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  50253. /**
  50254. * Disposes of the object
  50255. */
  50256. dispose(): void;
  50257. /**
  50258. * Initializes the xr layer for the session
  50259. * @param xrSession xr session
  50260. * @returns a promise that will resolve once the XR Layer has been created
  50261. */
  50262. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  50263. private _addCanvas;
  50264. private _removeCanvas;
  50265. private _setCanvasSize;
  50266. private _setManagedOutputCanvas;
  50267. }
  50268. }
  50269. declare module BABYLON {
  50270. /**
  50271. * Manages an XRSession to work with Babylon's engine
  50272. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  50273. */
  50274. export class WebXRSessionManager implements IDisposable {
  50275. /** The scene which the session should be created for */
  50276. scene: Scene;
  50277. private _referenceSpace;
  50278. private _rttProvider;
  50279. private _sessionEnded;
  50280. private _xrNavigator;
  50281. private baseLayer;
  50282. /**
  50283. * The base reference space from which the session started. good if you want to reset your
  50284. * reference space
  50285. */
  50286. baseReferenceSpace: XRReferenceSpace;
  50287. /**
  50288. * Current XR frame
  50289. */
  50290. currentFrame: Nullable<XRFrame>;
  50291. /** WebXR timestamp updated every frame */
  50292. currentTimestamp: number;
  50293. /**
  50294. * Used just in case of a failure to initialize an immersive session.
  50295. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  50296. */
  50297. defaultHeightCompensation: number;
  50298. /**
  50299. * Fires every time a new xrFrame arrives which can be used to update the camera
  50300. */
  50301. onXRFrameObservable: Observable<XRFrame>;
  50302. /**
  50303. * Fires when the reference space changed
  50304. */
  50305. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  50306. /**
  50307. * Fires when the xr session is ended either by the device or manually done
  50308. */
  50309. onXRSessionEnded: Observable<any>;
  50310. /**
  50311. * Fires when the xr session is ended either by the device or manually done
  50312. */
  50313. onXRSessionInit: Observable<XRSession>;
  50314. /**
  50315. * Underlying xr session
  50316. */
  50317. session: XRSession;
  50318. /**
  50319. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  50320. * or get the offset the player is currently at.
  50321. */
  50322. viewerReferenceSpace: XRReferenceSpace;
  50323. /**
  50324. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  50325. * @param scene The scene which the session should be created for
  50326. */
  50327. constructor(
  50328. /** The scene which the session should be created for */
  50329. scene: Scene);
  50330. /**
  50331. * The current reference space used in this session. This reference space can constantly change!
  50332. * It is mainly used to offset the camera's position.
  50333. */
  50334. get referenceSpace(): XRReferenceSpace;
  50335. /**
  50336. * Set a new reference space and triggers the observable
  50337. */
  50338. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  50339. /**
  50340. * Disposes of the session manager
  50341. */
  50342. dispose(): void;
  50343. /**
  50344. * Stops the xrSession and restores the render loop
  50345. * @returns Promise which resolves after it exits XR
  50346. */
  50347. exitXRAsync(): Promise<void>;
  50348. /**
  50349. * Gets the correct render target texture to be rendered this frame for this eye
  50350. * @param eye the eye for which to get the render target
  50351. * @returns the render target for the specified eye
  50352. */
  50353. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  50354. /**
  50355. * Creates a WebXRRenderTarget object for the XR session
  50356. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  50357. * @param options optional options to provide when creating a new render target
  50358. * @returns a WebXR render target to which the session can render
  50359. */
  50360. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  50361. /**
  50362. * Initializes the manager
  50363. * After initialization enterXR can be called to start an XR session
  50364. * @returns Promise which resolves after it is initialized
  50365. */
  50366. initializeAsync(): Promise<void>;
  50367. /**
  50368. * Initializes an xr session
  50369. * @param xrSessionMode mode to initialize
  50370. * @param xrSessionInit defines optional and required values to pass to the session builder
  50371. * @returns a promise which will resolve once the session has been initialized
  50372. */
  50373. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  50374. /**
  50375. * Checks if a session would be supported for the creation options specified
  50376. * @param sessionMode session mode to check if supported eg. immersive-vr
  50377. * @returns A Promise that resolves to true if supported and false if not
  50378. */
  50379. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  50380. /**
  50381. * Resets the reference space to the one started the session
  50382. */
  50383. resetReferenceSpace(): void;
  50384. /**
  50385. * Starts rendering to the xr layer
  50386. */
  50387. runXRRenderLoop(): void;
  50388. /**
  50389. * Sets the reference space on the xr session
  50390. * @param referenceSpaceType space to set
  50391. * @returns a promise that will resolve once the reference space has been set
  50392. */
  50393. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  50394. /**
  50395. * Updates the render state of the session
  50396. * @param state state to set
  50397. * @returns a promise that resolves once the render state has been updated
  50398. */
  50399. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  50400. /**
  50401. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  50402. * @param sessionMode defines the session to test
  50403. * @returns a promise with boolean as final value
  50404. */
  50405. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  50406. private _createRenderTargetTexture;
  50407. }
  50408. }
  50409. declare module BABYLON {
  50410. /**
  50411. * WebXR Camera which holds the views for the xrSession
  50412. * @see https://doc.babylonjs.com/how_to/webxr_camera
  50413. */
  50414. export class WebXRCamera extends FreeCamera {
  50415. private _xrSessionManager;
  50416. private _firstFrame;
  50417. private _referenceQuaternion;
  50418. private _referencedPosition;
  50419. private _xrInvPositionCache;
  50420. private _xrInvQuaternionCache;
  50421. private _trackingState;
  50422. /**
  50423. * Observable raised before camera teleportation
  50424. */
  50425. onBeforeCameraTeleport: Observable<Vector3>;
  50426. /**
  50427. * Observable raised after camera teleportation
  50428. */
  50429. onAfterCameraTeleport: Observable<Vector3>;
  50430. /**
  50431. * Notifies when the camera's tracking state has changed.
  50432. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  50433. */
  50434. onTrackingStateChanged: Observable<WebXRTrackingState>;
  50435. /**
  50436. * Should position compensation execute on first frame.
  50437. * This is used when copying the position from a native (non XR) camera
  50438. */
  50439. compensateOnFirstFrame: boolean;
  50440. /**
  50441. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  50442. * @param name the name of the camera
  50443. * @param scene the scene to add the camera to
  50444. * @param _xrSessionManager a constructed xr session manager
  50445. */
  50446. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  50447. /**
  50448. * Get the current XR tracking state of the camera
  50449. */
  50450. get trackingState(): WebXRTrackingState;
  50451. private _setTrackingState;
  50452. /**
  50453. * Return the user's height, unrelated to the current ground.
  50454. * This will be the y position of this camera, when ground level is 0.
  50455. */
  50456. get realWorldHeight(): number;
  50457. /** @hidden */
  50458. _updateForDualEyeDebugging(): void;
  50459. /**
  50460. * Sets this camera's transformation based on a non-vr camera
  50461. * @param otherCamera the non-vr camera to copy the transformation from
  50462. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  50463. */
  50464. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  50465. /**
  50466. * Gets the current instance class name ("WebXRCamera").
  50467. * @returns the class name
  50468. */
  50469. getClassName(): string;
  50470. private _rotate180;
  50471. private _updateFromXRSession;
  50472. private _updateNumberOfRigCameras;
  50473. private _updateReferenceSpace;
  50474. private _updateReferenceSpaceOffset;
  50475. }
  50476. }
  50477. declare module BABYLON {
  50478. /**
  50479. * Defining the interface required for a (webxr) feature
  50480. */
  50481. export interface IWebXRFeature extends IDisposable {
  50482. /**
  50483. * Is this feature attached
  50484. */
  50485. attached: boolean;
  50486. /**
  50487. * Should auto-attach be disabled?
  50488. */
  50489. disableAutoAttach: boolean;
  50490. /**
  50491. * Attach the feature to the session
  50492. * Will usually be called by the features manager
  50493. *
  50494. * @param force should attachment be forced (even when already attached)
  50495. * @returns true if successful.
  50496. */
  50497. attach(force?: boolean): boolean;
  50498. /**
  50499. * Detach the feature from the session
  50500. * Will usually be called by the features manager
  50501. *
  50502. * @returns true if successful.
  50503. */
  50504. detach(): boolean;
  50505. /**
  50506. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  50507. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  50508. *
  50509. * @returns whether or not the feature is compatible in this environment
  50510. */
  50511. isCompatible(): boolean;
  50512. /**
  50513. * Was this feature disposed;
  50514. */
  50515. isDisposed: boolean;
  50516. /**
  50517. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  50518. */
  50519. xrNativeFeatureName?: string;
  50520. /**
  50521. * A list of (Babylon WebXR) features this feature depends on
  50522. */
  50523. dependsOn?: string[];
  50524. }
  50525. /**
  50526. * A list of the currently available features without referencing them
  50527. */
  50528. export class WebXRFeatureName {
  50529. /**
  50530. * The name of the anchor system feature
  50531. */
  50532. static readonly ANCHOR_SYSTEM: string;
  50533. /**
  50534. * The name of the background remover feature
  50535. */
  50536. static readonly BACKGROUND_REMOVER: string;
  50537. /**
  50538. * The name of the hit test feature
  50539. */
  50540. static readonly HIT_TEST: string;
  50541. /**
  50542. * physics impostors for xr controllers feature
  50543. */
  50544. static readonly PHYSICS_CONTROLLERS: string;
  50545. /**
  50546. * The name of the plane detection feature
  50547. */
  50548. static readonly PLANE_DETECTION: string;
  50549. /**
  50550. * The name of the pointer selection feature
  50551. */
  50552. static readonly POINTER_SELECTION: string;
  50553. /**
  50554. * The name of the teleportation feature
  50555. */
  50556. static readonly TELEPORTATION: string;
  50557. /**
  50558. * The name of the feature points feature.
  50559. */
  50560. static readonly FEATURE_POINTS: string;
  50561. /**
  50562. * The name of the hand tracking feature.
  50563. */
  50564. static readonly HAND_TRACKING: string;
  50565. }
  50566. /**
  50567. * Defining the constructor of a feature. Used to register the modules.
  50568. */
  50569. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  50570. /**
  50571. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  50572. * It is mainly used in AR sessions.
  50573. *
  50574. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  50575. */
  50576. export class WebXRFeaturesManager implements IDisposable {
  50577. private _xrSessionManager;
  50578. private static readonly _AvailableFeatures;
  50579. private _features;
  50580. /**
  50581. * constructs a new features manages.
  50582. *
  50583. * @param _xrSessionManager an instance of WebXRSessionManager
  50584. */
  50585. constructor(_xrSessionManager: WebXRSessionManager);
  50586. /**
  50587. * Used to register a module. After calling this function a developer can use this feature in the scene.
  50588. * Mainly used internally.
  50589. *
  50590. * @param featureName the name of the feature to register
  50591. * @param constructorFunction the function used to construct the module
  50592. * @param version the (babylon) version of the module
  50593. * @param stable is that a stable version of this module
  50594. */
  50595. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  50596. /**
  50597. * Returns a constructor of a specific feature.
  50598. *
  50599. * @param featureName the name of the feature to construct
  50600. * @param version the version of the feature to load
  50601. * @param xrSessionManager the xrSessionManager. Used to construct the module
  50602. * @param options optional options provided to the module.
  50603. * @returns a function that, when called, will return a new instance of this feature
  50604. */
  50605. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  50606. /**
  50607. * Can be used to return the list of features currently registered
  50608. *
  50609. * @returns an Array of available features
  50610. */
  50611. static GetAvailableFeatures(): string[];
  50612. /**
  50613. * Gets the versions available for a specific feature
  50614. * @param featureName the name of the feature
  50615. * @returns an array with the available versions
  50616. */
  50617. static GetAvailableVersions(featureName: string): string[];
  50618. /**
  50619. * Return the latest unstable version of this feature
  50620. * @param featureName the name of the feature to search
  50621. * @returns the version number. if not found will return -1
  50622. */
  50623. static GetLatestVersionOfFeature(featureName: string): number;
  50624. /**
  50625. * Return the latest stable version of this feature
  50626. * @param featureName the name of the feature to search
  50627. * @returns the version number. if not found will return -1
  50628. */
  50629. static GetStableVersionOfFeature(featureName: string): number;
  50630. /**
  50631. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  50632. * Can be used during a session to start a feature
  50633. * @param featureName the name of feature to attach
  50634. */
  50635. attachFeature(featureName: string): void;
  50636. /**
  50637. * Can be used inside a session or when the session ends to detach a specific feature
  50638. * @param featureName the name of the feature to detach
  50639. */
  50640. detachFeature(featureName: string): void;
  50641. /**
  50642. * Used to disable an already-enabled feature
  50643. * The feature will be disposed and will be recreated once enabled.
  50644. * @param featureName the feature to disable
  50645. * @returns true if disable was successful
  50646. */
  50647. disableFeature(featureName: string | {
  50648. Name: string;
  50649. }): boolean;
  50650. /**
  50651. * dispose this features manager
  50652. */
  50653. dispose(): void;
  50654. /**
  50655. * 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.
  50656. * 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.
  50657. *
  50658. * @param featureName the name of the feature to load or the class of the feature
  50659. * @param version optional version to load. if not provided the latest version will be enabled
  50660. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  50661. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  50662. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  50663. * @returns a new constructed feature or throws an error if feature not found.
  50664. */
  50665. enableFeature(featureName: string | {
  50666. Name: string;
  50667. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  50668. /**
  50669. * get the implementation of an enabled feature.
  50670. * @param featureName the name of the feature to load
  50671. * @returns the feature class, if found
  50672. */
  50673. getEnabledFeature(featureName: string): IWebXRFeature;
  50674. /**
  50675. * Get the list of enabled features
  50676. * @returns an array of enabled features
  50677. */
  50678. getEnabledFeatures(): string[];
  50679. /**
  50680. * This function will exten the session creation configuration object with enabled features.
  50681. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  50682. * according to the defined "required" variable, provided during enableFeature call
  50683. * @param xrSessionInit the xr Session init object to extend
  50684. *
  50685. * @returns an extended XRSessionInit object
  50686. */
  50687. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  50688. }
  50689. }
  50690. declare module BABYLON {
  50691. /**
  50692. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  50693. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  50694. */
  50695. export class WebXRExperienceHelper implements IDisposable {
  50696. private scene;
  50697. private _nonVRCamera;
  50698. private _originalSceneAutoClear;
  50699. private _supported;
  50700. /**
  50701. * Camera used to render xr content
  50702. */
  50703. camera: WebXRCamera;
  50704. /** A features manager for this xr session */
  50705. featuresManager: WebXRFeaturesManager;
  50706. /**
  50707. * Observers registered here will be triggered after the camera's initial transformation is set
  50708. * This can be used to set a different ground level or an extra rotation.
  50709. *
  50710. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  50711. * to the position set after this observable is done executing.
  50712. */
  50713. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  50714. /**
  50715. * Fires when the state of the experience helper has changed
  50716. */
  50717. onStateChangedObservable: Observable<WebXRState>;
  50718. /** Session manager used to keep track of xr session */
  50719. sessionManager: WebXRSessionManager;
  50720. /**
  50721. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  50722. */
  50723. state: WebXRState;
  50724. /**
  50725. * Creates a WebXRExperienceHelper
  50726. * @param scene The scene the helper should be created in
  50727. */
  50728. private constructor();
  50729. /**
  50730. * Creates the experience helper
  50731. * @param scene the scene to attach the experience helper to
  50732. * @returns a promise for the experience helper
  50733. */
  50734. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  50735. /**
  50736. * Disposes of the experience helper
  50737. */
  50738. dispose(): void;
  50739. /**
  50740. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  50741. * @param sessionMode options for the XR session
  50742. * @param referenceSpaceType frame of reference of the XR session
  50743. * @param renderTarget the output canvas that will be used to enter XR mode
  50744. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  50745. * @returns promise that resolves after xr mode has entered
  50746. */
  50747. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  50748. /**
  50749. * Exits XR mode and returns the scene to its original state
  50750. * @returns promise that resolves after xr mode has exited
  50751. */
  50752. exitXRAsync(): Promise<void>;
  50753. private _nonXRToXRCamera;
  50754. private _setState;
  50755. }
  50756. }
  50757. declare module BABYLON {
  50758. /**
  50759. * X-Y values for axes in WebXR
  50760. */
  50761. export interface IWebXRMotionControllerAxesValue {
  50762. /**
  50763. * The value of the x axis
  50764. */
  50765. x: number;
  50766. /**
  50767. * The value of the y-axis
  50768. */
  50769. y: number;
  50770. }
  50771. /**
  50772. * changed / previous values for the values of this component
  50773. */
  50774. export interface IWebXRMotionControllerComponentChangesValues<T> {
  50775. /**
  50776. * current (this frame) value
  50777. */
  50778. current: T;
  50779. /**
  50780. * previous (last change) value
  50781. */
  50782. previous: T;
  50783. }
  50784. /**
  50785. * Represents changes in the component between current frame and last values recorded
  50786. */
  50787. export interface IWebXRMotionControllerComponentChanges {
  50788. /**
  50789. * will be populated with previous and current values if axes changed
  50790. */
  50791. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  50792. /**
  50793. * will be populated with previous and current values if pressed changed
  50794. */
  50795. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  50796. /**
  50797. * will be populated with previous and current values if touched changed
  50798. */
  50799. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  50800. /**
  50801. * will be populated with previous and current values if value changed
  50802. */
  50803. value?: IWebXRMotionControllerComponentChangesValues<number>;
  50804. }
  50805. /**
  50806. * This class represents a single component (for example button or thumbstick) of a motion controller
  50807. */
  50808. export class WebXRControllerComponent implements IDisposable {
  50809. /**
  50810. * the id of this component
  50811. */
  50812. id: string;
  50813. /**
  50814. * the type of the component
  50815. */
  50816. type: MotionControllerComponentType;
  50817. private _buttonIndex;
  50818. private _axesIndices;
  50819. private _axes;
  50820. private _changes;
  50821. private _currentValue;
  50822. private _hasChanges;
  50823. private _pressed;
  50824. private _touched;
  50825. /**
  50826. * button component type
  50827. */
  50828. static BUTTON_TYPE: MotionControllerComponentType;
  50829. /**
  50830. * squeeze component type
  50831. */
  50832. static SQUEEZE_TYPE: MotionControllerComponentType;
  50833. /**
  50834. * Thumbstick component type
  50835. */
  50836. static THUMBSTICK_TYPE: MotionControllerComponentType;
  50837. /**
  50838. * Touchpad component type
  50839. */
  50840. static TOUCHPAD_TYPE: MotionControllerComponentType;
  50841. /**
  50842. * trigger component type
  50843. */
  50844. static TRIGGER_TYPE: MotionControllerComponentType;
  50845. /**
  50846. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  50847. * the axes data changes
  50848. */
  50849. onAxisValueChangedObservable: Observable<{
  50850. x: number;
  50851. y: number;
  50852. }>;
  50853. /**
  50854. * Observers registered here will be triggered when the state of a button changes
  50855. * State change is either pressed / touched / value
  50856. */
  50857. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  50858. /**
  50859. * Creates a new component for a motion controller.
  50860. * It is created by the motion controller itself
  50861. *
  50862. * @param id the id of this component
  50863. * @param type the type of the component
  50864. * @param _buttonIndex index in the buttons array of the gamepad
  50865. * @param _axesIndices indices of the values in the axes array of the gamepad
  50866. */
  50867. constructor(
  50868. /**
  50869. * the id of this component
  50870. */
  50871. id: string,
  50872. /**
  50873. * the type of the component
  50874. */
  50875. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  50876. /**
  50877. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  50878. */
  50879. get axes(): IWebXRMotionControllerAxesValue;
  50880. /**
  50881. * Get the changes. Elements will be populated only if they changed with their previous and current value
  50882. */
  50883. get changes(): IWebXRMotionControllerComponentChanges;
  50884. /**
  50885. * Return whether or not the component changed the last frame
  50886. */
  50887. get hasChanges(): boolean;
  50888. /**
  50889. * is the button currently pressed
  50890. */
  50891. get pressed(): boolean;
  50892. /**
  50893. * is the button currently touched
  50894. */
  50895. get touched(): boolean;
  50896. /**
  50897. * Get the current value of this component
  50898. */
  50899. get value(): number;
  50900. /**
  50901. * Dispose this component
  50902. */
  50903. dispose(): void;
  50904. /**
  50905. * Are there axes correlating to this component
  50906. * @return true is axes data is available
  50907. */
  50908. isAxes(): boolean;
  50909. /**
  50910. * Is this component a button (hence - pressable)
  50911. * @returns true if can be pressed
  50912. */
  50913. isButton(): boolean;
  50914. /**
  50915. * update this component using the gamepad object it is in. Called on every frame
  50916. * @param nativeController the native gamepad controller object
  50917. */
  50918. update(nativeController: IMinimalMotionControllerObject): void;
  50919. }
  50920. }
  50921. declare module BABYLON {
  50922. /**
  50923. * Interface used to represent data loading progression
  50924. */
  50925. export interface ISceneLoaderProgressEvent {
  50926. /**
  50927. * Defines if data length to load can be evaluated
  50928. */
  50929. readonly lengthComputable: boolean;
  50930. /**
  50931. * Defines the loaded data length
  50932. */
  50933. readonly loaded: number;
  50934. /**
  50935. * Defines the data length to load
  50936. */
  50937. readonly total: number;
  50938. }
  50939. /**
  50940. * Interface used by SceneLoader plugins to define supported file extensions
  50941. */
  50942. export interface ISceneLoaderPluginExtensions {
  50943. /**
  50944. * Defines the list of supported extensions
  50945. */
  50946. [extension: string]: {
  50947. isBinary: boolean;
  50948. };
  50949. }
  50950. /**
  50951. * Interface used by SceneLoader plugin factory
  50952. */
  50953. export interface ISceneLoaderPluginFactory {
  50954. /**
  50955. * Defines the name of the factory
  50956. */
  50957. name: string;
  50958. /**
  50959. * Function called to create a new plugin
  50960. * @return the new plugin
  50961. */
  50962. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  50963. /**
  50964. * The callback that returns true if the data can be directly loaded.
  50965. * @param data string containing the file data
  50966. * @returns if the data can be loaded directly
  50967. */
  50968. canDirectLoad?(data: string): boolean;
  50969. }
  50970. /**
  50971. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  50972. */
  50973. export interface ISceneLoaderPluginBase {
  50974. /**
  50975. * The friendly name of this plugin.
  50976. */
  50977. name: string;
  50978. /**
  50979. * The file extensions supported by this plugin.
  50980. */
  50981. extensions: string | ISceneLoaderPluginExtensions;
  50982. /**
  50983. * The callback called when loading from a url.
  50984. * @param scene scene loading this url
  50985. * @param url url to load
  50986. * @param onSuccess callback called when the file successfully loads
  50987. * @param onProgress callback called while file is loading (if the server supports this mode)
  50988. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  50989. * @param onError callback called when the file fails to load
  50990. * @returns a file request object
  50991. */
  50992. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  50993. /**
  50994. * The callback called when loading from a file object.
  50995. * @param scene scene loading this file
  50996. * @param file defines the file to load
  50997. * @param onSuccess defines the callback to call when data is loaded
  50998. * @param onProgress defines the callback to call during loading process
  50999. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  51000. * @param onError defines the callback to call when an error occurs
  51001. * @returns a file request object
  51002. */
  51003. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  51004. /**
  51005. * The callback that returns true if the data can be directly loaded.
  51006. * @param data string containing the file data
  51007. * @returns if the data can be loaded directly
  51008. */
  51009. canDirectLoad?(data: string): boolean;
  51010. /**
  51011. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  51012. * @param scene scene loading this data
  51013. * @param data string containing the data
  51014. * @returns data to pass to the plugin
  51015. */
  51016. directLoad?(scene: Scene, data: string): any;
  51017. /**
  51018. * The callback that allows custom handling of the root url based on the response url.
  51019. * @param rootUrl the original root url
  51020. * @param responseURL the response url if available
  51021. * @returns the new root url
  51022. */
  51023. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  51024. }
  51025. /**
  51026. * Interface used to define a SceneLoader plugin
  51027. */
  51028. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  51029. /**
  51030. * Import meshes into a scene.
  51031. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51032. * @param scene The scene to import into
  51033. * @param data The data to import
  51034. * @param rootUrl The root url for scene and resources
  51035. * @param meshes The meshes array to import into
  51036. * @param particleSystems The particle systems array to import into
  51037. * @param skeletons The skeletons array to import into
  51038. * @param onError The callback when import fails
  51039. * @returns True if successful or false otherwise
  51040. */
  51041. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  51042. /**
  51043. * Load into a scene.
  51044. * @param scene The scene to load into
  51045. * @param data The data to import
  51046. * @param rootUrl The root url for scene and resources
  51047. * @param onError The callback when import fails
  51048. * @returns True if successful or false otherwise
  51049. */
  51050. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  51051. /**
  51052. * Load into an asset container.
  51053. * @param scene The scene to load into
  51054. * @param data The data to import
  51055. * @param rootUrl The root url for scene and resources
  51056. * @param onError The callback when import fails
  51057. * @returns The loaded asset container
  51058. */
  51059. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  51060. }
  51061. /**
  51062. * Interface used to define an async SceneLoader plugin
  51063. */
  51064. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  51065. /**
  51066. * Import meshes into a scene.
  51067. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51068. * @param scene The scene to import into
  51069. * @param data The data to import
  51070. * @param rootUrl The root url for scene and resources
  51071. * @param onProgress The callback when the load progresses
  51072. * @param fileName Defines the name of the file to load
  51073. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  51074. */
  51075. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  51076. meshes: AbstractMesh[];
  51077. particleSystems: IParticleSystem[];
  51078. skeletons: Skeleton[];
  51079. animationGroups: AnimationGroup[];
  51080. }>;
  51081. /**
  51082. * Load into a scene.
  51083. * @param scene The scene to load into
  51084. * @param data The data to import
  51085. * @param rootUrl The root url for scene and resources
  51086. * @param onProgress The callback when the load progresses
  51087. * @param fileName Defines the name of the file to load
  51088. * @returns Nothing
  51089. */
  51090. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  51091. /**
  51092. * Load into an asset container.
  51093. * @param scene The scene to load into
  51094. * @param data The data to import
  51095. * @param rootUrl The root url for scene and resources
  51096. * @param onProgress The callback when the load progresses
  51097. * @param fileName Defines the name of the file to load
  51098. * @returns The loaded asset container
  51099. */
  51100. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  51101. }
  51102. /**
  51103. * Mode that determines how to handle old animation groups before loading new ones.
  51104. */
  51105. export enum SceneLoaderAnimationGroupLoadingMode {
  51106. /**
  51107. * Reset all old animations to initial state then dispose them.
  51108. */
  51109. Clean = 0,
  51110. /**
  51111. * Stop all old animations.
  51112. */
  51113. Stop = 1,
  51114. /**
  51115. * Restart old animations from first frame.
  51116. */
  51117. Sync = 2,
  51118. /**
  51119. * Old animations remains untouched.
  51120. */
  51121. NoSync = 3
  51122. }
  51123. /**
  51124. * Defines a plugin registered by the SceneLoader
  51125. */
  51126. interface IRegisteredPlugin {
  51127. /**
  51128. * Defines the plugin to use
  51129. */
  51130. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  51131. /**
  51132. * Defines if the plugin supports binary data
  51133. */
  51134. isBinary: boolean;
  51135. }
  51136. /**
  51137. * Class used to load scene from various file formats using registered plugins
  51138. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  51139. */
  51140. export class SceneLoader {
  51141. /**
  51142. * No logging while loading
  51143. */
  51144. static readonly NO_LOGGING: number;
  51145. /**
  51146. * Minimal logging while loading
  51147. */
  51148. static readonly MINIMAL_LOGGING: number;
  51149. /**
  51150. * Summary logging while loading
  51151. */
  51152. static readonly SUMMARY_LOGGING: number;
  51153. /**
  51154. * Detailled logging while loading
  51155. */
  51156. static readonly DETAILED_LOGGING: number;
  51157. /**
  51158. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  51159. */
  51160. static get ForceFullSceneLoadingForIncremental(): boolean;
  51161. static set ForceFullSceneLoadingForIncremental(value: boolean);
  51162. /**
  51163. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  51164. */
  51165. static get ShowLoadingScreen(): boolean;
  51166. static set ShowLoadingScreen(value: boolean);
  51167. /**
  51168. * Defines the current logging level (while loading the scene)
  51169. * @ignorenaming
  51170. */
  51171. static get loggingLevel(): number;
  51172. static set loggingLevel(value: number);
  51173. /**
  51174. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  51175. */
  51176. static get CleanBoneMatrixWeights(): boolean;
  51177. static set CleanBoneMatrixWeights(value: boolean);
  51178. /**
  51179. * Event raised when a plugin is used to load a scene
  51180. */
  51181. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  51182. private static _registeredPlugins;
  51183. private static _showingLoadingScreen;
  51184. /**
  51185. * Gets the default plugin (used to load Babylon files)
  51186. * @returns the .babylon plugin
  51187. */
  51188. static GetDefaultPlugin(): IRegisteredPlugin;
  51189. private static _GetPluginForExtension;
  51190. private static _GetPluginForDirectLoad;
  51191. private static _GetPluginForFilename;
  51192. private static _GetDirectLoad;
  51193. private static _LoadData;
  51194. private static _GetFileInfo;
  51195. /**
  51196. * Gets a plugin that can load the given extension
  51197. * @param extension defines the extension to load
  51198. * @returns a plugin or null if none works
  51199. */
  51200. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  51201. /**
  51202. * Gets a boolean indicating that the given extension can be loaded
  51203. * @param extension defines the extension to load
  51204. * @returns true if the extension is supported
  51205. */
  51206. static IsPluginForExtensionAvailable(extension: string): boolean;
  51207. /**
  51208. * Adds a new plugin to the list of registered plugins
  51209. * @param plugin defines the plugin to add
  51210. */
  51211. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  51212. /**
  51213. * Import meshes into a scene
  51214. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51215. * @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)
  51216. * @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)
  51217. * @param scene the instance of BABYLON.Scene to append to
  51218. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  51219. * @param onProgress a callback with a progress event for each file being loaded
  51220. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51221. * @param pluginExtension the extension used to determine the plugin
  51222. * @returns The loaded plugin
  51223. */
  51224. 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>;
  51225. /**
  51226. * Import meshes into a scene
  51227. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51228. * @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)
  51229. * @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)
  51230. * @param scene the instance of BABYLON.Scene to append to
  51231. * @param onProgress a callback with a progress event for each file being loaded
  51232. * @param pluginExtension the extension used to determine the plugin
  51233. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  51234. */
  51235. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  51236. meshes: AbstractMesh[];
  51237. particleSystems: IParticleSystem[];
  51238. skeletons: Skeleton[];
  51239. animationGroups: AnimationGroup[];
  51240. }>;
  51241. /**
  51242. * Load a scene
  51243. * @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)
  51244. * @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)
  51245. * @param engine is the instance of BABYLON.Engine to use to create the scene
  51246. * @param onSuccess a callback with the scene when import succeeds
  51247. * @param onProgress a callback with a progress event for each file being loaded
  51248. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51249. * @param pluginExtension the extension used to determine the plugin
  51250. * @returns The loaded plugin
  51251. */
  51252. 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>;
  51253. /**
  51254. * Load a scene
  51255. * @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)
  51256. * @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)
  51257. * @param engine is the instance of BABYLON.Engine to use to create the scene
  51258. * @param onProgress a callback with a progress event for each file being loaded
  51259. * @param pluginExtension the extension used to determine the plugin
  51260. * @returns The loaded scene
  51261. */
  51262. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  51263. /**
  51264. * Append a scene
  51265. * @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)
  51266. * @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)
  51267. * @param scene is the instance of BABYLON.Scene to append to
  51268. * @param onSuccess a callback with the scene when import succeeds
  51269. * @param onProgress a callback with a progress event for each file being loaded
  51270. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51271. * @param pluginExtension the extension used to determine the plugin
  51272. * @returns The loaded plugin
  51273. */
  51274. 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>;
  51275. /**
  51276. * Append a scene
  51277. * @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)
  51278. * @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)
  51279. * @param scene is the instance of BABYLON.Scene to append to
  51280. * @param onProgress a callback with a progress event for each file being loaded
  51281. * @param pluginExtension the extension used to determine the plugin
  51282. * @returns The given scene
  51283. */
  51284. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  51285. /**
  51286. * Load a scene into an asset container
  51287. * @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)
  51288. * @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)
  51289. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51290. * @param onSuccess a callback with the scene when import succeeds
  51291. * @param onProgress a callback with a progress event for each file being loaded
  51292. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51293. * @param pluginExtension the extension used to determine the plugin
  51294. * @returns The loaded plugin
  51295. */
  51296. 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>;
  51297. /**
  51298. * Load a scene into an asset container
  51299. * @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)
  51300. * @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)
  51301. * @param scene is the instance of Scene to append to
  51302. * @param onProgress a callback with a progress event for each file being loaded
  51303. * @param pluginExtension the extension used to determine the plugin
  51304. * @returns The loaded asset container
  51305. */
  51306. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  51307. /**
  51308. * Import animations from a file into a scene
  51309. * @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)
  51310. * @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)
  51311. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51312. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  51313. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  51314. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  51315. * @param onSuccess a callback with the scene when import succeeds
  51316. * @param onProgress a callback with a progress event for each file being loaded
  51317. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51318. * @param pluginExtension the extension used to determine the plugin
  51319. */
  51320. 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;
  51321. /**
  51322. * Import animations from a file into a scene
  51323. * @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)
  51324. * @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)
  51325. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51326. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  51327. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  51328. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  51329. * @param onSuccess a callback with the scene when import succeeds
  51330. * @param onProgress a callback with a progress event for each file being loaded
  51331. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51332. * @param pluginExtension the extension used to determine the plugin
  51333. * @returns the updated scene with imported animations
  51334. */
  51335. 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>;
  51336. }
  51337. }
  51338. declare module BABYLON {
  51339. /**
  51340. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  51341. */
  51342. export type MotionControllerHandedness = "none" | "left" | "right";
  51343. /**
  51344. * The type of components available in motion controllers.
  51345. * This is not the name of the component.
  51346. */
  51347. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  51348. /**
  51349. * The state of a controller component
  51350. */
  51351. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  51352. /**
  51353. * The schema of motion controller layout.
  51354. * No object will be initialized using this interface
  51355. * This is used just to define the profile.
  51356. */
  51357. export interface IMotionControllerLayout {
  51358. /**
  51359. * Path to load the assets. Usually relative to the base path
  51360. */
  51361. assetPath: string;
  51362. /**
  51363. * Available components (unsorted)
  51364. */
  51365. components: {
  51366. /**
  51367. * A map of component Ids
  51368. */
  51369. [componentId: string]: {
  51370. /**
  51371. * The type of input the component outputs
  51372. */
  51373. type: MotionControllerComponentType;
  51374. /**
  51375. * The indices of this component in the gamepad object
  51376. */
  51377. gamepadIndices: {
  51378. /**
  51379. * Index of button
  51380. */
  51381. button?: number;
  51382. /**
  51383. * If available, index of x-axis
  51384. */
  51385. xAxis?: number;
  51386. /**
  51387. * If available, index of y-axis
  51388. */
  51389. yAxis?: number;
  51390. };
  51391. /**
  51392. * The mesh's root node name
  51393. */
  51394. rootNodeName: string;
  51395. /**
  51396. * Animation definitions for this model
  51397. */
  51398. visualResponses: {
  51399. [stateKey: string]: {
  51400. /**
  51401. * What property will be animated
  51402. */
  51403. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  51404. /**
  51405. * What states influence this visual response
  51406. */
  51407. states: MotionControllerComponentStateType[];
  51408. /**
  51409. * Type of animation - movement or visibility
  51410. */
  51411. valueNodeProperty: "transform" | "visibility";
  51412. /**
  51413. * Base node name to move. Its position will be calculated according to the min and max nodes
  51414. */
  51415. valueNodeName?: string;
  51416. /**
  51417. * Minimum movement node
  51418. */
  51419. minNodeName?: string;
  51420. /**
  51421. * Max movement node
  51422. */
  51423. maxNodeName?: string;
  51424. };
  51425. };
  51426. /**
  51427. * If touch enabled, what is the name of node to display user feedback
  51428. */
  51429. touchPointNodeName?: string;
  51430. };
  51431. };
  51432. /**
  51433. * Is it xr standard mapping or not
  51434. */
  51435. gamepadMapping: "" | "xr-standard";
  51436. /**
  51437. * Base root node of this entire model
  51438. */
  51439. rootNodeName: string;
  51440. /**
  51441. * Defines the main button component id
  51442. */
  51443. selectComponentId: string;
  51444. }
  51445. /**
  51446. * A definition for the layout map in the input profile
  51447. */
  51448. export interface IMotionControllerLayoutMap {
  51449. /**
  51450. * Layouts with handedness type as a key
  51451. */
  51452. [handedness: string]: IMotionControllerLayout;
  51453. }
  51454. /**
  51455. * The XR Input profile schema
  51456. * Profiles can be found here:
  51457. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  51458. */
  51459. export interface IMotionControllerProfile {
  51460. /**
  51461. * fallback profiles for this profileId
  51462. */
  51463. fallbackProfileIds: string[];
  51464. /**
  51465. * The layout map, with handedness as key
  51466. */
  51467. layouts: IMotionControllerLayoutMap;
  51468. /**
  51469. * The id of this profile
  51470. * correlates to the profile(s) in the xrInput.profiles array
  51471. */
  51472. profileId: string;
  51473. }
  51474. /**
  51475. * A helper-interface for the 3 meshes needed for controller button animation
  51476. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  51477. */
  51478. export interface IMotionControllerButtonMeshMap {
  51479. /**
  51480. * the mesh that defines the pressed value mesh position.
  51481. * This is used to find the max-position of this button
  51482. */
  51483. pressedMesh: AbstractMesh;
  51484. /**
  51485. * the mesh that defines the unpressed value mesh position.
  51486. * This is used to find the min (or initial) position of this button
  51487. */
  51488. unpressedMesh: AbstractMesh;
  51489. /**
  51490. * The mesh that will be changed when value changes
  51491. */
  51492. valueMesh: AbstractMesh;
  51493. }
  51494. /**
  51495. * A helper-interface for the 3 meshes needed for controller axis animation.
  51496. * This will be expanded when touchpad animations are fully supported
  51497. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  51498. */
  51499. export interface IMotionControllerMeshMap {
  51500. /**
  51501. * the mesh that defines the maximum value mesh position.
  51502. */
  51503. maxMesh?: AbstractMesh;
  51504. /**
  51505. * the mesh that defines the minimum value mesh position.
  51506. */
  51507. minMesh?: AbstractMesh;
  51508. /**
  51509. * The mesh that will be changed when axis value changes
  51510. */
  51511. valueMesh?: AbstractMesh;
  51512. }
  51513. /**
  51514. * The elements needed for change-detection of the gamepad objects in motion controllers
  51515. */
  51516. export interface IMinimalMotionControllerObject {
  51517. /**
  51518. * Available axes of this controller
  51519. */
  51520. axes: number[];
  51521. /**
  51522. * An array of available buttons
  51523. */
  51524. buttons: Array<{
  51525. /**
  51526. * Value of the button/trigger
  51527. */
  51528. value: number;
  51529. /**
  51530. * If the button/trigger is currently touched
  51531. */
  51532. touched: boolean;
  51533. /**
  51534. * If the button/trigger is currently pressed
  51535. */
  51536. pressed: boolean;
  51537. }>;
  51538. /**
  51539. * EXPERIMENTAL haptic support.
  51540. */
  51541. hapticActuators?: Array<{
  51542. pulse: (value: number, duration: number) => Promise<boolean>;
  51543. }>;
  51544. }
  51545. /**
  51546. * An Abstract Motion controller
  51547. * This class receives an xrInput and a profile layout and uses those to initialize the components
  51548. * Each component has an observable to check for changes in value and state
  51549. */
  51550. export abstract class WebXRAbstractMotionController implements IDisposable {
  51551. protected scene: Scene;
  51552. protected layout: IMotionControllerLayout;
  51553. /**
  51554. * The gamepad object correlating to this controller
  51555. */
  51556. gamepadObject: IMinimalMotionControllerObject;
  51557. /**
  51558. * handedness (left/right/none) of this controller
  51559. */
  51560. handedness: MotionControllerHandedness;
  51561. private _initComponent;
  51562. private _modelReady;
  51563. /**
  51564. * A map of components (WebXRControllerComponent) in this motion controller
  51565. * Components have a ComponentType and can also have both button and axis definitions
  51566. */
  51567. readonly components: {
  51568. [id: string]: WebXRControllerComponent;
  51569. };
  51570. /**
  51571. * Disable the model's animation. Can be set at any time.
  51572. */
  51573. disableAnimation: boolean;
  51574. /**
  51575. * Observers registered here will be triggered when the model of this controller is done loading
  51576. */
  51577. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  51578. /**
  51579. * The profile id of this motion controller
  51580. */
  51581. abstract profileId: string;
  51582. /**
  51583. * The root mesh of the model. It is null if the model was not yet initialized
  51584. */
  51585. rootMesh: Nullable<AbstractMesh>;
  51586. /**
  51587. * constructs a new abstract motion controller
  51588. * @param scene the scene to which the model of the controller will be added
  51589. * @param layout The profile layout to load
  51590. * @param gamepadObject The gamepad object correlating to this controller
  51591. * @param handedness handedness (left/right/none) of this controller
  51592. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  51593. */
  51594. constructor(scene: Scene, layout: IMotionControllerLayout,
  51595. /**
  51596. * The gamepad object correlating to this controller
  51597. */
  51598. gamepadObject: IMinimalMotionControllerObject,
  51599. /**
  51600. * handedness (left/right/none) of this controller
  51601. */
  51602. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  51603. /**
  51604. * Dispose this controller, the model mesh and all its components
  51605. */
  51606. dispose(): void;
  51607. /**
  51608. * Returns all components of specific type
  51609. * @param type the type to search for
  51610. * @return an array of components with this type
  51611. */
  51612. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  51613. /**
  51614. * get a component based an its component id as defined in layout.components
  51615. * @param id the id of the component
  51616. * @returns the component correlates to the id or undefined if not found
  51617. */
  51618. getComponent(id: string): WebXRControllerComponent;
  51619. /**
  51620. * Get the list of components available in this motion controller
  51621. * @returns an array of strings correlating to available components
  51622. */
  51623. getComponentIds(): string[];
  51624. /**
  51625. * Get the first component of specific type
  51626. * @param type type of component to find
  51627. * @return a controller component or null if not found
  51628. */
  51629. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  51630. /**
  51631. * Get the main (Select) component of this controller as defined in the layout
  51632. * @returns the main component of this controller
  51633. */
  51634. getMainComponent(): WebXRControllerComponent;
  51635. /**
  51636. * Loads the model correlating to this controller
  51637. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  51638. * @returns A promise fulfilled with the result of the model loading
  51639. */
  51640. loadModel(): Promise<boolean>;
  51641. /**
  51642. * Update this model using the current XRFrame
  51643. * @param xrFrame the current xr frame to use and update the model
  51644. */
  51645. updateFromXRFrame(xrFrame: XRFrame): void;
  51646. /**
  51647. * Backwards compatibility due to a deeply-integrated typo
  51648. */
  51649. get handness(): XREye;
  51650. /**
  51651. * Pulse (vibrate) this controller
  51652. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  51653. * Consecutive calls to this function will cancel the last pulse call
  51654. *
  51655. * @param value the strength of the pulse in 0.0...1.0 range
  51656. * @param duration Duration of the pulse in milliseconds
  51657. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  51658. * @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
  51659. */
  51660. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  51661. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  51662. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  51663. /**
  51664. * Moves the axis on the controller mesh based on its current state
  51665. * @param axis the index of the axis
  51666. * @param axisValue the value of the axis which determines the meshes new position
  51667. * @hidden
  51668. */
  51669. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  51670. /**
  51671. * Update the model itself with the current frame data
  51672. * @param xrFrame the frame to use for updating the model mesh
  51673. */
  51674. protected updateModel(xrFrame: XRFrame): void;
  51675. /**
  51676. * Get the filename and path for this controller's model
  51677. * @returns a map of filename and path
  51678. */
  51679. protected abstract _getFilenameAndPath(): {
  51680. filename: string;
  51681. path: string;
  51682. };
  51683. /**
  51684. * This function is called before the mesh is loaded. It checks for loading constraints.
  51685. * For example, this function can check if the GLB loader is available
  51686. * If this function returns false, the generic controller will be loaded instead
  51687. * @returns Is the client ready to load the mesh
  51688. */
  51689. protected abstract _getModelLoadingConstraints(): boolean;
  51690. /**
  51691. * This function will be called after the model was successfully loaded and can be used
  51692. * for mesh transformations before it is available for the user
  51693. * @param meshes the loaded meshes
  51694. */
  51695. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  51696. /**
  51697. * Set the root mesh for this controller. Important for the WebXR controller class
  51698. * @param meshes the loaded meshes
  51699. */
  51700. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  51701. /**
  51702. * A function executed each frame that updates the mesh (if needed)
  51703. * @param xrFrame the current xrFrame
  51704. */
  51705. protected abstract _updateModel(xrFrame: XRFrame): void;
  51706. private _getGenericFilenameAndPath;
  51707. private _getGenericParentMesh;
  51708. }
  51709. }
  51710. declare module BABYLON {
  51711. /**
  51712. * A generic trigger-only motion controller for WebXR
  51713. */
  51714. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  51715. /**
  51716. * Static version of the profile id of this controller
  51717. */
  51718. static ProfileId: string;
  51719. profileId: string;
  51720. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  51721. protected _getFilenameAndPath(): {
  51722. filename: string;
  51723. path: string;
  51724. };
  51725. protected _getModelLoadingConstraints(): boolean;
  51726. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  51727. protected _setRootMesh(meshes: AbstractMesh[]): void;
  51728. protected _updateModel(): void;
  51729. }
  51730. }
  51731. declare module BABYLON {
  51732. /**
  51733. * Class containing static functions to help procedurally build meshes
  51734. */
  51735. export class SphereBuilder {
  51736. /**
  51737. * Creates a sphere mesh
  51738. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  51739. * * 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`)
  51740. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  51741. * * 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
  51742. * * 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)
  51743. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51744. * * 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
  51745. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51746. * @param name defines the name of the mesh
  51747. * @param options defines the options used to create the mesh
  51748. * @param scene defines the hosting scene
  51749. * @returns the sphere mesh
  51750. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  51751. */
  51752. static CreateSphere(name: string, options: {
  51753. segments?: number;
  51754. diameter?: number;
  51755. diameterX?: number;
  51756. diameterY?: number;
  51757. diameterZ?: number;
  51758. arc?: number;
  51759. slice?: number;
  51760. sideOrientation?: number;
  51761. frontUVs?: Vector4;
  51762. backUVs?: Vector4;
  51763. updatable?: boolean;
  51764. }, scene?: Nullable<Scene>): Mesh;
  51765. }
  51766. }
  51767. declare module BABYLON {
  51768. /**
  51769. * A profiled motion controller has its profile loaded from an online repository.
  51770. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  51771. */
  51772. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  51773. private _repositoryUrl;
  51774. private _buttonMeshMapping;
  51775. private _touchDots;
  51776. /**
  51777. * The profile ID of this controller. Will be populated when the controller initializes.
  51778. */
  51779. profileId: string;
  51780. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  51781. dispose(): void;
  51782. protected _getFilenameAndPath(): {
  51783. filename: string;
  51784. path: string;
  51785. };
  51786. protected _getModelLoadingConstraints(): boolean;
  51787. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  51788. protected _setRootMesh(meshes: AbstractMesh[]): void;
  51789. protected _updateModel(_xrFrame: XRFrame): void;
  51790. }
  51791. }
  51792. declare module BABYLON {
  51793. /**
  51794. * A construction function type to create a new controller based on an xrInput object
  51795. */
  51796. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  51797. /**
  51798. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  51799. *
  51800. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  51801. * it should be replaced with auto-loaded controllers.
  51802. *
  51803. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  51804. */
  51805. export class WebXRMotionControllerManager {
  51806. private static _AvailableControllers;
  51807. private static _Fallbacks;
  51808. private static _ProfileLoadingPromises;
  51809. private static _ProfilesList;
  51810. /**
  51811. * The base URL of the online controller repository. Can be changed at any time.
  51812. */
  51813. static BaseRepositoryUrl: string;
  51814. /**
  51815. * Which repository gets priority - local or online
  51816. */
  51817. static PrioritizeOnlineRepository: boolean;
  51818. /**
  51819. * Use the online repository, or use only locally-defined controllers
  51820. */
  51821. static UseOnlineRepository: boolean;
  51822. /**
  51823. * Clear the cache used for profile loading and reload when requested again
  51824. */
  51825. static ClearProfilesCache(): void;
  51826. /**
  51827. * Register the default fallbacks.
  51828. * This function is called automatically when this file is imported.
  51829. */
  51830. static DefaultFallbacks(): void;
  51831. /**
  51832. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  51833. * @param profileId the profile to which a fallback needs to be found
  51834. * @return an array with corresponding fallback profiles
  51835. */
  51836. static FindFallbackWithProfileId(profileId: string): string[];
  51837. /**
  51838. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  51839. * The order of search:
  51840. *
  51841. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  51842. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  51843. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  51844. * 4) return the generic trigger controller if none were found
  51845. *
  51846. * @param xrInput the xrInput to which a new controller is initialized
  51847. * @param scene the scene to which the model will be added
  51848. * @param forceProfile force a certain profile for this controller
  51849. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  51850. */
  51851. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  51852. /**
  51853. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  51854. *
  51855. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  51856. *
  51857. * @param type the profile type to register
  51858. * @param constructFunction the function to be called when loading this profile
  51859. */
  51860. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  51861. /**
  51862. * Register a fallback to a specific profile.
  51863. * @param profileId the profileId that will receive the fallbacks
  51864. * @param fallbacks A list of fallback profiles
  51865. */
  51866. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  51867. /**
  51868. * Will update the list of profiles available in the repository
  51869. * @return a promise that resolves to a map of profiles available online
  51870. */
  51871. static UpdateProfilesList(): Promise<{
  51872. [profile: string]: string;
  51873. }>;
  51874. private static _LoadProfileFromRepository;
  51875. private static _LoadProfilesFromAvailableControllers;
  51876. }
  51877. }
  51878. declare module BABYLON {
  51879. /**
  51880. * Configuration options for the WebXR controller creation
  51881. */
  51882. export interface IWebXRControllerOptions {
  51883. /**
  51884. * Should the controller mesh be animated when a user interacts with it
  51885. * The pressed buttons / thumbstick and touchpad animations will be disabled
  51886. */
  51887. disableMotionControllerAnimation?: boolean;
  51888. /**
  51889. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  51890. */
  51891. doNotLoadControllerMesh?: boolean;
  51892. /**
  51893. * Force a specific controller type for this controller.
  51894. * This can be used when creating your own profile or when testing different controllers
  51895. */
  51896. forceControllerProfile?: string;
  51897. /**
  51898. * Defines a rendering group ID for meshes that will be loaded.
  51899. * This is for the default controllers only.
  51900. */
  51901. renderingGroupId?: number;
  51902. }
  51903. /**
  51904. * Represents an XR controller
  51905. */
  51906. export class WebXRInputSource {
  51907. private _scene;
  51908. /** The underlying input source for the controller */
  51909. inputSource: XRInputSource;
  51910. private _options;
  51911. private _tmpVector;
  51912. private _uniqueId;
  51913. private _disposed;
  51914. /**
  51915. * 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
  51916. */
  51917. grip?: AbstractMesh;
  51918. /**
  51919. * If available, this is the gamepad object related to this controller.
  51920. * Using this object it is possible to get click events and trackpad changes of the
  51921. * webxr controller that is currently being used.
  51922. */
  51923. motionController?: WebXRAbstractMotionController;
  51924. /**
  51925. * Event that fires when the controller is removed/disposed.
  51926. * The object provided as event data is this controller, after associated assets were disposed.
  51927. * uniqueId is still available.
  51928. */
  51929. onDisposeObservable: Observable<WebXRInputSource>;
  51930. /**
  51931. * Will be triggered when the mesh associated with the motion controller is done loading.
  51932. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  51933. * A shortened version of controller -> motion controller -> on mesh loaded.
  51934. */
  51935. onMeshLoadedObservable: Observable<AbstractMesh>;
  51936. /**
  51937. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  51938. */
  51939. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  51940. /**
  51941. * Pointer which can be used to select objects or attach a visible laser to
  51942. */
  51943. pointer: AbstractMesh;
  51944. /**
  51945. * Creates the input source object
  51946. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  51947. * @param _scene the scene which the controller should be associated to
  51948. * @param inputSource the underlying input source for the controller
  51949. * @param _options options for this controller creation
  51950. */
  51951. constructor(_scene: Scene,
  51952. /** The underlying input source for the controller */
  51953. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  51954. /**
  51955. * Get this controllers unique id
  51956. */
  51957. get uniqueId(): string;
  51958. /**
  51959. * Disposes of the object
  51960. */
  51961. dispose(): void;
  51962. /**
  51963. * Gets a world space ray coming from the pointer or grip
  51964. * @param result the resulting ray
  51965. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  51966. */
  51967. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  51968. /**
  51969. * Updates the controller pose based on the given XRFrame
  51970. * @param xrFrame xr frame to update the pose with
  51971. * @param referenceSpace reference space to use
  51972. */
  51973. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  51974. }
  51975. }
  51976. declare module BABYLON {
  51977. /**
  51978. * The schema for initialization options of the XR Input class
  51979. */
  51980. export interface IWebXRInputOptions {
  51981. /**
  51982. * If set to true no model will be automatically loaded
  51983. */
  51984. doNotLoadControllerMeshes?: boolean;
  51985. /**
  51986. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  51987. * If not found, the xr input profile data will be used.
  51988. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  51989. */
  51990. forceInputProfile?: string;
  51991. /**
  51992. * Do not send a request to the controller repository to load the profile.
  51993. *
  51994. * Instead, use the controllers available in babylon itself.
  51995. */
  51996. disableOnlineControllerRepository?: boolean;
  51997. /**
  51998. * A custom URL for the controllers repository
  51999. */
  52000. customControllersRepositoryURL?: string;
  52001. /**
  52002. * Should the controller model's components not move according to the user input
  52003. */
  52004. disableControllerAnimation?: boolean;
  52005. /**
  52006. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  52007. */
  52008. controllerOptions?: IWebXRControllerOptions;
  52009. }
  52010. /**
  52011. * XR input used to track XR inputs such as controllers/rays
  52012. */
  52013. export class WebXRInput implements IDisposable {
  52014. /**
  52015. * the xr session manager for this session
  52016. */
  52017. xrSessionManager: WebXRSessionManager;
  52018. /**
  52019. * the WebXR camera for this session. Mainly used for teleportation
  52020. */
  52021. xrCamera: WebXRCamera;
  52022. private readonly options;
  52023. /**
  52024. * XR controllers being tracked
  52025. */
  52026. controllers: Array<WebXRInputSource>;
  52027. private _frameObserver;
  52028. private _sessionEndedObserver;
  52029. private _sessionInitObserver;
  52030. /**
  52031. * Event when a controller has been connected/added
  52032. */
  52033. onControllerAddedObservable: Observable<WebXRInputSource>;
  52034. /**
  52035. * Event when a controller has been removed/disconnected
  52036. */
  52037. onControllerRemovedObservable: Observable<WebXRInputSource>;
  52038. /**
  52039. * Initializes the WebXRInput
  52040. * @param xrSessionManager the xr session manager for this session
  52041. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  52042. * @param options = initialization options for this xr input
  52043. */
  52044. constructor(
  52045. /**
  52046. * the xr session manager for this session
  52047. */
  52048. xrSessionManager: WebXRSessionManager,
  52049. /**
  52050. * the WebXR camera for this session. Mainly used for teleportation
  52051. */
  52052. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  52053. private _onInputSourcesChange;
  52054. private _addAndRemoveControllers;
  52055. /**
  52056. * Disposes of the object
  52057. */
  52058. dispose(): void;
  52059. }
  52060. }
  52061. declare module BABYLON {
  52062. /**
  52063. * This is the base class for all WebXR features.
  52064. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  52065. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  52066. */
  52067. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  52068. protected _xrSessionManager: WebXRSessionManager;
  52069. private _attached;
  52070. private _removeOnDetach;
  52071. /**
  52072. * Is this feature disposed?
  52073. */
  52074. isDisposed: boolean;
  52075. /**
  52076. * Should auto-attach be disabled?
  52077. */
  52078. disableAutoAttach: boolean;
  52079. /**
  52080. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  52081. */
  52082. xrNativeFeatureName: string;
  52083. /**
  52084. * Construct a new (abstract) WebXR feature
  52085. * @param _xrSessionManager the xr session manager for this feature
  52086. */
  52087. constructor(_xrSessionManager: WebXRSessionManager);
  52088. /**
  52089. * Is this feature attached
  52090. */
  52091. get attached(): boolean;
  52092. /**
  52093. * attach this feature
  52094. *
  52095. * @param force should attachment be forced (even when already attached)
  52096. * @returns true if successful, false is failed or already attached
  52097. */
  52098. attach(force?: boolean): boolean;
  52099. /**
  52100. * detach this feature.
  52101. *
  52102. * @returns true if successful, false if failed or already detached
  52103. */
  52104. detach(): boolean;
  52105. /**
  52106. * Dispose this feature and all of the resources attached
  52107. */
  52108. dispose(): void;
  52109. /**
  52110. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  52111. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  52112. *
  52113. * @returns whether or not the feature is compatible in this environment
  52114. */
  52115. isCompatible(): boolean;
  52116. /**
  52117. * This is used to register callbacks that will automatically be removed when detach is called.
  52118. * @param observable the observable to which the observer will be attached
  52119. * @param callback the callback to register
  52120. */
  52121. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  52122. /**
  52123. * Code in this function will be executed on each xrFrame received from the browser.
  52124. * This function will not execute after the feature is detached.
  52125. * @param _xrFrame the current frame
  52126. */
  52127. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  52128. }
  52129. }
  52130. declare module BABYLON {
  52131. /**
  52132. * Renders a layer on top of an existing scene
  52133. */
  52134. export class UtilityLayerRenderer implements IDisposable {
  52135. /** the original scene that will be rendered on top of */
  52136. originalScene: Scene;
  52137. private _pointerCaptures;
  52138. private _lastPointerEvents;
  52139. private static _DefaultUtilityLayer;
  52140. private static _DefaultKeepDepthUtilityLayer;
  52141. private _sharedGizmoLight;
  52142. private _renderCamera;
  52143. /**
  52144. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  52145. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  52146. * @returns the camera that is used when rendering the utility layer
  52147. */
  52148. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  52149. /**
  52150. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  52151. * @param cam the camera that should be used when rendering the utility layer
  52152. */
  52153. setRenderCamera(cam: Nullable<Camera>): void;
  52154. /**
  52155. * @hidden
  52156. * Light which used by gizmos to get light shading
  52157. */
  52158. _getSharedGizmoLight(): HemisphericLight;
  52159. /**
  52160. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  52161. */
  52162. pickUtilitySceneFirst: boolean;
  52163. /**
  52164. * 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)
  52165. */
  52166. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  52167. /**
  52168. * 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)
  52169. */
  52170. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  52171. /**
  52172. * The scene that is rendered on top of the original scene
  52173. */
  52174. utilityLayerScene: Scene;
  52175. /**
  52176. * If the utility layer should automatically be rendered on top of existing scene
  52177. */
  52178. shouldRender: boolean;
  52179. /**
  52180. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  52181. */
  52182. onlyCheckPointerDownEvents: boolean;
  52183. /**
  52184. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  52185. */
  52186. processAllEvents: boolean;
  52187. /**
  52188. * Observable raised when the pointer move from the utility layer scene to the main scene
  52189. */
  52190. onPointerOutObservable: Observable<number>;
  52191. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  52192. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  52193. private _afterRenderObserver;
  52194. private _sceneDisposeObserver;
  52195. private _originalPointerObserver;
  52196. /**
  52197. * Instantiates a UtilityLayerRenderer
  52198. * @param originalScene the original scene that will be rendered on top of
  52199. * @param handleEvents boolean indicating if the utility layer should handle events
  52200. */
  52201. constructor(
  52202. /** the original scene that will be rendered on top of */
  52203. originalScene: Scene, handleEvents?: boolean);
  52204. private _notifyObservers;
  52205. /**
  52206. * Renders the utility layers scene on top of the original scene
  52207. */
  52208. render(): void;
  52209. /**
  52210. * Disposes of the renderer
  52211. */
  52212. dispose(): void;
  52213. private _updateCamera;
  52214. }
  52215. }
  52216. declare module BABYLON {
  52217. /**
  52218. * Options interface for the pointer selection module
  52219. */
  52220. export interface IWebXRControllerPointerSelectionOptions {
  52221. /**
  52222. * if provided, this scene will be used to render meshes.
  52223. */
  52224. customUtilityLayerScene?: Scene;
  52225. /**
  52226. * 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)
  52227. * If not disabled, the last picked point will be used to execute a pointer up event
  52228. * If disabled, pointer up event will be triggered right after the pointer down event.
  52229. * Used in screen and gaze target ray mode only
  52230. */
  52231. disablePointerUpOnTouchOut: boolean;
  52232. /**
  52233. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  52234. */
  52235. forceGazeMode: boolean;
  52236. /**
  52237. * 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
  52238. * to start a new countdown to the pointer down event.
  52239. * Defaults to 1.
  52240. */
  52241. gazeModePointerMovedFactor?: number;
  52242. /**
  52243. * Different button type to use instead of the main component
  52244. */
  52245. overrideButtonId?: string;
  52246. /**
  52247. * use this rendering group id for the meshes (optional)
  52248. */
  52249. renderingGroupId?: number;
  52250. /**
  52251. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  52252. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  52253. * 3000 means 3 seconds between pointing at something and selecting it
  52254. */
  52255. timeToSelect?: number;
  52256. /**
  52257. * Should meshes created here be added to a utility layer or the main scene
  52258. */
  52259. useUtilityLayer?: boolean;
  52260. /**
  52261. * Optional WebXR camera to be used for gaze selection
  52262. */
  52263. gazeCamera?: WebXRCamera;
  52264. /**
  52265. * the xr input to use with this pointer selection
  52266. */
  52267. xrInput: WebXRInput;
  52268. /**
  52269. * Should the scene pointerX and pointerY update be disabled
  52270. * This is required for fullscreen AR GUI, but might slow down other experiences.
  52271. * Disable in VR, if not needed.
  52272. * The first rig camera (left eye) will be used to calculate the projection
  52273. */
  52274. disableScenePointerVectorUpdate: boolean;
  52275. /**
  52276. * Enable pointer selection on all controllers instead of switching between them
  52277. */
  52278. enablePointerSelectionOnAllControllers?: boolean;
  52279. /**
  52280. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  52281. * If switch is enabled, it will still allow the user to switch between the different controllers
  52282. */
  52283. preferredHandedness?: XRHandedness;
  52284. /**
  52285. * Disable switching the pointer selection from one controller to the other.
  52286. * If the preferred hand is set it will be fixed on this hand, and if not it will be fixed on the first controller added to the scene
  52287. */
  52288. disableSwitchOnClick?: boolean;
  52289. /**
  52290. * The maximum distance of the pointer selection feature. Defaults to 100.
  52291. */
  52292. maxPointerDistance?: number;
  52293. }
  52294. /**
  52295. * A module that will enable pointer selection for motion controllers of XR Input Sources
  52296. */
  52297. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  52298. private readonly _options;
  52299. private static _idCounter;
  52300. private _attachController;
  52301. private _controllers;
  52302. private _scene;
  52303. private _tmpVectorForPickCompare;
  52304. private _attachedController;
  52305. /**
  52306. * The module's name
  52307. */
  52308. static readonly Name: string;
  52309. /**
  52310. * The (Babylon) version of this module.
  52311. * This is an integer representing the implementation version.
  52312. * This number does not correspond to the WebXR specs version
  52313. */
  52314. static readonly Version: number;
  52315. /**
  52316. * Disable lighting on the laser pointer (so it will always be visible)
  52317. */
  52318. disablePointerLighting: boolean;
  52319. /**
  52320. * Disable lighting on the selection mesh (so it will always be visible)
  52321. */
  52322. disableSelectionMeshLighting: boolean;
  52323. /**
  52324. * Should the laser pointer be displayed
  52325. */
  52326. displayLaserPointer: boolean;
  52327. /**
  52328. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  52329. */
  52330. displaySelectionMesh: boolean;
  52331. /**
  52332. * This color will be set to the laser pointer when selection is triggered
  52333. */
  52334. laserPointerPickedColor: Color3;
  52335. /**
  52336. * Default color of the laser pointer
  52337. */
  52338. laserPointerDefaultColor: Color3;
  52339. /**
  52340. * default color of the selection ring
  52341. */
  52342. selectionMeshDefaultColor: Color3;
  52343. /**
  52344. * This color will be applied to the selection ring when selection is triggered
  52345. */
  52346. selectionMeshPickedColor: Color3;
  52347. /**
  52348. * Optional filter to be used for ray selection. This predicate shares behavior with
  52349. * scene.pointerMovePredicate which takes priority if it is also assigned.
  52350. */
  52351. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  52352. /**
  52353. * constructs a new background remover module
  52354. * @param _xrSessionManager the session manager for this module
  52355. * @param _options read-only options to be used in this module
  52356. */
  52357. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  52358. /**
  52359. * attach this feature
  52360. * Will usually be called by the features manager
  52361. *
  52362. * @returns true if successful.
  52363. */
  52364. attach(): boolean;
  52365. /**
  52366. * detach this feature.
  52367. * Will usually be called by the features manager
  52368. *
  52369. * @returns true if successful.
  52370. */
  52371. detach(): boolean;
  52372. /**
  52373. * Will get the mesh under a specific pointer.
  52374. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  52375. * @param controllerId the controllerId to check
  52376. * @returns The mesh under pointer or null if no mesh is under the pointer
  52377. */
  52378. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  52379. /**
  52380. * Get the xr controller that correlates to the pointer id in the pointer event
  52381. *
  52382. * @param id the pointer id to search for
  52383. * @returns the controller that correlates to this id or null if not found
  52384. */
  52385. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  52386. private _identityMatrix;
  52387. private _screenCoordinatesRef;
  52388. private _viewportRef;
  52389. protected _onXRFrame(_xrFrame: XRFrame): void;
  52390. private _attachGazeMode;
  52391. private _attachScreenRayMode;
  52392. private _attachTrackedPointerRayMode;
  52393. private _convertNormalToDirectionOfRay;
  52394. private _detachController;
  52395. private _generateNewMeshPair;
  52396. private _pickingMoved;
  52397. private _updatePointerDistance;
  52398. /** @hidden */
  52399. get lasterPointerDefaultColor(): Color3;
  52400. }
  52401. }
  52402. declare module BABYLON {
  52403. /**
  52404. * Button which can be used to enter a different mode of XR
  52405. */
  52406. export class WebXREnterExitUIButton {
  52407. /** button element */
  52408. element: HTMLElement;
  52409. /** XR initialization options for the button */
  52410. sessionMode: XRSessionMode;
  52411. /** Reference space type */
  52412. referenceSpaceType: XRReferenceSpaceType;
  52413. /**
  52414. * Creates a WebXREnterExitUIButton
  52415. * @param element button element
  52416. * @param sessionMode XR initialization session mode
  52417. * @param referenceSpaceType the type of reference space to be used
  52418. */
  52419. constructor(
  52420. /** button element */
  52421. element: HTMLElement,
  52422. /** XR initialization options for the button */
  52423. sessionMode: XRSessionMode,
  52424. /** Reference space type */
  52425. referenceSpaceType: XRReferenceSpaceType);
  52426. /**
  52427. * Extendable function which can be used to update the button's visuals when the state changes
  52428. * @param activeButton the current active button in the UI
  52429. */
  52430. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  52431. }
  52432. /**
  52433. * Options to create the webXR UI
  52434. */
  52435. export class WebXREnterExitUIOptions {
  52436. /**
  52437. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  52438. */
  52439. customButtons?: Array<WebXREnterExitUIButton>;
  52440. /**
  52441. * A reference space type to use when creating the default button.
  52442. * Default is local-floor
  52443. */
  52444. referenceSpaceType?: XRReferenceSpaceType;
  52445. /**
  52446. * Context to enter xr with
  52447. */
  52448. renderTarget?: Nullable<WebXRRenderTarget>;
  52449. /**
  52450. * A session mode to use when creating the default button.
  52451. * Default is immersive-vr
  52452. */
  52453. sessionMode?: XRSessionMode;
  52454. /**
  52455. * A list of optional features to init the session with
  52456. */
  52457. optionalFeatures?: string[];
  52458. /**
  52459. * A list of optional features to init the session with
  52460. */
  52461. requiredFeatures?: string[];
  52462. /**
  52463. * If defined, this function will be executed if the UI encounters an error when entering XR
  52464. */
  52465. onError?: (error: any) => void;
  52466. }
  52467. /**
  52468. * UI to allow the user to enter/exit XR mode
  52469. */
  52470. export class WebXREnterExitUI implements IDisposable {
  52471. private scene;
  52472. /** version of the options passed to this UI */
  52473. options: WebXREnterExitUIOptions;
  52474. private _activeButton;
  52475. private _buttons;
  52476. /**
  52477. * The HTML Div Element to which buttons are added.
  52478. */
  52479. readonly overlay: HTMLDivElement;
  52480. /**
  52481. * Fired every time the active button is changed.
  52482. *
  52483. * When xr is entered via a button that launches xr that button will be the callback parameter
  52484. *
  52485. * When exiting xr the callback parameter will be null)
  52486. */
  52487. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  52488. /**
  52489. *
  52490. * @param scene babylon scene object to use
  52491. * @param options (read-only) version of the options passed to this UI
  52492. */
  52493. private constructor();
  52494. /**
  52495. * Creates UI to allow the user to enter/exit XR mode
  52496. * @param scene the scene to add the ui to
  52497. * @param helper the xr experience helper to enter/exit xr with
  52498. * @param options options to configure the UI
  52499. * @returns the created ui
  52500. */
  52501. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  52502. /**
  52503. * Disposes of the XR UI component
  52504. */
  52505. dispose(): void;
  52506. private _updateButtons;
  52507. }
  52508. }
  52509. declare module BABYLON {
  52510. /**
  52511. * Class containing static functions to help procedurally build meshes
  52512. */
  52513. export class LinesBuilder {
  52514. /**
  52515. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52516. * * 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
  52517. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52518. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52519. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52520. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52521. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52522. * * 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
  52523. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52524. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52525. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52526. * @param name defines the name of the new line system
  52527. * @param options defines the options used to create the line system
  52528. * @param scene defines the hosting scene
  52529. * @returns a new line system mesh
  52530. */
  52531. static CreateLineSystem(name: string, options: {
  52532. lines: Vector3[][];
  52533. updatable?: boolean;
  52534. instance?: Nullable<LinesMesh>;
  52535. colors?: Nullable<Color4[][]>;
  52536. useVertexAlpha?: boolean;
  52537. }, scene: Nullable<Scene>): LinesMesh;
  52538. /**
  52539. * Creates a line mesh
  52540. * 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
  52541. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52542. * * The parameter `points` is an array successive Vector3
  52543. * * 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
  52544. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52545. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52546. * * When updating an instance, remember that only point positions can change, not the number of points
  52547. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52548. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52549. * @param name defines the name of the new line system
  52550. * @param options defines the options used to create the line system
  52551. * @param scene defines the hosting scene
  52552. * @returns a new line mesh
  52553. */
  52554. static CreateLines(name: string, options: {
  52555. points: Vector3[];
  52556. updatable?: boolean;
  52557. instance?: Nullable<LinesMesh>;
  52558. colors?: Color4[];
  52559. useVertexAlpha?: boolean;
  52560. }, scene?: Nullable<Scene>): LinesMesh;
  52561. /**
  52562. * Creates a dashed line mesh
  52563. * * 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
  52564. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52565. * * The parameter `points` is an array successive Vector3
  52566. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52567. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52568. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52569. * * 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
  52570. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52571. * * When updating an instance, remember that only point positions can change, not the number of points
  52572. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52573. * @param name defines the name of the mesh
  52574. * @param options defines the options used to create the mesh
  52575. * @param scene defines the hosting scene
  52576. * @returns the dashed line mesh
  52577. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52578. */
  52579. static CreateDashedLines(name: string, options: {
  52580. points: Vector3[];
  52581. dashSize?: number;
  52582. gapSize?: number;
  52583. dashNb?: number;
  52584. updatable?: boolean;
  52585. instance?: LinesMesh;
  52586. useVertexAlpha?: boolean;
  52587. }, scene?: Nullable<Scene>): LinesMesh;
  52588. }
  52589. }
  52590. declare module BABYLON {
  52591. /**
  52592. * Construction options for a timer
  52593. */
  52594. export interface ITimerOptions<T> {
  52595. /**
  52596. * Time-to-end
  52597. */
  52598. timeout: number;
  52599. /**
  52600. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  52601. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  52602. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  52603. */
  52604. contextObservable: Observable<T>;
  52605. /**
  52606. * Optional parameters when adding an observer to the observable
  52607. */
  52608. observableParameters?: {
  52609. mask?: number;
  52610. insertFirst?: boolean;
  52611. scope?: any;
  52612. };
  52613. /**
  52614. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  52615. */
  52616. breakCondition?: (data?: ITimerData<T>) => boolean;
  52617. /**
  52618. * Will be triggered when the time condition has met
  52619. */
  52620. onEnded?: (data: ITimerData<any>) => void;
  52621. /**
  52622. * Will be triggered when the break condition has met (prematurely ended)
  52623. */
  52624. onAborted?: (data: ITimerData<any>) => void;
  52625. /**
  52626. * Optional function to execute on each tick (or count)
  52627. */
  52628. onTick?: (data: ITimerData<any>) => void;
  52629. }
  52630. /**
  52631. * An interface defining the data sent by the timer
  52632. */
  52633. export interface ITimerData<T> {
  52634. /**
  52635. * When did it start
  52636. */
  52637. startTime: number;
  52638. /**
  52639. * Time now
  52640. */
  52641. currentTime: number;
  52642. /**
  52643. * Time passed since started
  52644. */
  52645. deltaTime: number;
  52646. /**
  52647. * How much is completed, in [0.0...1.0].
  52648. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  52649. */
  52650. completeRate: number;
  52651. /**
  52652. * What the registered observable sent in the last count
  52653. */
  52654. payload: T;
  52655. }
  52656. /**
  52657. * The current state of the timer
  52658. */
  52659. export enum TimerState {
  52660. /**
  52661. * Timer initialized, not yet started
  52662. */
  52663. INIT = 0,
  52664. /**
  52665. * Timer started and counting
  52666. */
  52667. STARTED = 1,
  52668. /**
  52669. * Timer ended (whether aborted or time reached)
  52670. */
  52671. ENDED = 2
  52672. }
  52673. /**
  52674. * A simple version of the timer. Will take options and start the timer immediately after calling it
  52675. *
  52676. * @param options options with which to initialize this timer
  52677. */
  52678. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  52679. /**
  52680. * An advanced implementation of a timer class
  52681. */
  52682. export class AdvancedTimer<T = any> implements IDisposable {
  52683. /**
  52684. * Will notify each time the timer calculates the remaining time
  52685. */
  52686. onEachCountObservable: Observable<ITimerData<T>>;
  52687. /**
  52688. * Will trigger when the timer was aborted due to the break condition
  52689. */
  52690. onTimerAbortedObservable: Observable<ITimerData<T>>;
  52691. /**
  52692. * Will trigger when the timer ended successfully
  52693. */
  52694. onTimerEndedObservable: Observable<ITimerData<T>>;
  52695. /**
  52696. * Will trigger when the timer state has changed
  52697. */
  52698. onStateChangedObservable: Observable<TimerState>;
  52699. private _observer;
  52700. private _contextObservable;
  52701. private _observableParameters;
  52702. private _startTime;
  52703. private _timer;
  52704. private _state;
  52705. private _breakCondition;
  52706. private _timeToEnd;
  52707. private _breakOnNextTick;
  52708. /**
  52709. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  52710. * @param options construction options for this advanced timer
  52711. */
  52712. constructor(options: ITimerOptions<T>);
  52713. /**
  52714. * set a breaking condition for this timer. Default is to never break during count
  52715. * @param predicate the new break condition. Returns true to break, false otherwise
  52716. */
  52717. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  52718. /**
  52719. * Reset ALL associated observables in this advanced timer
  52720. */
  52721. clearObservables(): void;
  52722. /**
  52723. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  52724. *
  52725. * @param timeToEnd how much time to measure until timer ended
  52726. */
  52727. start(timeToEnd?: number): void;
  52728. /**
  52729. * Will force a stop on the next tick.
  52730. */
  52731. stop(): void;
  52732. /**
  52733. * Dispose this timer, clearing all resources
  52734. */
  52735. dispose(): void;
  52736. private _setState;
  52737. private _tick;
  52738. private _stop;
  52739. }
  52740. }
  52741. declare module BABYLON {
  52742. /**
  52743. * The options container for the teleportation module
  52744. */
  52745. export interface IWebXRTeleportationOptions {
  52746. /**
  52747. * if provided, this scene will be used to render meshes.
  52748. */
  52749. customUtilityLayerScene?: Scene;
  52750. /**
  52751. * Values to configure the default target mesh
  52752. */
  52753. defaultTargetMeshOptions?: {
  52754. /**
  52755. * Fill color of the teleportation area
  52756. */
  52757. teleportationFillColor?: string;
  52758. /**
  52759. * Border color for the teleportation area
  52760. */
  52761. teleportationBorderColor?: string;
  52762. /**
  52763. * Disable the mesh's animation sequence
  52764. */
  52765. disableAnimation?: boolean;
  52766. /**
  52767. * Disable lighting on the material or the ring and arrow
  52768. */
  52769. disableLighting?: boolean;
  52770. /**
  52771. * Override the default material of the torus and arrow
  52772. */
  52773. torusArrowMaterial?: Material;
  52774. };
  52775. /**
  52776. * A list of meshes to use as floor meshes.
  52777. * Meshes can be added and removed after initializing the feature using the
  52778. * addFloorMesh and removeFloorMesh functions
  52779. * If empty, rotation will still work
  52780. */
  52781. floorMeshes?: AbstractMesh[];
  52782. /**
  52783. * use this rendering group id for the meshes (optional)
  52784. */
  52785. renderingGroupId?: number;
  52786. /**
  52787. * Should teleportation move only to snap points
  52788. */
  52789. snapPointsOnly?: boolean;
  52790. /**
  52791. * An array of points to which the teleportation will snap to.
  52792. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  52793. */
  52794. snapPositions?: Vector3[];
  52795. /**
  52796. * How close should the teleportation ray be in order to snap to position.
  52797. * Default to 0.8 units (meters)
  52798. */
  52799. snapToPositionRadius?: number;
  52800. /**
  52801. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  52802. * If you want to support rotation, make sure your mesh has a direction indicator.
  52803. *
  52804. * When left untouched, the default mesh will be initialized.
  52805. */
  52806. teleportationTargetMesh?: AbstractMesh;
  52807. /**
  52808. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  52809. */
  52810. timeToTeleport?: number;
  52811. /**
  52812. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  52813. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  52814. */
  52815. useMainComponentOnly?: boolean;
  52816. /**
  52817. * Should meshes created here be added to a utility layer or the main scene
  52818. */
  52819. useUtilityLayer?: boolean;
  52820. /**
  52821. * Babylon XR Input class for controller
  52822. */
  52823. xrInput: WebXRInput;
  52824. /**
  52825. * Meshes that the teleportation ray cannot go through
  52826. */
  52827. pickBlockerMeshes?: AbstractMesh[];
  52828. }
  52829. /**
  52830. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  52831. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  52832. * the input of the attached controllers.
  52833. */
  52834. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  52835. private _options;
  52836. private _controllers;
  52837. private _currentTeleportationControllerId;
  52838. private _floorMeshes;
  52839. private _quadraticBezierCurve;
  52840. private _selectionFeature;
  52841. private _snapToPositions;
  52842. private _snappedToPoint;
  52843. private _teleportationRingMaterial?;
  52844. private _tmpRay;
  52845. private _tmpVector;
  52846. private _tmpQuaternion;
  52847. /**
  52848. * The module's name
  52849. */
  52850. static readonly Name: string;
  52851. /**
  52852. * The (Babylon) version of this module.
  52853. * This is an integer representing the implementation version.
  52854. * This number does not correspond to the webxr specs version
  52855. */
  52856. static readonly Version: number;
  52857. /**
  52858. * Is movement backwards enabled
  52859. */
  52860. backwardsMovementEnabled: boolean;
  52861. /**
  52862. * Distance to travel when moving backwards
  52863. */
  52864. backwardsTeleportationDistance: number;
  52865. /**
  52866. * The distance from the user to the inspection point in the direction of the controller
  52867. * A higher number will allow the user to move further
  52868. * defaults to 5 (meters, in xr units)
  52869. */
  52870. parabolicCheckRadius: number;
  52871. /**
  52872. * Should the module support parabolic ray on top of direct ray
  52873. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  52874. * Very helpful when moving between floors / different heights
  52875. */
  52876. parabolicRayEnabled: boolean;
  52877. /**
  52878. * How much rotation should be applied when rotating right and left
  52879. */
  52880. rotationAngle: number;
  52881. /**
  52882. * Is rotation enabled when moving forward?
  52883. * Disabling this feature will prevent the user from deciding the direction when teleporting
  52884. */
  52885. rotationEnabled: boolean;
  52886. /**
  52887. * constructs a new anchor system
  52888. * @param _xrSessionManager an instance of WebXRSessionManager
  52889. * @param _options configuration object for this feature
  52890. */
  52891. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  52892. /**
  52893. * Get the snapPointsOnly flag
  52894. */
  52895. get snapPointsOnly(): boolean;
  52896. /**
  52897. * Sets the snapPointsOnly flag
  52898. * @param snapToPoints should teleportation be exclusively to snap points
  52899. */
  52900. set snapPointsOnly(snapToPoints: boolean);
  52901. /**
  52902. * Add a new mesh to the floor meshes array
  52903. * @param mesh the mesh to use as floor mesh
  52904. */
  52905. addFloorMesh(mesh: AbstractMesh): void;
  52906. /**
  52907. * Add a new snap-to point to fix teleportation to this position
  52908. * @param newSnapPoint The new Snap-To point
  52909. */
  52910. addSnapPoint(newSnapPoint: Vector3): void;
  52911. attach(): boolean;
  52912. detach(): boolean;
  52913. dispose(): void;
  52914. /**
  52915. * Remove a mesh from the floor meshes array
  52916. * @param mesh the mesh to remove
  52917. */
  52918. removeFloorMesh(mesh: AbstractMesh): void;
  52919. /**
  52920. * Remove a mesh from the floor meshes array using its name
  52921. * @param name the mesh name to remove
  52922. */
  52923. removeFloorMeshByName(name: string): void;
  52924. /**
  52925. * 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
  52926. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  52927. * @returns was the point found and removed or not
  52928. */
  52929. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  52930. /**
  52931. * This function sets a selection feature that will be disabled when
  52932. * the forward ray is shown and will be reattached when hidden.
  52933. * This is used to remove the selection rays when moving.
  52934. * @param selectionFeature the feature to disable when forward movement is enabled
  52935. */
  52936. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  52937. protected _onXRFrame(_xrFrame: XRFrame): void;
  52938. private _attachController;
  52939. private _createDefaultTargetMesh;
  52940. private _detachController;
  52941. private _findClosestSnapPointWithRadius;
  52942. private _setTargetMeshPosition;
  52943. private _setTargetMeshVisibility;
  52944. private _showParabolicPath;
  52945. private _teleportForward;
  52946. }
  52947. }
  52948. declare module BABYLON {
  52949. /**
  52950. * Options for the default xr helper
  52951. */
  52952. export class WebXRDefaultExperienceOptions {
  52953. /**
  52954. * Enable or disable default UI to enter XR
  52955. */
  52956. disableDefaultUI?: boolean;
  52957. /**
  52958. * Should teleportation not initialize. defaults to false.
  52959. */
  52960. disableTeleportation?: boolean;
  52961. /**
  52962. * Floor meshes that will be used for teleport
  52963. */
  52964. floorMeshes?: Array<AbstractMesh>;
  52965. /**
  52966. * If set to true, the first frame will not be used to reset position
  52967. * The first frame is mainly used when copying transformation from the old camera
  52968. * Mainly used in AR
  52969. */
  52970. ignoreNativeCameraTransformation?: boolean;
  52971. /**
  52972. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  52973. */
  52974. inputOptions?: IWebXRInputOptions;
  52975. /**
  52976. * optional configuration for the output canvas
  52977. */
  52978. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  52979. /**
  52980. * optional UI options. This can be used among other to change session mode and reference space type
  52981. */
  52982. uiOptions?: WebXREnterExitUIOptions;
  52983. /**
  52984. * When loading teleportation and pointer select, use stable versions instead of latest.
  52985. */
  52986. useStablePlugins?: boolean;
  52987. /**
  52988. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  52989. */
  52990. renderingGroupId?: number;
  52991. /**
  52992. * A list of optional features to init the session with
  52993. * If set to true, all features we support will be added
  52994. */
  52995. optionalFeatures?: boolean | string[];
  52996. }
  52997. /**
  52998. * Default experience which provides a similar setup to the previous webVRExperience
  52999. */
  53000. export class WebXRDefaultExperience {
  53001. /**
  53002. * Base experience
  53003. */
  53004. baseExperience: WebXRExperienceHelper;
  53005. /**
  53006. * Enables ui for entering/exiting xr
  53007. */
  53008. enterExitUI: WebXREnterExitUI;
  53009. /**
  53010. * Input experience extension
  53011. */
  53012. input: WebXRInput;
  53013. /**
  53014. * Enables laser pointer and selection
  53015. */
  53016. pointerSelection: WebXRControllerPointerSelection;
  53017. /**
  53018. * Default target xr should render to
  53019. */
  53020. renderTarget: WebXRRenderTarget;
  53021. /**
  53022. * Enables teleportation
  53023. */
  53024. teleportation: WebXRMotionControllerTeleportation;
  53025. private constructor();
  53026. /**
  53027. * Creates the default xr experience
  53028. * @param scene scene
  53029. * @param options options for basic configuration
  53030. * @returns resulting WebXRDefaultExperience
  53031. */
  53032. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  53033. /**
  53034. * DIsposes of the experience helper
  53035. */
  53036. dispose(): void;
  53037. }
  53038. }
  53039. declare module BABYLON {
  53040. /**
  53041. * Options to modify the vr teleportation behavior.
  53042. */
  53043. export interface VRTeleportationOptions {
  53044. /**
  53045. * The name of the mesh which should be used as the teleportation floor. (default: null)
  53046. */
  53047. floorMeshName?: string;
  53048. /**
  53049. * A list of meshes to be used as the teleportation floor. (default: empty)
  53050. */
  53051. floorMeshes?: Mesh[];
  53052. /**
  53053. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  53054. */
  53055. teleportationMode?: number;
  53056. /**
  53057. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  53058. */
  53059. teleportationTime?: number;
  53060. /**
  53061. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  53062. */
  53063. teleportationSpeed?: number;
  53064. /**
  53065. * The easing function used in the animation or null for Linear. (default CircleEase)
  53066. */
  53067. easingFunction?: EasingFunction;
  53068. }
  53069. /**
  53070. * Options to modify the vr experience helper's behavior.
  53071. */
  53072. export interface VRExperienceHelperOptions extends WebVROptions {
  53073. /**
  53074. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  53075. */
  53076. createDeviceOrientationCamera?: boolean;
  53077. /**
  53078. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  53079. */
  53080. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  53081. /**
  53082. * Uses the main button on the controller to toggle the laser casted. (default: true)
  53083. */
  53084. laserToggle?: boolean;
  53085. /**
  53086. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  53087. */
  53088. floorMeshes?: Mesh[];
  53089. /**
  53090. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  53091. */
  53092. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  53093. /**
  53094. * Defines if WebXR should be used instead of WebVR (if available)
  53095. */
  53096. useXR?: boolean;
  53097. }
  53098. /**
  53099. * Event containing information after VR has been entered
  53100. */
  53101. export class OnAfterEnteringVRObservableEvent {
  53102. /**
  53103. * If entering vr was successful
  53104. */
  53105. success: boolean;
  53106. }
  53107. /**
  53108. * Helps to quickly add VR support to an existing scene.
  53109. * See https://doc.babylonjs.com/how_to/webvr_helper
  53110. */
  53111. export class VRExperienceHelper {
  53112. /** Options to modify the vr experience helper's behavior. */
  53113. webVROptions: VRExperienceHelperOptions;
  53114. private _scene;
  53115. private _position;
  53116. private _btnVR;
  53117. private _btnVRDisplayed;
  53118. private _webVRsupported;
  53119. private _webVRready;
  53120. private _webVRrequesting;
  53121. private _webVRpresenting;
  53122. private _hasEnteredVR;
  53123. private _fullscreenVRpresenting;
  53124. private _inputElement;
  53125. private _webVRCamera;
  53126. private _vrDeviceOrientationCamera;
  53127. private _deviceOrientationCamera;
  53128. private _existingCamera;
  53129. private _onKeyDown;
  53130. private _onVrDisplayPresentChange;
  53131. private _onVRDisplayChanged;
  53132. private _onVRRequestPresentStart;
  53133. private _onVRRequestPresentComplete;
  53134. /**
  53135. * 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)
  53136. */
  53137. enableGazeEvenWhenNoPointerLock: boolean;
  53138. /**
  53139. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  53140. */
  53141. exitVROnDoubleTap: boolean;
  53142. /**
  53143. * Observable raised right before entering VR.
  53144. */
  53145. onEnteringVRObservable: Observable<VRExperienceHelper>;
  53146. /**
  53147. * Observable raised when entering VR has completed.
  53148. */
  53149. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  53150. /**
  53151. * Observable raised when exiting VR.
  53152. */
  53153. onExitingVRObservable: Observable<VRExperienceHelper>;
  53154. /**
  53155. * Observable raised when controller mesh is loaded.
  53156. */
  53157. onControllerMeshLoadedObservable: Observable<WebVRController>;
  53158. /** Return this.onEnteringVRObservable
  53159. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  53160. */
  53161. get onEnteringVR(): Observable<VRExperienceHelper>;
  53162. /** Return this.onExitingVRObservable
  53163. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  53164. */
  53165. get onExitingVR(): Observable<VRExperienceHelper>;
  53166. /** Return this.onControllerMeshLoadedObservable
  53167. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  53168. */
  53169. get onControllerMeshLoaded(): Observable<WebVRController>;
  53170. private _rayLength;
  53171. private _useCustomVRButton;
  53172. private _teleportationRequested;
  53173. private _teleportActive;
  53174. private _floorMeshName;
  53175. private _floorMeshesCollection;
  53176. private _teleportationMode;
  53177. private _teleportationTime;
  53178. private _teleportationSpeed;
  53179. private _teleportationEasing;
  53180. private _rotationAllowed;
  53181. private _teleportBackwardsVector;
  53182. private _teleportationTarget;
  53183. private _isDefaultTeleportationTarget;
  53184. private _postProcessMove;
  53185. private _teleportationFillColor;
  53186. private _teleportationBorderColor;
  53187. private _rotationAngle;
  53188. private _haloCenter;
  53189. private _cameraGazer;
  53190. private _padSensibilityUp;
  53191. private _padSensibilityDown;
  53192. private _leftController;
  53193. private _rightController;
  53194. private _gazeColor;
  53195. private _laserColor;
  53196. private _pickedLaserColor;
  53197. private _pickedGazeColor;
  53198. /**
  53199. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  53200. */
  53201. onNewMeshSelected: Observable<AbstractMesh>;
  53202. /**
  53203. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  53204. * This observable will provide the mesh and the controller used to select the mesh
  53205. */
  53206. onMeshSelectedWithController: Observable<{
  53207. mesh: AbstractMesh;
  53208. controller: WebVRController;
  53209. }>;
  53210. /**
  53211. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  53212. */
  53213. onNewMeshPicked: Observable<PickingInfo>;
  53214. private _circleEase;
  53215. /**
  53216. * Observable raised before camera teleportation
  53217. */
  53218. onBeforeCameraTeleport: Observable<Vector3>;
  53219. /**
  53220. * Observable raised after camera teleportation
  53221. */
  53222. onAfterCameraTeleport: Observable<Vector3>;
  53223. /**
  53224. * Observable raised when current selected mesh gets unselected
  53225. */
  53226. onSelectedMeshUnselected: Observable<AbstractMesh>;
  53227. private _raySelectionPredicate;
  53228. /**
  53229. * To be optionaly changed by user to define custom ray selection
  53230. */
  53231. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  53232. /**
  53233. * To be optionaly changed by user to define custom selection logic (after ray selection)
  53234. */
  53235. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53236. /**
  53237. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  53238. */
  53239. teleportationEnabled: boolean;
  53240. private _defaultHeight;
  53241. private _teleportationInitialized;
  53242. private _interactionsEnabled;
  53243. private _interactionsRequested;
  53244. private _displayGaze;
  53245. private _displayLaserPointer;
  53246. /**
  53247. * The mesh used to display where the user is going to teleport.
  53248. */
  53249. get teleportationTarget(): Mesh;
  53250. /**
  53251. * Sets the mesh to be used to display where the user is going to teleport.
  53252. */
  53253. set teleportationTarget(value: Mesh);
  53254. /**
  53255. * 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
  53256. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  53257. * See https://doc.babylonjs.com/resources/baking_transformations
  53258. */
  53259. get gazeTrackerMesh(): Mesh;
  53260. set gazeTrackerMesh(value: Mesh);
  53261. /**
  53262. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  53263. */
  53264. updateGazeTrackerScale: boolean;
  53265. /**
  53266. * If the gaze trackers color should be updated when selecting meshes
  53267. */
  53268. updateGazeTrackerColor: boolean;
  53269. /**
  53270. * If the controller laser color should be updated when selecting meshes
  53271. */
  53272. updateControllerLaserColor: boolean;
  53273. /**
  53274. * The gaze tracking mesh corresponding to the left controller
  53275. */
  53276. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  53277. /**
  53278. * The gaze tracking mesh corresponding to the right controller
  53279. */
  53280. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  53281. /**
  53282. * If the ray of the gaze should be displayed.
  53283. */
  53284. get displayGaze(): boolean;
  53285. /**
  53286. * Sets if the ray of the gaze should be displayed.
  53287. */
  53288. set displayGaze(value: boolean);
  53289. /**
  53290. * If the ray of the LaserPointer should be displayed.
  53291. */
  53292. get displayLaserPointer(): boolean;
  53293. /**
  53294. * Sets if the ray of the LaserPointer should be displayed.
  53295. */
  53296. set displayLaserPointer(value: boolean);
  53297. /**
  53298. * The deviceOrientationCamera used as the camera when not in VR.
  53299. */
  53300. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  53301. /**
  53302. * Based on the current WebVR support, returns the current VR camera used.
  53303. */
  53304. get currentVRCamera(): Nullable<Camera>;
  53305. /**
  53306. * The webVRCamera which is used when in VR.
  53307. */
  53308. get webVRCamera(): WebVRFreeCamera;
  53309. /**
  53310. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  53311. */
  53312. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  53313. /**
  53314. * The html button that is used to trigger entering into VR.
  53315. */
  53316. get vrButton(): Nullable<HTMLButtonElement>;
  53317. private get _teleportationRequestInitiated();
  53318. /**
  53319. * Defines whether or not Pointer lock should be requested when switching to
  53320. * full screen.
  53321. */
  53322. requestPointerLockOnFullScreen: boolean;
  53323. /**
  53324. * If asking to force XR, this will be populated with the default xr experience
  53325. */
  53326. xr: WebXRDefaultExperience;
  53327. /**
  53328. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  53329. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  53330. */
  53331. xrTestDone: boolean;
  53332. /**
  53333. * Instantiates a VRExperienceHelper.
  53334. * Helps to quickly add VR support to an existing scene.
  53335. * @param scene The scene the VRExperienceHelper belongs to.
  53336. * @param webVROptions Options to modify the vr experience helper's behavior.
  53337. */
  53338. constructor(scene: Scene,
  53339. /** Options to modify the vr experience helper's behavior. */
  53340. webVROptions?: VRExperienceHelperOptions);
  53341. private completeVRInit;
  53342. private _onDefaultMeshLoaded;
  53343. private _onResize;
  53344. private _onFullscreenChange;
  53345. /**
  53346. * Gets a value indicating if we are currently in VR mode.
  53347. */
  53348. get isInVRMode(): boolean;
  53349. private onVrDisplayPresentChange;
  53350. private onVRDisplayChanged;
  53351. private moveButtonToBottomRight;
  53352. private displayVRButton;
  53353. private updateButtonVisibility;
  53354. private _cachedAngularSensibility;
  53355. /**
  53356. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  53357. * Otherwise, will use the fullscreen API.
  53358. */
  53359. enterVR(): void;
  53360. /**
  53361. * Attempt to exit VR, or fullscreen.
  53362. */
  53363. exitVR(): void;
  53364. /**
  53365. * The position of the vr experience helper.
  53366. */
  53367. get position(): Vector3;
  53368. /**
  53369. * Sets the position of the vr experience helper.
  53370. */
  53371. set position(value: Vector3);
  53372. /**
  53373. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  53374. */
  53375. enableInteractions(): void;
  53376. private get _noControllerIsActive();
  53377. private beforeRender;
  53378. private _isTeleportationFloor;
  53379. /**
  53380. * Adds a floor mesh to be used for teleportation.
  53381. * @param floorMesh the mesh to be used for teleportation.
  53382. */
  53383. addFloorMesh(floorMesh: Mesh): void;
  53384. /**
  53385. * Removes a floor mesh from being used for teleportation.
  53386. * @param floorMesh the mesh to be removed.
  53387. */
  53388. removeFloorMesh(floorMesh: Mesh): void;
  53389. /**
  53390. * Enables interactions and teleportation using the VR controllers and gaze.
  53391. * @param vrTeleportationOptions options to modify teleportation behavior.
  53392. */
  53393. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  53394. private _onNewGamepadConnected;
  53395. private _tryEnableInteractionOnController;
  53396. private _onNewGamepadDisconnected;
  53397. private _enableInteractionOnController;
  53398. private _checkTeleportWithRay;
  53399. private _checkRotate;
  53400. private _checkTeleportBackwards;
  53401. private _enableTeleportationOnController;
  53402. private _createTeleportationCircles;
  53403. private _displayTeleportationTarget;
  53404. private _hideTeleportationTarget;
  53405. private _rotateCamera;
  53406. private _moveTeleportationSelectorTo;
  53407. private _workingVector;
  53408. private _workingQuaternion;
  53409. private _workingMatrix;
  53410. /**
  53411. * Time Constant Teleportation Mode
  53412. */
  53413. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  53414. /**
  53415. * Speed Constant Teleportation Mode
  53416. */
  53417. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  53418. /**
  53419. * Teleports the users feet to the desired location
  53420. * @param location The location where the user's feet should be placed
  53421. */
  53422. teleportCamera(location: Vector3): void;
  53423. private _convertNormalToDirectionOfRay;
  53424. private _castRayAndSelectObject;
  53425. private _notifySelectedMeshUnselected;
  53426. /**
  53427. * Permanently set new colors for the laser pointer
  53428. * @param color the new laser color
  53429. * @param pickedColor the new laser color when picked mesh detected
  53430. */
  53431. setLaserColor(color: Color3, pickedColor?: Color3): void;
  53432. /**
  53433. * Set lighting enabled / disabled on the laser pointer of both controllers
  53434. * @param enabled should the lighting be enabled on the laser pointer
  53435. */
  53436. setLaserLightingState(enabled?: boolean): void;
  53437. /**
  53438. * Permanently set new colors for the gaze pointer
  53439. * @param color the new gaze color
  53440. * @param pickedColor the new gaze color when picked mesh detected
  53441. */
  53442. setGazeColor(color: Color3, pickedColor?: Color3): void;
  53443. /**
  53444. * Sets the color of the laser ray from the vr controllers.
  53445. * @param color new color for the ray.
  53446. */
  53447. changeLaserColor(color: Color3): void;
  53448. /**
  53449. * Sets the color of the ray from the vr headsets gaze.
  53450. * @param color new color for the ray.
  53451. */
  53452. changeGazeColor(color: Color3): void;
  53453. /**
  53454. * Exits VR and disposes of the vr experience helper
  53455. */
  53456. dispose(): void;
  53457. /**
  53458. * Gets the name of the VRExperienceHelper class
  53459. * @returns "VRExperienceHelper"
  53460. */
  53461. getClassName(): string;
  53462. }
  53463. }
  53464. declare module BABYLON {
  53465. /**
  53466. * Contains an array of blocks representing the octree
  53467. */
  53468. export interface IOctreeContainer<T> {
  53469. /**
  53470. * Blocks within the octree
  53471. */
  53472. blocks: Array<OctreeBlock<T>>;
  53473. }
  53474. /**
  53475. * Class used to store a cell in an octree
  53476. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53477. */
  53478. export class OctreeBlock<T> {
  53479. /**
  53480. * Gets the content of the current block
  53481. */
  53482. entries: T[];
  53483. /**
  53484. * Gets the list of block children
  53485. */
  53486. blocks: Array<OctreeBlock<T>>;
  53487. private _depth;
  53488. private _maxDepth;
  53489. private _capacity;
  53490. private _minPoint;
  53491. private _maxPoint;
  53492. private _boundingVectors;
  53493. private _creationFunc;
  53494. /**
  53495. * Creates a new block
  53496. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  53497. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  53498. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  53499. * @param depth defines the current depth of this block in the octree
  53500. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  53501. * @param creationFunc defines a callback to call when an element is added to the block
  53502. */
  53503. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  53504. /**
  53505. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  53506. */
  53507. get capacity(): number;
  53508. /**
  53509. * Gets the minimum vector (in world space) of the block's bounding box
  53510. */
  53511. get minPoint(): Vector3;
  53512. /**
  53513. * Gets the maximum vector (in world space) of the block's bounding box
  53514. */
  53515. get maxPoint(): Vector3;
  53516. /**
  53517. * Add a new element to this block
  53518. * @param entry defines the element to add
  53519. */
  53520. addEntry(entry: T): void;
  53521. /**
  53522. * Remove an element from this block
  53523. * @param entry defines the element to remove
  53524. */
  53525. removeEntry(entry: T): void;
  53526. /**
  53527. * Add an array of elements to this block
  53528. * @param entries defines the array of elements to add
  53529. */
  53530. addEntries(entries: T[]): void;
  53531. /**
  53532. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  53533. * @param frustumPlanes defines the frustum planes to test
  53534. * @param selection defines the array to store current content if selection is positive
  53535. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53536. */
  53537. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  53538. /**
  53539. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  53540. * @param sphereCenter defines the bounding sphere center
  53541. * @param sphereRadius defines the bounding sphere radius
  53542. * @param selection defines the array to store current content if selection is positive
  53543. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53544. */
  53545. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  53546. /**
  53547. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  53548. * @param ray defines the ray to test with
  53549. * @param selection defines the array to store current content if selection is positive
  53550. */
  53551. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  53552. /**
  53553. * Subdivide the content into child blocks (this block will then be empty)
  53554. */
  53555. createInnerBlocks(): void;
  53556. /**
  53557. * @hidden
  53558. */
  53559. 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;
  53560. }
  53561. }
  53562. declare module BABYLON {
  53563. /**
  53564. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  53565. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53566. */
  53567. export class Octree<T> {
  53568. /** 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.) */
  53569. maxDepth: number;
  53570. /**
  53571. * Blocks within the octree containing objects
  53572. */
  53573. blocks: Array<OctreeBlock<T>>;
  53574. /**
  53575. * Content stored in the octree
  53576. */
  53577. dynamicContent: T[];
  53578. private _maxBlockCapacity;
  53579. private _selectionContent;
  53580. private _creationFunc;
  53581. /**
  53582. * Creates a octree
  53583. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53584. * @param creationFunc function to be used to instatiate the octree
  53585. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  53586. * @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.)
  53587. */
  53588. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  53589. /** 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.) */
  53590. maxDepth?: number);
  53591. /**
  53592. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  53593. * @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);
  53594. * @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);
  53595. * @param entries meshes to be added to the octree blocks
  53596. */
  53597. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  53598. /**
  53599. * Adds a mesh to the octree
  53600. * @param entry Mesh to add to the octree
  53601. */
  53602. addMesh(entry: T): void;
  53603. /**
  53604. * Remove an element from the octree
  53605. * @param entry defines the element to remove
  53606. */
  53607. removeMesh(entry: T): void;
  53608. /**
  53609. * Selects an array of meshes within the frustum
  53610. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  53611. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  53612. * @returns array of meshes within the frustum
  53613. */
  53614. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  53615. /**
  53616. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  53617. * @param sphereCenter defines the bounding sphere center
  53618. * @param sphereRadius defines the bounding sphere radius
  53619. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53620. * @returns an array of objects that intersect the sphere
  53621. */
  53622. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  53623. /**
  53624. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  53625. * @param ray defines the ray to test with
  53626. * @returns array of intersected objects
  53627. */
  53628. intersectsRay(ray: Ray): SmartArray<T>;
  53629. /**
  53630. * Adds a mesh into the octree block if it intersects the block
  53631. */
  53632. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  53633. /**
  53634. * Adds a submesh into the octree block if it intersects the block
  53635. */
  53636. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  53637. }
  53638. }
  53639. declare module BABYLON {
  53640. interface Scene {
  53641. /**
  53642. * @hidden
  53643. * Backing Filed
  53644. */
  53645. _selectionOctree: Octree<AbstractMesh>;
  53646. /**
  53647. * Gets the octree used to boost mesh selection (picking)
  53648. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53649. */
  53650. selectionOctree: Octree<AbstractMesh>;
  53651. /**
  53652. * Creates or updates the octree used to boost selection (picking)
  53653. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53654. * @param maxCapacity defines the maximum capacity per leaf
  53655. * @param maxDepth defines the maximum depth of the octree
  53656. * @returns an octree of AbstractMesh
  53657. */
  53658. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  53659. }
  53660. interface AbstractMesh {
  53661. /**
  53662. * @hidden
  53663. * Backing Field
  53664. */
  53665. _submeshesOctree: Octree<SubMesh>;
  53666. /**
  53667. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  53668. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  53669. * @param maxCapacity defines the maximum size of each block (64 by default)
  53670. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  53671. * @returns the new octree
  53672. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  53673. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53674. */
  53675. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  53676. }
  53677. /**
  53678. * Defines the octree scene component responsible to manage any octrees
  53679. * in a given scene.
  53680. */
  53681. export class OctreeSceneComponent {
  53682. /**
  53683. * The component name help to identify the component in the list of scene components.
  53684. */
  53685. readonly name: string;
  53686. /**
  53687. * The scene the component belongs to.
  53688. */
  53689. scene: Scene;
  53690. /**
  53691. * Indicates if the meshes have been checked to make sure they are isEnabled()
  53692. */
  53693. readonly checksIsEnabled: boolean;
  53694. /**
  53695. * Creates a new instance of the component for the given scene
  53696. * @param scene Defines the scene to register the component in
  53697. */
  53698. constructor(scene: Scene);
  53699. /**
  53700. * Registers the component in a given scene
  53701. */
  53702. register(): void;
  53703. /**
  53704. * Return the list of active meshes
  53705. * @returns the list of active meshes
  53706. */
  53707. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  53708. /**
  53709. * Return the list of active sub meshes
  53710. * @param mesh The mesh to get the candidates sub meshes from
  53711. * @returns the list of active sub meshes
  53712. */
  53713. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  53714. private _tempRay;
  53715. /**
  53716. * Return the list of sub meshes intersecting with a given local ray
  53717. * @param mesh defines the mesh to find the submesh for
  53718. * @param localRay defines the ray in local space
  53719. * @returns the list of intersecting sub meshes
  53720. */
  53721. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  53722. /**
  53723. * Return the list of sub meshes colliding with a collider
  53724. * @param mesh defines the mesh to find the submesh for
  53725. * @param collider defines the collider to evaluate the collision against
  53726. * @returns the list of colliding sub meshes
  53727. */
  53728. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  53729. /**
  53730. * Rebuilds the elements related to this component in case of
  53731. * context lost for instance.
  53732. */
  53733. rebuild(): void;
  53734. /**
  53735. * Disposes the component and the associated ressources.
  53736. */
  53737. dispose(): void;
  53738. }
  53739. }
  53740. declare module BABYLON {
  53741. /**
  53742. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  53743. */
  53744. export class Gizmo implements IDisposable {
  53745. /** The utility layer the gizmo will be added to */
  53746. gizmoLayer: UtilityLayerRenderer;
  53747. /**
  53748. * The root mesh of the gizmo
  53749. */
  53750. _rootMesh: Mesh;
  53751. private _attachedMesh;
  53752. private _attachedNode;
  53753. /**
  53754. * Ratio for the scale of the gizmo (Default: 1)
  53755. */
  53756. protected _scaleRatio: number;
  53757. /**
  53758. * boolean updated by pointermove when a gizmo mesh is hovered
  53759. */
  53760. protected _isHovered: boolean;
  53761. /**
  53762. * Ratio for the scale of the gizmo (Default: 1)
  53763. */
  53764. set scaleRatio(value: number);
  53765. get scaleRatio(): number;
  53766. /**
  53767. * True when the mouse pointer is hovered a gizmo mesh
  53768. */
  53769. get isHovered(): boolean;
  53770. /**
  53771. * If a custom mesh has been set (Default: false)
  53772. */
  53773. protected _customMeshSet: boolean;
  53774. /**
  53775. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  53776. * * When set, interactions will be enabled
  53777. */
  53778. get attachedMesh(): Nullable<AbstractMesh>;
  53779. set attachedMesh(value: Nullable<AbstractMesh>);
  53780. /**
  53781. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  53782. * * When set, interactions will be enabled
  53783. */
  53784. get attachedNode(): Nullable<Node>;
  53785. set attachedNode(value: Nullable<Node>);
  53786. /**
  53787. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  53788. * @param mesh The mesh to replace the default mesh of the gizmo
  53789. */
  53790. setCustomMesh(mesh: Mesh): void;
  53791. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  53792. /**
  53793. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  53794. */
  53795. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53796. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53797. /**
  53798. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  53799. */
  53800. updateGizmoPositionToMatchAttachedMesh: boolean;
  53801. /**
  53802. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  53803. */
  53804. updateScale: boolean;
  53805. protected _interactionsEnabled: boolean;
  53806. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53807. private _beforeRenderObserver;
  53808. private _tempQuaternion;
  53809. private _tempVector;
  53810. private _tempVector2;
  53811. private _tempMatrix1;
  53812. private _tempMatrix2;
  53813. private _rightHandtoLeftHandMatrix;
  53814. /**
  53815. * Creates a gizmo
  53816. * @param gizmoLayer The utility layer the gizmo will be added to
  53817. */
  53818. constructor(
  53819. /** The utility layer the gizmo will be added to */
  53820. gizmoLayer?: UtilityLayerRenderer);
  53821. /**
  53822. * Updates the gizmo to match the attached mesh's position/rotation
  53823. */
  53824. protected _update(): void;
  53825. /**
  53826. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  53827. * @param value Node, TransformNode or mesh
  53828. */
  53829. protected _matrixChanged(): void;
  53830. /**
  53831. * Disposes of the gizmo
  53832. */
  53833. dispose(): void;
  53834. }
  53835. }
  53836. declare module BABYLON {
  53837. /**
  53838. * Single plane drag gizmo
  53839. */
  53840. export class PlaneDragGizmo extends Gizmo {
  53841. /**
  53842. * Drag behavior responsible for the gizmos dragging interactions
  53843. */
  53844. dragBehavior: PointerDragBehavior;
  53845. private _pointerObserver;
  53846. /**
  53847. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53848. */
  53849. snapDistance: number;
  53850. /**
  53851. * Event that fires each time the gizmo snaps to a new location.
  53852. * * snapDistance is the the change in distance
  53853. */
  53854. onSnapObservable: Observable<{
  53855. snapDistance: number;
  53856. }>;
  53857. private _plane;
  53858. private _coloredMaterial;
  53859. private _hoverMaterial;
  53860. private _isEnabled;
  53861. private _parent;
  53862. /** @hidden */
  53863. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  53864. /** @hidden */
  53865. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  53866. /**
  53867. * Creates a PlaneDragGizmo
  53868. * @param gizmoLayer The utility layer the gizmo will be added to
  53869. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  53870. * @param color The color of the gizmo
  53871. */
  53872. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  53873. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53874. /**
  53875. * If the gizmo is enabled
  53876. */
  53877. set isEnabled(value: boolean);
  53878. get isEnabled(): boolean;
  53879. /**
  53880. * Disposes of the gizmo
  53881. */
  53882. dispose(): void;
  53883. }
  53884. }
  53885. declare module BABYLON {
  53886. /**
  53887. * Gizmo that enables dragging a mesh along 3 axis
  53888. */
  53889. export class PositionGizmo extends Gizmo {
  53890. /**
  53891. * Internal gizmo used for interactions on the x axis
  53892. */
  53893. xGizmo: AxisDragGizmo;
  53894. /**
  53895. * Internal gizmo used for interactions on the y axis
  53896. */
  53897. yGizmo: AxisDragGizmo;
  53898. /**
  53899. * Internal gizmo used for interactions on the z axis
  53900. */
  53901. zGizmo: AxisDragGizmo;
  53902. /**
  53903. * Internal gizmo used for interactions on the yz plane
  53904. */
  53905. xPlaneGizmo: PlaneDragGizmo;
  53906. /**
  53907. * Internal gizmo used for interactions on the xz plane
  53908. */
  53909. yPlaneGizmo: PlaneDragGizmo;
  53910. /**
  53911. * Internal gizmo used for interactions on the xy plane
  53912. */
  53913. zPlaneGizmo: PlaneDragGizmo;
  53914. /**
  53915. * private variables
  53916. */
  53917. private _meshAttached;
  53918. private _nodeAttached;
  53919. private _snapDistance;
  53920. /** Fires an event when any of it's sub gizmos are dragged */
  53921. onDragStartObservable: Observable<unknown>;
  53922. /** Fires an event when any of it's sub gizmos are released from dragging */
  53923. onDragEndObservable: Observable<unknown>;
  53924. /**
  53925. * If set to true, planar drag is enabled
  53926. */
  53927. private _planarGizmoEnabled;
  53928. get attachedMesh(): Nullable<AbstractMesh>;
  53929. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53930. get attachedNode(): Nullable<Node>;
  53931. set attachedNode(node: Nullable<Node>);
  53932. /**
  53933. * True when the mouse pointer is hovering a gizmo mesh
  53934. */
  53935. get isHovered(): boolean;
  53936. /**
  53937. * Creates a PositionGizmo
  53938. * @param gizmoLayer The utility layer the gizmo will be added to
  53939. @param thickness display gizmo axis thickness
  53940. */
  53941. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  53942. /**
  53943. * If the planar drag gizmo is enabled
  53944. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  53945. */
  53946. set planarGizmoEnabled(value: boolean);
  53947. get planarGizmoEnabled(): boolean;
  53948. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53949. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53950. /**
  53951. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53952. */
  53953. set snapDistance(value: number);
  53954. get snapDistance(): number;
  53955. /**
  53956. * Ratio for the scale of the gizmo (Default: 1)
  53957. */
  53958. set scaleRatio(value: number);
  53959. get scaleRatio(): number;
  53960. /**
  53961. * Disposes of the gizmo
  53962. */
  53963. dispose(): void;
  53964. /**
  53965. * CustomMeshes are not supported by this gizmo
  53966. * @param mesh The mesh to replace the default mesh of the gizmo
  53967. */
  53968. setCustomMesh(mesh: Mesh): void;
  53969. }
  53970. }
  53971. declare module BABYLON {
  53972. /**
  53973. * Single axis drag gizmo
  53974. */
  53975. export class AxisDragGizmo extends Gizmo {
  53976. /**
  53977. * Drag behavior responsible for the gizmos dragging interactions
  53978. */
  53979. dragBehavior: PointerDragBehavior;
  53980. private _pointerObserver;
  53981. /**
  53982. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53983. */
  53984. snapDistance: number;
  53985. /**
  53986. * Event that fires each time the gizmo snaps to a new location.
  53987. * * snapDistance is the the change in distance
  53988. */
  53989. onSnapObservable: Observable<{
  53990. snapDistance: number;
  53991. }>;
  53992. private _isEnabled;
  53993. private _parent;
  53994. private _arrow;
  53995. private _coloredMaterial;
  53996. private _hoverMaterial;
  53997. /** @hidden */
  53998. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  53999. /** @hidden */
  54000. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  54001. /**
  54002. * Creates an AxisDragGizmo
  54003. * @param gizmoLayer The utility layer the gizmo will be added to
  54004. * @param dragAxis The axis which the gizmo will be able to drag on
  54005. * @param color The color of the gizmo
  54006. * @param thickness display gizmo axis thickness
  54007. */
  54008. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  54009. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54010. /**
  54011. * If the gizmo is enabled
  54012. */
  54013. set isEnabled(value: boolean);
  54014. get isEnabled(): boolean;
  54015. /**
  54016. * Disposes of the gizmo
  54017. */
  54018. dispose(): void;
  54019. }
  54020. }
  54021. declare module BABYLON.Debug {
  54022. /**
  54023. * The Axes viewer will show 3 axes in a specific point in space
  54024. */
  54025. export class AxesViewer {
  54026. private _xAxis;
  54027. private _yAxis;
  54028. private _zAxis;
  54029. private _scaleLinesFactor;
  54030. private _instanced;
  54031. /**
  54032. * Gets the hosting scene
  54033. */
  54034. scene: Nullable<Scene>;
  54035. /**
  54036. * Gets or sets a number used to scale line length
  54037. */
  54038. scaleLines: number;
  54039. /** Gets the node hierarchy used to render x-axis */
  54040. get xAxis(): TransformNode;
  54041. /** Gets the node hierarchy used to render y-axis */
  54042. get yAxis(): TransformNode;
  54043. /** Gets the node hierarchy used to render z-axis */
  54044. get zAxis(): TransformNode;
  54045. /**
  54046. * Creates a new AxesViewer
  54047. * @param scene defines the hosting scene
  54048. * @param scaleLines defines a number used to scale line length (1 by default)
  54049. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  54050. * @param xAxis defines the node hierarchy used to render the x-axis
  54051. * @param yAxis defines the node hierarchy used to render the y-axis
  54052. * @param zAxis defines the node hierarchy used to render the z-axis
  54053. */
  54054. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  54055. /**
  54056. * Force the viewer to update
  54057. * @param position defines the position of the viewer
  54058. * @param xaxis defines the x axis of the viewer
  54059. * @param yaxis defines the y axis of the viewer
  54060. * @param zaxis defines the z axis of the viewer
  54061. */
  54062. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  54063. /**
  54064. * Creates an instance of this axes viewer.
  54065. * @returns a new axes viewer with instanced meshes
  54066. */
  54067. createInstance(): AxesViewer;
  54068. /** Releases resources */
  54069. dispose(): void;
  54070. private static _SetRenderingGroupId;
  54071. }
  54072. }
  54073. declare module BABYLON.Debug {
  54074. /**
  54075. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  54076. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  54077. */
  54078. export class BoneAxesViewer extends AxesViewer {
  54079. /**
  54080. * Gets or sets the target mesh where to display the axes viewer
  54081. */
  54082. mesh: Nullable<Mesh>;
  54083. /**
  54084. * Gets or sets the target bone where to display the axes viewer
  54085. */
  54086. bone: Nullable<Bone>;
  54087. /** Gets current position */
  54088. pos: Vector3;
  54089. /** Gets direction of X axis */
  54090. xaxis: Vector3;
  54091. /** Gets direction of Y axis */
  54092. yaxis: Vector3;
  54093. /** Gets direction of Z axis */
  54094. zaxis: Vector3;
  54095. /**
  54096. * Creates a new BoneAxesViewer
  54097. * @param scene defines the hosting scene
  54098. * @param bone defines the target bone
  54099. * @param mesh defines the target mesh
  54100. * @param scaleLines defines a scaling factor for line length (1 by default)
  54101. */
  54102. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  54103. /**
  54104. * Force the viewer to update
  54105. */
  54106. update(): void;
  54107. /** Releases resources */
  54108. dispose(): void;
  54109. }
  54110. }
  54111. declare module BABYLON {
  54112. /**
  54113. * Interface used to define scene explorer extensibility option
  54114. */
  54115. export interface IExplorerExtensibilityOption {
  54116. /**
  54117. * Define the option label
  54118. */
  54119. label: string;
  54120. /**
  54121. * Defines the action to execute on click
  54122. */
  54123. action: (entity: any) => void;
  54124. }
  54125. /**
  54126. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  54127. */
  54128. export interface IExplorerExtensibilityGroup {
  54129. /**
  54130. * Defines a predicate to test if a given type mut be extended
  54131. */
  54132. predicate: (entity: any) => boolean;
  54133. /**
  54134. * Gets the list of options added to a type
  54135. */
  54136. entries: IExplorerExtensibilityOption[];
  54137. }
  54138. /**
  54139. * Interface used to define the options to use to create the Inspector
  54140. */
  54141. export interface IInspectorOptions {
  54142. /**
  54143. * Display in overlay mode (default: false)
  54144. */
  54145. overlay?: boolean;
  54146. /**
  54147. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  54148. */
  54149. globalRoot?: HTMLElement;
  54150. /**
  54151. * Display the Scene explorer
  54152. */
  54153. showExplorer?: boolean;
  54154. /**
  54155. * Display the property inspector
  54156. */
  54157. showInspector?: boolean;
  54158. /**
  54159. * Display in embed mode (both panes on the right)
  54160. */
  54161. embedMode?: boolean;
  54162. /**
  54163. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  54164. */
  54165. handleResize?: boolean;
  54166. /**
  54167. * Allow the panes to popup (default: true)
  54168. */
  54169. enablePopup?: boolean;
  54170. /**
  54171. * Allow the panes to be closed by users (default: true)
  54172. */
  54173. enableClose?: boolean;
  54174. /**
  54175. * Optional list of extensibility entries
  54176. */
  54177. explorerExtensibility?: IExplorerExtensibilityGroup[];
  54178. /**
  54179. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  54180. */
  54181. inspectorURL?: string;
  54182. /**
  54183. * Optional initial tab (default to DebugLayerTab.Properties)
  54184. */
  54185. initialTab?: DebugLayerTab;
  54186. }
  54187. interface Scene {
  54188. /**
  54189. * @hidden
  54190. * Backing field
  54191. */
  54192. _debugLayer: DebugLayer;
  54193. /**
  54194. * Gets the debug layer (aka Inspector) associated with the scene
  54195. * @see https://doc.babylonjs.com/features/playground_debuglayer
  54196. */
  54197. debugLayer: DebugLayer;
  54198. }
  54199. /**
  54200. * Enum of inspector action tab
  54201. */
  54202. export enum DebugLayerTab {
  54203. /**
  54204. * Properties tag (default)
  54205. */
  54206. Properties = 0,
  54207. /**
  54208. * Debug tab
  54209. */
  54210. Debug = 1,
  54211. /**
  54212. * Statistics tab
  54213. */
  54214. Statistics = 2,
  54215. /**
  54216. * Tools tab
  54217. */
  54218. Tools = 3,
  54219. /**
  54220. * Settings tab
  54221. */
  54222. Settings = 4
  54223. }
  54224. /**
  54225. * The debug layer (aka Inspector) is the go to tool in order to better understand
  54226. * what is happening in your scene
  54227. * @see https://doc.babylonjs.com/features/playground_debuglayer
  54228. */
  54229. export class DebugLayer {
  54230. /**
  54231. * Define the url to get the inspector script from.
  54232. * By default it uses the babylonjs CDN.
  54233. * @ignoreNaming
  54234. */
  54235. static InspectorURL: string;
  54236. private _scene;
  54237. private BJSINSPECTOR;
  54238. private _onPropertyChangedObservable?;
  54239. /**
  54240. * Observable triggered when a property is changed through the inspector.
  54241. */
  54242. get onPropertyChangedObservable(): any;
  54243. /**
  54244. * Instantiates a new debug layer.
  54245. * The debug layer (aka Inspector) is the go to tool in order to better understand
  54246. * what is happening in your scene
  54247. * @see https://doc.babylonjs.com/features/playground_debuglayer
  54248. * @param scene Defines the scene to inspect
  54249. */
  54250. constructor(scene: Scene);
  54251. /** Creates the inspector window. */
  54252. private _createInspector;
  54253. /**
  54254. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  54255. * @param entity defines the entity to select
  54256. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  54257. */
  54258. select(entity: any, lineContainerTitles?: string | string[]): void;
  54259. /** Get the inspector from bundle or global */
  54260. private _getGlobalInspector;
  54261. /**
  54262. * Get if the inspector is visible or not.
  54263. * @returns true if visible otherwise, false
  54264. */
  54265. isVisible(): boolean;
  54266. /**
  54267. * Hide the inspector and close its window.
  54268. */
  54269. hide(): void;
  54270. /**
  54271. * Update the scene in the inspector
  54272. */
  54273. setAsActiveScene(): void;
  54274. /**
  54275. * Launch the debugLayer.
  54276. * @param config Define the configuration of the inspector
  54277. * @return a promise fulfilled when the debug layer is visible
  54278. */
  54279. show(config?: IInspectorOptions): Promise<DebugLayer>;
  54280. }
  54281. }
  54282. declare module BABYLON {
  54283. /**
  54284. * Class containing static functions to help procedurally build meshes
  54285. */
  54286. export class BoxBuilder {
  54287. /**
  54288. * Creates a box mesh
  54289. * * The parameter `size` sets the size (float) of each box side (default 1)
  54290. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  54291. * * 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)
  54292. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54293. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54294. * * 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
  54295. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54296. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54297. * @param name defines the name of the mesh
  54298. * @param options defines the options used to create the mesh
  54299. * @param scene defines the hosting scene
  54300. * @returns the box mesh
  54301. */
  54302. static CreateBox(name: string, options: {
  54303. size?: number;
  54304. width?: number;
  54305. height?: number;
  54306. depth?: number;
  54307. faceUV?: Vector4[];
  54308. faceColors?: Color4[];
  54309. sideOrientation?: number;
  54310. frontUVs?: Vector4;
  54311. backUVs?: Vector4;
  54312. wrap?: boolean;
  54313. topBaseAt?: number;
  54314. bottomBaseAt?: number;
  54315. updatable?: boolean;
  54316. }, scene?: Nullable<Scene>): Mesh;
  54317. }
  54318. }
  54319. declare module BABYLON.Debug {
  54320. /**
  54321. * Used to show the physics impostor around the specific mesh
  54322. */
  54323. export class PhysicsViewer {
  54324. /** @hidden */
  54325. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  54326. /** @hidden */
  54327. protected _meshes: Array<Nullable<AbstractMesh>>;
  54328. /** @hidden */
  54329. protected _scene: Nullable<Scene>;
  54330. /** @hidden */
  54331. protected _numMeshes: number;
  54332. /** @hidden */
  54333. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  54334. private _renderFunction;
  54335. private _utilityLayer;
  54336. private _debugBoxMesh;
  54337. private _debugSphereMesh;
  54338. private _debugCylinderMesh;
  54339. private _debugMaterial;
  54340. private _debugMeshMeshes;
  54341. /**
  54342. * Creates a new PhysicsViewer
  54343. * @param scene defines the hosting scene
  54344. */
  54345. constructor(scene: Scene);
  54346. /** @hidden */
  54347. protected _updateDebugMeshes(): void;
  54348. /**
  54349. * Renders a specified physic impostor
  54350. * @param impostor defines the impostor to render
  54351. * @param targetMesh defines the mesh represented by the impostor
  54352. * @returns the new debug mesh used to render the impostor
  54353. */
  54354. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  54355. /**
  54356. * Hides a specified physic impostor
  54357. * @param impostor defines the impostor to hide
  54358. */
  54359. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  54360. private _getDebugMaterial;
  54361. private _getDebugBoxMesh;
  54362. private _getDebugSphereMesh;
  54363. private _getDebugCylinderMesh;
  54364. private _getDebugMeshMesh;
  54365. private _getDebugMesh;
  54366. /** Releases all resources */
  54367. dispose(): void;
  54368. }
  54369. }
  54370. declare module BABYLON {
  54371. /**
  54372. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  54373. * in order to better appreciate the issue one might have.
  54374. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  54375. */
  54376. export class RayHelper {
  54377. /**
  54378. * Defines the ray we are currently tryin to visualize.
  54379. */
  54380. ray: Nullable<Ray>;
  54381. private _renderPoints;
  54382. private _renderLine;
  54383. private _renderFunction;
  54384. private _scene;
  54385. private _onAfterRenderObserver;
  54386. private _onAfterStepObserver;
  54387. private _attachedToMesh;
  54388. private _meshSpaceDirection;
  54389. private _meshSpaceOrigin;
  54390. /**
  54391. * Helper function to create a colored helper in a scene in one line.
  54392. * @param ray Defines the ray we are currently tryin to visualize
  54393. * @param scene Defines the scene the ray is used in
  54394. * @param color Defines the color we want to see the ray in
  54395. * @returns The newly created ray helper.
  54396. */
  54397. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  54398. /**
  54399. * Instantiate a new ray helper.
  54400. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  54401. * in order to better appreciate the issue one might have.
  54402. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  54403. * @param ray Defines the ray we are currently tryin to visualize
  54404. */
  54405. constructor(ray: Ray);
  54406. /**
  54407. * Shows the ray we are willing to debug.
  54408. * @param scene Defines the scene the ray needs to be rendered in
  54409. * @param color Defines the color the ray needs to be rendered in
  54410. */
  54411. show(scene: Scene, color?: Color3): void;
  54412. /**
  54413. * Hides the ray we are debugging.
  54414. */
  54415. hide(): void;
  54416. private _render;
  54417. /**
  54418. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  54419. * @param mesh Defines the mesh we want the helper attached to
  54420. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  54421. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  54422. * @param length Defines the length of the ray
  54423. */
  54424. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  54425. /**
  54426. * Detach the ray helper from the mesh it has previously been attached to.
  54427. */
  54428. detachFromMesh(): void;
  54429. private _updateToMesh;
  54430. /**
  54431. * Dispose the helper and release its associated resources.
  54432. */
  54433. dispose(): void;
  54434. }
  54435. }
  54436. declare module BABYLON {
  54437. /**
  54438. * Defines the options associated with the creation of a SkeletonViewer.
  54439. */
  54440. export interface ISkeletonViewerOptions {
  54441. /** Should the system pause animations before building the Viewer? */
  54442. pauseAnimations: boolean;
  54443. /** Should the system return the skeleton to rest before building? */
  54444. returnToRest: boolean;
  54445. /** public Display Mode of the Viewer */
  54446. displayMode: number;
  54447. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  54448. displayOptions: ISkeletonViewerDisplayOptions;
  54449. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  54450. computeBonesUsingShaders: boolean;
  54451. /** Flag ignore non weighted bones */
  54452. useAllBones: boolean;
  54453. }
  54454. /**
  54455. * Defines how to display the various bone meshes for the viewer.
  54456. */
  54457. export interface ISkeletonViewerDisplayOptions {
  54458. /** How far down to start tapering the bone spurs */
  54459. midStep?: number;
  54460. /** How big is the midStep? */
  54461. midStepFactor?: number;
  54462. /** Base for the Sphere Size */
  54463. sphereBaseSize?: number;
  54464. /** The ratio of the sphere to the longest bone in units */
  54465. sphereScaleUnit?: number;
  54466. /** Ratio for the Sphere Size */
  54467. sphereFactor?: number;
  54468. /** Whether a spur should attach its far end to the child bone position */
  54469. spurFollowsChild?: boolean;
  54470. /** Whether to show local axes or not */
  54471. showLocalAxes?: boolean;
  54472. /** Length of each local axis */
  54473. localAxesSize?: number;
  54474. }
  54475. /**
  54476. * Defines the constructor options for the BoneWeight Shader.
  54477. */
  54478. export interface IBoneWeightShaderOptions {
  54479. /** Skeleton to Map */
  54480. skeleton: Skeleton;
  54481. /** Colors for Uninfluenced bones */
  54482. colorBase?: Color3;
  54483. /** Colors for 0.0-0.25 Weight bones */
  54484. colorZero?: Color3;
  54485. /** Color for 0.25-0.5 Weight Influence */
  54486. colorQuarter?: Color3;
  54487. /** Color for 0.5-0.75 Weight Influence */
  54488. colorHalf?: Color3;
  54489. /** Color for 0.75-1 Weight Influence */
  54490. colorFull?: Color3;
  54491. /** Color for Zero Weight Influence */
  54492. targetBoneIndex?: number;
  54493. }
  54494. /**
  54495. * Simple structure of the gradient steps for the Color Map.
  54496. */
  54497. export interface ISkeletonMapShaderColorMapKnot {
  54498. /** Color of the Knot */
  54499. color: Color3;
  54500. /** Location of the Knot */
  54501. location: number;
  54502. }
  54503. /**
  54504. * Defines the constructor options for the SkeletonMap Shader.
  54505. */
  54506. export interface ISkeletonMapShaderOptions {
  54507. /** Skeleton to Map */
  54508. skeleton: Skeleton;
  54509. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  54510. colorMap?: ISkeletonMapShaderColorMapKnot[];
  54511. }
  54512. }
  54513. declare module BABYLON {
  54514. /**
  54515. * Class containing static functions to help procedurally build meshes
  54516. */
  54517. export class RibbonBuilder {
  54518. /**
  54519. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54520. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54521. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54522. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54523. * * 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
  54524. * * 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
  54525. * * 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
  54526. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54527. * * 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
  54528. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54529. * * 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
  54530. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54531. * * 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
  54532. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54533. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54534. * @param name defines the name of the mesh
  54535. * @param options defines the options used to create the mesh
  54536. * @param scene defines the hosting scene
  54537. * @returns the ribbon mesh
  54538. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54539. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54540. */
  54541. static CreateRibbon(name: string, options: {
  54542. pathArray: Vector3[][];
  54543. closeArray?: boolean;
  54544. closePath?: boolean;
  54545. offset?: number;
  54546. updatable?: boolean;
  54547. sideOrientation?: number;
  54548. frontUVs?: Vector4;
  54549. backUVs?: Vector4;
  54550. instance?: Mesh;
  54551. invertUV?: boolean;
  54552. uvs?: Vector2[];
  54553. colors?: Color4[];
  54554. }, scene?: Nullable<Scene>): Mesh;
  54555. }
  54556. }
  54557. declare module BABYLON {
  54558. /**
  54559. * Class containing static functions to help procedurally build meshes
  54560. */
  54561. export class ShapeBuilder {
  54562. /**
  54563. * 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.
  54564. * * 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.
  54565. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54566. * * 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.
  54567. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  54568. * * 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
  54569. * * 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
  54570. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  54571. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54572. * * 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
  54573. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  54574. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54575. * @param name defines the name of the mesh
  54576. * @param options defines the options used to create the mesh
  54577. * @param scene defines the hosting scene
  54578. * @returns the extruded shape mesh
  54579. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54580. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54581. */
  54582. static ExtrudeShape(name: string, options: {
  54583. shape: Vector3[];
  54584. path: Vector3[];
  54585. scale?: number;
  54586. rotation?: number;
  54587. cap?: number;
  54588. updatable?: boolean;
  54589. sideOrientation?: number;
  54590. frontUVs?: Vector4;
  54591. backUVs?: Vector4;
  54592. instance?: Mesh;
  54593. invertUV?: boolean;
  54594. }, scene?: Nullable<Scene>): Mesh;
  54595. /**
  54596. * Creates an custom extruded shape mesh.
  54597. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  54598. * * 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.
  54599. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54600. * * 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
  54601. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  54602. * * 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
  54603. * * It must returns a float value that will be the scale value applied to the shape on each path point
  54604. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  54605. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  54606. * * 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
  54607. * * 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
  54608. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  54609. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54610. * * 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
  54611. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54612. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54613. * @param name defines the name of the mesh
  54614. * @param options defines the options used to create the mesh
  54615. * @param scene defines the hosting scene
  54616. * @returns the custom extruded shape mesh
  54617. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  54618. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54619. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54620. */
  54621. static ExtrudeShapeCustom(name: string, options: {
  54622. shape: Vector3[];
  54623. path: Vector3[];
  54624. scaleFunction?: any;
  54625. rotationFunction?: any;
  54626. ribbonCloseArray?: boolean;
  54627. ribbonClosePath?: boolean;
  54628. cap?: number;
  54629. updatable?: boolean;
  54630. sideOrientation?: number;
  54631. frontUVs?: Vector4;
  54632. backUVs?: Vector4;
  54633. instance?: Mesh;
  54634. invertUV?: boolean;
  54635. }, scene?: Nullable<Scene>): Mesh;
  54636. private static _ExtrudeShapeGeneric;
  54637. }
  54638. }
  54639. declare module BABYLON.Debug {
  54640. /**
  54641. * Class used to render a debug view of a given skeleton
  54642. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  54643. */
  54644. export class SkeletonViewer {
  54645. /** defines the skeleton to render */
  54646. skeleton: Skeleton;
  54647. /** defines the mesh attached to the skeleton */
  54648. mesh: AbstractMesh;
  54649. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  54650. autoUpdateBonesMatrices: boolean;
  54651. /** defines the rendering group id to use with the viewer */
  54652. renderingGroupId: number;
  54653. /** is the options for the viewer */
  54654. options: Partial<ISkeletonViewerOptions>;
  54655. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  54656. static readonly DISPLAY_LINES: number;
  54657. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  54658. static readonly DISPLAY_SPHERES: number;
  54659. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  54660. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  54661. /** public static method to create a BoneWeight Shader
  54662. * @param options The constructor options
  54663. * @param scene The scene that the shader is scoped to
  54664. * @returns The created ShaderMaterial
  54665. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  54666. */
  54667. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  54668. /** public static method to create a BoneWeight Shader
  54669. * @param options The constructor options
  54670. * @param scene The scene that the shader is scoped to
  54671. * @returns The created ShaderMaterial
  54672. */
  54673. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  54674. /** private static method to create a BoneWeight Shader
  54675. * @param size The size of the buffer to create (usually the bone count)
  54676. * @param colorMap The gradient data to generate
  54677. * @param scene The scene that the shader is scoped to
  54678. * @returns an Array of floats from the color gradient values
  54679. */
  54680. private static _CreateBoneMapColorBuffer;
  54681. /** If SkeletonViewer scene scope. */
  54682. private _scene;
  54683. /** Gets or sets the color used to render the skeleton */
  54684. color: Color3;
  54685. /** Array of the points of the skeleton fo the line view. */
  54686. private _debugLines;
  54687. /** The SkeletonViewers Mesh. */
  54688. private _debugMesh;
  54689. /** The local axes Meshes. */
  54690. private _localAxes;
  54691. /** If SkeletonViewer is enabled. */
  54692. private _isEnabled;
  54693. /** If SkeletonViewer is ready. */
  54694. private _ready;
  54695. /** SkeletonViewer render observable. */
  54696. private _obs;
  54697. /** The Utility Layer to render the gizmos in. */
  54698. private _utilityLayer;
  54699. private _boneIndices;
  54700. /** Gets the Scene. */
  54701. get scene(): Scene;
  54702. /** Gets the utilityLayer. */
  54703. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  54704. /** Checks Ready Status. */
  54705. get isReady(): Boolean;
  54706. /** Sets Ready Status. */
  54707. set ready(value: boolean);
  54708. /** Gets the debugMesh */
  54709. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  54710. /** Sets the debugMesh */
  54711. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  54712. /** Gets the displayMode */
  54713. get displayMode(): number;
  54714. /** Sets the displayMode */
  54715. set displayMode(value: number);
  54716. /**
  54717. * Creates a new SkeletonViewer
  54718. * @param skeleton defines the skeleton to render
  54719. * @param mesh defines the mesh attached to the skeleton
  54720. * @param scene defines the hosting scene
  54721. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  54722. * @param renderingGroupId defines the rendering group id to use with the viewer
  54723. * @param options All of the extra constructor options for the SkeletonViewer
  54724. */
  54725. constructor(
  54726. /** defines the skeleton to render */
  54727. skeleton: Skeleton,
  54728. /** defines the mesh attached to the skeleton */
  54729. mesh: AbstractMesh,
  54730. /** The Scene scope*/
  54731. scene: Scene,
  54732. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  54733. autoUpdateBonesMatrices?: boolean,
  54734. /** defines the rendering group id to use with the viewer */
  54735. renderingGroupId?: number,
  54736. /** is the options for the viewer */
  54737. options?: Partial<ISkeletonViewerOptions>);
  54738. /** The Dynamic bindings for the update functions */
  54739. private _bindObs;
  54740. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  54741. update(): void;
  54742. /** Gets or sets a boolean indicating if the viewer is enabled */
  54743. set isEnabled(value: boolean);
  54744. get isEnabled(): boolean;
  54745. private _getBonePosition;
  54746. private _getLinesForBonesWithLength;
  54747. private _getLinesForBonesNoLength;
  54748. /** function to revert the mesh and scene back to the initial state. */
  54749. private _revert;
  54750. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  54751. private _getAbsoluteBindPoseToRef;
  54752. /** function to build and bind sphere joint points and spur bone representations. */
  54753. private _buildSpheresAndSpurs;
  54754. private _buildLocalAxes;
  54755. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  54756. private _displayLinesUpdate;
  54757. /** Changes the displayMode of the skeleton viewer
  54758. * @param mode The displayMode numerical value
  54759. */
  54760. changeDisplayMode(mode: number): void;
  54761. /** Sets a display option of the skeleton viewer
  54762. *
  54763. * | Option | Type | Default | Description |
  54764. * | ---------------- | ------- | ------- | ----------- |
  54765. * | midStep | float | 0.235 | A percentage between a bone and its child that determines the widest part of a spur. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  54766. * | midStepFactor | float | 0.15 | Mid step width expressed as a factor of the length. A value of 0.5 makes the spur width half of the spur length. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  54767. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  54768. * | sphereScaleUnit | float | 0.865 | Sphere scale factor used to scale spheres in relation to the longest bone. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  54769. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  54770. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  54771. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  54772. *
  54773. * @param option String of the option name
  54774. * @param value The numerical option value
  54775. */
  54776. changeDisplayOptions(option: string, value: number): void;
  54777. /** Release associated resources */
  54778. dispose(): void;
  54779. }
  54780. }
  54781. declare module BABYLON {
  54782. /**
  54783. * Enum for Device Types
  54784. */
  54785. export enum DeviceType {
  54786. /** Generic */
  54787. Generic = 0,
  54788. /** Keyboard */
  54789. Keyboard = 1,
  54790. /** Mouse */
  54791. Mouse = 2,
  54792. /** Touch Pointers */
  54793. Touch = 3,
  54794. /** PS4 Dual Shock */
  54795. DualShock = 4,
  54796. /** Xbox */
  54797. Xbox = 5,
  54798. /** Switch Controller */
  54799. Switch = 6
  54800. }
  54801. /**
  54802. * Enum for All Pointers (Touch/Mouse)
  54803. */
  54804. export enum PointerInput {
  54805. /** Horizontal Axis */
  54806. Horizontal = 0,
  54807. /** Vertical Axis */
  54808. Vertical = 1,
  54809. /** Left Click or Touch */
  54810. LeftClick = 2,
  54811. /** Middle Click */
  54812. MiddleClick = 3,
  54813. /** Right Click */
  54814. RightClick = 4,
  54815. /** Browser Back */
  54816. BrowserBack = 5,
  54817. /** Browser Forward */
  54818. BrowserForward = 6
  54819. }
  54820. /**
  54821. * Enum for Dual Shock Gamepad
  54822. */
  54823. export enum DualShockInput {
  54824. /** Cross */
  54825. Cross = 0,
  54826. /** Circle */
  54827. Circle = 1,
  54828. /** Square */
  54829. Square = 2,
  54830. /** Triangle */
  54831. Triangle = 3,
  54832. /** L1 */
  54833. L1 = 4,
  54834. /** R1 */
  54835. R1 = 5,
  54836. /** L2 */
  54837. L2 = 6,
  54838. /** R2 */
  54839. R2 = 7,
  54840. /** Share */
  54841. Share = 8,
  54842. /** Options */
  54843. Options = 9,
  54844. /** L3 */
  54845. L3 = 10,
  54846. /** R3 */
  54847. R3 = 11,
  54848. /** DPadUp */
  54849. DPadUp = 12,
  54850. /** DPadDown */
  54851. DPadDown = 13,
  54852. /** DPadLeft */
  54853. DPadLeft = 14,
  54854. /** DRight */
  54855. DPadRight = 15,
  54856. /** Home */
  54857. Home = 16,
  54858. /** TouchPad */
  54859. TouchPad = 17,
  54860. /** LStickXAxis */
  54861. LStickXAxis = 18,
  54862. /** LStickYAxis */
  54863. LStickYAxis = 19,
  54864. /** RStickXAxis */
  54865. RStickXAxis = 20,
  54866. /** RStickYAxis */
  54867. RStickYAxis = 21
  54868. }
  54869. /**
  54870. * Enum for Xbox Gamepad
  54871. */
  54872. export enum XboxInput {
  54873. /** A */
  54874. A = 0,
  54875. /** B */
  54876. B = 1,
  54877. /** X */
  54878. X = 2,
  54879. /** Y */
  54880. Y = 3,
  54881. /** LB */
  54882. LB = 4,
  54883. /** RB */
  54884. RB = 5,
  54885. /** LT */
  54886. LT = 6,
  54887. /** RT */
  54888. RT = 7,
  54889. /** Back */
  54890. Back = 8,
  54891. /** Start */
  54892. Start = 9,
  54893. /** LS */
  54894. LS = 10,
  54895. /** RS */
  54896. RS = 11,
  54897. /** DPadUp */
  54898. DPadUp = 12,
  54899. /** DPadDown */
  54900. DPadDown = 13,
  54901. /** DPadLeft */
  54902. DPadLeft = 14,
  54903. /** DRight */
  54904. DPadRight = 15,
  54905. /** Home */
  54906. Home = 16,
  54907. /** LStickXAxis */
  54908. LStickXAxis = 17,
  54909. /** LStickYAxis */
  54910. LStickYAxis = 18,
  54911. /** RStickXAxis */
  54912. RStickXAxis = 19,
  54913. /** RStickYAxis */
  54914. RStickYAxis = 20
  54915. }
  54916. /**
  54917. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  54918. */
  54919. export enum SwitchInput {
  54920. /** B */
  54921. B = 0,
  54922. /** A */
  54923. A = 1,
  54924. /** Y */
  54925. Y = 2,
  54926. /** X */
  54927. X = 3,
  54928. /** L */
  54929. L = 4,
  54930. /** R */
  54931. R = 5,
  54932. /** ZL */
  54933. ZL = 6,
  54934. /** ZR */
  54935. ZR = 7,
  54936. /** Minus */
  54937. Minus = 8,
  54938. /** Plus */
  54939. Plus = 9,
  54940. /** LS */
  54941. LS = 10,
  54942. /** RS */
  54943. RS = 11,
  54944. /** DPadUp */
  54945. DPadUp = 12,
  54946. /** DPadDown */
  54947. DPadDown = 13,
  54948. /** DPadLeft */
  54949. DPadLeft = 14,
  54950. /** DRight */
  54951. DPadRight = 15,
  54952. /** Home */
  54953. Home = 16,
  54954. /** Capture */
  54955. Capture = 17,
  54956. /** LStickXAxis */
  54957. LStickXAxis = 18,
  54958. /** LStickYAxis */
  54959. LStickYAxis = 19,
  54960. /** RStickXAxis */
  54961. RStickXAxis = 20,
  54962. /** RStickYAxis */
  54963. RStickYAxis = 21
  54964. }
  54965. }
  54966. declare module BABYLON {
  54967. /**
  54968. * This class will take all inputs from Keyboard, Pointer, and
  54969. * any Gamepads and provide a polling system that all devices
  54970. * will use. This class assumes that there will only be one
  54971. * pointer device and one keyboard.
  54972. */
  54973. export class DeviceInputSystem implements IDisposable {
  54974. /**
  54975. * Returns onDeviceConnected callback property
  54976. * @returns Callback with function to execute when a device is connected
  54977. */
  54978. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  54979. /**
  54980. * Sets callback function when a device is connected and executes against all connected devices
  54981. * @param callback Function to execute when a device is connected
  54982. */
  54983. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  54984. /**
  54985. * Callback to be triggered when a device is disconnected
  54986. */
  54987. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  54988. /**
  54989. * Callback to be triggered when event driven input is updated
  54990. */
  54991. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  54992. private _inputs;
  54993. private _gamepads;
  54994. private _keyboardActive;
  54995. private _pointerActive;
  54996. private _elementToAttachTo;
  54997. private _keyboardDownEvent;
  54998. private _keyboardUpEvent;
  54999. private _pointerMoveEvent;
  55000. private _pointerDownEvent;
  55001. private _pointerUpEvent;
  55002. private _gamepadConnectedEvent;
  55003. private _gamepadDisconnectedEvent;
  55004. private _onDeviceConnected;
  55005. private static _MAX_KEYCODES;
  55006. private static _MAX_POINTER_INPUTS;
  55007. private constructor();
  55008. /**
  55009. * Creates a new DeviceInputSystem instance
  55010. * @param engine Engine to pull input element from
  55011. * @returns The new instance
  55012. */
  55013. static Create(engine: Engine): DeviceInputSystem;
  55014. /**
  55015. * Checks for current device input value, given an id and input index
  55016. * @param deviceName Id of connected device
  55017. * @param inputIndex Index of device input
  55018. * @returns Current value of input
  55019. */
  55020. /**
  55021. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  55022. * @param deviceType Enum specifiying device type
  55023. * @param deviceSlot "Slot" or index that device is referenced in
  55024. * @param inputIndex Id of input to be checked
  55025. * @returns Current value of input
  55026. */
  55027. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  55028. /**
  55029. * Dispose of all the eventlisteners
  55030. */
  55031. dispose(): void;
  55032. /**
  55033. * Checks for existing connections to devices and register them, if necessary
  55034. * Currently handles gamepads and mouse
  55035. */
  55036. private _checkForConnectedDevices;
  55037. /**
  55038. * Add a gamepad to the DeviceInputSystem
  55039. * @param gamepad A single DOM Gamepad object
  55040. */
  55041. private _addGamePad;
  55042. /**
  55043. * Add pointer device to DeviceInputSystem
  55044. * @param deviceType Type of Pointer to add
  55045. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  55046. * @param currentX Current X at point of adding
  55047. * @param currentY Current Y at point of adding
  55048. */
  55049. private _addPointerDevice;
  55050. /**
  55051. * Add device and inputs to device array
  55052. * @param deviceType Enum specifiying device type
  55053. * @param deviceSlot "Slot" or index that device is referenced in
  55054. * @param numberOfInputs Number of input entries to create for given device
  55055. */
  55056. private _registerDevice;
  55057. /**
  55058. * Given a specific device name, remove that device from the device map
  55059. * @param deviceType Enum specifiying device type
  55060. * @param deviceSlot "Slot" or index that device is referenced in
  55061. */
  55062. private _unregisterDevice;
  55063. /**
  55064. * Handle all actions that come from keyboard interaction
  55065. */
  55066. private _handleKeyActions;
  55067. /**
  55068. * Handle all actions that come from pointer interaction
  55069. */
  55070. private _handlePointerActions;
  55071. /**
  55072. * Handle all actions that come from gamepad interaction
  55073. */
  55074. private _handleGamepadActions;
  55075. /**
  55076. * Update all non-event based devices with each frame
  55077. * @param deviceType Enum specifiying device type
  55078. * @param deviceSlot "Slot" or index that device is referenced in
  55079. * @param inputIndex Id of input to be checked
  55080. */
  55081. private _updateDevice;
  55082. /**
  55083. * Gets DeviceType from the device name
  55084. * @param deviceName Name of Device from DeviceInputSystem
  55085. * @returns DeviceType enum value
  55086. */
  55087. private _getGamepadDeviceType;
  55088. }
  55089. }
  55090. declare module BABYLON {
  55091. /**
  55092. * Type to handle enforcement of inputs
  55093. */
  55094. 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;
  55095. }
  55096. declare module BABYLON {
  55097. /**
  55098. * Class that handles all input for a specific device
  55099. */
  55100. export class DeviceSource<T extends DeviceType> {
  55101. /** Type of device */
  55102. readonly deviceType: DeviceType;
  55103. /** "Slot" or index that device is referenced in */
  55104. readonly deviceSlot: number;
  55105. /**
  55106. * Observable to handle device input changes per device
  55107. */
  55108. readonly onInputChangedObservable: Observable<{
  55109. inputIndex: DeviceInput<T>;
  55110. previousState: Nullable<number>;
  55111. currentState: Nullable<number>;
  55112. }>;
  55113. private readonly _deviceInputSystem;
  55114. /**
  55115. * Default Constructor
  55116. * @param deviceInputSystem Reference to DeviceInputSystem
  55117. * @param deviceType Type of device
  55118. * @param deviceSlot "Slot" or index that device is referenced in
  55119. */
  55120. constructor(deviceInputSystem: DeviceInputSystem,
  55121. /** Type of device */
  55122. deviceType: DeviceType,
  55123. /** "Slot" or index that device is referenced in */
  55124. deviceSlot?: number);
  55125. /**
  55126. * Get input for specific input
  55127. * @param inputIndex index of specific input on device
  55128. * @returns Input value from DeviceInputSystem
  55129. */
  55130. getInput(inputIndex: DeviceInput<T>): number;
  55131. }
  55132. /**
  55133. * Class to keep track of devices
  55134. */
  55135. export class DeviceSourceManager implements IDisposable {
  55136. /**
  55137. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  55138. */
  55139. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  55140. /**
  55141. * Observable to be triggered when after a device is disconnected
  55142. */
  55143. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  55144. private readonly _devices;
  55145. private readonly _firstDevice;
  55146. private readonly _deviceInputSystem;
  55147. /**
  55148. * Default Constructor
  55149. * @param engine engine to pull input element from
  55150. */
  55151. constructor(engine: Engine);
  55152. /**
  55153. * Gets a DeviceSource, given a type and slot
  55154. * @param deviceType Enum specifying device type
  55155. * @param deviceSlot "Slot" or index that device is referenced in
  55156. * @returns DeviceSource object
  55157. */
  55158. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  55159. /**
  55160. * Gets an array of DeviceSource objects for a given device type
  55161. * @param deviceType Enum specifying device type
  55162. * @returns Array of DeviceSource objects
  55163. */
  55164. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  55165. /**
  55166. * Returns a read-only list of all available devices
  55167. * @returns Read-only array with active devices
  55168. */
  55169. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  55170. /**
  55171. * Dispose of DeviceInputSystem and other parts
  55172. */
  55173. dispose(): void;
  55174. /**
  55175. * Function to add device name to device list
  55176. * @param deviceType Enum specifying device type
  55177. * @param deviceSlot "Slot" or index that device is referenced in
  55178. */
  55179. private _addDevice;
  55180. /**
  55181. * Function to remove device name to device list
  55182. * @param deviceType Enum specifying device type
  55183. * @param deviceSlot "Slot" or index that device is referenced in
  55184. */
  55185. private _removeDevice;
  55186. /**
  55187. * Updates array storing first connected device of each type
  55188. * @param type Type of Device
  55189. */
  55190. private _updateFirstDevices;
  55191. }
  55192. }
  55193. declare module BABYLON {
  55194. /**
  55195. * Options to create the null engine
  55196. */
  55197. export class NullEngineOptions {
  55198. /**
  55199. * Render width (Default: 512)
  55200. */
  55201. renderWidth: number;
  55202. /**
  55203. * Render height (Default: 256)
  55204. */
  55205. renderHeight: number;
  55206. /**
  55207. * Texture size (Default: 512)
  55208. */
  55209. textureSize: number;
  55210. /**
  55211. * If delta time between frames should be constant
  55212. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  55213. */
  55214. deterministicLockstep: boolean;
  55215. /**
  55216. * Maximum about of steps between frames (Default: 4)
  55217. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  55218. */
  55219. lockstepMaxSteps: number;
  55220. /**
  55221. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  55222. */
  55223. useHighPrecisionMatrix?: boolean;
  55224. }
  55225. /**
  55226. * The null engine class provides support for headless version of babylon.js.
  55227. * This can be used in server side scenario or for testing purposes
  55228. */
  55229. export class NullEngine extends Engine {
  55230. private _options;
  55231. /**
  55232. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  55233. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  55234. * @returns true if engine is in deterministic lock step mode
  55235. */
  55236. isDeterministicLockStep(): boolean;
  55237. /**
  55238. * Gets the max steps when engine is running in deterministic lock step
  55239. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  55240. * @returns the max steps
  55241. */
  55242. getLockstepMaxSteps(): number;
  55243. /**
  55244. * Gets the current hardware scaling level.
  55245. * By default the hardware scaling level is computed from the window device ratio.
  55246. * 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.
  55247. * @returns a number indicating the current hardware scaling level
  55248. */
  55249. getHardwareScalingLevel(): number;
  55250. constructor(options?: NullEngineOptions);
  55251. /**
  55252. * Creates a vertex buffer
  55253. * @param vertices the data for the vertex buffer
  55254. * @returns the new WebGL static buffer
  55255. */
  55256. createVertexBuffer(vertices: FloatArray): DataBuffer;
  55257. /**
  55258. * Creates a new index buffer
  55259. * @param indices defines the content of the index buffer
  55260. * @param updatable defines if the index buffer must be updatable
  55261. * @returns a new webGL buffer
  55262. */
  55263. createIndexBuffer(indices: IndicesArray): DataBuffer;
  55264. /**
  55265. * Clear the current render buffer or the current render target (if any is set up)
  55266. * @param color defines the color to use
  55267. * @param backBuffer defines if the back buffer must be cleared
  55268. * @param depth defines if the depth buffer must be cleared
  55269. * @param stencil defines if the stencil buffer must be cleared
  55270. */
  55271. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  55272. /**
  55273. * Gets the current render width
  55274. * @param useScreen defines if screen size must be used (or the current render target if any)
  55275. * @returns a number defining the current render width
  55276. */
  55277. getRenderWidth(useScreen?: boolean): number;
  55278. /**
  55279. * Gets the current render height
  55280. * @param useScreen defines if screen size must be used (or the current render target if any)
  55281. * @returns a number defining the current render height
  55282. */
  55283. getRenderHeight(useScreen?: boolean): number;
  55284. /**
  55285. * Set the WebGL's viewport
  55286. * @param viewport defines the viewport element to be used
  55287. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  55288. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  55289. */
  55290. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  55291. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  55292. /**
  55293. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  55294. * @param pipelineContext defines the pipeline context to use
  55295. * @param uniformsNames defines the list of uniform names
  55296. * @returns an array of webGL uniform locations
  55297. */
  55298. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  55299. /**
  55300. * Gets the lsit of active attributes for a given webGL program
  55301. * @param pipelineContext defines the pipeline context to use
  55302. * @param attributesNames defines the list of attribute names to get
  55303. * @returns an array of indices indicating the offset of each attribute
  55304. */
  55305. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  55306. /**
  55307. * Binds an effect to the webGL context
  55308. * @param effect defines the effect to bind
  55309. */
  55310. bindSamplers(effect: Effect): void;
  55311. /**
  55312. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  55313. * @param effect defines the effect to activate
  55314. */
  55315. enableEffect(effect: Effect): void;
  55316. /**
  55317. * Set various states to the webGL context
  55318. * @param culling defines backface culling state
  55319. * @param zOffset defines the value to apply to zOffset (0 by default)
  55320. * @param force defines if states must be applied even if cache is up to date
  55321. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  55322. */
  55323. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  55324. /**
  55325. * Set the value of an uniform to an array of int32
  55326. * @param uniform defines the webGL uniform location where to store the value
  55327. * @param array defines the array of int32 to store
  55328. * @returns true if value was set
  55329. */
  55330. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55331. /**
  55332. * Set the value of an uniform to an array of int32 (stored as vec2)
  55333. * @param uniform defines the webGL uniform location where to store the value
  55334. * @param array defines the array of int32 to store
  55335. * @returns true if value was set
  55336. */
  55337. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55338. /**
  55339. * Set the value of an uniform to an array of int32 (stored as vec3)
  55340. * @param uniform defines the webGL uniform location where to store the value
  55341. * @param array defines the array of int32 to store
  55342. * @returns true if value was set
  55343. */
  55344. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55345. /**
  55346. * Set the value of an uniform to an array of int32 (stored as vec4)
  55347. * @param uniform defines the webGL uniform location where to store the value
  55348. * @param array defines the array of int32 to store
  55349. * @returns true if value was set
  55350. */
  55351. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55352. /**
  55353. * Set the value of an uniform to an array of float32
  55354. * @param uniform defines the webGL uniform location where to store the value
  55355. * @param array defines the array of float32 to store
  55356. * @returns true if value was set
  55357. */
  55358. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55359. /**
  55360. * Set the value of an uniform to an array of float32 (stored as vec2)
  55361. * @param uniform defines the webGL uniform location where to store the value
  55362. * @param array defines the array of float32 to store
  55363. * @returns true if value was set
  55364. */
  55365. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55366. /**
  55367. * Set the value of an uniform to an array of float32 (stored as vec3)
  55368. * @param uniform defines the webGL uniform location where to store the value
  55369. * @param array defines the array of float32 to store
  55370. * @returns true if value was set
  55371. */
  55372. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55373. /**
  55374. * Set the value of an uniform to an array of float32 (stored as vec4)
  55375. * @param uniform defines the webGL uniform location where to store the value
  55376. * @param array defines the array of float32 to store
  55377. * @returns true if value was set
  55378. */
  55379. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55380. /**
  55381. * Set the value of an uniform to an array of number
  55382. * @param uniform defines the webGL uniform location where to store the value
  55383. * @param array defines the array of number to store
  55384. * @returns true if value was set
  55385. */
  55386. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  55387. /**
  55388. * Set the value of an uniform to an array of number (stored as vec2)
  55389. * @param uniform defines the webGL uniform location where to store the value
  55390. * @param array defines the array of number to store
  55391. * @returns true if value was set
  55392. */
  55393. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  55394. /**
  55395. * Set the value of an uniform to an array of number (stored as vec3)
  55396. * @param uniform defines the webGL uniform location where to store the value
  55397. * @param array defines the array of number to store
  55398. * @returns true if value was set
  55399. */
  55400. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  55401. /**
  55402. * Set the value of an uniform to an array of number (stored as vec4)
  55403. * @param uniform defines the webGL uniform location where to store the value
  55404. * @param array defines the array of number to store
  55405. * @returns true if value was set
  55406. */
  55407. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  55408. /**
  55409. * Set the value of an uniform to an array of float32 (stored as matrices)
  55410. * @param uniform defines the webGL uniform location where to store the value
  55411. * @param matrices defines the array of float32 to store
  55412. * @returns true if value was set
  55413. */
  55414. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  55415. /**
  55416. * Set the value of an uniform to a matrix (3x3)
  55417. * @param uniform defines the webGL uniform location where to store the value
  55418. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  55419. * @returns true if value was set
  55420. */
  55421. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55422. /**
  55423. * Set the value of an uniform to a matrix (2x2)
  55424. * @param uniform defines the webGL uniform location where to store the value
  55425. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  55426. * @returns true if value was set
  55427. */
  55428. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55429. /**
  55430. * Set the value of an uniform to a number (float)
  55431. * @param uniform defines the webGL uniform location where to store the value
  55432. * @param value defines the float number to store
  55433. * @returns true if value was set
  55434. */
  55435. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  55436. /**
  55437. * Set the value of an uniform to a vec2
  55438. * @param uniform defines the webGL uniform location where to store the value
  55439. * @param x defines the 1st component of the value
  55440. * @param y defines the 2nd component of the value
  55441. * @returns true if value was set
  55442. */
  55443. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  55444. /**
  55445. * Set the value of an uniform to a vec3
  55446. * @param uniform defines the webGL uniform location where to store the value
  55447. * @param x defines the 1st component of the value
  55448. * @param y defines the 2nd component of the value
  55449. * @param z defines the 3rd component of the value
  55450. * @returns true if value was set
  55451. */
  55452. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  55453. /**
  55454. * Set the value of an uniform to a boolean
  55455. * @param uniform defines the webGL uniform location where to store the value
  55456. * @param bool defines the boolean to store
  55457. * @returns true if value was set
  55458. */
  55459. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  55460. /**
  55461. * Set the value of an uniform to a vec4
  55462. * @param uniform defines the webGL uniform location where to store the value
  55463. * @param x defines the 1st component of the value
  55464. * @param y defines the 2nd component of the value
  55465. * @param z defines the 3rd component of the value
  55466. * @param w defines the 4th component of the value
  55467. * @returns true if value was set
  55468. */
  55469. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  55470. /**
  55471. * Sets the current alpha mode
  55472. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  55473. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  55474. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55475. */
  55476. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  55477. /**
  55478. * Bind webGl buffers directly to the webGL context
  55479. * @param vertexBuffers defines the vertex buffer to bind
  55480. * @param indexBuffer defines the index buffer to bind
  55481. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  55482. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  55483. * @param effect defines the effect associated with the vertex buffer
  55484. */
  55485. bindBuffers(vertexBuffers: {
  55486. [key: string]: VertexBuffer;
  55487. }, indexBuffer: DataBuffer, effect: Effect): void;
  55488. /**
  55489. * Force the entire cache to be cleared
  55490. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  55491. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  55492. */
  55493. wipeCaches(bruteForce?: boolean): void;
  55494. /**
  55495. * Send a draw order
  55496. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  55497. * @param indexStart defines the starting index
  55498. * @param indexCount defines the number of index to draw
  55499. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55500. */
  55501. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  55502. /**
  55503. * Draw a list of indexed primitives
  55504. * @param fillMode defines the primitive to use
  55505. * @param indexStart defines the starting index
  55506. * @param indexCount defines the number of index to draw
  55507. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55508. */
  55509. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  55510. /**
  55511. * Draw a list of unindexed primitives
  55512. * @param fillMode defines the primitive to use
  55513. * @param verticesStart defines the index of first vertex to draw
  55514. * @param verticesCount defines the count of vertices to draw
  55515. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55516. */
  55517. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  55518. /** @hidden */
  55519. _createTexture(): WebGLTexture;
  55520. /** @hidden */
  55521. _releaseTexture(texture: InternalTexture): void;
  55522. /**
  55523. * Usually called from Texture.ts.
  55524. * Passed information to create a WebGLTexture
  55525. * @param urlArg defines a value which contains one of the following:
  55526. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  55527. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  55528. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  55529. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  55530. * @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)
  55531. * @param scene needed for loading to the correct scene
  55532. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  55533. * @param onLoad optional callback to be called upon successful completion
  55534. * @param onError optional callback to be called upon failure
  55535. * @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
  55536. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  55537. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  55538. * @param forcedExtension defines the extension to use to pick the right loader
  55539. * @param mimeType defines an optional mime type
  55540. * @returns a InternalTexture for assignment back into BABYLON.Texture
  55541. */
  55542. 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;
  55543. /**
  55544. * Creates a new render target texture
  55545. * @param size defines the size of the texture
  55546. * @param options defines the options used to create the texture
  55547. * @returns a new render target texture stored in an InternalTexture
  55548. */
  55549. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  55550. /**
  55551. * Update the sampling mode of a given texture
  55552. * @param samplingMode defines the required sampling mode
  55553. * @param texture defines the texture to update
  55554. */
  55555. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  55556. /**
  55557. * Binds the frame buffer to the specified texture.
  55558. * @param texture The texture to render to or null for the default canvas
  55559. * @param faceIndex The face of the texture to render to in case of cube texture
  55560. * @param requiredWidth The width of the target to render to
  55561. * @param requiredHeight The height of the target to render to
  55562. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  55563. * @param lodLevel defines le lod level to bind to the frame buffer
  55564. */
  55565. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  55566. /**
  55567. * Unbind the current render target texture from the webGL context
  55568. * @param texture defines the render target texture to unbind
  55569. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  55570. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  55571. */
  55572. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  55573. /**
  55574. * Creates a dynamic vertex buffer
  55575. * @param vertices the data for the dynamic vertex buffer
  55576. * @returns the new WebGL dynamic buffer
  55577. */
  55578. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  55579. /**
  55580. * Update the content of a dynamic texture
  55581. * @param texture defines the texture to update
  55582. * @param canvas defines the canvas containing the source
  55583. * @param invertY defines if data must be stored with Y axis inverted
  55584. * @param premulAlpha defines if alpha is stored as premultiplied
  55585. * @param format defines the format of the data
  55586. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  55587. */
  55588. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  55589. /**
  55590. * Gets a boolean indicating if all created effects are ready
  55591. * @returns true if all effects are ready
  55592. */
  55593. areAllEffectsReady(): boolean;
  55594. /**
  55595. * @hidden
  55596. * Get the current error code of the webGL context
  55597. * @returns the error code
  55598. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  55599. */
  55600. getError(): number;
  55601. /** @hidden */
  55602. _getUnpackAlignement(): number;
  55603. /** @hidden */
  55604. _unpackFlipY(value: boolean): void;
  55605. /**
  55606. * Update a dynamic index buffer
  55607. * @param indexBuffer defines the target index buffer
  55608. * @param indices defines the data to update
  55609. * @param offset defines the offset in the target index buffer where update should start
  55610. */
  55611. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  55612. /**
  55613. * Updates a dynamic vertex buffer.
  55614. * @param vertexBuffer the vertex buffer to update
  55615. * @param vertices the data used to update the vertex buffer
  55616. * @param byteOffset the byte offset of the data (optional)
  55617. * @param byteLength the byte length of the data (optional)
  55618. */
  55619. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  55620. /** @hidden */
  55621. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  55622. /** @hidden */
  55623. _bindTexture(channel: number, texture: InternalTexture): void;
  55624. protected _deleteBuffer(buffer: WebGLBuffer): void;
  55625. /**
  55626. * 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
  55627. */
  55628. releaseEffects(): void;
  55629. displayLoadingUI(): void;
  55630. hideLoadingUI(): void;
  55631. /** @hidden */
  55632. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55633. /** @hidden */
  55634. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55635. /** @hidden */
  55636. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55637. /** @hidden */
  55638. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  55639. }
  55640. }
  55641. declare module BABYLON {
  55642. /**
  55643. * @hidden
  55644. **/
  55645. export class _TimeToken {
  55646. _startTimeQuery: Nullable<WebGLQuery>;
  55647. _endTimeQuery: Nullable<WebGLQuery>;
  55648. _timeElapsedQuery: Nullable<WebGLQuery>;
  55649. _timeElapsedQueryEnded: boolean;
  55650. }
  55651. }
  55652. declare module BABYLON {
  55653. /** @hidden */
  55654. export class _OcclusionDataStorage {
  55655. /** @hidden */
  55656. occlusionInternalRetryCounter: number;
  55657. /** @hidden */
  55658. isOcclusionQueryInProgress: boolean;
  55659. /** @hidden */
  55660. isOccluded: boolean;
  55661. /** @hidden */
  55662. occlusionRetryCount: number;
  55663. /** @hidden */
  55664. occlusionType: number;
  55665. /** @hidden */
  55666. occlusionQueryAlgorithmType: number;
  55667. }
  55668. interface Engine {
  55669. /**
  55670. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  55671. * @return the new query
  55672. */
  55673. createQuery(): WebGLQuery;
  55674. /**
  55675. * Delete and release a webGL query
  55676. * @param query defines the query to delete
  55677. * @return the current engine
  55678. */
  55679. deleteQuery(query: WebGLQuery): Engine;
  55680. /**
  55681. * Check if a given query has resolved and got its value
  55682. * @param query defines the query to check
  55683. * @returns true if the query got its value
  55684. */
  55685. isQueryResultAvailable(query: WebGLQuery): boolean;
  55686. /**
  55687. * Gets the value of a given query
  55688. * @param query defines the query to check
  55689. * @returns the value of the query
  55690. */
  55691. getQueryResult(query: WebGLQuery): number;
  55692. /**
  55693. * Initiates an occlusion query
  55694. * @param algorithmType defines the algorithm to use
  55695. * @param query defines the query to use
  55696. * @returns the current engine
  55697. * @see https://doc.babylonjs.com/features/occlusionquery
  55698. */
  55699. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  55700. /**
  55701. * Ends an occlusion query
  55702. * @see https://doc.babylonjs.com/features/occlusionquery
  55703. * @param algorithmType defines the algorithm to use
  55704. * @returns the current engine
  55705. */
  55706. endOcclusionQuery(algorithmType: number): Engine;
  55707. /**
  55708. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  55709. * Please note that only one query can be issued at a time
  55710. * @returns a time token used to track the time span
  55711. */
  55712. startTimeQuery(): Nullable<_TimeToken>;
  55713. /**
  55714. * Ends a time query
  55715. * @param token defines the token used to measure the time span
  55716. * @returns the time spent (in ns)
  55717. */
  55718. endTimeQuery(token: _TimeToken): int;
  55719. /** @hidden */
  55720. _currentNonTimestampToken: Nullable<_TimeToken>;
  55721. /** @hidden */
  55722. _createTimeQuery(): WebGLQuery;
  55723. /** @hidden */
  55724. _deleteTimeQuery(query: WebGLQuery): void;
  55725. /** @hidden */
  55726. _getGlAlgorithmType(algorithmType: number): number;
  55727. /** @hidden */
  55728. _getTimeQueryResult(query: WebGLQuery): any;
  55729. /** @hidden */
  55730. _getTimeQueryAvailability(query: WebGLQuery): any;
  55731. }
  55732. interface AbstractMesh {
  55733. /**
  55734. * Backing filed
  55735. * @hidden
  55736. */
  55737. __occlusionDataStorage: _OcclusionDataStorage;
  55738. /**
  55739. * Access property
  55740. * @hidden
  55741. */
  55742. _occlusionDataStorage: _OcclusionDataStorage;
  55743. /**
  55744. * 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.
  55745. * The default value is -1 which means don't break the query and wait till the result
  55746. * @see https://doc.babylonjs.com/features/occlusionquery
  55747. */
  55748. occlusionRetryCount: number;
  55749. /**
  55750. * 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:
  55751. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  55752. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  55753. * * 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.
  55754. * @see https://doc.babylonjs.com/features/occlusionquery
  55755. */
  55756. occlusionType: number;
  55757. /**
  55758. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  55759. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  55760. * * 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.
  55761. * @see https://doc.babylonjs.com/features/occlusionquery
  55762. */
  55763. occlusionQueryAlgorithmType: number;
  55764. /**
  55765. * 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
  55766. * @see https://doc.babylonjs.com/features/occlusionquery
  55767. */
  55768. isOccluded: boolean;
  55769. /**
  55770. * Flag to check the progress status of the query
  55771. * @see https://doc.babylonjs.com/features/occlusionquery
  55772. */
  55773. isOcclusionQueryInProgress: boolean;
  55774. }
  55775. }
  55776. declare module BABYLON {
  55777. /** @hidden */
  55778. export var _forceTransformFeedbackToBundle: boolean;
  55779. interface Engine {
  55780. /**
  55781. * Creates a webGL transform feedback object
  55782. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  55783. * @returns the webGL transform feedback object
  55784. */
  55785. createTransformFeedback(): WebGLTransformFeedback;
  55786. /**
  55787. * Delete a webGL transform feedback object
  55788. * @param value defines the webGL transform feedback object to delete
  55789. */
  55790. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  55791. /**
  55792. * Bind a webGL transform feedback object to the webgl context
  55793. * @param value defines the webGL transform feedback object to bind
  55794. */
  55795. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  55796. /**
  55797. * Begins a transform feedback operation
  55798. * @param usePoints defines if points or triangles must be used
  55799. */
  55800. beginTransformFeedback(usePoints: boolean): void;
  55801. /**
  55802. * Ends a transform feedback operation
  55803. */
  55804. endTransformFeedback(): void;
  55805. /**
  55806. * Specify the varyings to use with transform feedback
  55807. * @param program defines the associated webGL program
  55808. * @param value defines the list of strings representing the varying names
  55809. */
  55810. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  55811. /**
  55812. * Bind a webGL buffer for a transform feedback operation
  55813. * @param value defines the webGL buffer to bind
  55814. */
  55815. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  55816. }
  55817. }
  55818. declare module BABYLON {
  55819. /**
  55820. * Class used to define an additional view for the engine
  55821. * @see https://doc.babylonjs.com/how_to/multi_canvases
  55822. */
  55823. export class EngineView {
  55824. /** Defines the canvas where to render the view */
  55825. target: HTMLCanvasElement;
  55826. /** Defines an optional camera used to render the view (will use active camera else) */
  55827. camera?: Camera;
  55828. }
  55829. interface Engine {
  55830. /**
  55831. * Gets or sets the HTML element to use for attaching events
  55832. */
  55833. inputElement: Nullable<HTMLElement>;
  55834. /**
  55835. * Gets the current engine view
  55836. * @see https://doc.babylonjs.com/how_to/multi_canvases
  55837. */
  55838. activeView: Nullable<EngineView>;
  55839. /** Gets or sets the list of views */
  55840. views: EngineView[];
  55841. /**
  55842. * Register a new child canvas
  55843. * @param canvas defines the canvas to register
  55844. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  55845. * @returns the associated view
  55846. */
  55847. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  55848. /**
  55849. * Remove a registered child canvas
  55850. * @param canvas defines the canvas to remove
  55851. * @returns the current engine
  55852. */
  55853. unRegisterView(canvas: HTMLCanvasElement): Engine;
  55854. }
  55855. }
  55856. declare module BABYLON {
  55857. interface Engine {
  55858. /** @hidden */
  55859. _excludedCompressedTextures: string[];
  55860. /** @hidden */
  55861. _textureFormatInUse: string;
  55862. /**
  55863. * Gets the list of texture formats supported
  55864. */
  55865. readonly texturesSupported: Array<string>;
  55866. /**
  55867. * Gets the texture format in use
  55868. */
  55869. readonly textureFormatInUse: Nullable<string>;
  55870. /**
  55871. * Set the compressed texture extensions or file names to skip.
  55872. *
  55873. * @param skippedFiles defines the list of those texture files you want to skip
  55874. * Example: [".dds", ".env", "myfile.png"]
  55875. */
  55876. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  55877. /**
  55878. * Set the compressed texture format to use, based on the formats you have, and the formats
  55879. * supported by the hardware / browser.
  55880. *
  55881. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  55882. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  55883. * to API arguments needed to compressed textures. This puts the burden on the container
  55884. * generator to house the arcane code for determining these for current & future formats.
  55885. *
  55886. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  55887. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  55888. *
  55889. * Note: The result of this call is not taken into account when a texture is base64.
  55890. *
  55891. * @param formatsAvailable defines the list of those format families you have created
  55892. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  55893. *
  55894. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  55895. * @returns The extension selected.
  55896. */
  55897. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  55898. }
  55899. }
  55900. declare module BABYLON {
  55901. /** @hidden */
  55902. export var rgbdEncodePixelShader: {
  55903. name: string;
  55904. shader: string;
  55905. };
  55906. }
  55907. declare module BABYLON {
  55908. /**
  55909. * Raw texture data and descriptor sufficient for WebGL texture upload
  55910. */
  55911. export interface EnvironmentTextureInfo {
  55912. /**
  55913. * Version of the environment map
  55914. */
  55915. version: number;
  55916. /**
  55917. * Width of image
  55918. */
  55919. width: number;
  55920. /**
  55921. * Irradiance information stored in the file.
  55922. */
  55923. irradiance: any;
  55924. /**
  55925. * Specular information stored in the file.
  55926. */
  55927. specular: any;
  55928. }
  55929. /**
  55930. * Defines One Image in the file. It requires only the position in the file
  55931. * as well as the length.
  55932. */
  55933. interface BufferImageData {
  55934. /**
  55935. * Length of the image data.
  55936. */
  55937. length: number;
  55938. /**
  55939. * Position of the data from the null terminator delimiting the end of the JSON.
  55940. */
  55941. position: number;
  55942. }
  55943. /**
  55944. * Defines the specular data enclosed in the file.
  55945. * This corresponds to the version 1 of the data.
  55946. */
  55947. export interface EnvironmentTextureSpecularInfoV1 {
  55948. /**
  55949. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  55950. */
  55951. specularDataPosition?: number;
  55952. /**
  55953. * This contains all the images data needed to reconstruct the cubemap.
  55954. */
  55955. mipmaps: Array<BufferImageData>;
  55956. /**
  55957. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  55958. */
  55959. lodGenerationScale: number;
  55960. }
  55961. /**
  55962. * Sets of helpers addressing the serialization and deserialization of environment texture
  55963. * stored in a BabylonJS env file.
  55964. * Those files are usually stored as .env files.
  55965. */
  55966. export class EnvironmentTextureTools {
  55967. /**
  55968. * Magic number identifying the env file.
  55969. */
  55970. private static _MagicBytes;
  55971. /**
  55972. * Gets the environment info from an env file.
  55973. * @param data The array buffer containing the .env bytes.
  55974. * @returns the environment file info (the json header) if successfully parsed.
  55975. */
  55976. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  55977. /**
  55978. * Creates an environment texture from a loaded cube texture.
  55979. * @param texture defines the cube texture to convert in env file
  55980. * @return a promise containing the environment data if succesfull.
  55981. */
  55982. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  55983. /**
  55984. * Creates a JSON representation of the spherical data.
  55985. * @param texture defines the texture containing the polynomials
  55986. * @return the JSON representation of the spherical info
  55987. */
  55988. private static _CreateEnvTextureIrradiance;
  55989. /**
  55990. * Creates the ArrayBufferViews used for initializing environment texture image data.
  55991. * @param data the image data
  55992. * @param info parameters that determine what views will be created for accessing the underlying buffer
  55993. * @return the views described by info providing access to the underlying buffer
  55994. */
  55995. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  55996. /**
  55997. * Uploads the texture info contained in the env file to the GPU.
  55998. * @param texture defines the internal texture to upload to
  55999. * @param data defines the data to load
  56000. * @param info defines the texture info retrieved through the GetEnvInfo method
  56001. * @returns a promise
  56002. */
  56003. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  56004. private static _OnImageReadyAsync;
  56005. /**
  56006. * Uploads the levels of image data to the GPU.
  56007. * @param texture defines the internal texture to upload to
  56008. * @param imageData defines the array buffer views of image data [mipmap][face]
  56009. * @returns a promise
  56010. */
  56011. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  56012. /**
  56013. * Uploads spherical polynomials information to the texture.
  56014. * @param texture defines the texture we are trying to upload the information to
  56015. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  56016. */
  56017. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  56018. /** @hidden */
  56019. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  56020. }
  56021. }
  56022. declare module BABYLON {
  56023. /**
  56024. * Class used to inline functions in shader code
  56025. */
  56026. export class ShaderCodeInliner {
  56027. private static readonly _RegexpFindFunctionNameAndType;
  56028. private _sourceCode;
  56029. private _functionDescr;
  56030. private _numMaxIterations;
  56031. /** Gets or sets the token used to mark the functions to inline */
  56032. inlineToken: string;
  56033. /** Gets or sets the debug mode */
  56034. debug: boolean;
  56035. /** Gets the code after the inlining process */
  56036. get code(): string;
  56037. /**
  56038. * Initializes the inliner
  56039. * @param sourceCode shader code source to inline
  56040. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  56041. */
  56042. constructor(sourceCode: string, numMaxIterations?: number);
  56043. /**
  56044. * Start the processing of the shader code
  56045. */
  56046. processCode(): void;
  56047. private _collectFunctions;
  56048. private _processInlining;
  56049. private _extractBetweenMarkers;
  56050. private _skipWhitespaces;
  56051. private _removeComments;
  56052. private _replaceFunctionCallsByCode;
  56053. private _findBackward;
  56054. private _escapeRegExp;
  56055. private _replaceNames;
  56056. }
  56057. }
  56058. declare module BABYLON {
  56059. /**
  56060. * Container for accessors for natively-stored mesh data buffers.
  56061. */
  56062. class NativeDataBuffer extends DataBuffer {
  56063. /**
  56064. * Accessor value used to identify/retrieve a natively-stored index buffer.
  56065. */
  56066. nativeIndexBuffer?: any;
  56067. /**
  56068. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  56069. */
  56070. nativeVertexBuffer?: any;
  56071. }
  56072. /** @hidden */
  56073. class NativeTexture extends InternalTexture {
  56074. getInternalTexture(): InternalTexture;
  56075. getViewCount(): number;
  56076. }
  56077. /** @hidden */
  56078. export class NativeEngine extends Engine {
  56079. private readonly _native;
  56080. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  56081. private readonly INVALID_HANDLE;
  56082. private _boundBuffersVertexArray;
  56083. private _currentDepthTest;
  56084. getHardwareScalingLevel(): number;
  56085. constructor();
  56086. dispose(): void;
  56087. /**
  56088. * Can be used to override the current requestAnimationFrame requester.
  56089. * @hidden
  56090. */
  56091. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  56092. /**
  56093. * Override default engine behavior.
  56094. * @param color
  56095. * @param backBuffer
  56096. * @param depth
  56097. * @param stencil
  56098. */
  56099. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  56100. /**
  56101. * Gets host document
  56102. * @returns the host document object
  56103. */
  56104. getHostDocument(): Nullable<Document>;
  56105. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  56106. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  56107. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  56108. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  56109. [key: string]: VertexBuffer;
  56110. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  56111. bindBuffers(vertexBuffers: {
  56112. [key: string]: VertexBuffer;
  56113. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  56114. recordVertexArrayObject(vertexBuffers: {
  56115. [key: string]: VertexBuffer;
  56116. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  56117. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  56118. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  56119. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  56120. /**
  56121. * Draw a list of indexed primitives
  56122. * @param fillMode defines the primitive to use
  56123. * @param indexStart defines the starting index
  56124. * @param indexCount defines the number of index to draw
  56125. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56126. */
  56127. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  56128. /**
  56129. * Draw a list of unindexed primitives
  56130. * @param fillMode defines the primitive to use
  56131. * @param verticesStart defines the index of first vertex to draw
  56132. * @param verticesCount defines the count of vertices to draw
  56133. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56134. */
  56135. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  56136. createPipelineContext(): IPipelineContext;
  56137. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  56138. /** @hidden */
  56139. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  56140. /** @hidden */
  56141. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  56142. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  56143. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  56144. protected _setProgram(program: WebGLProgram): void;
  56145. _releaseEffect(effect: Effect): void;
  56146. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  56147. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  56148. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  56149. bindSamplers(effect: Effect): void;
  56150. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  56151. getRenderWidth(useScreen?: boolean): number;
  56152. getRenderHeight(useScreen?: boolean): number;
  56153. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  56154. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  56155. /**
  56156. * Set the z offset to apply to current rendering
  56157. * @param value defines the offset to apply
  56158. */
  56159. setZOffset(value: number): void;
  56160. /**
  56161. * Gets the current value of the zOffset
  56162. * @returns the current zOffset state
  56163. */
  56164. getZOffset(): number;
  56165. /**
  56166. * Enable or disable depth buffering
  56167. * @param enable defines the state to set
  56168. */
  56169. setDepthBuffer(enable: boolean): void;
  56170. /**
  56171. * Gets a boolean indicating if depth writing is enabled
  56172. * @returns the current depth writing state
  56173. */
  56174. getDepthWrite(): boolean;
  56175. setDepthFunctionToGreater(): void;
  56176. setDepthFunctionToGreaterOrEqual(): void;
  56177. setDepthFunctionToLess(): void;
  56178. setDepthFunctionToLessOrEqual(): void;
  56179. /**
  56180. * Enable or disable depth writing
  56181. * @param enable defines the state to set
  56182. */
  56183. setDepthWrite(enable: boolean): void;
  56184. /**
  56185. * Enable or disable color writing
  56186. * @param enable defines the state to set
  56187. */
  56188. setColorWrite(enable: boolean): void;
  56189. /**
  56190. * Gets a boolean indicating if color writing is enabled
  56191. * @returns the current color writing state
  56192. */
  56193. getColorWrite(): boolean;
  56194. /**
  56195. * Sets alpha constants used by some alpha blending modes
  56196. * @param r defines the red component
  56197. * @param g defines the green component
  56198. * @param b defines the blue component
  56199. * @param a defines the alpha component
  56200. */
  56201. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  56202. /**
  56203. * Sets the current alpha mode
  56204. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  56205. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  56206. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  56207. */
  56208. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  56209. /**
  56210. * Gets the current alpha mode
  56211. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  56212. * @returns the current alpha mode
  56213. */
  56214. getAlphaMode(): number;
  56215. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  56216. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56217. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56218. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56219. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56220. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56221. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56222. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56223. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56224. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  56225. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  56226. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  56227. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  56228. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  56229. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  56230. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  56231. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  56232. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  56233. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  56234. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  56235. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  56236. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  56237. wipeCaches(bruteForce?: boolean): void;
  56238. _createTexture(): WebGLTexture;
  56239. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  56240. /**
  56241. * Update the content of a dynamic texture
  56242. * @param texture defines the texture to update
  56243. * @param canvas defines the canvas containing the source
  56244. * @param invertY defines if data must be stored with Y axis inverted
  56245. * @param premulAlpha defines if alpha is stored as premultiplied
  56246. * @param format defines the format of the data
  56247. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  56248. */
  56249. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  56250. /**
  56251. * Usually called from Texture.ts.
  56252. * Passed information to create a WebGLTexture
  56253. * @param url defines a value which contains one of the following:
  56254. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  56255. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  56256. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  56257. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  56258. * @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)
  56259. * @param scene needed for loading to the correct scene
  56260. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  56261. * @param onLoad optional callback to be called upon successful completion
  56262. * @param onError optional callback to be called upon failure
  56263. * @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
  56264. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  56265. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  56266. * @param forcedExtension defines the extension to use to pick the right loader
  56267. * @param mimeType defines an optional mime type
  56268. * @param loaderOptions options to be passed to the loader
  56269. * @returns a InternalTexture for assignment back into BABYLON.Texture
  56270. */
  56271. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string, loaderOptions?: any): InternalTexture;
  56272. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  56273. _releaseFramebufferObjects(texture: InternalTexture): void;
  56274. /**
  56275. * Creates a cube texture
  56276. * @param rootUrl defines the url where the files to load is located
  56277. * @param scene defines the current scene
  56278. * @param files defines the list of files to load (1 per face)
  56279. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  56280. * @param onLoad defines an optional callback raised when the texture is loaded
  56281. * @param onError defines an optional callback raised if there is an issue to load the texture
  56282. * @param format defines the format of the data
  56283. * @param forcedExtension defines the extension to use to pick the right loader
  56284. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  56285. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56286. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56287. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  56288. * @returns the cube texture as an InternalTexture
  56289. */
  56290. 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;
  56291. createRenderTargetTexture(size: number | {
  56292. width: number;
  56293. height: number;
  56294. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  56295. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  56296. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  56297. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  56298. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  56299. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  56300. /**
  56301. * Updates a dynamic vertex buffer.
  56302. * @param vertexBuffer the vertex buffer to update
  56303. * @param data the data used to update the vertex buffer
  56304. * @param byteOffset the byte offset of the data (optional)
  56305. * @param byteLength the byte length of the data (optional)
  56306. */
  56307. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  56308. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  56309. private _updateAnisotropicLevel;
  56310. private _getAddressMode;
  56311. /** @hidden */
  56312. _bindTexture(channel: number, texture: InternalTexture): void;
  56313. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  56314. releaseEffects(): void;
  56315. /** @hidden */
  56316. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56317. /** @hidden */
  56318. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56319. /** @hidden */
  56320. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56321. /** @hidden */
  56322. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  56323. private _getNativeSamplingMode;
  56324. private _getNativeTextureFormat;
  56325. private _getNativeAlphaMode;
  56326. private _getNativeAttribType;
  56327. }
  56328. }
  56329. declare module BABYLON {
  56330. /**
  56331. * Gather the list of clipboard event types as constants.
  56332. */
  56333. export class ClipboardEventTypes {
  56334. /**
  56335. * The clipboard event is fired when a copy command is active (pressed).
  56336. */
  56337. static readonly COPY: number;
  56338. /**
  56339. * The clipboard event is fired when a cut command is active (pressed).
  56340. */
  56341. static readonly CUT: number;
  56342. /**
  56343. * The clipboard event is fired when a paste command is active (pressed).
  56344. */
  56345. static readonly PASTE: number;
  56346. }
  56347. /**
  56348. * This class is used to store clipboard related info for the onClipboardObservable event.
  56349. */
  56350. export class ClipboardInfo {
  56351. /**
  56352. * Defines the type of event (BABYLON.ClipboardEventTypes)
  56353. */
  56354. type: number;
  56355. /**
  56356. * Defines the related dom event
  56357. */
  56358. event: ClipboardEvent;
  56359. /**
  56360. *Creates an instance of ClipboardInfo.
  56361. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  56362. * @param event Defines the related dom event
  56363. */
  56364. constructor(
  56365. /**
  56366. * Defines the type of event (BABYLON.ClipboardEventTypes)
  56367. */
  56368. type: number,
  56369. /**
  56370. * Defines the related dom event
  56371. */
  56372. event: ClipboardEvent);
  56373. /**
  56374. * Get the clipboard event's type from the keycode.
  56375. * @param keyCode Defines the keyCode for the current keyboard event.
  56376. * @return {number}
  56377. */
  56378. static GetTypeFromCharacter(keyCode: number): number;
  56379. }
  56380. }
  56381. declare module BABYLON {
  56382. /**
  56383. * Google Daydream controller
  56384. */
  56385. export class DaydreamController extends WebVRController {
  56386. /**
  56387. * Base Url for the controller model.
  56388. */
  56389. static MODEL_BASE_URL: string;
  56390. /**
  56391. * File name for the controller model.
  56392. */
  56393. static MODEL_FILENAME: string;
  56394. /**
  56395. * Gamepad Id prefix used to identify Daydream Controller.
  56396. */
  56397. static readonly GAMEPAD_ID_PREFIX: string;
  56398. /**
  56399. * Creates a new DaydreamController from a gamepad
  56400. * @param vrGamepad the gamepad that the controller should be created from
  56401. */
  56402. constructor(vrGamepad: any);
  56403. /**
  56404. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56405. * @param scene scene in which to add meshes
  56406. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56407. */
  56408. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56409. /**
  56410. * Called once for each button that changed state since the last frame
  56411. * @param buttonIdx Which button index changed
  56412. * @param state New state of the button
  56413. * @param changes Which properties on the state changed since last frame
  56414. */
  56415. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56416. }
  56417. }
  56418. declare module BABYLON {
  56419. /**
  56420. * Gear VR Controller
  56421. */
  56422. export class GearVRController extends WebVRController {
  56423. /**
  56424. * Base Url for the controller model.
  56425. */
  56426. static MODEL_BASE_URL: string;
  56427. /**
  56428. * File name for the controller model.
  56429. */
  56430. static MODEL_FILENAME: string;
  56431. /**
  56432. * Gamepad Id prefix used to identify this controller.
  56433. */
  56434. static readonly GAMEPAD_ID_PREFIX: string;
  56435. private readonly _buttonIndexToObservableNameMap;
  56436. /**
  56437. * Creates a new GearVRController from a gamepad
  56438. * @param vrGamepad the gamepad that the controller should be created from
  56439. */
  56440. constructor(vrGamepad: any);
  56441. /**
  56442. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56443. * @param scene scene in which to add meshes
  56444. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56445. */
  56446. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56447. /**
  56448. * Called once for each button that changed state since the last frame
  56449. * @param buttonIdx Which button index changed
  56450. * @param state New state of the button
  56451. * @param changes Which properties on the state changed since last frame
  56452. */
  56453. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56454. }
  56455. }
  56456. declare module BABYLON {
  56457. /**
  56458. * Generic Controller
  56459. */
  56460. export class GenericController extends WebVRController {
  56461. /**
  56462. * Base Url for the controller model.
  56463. */
  56464. static readonly MODEL_BASE_URL: string;
  56465. /**
  56466. * File name for the controller model.
  56467. */
  56468. static readonly MODEL_FILENAME: string;
  56469. /**
  56470. * Creates a new GenericController from a gamepad
  56471. * @param vrGamepad the gamepad that the controller should be created from
  56472. */
  56473. constructor(vrGamepad: any);
  56474. /**
  56475. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56476. * @param scene scene in which to add meshes
  56477. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56478. */
  56479. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56480. /**
  56481. * Called once for each button that changed state since the last frame
  56482. * @param buttonIdx Which button index changed
  56483. * @param state New state of the button
  56484. * @param changes Which properties on the state changed since last frame
  56485. */
  56486. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56487. }
  56488. }
  56489. declare module BABYLON {
  56490. /**
  56491. * Oculus Touch Controller
  56492. */
  56493. export class OculusTouchController extends WebVRController {
  56494. /**
  56495. * Base Url for the controller model.
  56496. */
  56497. static MODEL_BASE_URL: string;
  56498. /**
  56499. * File name for the left controller model.
  56500. */
  56501. static MODEL_LEFT_FILENAME: string;
  56502. /**
  56503. * File name for the right controller model.
  56504. */
  56505. static MODEL_RIGHT_FILENAME: string;
  56506. /**
  56507. * Base Url for the Quest controller model.
  56508. */
  56509. static QUEST_MODEL_BASE_URL: string;
  56510. /**
  56511. * @hidden
  56512. * If the controllers are running on a device that needs the updated Quest controller models
  56513. */
  56514. static _IsQuest: boolean;
  56515. /**
  56516. * Fired when the secondary trigger on this controller is modified
  56517. */
  56518. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  56519. /**
  56520. * Fired when the thumb rest on this controller is modified
  56521. */
  56522. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  56523. /**
  56524. * Creates a new OculusTouchController from a gamepad
  56525. * @param vrGamepad the gamepad that the controller should be created from
  56526. */
  56527. constructor(vrGamepad: any);
  56528. /**
  56529. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56530. * @param scene scene in which to add meshes
  56531. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56532. */
  56533. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56534. /**
  56535. * Fired when the A button on this controller is modified
  56536. */
  56537. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56538. /**
  56539. * Fired when the B button on this controller is modified
  56540. */
  56541. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56542. /**
  56543. * Fired when the X button on this controller is modified
  56544. */
  56545. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56546. /**
  56547. * Fired when the Y button on this controller is modified
  56548. */
  56549. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56550. /**
  56551. * Called once for each button that changed state since the last frame
  56552. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  56553. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  56554. * 2) secondary trigger (same)
  56555. * 3) A (right) X (left), touch, pressed = value
  56556. * 4) B / Y
  56557. * 5) thumb rest
  56558. * @param buttonIdx Which button index changed
  56559. * @param state New state of the button
  56560. * @param changes Which properties on the state changed since last frame
  56561. */
  56562. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56563. }
  56564. }
  56565. declare module BABYLON {
  56566. /**
  56567. * Vive Controller
  56568. */
  56569. export class ViveController extends WebVRController {
  56570. /**
  56571. * Base Url for the controller model.
  56572. */
  56573. static MODEL_BASE_URL: string;
  56574. /**
  56575. * File name for the controller model.
  56576. */
  56577. static MODEL_FILENAME: string;
  56578. /**
  56579. * Creates a new ViveController from a gamepad
  56580. * @param vrGamepad the gamepad that the controller should be created from
  56581. */
  56582. constructor(vrGamepad: any);
  56583. /**
  56584. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56585. * @param scene scene in which to add meshes
  56586. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56587. */
  56588. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56589. /**
  56590. * Fired when the left button on this controller is modified
  56591. */
  56592. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56593. /**
  56594. * Fired when the right button on this controller is modified
  56595. */
  56596. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56597. /**
  56598. * Fired when the menu button on this controller is modified
  56599. */
  56600. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56601. /**
  56602. * Called once for each button that changed state since the last frame
  56603. * Vive mapping:
  56604. * 0: touchpad
  56605. * 1: trigger
  56606. * 2: left AND right buttons
  56607. * 3: menu button
  56608. * @param buttonIdx Which button index changed
  56609. * @param state New state of the button
  56610. * @param changes Which properties on the state changed since last frame
  56611. */
  56612. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56613. }
  56614. }
  56615. declare module BABYLON {
  56616. /**
  56617. * Defines the WindowsMotionController object that the state of the windows motion controller
  56618. */
  56619. export class WindowsMotionController extends WebVRController {
  56620. /**
  56621. * The base url used to load the left and right controller models
  56622. */
  56623. static MODEL_BASE_URL: string;
  56624. /**
  56625. * The name of the left controller model file
  56626. */
  56627. static MODEL_LEFT_FILENAME: string;
  56628. /**
  56629. * The name of the right controller model file
  56630. */
  56631. static MODEL_RIGHT_FILENAME: string;
  56632. /**
  56633. * The controller name prefix for this controller type
  56634. */
  56635. static readonly GAMEPAD_ID_PREFIX: string;
  56636. /**
  56637. * The controller id pattern for this controller type
  56638. */
  56639. private static readonly GAMEPAD_ID_PATTERN;
  56640. private _loadedMeshInfo;
  56641. protected readonly _mapping: {
  56642. buttons: string[];
  56643. buttonMeshNames: {
  56644. trigger: string;
  56645. menu: string;
  56646. grip: string;
  56647. thumbstick: string;
  56648. trackpad: string;
  56649. };
  56650. buttonObservableNames: {
  56651. trigger: string;
  56652. menu: string;
  56653. grip: string;
  56654. thumbstick: string;
  56655. trackpad: string;
  56656. };
  56657. axisMeshNames: string[];
  56658. pointingPoseMeshName: string;
  56659. };
  56660. /**
  56661. * Fired when the trackpad on this controller is clicked
  56662. */
  56663. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  56664. /**
  56665. * Fired when the trackpad on this controller is modified
  56666. */
  56667. onTrackpadValuesChangedObservable: Observable<StickValues>;
  56668. /**
  56669. * The current x and y values of this controller's trackpad
  56670. */
  56671. trackpad: StickValues;
  56672. /**
  56673. * Creates a new WindowsMotionController from a gamepad
  56674. * @param vrGamepad the gamepad that the controller should be created from
  56675. */
  56676. constructor(vrGamepad: any);
  56677. /**
  56678. * Fired when the trigger on this controller is modified
  56679. */
  56680. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56681. /**
  56682. * Fired when the menu button on this controller is modified
  56683. */
  56684. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56685. /**
  56686. * Fired when the grip button on this controller is modified
  56687. */
  56688. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56689. /**
  56690. * Fired when the thumbstick button on this controller is modified
  56691. */
  56692. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56693. /**
  56694. * Fired when the touchpad button on this controller is modified
  56695. */
  56696. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56697. /**
  56698. * Fired when the touchpad values on this controller are modified
  56699. */
  56700. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  56701. protected _updateTrackpad(): void;
  56702. /**
  56703. * Called once per frame by the engine.
  56704. */
  56705. update(): void;
  56706. /**
  56707. * Called once for each button that changed state since the last frame
  56708. * @param buttonIdx Which button index changed
  56709. * @param state New state of the button
  56710. * @param changes Which properties on the state changed since last frame
  56711. */
  56712. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56713. /**
  56714. * Moves the buttons on the controller mesh based on their current state
  56715. * @param buttonName the name of the button to move
  56716. * @param buttonValue the value of the button which determines the buttons new position
  56717. */
  56718. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  56719. /**
  56720. * Moves the axis on the controller mesh based on its current state
  56721. * @param axis the index of the axis
  56722. * @param axisValue the value of the axis which determines the meshes new position
  56723. * @hidden
  56724. */
  56725. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  56726. /**
  56727. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56728. * @param scene scene in which to add meshes
  56729. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56730. */
  56731. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  56732. /**
  56733. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  56734. * can be transformed by button presses and axes values, based on this._mapping.
  56735. *
  56736. * @param scene scene in which the meshes exist
  56737. * @param meshes list of meshes that make up the controller model to process
  56738. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  56739. */
  56740. private processModel;
  56741. private createMeshInfo;
  56742. /**
  56743. * Gets the ray of the controller in the direction the controller is pointing
  56744. * @param length the length the resulting ray should be
  56745. * @returns a ray in the direction the controller is pointing
  56746. */
  56747. getForwardRay(length?: number): Ray;
  56748. /**
  56749. * Disposes of the controller
  56750. */
  56751. dispose(): void;
  56752. }
  56753. /**
  56754. * This class represents a new windows motion controller in XR.
  56755. */
  56756. export class XRWindowsMotionController extends WindowsMotionController {
  56757. /**
  56758. * Changing the original WIndowsMotionController mapping to fir the new mapping
  56759. */
  56760. protected readonly _mapping: {
  56761. buttons: string[];
  56762. buttonMeshNames: {
  56763. trigger: string;
  56764. menu: string;
  56765. grip: string;
  56766. thumbstick: string;
  56767. trackpad: string;
  56768. };
  56769. buttonObservableNames: {
  56770. trigger: string;
  56771. menu: string;
  56772. grip: string;
  56773. thumbstick: string;
  56774. trackpad: string;
  56775. };
  56776. axisMeshNames: string[];
  56777. pointingPoseMeshName: string;
  56778. };
  56779. /**
  56780. * Construct a new XR-Based windows motion controller
  56781. *
  56782. * @param gamepadInfo the gamepad object from the browser
  56783. */
  56784. constructor(gamepadInfo: any);
  56785. /**
  56786. * holds the thumbstick values (X,Y)
  56787. */
  56788. thumbstickValues: StickValues;
  56789. /**
  56790. * Fired when the thumbstick on this controller is clicked
  56791. */
  56792. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  56793. /**
  56794. * Fired when the thumbstick on this controller is modified
  56795. */
  56796. onThumbstickValuesChangedObservable: Observable<StickValues>;
  56797. /**
  56798. * Fired when the touchpad button on this controller is modified
  56799. */
  56800. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  56801. /**
  56802. * Fired when the touchpad values on this controller are modified
  56803. */
  56804. onTrackpadValuesChangedObservable: Observable<StickValues>;
  56805. /**
  56806. * Fired when the thumbstick button on this controller is modified
  56807. * here to prevent breaking changes
  56808. */
  56809. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56810. /**
  56811. * updating the thumbstick(!) and not the trackpad.
  56812. * This is named this way due to the difference between WebVR and XR and to avoid
  56813. * changing the parent class.
  56814. */
  56815. protected _updateTrackpad(): void;
  56816. /**
  56817. * Disposes the class with joy
  56818. */
  56819. dispose(): void;
  56820. }
  56821. }
  56822. declare module BABYLON {
  56823. /**
  56824. * Class containing static functions to help procedurally build meshes
  56825. */
  56826. export class PolyhedronBuilder {
  56827. /**
  56828. * Creates a polyhedron mesh
  56829. * * 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
  56830. * * The parameter `size` (positive float, default 1) sets the polygon size
  56831. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56832. * * 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`
  56833. * * 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
  56834. * * 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)`)
  56835. * * 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
  56836. * * 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
  56837. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56838. * * 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
  56839. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56840. * @param name defines the name of the mesh
  56841. * @param options defines the options used to create the mesh
  56842. * @param scene defines the hosting scene
  56843. * @returns the polyhedron mesh
  56844. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56845. */
  56846. static CreatePolyhedron(name: string, options: {
  56847. type?: number;
  56848. size?: number;
  56849. sizeX?: number;
  56850. sizeY?: number;
  56851. sizeZ?: number;
  56852. custom?: any;
  56853. faceUV?: Vector4[];
  56854. faceColors?: Color4[];
  56855. flat?: boolean;
  56856. updatable?: boolean;
  56857. sideOrientation?: number;
  56858. frontUVs?: Vector4;
  56859. backUVs?: Vector4;
  56860. }, scene?: Nullable<Scene>): Mesh;
  56861. }
  56862. }
  56863. declare module BABYLON {
  56864. /**
  56865. * Gizmo that enables scaling a mesh along 3 axis
  56866. */
  56867. export class ScaleGizmo extends Gizmo {
  56868. /**
  56869. * Internal gizmo used for interactions on the x axis
  56870. */
  56871. xGizmo: AxisScaleGizmo;
  56872. /**
  56873. * Internal gizmo used for interactions on the y axis
  56874. */
  56875. yGizmo: AxisScaleGizmo;
  56876. /**
  56877. * Internal gizmo used for interactions on the z axis
  56878. */
  56879. zGizmo: AxisScaleGizmo;
  56880. /**
  56881. * Internal gizmo used to scale all axis equally
  56882. */
  56883. uniformScaleGizmo: AxisScaleGizmo;
  56884. private _meshAttached;
  56885. private _nodeAttached;
  56886. private _snapDistance;
  56887. private _uniformScalingMesh;
  56888. private _octahedron;
  56889. private _sensitivity;
  56890. /** Fires an event when any of it's sub gizmos are dragged */
  56891. onDragStartObservable: Observable<unknown>;
  56892. /** Fires an event when any of it's sub gizmos are released from dragging */
  56893. onDragEndObservable: Observable<unknown>;
  56894. get attachedMesh(): Nullable<AbstractMesh>;
  56895. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56896. get attachedNode(): Nullable<Node>;
  56897. set attachedNode(node: Nullable<Node>);
  56898. /**
  56899. * True when the mouse pointer is hovering a gizmo mesh
  56900. */
  56901. get isHovered(): boolean;
  56902. /**
  56903. * Creates a ScaleGizmo
  56904. * @param gizmoLayer The utility layer the gizmo will be added to
  56905. * @param thickness display gizmo axis thickness
  56906. */
  56907. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  56908. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56909. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56910. /**
  56911. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56912. */
  56913. set snapDistance(value: number);
  56914. get snapDistance(): number;
  56915. /**
  56916. * Ratio for the scale of the gizmo (Default: 1)
  56917. */
  56918. set scaleRatio(value: number);
  56919. get scaleRatio(): number;
  56920. /**
  56921. * Sensitivity factor for dragging (Default: 1)
  56922. */
  56923. set sensitivity(value: number);
  56924. get sensitivity(): number;
  56925. /**
  56926. * Disposes of the gizmo
  56927. */
  56928. dispose(): void;
  56929. }
  56930. }
  56931. declare module BABYLON {
  56932. /**
  56933. * Single axis scale gizmo
  56934. */
  56935. export class AxisScaleGizmo extends Gizmo {
  56936. /**
  56937. * Drag behavior responsible for the gizmos dragging interactions
  56938. */
  56939. dragBehavior: PointerDragBehavior;
  56940. private _pointerObserver;
  56941. /**
  56942. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56943. */
  56944. snapDistance: number;
  56945. /**
  56946. * Event that fires each time the gizmo snaps to a new location.
  56947. * * snapDistance is the the change in distance
  56948. */
  56949. onSnapObservable: Observable<{
  56950. snapDistance: number;
  56951. }>;
  56952. /**
  56953. * If the scaling operation should be done on all axis (default: false)
  56954. */
  56955. uniformScaling: boolean;
  56956. /**
  56957. * Custom sensitivity value for the drag strength
  56958. */
  56959. sensitivity: number;
  56960. private _isEnabled;
  56961. private _parent;
  56962. private _arrow;
  56963. private _coloredMaterial;
  56964. private _hoverMaterial;
  56965. /**
  56966. * Creates an AxisScaleGizmo
  56967. * @param gizmoLayer The utility layer the gizmo will be added to
  56968. * @param dragAxis The axis which the gizmo will be able to scale on
  56969. * @param color The color of the gizmo
  56970. * @param thickness display gizmo axis thickness
  56971. */
  56972. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  56973. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56974. /**
  56975. * If the gizmo is enabled
  56976. */
  56977. set isEnabled(value: boolean);
  56978. get isEnabled(): boolean;
  56979. /**
  56980. * Disposes of the gizmo
  56981. */
  56982. dispose(): void;
  56983. /**
  56984. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  56985. * @param mesh The mesh to replace the default mesh of the gizmo
  56986. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  56987. */
  56988. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  56989. }
  56990. }
  56991. declare module BABYLON {
  56992. /**
  56993. * Bounding box gizmo
  56994. */
  56995. export class BoundingBoxGizmo extends Gizmo {
  56996. private _lineBoundingBox;
  56997. private _rotateSpheresParent;
  56998. private _scaleBoxesParent;
  56999. private _boundingDimensions;
  57000. private _renderObserver;
  57001. private _pointerObserver;
  57002. private _scaleDragSpeed;
  57003. private _tmpQuaternion;
  57004. private _tmpVector;
  57005. private _tmpRotationMatrix;
  57006. /**
  57007. * 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)
  57008. */
  57009. ignoreChildren: boolean;
  57010. /**
  57011. * 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)
  57012. */
  57013. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  57014. /**
  57015. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  57016. */
  57017. rotationSphereSize: number;
  57018. /**
  57019. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  57020. */
  57021. scaleBoxSize: number;
  57022. /**
  57023. * 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)
  57024. */
  57025. fixedDragMeshScreenSize: boolean;
  57026. /**
  57027. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  57028. */
  57029. fixedDragMeshScreenSizeDistanceFactor: number;
  57030. /**
  57031. * Fired when a rotation sphere or scale box is dragged
  57032. */
  57033. onDragStartObservable: Observable<{}>;
  57034. /**
  57035. * Fired when a scale box is dragged
  57036. */
  57037. onScaleBoxDragObservable: Observable<{}>;
  57038. /**
  57039. * Fired when a scale box drag is ended
  57040. */
  57041. onScaleBoxDragEndObservable: Observable<{}>;
  57042. /**
  57043. * Fired when a rotation sphere is dragged
  57044. */
  57045. onRotationSphereDragObservable: Observable<{}>;
  57046. /**
  57047. * Fired when a rotation sphere drag is ended
  57048. */
  57049. onRotationSphereDragEndObservable: Observable<{}>;
  57050. /**
  57051. * 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)
  57052. */
  57053. scalePivot: Nullable<Vector3>;
  57054. /**
  57055. * Mesh used as a pivot to rotate the attached node
  57056. */
  57057. private _anchorMesh;
  57058. private _existingMeshScale;
  57059. private _dragMesh;
  57060. private pointerDragBehavior;
  57061. private coloredMaterial;
  57062. private hoverColoredMaterial;
  57063. /**
  57064. * Sets the color of the bounding box gizmo
  57065. * @param color the color to set
  57066. */
  57067. setColor(color: Color3): void;
  57068. /**
  57069. * Creates an BoundingBoxGizmo
  57070. * @param gizmoLayer The utility layer the gizmo will be added to
  57071. * @param color The color of the gizmo
  57072. */
  57073. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  57074. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  57075. private _selectNode;
  57076. /**
  57077. * Updates the bounding box information for the Gizmo
  57078. */
  57079. updateBoundingBox(): void;
  57080. private _updateRotationSpheres;
  57081. private _updateScaleBoxes;
  57082. /**
  57083. * Enables rotation on the specified axis and disables rotation on the others
  57084. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  57085. */
  57086. setEnabledRotationAxis(axis: string): void;
  57087. /**
  57088. * Enables/disables scaling
  57089. * @param enable if scaling should be enabled
  57090. * @param homogeneousScaling defines if scaling should only be homogeneous
  57091. */
  57092. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  57093. private _updateDummy;
  57094. /**
  57095. * Enables a pointer drag behavior on the bounding box of the gizmo
  57096. */
  57097. enableDragBehavior(): void;
  57098. /**
  57099. * Disposes of the gizmo
  57100. */
  57101. dispose(): void;
  57102. /**
  57103. * 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)
  57104. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  57105. * @returns the bounding box mesh with the passed in mesh as a child
  57106. */
  57107. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  57108. /**
  57109. * CustomMeshes are not supported by this gizmo
  57110. * @param mesh The mesh to replace the default mesh of the gizmo
  57111. */
  57112. setCustomMesh(mesh: Mesh): void;
  57113. }
  57114. }
  57115. declare module BABYLON {
  57116. /**
  57117. * Single plane rotation gizmo
  57118. */
  57119. export class PlaneRotationGizmo extends Gizmo {
  57120. /**
  57121. * Drag behavior responsible for the gizmos dragging interactions
  57122. */
  57123. dragBehavior: PointerDragBehavior;
  57124. private _pointerObserver;
  57125. /**
  57126. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  57127. */
  57128. snapDistance: number;
  57129. /**
  57130. * Event that fires each time the gizmo snaps to a new location.
  57131. * * snapDistance is the the change in distance
  57132. */
  57133. onSnapObservable: Observable<{
  57134. snapDistance: number;
  57135. }>;
  57136. private _isEnabled;
  57137. private _parent;
  57138. /**
  57139. * Creates a PlaneRotationGizmo
  57140. * @param gizmoLayer The utility layer the gizmo will be added to
  57141. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  57142. * @param color The color of the gizmo
  57143. * @param tessellation Amount of tessellation to be used when creating rotation circles
  57144. * @param useEulerRotation Use and update Euler angle instead of quaternion
  57145. * @param thickness display gizmo axis thickness
  57146. */
  57147. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  57148. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57149. /**
  57150. * If the gizmo is enabled
  57151. */
  57152. set isEnabled(value: boolean);
  57153. get isEnabled(): boolean;
  57154. /**
  57155. * Disposes of the gizmo
  57156. */
  57157. dispose(): void;
  57158. }
  57159. }
  57160. declare module BABYLON {
  57161. /**
  57162. * Gizmo that enables rotating a mesh along 3 axis
  57163. */
  57164. export class RotationGizmo extends Gizmo {
  57165. /**
  57166. * Internal gizmo used for interactions on the x axis
  57167. */
  57168. xGizmo: PlaneRotationGizmo;
  57169. /**
  57170. * Internal gizmo used for interactions on the y axis
  57171. */
  57172. yGizmo: PlaneRotationGizmo;
  57173. /**
  57174. * Internal gizmo used for interactions on the z axis
  57175. */
  57176. zGizmo: PlaneRotationGizmo;
  57177. /** Fires an event when any of it's sub gizmos are dragged */
  57178. onDragStartObservable: Observable<unknown>;
  57179. /** Fires an event when any of it's sub gizmos are released from dragging */
  57180. onDragEndObservable: Observable<unknown>;
  57181. private _meshAttached;
  57182. private _nodeAttached;
  57183. get attachedMesh(): Nullable<AbstractMesh>;
  57184. set attachedMesh(mesh: Nullable<AbstractMesh>);
  57185. get attachedNode(): Nullable<Node>;
  57186. set attachedNode(node: Nullable<Node>);
  57187. protected _checkBillboardTransform(): void;
  57188. /**
  57189. * True when the mouse pointer is hovering a gizmo mesh
  57190. */
  57191. get isHovered(): boolean;
  57192. /**
  57193. * Creates a RotationGizmo
  57194. * @param gizmoLayer The utility layer the gizmo will be added to
  57195. * @param tessellation Amount of tessellation to be used when creating rotation circles
  57196. * @param useEulerRotation Use and update Euler angle instead of quaternion
  57197. * @param thickness display gizmo axis thickness
  57198. */
  57199. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  57200. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57201. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57202. /**
  57203. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57204. */
  57205. set snapDistance(value: number);
  57206. get snapDistance(): number;
  57207. /**
  57208. * Ratio for the scale of the gizmo (Default: 1)
  57209. */
  57210. set scaleRatio(value: number);
  57211. get scaleRatio(): number;
  57212. /**
  57213. * Disposes of the gizmo
  57214. */
  57215. dispose(): void;
  57216. /**
  57217. * CustomMeshes are not supported by this gizmo
  57218. * @param mesh The mesh to replace the default mesh of the gizmo
  57219. */
  57220. setCustomMesh(mesh: Mesh): void;
  57221. }
  57222. }
  57223. declare module BABYLON {
  57224. /**
  57225. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  57226. */
  57227. export class GizmoManager implements IDisposable {
  57228. private scene;
  57229. /**
  57230. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  57231. */
  57232. gizmos: {
  57233. positionGizmo: Nullable<PositionGizmo>;
  57234. rotationGizmo: Nullable<RotationGizmo>;
  57235. scaleGizmo: Nullable<ScaleGizmo>;
  57236. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  57237. };
  57238. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  57239. clearGizmoOnEmptyPointerEvent: boolean;
  57240. /** Fires an event when the manager is attached to a mesh */
  57241. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  57242. /** Fires an event when the manager is attached to a node */
  57243. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  57244. private _gizmosEnabled;
  57245. private _pointerObserver;
  57246. private _attachedMesh;
  57247. private _attachedNode;
  57248. private _boundingBoxColor;
  57249. private _defaultUtilityLayer;
  57250. private _defaultKeepDepthUtilityLayer;
  57251. private _thickness;
  57252. /**
  57253. * When bounding box gizmo is enabled, this can be used to track drag/end events
  57254. */
  57255. boundingBoxDragBehavior: SixDofDragBehavior;
  57256. /**
  57257. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  57258. */
  57259. attachableMeshes: Nullable<Array<AbstractMesh>>;
  57260. /**
  57261. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  57262. */
  57263. attachableNodes: Nullable<Array<Node>>;
  57264. /**
  57265. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  57266. */
  57267. usePointerToAttachGizmos: boolean;
  57268. /**
  57269. * Utility layer that the bounding box gizmo belongs to
  57270. */
  57271. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  57272. /**
  57273. * Utility layer that all gizmos besides bounding box belong to
  57274. */
  57275. get utilityLayer(): UtilityLayerRenderer;
  57276. /**
  57277. * True when the mouse pointer is hovering a gizmo mesh
  57278. */
  57279. get isHovered(): boolean;
  57280. /**
  57281. * Instatiates a gizmo manager
  57282. * @param scene the scene to overlay the gizmos on top of
  57283. * @param thickness display gizmo axis thickness
  57284. */
  57285. constructor(scene: Scene, thickness?: number);
  57286. /**
  57287. * Attaches a set of gizmos to the specified mesh
  57288. * @param mesh The mesh the gizmo's should be attached to
  57289. */
  57290. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  57291. /**
  57292. * Attaches a set of gizmos to the specified node
  57293. * @param node The node the gizmo's should be attached to
  57294. */
  57295. attachToNode(node: Nullable<Node>): void;
  57296. /**
  57297. * If the position gizmo is enabled
  57298. */
  57299. set positionGizmoEnabled(value: boolean);
  57300. get positionGizmoEnabled(): boolean;
  57301. /**
  57302. * If the rotation gizmo is enabled
  57303. */
  57304. set rotationGizmoEnabled(value: boolean);
  57305. get rotationGizmoEnabled(): boolean;
  57306. /**
  57307. * If the scale gizmo is enabled
  57308. */
  57309. set scaleGizmoEnabled(value: boolean);
  57310. get scaleGizmoEnabled(): boolean;
  57311. /**
  57312. * If the boundingBox gizmo is enabled
  57313. */
  57314. set boundingBoxGizmoEnabled(value: boolean);
  57315. get boundingBoxGizmoEnabled(): boolean;
  57316. /**
  57317. * Disposes of the gizmo manager
  57318. */
  57319. dispose(): void;
  57320. }
  57321. }
  57322. declare module BABYLON {
  57323. /**
  57324. * A directional light is defined by a direction (what a surprise!).
  57325. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  57326. * 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.
  57327. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57328. */
  57329. export class DirectionalLight extends ShadowLight {
  57330. private _shadowFrustumSize;
  57331. /**
  57332. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  57333. */
  57334. get shadowFrustumSize(): number;
  57335. /**
  57336. * Specifies a fix frustum size for the shadow generation.
  57337. */
  57338. set shadowFrustumSize(value: number);
  57339. private _shadowOrthoScale;
  57340. /**
  57341. * Gets the shadow projection scale against the optimal computed one.
  57342. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  57343. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  57344. */
  57345. get shadowOrthoScale(): number;
  57346. /**
  57347. * Sets the shadow projection scale against the optimal computed one.
  57348. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  57349. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  57350. */
  57351. set shadowOrthoScale(value: number);
  57352. /**
  57353. * Automatically compute the projection matrix to best fit (including all the casters)
  57354. * on each frame.
  57355. */
  57356. autoUpdateExtends: boolean;
  57357. /**
  57358. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  57359. * on each frame. autoUpdateExtends must be set to true for this to work
  57360. */
  57361. autoCalcShadowZBounds: boolean;
  57362. private _orthoLeft;
  57363. private _orthoRight;
  57364. private _orthoTop;
  57365. private _orthoBottom;
  57366. /**
  57367. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  57368. * The directional light is emitted from everywhere in the given direction.
  57369. * It can cast shadows.
  57370. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57371. * @param name The friendly name of the light
  57372. * @param direction The direction of the light
  57373. * @param scene The scene the light belongs to
  57374. */
  57375. constructor(name: string, direction: Vector3, scene: Scene);
  57376. /**
  57377. * Returns the string "DirectionalLight".
  57378. * @return The class name
  57379. */
  57380. getClassName(): string;
  57381. /**
  57382. * Returns the integer 1.
  57383. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57384. */
  57385. getTypeID(): number;
  57386. /**
  57387. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  57388. * Returns the DirectionalLight Shadow projection matrix.
  57389. */
  57390. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57391. /**
  57392. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  57393. * Returns the DirectionalLight Shadow projection matrix.
  57394. */
  57395. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  57396. /**
  57397. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  57398. * Returns the DirectionalLight Shadow projection matrix.
  57399. */
  57400. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57401. protected _buildUniformLayout(): void;
  57402. /**
  57403. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  57404. * @param effect The effect to update
  57405. * @param lightIndex The index of the light in the effect to update
  57406. * @returns The directional light
  57407. */
  57408. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  57409. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  57410. /**
  57411. * Gets the minZ used for shadow according to both the scene and the light.
  57412. *
  57413. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  57414. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  57415. * @param activeCamera The camera we are returning the min for
  57416. * @returns the depth min z
  57417. */
  57418. getDepthMinZ(activeCamera: Camera): number;
  57419. /**
  57420. * Gets the maxZ used for shadow according to both the scene and the light.
  57421. *
  57422. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  57423. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  57424. * @param activeCamera The camera we are returning the max for
  57425. * @returns the depth max z
  57426. */
  57427. getDepthMaxZ(activeCamera: Camera): number;
  57428. /**
  57429. * Prepares the list of defines specific to the light type.
  57430. * @param defines the list of defines
  57431. * @param lightIndex defines the index of the light for the effect
  57432. */
  57433. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57434. }
  57435. }
  57436. declare module BABYLON {
  57437. /**
  57438. * Class containing static functions to help procedurally build meshes
  57439. */
  57440. export class HemisphereBuilder {
  57441. /**
  57442. * Creates a hemisphere mesh
  57443. * @param name defines the name of the mesh
  57444. * @param options defines the options used to create the mesh
  57445. * @param scene defines the hosting scene
  57446. * @returns the hemisphere mesh
  57447. */
  57448. static CreateHemisphere(name: string, options: {
  57449. segments?: number;
  57450. diameter?: number;
  57451. sideOrientation?: number;
  57452. }, scene: any): Mesh;
  57453. }
  57454. }
  57455. declare module BABYLON {
  57456. /**
  57457. * A spot light is defined by a position, a direction, an angle, and an exponent.
  57458. * These values define a cone of light starting from the position, emitting toward the direction.
  57459. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  57460. * and the exponent defines the speed of the decay of the light with distance (reach).
  57461. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57462. */
  57463. export class SpotLight extends ShadowLight {
  57464. private _angle;
  57465. private _innerAngle;
  57466. private _cosHalfAngle;
  57467. private _lightAngleScale;
  57468. private _lightAngleOffset;
  57469. /**
  57470. * Gets the cone angle of the spot light in Radians.
  57471. */
  57472. get angle(): number;
  57473. /**
  57474. * Sets the cone angle of the spot light in Radians.
  57475. */
  57476. set angle(value: number);
  57477. /**
  57478. * Only used in gltf falloff mode, this defines the angle where
  57479. * the directional falloff will start before cutting at angle which could be seen
  57480. * as outer angle.
  57481. */
  57482. get innerAngle(): number;
  57483. /**
  57484. * Only used in gltf falloff mode, this defines the angle where
  57485. * the directional falloff will start before cutting at angle which could be seen
  57486. * as outer angle.
  57487. */
  57488. set innerAngle(value: number);
  57489. private _shadowAngleScale;
  57490. /**
  57491. * Allows scaling the angle of the light for shadow generation only.
  57492. */
  57493. get shadowAngleScale(): number;
  57494. /**
  57495. * Allows scaling the angle of the light for shadow generation only.
  57496. */
  57497. set shadowAngleScale(value: number);
  57498. /**
  57499. * The light decay speed with the distance from the emission spot.
  57500. */
  57501. exponent: number;
  57502. private _projectionTextureMatrix;
  57503. /**
  57504. * Allows reading the projecton texture
  57505. */
  57506. get projectionTextureMatrix(): Matrix;
  57507. protected _projectionTextureLightNear: number;
  57508. /**
  57509. * Gets the near clip of the Spotlight for texture projection.
  57510. */
  57511. get projectionTextureLightNear(): number;
  57512. /**
  57513. * Sets the near clip of the Spotlight for texture projection.
  57514. */
  57515. set projectionTextureLightNear(value: number);
  57516. protected _projectionTextureLightFar: number;
  57517. /**
  57518. * Gets the far clip of the Spotlight for texture projection.
  57519. */
  57520. get projectionTextureLightFar(): number;
  57521. /**
  57522. * Sets the far clip of the Spotlight for texture projection.
  57523. */
  57524. set projectionTextureLightFar(value: number);
  57525. protected _projectionTextureUpDirection: Vector3;
  57526. /**
  57527. * Gets the Up vector of the Spotlight for texture projection.
  57528. */
  57529. get projectionTextureUpDirection(): Vector3;
  57530. /**
  57531. * Sets the Up vector of the Spotlight for texture projection.
  57532. */
  57533. set projectionTextureUpDirection(value: Vector3);
  57534. private _projectionTexture;
  57535. /**
  57536. * Gets the projection texture of the light.
  57537. */
  57538. get projectionTexture(): Nullable<BaseTexture>;
  57539. /**
  57540. * Sets the projection texture of the light.
  57541. */
  57542. set projectionTexture(value: Nullable<BaseTexture>);
  57543. private _projectionTextureViewLightDirty;
  57544. private _projectionTextureProjectionLightDirty;
  57545. private _projectionTextureDirty;
  57546. private _projectionTextureViewTargetVector;
  57547. private _projectionTextureViewLightMatrix;
  57548. private _projectionTextureProjectionLightMatrix;
  57549. private _projectionTextureScalingMatrix;
  57550. /**
  57551. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  57552. * It can cast shadows.
  57553. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57554. * @param name The light friendly name
  57555. * @param position The position of the spot light in the scene
  57556. * @param direction The direction of the light in the scene
  57557. * @param angle The cone angle of the light in Radians
  57558. * @param exponent The light decay speed with the distance from the emission spot
  57559. * @param scene The scene the lights belongs to
  57560. */
  57561. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  57562. /**
  57563. * Returns the string "SpotLight".
  57564. * @returns the class name
  57565. */
  57566. getClassName(): string;
  57567. /**
  57568. * Returns the integer 2.
  57569. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57570. */
  57571. getTypeID(): number;
  57572. /**
  57573. * Overrides the direction setter to recompute the projection texture view light Matrix.
  57574. */
  57575. protected _setDirection(value: Vector3): void;
  57576. /**
  57577. * Overrides the position setter to recompute the projection texture view light Matrix.
  57578. */
  57579. protected _setPosition(value: Vector3): void;
  57580. /**
  57581. * 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.
  57582. * Returns the SpotLight.
  57583. */
  57584. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57585. protected _computeProjectionTextureViewLightMatrix(): void;
  57586. protected _computeProjectionTextureProjectionLightMatrix(): void;
  57587. /**
  57588. * Main function for light texture projection matrix computing.
  57589. */
  57590. protected _computeProjectionTextureMatrix(): void;
  57591. protected _buildUniformLayout(): void;
  57592. private _computeAngleValues;
  57593. /**
  57594. * Sets the passed Effect "effect" with the Light textures.
  57595. * @param effect The effect to update
  57596. * @param lightIndex The index of the light in the effect to update
  57597. * @returns The light
  57598. */
  57599. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  57600. /**
  57601. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  57602. * @param effect The effect to update
  57603. * @param lightIndex The index of the light in the effect to update
  57604. * @returns The spot light
  57605. */
  57606. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  57607. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  57608. /**
  57609. * Disposes the light and the associated resources.
  57610. */
  57611. dispose(): void;
  57612. /**
  57613. * Prepares the list of defines specific to the light type.
  57614. * @param defines the list of defines
  57615. * @param lightIndex defines the index of the light for the effect
  57616. */
  57617. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57618. }
  57619. }
  57620. declare module BABYLON {
  57621. /**
  57622. * Gizmo that enables viewing a light
  57623. */
  57624. export class LightGizmo extends Gizmo {
  57625. private _lightMesh;
  57626. private _material;
  57627. private _cachedPosition;
  57628. private _cachedForward;
  57629. private _attachedMeshParent;
  57630. private _pointerObserver;
  57631. /**
  57632. * Event that fires each time the gizmo is clicked
  57633. */
  57634. onClickedObservable: Observable<Light>;
  57635. /**
  57636. * Creates a LightGizmo
  57637. * @param gizmoLayer The utility layer the gizmo will be added to
  57638. */
  57639. constructor(gizmoLayer?: UtilityLayerRenderer);
  57640. private _light;
  57641. /**
  57642. * The light that the gizmo is attached to
  57643. */
  57644. set light(light: Nullable<Light>);
  57645. get light(): Nullable<Light>;
  57646. /**
  57647. * Gets the material used to render the light gizmo
  57648. */
  57649. get material(): StandardMaterial;
  57650. /**
  57651. * @hidden
  57652. * Updates the gizmo to match the attached mesh's position/rotation
  57653. */
  57654. protected _update(): void;
  57655. private static _Scale;
  57656. /**
  57657. * Creates the lines for a light mesh
  57658. */
  57659. private static _CreateLightLines;
  57660. /**
  57661. * Disposes of the light gizmo
  57662. */
  57663. dispose(): void;
  57664. private static _CreateHemisphericLightMesh;
  57665. private static _CreatePointLightMesh;
  57666. private static _CreateSpotLightMesh;
  57667. private static _CreateDirectionalLightMesh;
  57668. }
  57669. }
  57670. declare module BABYLON {
  57671. /**
  57672. * Gizmo that enables viewing a camera
  57673. */
  57674. export class CameraGizmo extends Gizmo {
  57675. private _cameraMesh;
  57676. private _cameraLinesMesh;
  57677. private _material;
  57678. private _pointerObserver;
  57679. /**
  57680. * Event that fires each time the gizmo is clicked
  57681. */
  57682. onClickedObservable: Observable<Camera>;
  57683. /**
  57684. * Creates a CameraGizmo
  57685. * @param gizmoLayer The utility layer the gizmo will be added to
  57686. */
  57687. constructor(gizmoLayer?: UtilityLayerRenderer);
  57688. private _camera;
  57689. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  57690. get displayFrustum(): boolean;
  57691. set displayFrustum(value: boolean);
  57692. /**
  57693. * The camera that the gizmo is attached to
  57694. */
  57695. set camera(camera: Nullable<Camera>);
  57696. get camera(): Nullable<Camera>;
  57697. /**
  57698. * Gets the material used to render the camera gizmo
  57699. */
  57700. get material(): StandardMaterial;
  57701. /**
  57702. * @hidden
  57703. * Updates the gizmo to match the attached mesh's position/rotation
  57704. */
  57705. protected _update(): void;
  57706. private static _Scale;
  57707. private _invProjection;
  57708. /**
  57709. * Disposes of the camera gizmo
  57710. */
  57711. dispose(): void;
  57712. private static _CreateCameraMesh;
  57713. private static _CreateCameraFrustum;
  57714. }
  57715. }
  57716. declare module BABYLON {
  57717. /** @hidden */
  57718. export var backgroundFragmentDeclaration: {
  57719. name: string;
  57720. shader: string;
  57721. };
  57722. }
  57723. declare module BABYLON {
  57724. /** @hidden */
  57725. export var backgroundUboDeclaration: {
  57726. name: string;
  57727. shader: string;
  57728. };
  57729. }
  57730. declare module BABYLON {
  57731. /** @hidden */
  57732. export var backgroundPixelShader: {
  57733. name: string;
  57734. shader: string;
  57735. };
  57736. }
  57737. declare module BABYLON {
  57738. /** @hidden */
  57739. export var backgroundVertexDeclaration: {
  57740. name: string;
  57741. shader: string;
  57742. };
  57743. }
  57744. declare module BABYLON {
  57745. /** @hidden */
  57746. export var backgroundVertexShader: {
  57747. name: string;
  57748. shader: string;
  57749. };
  57750. }
  57751. declare module BABYLON {
  57752. /**
  57753. * Background material used to create an efficient environement around your scene.
  57754. */
  57755. export class BackgroundMaterial extends PushMaterial {
  57756. /**
  57757. * Standard reflectance value at parallel view angle.
  57758. */
  57759. static StandardReflectance0: number;
  57760. /**
  57761. * Standard reflectance value at grazing angle.
  57762. */
  57763. static StandardReflectance90: number;
  57764. protected _primaryColor: Color3;
  57765. /**
  57766. * Key light Color (multiply against the environement texture)
  57767. */
  57768. primaryColor: Color3;
  57769. protected __perceptualColor: Nullable<Color3>;
  57770. /**
  57771. * Experimental Internal Use Only.
  57772. *
  57773. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  57774. * This acts as a helper to set the primary color to a more "human friendly" value.
  57775. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  57776. * output color as close as possible from the chosen value.
  57777. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  57778. * part of lighting setup.)
  57779. */
  57780. get _perceptualColor(): Nullable<Color3>;
  57781. set _perceptualColor(value: Nullable<Color3>);
  57782. protected _primaryColorShadowLevel: float;
  57783. /**
  57784. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  57785. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  57786. */
  57787. get primaryColorShadowLevel(): float;
  57788. set primaryColorShadowLevel(value: float);
  57789. protected _primaryColorHighlightLevel: float;
  57790. /**
  57791. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  57792. * The primary color is used at the level chosen to define what the white area would look.
  57793. */
  57794. get primaryColorHighlightLevel(): float;
  57795. set primaryColorHighlightLevel(value: float);
  57796. protected _reflectionTexture: Nullable<BaseTexture>;
  57797. /**
  57798. * Reflection Texture used in the material.
  57799. * Should be author in a specific way for the best result (refer to the documentation).
  57800. */
  57801. reflectionTexture: Nullable<BaseTexture>;
  57802. protected _reflectionBlur: float;
  57803. /**
  57804. * Reflection Texture level of blur.
  57805. *
  57806. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  57807. * texture twice.
  57808. */
  57809. reflectionBlur: float;
  57810. protected _diffuseTexture: Nullable<BaseTexture>;
  57811. /**
  57812. * Diffuse Texture used in the material.
  57813. * Should be author in a specific way for the best result (refer to the documentation).
  57814. */
  57815. diffuseTexture: Nullable<BaseTexture>;
  57816. protected _shadowLights: Nullable<IShadowLight[]>;
  57817. /**
  57818. * Specify the list of lights casting shadow on the material.
  57819. * All scene shadow lights will be included if null.
  57820. */
  57821. shadowLights: Nullable<IShadowLight[]>;
  57822. protected _shadowLevel: float;
  57823. /**
  57824. * Helps adjusting the shadow to a softer level if required.
  57825. * 0 means black shadows and 1 means no shadows.
  57826. */
  57827. shadowLevel: float;
  57828. protected _sceneCenter: Vector3;
  57829. /**
  57830. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  57831. * It is usually zero but might be interesting to modify according to your setup.
  57832. */
  57833. sceneCenter: Vector3;
  57834. protected _opacityFresnel: boolean;
  57835. /**
  57836. * This helps specifying that the material is falling off to the sky box at grazing angle.
  57837. * This helps ensuring a nice transition when the camera goes under the ground.
  57838. */
  57839. opacityFresnel: boolean;
  57840. protected _reflectionFresnel: boolean;
  57841. /**
  57842. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  57843. * This helps adding a mirror texture on the ground.
  57844. */
  57845. reflectionFresnel: boolean;
  57846. protected _reflectionFalloffDistance: number;
  57847. /**
  57848. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  57849. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  57850. */
  57851. reflectionFalloffDistance: number;
  57852. protected _reflectionAmount: number;
  57853. /**
  57854. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  57855. */
  57856. reflectionAmount: number;
  57857. protected _reflectionReflectance0: number;
  57858. /**
  57859. * This specifies the weight of the reflection at grazing angle.
  57860. */
  57861. reflectionReflectance0: number;
  57862. protected _reflectionReflectance90: number;
  57863. /**
  57864. * This specifies the weight of the reflection at a perpendicular point of view.
  57865. */
  57866. reflectionReflectance90: number;
  57867. /**
  57868. * Sets the reflection reflectance fresnel values according to the default standard
  57869. * empirically know to work well :-)
  57870. */
  57871. set reflectionStandardFresnelWeight(value: number);
  57872. protected _useRGBColor: boolean;
  57873. /**
  57874. * Helps to directly use the maps channels instead of their level.
  57875. */
  57876. useRGBColor: boolean;
  57877. protected _enableNoise: boolean;
  57878. /**
  57879. * This helps reducing the banding effect that could occur on the background.
  57880. */
  57881. enableNoise: boolean;
  57882. /**
  57883. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57884. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  57885. * Recommended to be keep at 1.0 except for special cases.
  57886. */
  57887. get fovMultiplier(): number;
  57888. set fovMultiplier(value: number);
  57889. private _fovMultiplier;
  57890. /**
  57891. * Enable the FOV adjustment feature controlled by fovMultiplier.
  57892. */
  57893. useEquirectangularFOV: boolean;
  57894. private _maxSimultaneousLights;
  57895. /**
  57896. * Number of Simultaneous lights allowed on the material.
  57897. */
  57898. maxSimultaneousLights: int;
  57899. private _shadowOnly;
  57900. /**
  57901. * Make the material only render shadows
  57902. */
  57903. shadowOnly: boolean;
  57904. /**
  57905. * Default configuration related to image processing available in the Background Material.
  57906. */
  57907. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57908. /**
  57909. * Keep track of the image processing observer to allow dispose and replace.
  57910. */
  57911. private _imageProcessingObserver;
  57912. /**
  57913. * Attaches a new image processing configuration to the PBR Material.
  57914. * @param configuration (if null the scene configuration will be use)
  57915. */
  57916. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57917. /**
  57918. * Gets the image processing configuration used either in this material.
  57919. */
  57920. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  57921. /**
  57922. * Sets the Default image processing configuration used either in the this material.
  57923. *
  57924. * If sets to null, the scene one is in use.
  57925. */
  57926. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  57927. /**
  57928. * Gets wether the color curves effect is enabled.
  57929. */
  57930. get cameraColorCurvesEnabled(): boolean;
  57931. /**
  57932. * Sets wether the color curves effect is enabled.
  57933. */
  57934. set cameraColorCurvesEnabled(value: boolean);
  57935. /**
  57936. * Gets wether the color grading effect is enabled.
  57937. */
  57938. get cameraColorGradingEnabled(): boolean;
  57939. /**
  57940. * Gets wether the color grading effect is enabled.
  57941. */
  57942. set cameraColorGradingEnabled(value: boolean);
  57943. /**
  57944. * Gets wether tonemapping is enabled or not.
  57945. */
  57946. get cameraToneMappingEnabled(): boolean;
  57947. /**
  57948. * Sets wether tonemapping is enabled or not
  57949. */
  57950. set cameraToneMappingEnabled(value: boolean);
  57951. /**
  57952. * The camera exposure used on this material.
  57953. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57954. * This corresponds to a photographic exposure.
  57955. */
  57956. get cameraExposure(): float;
  57957. /**
  57958. * The camera exposure used on this material.
  57959. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57960. * This corresponds to a photographic exposure.
  57961. */
  57962. set cameraExposure(value: float);
  57963. /**
  57964. * Gets The camera contrast used on this material.
  57965. */
  57966. get cameraContrast(): float;
  57967. /**
  57968. * Sets The camera contrast used on this material.
  57969. */
  57970. set cameraContrast(value: float);
  57971. /**
  57972. * Gets the Color Grading 2D Lookup Texture.
  57973. */
  57974. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  57975. /**
  57976. * Sets the Color Grading 2D Lookup Texture.
  57977. */
  57978. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  57979. /**
  57980. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57981. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57982. * 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;
  57983. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57984. */
  57985. get cameraColorCurves(): Nullable<ColorCurves>;
  57986. /**
  57987. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57988. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57989. * 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;
  57990. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57991. */
  57992. set cameraColorCurves(value: Nullable<ColorCurves>);
  57993. /**
  57994. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  57995. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  57996. */
  57997. switchToBGR: boolean;
  57998. private _renderTargets;
  57999. private _reflectionControls;
  58000. private _white;
  58001. private _primaryShadowColor;
  58002. private _primaryHighlightColor;
  58003. /**
  58004. * Instantiates a Background Material in the given scene
  58005. * @param name The friendly name of the material
  58006. * @param scene The scene to add the material to
  58007. */
  58008. constructor(name: string, scene: Scene);
  58009. /**
  58010. * Gets a boolean indicating that current material needs to register RTT
  58011. */
  58012. get hasRenderTargetTextures(): boolean;
  58013. /**
  58014. * The entire material has been created in order to prevent overdraw.
  58015. * @returns false
  58016. */
  58017. needAlphaTesting(): boolean;
  58018. /**
  58019. * The entire material has been created in order to prevent overdraw.
  58020. * @returns true if blending is enable
  58021. */
  58022. needAlphaBlending(): boolean;
  58023. /**
  58024. * Checks wether the material is ready to be rendered for a given mesh.
  58025. * @param mesh The mesh to render
  58026. * @param subMesh The submesh to check against
  58027. * @param useInstances Specify wether or not the material is used with instances
  58028. * @returns true if all the dependencies are ready (Textures, Effects...)
  58029. */
  58030. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  58031. /**
  58032. * Compute the primary color according to the chosen perceptual color.
  58033. */
  58034. private _computePrimaryColorFromPerceptualColor;
  58035. /**
  58036. * Compute the highlights and shadow colors according to their chosen levels.
  58037. */
  58038. private _computePrimaryColors;
  58039. /**
  58040. * Build the uniform buffer used in the material.
  58041. */
  58042. buildUniformLayout(): void;
  58043. /**
  58044. * Unbind the material.
  58045. */
  58046. unbind(): void;
  58047. /**
  58048. * Bind only the world matrix to the material.
  58049. * @param world The world matrix to bind.
  58050. */
  58051. bindOnlyWorldMatrix(world: Matrix): void;
  58052. /**
  58053. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  58054. * @param world The world matrix to bind.
  58055. * @param subMesh The submesh to bind for.
  58056. */
  58057. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  58058. /**
  58059. * Checks to see if a texture is used in the material.
  58060. * @param texture - Base texture to use.
  58061. * @returns - Boolean specifying if a texture is used in the material.
  58062. */
  58063. hasTexture(texture: BaseTexture): boolean;
  58064. /**
  58065. * Dispose the material.
  58066. * @param forceDisposeEffect Force disposal of the associated effect.
  58067. * @param forceDisposeTextures Force disposal of the associated textures.
  58068. */
  58069. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  58070. /**
  58071. * Clones the material.
  58072. * @param name The cloned name.
  58073. * @returns The cloned material.
  58074. */
  58075. clone(name: string): BackgroundMaterial;
  58076. /**
  58077. * Serializes the current material to its JSON representation.
  58078. * @returns The JSON representation.
  58079. */
  58080. serialize(): any;
  58081. /**
  58082. * Gets the class name of the material
  58083. * @returns "BackgroundMaterial"
  58084. */
  58085. getClassName(): string;
  58086. /**
  58087. * Parse a JSON input to create back a background material.
  58088. * @param source The JSON data to parse
  58089. * @param scene The scene to create the parsed material in
  58090. * @param rootUrl The root url of the assets the material depends upon
  58091. * @returns the instantiated BackgroundMaterial.
  58092. */
  58093. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  58094. }
  58095. }
  58096. declare module BABYLON {
  58097. /**
  58098. * Represents the different options available during the creation of
  58099. * a Environment helper.
  58100. *
  58101. * This can control the default ground, skybox and image processing setup of your scene.
  58102. */
  58103. export interface IEnvironmentHelperOptions {
  58104. /**
  58105. * Specifies whether or not to create a ground.
  58106. * True by default.
  58107. */
  58108. createGround: boolean;
  58109. /**
  58110. * Specifies the ground size.
  58111. * 15 by default.
  58112. */
  58113. groundSize: number;
  58114. /**
  58115. * The texture used on the ground for the main color.
  58116. * Comes from the BabylonJS CDN by default.
  58117. *
  58118. * Remarks: Can be either a texture or a url.
  58119. */
  58120. groundTexture: string | BaseTexture;
  58121. /**
  58122. * The color mixed in the ground texture by default.
  58123. * BabylonJS clearColor by default.
  58124. */
  58125. groundColor: Color3;
  58126. /**
  58127. * Specifies the ground opacity.
  58128. * 1 by default.
  58129. */
  58130. groundOpacity: number;
  58131. /**
  58132. * Enables the ground to receive shadows.
  58133. * True by default.
  58134. */
  58135. enableGroundShadow: boolean;
  58136. /**
  58137. * Helps preventing the shadow to be fully black on the ground.
  58138. * 0.5 by default.
  58139. */
  58140. groundShadowLevel: number;
  58141. /**
  58142. * Creates a mirror texture attach to the ground.
  58143. * false by default.
  58144. */
  58145. enableGroundMirror: boolean;
  58146. /**
  58147. * Specifies the ground mirror size ratio.
  58148. * 0.3 by default as the default kernel is 64.
  58149. */
  58150. groundMirrorSizeRatio: number;
  58151. /**
  58152. * Specifies the ground mirror blur kernel size.
  58153. * 64 by default.
  58154. */
  58155. groundMirrorBlurKernel: number;
  58156. /**
  58157. * Specifies the ground mirror visibility amount.
  58158. * 1 by default
  58159. */
  58160. groundMirrorAmount: number;
  58161. /**
  58162. * Specifies the ground mirror reflectance weight.
  58163. * This uses the standard weight of the background material to setup the fresnel effect
  58164. * of the mirror.
  58165. * 1 by default.
  58166. */
  58167. groundMirrorFresnelWeight: number;
  58168. /**
  58169. * Specifies the ground mirror Falloff distance.
  58170. * This can helps reducing the size of the reflection.
  58171. * 0 by Default.
  58172. */
  58173. groundMirrorFallOffDistance: number;
  58174. /**
  58175. * Specifies the ground mirror texture type.
  58176. * Unsigned Int by Default.
  58177. */
  58178. groundMirrorTextureType: number;
  58179. /**
  58180. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  58181. * the shown objects.
  58182. */
  58183. groundYBias: number;
  58184. /**
  58185. * Specifies whether or not to create a skybox.
  58186. * True by default.
  58187. */
  58188. createSkybox: boolean;
  58189. /**
  58190. * Specifies the skybox size.
  58191. * 20 by default.
  58192. */
  58193. skyboxSize: number;
  58194. /**
  58195. * The texture used on the skybox for the main color.
  58196. * Comes from the BabylonJS CDN by default.
  58197. *
  58198. * Remarks: Can be either a texture or a url.
  58199. */
  58200. skyboxTexture: string | BaseTexture;
  58201. /**
  58202. * The color mixed in the skybox texture by default.
  58203. * BabylonJS clearColor by default.
  58204. */
  58205. skyboxColor: Color3;
  58206. /**
  58207. * The background rotation around the Y axis of the scene.
  58208. * This helps aligning the key lights of your scene with the background.
  58209. * 0 by default.
  58210. */
  58211. backgroundYRotation: number;
  58212. /**
  58213. * Compute automatically the size of the elements to best fit with the scene.
  58214. */
  58215. sizeAuto: boolean;
  58216. /**
  58217. * Default position of the rootMesh if autoSize is not true.
  58218. */
  58219. rootPosition: Vector3;
  58220. /**
  58221. * Sets up the image processing in the scene.
  58222. * true by default.
  58223. */
  58224. setupImageProcessing: boolean;
  58225. /**
  58226. * The texture used as your environment texture in the scene.
  58227. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  58228. *
  58229. * Remarks: Can be either a texture or a url.
  58230. */
  58231. environmentTexture: string | BaseTexture;
  58232. /**
  58233. * The value of the exposure to apply to the scene.
  58234. * 0.6 by default if setupImageProcessing is true.
  58235. */
  58236. cameraExposure: number;
  58237. /**
  58238. * The value of the contrast to apply to the scene.
  58239. * 1.6 by default if setupImageProcessing is true.
  58240. */
  58241. cameraContrast: number;
  58242. /**
  58243. * Specifies whether or not tonemapping should be enabled in the scene.
  58244. * true by default if setupImageProcessing is true.
  58245. */
  58246. toneMappingEnabled: boolean;
  58247. }
  58248. /**
  58249. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  58250. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  58251. * It also helps with the default setup of your imageProcessing configuration.
  58252. */
  58253. export class EnvironmentHelper {
  58254. /**
  58255. * Default ground texture URL.
  58256. */
  58257. private static _groundTextureCDNUrl;
  58258. /**
  58259. * Default skybox texture URL.
  58260. */
  58261. private static _skyboxTextureCDNUrl;
  58262. /**
  58263. * Default environment texture URL.
  58264. */
  58265. private static _environmentTextureCDNUrl;
  58266. /**
  58267. * Creates the default options for the helper.
  58268. */
  58269. private static _getDefaultOptions;
  58270. private _rootMesh;
  58271. /**
  58272. * Gets the root mesh created by the helper.
  58273. */
  58274. get rootMesh(): Mesh;
  58275. private _skybox;
  58276. /**
  58277. * Gets the skybox created by the helper.
  58278. */
  58279. get skybox(): Nullable<Mesh>;
  58280. private _skyboxTexture;
  58281. /**
  58282. * Gets the skybox texture created by the helper.
  58283. */
  58284. get skyboxTexture(): Nullable<BaseTexture>;
  58285. private _skyboxMaterial;
  58286. /**
  58287. * Gets the skybox material created by the helper.
  58288. */
  58289. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  58290. private _ground;
  58291. /**
  58292. * Gets the ground mesh created by the helper.
  58293. */
  58294. get ground(): Nullable<Mesh>;
  58295. private _groundTexture;
  58296. /**
  58297. * Gets the ground texture created by the helper.
  58298. */
  58299. get groundTexture(): Nullable<BaseTexture>;
  58300. private _groundMirror;
  58301. /**
  58302. * Gets the ground mirror created by the helper.
  58303. */
  58304. get groundMirror(): Nullable<MirrorTexture>;
  58305. /**
  58306. * Gets the ground mirror render list to helps pushing the meshes
  58307. * you wish in the ground reflection.
  58308. */
  58309. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  58310. private _groundMaterial;
  58311. /**
  58312. * Gets the ground material created by the helper.
  58313. */
  58314. get groundMaterial(): Nullable<BackgroundMaterial>;
  58315. /**
  58316. * Stores the creation options.
  58317. */
  58318. private readonly _scene;
  58319. private _options;
  58320. /**
  58321. * This observable will be notified with any error during the creation of the environment,
  58322. * mainly texture creation errors.
  58323. */
  58324. onErrorObservable: Observable<{
  58325. message?: string;
  58326. exception?: any;
  58327. }>;
  58328. /**
  58329. * constructor
  58330. * @param options Defines the options we want to customize the helper
  58331. * @param scene The scene to add the material to
  58332. */
  58333. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  58334. /**
  58335. * Updates the background according to the new options
  58336. * @param options
  58337. */
  58338. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  58339. /**
  58340. * Sets the primary color of all the available elements.
  58341. * @param color the main color to affect to the ground and the background
  58342. */
  58343. setMainColor(color: Color3): void;
  58344. /**
  58345. * Setup the image processing according to the specified options.
  58346. */
  58347. private _setupImageProcessing;
  58348. /**
  58349. * Setup the environment texture according to the specified options.
  58350. */
  58351. private _setupEnvironmentTexture;
  58352. /**
  58353. * Setup the background according to the specified options.
  58354. */
  58355. private _setupBackground;
  58356. /**
  58357. * Get the scene sizes according to the setup.
  58358. */
  58359. private _getSceneSize;
  58360. /**
  58361. * Setup the ground according to the specified options.
  58362. */
  58363. private _setupGround;
  58364. /**
  58365. * Setup the ground material according to the specified options.
  58366. */
  58367. private _setupGroundMaterial;
  58368. /**
  58369. * Setup the ground diffuse texture according to the specified options.
  58370. */
  58371. private _setupGroundDiffuseTexture;
  58372. /**
  58373. * Setup the ground mirror texture according to the specified options.
  58374. */
  58375. private _setupGroundMirrorTexture;
  58376. /**
  58377. * Setup the ground to receive the mirror texture.
  58378. */
  58379. private _setupMirrorInGroundMaterial;
  58380. /**
  58381. * Setup the skybox according to the specified options.
  58382. */
  58383. private _setupSkybox;
  58384. /**
  58385. * Setup the skybox material according to the specified options.
  58386. */
  58387. private _setupSkyboxMaterial;
  58388. /**
  58389. * Setup the skybox reflection texture according to the specified options.
  58390. */
  58391. private _setupSkyboxReflectionTexture;
  58392. private _errorHandler;
  58393. /**
  58394. * Dispose all the elements created by the Helper.
  58395. */
  58396. dispose(): void;
  58397. }
  58398. }
  58399. declare module BABYLON {
  58400. /**
  58401. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  58402. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  58403. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  58404. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58405. */
  58406. export abstract class TextureDome<T extends Texture> extends TransformNode {
  58407. protected onError: Nullable<(message?: string, exception?: any) => void>;
  58408. /**
  58409. * Define the source as a Monoscopic panoramic 360/180.
  58410. */
  58411. static readonly MODE_MONOSCOPIC: number;
  58412. /**
  58413. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  58414. */
  58415. static readonly MODE_TOPBOTTOM: number;
  58416. /**
  58417. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  58418. */
  58419. static readonly MODE_SIDEBYSIDE: number;
  58420. private _halfDome;
  58421. private _crossEye;
  58422. protected _useDirectMapping: boolean;
  58423. /**
  58424. * The texture being displayed on the sphere
  58425. */
  58426. protected _texture: T;
  58427. /**
  58428. * Gets the texture being displayed on the sphere
  58429. */
  58430. get texture(): T;
  58431. /**
  58432. * Sets the texture being displayed on the sphere
  58433. */
  58434. set texture(newTexture: T);
  58435. /**
  58436. * The skybox material
  58437. */
  58438. protected _material: BackgroundMaterial;
  58439. /**
  58440. * The surface used for the dome
  58441. */
  58442. protected _mesh: Mesh;
  58443. /**
  58444. * Gets the mesh used for the dome.
  58445. */
  58446. get mesh(): Mesh;
  58447. /**
  58448. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  58449. */
  58450. private _halfDomeMask;
  58451. /**
  58452. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  58453. * Also see the options.resolution property.
  58454. */
  58455. get fovMultiplier(): number;
  58456. set fovMultiplier(value: number);
  58457. protected _textureMode: number;
  58458. /**
  58459. * Gets or set the current texture mode for the texture. It can be:
  58460. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58461. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58462. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58463. */
  58464. get textureMode(): number;
  58465. /**
  58466. * Sets the current texture mode for the texture. It can be:
  58467. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58468. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58469. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58470. */
  58471. set textureMode(value: number);
  58472. /**
  58473. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  58474. */
  58475. get halfDome(): boolean;
  58476. /**
  58477. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  58478. */
  58479. set halfDome(enabled: boolean);
  58480. /**
  58481. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  58482. */
  58483. set crossEye(enabled: boolean);
  58484. /**
  58485. * Is it a cross-eye texture?
  58486. */
  58487. get crossEye(): boolean;
  58488. /**
  58489. * The background material of this dome.
  58490. */
  58491. get material(): BackgroundMaterial;
  58492. /**
  58493. * Oberserver used in Stereoscopic VR Mode.
  58494. */
  58495. private _onBeforeCameraRenderObserver;
  58496. /**
  58497. * Observable raised when an error occured while loading the 360 image
  58498. */
  58499. onLoadErrorObservable: Observable<string>;
  58500. /**
  58501. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  58502. * @param name Element's name, child elements will append suffixes for their own names.
  58503. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  58504. * @param options An object containing optional or exposed sub element properties
  58505. */
  58506. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  58507. resolution?: number;
  58508. clickToPlay?: boolean;
  58509. autoPlay?: boolean;
  58510. loop?: boolean;
  58511. size?: number;
  58512. poster?: string;
  58513. faceForward?: boolean;
  58514. useDirectMapping?: boolean;
  58515. halfDomeMode?: boolean;
  58516. crossEyeMode?: boolean;
  58517. generateMipMaps?: boolean;
  58518. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  58519. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  58520. protected _changeTextureMode(value: number): void;
  58521. /**
  58522. * Releases resources associated with this node.
  58523. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  58524. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  58525. */
  58526. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  58527. }
  58528. }
  58529. declare module BABYLON {
  58530. /**
  58531. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  58532. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  58533. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  58534. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58535. */
  58536. export class PhotoDome extends TextureDome<Texture> {
  58537. /**
  58538. * Define the image as a Monoscopic panoramic 360 image.
  58539. */
  58540. static readonly MODE_MONOSCOPIC: number;
  58541. /**
  58542. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  58543. */
  58544. static readonly MODE_TOPBOTTOM: number;
  58545. /**
  58546. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  58547. */
  58548. static readonly MODE_SIDEBYSIDE: number;
  58549. /**
  58550. * Gets or sets the texture being displayed on the sphere
  58551. */
  58552. get photoTexture(): Texture;
  58553. /**
  58554. * sets the texture being displayed on the sphere
  58555. */
  58556. set photoTexture(value: Texture);
  58557. /**
  58558. * Gets the current video mode for the video. It can be:
  58559. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58560. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58561. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58562. */
  58563. get imageMode(): number;
  58564. /**
  58565. * Sets the current video mode for the video. It can be:
  58566. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58567. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58568. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58569. */
  58570. set imageMode(value: number);
  58571. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  58572. }
  58573. }
  58574. declare module BABYLON {
  58575. /**
  58576. * Direct draw surface info
  58577. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  58578. */
  58579. export interface DDSInfo {
  58580. /**
  58581. * Width of the texture
  58582. */
  58583. width: number;
  58584. /**
  58585. * Width of the texture
  58586. */
  58587. height: number;
  58588. /**
  58589. * Number of Mipmaps for the texture
  58590. * @see https://en.wikipedia.org/wiki/Mipmap
  58591. */
  58592. mipmapCount: number;
  58593. /**
  58594. * If the textures format is a known fourCC format
  58595. * @see https://www.fourcc.org/
  58596. */
  58597. isFourCC: boolean;
  58598. /**
  58599. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  58600. */
  58601. isRGB: boolean;
  58602. /**
  58603. * If the texture is a lumincance format
  58604. */
  58605. isLuminance: boolean;
  58606. /**
  58607. * If this is a cube texture
  58608. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  58609. */
  58610. isCube: boolean;
  58611. /**
  58612. * If the texture is a compressed format eg. FOURCC_DXT1
  58613. */
  58614. isCompressed: boolean;
  58615. /**
  58616. * The dxgiFormat of the texture
  58617. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  58618. */
  58619. dxgiFormat: number;
  58620. /**
  58621. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  58622. */
  58623. textureType: number;
  58624. /**
  58625. * Sphericle polynomial created for the dds texture
  58626. */
  58627. sphericalPolynomial?: SphericalPolynomial;
  58628. }
  58629. /**
  58630. * Class used to provide DDS decompression tools
  58631. */
  58632. export class DDSTools {
  58633. /**
  58634. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  58635. */
  58636. static StoreLODInAlphaChannel: boolean;
  58637. /**
  58638. * Gets DDS information from an array buffer
  58639. * @param data defines the array buffer view to read data from
  58640. * @returns the DDS information
  58641. */
  58642. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  58643. private static _FloatView;
  58644. private static _Int32View;
  58645. private static _ToHalfFloat;
  58646. private static _FromHalfFloat;
  58647. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  58648. private static _GetHalfFloatRGBAArrayBuffer;
  58649. private static _GetFloatRGBAArrayBuffer;
  58650. private static _GetFloatAsUIntRGBAArrayBuffer;
  58651. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  58652. private static _GetRGBAArrayBuffer;
  58653. private static _ExtractLongWordOrder;
  58654. private static _GetRGBArrayBuffer;
  58655. private static _GetLuminanceArrayBuffer;
  58656. /**
  58657. * Uploads DDS Levels to a Babylon Texture
  58658. * @hidden
  58659. */
  58660. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  58661. }
  58662. interface ThinEngine {
  58663. /**
  58664. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  58665. * @param rootUrl defines the url where the file to load is located
  58666. * @param scene defines the current scene
  58667. * @param lodScale defines scale to apply to the mip map selection
  58668. * @param lodOffset defines offset to apply to the mip map selection
  58669. * @param onLoad defines an optional callback raised when the texture is loaded
  58670. * @param onError defines an optional callback raised if there is an issue to load the texture
  58671. * @param format defines the format of the data
  58672. * @param forcedExtension defines the extension to use to pick the right loader
  58673. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  58674. * @returns the cube texture as an InternalTexture
  58675. */
  58676. 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;
  58677. }
  58678. }
  58679. declare module BABYLON {
  58680. /**
  58681. * Implementation of the DDS Texture Loader.
  58682. * @hidden
  58683. */
  58684. export class _DDSTextureLoader implements IInternalTextureLoader {
  58685. /**
  58686. * Defines wether the loader supports cascade loading the different faces.
  58687. */
  58688. readonly supportCascades: boolean;
  58689. /**
  58690. * This returns if the loader support the current file information.
  58691. * @param extension defines the file extension of the file being loaded
  58692. * @returns true if the loader can load the specified file
  58693. */
  58694. canLoad(extension: string): boolean;
  58695. /**
  58696. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58697. * @param data contains the texture data
  58698. * @param texture defines the BabylonJS internal texture
  58699. * @param createPolynomials will be true if polynomials have been requested
  58700. * @param onLoad defines the callback to trigger once the texture is ready
  58701. * @param onError defines the callback to trigger in case of error
  58702. */
  58703. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58704. /**
  58705. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58706. * @param data contains the texture data
  58707. * @param texture defines the BabylonJS internal texture
  58708. * @param callback defines the method to call once ready to upload
  58709. */
  58710. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58711. }
  58712. }
  58713. declare module BABYLON {
  58714. /**
  58715. * Implementation of the ENV Texture Loader.
  58716. * @hidden
  58717. */
  58718. export class _ENVTextureLoader implements IInternalTextureLoader {
  58719. /**
  58720. * Defines wether the loader supports cascade loading the different faces.
  58721. */
  58722. readonly supportCascades: boolean;
  58723. /**
  58724. * This returns if the loader support the current file information.
  58725. * @param extension defines the file extension of the file being loaded
  58726. * @returns true if the loader can load the specified file
  58727. */
  58728. canLoad(extension: string): boolean;
  58729. /**
  58730. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58731. * @param data contains the texture data
  58732. * @param texture defines the BabylonJS internal texture
  58733. * @param createPolynomials will be true if polynomials have been requested
  58734. * @param onLoad defines the callback to trigger once the texture is ready
  58735. * @param onError defines the callback to trigger in case of error
  58736. */
  58737. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58738. /**
  58739. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58740. * @param data contains the texture data
  58741. * @param texture defines the BabylonJS internal texture
  58742. * @param callback defines the method to call once ready to upload
  58743. */
  58744. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58745. }
  58746. }
  58747. declare module BABYLON {
  58748. /**
  58749. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  58750. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  58751. */
  58752. export class KhronosTextureContainer {
  58753. /** contents of the KTX container file */
  58754. data: ArrayBufferView;
  58755. private static HEADER_LEN;
  58756. private static COMPRESSED_2D;
  58757. private static COMPRESSED_3D;
  58758. private static TEX_2D;
  58759. private static TEX_3D;
  58760. /**
  58761. * Gets the openGL type
  58762. */
  58763. glType: number;
  58764. /**
  58765. * Gets the openGL type size
  58766. */
  58767. glTypeSize: number;
  58768. /**
  58769. * Gets the openGL format
  58770. */
  58771. glFormat: number;
  58772. /**
  58773. * Gets the openGL internal format
  58774. */
  58775. glInternalFormat: number;
  58776. /**
  58777. * Gets the base internal format
  58778. */
  58779. glBaseInternalFormat: number;
  58780. /**
  58781. * Gets image width in pixel
  58782. */
  58783. pixelWidth: number;
  58784. /**
  58785. * Gets image height in pixel
  58786. */
  58787. pixelHeight: number;
  58788. /**
  58789. * Gets image depth in pixels
  58790. */
  58791. pixelDepth: number;
  58792. /**
  58793. * Gets the number of array elements
  58794. */
  58795. numberOfArrayElements: number;
  58796. /**
  58797. * Gets the number of faces
  58798. */
  58799. numberOfFaces: number;
  58800. /**
  58801. * Gets the number of mipmap levels
  58802. */
  58803. numberOfMipmapLevels: number;
  58804. /**
  58805. * Gets the bytes of key value data
  58806. */
  58807. bytesOfKeyValueData: number;
  58808. /**
  58809. * Gets the load type
  58810. */
  58811. loadType: number;
  58812. /**
  58813. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  58814. */
  58815. isInvalid: boolean;
  58816. /**
  58817. * Creates a new KhronosTextureContainer
  58818. * @param data contents of the KTX container file
  58819. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  58820. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  58821. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  58822. */
  58823. constructor(
  58824. /** contents of the KTX container file */
  58825. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  58826. /**
  58827. * Uploads KTX content to a Babylon Texture.
  58828. * It is assumed that the texture has already been created & is currently bound
  58829. * @hidden
  58830. */
  58831. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  58832. private _upload2DCompressedLevels;
  58833. /**
  58834. * Checks if the given data starts with a KTX file identifier.
  58835. * @param data the data to check
  58836. * @returns true if the data is a KTX file or false otherwise
  58837. */
  58838. static IsValid(data: ArrayBufferView): boolean;
  58839. }
  58840. }
  58841. declare module BABYLON {
  58842. /**
  58843. * Helper class to push actions to a pool of workers.
  58844. */
  58845. export class WorkerPool implements IDisposable {
  58846. private _workerInfos;
  58847. private _pendingActions;
  58848. /**
  58849. * Constructor
  58850. * @param workers Array of workers to use for actions
  58851. */
  58852. constructor(workers: Array<Worker>);
  58853. /**
  58854. * Terminates all workers and clears any pending actions.
  58855. */
  58856. dispose(): void;
  58857. /**
  58858. * Pushes an action to the worker pool. If all the workers are active, the action will be
  58859. * pended until a worker has completed its action.
  58860. * @param action The action to perform. Call onComplete when the action is complete.
  58861. */
  58862. push(action: (worker: Worker, onComplete: () => void) => void): void;
  58863. private _execute;
  58864. }
  58865. }
  58866. declare module BABYLON {
  58867. /**
  58868. * Class for loading KTX2 files
  58869. */
  58870. export class KhronosTextureContainer2 {
  58871. private static _WorkerPoolPromise?;
  58872. private static _Initialized;
  58873. private static _Ktx2Decoder;
  58874. /**
  58875. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  58876. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  58877. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  58878. * Urls you can change:
  58879. * URLConfig.jsDecoderModule
  58880. * URLConfig.wasmUASTCToASTC
  58881. * URLConfig.wasmUASTCToBC7
  58882. * URLConfig.wasmUASTCToRGBA_UNORM
  58883. * URLConfig.wasmUASTCToRGBA_SRGB
  58884. * URLConfig.jsMSCTranscoder
  58885. * URLConfig.wasmMSCTranscoder
  58886. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  58887. */
  58888. static URLConfig: {
  58889. jsDecoderModule: string;
  58890. wasmUASTCToASTC: null;
  58891. wasmUASTCToBC7: null;
  58892. wasmUASTCToRGBA_UNORM: null;
  58893. wasmUASTCToRGBA_SRGB: null;
  58894. jsMSCTranscoder: null;
  58895. wasmMSCTranscoder: null;
  58896. };
  58897. /**
  58898. * Default number of workers used to handle data decoding
  58899. */
  58900. static DefaultNumWorkers: number;
  58901. private static GetDefaultNumWorkers;
  58902. private _engine;
  58903. private static _CreateWorkerPool;
  58904. /**
  58905. * Constructor
  58906. * @param engine The engine to use
  58907. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  58908. */
  58909. constructor(engine: ThinEngine, numWorkers?: number);
  58910. /** @hidden */
  58911. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  58912. /**
  58913. * Stop all async operations and release resources.
  58914. */
  58915. dispose(): void;
  58916. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  58917. /**
  58918. * Checks if the given data starts with a KTX2 file identifier.
  58919. * @param data the data to check
  58920. * @returns true if the data is a KTX2 file or false otherwise
  58921. */
  58922. static IsValid(data: ArrayBufferView): boolean;
  58923. }
  58924. }
  58925. declare module BABYLON {
  58926. /**
  58927. * Implementation of the KTX Texture Loader.
  58928. * @hidden
  58929. */
  58930. export class _KTXTextureLoader implements IInternalTextureLoader {
  58931. /**
  58932. * Defines wether the loader supports cascade loading the different faces.
  58933. */
  58934. readonly supportCascades: boolean;
  58935. /**
  58936. * This returns if the loader support the current file information.
  58937. * @param extension defines the file extension of the file being loaded
  58938. * @param mimeType defines the optional mime type of the file being loaded
  58939. * @returns true if the loader can load the specified file
  58940. */
  58941. canLoad(extension: string, mimeType?: string): boolean;
  58942. /**
  58943. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58944. * @param data contains the texture data
  58945. * @param texture defines the BabylonJS internal texture
  58946. * @param createPolynomials will be true if polynomials have been requested
  58947. * @param onLoad defines the callback to trigger once the texture is ready
  58948. * @param onError defines the callback to trigger in case of error
  58949. */
  58950. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58951. /**
  58952. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58953. * @param data contains the texture data
  58954. * @param texture defines the BabylonJS internal texture
  58955. * @param callback defines the method to call once ready to upload
  58956. */
  58957. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  58958. }
  58959. }
  58960. declare module BABYLON {
  58961. /** @hidden */
  58962. export var _forceSceneHelpersToBundle: boolean;
  58963. interface Scene {
  58964. /**
  58965. * Creates a default light for the scene.
  58966. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  58967. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  58968. */
  58969. createDefaultLight(replace?: boolean): void;
  58970. /**
  58971. * Creates a default camera for the scene.
  58972. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  58973. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58974. * @param replace has default false, when true replaces the active camera in the scene
  58975. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  58976. */
  58977. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58978. /**
  58979. * Creates a default camera and a default light.
  58980. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  58981. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58982. * @param replace has the default false, when true replaces the active camera/light in the scene
  58983. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  58984. */
  58985. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58986. /**
  58987. * Creates a new sky box
  58988. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  58989. * @param environmentTexture defines the texture to use as environment texture
  58990. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  58991. * @param scale defines the overall scale of the skybox
  58992. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  58993. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  58994. * @returns a new mesh holding the sky box
  58995. */
  58996. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  58997. /**
  58998. * Creates a new environment
  58999. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  59000. * @param options defines the options you can use to configure the environment
  59001. * @returns the new EnvironmentHelper
  59002. */
  59003. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  59004. /**
  59005. * Creates a new VREXperienceHelper
  59006. * @see https://doc.babylonjs.com/how_to/webvr_helper
  59007. * @param webVROptions defines the options used to create the new VREXperienceHelper
  59008. * @returns a new VREXperienceHelper
  59009. */
  59010. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  59011. /**
  59012. * Creates a new WebXRDefaultExperience
  59013. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  59014. * @param options experience options
  59015. * @returns a promise for a new WebXRDefaultExperience
  59016. */
  59017. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  59018. }
  59019. }
  59020. declare module BABYLON {
  59021. /**
  59022. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  59023. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  59024. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  59025. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  59026. */
  59027. export class VideoDome extends TextureDome<VideoTexture> {
  59028. /**
  59029. * Define the video source as a Monoscopic panoramic 360 video.
  59030. */
  59031. static readonly MODE_MONOSCOPIC: number;
  59032. /**
  59033. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  59034. */
  59035. static readonly MODE_TOPBOTTOM: number;
  59036. /**
  59037. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  59038. */
  59039. static readonly MODE_SIDEBYSIDE: number;
  59040. /**
  59041. * Get the video texture associated with this video dome
  59042. */
  59043. get videoTexture(): VideoTexture;
  59044. /**
  59045. * Get the video mode of this dome
  59046. */
  59047. get videoMode(): number;
  59048. /**
  59049. * Set the video mode of this dome.
  59050. * @see textureMode
  59051. */
  59052. set videoMode(value: number);
  59053. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  59054. }
  59055. }
  59056. declare module BABYLON {
  59057. /**
  59058. * This class can be used to get instrumentation data from a Babylon engine
  59059. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59060. */
  59061. export class EngineInstrumentation implements IDisposable {
  59062. /**
  59063. * Define the instrumented engine.
  59064. */
  59065. engine: Engine;
  59066. private _captureGPUFrameTime;
  59067. private _gpuFrameTimeToken;
  59068. private _gpuFrameTime;
  59069. private _captureShaderCompilationTime;
  59070. private _shaderCompilationTime;
  59071. private _onBeginFrameObserver;
  59072. private _onEndFrameObserver;
  59073. private _onBeforeShaderCompilationObserver;
  59074. private _onAfterShaderCompilationObserver;
  59075. /**
  59076. * Gets the perf counter used for GPU frame time
  59077. */
  59078. get gpuFrameTimeCounter(): PerfCounter;
  59079. /**
  59080. * Gets the GPU frame time capture status
  59081. */
  59082. get captureGPUFrameTime(): boolean;
  59083. /**
  59084. * Enable or disable the GPU frame time capture
  59085. */
  59086. set captureGPUFrameTime(value: boolean);
  59087. /**
  59088. * Gets the perf counter used for shader compilation time
  59089. */
  59090. get shaderCompilationTimeCounter(): PerfCounter;
  59091. /**
  59092. * Gets the shader compilation time capture status
  59093. */
  59094. get captureShaderCompilationTime(): boolean;
  59095. /**
  59096. * Enable or disable the shader compilation time capture
  59097. */
  59098. set captureShaderCompilationTime(value: boolean);
  59099. /**
  59100. * Instantiates a new engine instrumentation.
  59101. * This class can be used to get instrumentation data from a Babylon engine
  59102. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59103. * @param engine Defines the engine to instrument
  59104. */
  59105. constructor(
  59106. /**
  59107. * Define the instrumented engine.
  59108. */
  59109. engine: Engine);
  59110. /**
  59111. * Dispose and release associated resources.
  59112. */
  59113. dispose(): void;
  59114. }
  59115. }
  59116. declare module BABYLON {
  59117. /**
  59118. * This class can be used to get instrumentation data from a Babylon engine
  59119. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59120. */
  59121. export class SceneInstrumentation implements IDisposable {
  59122. /**
  59123. * Defines the scene to instrument
  59124. */
  59125. scene: Scene;
  59126. private _captureActiveMeshesEvaluationTime;
  59127. private _activeMeshesEvaluationTime;
  59128. private _captureRenderTargetsRenderTime;
  59129. private _renderTargetsRenderTime;
  59130. private _captureFrameTime;
  59131. private _frameTime;
  59132. private _captureRenderTime;
  59133. private _renderTime;
  59134. private _captureInterFrameTime;
  59135. private _interFrameTime;
  59136. private _captureParticlesRenderTime;
  59137. private _particlesRenderTime;
  59138. private _captureSpritesRenderTime;
  59139. private _spritesRenderTime;
  59140. private _capturePhysicsTime;
  59141. private _physicsTime;
  59142. private _captureAnimationsTime;
  59143. private _animationsTime;
  59144. private _captureCameraRenderTime;
  59145. private _cameraRenderTime;
  59146. private _onBeforeActiveMeshesEvaluationObserver;
  59147. private _onAfterActiveMeshesEvaluationObserver;
  59148. private _onBeforeRenderTargetsRenderObserver;
  59149. private _onAfterRenderTargetsRenderObserver;
  59150. private _onAfterRenderObserver;
  59151. private _onBeforeDrawPhaseObserver;
  59152. private _onAfterDrawPhaseObserver;
  59153. private _onBeforeAnimationsObserver;
  59154. private _onBeforeParticlesRenderingObserver;
  59155. private _onAfterParticlesRenderingObserver;
  59156. private _onBeforeSpritesRenderingObserver;
  59157. private _onAfterSpritesRenderingObserver;
  59158. private _onBeforePhysicsObserver;
  59159. private _onAfterPhysicsObserver;
  59160. private _onAfterAnimationsObserver;
  59161. private _onBeforeCameraRenderObserver;
  59162. private _onAfterCameraRenderObserver;
  59163. /**
  59164. * Gets the perf counter used for active meshes evaluation time
  59165. */
  59166. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  59167. /**
  59168. * Gets the active meshes evaluation time capture status
  59169. */
  59170. get captureActiveMeshesEvaluationTime(): boolean;
  59171. /**
  59172. * Enable or disable the active meshes evaluation time capture
  59173. */
  59174. set captureActiveMeshesEvaluationTime(value: boolean);
  59175. /**
  59176. * Gets the perf counter used for render targets render time
  59177. */
  59178. get renderTargetsRenderTimeCounter(): PerfCounter;
  59179. /**
  59180. * Gets the render targets render time capture status
  59181. */
  59182. get captureRenderTargetsRenderTime(): boolean;
  59183. /**
  59184. * Enable or disable the render targets render time capture
  59185. */
  59186. set captureRenderTargetsRenderTime(value: boolean);
  59187. /**
  59188. * Gets the perf counter used for particles render time
  59189. */
  59190. get particlesRenderTimeCounter(): PerfCounter;
  59191. /**
  59192. * Gets the particles render time capture status
  59193. */
  59194. get captureParticlesRenderTime(): boolean;
  59195. /**
  59196. * Enable or disable the particles render time capture
  59197. */
  59198. set captureParticlesRenderTime(value: boolean);
  59199. /**
  59200. * Gets the perf counter used for sprites render time
  59201. */
  59202. get spritesRenderTimeCounter(): PerfCounter;
  59203. /**
  59204. * Gets the sprites render time capture status
  59205. */
  59206. get captureSpritesRenderTime(): boolean;
  59207. /**
  59208. * Enable or disable the sprites render time capture
  59209. */
  59210. set captureSpritesRenderTime(value: boolean);
  59211. /**
  59212. * Gets the perf counter used for physics time
  59213. */
  59214. get physicsTimeCounter(): PerfCounter;
  59215. /**
  59216. * Gets the physics time capture status
  59217. */
  59218. get capturePhysicsTime(): boolean;
  59219. /**
  59220. * Enable or disable the physics time capture
  59221. */
  59222. set capturePhysicsTime(value: boolean);
  59223. /**
  59224. * Gets the perf counter used for animations time
  59225. */
  59226. get animationsTimeCounter(): PerfCounter;
  59227. /**
  59228. * Gets the animations time capture status
  59229. */
  59230. get captureAnimationsTime(): boolean;
  59231. /**
  59232. * Enable or disable the animations time capture
  59233. */
  59234. set captureAnimationsTime(value: boolean);
  59235. /**
  59236. * Gets the perf counter used for frame time capture
  59237. */
  59238. get frameTimeCounter(): PerfCounter;
  59239. /**
  59240. * Gets the frame time capture status
  59241. */
  59242. get captureFrameTime(): boolean;
  59243. /**
  59244. * Enable or disable the frame time capture
  59245. */
  59246. set captureFrameTime(value: boolean);
  59247. /**
  59248. * Gets the perf counter used for inter-frames time capture
  59249. */
  59250. get interFrameTimeCounter(): PerfCounter;
  59251. /**
  59252. * Gets the inter-frames time capture status
  59253. */
  59254. get captureInterFrameTime(): boolean;
  59255. /**
  59256. * Enable or disable the inter-frames time capture
  59257. */
  59258. set captureInterFrameTime(value: boolean);
  59259. /**
  59260. * Gets the perf counter used for render time capture
  59261. */
  59262. get renderTimeCounter(): PerfCounter;
  59263. /**
  59264. * Gets the render time capture status
  59265. */
  59266. get captureRenderTime(): boolean;
  59267. /**
  59268. * Enable or disable the render time capture
  59269. */
  59270. set captureRenderTime(value: boolean);
  59271. /**
  59272. * Gets the perf counter used for camera render time capture
  59273. */
  59274. get cameraRenderTimeCounter(): PerfCounter;
  59275. /**
  59276. * Gets the camera render time capture status
  59277. */
  59278. get captureCameraRenderTime(): boolean;
  59279. /**
  59280. * Enable or disable the camera render time capture
  59281. */
  59282. set captureCameraRenderTime(value: boolean);
  59283. /**
  59284. * Gets the perf counter used for draw calls
  59285. */
  59286. get drawCallsCounter(): PerfCounter;
  59287. /**
  59288. * Instantiates a new scene instrumentation.
  59289. * This class can be used to get instrumentation data from a Babylon engine
  59290. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59291. * @param scene Defines the scene to instrument
  59292. */
  59293. constructor(
  59294. /**
  59295. * Defines the scene to instrument
  59296. */
  59297. scene: Scene);
  59298. /**
  59299. * Dispose and release associated resources.
  59300. */
  59301. dispose(): void;
  59302. }
  59303. }
  59304. declare module BABYLON {
  59305. /** @hidden */
  59306. export var glowMapGenerationPixelShader: {
  59307. name: string;
  59308. shader: string;
  59309. };
  59310. }
  59311. declare module BABYLON {
  59312. /** @hidden */
  59313. export var glowMapGenerationVertexShader: {
  59314. name: string;
  59315. shader: string;
  59316. };
  59317. }
  59318. declare module BABYLON {
  59319. /**
  59320. * Effect layer options. This helps customizing the behaviour
  59321. * of the effect layer.
  59322. */
  59323. export interface IEffectLayerOptions {
  59324. /**
  59325. * Multiplication factor apply to the canvas size to compute the render target size
  59326. * used to generated the objects (the smaller the faster).
  59327. */
  59328. mainTextureRatio: number;
  59329. /**
  59330. * Enforces a fixed size texture to ensure effect stability across devices.
  59331. */
  59332. mainTextureFixedSize?: number;
  59333. /**
  59334. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  59335. */
  59336. alphaBlendingMode: number;
  59337. /**
  59338. * The camera attached to the layer.
  59339. */
  59340. camera: Nullable<Camera>;
  59341. /**
  59342. * The rendering group to draw the layer in.
  59343. */
  59344. renderingGroupId: number;
  59345. }
  59346. /**
  59347. * The effect layer Helps adding post process effect blended with the main pass.
  59348. *
  59349. * This can be for instance use to generate glow or higlight effects on the scene.
  59350. *
  59351. * The effect layer class can not be used directly and is intented to inherited from to be
  59352. * customized per effects.
  59353. */
  59354. export abstract class EffectLayer {
  59355. private _vertexBuffers;
  59356. private _indexBuffer;
  59357. private _cachedDefines;
  59358. private _effectLayerMapGenerationEffect;
  59359. private _effectLayerOptions;
  59360. private _mergeEffect;
  59361. protected _scene: Scene;
  59362. protected _engine: Engine;
  59363. protected _maxSize: number;
  59364. protected _mainTextureDesiredSize: ISize;
  59365. protected _mainTexture: RenderTargetTexture;
  59366. protected _shouldRender: boolean;
  59367. protected _postProcesses: PostProcess[];
  59368. protected _textures: BaseTexture[];
  59369. protected _emissiveTextureAndColor: {
  59370. texture: Nullable<BaseTexture>;
  59371. color: Color4;
  59372. };
  59373. /**
  59374. * The name of the layer
  59375. */
  59376. name: string;
  59377. /**
  59378. * The clear color of the texture used to generate the glow map.
  59379. */
  59380. neutralColor: Color4;
  59381. /**
  59382. * Specifies whether the highlight layer is enabled or not.
  59383. */
  59384. isEnabled: boolean;
  59385. /**
  59386. * Gets the camera attached to the layer.
  59387. */
  59388. get camera(): Nullable<Camera>;
  59389. /**
  59390. * Gets the rendering group id the layer should render in.
  59391. */
  59392. get renderingGroupId(): number;
  59393. set renderingGroupId(renderingGroupId: number);
  59394. /**
  59395. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  59396. */
  59397. disableBoundingBoxesFromEffectLayer: boolean;
  59398. /**
  59399. * An event triggered when the effect layer has been disposed.
  59400. */
  59401. onDisposeObservable: Observable<EffectLayer>;
  59402. /**
  59403. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  59404. */
  59405. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  59406. /**
  59407. * An event triggered when the generated texture is being merged in the scene.
  59408. */
  59409. onBeforeComposeObservable: Observable<EffectLayer>;
  59410. /**
  59411. * An event triggered when the mesh is rendered into the effect render target.
  59412. */
  59413. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  59414. /**
  59415. * An event triggered after the mesh has been rendered into the effect render target.
  59416. */
  59417. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  59418. /**
  59419. * An event triggered when the generated texture has been merged in the scene.
  59420. */
  59421. onAfterComposeObservable: Observable<EffectLayer>;
  59422. /**
  59423. * An event triggered when the efffect layer changes its size.
  59424. */
  59425. onSizeChangedObservable: Observable<EffectLayer>;
  59426. /** @hidden */
  59427. static _SceneComponentInitialization: (scene: Scene) => void;
  59428. /**
  59429. * Instantiates a new effect Layer and references it in the scene.
  59430. * @param name The name of the layer
  59431. * @param scene The scene to use the layer in
  59432. */
  59433. constructor(
  59434. /** The Friendly of the effect in the scene */
  59435. name: string, scene: Scene);
  59436. /**
  59437. * Get the effect name of the layer.
  59438. * @return The effect name
  59439. */
  59440. abstract getEffectName(): string;
  59441. /**
  59442. * Checks for the readiness of the element composing the layer.
  59443. * @param subMesh the mesh to check for
  59444. * @param useInstances specify whether or not to use instances to render the mesh
  59445. * @return true if ready otherwise, false
  59446. */
  59447. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59448. /**
  59449. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59450. * @returns true if the effect requires stencil during the main canvas render pass.
  59451. */
  59452. abstract needStencil(): boolean;
  59453. /**
  59454. * Create the merge effect. This is the shader use to blit the information back
  59455. * to the main canvas at the end of the scene rendering.
  59456. * @returns The effect containing the shader used to merge the effect on the main canvas
  59457. */
  59458. protected abstract _createMergeEffect(): Effect;
  59459. /**
  59460. * Creates the render target textures and post processes used in the effect layer.
  59461. */
  59462. protected abstract _createTextureAndPostProcesses(): void;
  59463. /**
  59464. * Implementation specific of rendering the generating effect on the main canvas.
  59465. * @param effect The effect used to render through
  59466. */
  59467. protected abstract _internalRender(effect: Effect): void;
  59468. /**
  59469. * Sets the required values for both the emissive texture and and the main color.
  59470. */
  59471. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59472. /**
  59473. * Free any resources and references associated to a mesh.
  59474. * Internal use
  59475. * @param mesh The mesh to free.
  59476. */
  59477. abstract _disposeMesh(mesh: Mesh): void;
  59478. /**
  59479. * Serializes this layer (Glow or Highlight for example)
  59480. * @returns a serialized layer object
  59481. */
  59482. abstract serialize?(): any;
  59483. /**
  59484. * Initializes the effect layer with the required options.
  59485. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  59486. */
  59487. protected _init(options: Partial<IEffectLayerOptions>): void;
  59488. /**
  59489. * Generates the index buffer of the full screen quad blending to the main canvas.
  59490. */
  59491. private _generateIndexBuffer;
  59492. /**
  59493. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  59494. */
  59495. private _generateVertexBuffer;
  59496. /**
  59497. * Sets the main texture desired size which is the closest power of two
  59498. * of the engine canvas size.
  59499. */
  59500. private _setMainTextureSize;
  59501. /**
  59502. * Creates the main texture for the effect layer.
  59503. */
  59504. protected _createMainTexture(): void;
  59505. /**
  59506. * Adds specific effects defines.
  59507. * @param defines The defines to add specifics to.
  59508. */
  59509. protected _addCustomEffectDefines(defines: string[]): void;
  59510. /**
  59511. * Checks for the readiness of the element composing the layer.
  59512. * @param subMesh the mesh to check for
  59513. * @param useInstances specify whether or not to use instances to render the mesh
  59514. * @param emissiveTexture the associated emissive texture used to generate the glow
  59515. * @return true if ready otherwise, false
  59516. */
  59517. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  59518. /**
  59519. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  59520. */
  59521. render(): void;
  59522. /**
  59523. * Determine if a given mesh will be used in the current effect.
  59524. * @param mesh mesh to test
  59525. * @returns true if the mesh will be used
  59526. */
  59527. hasMesh(mesh: AbstractMesh): boolean;
  59528. /**
  59529. * Returns true if the layer contains information to display, otherwise false.
  59530. * @returns true if the glow layer should be rendered
  59531. */
  59532. shouldRender(): boolean;
  59533. /**
  59534. * Returns true if the mesh should render, otherwise false.
  59535. * @param mesh The mesh to render
  59536. * @returns true if it should render otherwise false
  59537. */
  59538. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  59539. /**
  59540. * Returns true if the mesh can be rendered, otherwise false.
  59541. * @param mesh The mesh to render
  59542. * @param material The material used on the mesh
  59543. * @returns true if it can be rendered otherwise false
  59544. */
  59545. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59546. /**
  59547. * Returns true if the mesh should render, otherwise false.
  59548. * @param mesh The mesh to render
  59549. * @returns true if it should render otherwise false
  59550. */
  59551. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  59552. /**
  59553. * Renders the submesh passed in parameter to the generation map.
  59554. */
  59555. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  59556. /**
  59557. * Defines whether the current material of the mesh should be use to render the effect.
  59558. * @param mesh defines the current mesh to render
  59559. */
  59560. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59561. /**
  59562. * Rebuild the required buffers.
  59563. * @hidden Internal use only.
  59564. */
  59565. _rebuild(): void;
  59566. /**
  59567. * Dispose only the render target textures and post process.
  59568. */
  59569. private _disposeTextureAndPostProcesses;
  59570. /**
  59571. * Dispose the highlight layer and free resources.
  59572. */
  59573. dispose(): void;
  59574. /**
  59575. * Gets the class name of the effect layer
  59576. * @returns the string with the class name of the effect layer
  59577. */
  59578. getClassName(): string;
  59579. /**
  59580. * Creates an effect layer from parsed effect layer data
  59581. * @param parsedEffectLayer defines effect layer data
  59582. * @param scene defines the current scene
  59583. * @param rootUrl defines the root URL containing the effect layer information
  59584. * @returns a parsed effect Layer
  59585. */
  59586. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  59587. }
  59588. }
  59589. declare module BABYLON {
  59590. interface AbstractScene {
  59591. /**
  59592. * The list of effect layers (highlights/glow) added to the scene
  59593. * @see https://doc.babylonjs.com/how_to/highlight_layer
  59594. * @see https://doc.babylonjs.com/how_to/glow_layer
  59595. */
  59596. effectLayers: Array<EffectLayer>;
  59597. /**
  59598. * Removes the given effect layer from this scene.
  59599. * @param toRemove defines the effect layer to remove
  59600. * @returns the index of the removed effect layer
  59601. */
  59602. removeEffectLayer(toRemove: EffectLayer): number;
  59603. /**
  59604. * Adds the given effect layer to this scene
  59605. * @param newEffectLayer defines the effect layer to add
  59606. */
  59607. addEffectLayer(newEffectLayer: EffectLayer): void;
  59608. }
  59609. /**
  59610. * Defines the layer scene component responsible to manage any effect layers
  59611. * in a given scene.
  59612. */
  59613. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  59614. /**
  59615. * The component name helpfull to identify the component in the list of scene components.
  59616. */
  59617. readonly name: string;
  59618. /**
  59619. * The scene the component belongs to.
  59620. */
  59621. scene: Scene;
  59622. private _engine;
  59623. private _renderEffects;
  59624. private _needStencil;
  59625. private _previousStencilState;
  59626. /**
  59627. * Creates a new instance of the component for the given scene
  59628. * @param scene Defines the scene to register the component in
  59629. */
  59630. constructor(scene: Scene);
  59631. /**
  59632. * Registers the component in a given scene
  59633. */
  59634. register(): void;
  59635. /**
  59636. * Rebuilds the elements related to this component in case of
  59637. * context lost for instance.
  59638. */
  59639. rebuild(): void;
  59640. /**
  59641. * Serializes the component data to the specified json object
  59642. * @param serializationObject The object to serialize to
  59643. */
  59644. serialize(serializationObject: any): void;
  59645. /**
  59646. * Adds all the elements from the container to the scene
  59647. * @param container the container holding the elements
  59648. */
  59649. addFromContainer(container: AbstractScene): void;
  59650. /**
  59651. * Removes all the elements in the container from the scene
  59652. * @param container contains the elements to remove
  59653. * @param dispose if the removed element should be disposed (default: false)
  59654. */
  59655. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59656. /**
  59657. * Disposes the component and the associated ressources.
  59658. */
  59659. dispose(): void;
  59660. private _isReadyForMesh;
  59661. private _renderMainTexture;
  59662. private _setStencil;
  59663. private _setStencilBack;
  59664. private _draw;
  59665. private _drawCamera;
  59666. private _drawRenderingGroup;
  59667. }
  59668. }
  59669. declare module BABYLON {
  59670. /** @hidden */
  59671. export var glowMapMergePixelShader: {
  59672. name: string;
  59673. shader: string;
  59674. };
  59675. }
  59676. declare module BABYLON {
  59677. /** @hidden */
  59678. export var glowMapMergeVertexShader: {
  59679. name: string;
  59680. shader: string;
  59681. };
  59682. }
  59683. declare module BABYLON {
  59684. interface AbstractScene {
  59685. /**
  59686. * Return a the first highlight layer of the scene with a given name.
  59687. * @param name The name of the highlight layer to look for.
  59688. * @return The highlight layer if found otherwise null.
  59689. */
  59690. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  59691. }
  59692. /**
  59693. * Glow layer options. This helps customizing the behaviour
  59694. * of the glow layer.
  59695. */
  59696. export interface IGlowLayerOptions {
  59697. /**
  59698. * Multiplication factor apply to the canvas size to compute the render target size
  59699. * used to generated the glowing objects (the smaller the faster).
  59700. */
  59701. mainTextureRatio: number;
  59702. /**
  59703. * Enforces a fixed size texture to ensure resize independant blur.
  59704. */
  59705. mainTextureFixedSize?: number;
  59706. /**
  59707. * How big is the kernel of the blur texture.
  59708. */
  59709. blurKernelSize: number;
  59710. /**
  59711. * The camera attached to the layer.
  59712. */
  59713. camera: Nullable<Camera>;
  59714. /**
  59715. * Enable MSAA by chosing the number of samples.
  59716. */
  59717. mainTextureSamples?: number;
  59718. /**
  59719. * The rendering group to draw the layer in.
  59720. */
  59721. renderingGroupId: number;
  59722. }
  59723. /**
  59724. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  59725. *
  59726. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  59727. *
  59728. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  59729. */
  59730. export class GlowLayer extends EffectLayer {
  59731. /**
  59732. * Effect Name of the layer.
  59733. */
  59734. static readonly EffectName: string;
  59735. /**
  59736. * The default blur kernel size used for the glow.
  59737. */
  59738. static DefaultBlurKernelSize: number;
  59739. /**
  59740. * The default texture size ratio used for the glow.
  59741. */
  59742. static DefaultTextureRatio: number;
  59743. /**
  59744. * Sets the kernel size of the blur.
  59745. */
  59746. set blurKernelSize(value: number);
  59747. /**
  59748. * Gets the kernel size of the blur.
  59749. */
  59750. get blurKernelSize(): number;
  59751. /**
  59752. * Sets the glow intensity.
  59753. */
  59754. set intensity(value: number);
  59755. /**
  59756. * Gets the glow intensity.
  59757. */
  59758. get intensity(): number;
  59759. private _options;
  59760. private _intensity;
  59761. private _horizontalBlurPostprocess1;
  59762. private _verticalBlurPostprocess1;
  59763. private _horizontalBlurPostprocess2;
  59764. private _verticalBlurPostprocess2;
  59765. private _blurTexture1;
  59766. private _blurTexture2;
  59767. private _postProcesses1;
  59768. private _postProcesses2;
  59769. private _includedOnlyMeshes;
  59770. private _excludedMeshes;
  59771. private _meshesUsingTheirOwnMaterials;
  59772. /**
  59773. * Callback used to let the user override the color selection on a per mesh basis
  59774. */
  59775. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  59776. /**
  59777. * Callback used to let the user override the texture selection on a per mesh basis
  59778. */
  59779. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  59780. /**
  59781. * Instantiates a new glow Layer and references it to the scene.
  59782. * @param name The name of the layer
  59783. * @param scene The scene to use the layer in
  59784. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  59785. */
  59786. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  59787. /**
  59788. * Get the effect name of the layer.
  59789. * @return The effect name
  59790. */
  59791. getEffectName(): string;
  59792. /**
  59793. * Create the merge effect. This is the shader use to blit the information back
  59794. * to the main canvas at the end of the scene rendering.
  59795. */
  59796. protected _createMergeEffect(): Effect;
  59797. /**
  59798. * Creates the render target textures and post processes used in the glow layer.
  59799. */
  59800. protected _createTextureAndPostProcesses(): void;
  59801. /**
  59802. * Checks for the readiness of the element composing the layer.
  59803. * @param subMesh the mesh to check for
  59804. * @param useInstances specify wether or not to use instances to render the mesh
  59805. * @param emissiveTexture the associated emissive texture used to generate the glow
  59806. * @return true if ready otherwise, false
  59807. */
  59808. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59809. /**
  59810. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59811. */
  59812. needStencil(): boolean;
  59813. /**
  59814. * Returns true if the mesh can be rendered, otherwise false.
  59815. * @param mesh The mesh to render
  59816. * @param material The material used on the mesh
  59817. * @returns true if it can be rendered otherwise false
  59818. */
  59819. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59820. /**
  59821. * Implementation specific of rendering the generating effect on the main canvas.
  59822. * @param effect The effect used to render through
  59823. */
  59824. protected _internalRender(effect: Effect): void;
  59825. /**
  59826. * Sets the required values for both the emissive texture and and the main color.
  59827. */
  59828. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59829. /**
  59830. * Returns true if the mesh should render, otherwise false.
  59831. * @param mesh The mesh to render
  59832. * @returns true if it should render otherwise false
  59833. */
  59834. protected _shouldRenderMesh(mesh: Mesh): boolean;
  59835. /**
  59836. * Adds specific effects defines.
  59837. * @param defines The defines to add specifics to.
  59838. */
  59839. protected _addCustomEffectDefines(defines: string[]): void;
  59840. /**
  59841. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  59842. * @param mesh The mesh to exclude from the glow layer
  59843. */
  59844. addExcludedMesh(mesh: Mesh): void;
  59845. /**
  59846. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  59847. * @param mesh The mesh to remove
  59848. */
  59849. removeExcludedMesh(mesh: Mesh): void;
  59850. /**
  59851. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  59852. * @param mesh The mesh to include in the glow layer
  59853. */
  59854. addIncludedOnlyMesh(mesh: Mesh): void;
  59855. /**
  59856. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  59857. * @param mesh The mesh to remove
  59858. */
  59859. removeIncludedOnlyMesh(mesh: Mesh): void;
  59860. /**
  59861. * Determine if a given mesh will be used in the glow layer
  59862. * @param mesh The mesh to test
  59863. * @returns true if the mesh will be highlighted by the current glow layer
  59864. */
  59865. hasMesh(mesh: AbstractMesh): boolean;
  59866. /**
  59867. * Defines whether the current material of the mesh should be use to render the effect.
  59868. * @param mesh defines the current mesh to render
  59869. */
  59870. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59871. /**
  59872. * Add a mesh to be rendered through its own material and not with emissive only.
  59873. * @param mesh The mesh for which we need to use its material
  59874. */
  59875. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  59876. /**
  59877. * Remove a mesh from being rendered through its own material and not with emissive only.
  59878. * @param mesh The mesh for which we need to not use its material
  59879. */
  59880. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  59881. /**
  59882. * Free any resources and references associated to a mesh.
  59883. * Internal use
  59884. * @param mesh The mesh to free.
  59885. * @hidden
  59886. */
  59887. _disposeMesh(mesh: Mesh): void;
  59888. /**
  59889. * Gets the class name of the effect layer
  59890. * @returns the string with the class name of the effect layer
  59891. */
  59892. getClassName(): string;
  59893. /**
  59894. * Serializes this glow layer
  59895. * @returns a serialized glow layer object
  59896. */
  59897. serialize(): any;
  59898. /**
  59899. * Creates a Glow Layer from parsed glow layer data
  59900. * @param parsedGlowLayer defines glow layer data
  59901. * @param scene defines the current scene
  59902. * @param rootUrl defines the root URL containing the glow layer information
  59903. * @returns a parsed Glow Layer
  59904. */
  59905. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  59906. }
  59907. }
  59908. declare module BABYLON {
  59909. /** @hidden */
  59910. export var glowBlurPostProcessPixelShader: {
  59911. name: string;
  59912. shader: string;
  59913. };
  59914. }
  59915. declare module BABYLON {
  59916. interface AbstractScene {
  59917. /**
  59918. * Return a the first highlight layer of the scene with a given name.
  59919. * @param name The name of the highlight layer to look for.
  59920. * @return The highlight layer if found otherwise null.
  59921. */
  59922. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  59923. }
  59924. /**
  59925. * Highlight layer options. This helps customizing the behaviour
  59926. * of the highlight layer.
  59927. */
  59928. export interface IHighlightLayerOptions {
  59929. /**
  59930. * Multiplication factor apply to the canvas size to compute the render target size
  59931. * used to generated the glowing objects (the smaller the faster).
  59932. */
  59933. mainTextureRatio: number;
  59934. /**
  59935. * Enforces a fixed size texture to ensure resize independant blur.
  59936. */
  59937. mainTextureFixedSize?: number;
  59938. /**
  59939. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  59940. * of the picture to blur (the smaller the faster).
  59941. */
  59942. blurTextureSizeRatio: number;
  59943. /**
  59944. * How big in texel of the blur texture is the vertical blur.
  59945. */
  59946. blurVerticalSize: number;
  59947. /**
  59948. * How big in texel of the blur texture is the horizontal blur.
  59949. */
  59950. blurHorizontalSize: number;
  59951. /**
  59952. * Alpha blending mode used to apply the blur. Default is combine.
  59953. */
  59954. alphaBlendingMode: number;
  59955. /**
  59956. * The camera attached to the layer.
  59957. */
  59958. camera: Nullable<Camera>;
  59959. /**
  59960. * Should we display highlight as a solid stroke?
  59961. */
  59962. isStroke?: boolean;
  59963. /**
  59964. * The rendering group to draw the layer in.
  59965. */
  59966. renderingGroupId: number;
  59967. }
  59968. /**
  59969. * The highlight layer Helps adding a glow effect around a mesh.
  59970. *
  59971. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  59972. * glowy meshes to your scene.
  59973. *
  59974. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  59975. */
  59976. export class HighlightLayer extends EffectLayer {
  59977. name: string;
  59978. /**
  59979. * Effect Name of the highlight layer.
  59980. */
  59981. static readonly EffectName: string;
  59982. /**
  59983. * The neutral color used during the preparation of the glow effect.
  59984. * This is black by default as the blend operation is a blend operation.
  59985. */
  59986. static NeutralColor: Color4;
  59987. /**
  59988. * Stencil value used for glowing meshes.
  59989. */
  59990. static GlowingMeshStencilReference: number;
  59991. /**
  59992. * Stencil value used for the other meshes in the scene.
  59993. */
  59994. static NormalMeshStencilReference: number;
  59995. /**
  59996. * Specifies whether or not the inner glow is ACTIVE in the layer.
  59997. */
  59998. innerGlow: boolean;
  59999. /**
  60000. * Specifies whether or not the outer glow is ACTIVE in the layer.
  60001. */
  60002. outerGlow: boolean;
  60003. /**
  60004. * Specifies the horizontal size of the blur.
  60005. */
  60006. set blurHorizontalSize(value: number);
  60007. /**
  60008. * Specifies the vertical size of the blur.
  60009. */
  60010. set blurVerticalSize(value: number);
  60011. /**
  60012. * Gets the horizontal size of the blur.
  60013. */
  60014. get blurHorizontalSize(): number;
  60015. /**
  60016. * Gets the vertical size of the blur.
  60017. */
  60018. get blurVerticalSize(): number;
  60019. /**
  60020. * An event triggered when the highlight layer is being blurred.
  60021. */
  60022. onBeforeBlurObservable: Observable<HighlightLayer>;
  60023. /**
  60024. * An event triggered when the highlight layer has been blurred.
  60025. */
  60026. onAfterBlurObservable: Observable<HighlightLayer>;
  60027. private _instanceGlowingMeshStencilReference;
  60028. private _options;
  60029. private _downSamplePostprocess;
  60030. private _horizontalBlurPostprocess;
  60031. private _verticalBlurPostprocess;
  60032. private _blurTexture;
  60033. private _meshes;
  60034. private _excludedMeshes;
  60035. /**
  60036. * Instantiates a new highlight Layer and references it to the scene..
  60037. * @param name The name of the layer
  60038. * @param scene The scene to use the layer in
  60039. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  60040. */
  60041. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  60042. /**
  60043. * Get the effect name of the layer.
  60044. * @return The effect name
  60045. */
  60046. getEffectName(): string;
  60047. /**
  60048. * Create the merge effect. This is the shader use to blit the information back
  60049. * to the main canvas at the end of the scene rendering.
  60050. */
  60051. protected _createMergeEffect(): Effect;
  60052. /**
  60053. * Creates the render target textures and post processes used in the highlight layer.
  60054. */
  60055. protected _createTextureAndPostProcesses(): void;
  60056. /**
  60057. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  60058. */
  60059. needStencil(): boolean;
  60060. /**
  60061. * Checks for the readiness of the element composing the layer.
  60062. * @param subMesh the mesh to check for
  60063. * @param useInstances specify wether or not to use instances to render the mesh
  60064. * @param emissiveTexture the associated emissive texture used to generate the glow
  60065. * @return true if ready otherwise, false
  60066. */
  60067. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60068. /**
  60069. * Implementation specific of rendering the generating effect on the main canvas.
  60070. * @param effect The effect used to render through
  60071. */
  60072. protected _internalRender(effect: Effect): void;
  60073. /**
  60074. * Returns true if the layer contains information to display, otherwise false.
  60075. */
  60076. shouldRender(): boolean;
  60077. /**
  60078. * Returns true if the mesh should render, otherwise false.
  60079. * @param mesh The mesh to render
  60080. * @returns true if it should render otherwise false
  60081. */
  60082. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60083. /**
  60084. * Returns true if the mesh can be rendered, otherwise false.
  60085. * @param mesh The mesh to render
  60086. * @param material The material used on the mesh
  60087. * @returns true if it can be rendered otherwise false
  60088. */
  60089. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60090. /**
  60091. * Adds specific effects defines.
  60092. * @param defines The defines to add specifics to.
  60093. */
  60094. protected _addCustomEffectDefines(defines: string[]): void;
  60095. /**
  60096. * Sets the required values for both the emissive texture and and the main color.
  60097. */
  60098. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60099. /**
  60100. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  60101. * @param mesh The mesh to exclude from the highlight layer
  60102. */
  60103. addExcludedMesh(mesh: Mesh): void;
  60104. /**
  60105. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  60106. * @param mesh The mesh to highlight
  60107. */
  60108. removeExcludedMesh(mesh: Mesh): void;
  60109. /**
  60110. * Determine if a given mesh will be highlighted by the current HighlightLayer
  60111. * @param mesh mesh to test
  60112. * @returns true if the mesh will be highlighted by the current HighlightLayer
  60113. */
  60114. hasMesh(mesh: AbstractMesh): boolean;
  60115. /**
  60116. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  60117. * @param mesh The mesh to highlight
  60118. * @param color The color of the highlight
  60119. * @param glowEmissiveOnly Extract the glow from the emissive texture
  60120. */
  60121. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  60122. /**
  60123. * Remove a mesh from the highlight layer in order to make it stop glowing.
  60124. * @param mesh The mesh to highlight
  60125. */
  60126. removeMesh(mesh: Mesh): void;
  60127. /**
  60128. * Remove all the meshes currently referenced in the highlight layer
  60129. */
  60130. removeAllMeshes(): void;
  60131. /**
  60132. * Force the stencil to the normal expected value for none glowing parts
  60133. */
  60134. private _defaultStencilReference;
  60135. /**
  60136. * Free any resources and references associated to a mesh.
  60137. * Internal use
  60138. * @param mesh The mesh to free.
  60139. * @hidden
  60140. */
  60141. _disposeMesh(mesh: Mesh): void;
  60142. /**
  60143. * Dispose the highlight layer and free resources.
  60144. */
  60145. dispose(): void;
  60146. /**
  60147. * Gets the class name of the effect layer
  60148. * @returns the string with the class name of the effect layer
  60149. */
  60150. getClassName(): string;
  60151. /**
  60152. * Serializes this Highlight layer
  60153. * @returns a serialized Highlight layer object
  60154. */
  60155. serialize(): any;
  60156. /**
  60157. * Creates a Highlight layer from parsed Highlight layer data
  60158. * @param parsedHightlightLayer defines the Highlight layer data
  60159. * @param scene defines the current scene
  60160. * @param rootUrl defines the root URL containing the Highlight layer information
  60161. * @returns a parsed Highlight layer
  60162. */
  60163. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  60164. }
  60165. }
  60166. declare module BABYLON {
  60167. interface AbstractScene {
  60168. /**
  60169. * The list of layers (background and foreground) of the scene
  60170. */
  60171. layers: Array<Layer>;
  60172. }
  60173. /**
  60174. * Defines the layer scene component responsible to manage any layers
  60175. * in a given scene.
  60176. */
  60177. export class LayerSceneComponent implements ISceneComponent {
  60178. /**
  60179. * The component name helpfull to identify the component in the list of scene components.
  60180. */
  60181. readonly name: string;
  60182. /**
  60183. * The scene the component belongs to.
  60184. */
  60185. scene: Scene;
  60186. private _engine;
  60187. /**
  60188. * Creates a new instance of the component for the given scene
  60189. * @param scene Defines the scene to register the component in
  60190. */
  60191. constructor(scene: Scene);
  60192. /**
  60193. * Registers the component in a given scene
  60194. */
  60195. register(): void;
  60196. /**
  60197. * Rebuilds the elements related to this component in case of
  60198. * context lost for instance.
  60199. */
  60200. rebuild(): void;
  60201. /**
  60202. * Disposes the component and the associated ressources.
  60203. */
  60204. dispose(): void;
  60205. private _draw;
  60206. private _drawCameraPredicate;
  60207. private _drawCameraBackground;
  60208. private _drawCameraForeground;
  60209. private _drawRenderTargetPredicate;
  60210. private _drawRenderTargetBackground;
  60211. private _drawRenderTargetForeground;
  60212. /**
  60213. * Adds all the elements from the container to the scene
  60214. * @param container the container holding the elements
  60215. */
  60216. addFromContainer(container: AbstractScene): void;
  60217. /**
  60218. * Removes all the elements in the container from the scene
  60219. * @param container contains the elements to remove
  60220. * @param dispose if the removed element should be disposed (default: false)
  60221. */
  60222. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60223. }
  60224. }
  60225. declare module BABYLON {
  60226. /** @hidden */
  60227. export var layerPixelShader: {
  60228. name: string;
  60229. shader: string;
  60230. };
  60231. }
  60232. declare module BABYLON {
  60233. /** @hidden */
  60234. export var layerVertexShader: {
  60235. name: string;
  60236. shader: string;
  60237. };
  60238. }
  60239. declare module BABYLON {
  60240. /**
  60241. * This represents a full screen 2d layer.
  60242. * This can be useful to display a picture in the background of your scene for instance.
  60243. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60244. */
  60245. export class Layer {
  60246. /**
  60247. * Define the name of the layer.
  60248. */
  60249. name: string;
  60250. /**
  60251. * Define the texture the layer should display.
  60252. */
  60253. texture: Nullable<Texture>;
  60254. /**
  60255. * Is the layer in background or foreground.
  60256. */
  60257. isBackground: boolean;
  60258. /**
  60259. * Define the color of the layer (instead of texture).
  60260. */
  60261. color: Color4;
  60262. /**
  60263. * Define the scale of the layer in order to zoom in out of the texture.
  60264. */
  60265. scale: Vector2;
  60266. /**
  60267. * Define an offset for the layer in order to shift the texture.
  60268. */
  60269. offset: Vector2;
  60270. /**
  60271. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  60272. */
  60273. alphaBlendingMode: number;
  60274. /**
  60275. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  60276. * Alpha test will not mix with the background color in case of transparency.
  60277. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  60278. */
  60279. alphaTest: boolean;
  60280. /**
  60281. * Define a mask to restrict the layer to only some of the scene cameras.
  60282. */
  60283. layerMask: number;
  60284. /**
  60285. * Define the list of render target the layer is visible into.
  60286. */
  60287. renderTargetTextures: RenderTargetTexture[];
  60288. /**
  60289. * Define if the layer is only used in renderTarget or if it also
  60290. * renders in the main frame buffer of the canvas.
  60291. */
  60292. renderOnlyInRenderTargetTextures: boolean;
  60293. private _scene;
  60294. private _vertexBuffers;
  60295. private _indexBuffer;
  60296. private _effect;
  60297. private _previousDefines;
  60298. /**
  60299. * An event triggered when the layer is disposed.
  60300. */
  60301. onDisposeObservable: Observable<Layer>;
  60302. private _onDisposeObserver;
  60303. /**
  60304. * Back compatibility with callback before the onDisposeObservable existed.
  60305. * The set callback will be triggered when the layer has been disposed.
  60306. */
  60307. set onDispose(callback: () => void);
  60308. /**
  60309. * An event triggered before rendering the scene
  60310. */
  60311. onBeforeRenderObservable: Observable<Layer>;
  60312. private _onBeforeRenderObserver;
  60313. /**
  60314. * Back compatibility with callback before the onBeforeRenderObservable existed.
  60315. * The set callback will be triggered just before rendering the layer.
  60316. */
  60317. set onBeforeRender(callback: () => void);
  60318. /**
  60319. * An event triggered after rendering the scene
  60320. */
  60321. onAfterRenderObservable: Observable<Layer>;
  60322. private _onAfterRenderObserver;
  60323. /**
  60324. * Back compatibility with callback before the onAfterRenderObservable existed.
  60325. * The set callback will be triggered just after rendering the layer.
  60326. */
  60327. set onAfterRender(callback: () => void);
  60328. /**
  60329. * Instantiates a new layer.
  60330. * This represents a full screen 2d layer.
  60331. * This can be useful to display a picture in the background of your scene for instance.
  60332. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60333. * @param name Define the name of the layer in the scene
  60334. * @param imgUrl Define the url of the texture to display in the layer
  60335. * @param scene Define the scene the layer belongs to
  60336. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  60337. * @param color Defines a color for the layer
  60338. */
  60339. constructor(
  60340. /**
  60341. * Define the name of the layer.
  60342. */
  60343. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  60344. private _createIndexBuffer;
  60345. /** @hidden */
  60346. _rebuild(): void;
  60347. /**
  60348. * Renders the layer in the scene.
  60349. */
  60350. render(): void;
  60351. /**
  60352. * Disposes and releases the associated ressources.
  60353. */
  60354. dispose(): void;
  60355. }
  60356. }
  60357. declare module BABYLON {
  60358. /** @hidden */
  60359. export var lensFlarePixelShader: {
  60360. name: string;
  60361. shader: string;
  60362. };
  60363. }
  60364. declare module BABYLON {
  60365. /** @hidden */
  60366. export var lensFlareVertexShader: {
  60367. name: string;
  60368. shader: string;
  60369. };
  60370. }
  60371. declare module BABYLON {
  60372. /**
  60373. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60374. * It is usually composed of several `lensFlare`.
  60375. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60376. */
  60377. export class LensFlareSystem {
  60378. /**
  60379. * Define the name of the lens flare system
  60380. */
  60381. name: string;
  60382. /**
  60383. * List of lens flares used in this system.
  60384. */
  60385. lensFlares: LensFlare[];
  60386. /**
  60387. * Define a limit from the border the lens flare can be visible.
  60388. */
  60389. borderLimit: number;
  60390. /**
  60391. * Define a viewport border we do not want to see the lens flare in.
  60392. */
  60393. viewportBorder: number;
  60394. /**
  60395. * Define a predicate which could limit the list of meshes able to occlude the effect.
  60396. */
  60397. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  60398. /**
  60399. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  60400. */
  60401. layerMask: number;
  60402. /**
  60403. * Define the id of the lens flare system in the scene.
  60404. * (equal to name by default)
  60405. */
  60406. id: string;
  60407. private _scene;
  60408. private _emitter;
  60409. private _vertexBuffers;
  60410. private _indexBuffer;
  60411. private _effect;
  60412. private _positionX;
  60413. private _positionY;
  60414. private _isEnabled;
  60415. /** @hidden */
  60416. static _SceneComponentInitialization: (scene: Scene) => void;
  60417. /**
  60418. * Instantiates a lens flare system.
  60419. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60420. * It is usually composed of several `lensFlare`.
  60421. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60422. * @param name Define the name of the lens flare system in the scene
  60423. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  60424. * @param scene Define the scene the lens flare system belongs to
  60425. */
  60426. constructor(
  60427. /**
  60428. * Define the name of the lens flare system
  60429. */
  60430. name: string, emitter: any, scene: Scene);
  60431. /**
  60432. * Define if the lens flare system is enabled.
  60433. */
  60434. get isEnabled(): boolean;
  60435. set isEnabled(value: boolean);
  60436. /**
  60437. * Get the scene the effects belongs to.
  60438. * @returns the scene holding the lens flare system
  60439. */
  60440. getScene(): Scene;
  60441. /**
  60442. * Get the emitter of the lens flare system.
  60443. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60444. * @returns the emitter of the lens flare system
  60445. */
  60446. getEmitter(): any;
  60447. /**
  60448. * Set the emitter of the lens flare system.
  60449. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60450. * @param newEmitter Define the new emitter of the system
  60451. */
  60452. setEmitter(newEmitter: any): void;
  60453. /**
  60454. * Get the lens flare system emitter position.
  60455. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  60456. * @returns the position
  60457. */
  60458. getEmitterPosition(): Vector3;
  60459. /**
  60460. * @hidden
  60461. */
  60462. computeEffectivePosition(globalViewport: Viewport): boolean;
  60463. /** @hidden */
  60464. _isVisible(): boolean;
  60465. /**
  60466. * @hidden
  60467. */
  60468. render(): boolean;
  60469. /**
  60470. * Dispose and release the lens flare with its associated resources.
  60471. */
  60472. dispose(): void;
  60473. /**
  60474. * Parse a lens flare system from a JSON repressentation
  60475. * @param parsedLensFlareSystem Define the JSON to parse
  60476. * @param scene Define the scene the parsed system should be instantiated in
  60477. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  60478. * @returns the parsed system
  60479. */
  60480. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  60481. /**
  60482. * Serialize the current Lens Flare System into a JSON representation.
  60483. * @returns the serialized JSON
  60484. */
  60485. serialize(): any;
  60486. }
  60487. }
  60488. declare module BABYLON {
  60489. /**
  60490. * This represents one of the lens effect in a `lensFlareSystem`.
  60491. * It controls one of the indiviual texture used in the effect.
  60492. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60493. */
  60494. export class LensFlare {
  60495. /**
  60496. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60497. */
  60498. size: number;
  60499. /**
  60500. * 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.
  60501. */
  60502. position: number;
  60503. /**
  60504. * Define the lens color.
  60505. */
  60506. color: Color3;
  60507. /**
  60508. * Define the lens texture.
  60509. */
  60510. texture: Nullable<Texture>;
  60511. /**
  60512. * Define the alpha mode to render this particular lens.
  60513. */
  60514. alphaMode: number;
  60515. private _system;
  60516. /**
  60517. * Creates a new Lens Flare.
  60518. * This represents one of the lens effect in a `lensFlareSystem`.
  60519. * It controls one of the indiviual texture used in the effect.
  60520. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60521. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  60522. * @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.
  60523. * @param color Define the lens color
  60524. * @param imgUrl Define the lens texture url
  60525. * @param system Define the `lensFlareSystem` this flare is part of
  60526. * @returns The newly created Lens Flare
  60527. */
  60528. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  60529. /**
  60530. * Instantiates a new Lens Flare.
  60531. * This represents one of the lens effect in a `lensFlareSystem`.
  60532. * It controls one of the indiviual texture used in the effect.
  60533. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60534. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  60535. * @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.
  60536. * @param color Define the lens color
  60537. * @param imgUrl Define the lens texture url
  60538. * @param system Define the `lensFlareSystem` this flare is part of
  60539. */
  60540. constructor(
  60541. /**
  60542. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60543. */
  60544. size: number,
  60545. /**
  60546. * 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.
  60547. */
  60548. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  60549. /**
  60550. * Dispose and release the lens flare with its associated resources.
  60551. */
  60552. dispose(): void;
  60553. }
  60554. }
  60555. declare module BABYLON {
  60556. interface AbstractScene {
  60557. /**
  60558. * The list of lens flare system added to the scene
  60559. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60560. */
  60561. lensFlareSystems: Array<LensFlareSystem>;
  60562. /**
  60563. * Removes the given lens flare system from this scene.
  60564. * @param toRemove The lens flare system to remove
  60565. * @returns The index of the removed lens flare system
  60566. */
  60567. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  60568. /**
  60569. * Adds the given lens flare system to this scene
  60570. * @param newLensFlareSystem The lens flare system to add
  60571. */
  60572. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  60573. /**
  60574. * Gets a lens flare system using its name
  60575. * @param name defines the name to look for
  60576. * @returns the lens flare system or null if not found
  60577. */
  60578. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  60579. /**
  60580. * Gets a lens flare system using its id
  60581. * @param id defines the id to look for
  60582. * @returns the lens flare system or null if not found
  60583. */
  60584. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  60585. }
  60586. /**
  60587. * Defines the lens flare scene component responsible to manage any lens flares
  60588. * in a given scene.
  60589. */
  60590. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  60591. /**
  60592. * The component name helpfull to identify the component in the list of scene components.
  60593. */
  60594. readonly name: string;
  60595. /**
  60596. * The scene the component belongs to.
  60597. */
  60598. scene: Scene;
  60599. /**
  60600. * Creates a new instance of the component for the given scene
  60601. * @param scene Defines the scene to register the component in
  60602. */
  60603. constructor(scene: Scene);
  60604. /**
  60605. * Registers the component in a given scene
  60606. */
  60607. register(): void;
  60608. /**
  60609. * Rebuilds the elements related to this component in case of
  60610. * context lost for instance.
  60611. */
  60612. rebuild(): void;
  60613. /**
  60614. * Adds all the elements from the container to the scene
  60615. * @param container the container holding the elements
  60616. */
  60617. addFromContainer(container: AbstractScene): void;
  60618. /**
  60619. * Removes all the elements in the container from the scene
  60620. * @param container contains the elements to remove
  60621. * @param dispose if the removed element should be disposed (default: false)
  60622. */
  60623. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60624. /**
  60625. * Serializes the component data to the specified json object
  60626. * @param serializationObject The object to serialize to
  60627. */
  60628. serialize(serializationObject: any): void;
  60629. /**
  60630. * Disposes the component and the associated ressources.
  60631. */
  60632. dispose(): void;
  60633. private _draw;
  60634. }
  60635. }
  60636. declare module BABYLON {
  60637. /** @hidden */
  60638. export var depthPixelShader: {
  60639. name: string;
  60640. shader: string;
  60641. };
  60642. }
  60643. declare module BABYLON {
  60644. /** @hidden */
  60645. export var depthVertexShader: {
  60646. name: string;
  60647. shader: string;
  60648. };
  60649. }
  60650. declare module BABYLON {
  60651. /**
  60652. * This represents a depth renderer in Babylon.
  60653. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60654. */
  60655. export class DepthRenderer {
  60656. private _scene;
  60657. private _depthMap;
  60658. private _effect;
  60659. private readonly _storeNonLinearDepth;
  60660. private readonly _clearColor;
  60661. /** Get if the depth renderer is using packed depth or not */
  60662. readonly isPacked: boolean;
  60663. private _cachedDefines;
  60664. private _camera;
  60665. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  60666. enabled: boolean;
  60667. /**
  60668. * Specifiess that the depth renderer will only be used within
  60669. * the camera it is created for.
  60670. * This can help forcing its rendering during the camera processing.
  60671. */
  60672. useOnlyInActiveCamera: boolean;
  60673. /** @hidden */
  60674. static _SceneComponentInitialization: (scene: Scene) => void;
  60675. /**
  60676. * Instantiates a depth renderer
  60677. * @param scene The scene the renderer belongs to
  60678. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60679. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60680. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60681. */
  60682. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  60683. /**
  60684. * Creates the depth rendering effect and checks if the effect is ready.
  60685. * @param subMesh The submesh to be used to render the depth map of
  60686. * @param useInstances If multiple world instances should be used
  60687. * @returns if the depth renderer is ready to render the depth map
  60688. */
  60689. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60690. /**
  60691. * Gets the texture which the depth map will be written to.
  60692. * @returns The depth map texture
  60693. */
  60694. getDepthMap(): RenderTargetTexture;
  60695. /**
  60696. * Disposes of the depth renderer.
  60697. */
  60698. dispose(): void;
  60699. }
  60700. }
  60701. declare module BABYLON {
  60702. /** @hidden */
  60703. export var minmaxReduxPixelShader: {
  60704. name: string;
  60705. shader: string;
  60706. };
  60707. }
  60708. declare module BABYLON {
  60709. /**
  60710. * This class computes a min/max reduction from a texture: it means it computes the minimum
  60711. * and maximum values from all values of the texture.
  60712. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  60713. * The source values are read from the red channel of the texture.
  60714. */
  60715. export class MinMaxReducer {
  60716. /**
  60717. * Observable triggered when the computation has been performed
  60718. */
  60719. onAfterReductionPerformed: Observable<{
  60720. min: number;
  60721. max: number;
  60722. }>;
  60723. protected _camera: Camera;
  60724. protected _sourceTexture: Nullable<RenderTargetTexture>;
  60725. protected _reductionSteps: Nullable<Array<PostProcess>>;
  60726. protected _postProcessManager: PostProcessManager;
  60727. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  60728. protected _forceFullscreenViewport: boolean;
  60729. /**
  60730. * Creates a min/max reducer
  60731. * @param camera The camera to use for the post processes
  60732. */
  60733. constructor(camera: Camera);
  60734. /**
  60735. * Gets the texture used to read the values from.
  60736. */
  60737. get sourceTexture(): Nullable<RenderTargetTexture>;
  60738. /**
  60739. * Sets the source texture to read the values from.
  60740. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  60741. * because in such textures '1' value must not be taken into account to compute the maximum
  60742. * as this value is used to clear the texture.
  60743. * Note that the computation is not activated by calling this function, you must call activate() for that!
  60744. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  60745. * @param depthRedux Indicates if the texture is a depth texture or not
  60746. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  60747. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  60748. */
  60749. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60750. /**
  60751. * Defines the refresh rate of the computation.
  60752. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  60753. */
  60754. get refreshRate(): number;
  60755. set refreshRate(value: number);
  60756. protected _activated: boolean;
  60757. /**
  60758. * Gets the activation status of the reducer
  60759. */
  60760. get activated(): boolean;
  60761. /**
  60762. * Activates the reduction computation.
  60763. * When activated, the observers registered in onAfterReductionPerformed are
  60764. * called after the compuation is performed
  60765. */
  60766. activate(): void;
  60767. /**
  60768. * Deactivates the reduction computation.
  60769. */
  60770. deactivate(): void;
  60771. /**
  60772. * Disposes the min/max reducer
  60773. * @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.
  60774. */
  60775. dispose(disposeAll?: boolean): void;
  60776. }
  60777. }
  60778. declare module BABYLON {
  60779. /**
  60780. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  60781. */
  60782. export class DepthReducer extends MinMaxReducer {
  60783. private _depthRenderer;
  60784. private _depthRendererId;
  60785. /**
  60786. * Gets the depth renderer used for the computation.
  60787. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  60788. */
  60789. get depthRenderer(): Nullable<DepthRenderer>;
  60790. /**
  60791. * Creates a depth reducer
  60792. * @param camera The camera used to render the depth texture
  60793. */
  60794. constructor(camera: Camera);
  60795. /**
  60796. * Sets the depth renderer to use to generate the depth map
  60797. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  60798. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  60799. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  60800. */
  60801. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  60802. /** @hidden */
  60803. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60804. /**
  60805. * Activates the reduction computation.
  60806. * When activated, the observers registered in onAfterReductionPerformed are
  60807. * called after the compuation is performed
  60808. */
  60809. activate(): void;
  60810. /**
  60811. * Deactivates the reduction computation.
  60812. */
  60813. deactivate(): void;
  60814. /**
  60815. * Disposes the depth reducer
  60816. * @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.
  60817. */
  60818. dispose(disposeAll?: boolean): void;
  60819. }
  60820. }
  60821. declare module BABYLON {
  60822. /**
  60823. * A CSM implementation allowing casting shadows on large scenes.
  60824. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  60825. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  60826. */
  60827. export class CascadedShadowGenerator extends ShadowGenerator {
  60828. private static readonly frustumCornersNDCSpace;
  60829. /**
  60830. * Name of the CSM class
  60831. */
  60832. static CLASSNAME: string;
  60833. /**
  60834. * Defines the default number of cascades used by the CSM.
  60835. */
  60836. static readonly DEFAULT_CASCADES_COUNT: number;
  60837. /**
  60838. * Defines the minimum number of cascades used by the CSM.
  60839. */
  60840. static readonly MIN_CASCADES_COUNT: number;
  60841. /**
  60842. * Defines the maximum number of cascades used by the CSM.
  60843. */
  60844. static readonly MAX_CASCADES_COUNT: number;
  60845. protected _validateFilter(filter: number): number;
  60846. /**
  60847. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  60848. */
  60849. penumbraDarkness: number;
  60850. private _numCascades;
  60851. /**
  60852. * Gets or set the number of cascades used by the CSM.
  60853. */
  60854. get numCascades(): number;
  60855. set numCascades(value: number);
  60856. /**
  60857. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  60858. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  60859. */
  60860. stabilizeCascades: boolean;
  60861. private _freezeShadowCastersBoundingInfo;
  60862. private _freezeShadowCastersBoundingInfoObservable;
  60863. /**
  60864. * Enables or disables the shadow casters bounding info computation.
  60865. * If your shadow casters don't move, you can disable this feature.
  60866. * If it is enabled, the bounding box computation is done every frame.
  60867. */
  60868. get freezeShadowCastersBoundingInfo(): boolean;
  60869. set freezeShadowCastersBoundingInfo(freeze: boolean);
  60870. private _scbiMin;
  60871. private _scbiMax;
  60872. protected _computeShadowCastersBoundingInfo(): void;
  60873. protected _shadowCastersBoundingInfo: BoundingInfo;
  60874. /**
  60875. * Gets or sets the shadow casters bounding info.
  60876. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  60877. * so that the system won't overwrite the bounds you provide
  60878. */
  60879. get shadowCastersBoundingInfo(): BoundingInfo;
  60880. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  60881. protected _breaksAreDirty: boolean;
  60882. protected _minDistance: number;
  60883. protected _maxDistance: number;
  60884. /**
  60885. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  60886. *
  60887. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  60888. * If you don't know these values, simply leave them to their defaults and don't call this function.
  60889. * @param min minimal distance for the breaks (default to 0.)
  60890. * @param max maximal distance for the breaks (default to 1.)
  60891. */
  60892. setMinMaxDistance(min: number, max: number): void;
  60893. /** Gets the minimal distance used in the cascade break computation */
  60894. get minDistance(): number;
  60895. /** Gets the maximal distance used in the cascade break computation */
  60896. get maxDistance(): number;
  60897. /**
  60898. * Gets the class name of that object
  60899. * @returns "CascadedShadowGenerator"
  60900. */
  60901. getClassName(): string;
  60902. private _cascadeMinExtents;
  60903. private _cascadeMaxExtents;
  60904. /**
  60905. * Gets a cascade minimum extents
  60906. * @param cascadeIndex index of the cascade
  60907. * @returns the minimum cascade extents
  60908. */
  60909. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  60910. /**
  60911. * Gets a cascade maximum extents
  60912. * @param cascadeIndex index of the cascade
  60913. * @returns the maximum cascade extents
  60914. */
  60915. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  60916. private _cascades;
  60917. private _currentLayer;
  60918. private _viewSpaceFrustumsZ;
  60919. private _viewMatrices;
  60920. private _projectionMatrices;
  60921. private _transformMatrices;
  60922. private _transformMatricesAsArray;
  60923. private _frustumLengths;
  60924. private _lightSizeUVCorrection;
  60925. private _depthCorrection;
  60926. private _frustumCornersWorldSpace;
  60927. private _frustumCenter;
  60928. private _shadowCameraPos;
  60929. private _shadowMaxZ;
  60930. /**
  60931. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  60932. * It defaults to camera.maxZ
  60933. */
  60934. get shadowMaxZ(): number;
  60935. /**
  60936. * Sets the shadow max z distance.
  60937. */
  60938. set shadowMaxZ(value: number);
  60939. protected _debug: boolean;
  60940. /**
  60941. * Gets or sets the debug flag.
  60942. * When enabled, the cascades are materialized by different colors on the screen.
  60943. */
  60944. get debug(): boolean;
  60945. set debug(dbg: boolean);
  60946. private _depthClamp;
  60947. /**
  60948. * Gets or sets the depth clamping value.
  60949. *
  60950. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  60951. * to account for the shadow casters far away.
  60952. *
  60953. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  60954. */
  60955. get depthClamp(): boolean;
  60956. set depthClamp(value: boolean);
  60957. private _cascadeBlendPercentage;
  60958. /**
  60959. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  60960. * It defaults to 0.1 (10% blending).
  60961. */
  60962. get cascadeBlendPercentage(): number;
  60963. set cascadeBlendPercentage(value: number);
  60964. private _lambda;
  60965. /**
  60966. * Gets or set the lambda parameter.
  60967. * This parameter is used to split the camera frustum and create the cascades.
  60968. * 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.
  60969. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  60970. */
  60971. get lambda(): number;
  60972. set lambda(value: number);
  60973. /**
  60974. * Gets the view matrix corresponding to a given cascade
  60975. * @param cascadeNum cascade to retrieve the view matrix from
  60976. * @returns the cascade view matrix
  60977. */
  60978. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  60979. /**
  60980. * Gets the projection matrix corresponding to a given cascade
  60981. * @param cascadeNum cascade to retrieve the projection matrix from
  60982. * @returns the cascade projection matrix
  60983. */
  60984. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  60985. /**
  60986. * Gets the transformation matrix corresponding to a given cascade
  60987. * @param cascadeNum cascade to retrieve the transformation matrix from
  60988. * @returns the cascade transformation matrix
  60989. */
  60990. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  60991. private _depthRenderer;
  60992. /**
  60993. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  60994. *
  60995. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  60996. *
  60997. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  60998. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  60999. * @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
  61000. */
  61001. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  61002. private _depthReducer;
  61003. private _autoCalcDepthBounds;
  61004. /**
  61005. * Gets or sets the autoCalcDepthBounds property.
  61006. *
  61007. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  61008. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  61009. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  61010. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  61011. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  61012. */
  61013. get autoCalcDepthBounds(): boolean;
  61014. set autoCalcDepthBounds(value: boolean);
  61015. /**
  61016. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  61017. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61018. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  61019. * for setting the refresh rate on the renderer yourself!
  61020. */
  61021. get autoCalcDepthBoundsRefreshRate(): number;
  61022. set autoCalcDepthBoundsRefreshRate(value: number);
  61023. /**
  61024. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  61025. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  61026. * you change the camera near/far planes!
  61027. */
  61028. splitFrustum(): void;
  61029. private _splitFrustum;
  61030. private _computeMatrices;
  61031. private _computeFrustumInWorldSpace;
  61032. private _computeCascadeFrustum;
  61033. /**
  61034. * Support test.
  61035. */
  61036. static get IsSupported(): boolean;
  61037. /** @hidden */
  61038. static _SceneComponentInitialization: (scene: Scene) => void;
  61039. /**
  61040. * Creates a Cascaded Shadow Generator object.
  61041. * A ShadowGenerator is the required tool to use the shadows.
  61042. * Each directional light casting shadows needs to use its own ShadowGenerator.
  61043. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61044. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  61045. * @param light The directional light object generating the shadows.
  61046. * @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.
  61047. */
  61048. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  61049. protected _initializeGenerator(): void;
  61050. protected _createTargetRenderTexture(): void;
  61051. protected _initializeShadowMap(): void;
  61052. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  61053. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  61054. /**
  61055. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  61056. * @param defines Defines of the material we want to update
  61057. * @param lightIndex Index of the light in the enabled light list of the material
  61058. */
  61059. prepareDefines(defines: any, lightIndex: number): void;
  61060. /**
  61061. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  61062. * defined in the generator but impacting the effect).
  61063. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  61064. * @param effect The effect we are binfing the information for
  61065. */
  61066. bindShadowLight(lightIndex: string, effect: Effect): void;
  61067. /**
  61068. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  61069. * (eq to view projection * shadow projection matrices)
  61070. * @returns The transform matrix used to create the shadow map
  61071. */
  61072. getTransformMatrix(): Matrix;
  61073. /**
  61074. * Disposes the ShadowGenerator.
  61075. * Returns nothing.
  61076. */
  61077. dispose(): void;
  61078. /**
  61079. * Serializes the shadow generator setup to a json object.
  61080. * @returns The serialized JSON object
  61081. */
  61082. serialize(): any;
  61083. /**
  61084. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  61085. * @param parsedShadowGenerator The JSON object to parse
  61086. * @param scene The scene to create the shadow map for
  61087. * @returns The parsed shadow generator
  61088. */
  61089. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  61090. }
  61091. }
  61092. declare module BABYLON {
  61093. /**
  61094. * Defines the shadow generator component responsible to manage any shadow generators
  61095. * in a given scene.
  61096. */
  61097. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  61098. /**
  61099. * The component name helpfull to identify the component in the list of scene components.
  61100. */
  61101. readonly name: string;
  61102. /**
  61103. * The scene the component belongs to.
  61104. */
  61105. scene: Scene;
  61106. /**
  61107. * Creates a new instance of the component for the given scene
  61108. * @param scene Defines the scene to register the component in
  61109. */
  61110. constructor(scene: Scene);
  61111. /**
  61112. * Registers the component in a given scene
  61113. */
  61114. register(): void;
  61115. /**
  61116. * Rebuilds the elements related to this component in case of
  61117. * context lost for instance.
  61118. */
  61119. rebuild(): void;
  61120. /**
  61121. * Serializes the component data to the specified json object
  61122. * @param serializationObject The object to serialize to
  61123. */
  61124. serialize(serializationObject: any): void;
  61125. /**
  61126. * Adds all the elements from the container to the scene
  61127. * @param container the container holding the elements
  61128. */
  61129. addFromContainer(container: AbstractScene): void;
  61130. /**
  61131. * Removes all the elements in the container from the scene
  61132. * @param container contains the elements to remove
  61133. * @param dispose if the removed element should be disposed (default: false)
  61134. */
  61135. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61136. /**
  61137. * Rebuilds the elements related to this component in case of
  61138. * context lost for instance.
  61139. */
  61140. dispose(): void;
  61141. private _gatherRenderTargets;
  61142. }
  61143. }
  61144. declare module BABYLON {
  61145. /**
  61146. * A point light is a light defined by an unique point in world space.
  61147. * The light is emitted in every direction from this point.
  61148. * A good example of a point light is a standard light bulb.
  61149. * Documentation: https://doc.babylonjs.com/babylon101/lights
  61150. */
  61151. export class PointLight extends ShadowLight {
  61152. private _shadowAngle;
  61153. /**
  61154. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61155. * This specifies what angle the shadow will use to be created.
  61156. *
  61157. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61158. */
  61159. get shadowAngle(): number;
  61160. /**
  61161. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61162. * This specifies what angle the shadow will use to be created.
  61163. *
  61164. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61165. */
  61166. set shadowAngle(value: number);
  61167. /**
  61168. * Gets the direction if it has been set.
  61169. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61170. */
  61171. get direction(): Vector3;
  61172. /**
  61173. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61174. */
  61175. set direction(value: Vector3);
  61176. /**
  61177. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  61178. * A PointLight emits the light in every direction.
  61179. * It can cast shadows.
  61180. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  61181. * ```javascript
  61182. * var pointLight = new PointLight("pl", camera.position, scene);
  61183. * ```
  61184. * Documentation : https://doc.babylonjs.com/babylon101/lights
  61185. * @param name The light friendly name
  61186. * @param position The position of the point light in the scene
  61187. * @param scene The scene the lights belongs to
  61188. */
  61189. constructor(name: string, position: Vector3, scene: Scene);
  61190. /**
  61191. * Returns the string "PointLight"
  61192. * @returns the class name
  61193. */
  61194. getClassName(): string;
  61195. /**
  61196. * Returns the integer 0.
  61197. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  61198. */
  61199. getTypeID(): number;
  61200. /**
  61201. * Specifies wether or not the shadowmap should be a cube texture.
  61202. * @returns true if the shadowmap needs to be a cube texture.
  61203. */
  61204. needCube(): boolean;
  61205. /**
  61206. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  61207. * @param faceIndex The index of the face we are computed the direction to generate shadow
  61208. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  61209. */
  61210. getShadowDirection(faceIndex?: number): Vector3;
  61211. /**
  61212. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  61213. * - fov = PI / 2
  61214. * - aspect ratio : 1.0
  61215. * - z-near and far equal to the active camera minZ and maxZ.
  61216. * Returns the PointLight.
  61217. */
  61218. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61219. protected _buildUniformLayout(): void;
  61220. /**
  61221. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  61222. * @param effect The effect to update
  61223. * @param lightIndex The index of the light in the effect to update
  61224. * @returns The point light
  61225. */
  61226. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  61227. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  61228. /**
  61229. * Prepares the list of defines specific to the light type.
  61230. * @param defines the list of defines
  61231. * @param lightIndex defines the index of the light for the effect
  61232. */
  61233. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  61234. }
  61235. }
  61236. declare module BABYLON {
  61237. /**
  61238. * Header information of HDR texture files.
  61239. */
  61240. export interface HDRInfo {
  61241. /**
  61242. * The height of the texture in pixels.
  61243. */
  61244. height: number;
  61245. /**
  61246. * The width of the texture in pixels.
  61247. */
  61248. width: number;
  61249. /**
  61250. * The index of the beginning of the data in the binary file.
  61251. */
  61252. dataPosition: number;
  61253. }
  61254. /**
  61255. * This groups tools to convert HDR texture to native colors array.
  61256. */
  61257. export class HDRTools {
  61258. private static Ldexp;
  61259. private static Rgbe2float;
  61260. private static readStringLine;
  61261. /**
  61262. * Reads header information from an RGBE texture stored in a native array.
  61263. * More information on this format are available here:
  61264. * https://en.wikipedia.org/wiki/RGBE_image_format
  61265. *
  61266. * @param uint8array The binary file stored in native array.
  61267. * @return The header information.
  61268. */
  61269. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  61270. /**
  61271. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  61272. * This RGBE texture needs to store the information as a panorama.
  61273. *
  61274. * More information on this format are available here:
  61275. * https://en.wikipedia.org/wiki/RGBE_image_format
  61276. *
  61277. * @param buffer The binary file stored in an array buffer.
  61278. * @param size The expected size of the extracted cubemap.
  61279. * @return The Cube Map information.
  61280. */
  61281. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  61282. /**
  61283. * Returns the pixels data extracted from an RGBE texture.
  61284. * This pixels will be stored left to right up to down in the R G B order in one array.
  61285. *
  61286. * More information on this format are available here:
  61287. * https://en.wikipedia.org/wiki/RGBE_image_format
  61288. *
  61289. * @param uint8array The binary file stored in an array buffer.
  61290. * @param hdrInfo The header information of the file.
  61291. * @return The pixels data in RGB right to left up to down order.
  61292. */
  61293. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  61294. private static RGBE_ReadPixels_RLE;
  61295. private static RGBE_ReadPixels_NOT_RLE;
  61296. }
  61297. }
  61298. declare module BABYLON {
  61299. /**
  61300. * Effect Render Options
  61301. */
  61302. export interface IEffectRendererOptions {
  61303. /**
  61304. * Defines the vertices positions.
  61305. */
  61306. positions?: number[];
  61307. /**
  61308. * Defines the indices.
  61309. */
  61310. indices?: number[];
  61311. }
  61312. /**
  61313. * Helper class to render one or more effects.
  61314. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  61315. */
  61316. export class EffectRenderer {
  61317. private engine;
  61318. private static _DefaultOptions;
  61319. private _vertexBuffers;
  61320. private _indexBuffer;
  61321. private _fullscreenViewport;
  61322. /**
  61323. * Creates an effect renderer
  61324. * @param engine the engine to use for rendering
  61325. * @param options defines the options of the effect renderer
  61326. */
  61327. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  61328. /**
  61329. * Sets the current viewport in normalized coordinates 0-1
  61330. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  61331. */
  61332. setViewport(viewport?: Viewport): void;
  61333. /**
  61334. * Binds the embedded attributes buffer to the effect.
  61335. * @param effect Defines the effect to bind the attributes for
  61336. */
  61337. bindBuffers(effect: Effect): void;
  61338. /**
  61339. * Sets the current effect wrapper to use during draw.
  61340. * The effect needs to be ready before calling this api.
  61341. * This also sets the default full screen position attribute.
  61342. * @param effectWrapper Defines the effect to draw with
  61343. */
  61344. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  61345. /**
  61346. * Restores engine states
  61347. */
  61348. restoreStates(): void;
  61349. /**
  61350. * Draws a full screen quad.
  61351. */
  61352. draw(): void;
  61353. private isRenderTargetTexture;
  61354. /**
  61355. * renders one or more effects to a specified texture
  61356. * @param effectWrapper the effect to renderer
  61357. * @param outputTexture texture to draw to, if null it will render to the screen.
  61358. */
  61359. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  61360. /**
  61361. * Disposes of the effect renderer
  61362. */
  61363. dispose(): void;
  61364. }
  61365. /**
  61366. * Options to create an EffectWrapper
  61367. */
  61368. interface EffectWrapperCreationOptions {
  61369. /**
  61370. * Engine to use to create the effect
  61371. */
  61372. engine: ThinEngine;
  61373. /**
  61374. * Fragment shader for the effect
  61375. */
  61376. fragmentShader: string;
  61377. /**
  61378. * Use the shader store instead of direct source code
  61379. */
  61380. useShaderStore?: boolean;
  61381. /**
  61382. * Vertex shader for the effect
  61383. */
  61384. vertexShader?: string;
  61385. /**
  61386. * Attributes to use in the shader
  61387. */
  61388. attributeNames?: Array<string>;
  61389. /**
  61390. * Uniforms to use in the shader
  61391. */
  61392. uniformNames?: Array<string>;
  61393. /**
  61394. * Texture sampler names to use in the shader
  61395. */
  61396. samplerNames?: Array<string>;
  61397. /**
  61398. * Defines to use in the shader
  61399. */
  61400. defines?: Array<string>;
  61401. /**
  61402. * Callback when effect is compiled
  61403. */
  61404. onCompiled?: Nullable<(effect: Effect) => void>;
  61405. /**
  61406. * The friendly name of the effect displayed in Spector.
  61407. */
  61408. name?: string;
  61409. }
  61410. /**
  61411. * Wraps an effect to be used for rendering
  61412. */
  61413. export class EffectWrapper {
  61414. /**
  61415. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61416. */
  61417. onApplyObservable: Observable<{}>;
  61418. /**
  61419. * The underlying effect
  61420. */
  61421. effect: Effect;
  61422. /**
  61423. * Creates an effect to be renderer
  61424. * @param creationOptions options to create the effect
  61425. */
  61426. constructor(creationOptions: EffectWrapperCreationOptions);
  61427. /**
  61428. * Disposes of the effect wrapper
  61429. */
  61430. dispose(): void;
  61431. }
  61432. }
  61433. declare module BABYLON {
  61434. /** @hidden */
  61435. export var hdrFilteringVertexShader: {
  61436. name: string;
  61437. shader: string;
  61438. };
  61439. }
  61440. declare module BABYLON {
  61441. /** @hidden */
  61442. export var hdrFilteringPixelShader: {
  61443. name: string;
  61444. shader: string;
  61445. };
  61446. }
  61447. declare module BABYLON {
  61448. /**
  61449. * Options for texture filtering
  61450. */
  61451. interface IHDRFilteringOptions {
  61452. /**
  61453. * Scales pixel intensity for the input HDR map.
  61454. */
  61455. hdrScale?: number;
  61456. /**
  61457. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  61458. */
  61459. quality?: number;
  61460. }
  61461. /**
  61462. * Filters HDR maps to get correct renderings of PBR reflections
  61463. */
  61464. export class HDRFiltering {
  61465. private _engine;
  61466. private _effectRenderer;
  61467. private _effectWrapper;
  61468. private _lodGenerationOffset;
  61469. private _lodGenerationScale;
  61470. /**
  61471. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  61472. * you care about baking speed.
  61473. */
  61474. quality: number;
  61475. /**
  61476. * Scales pixel intensity for the input HDR map.
  61477. */
  61478. hdrScale: number;
  61479. /**
  61480. * Instantiates HDR filter for reflection maps
  61481. *
  61482. * @param engine Thin engine
  61483. * @param options Options
  61484. */
  61485. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  61486. private _createRenderTarget;
  61487. private _prefilterInternal;
  61488. private _createEffect;
  61489. /**
  61490. * Get a value indicating if the filter is ready to be used
  61491. * @param texture Texture to filter
  61492. * @returns true if the filter is ready
  61493. */
  61494. isReady(texture: BaseTexture): boolean;
  61495. /**
  61496. * Prefilters a cube texture to have mipmap levels representing roughness values.
  61497. * Prefiltering will be invoked at the end of next rendering pass.
  61498. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  61499. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  61500. * @param texture Texture to filter
  61501. * @param onFinished Callback when filtering is done
  61502. * @return Promise called when prefiltering is done
  61503. */
  61504. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  61505. }
  61506. }
  61507. declare module BABYLON {
  61508. /**
  61509. * This represents a texture coming from an HDR input.
  61510. *
  61511. * The only supported format is currently panorama picture stored in RGBE format.
  61512. * Example of such files can be found on HDRLib: http://hdrlib.com/
  61513. */
  61514. export class HDRCubeTexture extends BaseTexture {
  61515. private static _facesMapping;
  61516. private _generateHarmonics;
  61517. private _noMipmap;
  61518. private _prefilterOnLoad;
  61519. private _textureMatrix;
  61520. private _size;
  61521. private _onLoad;
  61522. private _onError;
  61523. /**
  61524. * The texture URL.
  61525. */
  61526. url: string;
  61527. protected _isBlocking: boolean;
  61528. /**
  61529. * Sets wether or not the texture is blocking during loading.
  61530. */
  61531. set isBlocking(value: boolean);
  61532. /**
  61533. * Gets wether or not the texture is blocking during loading.
  61534. */
  61535. get isBlocking(): boolean;
  61536. protected _rotationY: number;
  61537. /**
  61538. * Sets texture matrix rotation angle around Y axis in radians.
  61539. */
  61540. set rotationY(value: number);
  61541. /**
  61542. * Gets texture matrix rotation angle around Y axis radians.
  61543. */
  61544. get rotationY(): number;
  61545. /**
  61546. * Gets or sets the center of the bounding box associated with the cube texture
  61547. * It must define where the camera used to render the texture was set
  61548. */
  61549. boundingBoxPosition: Vector3;
  61550. private _boundingBoxSize;
  61551. /**
  61552. * Gets or sets the size of the bounding box associated with the cube texture
  61553. * When defined, the cubemap will switch to local mode
  61554. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  61555. * @example https://www.babylonjs-playground.com/#RNASML
  61556. */
  61557. set boundingBoxSize(value: Vector3);
  61558. get boundingBoxSize(): Vector3;
  61559. /**
  61560. * Instantiates an HDRTexture from the following parameters.
  61561. *
  61562. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  61563. * @param sceneOrEngine The scene or engine the texture will be used in
  61564. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61565. * @param noMipmap Forces to not generate the mipmap if true
  61566. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  61567. * @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)
  61568. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  61569. */
  61570. 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>);
  61571. /**
  61572. * Get the current class name of the texture useful for serialization or dynamic coding.
  61573. * @returns "HDRCubeTexture"
  61574. */
  61575. getClassName(): string;
  61576. /**
  61577. * Occurs when the file is raw .hdr file.
  61578. */
  61579. private loadTexture;
  61580. clone(): HDRCubeTexture;
  61581. delayLoad(): void;
  61582. /**
  61583. * Get the texture reflection matrix used to rotate/transform the reflection.
  61584. * @returns the reflection matrix
  61585. */
  61586. getReflectionTextureMatrix(): Matrix;
  61587. /**
  61588. * Set the texture reflection matrix used to rotate/transform the reflection.
  61589. * @param value Define the reflection matrix to set
  61590. */
  61591. setReflectionTextureMatrix(value: Matrix): void;
  61592. /**
  61593. * Parses a JSON representation of an HDR Texture in order to create the texture
  61594. * @param parsedTexture Define the JSON representation
  61595. * @param scene Define the scene the texture should be created in
  61596. * @param rootUrl Define the root url in case we need to load relative dependencies
  61597. * @returns the newly created texture after parsing
  61598. */
  61599. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  61600. serialize(): any;
  61601. }
  61602. }
  61603. declare module BABYLON {
  61604. /**
  61605. * Class used to control physics engine
  61606. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  61607. */
  61608. export class PhysicsEngine implements IPhysicsEngine {
  61609. private _physicsPlugin;
  61610. /**
  61611. * Global value used to control the smallest number supported by the simulation
  61612. */
  61613. static Epsilon: number;
  61614. private _impostors;
  61615. private _joints;
  61616. private _subTimeStep;
  61617. /**
  61618. * Gets the gravity vector used by the simulation
  61619. */
  61620. gravity: Vector3;
  61621. /**
  61622. * Factory used to create the default physics plugin.
  61623. * @returns The default physics plugin
  61624. */
  61625. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  61626. /**
  61627. * Creates a new Physics Engine
  61628. * @param gravity defines the gravity vector used by the simulation
  61629. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  61630. */
  61631. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  61632. /**
  61633. * Sets the gravity vector used by the simulation
  61634. * @param gravity defines the gravity vector to use
  61635. */
  61636. setGravity(gravity: Vector3): void;
  61637. /**
  61638. * Set the time step of the physics engine.
  61639. * Default is 1/60.
  61640. * To slow it down, enter 1/600 for example.
  61641. * To speed it up, 1/30
  61642. * @param newTimeStep defines the new timestep to apply to this world.
  61643. */
  61644. setTimeStep(newTimeStep?: number): void;
  61645. /**
  61646. * Get the time step of the physics engine.
  61647. * @returns the current time step
  61648. */
  61649. getTimeStep(): number;
  61650. /**
  61651. * Set the sub time step of the physics engine.
  61652. * Default is 0 meaning there is no sub steps
  61653. * To increase physics resolution precision, set a small value (like 1 ms)
  61654. * @param subTimeStep defines the new sub timestep used for physics resolution.
  61655. */
  61656. setSubTimeStep(subTimeStep?: number): void;
  61657. /**
  61658. * Get the sub time step of the physics engine.
  61659. * @returns the current sub time step
  61660. */
  61661. getSubTimeStep(): number;
  61662. /**
  61663. * Release all resources
  61664. */
  61665. dispose(): void;
  61666. /**
  61667. * Gets the name of the current physics plugin
  61668. * @returns the name of the plugin
  61669. */
  61670. getPhysicsPluginName(): string;
  61671. /**
  61672. * Adding a new impostor for the impostor tracking.
  61673. * This will be done by the impostor itself.
  61674. * @param impostor the impostor to add
  61675. */
  61676. addImpostor(impostor: PhysicsImpostor): void;
  61677. /**
  61678. * Remove an impostor from the engine.
  61679. * This impostor and its mesh will not longer be updated by the physics engine.
  61680. * @param impostor the impostor to remove
  61681. */
  61682. removeImpostor(impostor: PhysicsImpostor): void;
  61683. /**
  61684. * Add a joint to the physics engine
  61685. * @param mainImpostor defines the main impostor to which the joint is added.
  61686. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  61687. * @param joint defines the joint that will connect both impostors.
  61688. */
  61689. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61690. /**
  61691. * Removes a joint from the simulation
  61692. * @param mainImpostor defines the impostor used with the joint
  61693. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  61694. * @param joint defines the joint to remove
  61695. */
  61696. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61697. /**
  61698. * Called by the scene. No need to call it.
  61699. * @param delta defines the timespam between frames
  61700. */
  61701. _step(delta: number): void;
  61702. /**
  61703. * Gets the current plugin used to run the simulation
  61704. * @returns current plugin
  61705. */
  61706. getPhysicsPlugin(): IPhysicsEnginePlugin;
  61707. /**
  61708. * Gets the list of physic impostors
  61709. * @returns an array of PhysicsImpostor
  61710. */
  61711. getImpostors(): Array<PhysicsImpostor>;
  61712. /**
  61713. * Gets the impostor for a physics enabled object
  61714. * @param object defines the object impersonated by the impostor
  61715. * @returns the PhysicsImpostor or null if not found
  61716. */
  61717. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  61718. /**
  61719. * Gets the impostor for a physics body object
  61720. * @param body defines physics body used by the impostor
  61721. * @returns the PhysicsImpostor or null if not found
  61722. */
  61723. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  61724. /**
  61725. * Does a raycast in the physics world
  61726. * @param from when should the ray start?
  61727. * @param to when should the ray end?
  61728. * @returns PhysicsRaycastResult
  61729. */
  61730. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61731. }
  61732. }
  61733. declare module BABYLON {
  61734. /** @hidden */
  61735. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  61736. private _useDeltaForWorldStep;
  61737. world: any;
  61738. name: string;
  61739. private _physicsMaterials;
  61740. private _fixedTimeStep;
  61741. private _cannonRaycastResult;
  61742. private _raycastResult;
  61743. private _physicsBodysToRemoveAfterStep;
  61744. private _firstFrame;
  61745. BJSCANNON: any;
  61746. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  61747. setGravity(gravity: Vector3): void;
  61748. setTimeStep(timeStep: number): void;
  61749. getTimeStep(): number;
  61750. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61751. private _removeMarkedPhysicsBodiesFromWorld;
  61752. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61753. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61754. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61755. private _processChildMeshes;
  61756. removePhysicsBody(impostor: PhysicsImpostor): void;
  61757. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61758. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61759. private _addMaterial;
  61760. private _checkWithEpsilon;
  61761. private _createShape;
  61762. private _createHeightmap;
  61763. private _minus90X;
  61764. private _plus90X;
  61765. private _tmpPosition;
  61766. private _tmpDeltaPosition;
  61767. private _tmpUnityRotation;
  61768. private _updatePhysicsBodyTransformation;
  61769. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61770. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61771. isSupported(): boolean;
  61772. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61773. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61774. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61775. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61776. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61777. getBodyMass(impostor: PhysicsImpostor): number;
  61778. getBodyFriction(impostor: PhysicsImpostor): number;
  61779. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61780. getBodyRestitution(impostor: PhysicsImpostor): number;
  61781. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61782. sleepBody(impostor: PhysicsImpostor): void;
  61783. wakeUpBody(impostor: PhysicsImpostor): void;
  61784. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  61785. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  61786. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  61787. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61788. getRadius(impostor: PhysicsImpostor): number;
  61789. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61790. dispose(): void;
  61791. private _extendNamespace;
  61792. /**
  61793. * Does a raycast in the physics world
  61794. * @param from when should the ray start?
  61795. * @param to when should the ray end?
  61796. * @returns PhysicsRaycastResult
  61797. */
  61798. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61799. }
  61800. }
  61801. declare module BABYLON {
  61802. /** @hidden */
  61803. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  61804. private _useDeltaForWorldStep;
  61805. world: any;
  61806. name: string;
  61807. BJSOIMO: any;
  61808. private _raycastResult;
  61809. private _fixedTimeStep;
  61810. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  61811. setGravity(gravity: Vector3): void;
  61812. setTimeStep(timeStep: number): void;
  61813. getTimeStep(): number;
  61814. private _tmpImpostorsArray;
  61815. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61816. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61817. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61818. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61819. private _tmpPositionVector;
  61820. removePhysicsBody(impostor: PhysicsImpostor): void;
  61821. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61822. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61823. isSupported(): boolean;
  61824. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61825. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61826. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61827. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61828. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61829. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61830. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61831. getBodyMass(impostor: PhysicsImpostor): number;
  61832. getBodyFriction(impostor: PhysicsImpostor): number;
  61833. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61834. getBodyRestitution(impostor: PhysicsImpostor): number;
  61835. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61836. sleepBody(impostor: PhysicsImpostor): void;
  61837. wakeUpBody(impostor: PhysicsImpostor): void;
  61838. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  61839. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  61840. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  61841. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61842. getRadius(impostor: PhysicsImpostor): number;
  61843. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61844. dispose(): void;
  61845. /**
  61846. * Does a raycast in the physics world
  61847. * @param from when should the ray start?
  61848. * @param to when should the ray end?
  61849. * @returns PhysicsRaycastResult
  61850. */
  61851. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61852. }
  61853. }
  61854. declare module BABYLON {
  61855. /**
  61856. * AmmoJS Physics plugin
  61857. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  61858. * @see https://github.com/kripken/ammo.js/
  61859. */
  61860. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  61861. private _useDeltaForWorldStep;
  61862. /**
  61863. * Reference to the Ammo library
  61864. */
  61865. bjsAMMO: any;
  61866. /**
  61867. * Created ammoJS world which physics bodies are added to
  61868. */
  61869. world: any;
  61870. /**
  61871. * Name of the plugin
  61872. */
  61873. name: string;
  61874. private _timeStep;
  61875. private _fixedTimeStep;
  61876. private _maxSteps;
  61877. private _tmpQuaternion;
  61878. private _tmpAmmoTransform;
  61879. private _tmpAmmoQuaternion;
  61880. private _tmpAmmoConcreteContactResultCallback;
  61881. private _collisionConfiguration;
  61882. private _dispatcher;
  61883. private _overlappingPairCache;
  61884. private _solver;
  61885. private _softBodySolver;
  61886. private _tmpAmmoVectorA;
  61887. private _tmpAmmoVectorB;
  61888. private _tmpAmmoVectorC;
  61889. private _tmpAmmoVectorD;
  61890. private _tmpContactCallbackResult;
  61891. private _tmpAmmoVectorRCA;
  61892. private _tmpAmmoVectorRCB;
  61893. private _raycastResult;
  61894. private _tmpContactPoint;
  61895. private static readonly DISABLE_COLLISION_FLAG;
  61896. private static readonly KINEMATIC_FLAG;
  61897. private static readonly DISABLE_DEACTIVATION_FLAG;
  61898. /**
  61899. * Initializes the ammoJS plugin
  61900. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  61901. * @param ammoInjection can be used to inject your own ammo reference
  61902. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  61903. */
  61904. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  61905. /**
  61906. * Sets the gravity of the physics world (m/(s^2))
  61907. * @param gravity Gravity to set
  61908. */
  61909. setGravity(gravity: Vector3): void;
  61910. /**
  61911. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  61912. * @param timeStep timestep to use in seconds
  61913. */
  61914. setTimeStep(timeStep: number): void;
  61915. /**
  61916. * 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)
  61917. * @param fixedTimeStep fixedTimeStep to use in seconds
  61918. */
  61919. setFixedTimeStep(fixedTimeStep: number): void;
  61920. /**
  61921. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  61922. * @param maxSteps the maximum number of steps by the physics engine per frame
  61923. */
  61924. setMaxSteps(maxSteps: number): void;
  61925. /**
  61926. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  61927. * @returns the current timestep in seconds
  61928. */
  61929. getTimeStep(): number;
  61930. /**
  61931. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  61932. */
  61933. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  61934. private _isImpostorInContact;
  61935. private _isImpostorPairInContact;
  61936. private _stepSimulation;
  61937. /**
  61938. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  61939. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  61940. * After the step the babylon meshes are set to the position of the physics imposters
  61941. * @param delta amount of time to step forward
  61942. * @param impostors array of imposters to update before/after the step
  61943. */
  61944. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61945. /**
  61946. * Update babylon mesh to match physics world object
  61947. * @param impostor imposter to match
  61948. */
  61949. private _afterSoftStep;
  61950. /**
  61951. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61952. * @param impostor imposter to match
  61953. */
  61954. private _ropeStep;
  61955. /**
  61956. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61957. * @param impostor imposter to match
  61958. */
  61959. private _softbodyOrClothStep;
  61960. private _tmpMatrix;
  61961. /**
  61962. * Applies an impulse on the imposter
  61963. * @param impostor imposter to apply impulse to
  61964. * @param force amount of force to be applied to the imposter
  61965. * @param contactPoint the location to apply the impulse on the imposter
  61966. */
  61967. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61968. /**
  61969. * Applies a force on the imposter
  61970. * @param impostor imposter to apply force
  61971. * @param force amount of force to be applied to the imposter
  61972. * @param contactPoint the location to apply the force on the imposter
  61973. */
  61974. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61975. /**
  61976. * Creates a physics body using the plugin
  61977. * @param impostor the imposter to create the physics body on
  61978. */
  61979. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61980. /**
  61981. * Removes the physics body from the imposter and disposes of the body's memory
  61982. * @param impostor imposter to remove the physics body from
  61983. */
  61984. removePhysicsBody(impostor: PhysicsImpostor): void;
  61985. /**
  61986. * Generates a joint
  61987. * @param impostorJoint the imposter joint to create the joint with
  61988. */
  61989. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61990. /**
  61991. * Removes a joint
  61992. * @param impostorJoint the imposter joint to remove the joint from
  61993. */
  61994. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61995. private _addMeshVerts;
  61996. /**
  61997. * Initialise the soft body vertices to match its object's (mesh) vertices
  61998. * Softbody vertices (nodes) are in world space and to match this
  61999. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  62000. * @param impostor to create the softbody for
  62001. */
  62002. private _softVertexData;
  62003. /**
  62004. * Create an impostor's soft body
  62005. * @param impostor to create the softbody for
  62006. */
  62007. private _createSoftbody;
  62008. /**
  62009. * Create cloth for an impostor
  62010. * @param impostor to create the softbody for
  62011. */
  62012. private _createCloth;
  62013. /**
  62014. * Create rope for an impostor
  62015. * @param impostor to create the softbody for
  62016. */
  62017. private _createRope;
  62018. /**
  62019. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  62020. * @param impostor to create the custom physics shape for
  62021. */
  62022. private _createCustom;
  62023. private _addHullVerts;
  62024. private _createShape;
  62025. /**
  62026. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  62027. * @param impostor imposter containing the physics body and babylon object
  62028. */
  62029. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62030. /**
  62031. * Sets the babylon object's position/rotation from the physics body's position/rotation
  62032. * @param impostor imposter containing the physics body and babylon object
  62033. * @param newPosition new position
  62034. * @param newRotation new rotation
  62035. */
  62036. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62037. /**
  62038. * If this plugin is supported
  62039. * @returns true if its supported
  62040. */
  62041. isSupported(): boolean;
  62042. /**
  62043. * Sets the linear velocity of the physics body
  62044. * @param impostor imposter to set the velocity on
  62045. * @param velocity velocity to set
  62046. */
  62047. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62048. /**
  62049. * Sets the angular velocity of the physics body
  62050. * @param impostor imposter to set the velocity on
  62051. * @param velocity velocity to set
  62052. */
  62053. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62054. /**
  62055. * gets the linear velocity
  62056. * @param impostor imposter to get linear velocity from
  62057. * @returns linear velocity
  62058. */
  62059. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62060. /**
  62061. * gets the angular velocity
  62062. * @param impostor imposter to get angular velocity from
  62063. * @returns angular velocity
  62064. */
  62065. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62066. /**
  62067. * Sets the mass of physics body
  62068. * @param impostor imposter to set the mass on
  62069. * @param mass mass to set
  62070. */
  62071. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62072. /**
  62073. * Gets the mass of the physics body
  62074. * @param impostor imposter to get the mass from
  62075. * @returns mass
  62076. */
  62077. getBodyMass(impostor: PhysicsImpostor): number;
  62078. /**
  62079. * Gets friction of the impostor
  62080. * @param impostor impostor to get friction from
  62081. * @returns friction value
  62082. */
  62083. getBodyFriction(impostor: PhysicsImpostor): number;
  62084. /**
  62085. * Sets friction of the impostor
  62086. * @param impostor impostor to set friction on
  62087. * @param friction friction value
  62088. */
  62089. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62090. /**
  62091. * Gets restitution of the impostor
  62092. * @param impostor impostor to get restitution from
  62093. * @returns restitution value
  62094. */
  62095. getBodyRestitution(impostor: PhysicsImpostor): number;
  62096. /**
  62097. * Sets resitution of the impostor
  62098. * @param impostor impostor to set resitution on
  62099. * @param restitution resitution value
  62100. */
  62101. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62102. /**
  62103. * Gets pressure inside the impostor
  62104. * @param impostor impostor to get pressure from
  62105. * @returns pressure value
  62106. */
  62107. getBodyPressure(impostor: PhysicsImpostor): number;
  62108. /**
  62109. * Sets pressure inside a soft body impostor
  62110. * Cloth and rope must remain 0 pressure
  62111. * @param impostor impostor to set pressure on
  62112. * @param pressure pressure value
  62113. */
  62114. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  62115. /**
  62116. * Gets stiffness of the impostor
  62117. * @param impostor impostor to get stiffness from
  62118. * @returns pressure value
  62119. */
  62120. getBodyStiffness(impostor: PhysicsImpostor): number;
  62121. /**
  62122. * Sets stiffness of the impostor
  62123. * @param impostor impostor to set stiffness on
  62124. * @param stiffness stiffness value from 0 to 1
  62125. */
  62126. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  62127. /**
  62128. * Gets velocityIterations of the impostor
  62129. * @param impostor impostor to get velocity iterations from
  62130. * @returns velocityIterations value
  62131. */
  62132. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  62133. /**
  62134. * Sets velocityIterations of the impostor
  62135. * @param impostor impostor to set velocity iterations on
  62136. * @param velocityIterations velocityIterations value
  62137. */
  62138. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  62139. /**
  62140. * Gets positionIterations of the impostor
  62141. * @param impostor impostor to get position iterations from
  62142. * @returns positionIterations value
  62143. */
  62144. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  62145. /**
  62146. * Sets positionIterations of the impostor
  62147. * @param impostor impostor to set position on
  62148. * @param positionIterations positionIterations value
  62149. */
  62150. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  62151. /**
  62152. * Append an anchor to a cloth object
  62153. * @param impostor is the cloth impostor to add anchor to
  62154. * @param otherImpostor is the rigid impostor to anchor to
  62155. * @param width ratio across width from 0 to 1
  62156. * @param height ratio up height from 0 to 1
  62157. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  62158. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62159. */
  62160. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62161. /**
  62162. * Append an hook to a rope object
  62163. * @param impostor is the rope impostor to add hook to
  62164. * @param otherImpostor is the rigid impostor to hook to
  62165. * @param length ratio along the rope from 0 to 1
  62166. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  62167. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62168. */
  62169. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62170. /**
  62171. * Sleeps the physics body and stops it from being active
  62172. * @param impostor impostor to sleep
  62173. */
  62174. sleepBody(impostor: PhysicsImpostor): void;
  62175. /**
  62176. * Activates the physics body
  62177. * @param impostor impostor to activate
  62178. */
  62179. wakeUpBody(impostor: PhysicsImpostor): void;
  62180. /**
  62181. * Updates the distance parameters of the joint
  62182. * @param joint joint to update
  62183. * @param maxDistance maximum distance of the joint
  62184. * @param minDistance minimum distance of the joint
  62185. */
  62186. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62187. /**
  62188. * Sets a motor on the joint
  62189. * @param joint joint to set motor on
  62190. * @param speed speed of the motor
  62191. * @param maxForce maximum force of the motor
  62192. * @param motorIndex index of the motor
  62193. */
  62194. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62195. /**
  62196. * Sets the motors limit
  62197. * @param joint joint to set limit on
  62198. * @param upperLimit upper limit
  62199. * @param lowerLimit lower limit
  62200. */
  62201. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62202. /**
  62203. * Syncs the position and rotation of a mesh with the impostor
  62204. * @param mesh mesh to sync
  62205. * @param impostor impostor to update the mesh with
  62206. */
  62207. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62208. /**
  62209. * Gets the radius of the impostor
  62210. * @param impostor impostor to get radius from
  62211. * @returns the radius
  62212. */
  62213. getRadius(impostor: PhysicsImpostor): number;
  62214. /**
  62215. * Gets the box size of the impostor
  62216. * @param impostor impostor to get box size from
  62217. * @param result the resulting box size
  62218. */
  62219. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62220. /**
  62221. * Disposes of the impostor
  62222. */
  62223. dispose(): void;
  62224. /**
  62225. * Does a raycast in the physics world
  62226. * @param from when should the ray start?
  62227. * @param to when should the ray end?
  62228. * @returns PhysicsRaycastResult
  62229. */
  62230. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62231. }
  62232. }
  62233. declare module BABYLON {
  62234. interface AbstractScene {
  62235. /**
  62236. * The list of reflection probes added to the scene
  62237. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62238. */
  62239. reflectionProbes: Array<ReflectionProbe>;
  62240. /**
  62241. * Removes the given reflection probe from this scene.
  62242. * @param toRemove The reflection probe to remove
  62243. * @returns The index of the removed reflection probe
  62244. */
  62245. removeReflectionProbe(toRemove: ReflectionProbe): number;
  62246. /**
  62247. * Adds the given reflection probe to this scene.
  62248. * @param newReflectionProbe The reflection probe to add
  62249. */
  62250. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  62251. }
  62252. /**
  62253. * Class used to generate realtime reflection / refraction cube textures
  62254. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62255. */
  62256. export class ReflectionProbe {
  62257. /** defines the name of the probe */
  62258. name: string;
  62259. private _scene;
  62260. private _renderTargetTexture;
  62261. private _projectionMatrix;
  62262. private _viewMatrix;
  62263. private _target;
  62264. private _add;
  62265. private _attachedMesh;
  62266. private _invertYAxis;
  62267. /** Gets or sets probe position (center of the cube map) */
  62268. position: Vector3;
  62269. /**
  62270. * Creates a new reflection probe
  62271. * @param name defines the name of the probe
  62272. * @param size defines the texture resolution (for each face)
  62273. * @param scene defines the hosting scene
  62274. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  62275. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  62276. */
  62277. constructor(
  62278. /** defines the name of the probe */
  62279. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  62280. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  62281. get samples(): number;
  62282. set samples(value: number);
  62283. /** Gets or sets the refresh rate to use (on every frame by default) */
  62284. get refreshRate(): number;
  62285. set refreshRate(value: number);
  62286. /**
  62287. * Gets the hosting scene
  62288. * @returns a Scene
  62289. */
  62290. getScene(): Scene;
  62291. /** Gets the internal CubeTexture used to render to */
  62292. get cubeTexture(): RenderTargetTexture;
  62293. /** Gets the list of meshes to render */
  62294. get renderList(): Nullable<AbstractMesh[]>;
  62295. /**
  62296. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  62297. * @param mesh defines the mesh to attach to
  62298. */
  62299. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  62300. /**
  62301. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  62302. * @param renderingGroupId The rendering group id corresponding to its index
  62303. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  62304. */
  62305. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  62306. /**
  62307. * Clean all associated resources
  62308. */
  62309. dispose(): void;
  62310. /**
  62311. * Converts the reflection probe information to a readable string for debug purpose.
  62312. * @param fullDetails Supports for multiple levels of logging within scene loading
  62313. * @returns the human readable reflection probe info
  62314. */
  62315. toString(fullDetails?: boolean): string;
  62316. /**
  62317. * Get the class name of the relfection probe.
  62318. * @returns "ReflectionProbe"
  62319. */
  62320. getClassName(): string;
  62321. /**
  62322. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  62323. * @returns The JSON representation of the texture
  62324. */
  62325. serialize(): any;
  62326. /**
  62327. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  62328. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  62329. * @param scene Define the scene the parsed reflection probe should be instantiated in
  62330. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  62331. * @returns The parsed reflection probe if successful
  62332. */
  62333. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  62334. }
  62335. }
  62336. declare module BABYLON {
  62337. /** @hidden */
  62338. export var _BabylonLoaderRegistered: boolean;
  62339. /**
  62340. * Helps setting up some configuration for the babylon file loader.
  62341. */
  62342. export class BabylonFileLoaderConfiguration {
  62343. /**
  62344. * The loader does not allow injecting custom physix engine into the plugins.
  62345. * Unfortunately in ES6, we need to manually inject them into the plugin.
  62346. * So you could set this variable to your engine import to make it work.
  62347. */
  62348. static LoaderInjectedPhysicsEngine: any;
  62349. }
  62350. }
  62351. declare module BABYLON {
  62352. /**
  62353. * The Physically based simple base material of BJS.
  62354. *
  62355. * This enables better naming and convention enforcements on top of the pbrMaterial.
  62356. * It is used as the base class for both the specGloss and metalRough conventions.
  62357. */
  62358. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  62359. /**
  62360. * Number of Simultaneous lights allowed on the material.
  62361. */
  62362. maxSimultaneousLights: number;
  62363. /**
  62364. * If sets to true, disables all the lights affecting the material.
  62365. */
  62366. disableLighting: boolean;
  62367. /**
  62368. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  62369. */
  62370. environmentTexture: BaseTexture;
  62371. /**
  62372. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  62373. */
  62374. invertNormalMapX: boolean;
  62375. /**
  62376. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  62377. */
  62378. invertNormalMapY: boolean;
  62379. /**
  62380. * Normal map used in the model.
  62381. */
  62382. normalTexture: BaseTexture;
  62383. /**
  62384. * Emissivie color used to self-illuminate the model.
  62385. */
  62386. emissiveColor: Color3;
  62387. /**
  62388. * Emissivie texture used to self-illuminate the model.
  62389. */
  62390. emissiveTexture: BaseTexture;
  62391. /**
  62392. * Occlusion Channel Strenght.
  62393. */
  62394. occlusionStrength: number;
  62395. /**
  62396. * Occlusion Texture of the material (adding extra occlusion effects).
  62397. */
  62398. occlusionTexture: BaseTexture;
  62399. /**
  62400. * Defines the alpha limits in alpha test mode.
  62401. */
  62402. alphaCutOff: number;
  62403. /**
  62404. * Gets the current double sided mode.
  62405. */
  62406. get doubleSided(): boolean;
  62407. /**
  62408. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  62409. */
  62410. set doubleSided(value: boolean);
  62411. /**
  62412. * Stores the pre-calculated light information of a mesh in a texture.
  62413. */
  62414. lightmapTexture: BaseTexture;
  62415. /**
  62416. * If true, the light map contains occlusion information instead of lighting info.
  62417. */
  62418. useLightmapAsShadowmap: boolean;
  62419. /**
  62420. * Instantiates a new PBRMaterial instance.
  62421. *
  62422. * @param name The material name
  62423. * @param scene The scene the material will be use in.
  62424. */
  62425. constructor(name: string, scene: Scene);
  62426. getClassName(): string;
  62427. }
  62428. }
  62429. declare module BABYLON {
  62430. /**
  62431. * The PBR material of BJS following the metal roughness convention.
  62432. *
  62433. * This fits to the PBR convention in the GLTF definition:
  62434. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  62435. */
  62436. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  62437. /**
  62438. * The base color has two different interpretations depending on the value of metalness.
  62439. * When the material is a metal, the base color is the specific measured reflectance value
  62440. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  62441. * of the material.
  62442. */
  62443. baseColor: Color3;
  62444. /**
  62445. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  62446. * well as opacity information in the alpha channel.
  62447. */
  62448. baseTexture: BaseTexture;
  62449. /**
  62450. * Specifies the metallic scalar value of the material.
  62451. * Can also be used to scale the metalness values of the metallic texture.
  62452. */
  62453. metallic: number;
  62454. /**
  62455. * Specifies the roughness scalar value of the material.
  62456. * Can also be used to scale the roughness values of the metallic texture.
  62457. */
  62458. roughness: number;
  62459. /**
  62460. * Texture containing both the metallic value in the B channel and the
  62461. * roughness value in the G channel to keep better precision.
  62462. */
  62463. metallicRoughnessTexture: BaseTexture;
  62464. /**
  62465. * Instantiates a new PBRMetalRoughnessMaterial instance.
  62466. *
  62467. * @param name The material name
  62468. * @param scene The scene the material will be use in.
  62469. */
  62470. constructor(name: string, scene: Scene);
  62471. /**
  62472. * Return the currrent class name of the material.
  62473. */
  62474. getClassName(): string;
  62475. /**
  62476. * Makes a duplicate of the current material.
  62477. * @param name - name to use for the new material.
  62478. */
  62479. clone(name: string): PBRMetallicRoughnessMaterial;
  62480. /**
  62481. * Serialize the material to a parsable JSON object.
  62482. */
  62483. serialize(): any;
  62484. /**
  62485. * Parses a JSON object correponding to the serialize function.
  62486. */
  62487. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  62488. }
  62489. }
  62490. declare module BABYLON {
  62491. /**
  62492. * The PBR material of BJS following the specular glossiness convention.
  62493. *
  62494. * This fits to the PBR convention in the GLTF definition:
  62495. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  62496. */
  62497. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  62498. /**
  62499. * Specifies the diffuse color of the material.
  62500. */
  62501. diffuseColor: Color3;
  62502. /**
  62503. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  62504. * channel.
  62505. */
  62506. diffuseTexture: BaseTexture;
  62507. /**
  62508. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  62509. */
  62510. specularColor: Color3;
  62511. /**
  62512. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  62513. */
  62514. glossiness: number;
  62515. /**
  62516. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  62517. */
  62518. specularGlossinessTexture: BaseTexture;
  62519. /**
  62520. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  62521. *
  62522. * @param name The material name
  62523. * @param scene The scene the material will be use in.
  62524. */
  62525. constructor(name: string, scene: Scene);
  62526. /**
  62527. * Return the currrent class name of the material.
  62528. */
  62529. getClassName(): string;
  62530. /**
  62531. * Makes a duplicate of the current material.
  62532. * @param name - name to use for the new material.
  62533. */
  62534. clone(name: string): PBRSpecularGlossinessMaterial;
  62535. /**
  62536. * Serialize the material to a parsable JSON object.
  62537. */
  62538. serialize(): any;
  62539. /**
  62540. * Parses a JSON object correponding to the serialize function.
  62541. */
  62542. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  62543. }
  62544. }
  62545. declare module BABYLON {
  62546. /**
  62547. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  62548. * It can help converting any input color in a desired output one. This can then be used to create effects
  62549. * from sepia, black and white to sixties or futuristic rendering...
  62550. *
  62551. * The only supported format is currently 3dl.
  62552. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  62553. */
  62554. export class ColorGradingTexture extends BaseTexture {
  62555. /**
  62556. * The texture URL.
  62557. */
  62558. url: string;
  62559. /**
  62560. * Empty line regex stored for GC.
  62561. */
  62562. private static _noneEmptyLineRegex;
  62563. private _textureMatrix;
  62564. private _onLoad;
  62565. /**
  62566. * Instantiates a ColorGradingTexture from the following parameters.
  62567. *
  62568. * @param url The location of the color gradind data (currently only supporting 3dl)
  62569. * @param sceneOrEngine The scene or engine the texture will be used in
  62570. * @param onLoad defines a callback triggered when the texture has been loaded
  62571. */
  62572. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  62573. /**
  62574. * Fires the onload event from the constructor if requested.
  62575. */
  62576. private _triggerOnLoad;
  62577. /**
  62578. * Returns the texture matrix used in most of the material.
  62579. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  62580. */
  62581. getTextureMatrix(): Matrix;
  62582. /**
  62583. * Occurs when the file being loaded is a .3dl LUT file.
  62584. */
  62585. private load3dlTexture;
  62586. /**
  62587. * Starts the loading process of the texture.
  62588. */
  62589. private loadTexture;
  62590. /**
  62591. * Clones the color gradind texture.
  62592. */
  62593. clone(): ColorGradingTexture;
  62594. /**
  62595. * Called during delayed load for textures.
  62596. */
  62597. delayLoad(): void;
  62598. /**
  62599. * Parses a color grading texture serialized by Babylon.
  62600. * @param parsedTexture The texture information being parsedTexture
  62601. * @param scene The scene to load the texture in
  62602. * @param rootUrl The root url of the data assets to load
  62603. * @return A color gradind texture
  62604. */
  62605. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  62606. /**
  62607. * Serializes the LUT texture to json format.
  62608. */
  62609. serialize(): any;
  62610. }
  62611. }
  62612. declare module BABYLON {
  62613. /**
  62614. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  62615. */
  62616. export class EquiRectangularCubeTexture extends BaseTexture {
  62617. /** The six faces of the cube. */
  62618. private static _FacesMapping;
  62619. private _noMipmap;
  62620. private _onLoad;
  62621. private _onError;
  62622. /** The size of the cubemap. */
  62623. private _size;
  62624. /** The buffer of the image. */
  62625. private _buffer;
  62626. /** The width of the input image. */
  62627. private _width;
  62628. /** The height of the input image. */
  62629. private _height;
  62630. /** The URL to the image. */
  62631. url: string;
  62632. /**
  62633. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  62634. * @param url The location of the image
  62635. * @param scene The scene the texture will be used in
  62636. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  62637. * @param noMipmap Forces to not generate the mipmap if true
  62638. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  62639. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  62640. * @param onLoad — defines a callback called when texture is loaded
  62641. * @param onError — defines a callback called if there is an error
  62642. */
  62643. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  62644. /**
  62645. * Load the image data, by putting the image on a canvas and extracting its buffer.
  62646. */
  62647. private loadImage;
  62648. /**
  62649. * Convert the image buffer into a cubemap and create a CubeTexture.
  62650. */
  62651. private loadTexture;
  62652. /**
  62653. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  62654. * @param buffer The ArrayBuffer that should be converted.
  62655. * @returns The buffer as Float32Array.
  62656. */
  62657. private getFloat32ArrayFromArrayBuffer;
  62658. /**
  62659. * Get the current class name of the texture useful for serialization or dynamic coding.
  62660. * @returns "EquiRectangularCubeTexture"
  62661. */
  62662. getClassName(): string;
  62663. /**
  62664. * Create a clone of the current EquiRectangularCubeTexture and return it.
  62665. * @returns A clone of the current EquiRectangularCubeTexture.
  62666. */
  62667. clone(): EquiRectangularCubeTexture;
  62668. }
  62669. }
  62670. declare module BABYLON {
  62671. /**
  62672. * Defines the options related to the creation of an HtmlElementTexture
  62673. */
  62674. export interface IHtmlElementTextureOptions {
  62675. /**
  62676. * Defines wether mip maps should be created or not.
  62677. */
  62678. generateMipMaps?: boolean;
  62679. /**
  62680. * Defines the sampling mode of the texture.
  62681. */
  62682. samplingMode?: number;
  62683. /**
  62684. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  62685. */
  62686. engine: Nullable<ThinEngine>;
  62687. /**
  62688. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  62689. */
  62690. scene: Nullable<Scene>;
  62691. }
  62692. /**
  62693. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  62694. * To be as efficient as possible depending on your constraints nothing aside the first upload
  62695. * is automatically managed.
  62696. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  62697. * in your application.
  62698. *
  62699. * As the update is not automatic, you need to call them manually.
  62700. */
  62701. export class HtmlElementTexture extends BaseTexture {
  62702. /**
  62703. * The texture URL.
  62704. */
  62705. element: HTMLVideoElement | HTMLCanvasElement;
  62706. private static readonly DefaultOptions;
  62707. private _textureMatrix;
  62708. private _isVideo;
  62709. private _generateMipMaps;
  62710. private _samplingMode;
  62711. /**
  62712. * Instantiates a HtmlElementTexture from the following parameters.
  62713. *
  62714. * @param name Defines the name of the texture
  62715. * @param element Defines the video or canvas the texture is filled with
  62716. * @param options Defines the other none mandatory texture creation options
  62717. */
  62718. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  62719. private _createInternalTexture;
  62720. /**
  62721. * Returns the texture matrix used in most of the material.
  62722. */
  62723. getTextureMatrix(): Matrix;
  62724. /**
  62725. * Updates the content of the texture.
  62726. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  62727. */
  62728. update(invertY?: Nullable<boolean>): void;
  62729. }
  62730. }
  62731. declare module BABYLON {
  62732. /**
  62733. * Based on jsTGALoader - Javascript loader for TGA file
  62734. * By Vincent Thibault
  62735. * @see http://blog.robrowser.com/javascript-tga-loader.html
  62736. */
  62737. export class TGATools {
  62738. private static _TYPE_INDEXED;
  62739. private static _TYPE_RGB;
  62740. private static _TYPE_GREY;
  62741. private static _TYPE_RLE_INDEXED;
  62742. private static _TYPE_RLE_RGB;
  62743. private static _TYPE_RLE_GREY;
  62744. private static _ORIGIN_MASK;
  62745. private static _ORIGIN_SHIFT;
  62746. private static _ORIGIN_BL;
  62747. private static _ORIGIN_BR;
  62748. private static _ORIGIN_UL;
  62749. private static _ORIGIN_UR;
  62750. /**
  62751. * Gets the header of a TGA file
  62752. * @param data defines the TGA data
  62753. * @returns the header
  62754. */
  62755. static GetTGAHeader(data: Uint8Array): any;
  62756. /**
  62757. * Uploads TGA content to a Babylon Texture
  62758. * @hidden
  62759. */
  62760. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  62761. /** @hidden */
  62762. 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;
  62763. /** @hidden */
  62764. 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;
  62765. /** @hidden */
  62766. 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;
  62767. /** @hidden */
  62768. 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;
  62769. /** @hidden */
  62770. 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;
  62771. /** @hidden */
  62772. 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;
  62773. }
  62774. }
  62775. declare module BABYLON {
  62776. /**
  62777. * Implementation of the TGA Texture Loader.
  62778. * @hidden
  62779. */
  62780. export class _TGATextureLoader implements IInternalTextureLoader {
  62781. /**
  62782. * Defines wether the loader supports cascade loading the different faces.
  62783. */
  62784. readonly supportCascades: boolean;
  62785. /**
  62786. * This returns if the loader support the current file information.
  62787. * @param extension defines the file extension of the file being loaded
  62788. * @returns true if the loader can load the specified file
  62789. */
  62790. canLoad(extension: string): boolean;
  62791. /**
  62792. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62793. * @param data contains the texture data
  62794. * @param texture defines the BabylonJS internal texture
  62795. * @param createPolynomials will be true if polynomials have been requested
  62796. * @param onLoad defines the callback to trigger once the texture is ready
  62797. * @param onError defines the callback to trigger in case of error
  62798. */
  62799. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62800. /**
  62801. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62802. * @param data contains the texture data
  62803. * @param texture defines the BabylonJS internal texture
  62804. * @param callback defines the method to call once ready to upload
  62805. */
  62806. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62807. }
  62808. }
  62809. declare module BABYLON {
  62810. /**
  62811. * Info about the .basis files
  62812. */
  62813. class BasisFileInfo {
  62814. /**
  62815. * If the file has alpha
  62816. */
  62817. hasAlpha: boolean;
  62818. /**
  62819. * Info about each image of the basis file
  62820. */
  62821. images: Array<{
  62822. levels: Array<{
  62823. width: number;
  62824. height: number;
  62825. transcodedPixels: ArrayBufferView;
  62826. }>;
  62827. }>;
  62828. }
  62829. /**
  62830. * Result of transcoding a basis file
  62831. */
  62832. class TranscodeResult {
  62833. /**
  62834. * Info about the .basis file
  62835. */
  62836. fileInfo: BasisFileInfo;
  62837. /**
  62838. * Format to use when loading the file
  62839. */
  62840. format: number;
  62841. }
  62842. /**
  62843. * Configuration options for the Basis transcoder
  62844. */
  62845. export class BasisTranscodeConfiguration {
  62846. /**
  62847. * Supported compression formats used to determine the supported output format of the transcoder
  62848. */
  62849. supportedCompressionFormats?: {
  62850. /**
  62851. * etc1 compression format
  62852. */
  62853. etc1?: boolean;
  62854. /**
  62855. * s3tc compression format
  62856. */
  62857. s3tc?: boolean;
  62858. /**
  62859. * pvrtc compression format
  62860. */
  62861. pvrtc?: boolean;
  62862. /**
  62863. * etc2 compression format
  62864. */
  62865. etc2?: boolean;
  62866. };
  62867. /**
  62868. * If mipmap levels should be loaded for transcoded images (Default: true)
  62869. */
  62870. loadMipmapLevels?: boolean;
  62871. /**
  62872. * Index of a single image to load (Default: all images)
  62873. */
  62874. loadSingleImage?: number;
  62875. }
  62876. /**
  62877. * Used to load .Basis files
  62878. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  62879. */
  62880. export class BasisTools {
  62881. private static _IgnoreSupportedFormats;
  62882. /**
  62883. * URL to use when loading the basis transcoder
  62884. */
  62885. static JSModuleURL: string;
  62886. /**
  62887. * URL to use when loading the wasm module for the transcoder
  62888. */
  62889. static WasmModuleURL: string;
  62890. /**
  62891. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  62892. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  62893. * @returns internal format corresponding to the Basis format
  62894. */
  62895. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  62896. private static _WorkerPromise;
  62897. private static _Worker;
  62898. private static _actionId;
  62899. private static _CreateWorkerAsync;
  62900. /**
  62901. * Transcodes a loaded image file to compressed pixel data
  62902. * @param data image data to transcode
  62903. * @param config configuration options for the transcoding
  62904. * @returns a promise resulting in the transcoded image
  62905. */
  62906. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  62907. /**
  62908. * Loads a texture from the transcode result
  62909. * @param texture texture load to
  62910. * @param transcodeResult the result of transcoding the basis file to load from
  62911. */
  62912. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  62913. }
  62914. }
  62915. declare module BABYLON {
  62916. /**
  62917. * Loader for .basis file format
  62918. */
  62919. export class _BasisTextureLoader implements IInternalTextureLoader {
  62920. /**
  62921. * Defines whether the loader supports cascade loading the different faces.
  62922. */
  62923. readonly supportCascades: boolean;
  62924. /**
  62925. * This returns if the loader support the current file information.
  62926. * @param extension defines the file extension of the file being loaded
  62927. * @returns true if the loader can load the specified file
  62928. */
  62929. canLoad(extension: string): boolean;
  62930. /**
  62931. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62932. * @param data contains the texture data
  62933. * @param texture defines the BabylonJS internal texture
  62934. * @param createPolynomials will be true if polynomials have been requested
  62935. * @param onLoad defines the callback to trigger once the texture is ready
  62936. * @param onError defines the callback to trigger in case of error
  62937. */
  62938. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62939. /**
  62940. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62941. * @param data contains the texture data
  62942. * @param texture defines the BabylonJS internal texture
  62943. * @param callback defines the method to call once ready to upload
  62944. */
  62945. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62946. }
  62947. }
  62948. declare module BABYLON {
  62949. /**
  62950. * Defines the basic options interface of a TexturePacker Frame
  62951. */
  62952. export interface ITexturePackerFrame {
  62953. /**
  62954. * The frame ID
  62955. */
  62956. id: number;
  62957. /**
  62958. * The frames Scale
  62959. */
  62960. scale: Vector2;
  62961. /**
  62962. * The Frames offset
  62963. */
  62964. offset: Vector2;
  62965. }
  62966. /**
  62967. * This is a support class for frame Data on texture packer sets.
  62968. */
  62969. export class TexturePackerFrame implements ITexturePackerFrame {
  62970. /**
  62971. * The frame ID
  62972. */
  62973. id: number;
  62974. /**
  62975. * The frames Scale
  62976. */
  62977. scale: Vector2;
  62978. /**
  62979. * The Frames offset
  62980. */
  62981. offset: Vector2;
  62982. /**
  62983. * Initializes a texture package frame.
  62984. * @param id The numerical frame identifier
  62985. * @param scale Scalar Vector2 for UV frame
  62986. * @param offset Vector2 for the frame position in UV units.
  62987. * @returns TexturePackerFrame
  62988. */
  62989. constructor(id: number, scale: Vector2, offset: Vector2);
  62990. }
  62991. }
  62992. declare module BABYLON {
  62993. /**
  62994. * Defines the basic options interface of a TexturePacker
  62995. */
  62996. export interface ITexturePackerOptions {
  62997. /**
  62998. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  62999. */
  63000. map?: string[];
  63001. /**
  63002. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63003. */
  63004. uvsIn?: string;
  63005. /**
  63006. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63007. */
  63008. uvsOut?: string;
  63009. /**
  63010. * number representing the layout style. Defaults to LAYOUT_STRIP
  63011. */
  63012. layout?: number;
  63013. /**
  63014. * number of columns if using custom column count layout(2). This defaults to 4.
  63015. */
  63016. colnum?: number;
  63017. /**
  63018. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  63019. */
  63020. updateInputMeshes?: boolean;
  63021. /**
  63022. * boolean flag to dispose all the source textures. Defaults to true.
  63023. */
  63024. disposeSources?: boolean;
  63025. /**
  63026. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  63027. */
  63028. fillBlanks?: boolean;
  63029. /**
  63030. * string value representing the context fill style color. Defaults to 'black'.
  63031. */
  63032. customFillColor?: string;
  63033. /**
  63034. * Width and Height Value of each Frame in the TexturePacker Sets
  63035. */
  63036. frameSize?: number;
  63037. /**
  63038. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  63039. */
  63040. paddingRatio?: number;
  63041. /**
  63042. * Number that declares the fill method for the padding gutter.
  63043. */
  63044. paddingMode?: number;
  63045. /**
  63046. * If in SUBUV_COLOR padding mode what color to use.
  63047. */
  63048. paddingColor?: Color3 | Color4;
  63049. }
  63050. /**
  63051. * Defines the basic interface of a TexturePacker JSON File
  63052. */
  63053. export interface ITexturePackerJSON {
  63054. /**
  63055. * The frame ID
  63056. */
  63057. name: string;
  63058. /**
  63059. * The base64 channel data
  63060. */
  63061. sets: any;
  63062. /**
  63063. * The options of the Packer
  63064. */
  63065. options: ITexturePackerOptions;
  63066. /**
  63067. * The frame data of the Packer
  63068. */
  63069. frames: Array<number>;
  63070. }
  63071. /**
  63072. * This is a support class that generates a series of packed texture sets.
  63073. * @see https://doc.babylonjs.com/babylon101/materials
  63074. */
  63075. export class TexturePacker {
  63076. /** Packer Layout Constant 0 */
  63077. static readonly LAYOUT_STRIP: number;
  63078. /** Packer Layout Constant 1 */
  63079. static readonly LAYOUT_POWER2: number;
  63080. /** Packer Layout Constant 2 */
  63081. static readonly LAYOUT_COLNUM: number;
  63082. /** Packer Layout Constant 0 */
  63083. static readonly SUBUV_WRAP: number;
  63084. /** Packer Layout Constant 1 */
  63085. static readonly SUBUV_EXTEND: number;
  63086. /** Packer Layout Constant 2 */
  63087. static readonly SUBUV_COLOR: number;
  63088. /** The Name of the Texture Package */
  63089. name: string;
  63090. /** The scene scope of the TexturePacker */
  63091. scene: Scene;
  63092. /** The Meshes to target */
  63093. meshes: AbstractMesh[];
  63094. /** Arguments passed with the Constructor */
  63095. options: ITexturePackerOptions;
  63096. /** The promise that is started upon initialization */
  63097. promise: Nullable<Promise<TexturePacker | string>>;
  63098. /** The Container object for the channel sets that are generated */
  63099. sets: object;
  63100. /** The Container array for the frames that are generated */
  63101. frames: TexturePackerFrame[];
  63102. /** The expected number of textures the system is parsing. */
  63103. private _expecting;
  63104. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  63105. private _paddingValue;
  63106. /**
  63107. * Initializes a texture package series from an array of meshes or a single mesh.
  63108. * @param name The name of the package
  63109. * @param meshes The target meshes to compose the package from
  63110. * @param options The arguments that texture packer should follow while building.
  63111. * @param scene The scene which the textures are scoped to.
  63112. * @returns TexturePacker
  63113. */
  63114. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  63115. /**
  63116. * Starts the package process
  63117. * @param resolve The promises resolution function
  63118. * @returns TexturePacker
  63119. */
  63120. private _createFrames;
  63121. /**
  63122. * Calculates the Size of the Channel Sets
  63123. * @returns Vector2
  63124. */
  63125. private _calculateSize;
  63126. /**
  63127. * Calculates the UV data for the frames.
  63128. * @param baseSize the base frameSize
  63129. * @param padding the base frame padding
  63130. * @param dtSize size of the Dynamic Texture for that channel
  63131. * @param dtUnits is 1/dtSize
  63132. * @param update flag to update the input meshes
  63133. */
  63134. private _calculateMeshUVFrames;
  63135. /**
  63136. * Calculates the frames Offset.
  63137. * @param index of the frame
  63138. * @returns Vector2
  63139. */
  63140. private _getFrameOffset;
  63141. /**
  63142. * Updates a Mesh to the frame data
  63143. * @param mesh that is the target
  63144. * @param frameID or the frame index
  63145. */
  63146. private _updateMeshUV;
  63147. /**
  63148. * Updates a Meshes materials to use the texture packer channels
  63149. * @param m is the mesh to target
  63150. * @param force all channels on the packer to be set.
  63151. */
  63152. private _updateTextureReferences;
  63153. /**
  63154. * Public method to set a Mesh to a frame
  63155. * @param m that is the target
  63156. * @param frameID or the frame index
  63157. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  63158. */
  63159. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  63160. /**
  63161. * Starts the async promise to compile the texture packer.
  63162. * @returns Promise<void>
  63163. */
  63164. processAsync(): Promise<void>;
  63165. /**
  63166. * Disposes all textures associated with this packer
  63167. */
  63168. dispose(): void;
  63169. /**
  63170. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  63171. * @param imageType is the image type to use.
  63172. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  63173. */
  63174. download(imageType?: string, quality?: number): void;
  63175. /**
  63176. * Public method to load a texturePacker JSON file.
  63177. * @param data of the JSON file in string format.
  63178. */
  63179. updateFromJSON(data: string): void;
  63180. }
  63181. }
  63182. declare module BABYLON {
  63183. /**
  63184. * 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.
  63185. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63186. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63187. */
  63188. export class CustomProceduralTexture extends ProceduralTexture {
  63189. private _animate;
  63190. private _time;
  63191. private _config;
  63192. private _texturePath;
  63193. /**
  63194. * Instantiates a new Custom Procedural Texture.
  63195. * 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.
  63196. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63197. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63198. * @param name Define the name of the texture
  63199. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  63200. * @param size Define the size of the texture to create
  63201. * @param scene Define the scene the texture belongs to
  63202. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  63203. * @param generateMipMaps Define if the texture should creates mip maps or not
  63204. */
  63205. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63206. private _loadJson;
  63207. /**
  63208. * Is the texture ready to be used ? (rendered at least once)
  63209. * @returns true if ready, otherwise, false.
  63210. */
  63211. isReady(): boolean;
  63212. /**
  63213. * Render the texture to its associated render target.
  63214. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  63215. */
  63216. render(useCameraPostProcess?: boolean): void;
  63217. /**
  63218. * Update the list of dependant textures samplers in the shader.
  63219. */
  63220. updateTextures(): void;
  63221. /**
  63222. * Update the uniform values of the procedural texture in the shader.
  63223. */
  63224. updateShaderUniforms(): void;
  63225. /**
  63226. * Define if the texture animates or not.
  63227. */
  63228. get animate(): boolean;
  63229. set animate(value: boolean);
  63230. }
  63231. }
  63232. declare module BABYLON {
  63233. /** @hidden */
  63234. export var noisePixelShader: {
  63235. name: string;
  63236. shader: string;
  63237. };
  63238. }
  63239. declare module BABYLON {
  63240. /**
  63241. * Class used to generate noise procedural textures
  63242. */
  63243. export class NoiseProceduralTexture extends ProceduralTexture {
  63244. /** Gets or sets the start time (default is 0) */
  63245. time: number;
  63246. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  63247. brightness: number;
  63248. /** Defines the number of octaves to process */
  63249. octaves: number;
  63250. /** Defines the level of persistence (0.8 by default) */
  63251. persistence: number;
  63252. /** Gets or sets animation speed factor (default is 1) */
  63253. animationSpeedFactor: number;
  63254. /**
  63255. * Creates a new NoiseProceduralTexture
  63256. * @param name defines the name fo the texture
  63257. * @param size defines the size of the texture (default is 256)
  63258. * @param scene defines the hosting scene
  63259. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  63260. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  63261. */
  63262. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63263. private _updateShaderUniforms;
  63264. protected _getDefines(): string;
  63265. /** Generate the current state of the procedural texture */
  63266. render(useCameraPostProcess?: boolean): void;
  63267. /**
  63268. * Serializes this noise procedural texture
  63269. * @returns a serialized noise procedural texture object
  63270. */
  63271. serialize(): any;
  63272. /**
  63273. * Clone the texture.
  63274. * @returns the cloned texture
  63275. */
  63276. clone(): NoiseProceduralTexture;
  63277. /**
  63278. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  63279. * @param parsedTexture defines parsed texture data
  63280. * @param scene defines the current scene
  63281. * @param rootUrl defines the root URL containing noise procedural texture information
  63282. * @returns a parsed NoiseProceduralTexture
  63283. */
  63284. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  63285. }
  63286. }
  63287. declare module BABYLON {
  63288. /**
  63289. * Raw cube texture where the raw buffers are passed in
  63290. */
  63291. export class RawCubeTexture extends CubeTexture {
  63292. /**
  63293. * Creates a cube texture where the raw buffers are passed in.
  63294. * @param scene defines the scene the texture is attached to
  63295. * @param data defines the array of data to use to create each face
  63296. * @param size defines the size of the textures
  63297. * @param format defines the format of the data
  63298. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  63299. * @param generateMipMaps defines if the engine should generate the mip levels
  63300. * @param invertY defines if data must be stored with Y axis inverted
  63301. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  63302. * @param compression defines the compression used (null by default)
  63303. */
  63304. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  63305. /**
  63306. * Updates the raw cube texture.
  63307. * @param data defines the data to store
  63308. * @param format defines the data format
  63309. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63310. * @param invertY defines if data must be stored with Y axis inverted
  63311. * @param compression defines the compression used (null by default)
  63312. * @param level defines which level of the texture to update
  63313. */
  63314. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  63315. /**
  63316. * Updates a raw cube texture with RGBD encoded data.
  63317. * @param data defines the array of data [mipmap][face] to use to create each face
  63318. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  63319. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  63320. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  63321. * @returns a promsie that resolves when the operation is complete
  63322. */
  63323. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  63324. /**
  63325. * Clones the raw cube texture.
  63326. * @return a new cube texture
  63327. */
  63328. clone(): CubeTexture;
  63329. /** @hidden */
  63330. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  63331. }
  63332. }
  63333. declare module BABYLON {
  63334. /**
  63335. * Class used to store 2D array textures containing user data
  63336. */
  63337. export class RawTexture2DArray extends Texture {
  63338. /** Gets or sets the texture format to use */
  63339. format: number;
  63340. /**
  63341. * Create a new RawTexture2DArray
  63342. * @param data defines the data of the texture
  63343. * @param width defines the width of the texture
  63344. * @param height defines the height of the texture
  63345. * @param depth defines the number of layers of the texture
  63346. * @param format defines the texture format to use
  63347. * @param scene defines the hosting scene
  63348. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63349. * @param invertY defines if texture must be stored with Y axis inverted
  63350. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63351. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63352. */
  63353. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63354. /** Gets or sets the texture format to use */
  63355. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63356. /**
  63357. * Update the texture with new data
  63358. * @param data defines the data to store in the texture
  63359. */
  63360. update(data: ArrayBufferView): void;
  63361. }
  63362. }
  63363. declare module BABYLON {
  63364. /**
  63365. * Class used to store 3D textures containing user data
  63366. */
  63367. export class RawTexture3D extends Texture {
  63368. /** Gets or sets the texture format to use */
  63369. format: number;
  63370. /**
  63371. * Create a new RawTexture3D
  63372. * @param data defines the data of the texture
  63373. * @param width defines the width of the texture
  63374. * @param height defines the height of the texture
  63375. * @param depth defines the depth of the texture
  63376. * @param format defines the texture format to use
  63377. * @param scene defines the hosting scene
  63378. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63379. * @param invertY defines if texture must be stored with Y axis inverted
  63380. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63381. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63382. */
  63383. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63384. /** Gets or sets the texture format to use */
  63385. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63386. /**
  63387. * Update the texture with new data
  63388. * @param data defines the data to store in the texture
  63389. */
  63390. update(data: ArrayBufferView): void;
  63391. }
  63392. }
  63393. declare module BABYLON {
  63394. /**
  63395. * Creates a refraction texture used by refraction channel of the standard material.
  63396. * It is like a mirror but to see through a material.
  63397. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63398. */
  63399. export class RefractionTexture extends RenderTargetTexture {
  63400. /**
  63401. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  63402. * 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.
  63403. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63404. */
  63405. refractionPlane: Plane;
  63406. /**
  63407. * Define how deep under the surface we should see.
  63408. */
  63409. depth: number;
  63410. /**
  63411. * Creates a refraction texture used by refraction channel of the standard material.
  63412. * It is like a mirror but to see through a material.
  63413. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63414. * @param name Define the texture name
  63415. * @param size Define the size of the underlying texture
  63416. * @param scene Define the scene the refraction belongs to
  63417. * @param generateMipMaps Define if we need to generate mips level for the refraction
  63418. */
  63419. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  63420. /**
  63421. * Clone the refraction texture.
  63422. * @returns the cloned texture
  63423. */
  63424. clone(): RefractionTexture;
  63425. /**
  63426. * Serialize the texture to a JSON representation you could use in Parse later on
  63427. * @returns the serialized JSON representation
  63428. */
  63429. serialize(): any;
  63430. }
  63431. }
  63432. declare module BABYLON {
  63433. /**
  63434. * Block used to add support for vertex skinning (bones)
  63435. */
  63436. export class BonesBlock extends NodeMaterialBlock {
  63437. /**
  63438. * Creates a new BonesBlock
  63439. * @param name defines the block name
  63440. */
  63441. constructor(name: string);
  63442. /**
  63443. * Initialize the block and prepare the context for build
  63444. * @param state defines the state that will be used for the build
  63445. */
  63446. initialize(state: NodeMaterialBuildState): void;
  63447. /**
  63448. * Gets the current class name
  63449. * @returns the class name
  63450. */
  63451. getClassName(): string;
  63452. /**
  63453. * Gets the matrix indices input component
  63454. */
  63455. get matricesIndices(): NodeMaterialConnectionPoint;
  63456. /**
  63457. * Gets the matrix weights input component
  63458. */
  63459. get matricesWeights(): NodeMaterialConnectionPoint;
  63460. /**
  63461. * Gets the extra matrix indices input component
  63462. */
  63463. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  63464. /**
  63465. * Gets the extra matrix weights input component
  63466. */
  63467. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  63468. /**
  63469. * Gets the world input component
  63470. */
  63471. get world(): NodeMaterialConnectionPoint;
  63472. /**
  63473. * Gets the output component
  63474. */
  63475. get output(): NodeMaterialConnectionPoint;
  63476. autoConfigure(material: NodeMaterial): void;
  63477. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  63478. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63479. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63480. protected _buildBlock(state: NodeMaterialBuildState): this;
  63481. }
  63482. }
  63483. declare module BABYLON {
  63484. /**
  63485. * Block used to add support for instances
  63486. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  63487. */
  63488. export class InstancesBlock extends NodeMaterialBlock {
  63489. /**
  63490. * Creates a new InstancesBlock
  63491. * @param name defines the block name
  63492. */
  63493. constructor(name: string);
  63494. /**
  63495. * Gets the current class name
  63496. * @returns the class name
  63497. */
  63498. getClassName(): string;
  63499. /**
  63500. * Gets the first world row input component
  63501. */
  63502. get world0(): NodeMaterialConnectionPoint;
  63503. /**
  63504. * Gets the second world row input component
  63505. */
  63506. get world1(): NodeMaterialConnectionPoint;
  63507. /**
  63508. * Gets the third world row input component
  63509. */
  63510. get world2(): NodeMaterialConnectionPoint;
  63511. /**
  63512. * Gets the forth world row input component
  63513. */
  63514. get world3(): NodeMaterialConnectionPoint;
  63515. /**
  63516. * Gets the world input component
  63517. */
  63518. get world(): NodeMaterialConnectionPoint;
  63519. /**
  63520. * Gets the output component
  63521. */
  63522. get output(): NodeMaterialConnectionPoint;
  63523. /**
  63524. * Gets the isntanceID component
  63525. */
  63526. get instanceID(): NodeMaterialConnectionPoint;
  63527. autoConfigure(material: NodeMaterial): void;
  63528. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  63529. protected _buildBlock(state: NodeMaterialBuildState): this;
  63530. }
  63531. }
  63532. declare module BABYLON {
  63533. /**
  63534. * Block used to add morph targets support to vertex shader
  63535. */
  63536. export class MorphTargetsBlock extends NodeMaterialBlock {
  63537. private _repeatableContentAnchor;
  63538. /**
  63539. * Create a new MorphTargetsBlock
  63540. * @param name defines the block name
  63541. */
  63542. constructor(name: string);
  63543. /**
  63544. * Gets the current class name
  63545. * @returns the class name
  63546. */
  63547. getClassName(): string;
  63548. /**
  63549. * Gets the position input component
  63550. */
  63551. get position(): NodeMaterialConnectionPoint;
  63552. /**
  63553. * Gets the normal input component
  63554. */
  63555. get normal(): NodeMaterialConnectionPoint;
  63556. /**
  63557. * Gets the tangent input component
  63558. */
  63559. get tangent(): NodeMaterialConnectionPoint;
  63560. /**
  63561. * Gets the tangent input component
  63562. */
  63563. get uv(): NodeMaterialConnectionPoint;
  63564. /**
  63565. * Gets the position output component
  63566. */
  63567. get positionOutput(): NodeMaterialConnectionPoint;
  63568. /**
  63569. * Gets the normal output component
  63570. */
  63571. get normalOutput(): NodeMaterialConnectionPoint;
  63572. /**
  63573. * Gets the tangent output component
  63574. */
  63575. get tangentOutput(): NodeMaterialConnectionPoint;
  63576. /**
  63577. * Gets the tangent output component
  63578. */
  63579. get uvOutput(): NodeMaterialConnectionPoint;
  63580. initialize(state: NodeMaterialBuildState): void;
  63581. autoConfigure(material: NodeMaterial): void;
  63582. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63583. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63584. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  63585. protected _buildBlock(state: NodeMaterialBuildState): this;
  63586. }
  63587. }
  63588. declare module BABYLON {
  63589. /**
  63590. * Block used to get data information from a light
  63591. */
  63592. export class LightInformationBlock extends NodeMaterialBlock {
  63593. private _lightDataUniformName;
  63594. private _lightColorUniformName;
  63595. private _lightTypeDefineName;
  63596. /**
  63597. * Gets or sets the light associated with this block
  63598. */
  63599. light: Nullable<Light>;
  63600. /**
  63601. * Creates a new LightInformationBlock
  63602. * @param name defines the block name
  63603. */
  63604. constructor(name: string);
  63605. /**
  63606. * Gets the current class name
  63607. * @returns the class name
  63608. */
  63609. getClassName(): string;
  63610. /**
  63611. * Gets the world position input component
  63612. */
  63613. get worldPosition(): NodeMaterialConnectionPoint;
  63614. /**
  63615. * Gets the direction output component
  63616. */
  63617. get direction(): NodeMaterialConnectionPoint;
  63618. /**
  63619. * Gets the direction output component
  63620. */
  63621. get color(): NodeMaterialConnectionPoint;
  63622. /**
  63623. * Gets the direction output component
  63624. */
  63625. get intensity(): NodeMaterialConnectionPoint;
  63626. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63627. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63628. protected _buildBlock(state: NodeMaterialBuildState): this;
  63629. serialize(): any;
  63630. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63631. }
  63632. }
  63633. declare module BABYLON {
  63634. /**
  63635. * Block used to add image processing support to fragment shader
  63636. */
  63637. export class ImageProcessingBlock extends NodeMaterialBlock {
  63638. /**
  63639. * Create a new ImageProcessingBlock
  63640. * @param name defines the block name
  63641. */
  63642. constructor(name: string);
  63643. /**
  63644. * Gets the current class name
  63645. * @returns the class name
  63646. */
  63647. getClassName(): string;
  63648. /**
  63649. * Gets the color input component
  63650. */
  63651. get color(): NodeMaterialConnectionPoint;
  63652. /**
  63653. * Gets the output component
  63654. */
  63655. get output(): NodeMaterialConnectionPoint;
  63656. /**
  63657. * Initialize the block and prepare the context for build
  63658. * @param state defines the state that will be used for the build
  63659. */
  63660. initialize(state: NodeMaterialBuildState): void;
  63661. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  63662. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63663. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63664. protected _buildBlock(state: NodeMaterialBuildState): this;
  63665. }
  63666. }
  63667. declare module BABYLON {
  63668. /**
  63669. * Block used to pertub normals based on a normal map
  63670. */
  63671. export class PerturbNormalBlock extends NodeMaterialBlock {
  63672. private _tangentSpaceParameterName;
  63673. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  63674. invertX: boolean;
  63675. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  63676. invertY: boolean;
  63677. /**
  63678. * Create a new PerturbNormalBlock
  63679. * @param name defines the block name
  63680. */
  63681. constructor(name: string);
  63682. /**
  63683. * Gets the current class name
  63684. * @returns the class name
  63685. */
  63686. getClassName(): string;
  63687. /**
  63688. * Gets the world position input component
  63689. */
  63690. get worldPosition(): NodeMaterialConnectionPoint;
  63691. /**
  63692. * Gets the world normal input component
  63693. */
  63694. get worldNormal(): NodeMaterialConnectionPoint;
  63695. /**
  63696. * Gets the world tangent input component
  63697. */
  63698. get worldTangent(): NodeMaterialConnectionPoint;
  63699. /**
  63700. * Gets the uv input component
  63701. */
  63702. get uv(): NodeMaterialConnectionPoint;
  63703. /**
  63704. * Gets the normal map color input component
  63705. */
  63706. get normalMapColor(): NodeMaterialConnectionPoint;
  63707. /**
  63708. * Gets the strength input component
  63709. */
  63710. get strength(): NodeMaterialConnectionPoint;
  63711. /**
  63712. * Gets the output component
  63713. */
  63714. get output(): NodeMaterialConnectionPoint;
  63715. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63716. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63717. autoConfigure(material: NodeMaterial): void;
  63718. protected _buildBlock(state: NodeMaterialBuildState): this;
  63719. protected _dumpPropertiesCode(): string;
  63720. serialize(): any;
  63721. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63722. }
  63723. }
  63724. declare module BABYLON {
  63725. /**
  63726. * Block used to discard a pixel if a value is smaller than a cutoff
  63727. */
  63728. export class DiscardBlock extends NodeMaterialBlock {
  63729. /**
  63730. * Create a new DiscardBlock
  63731. * @param name defines the block name
  63732. */
  63733. constructor(name: string);
  63734. /**
  63735. * Gets the current class name
  63736. * @returns the class name
  63737. */
  63738. getClassName(): string;
  63739. /**
  63740. * Gets the color input component
  63741. */
  63742. get value(): NodeMaterialConnectionPoint;
  63743. /**
  63744. * Gets the cutoff input component
  63745. */
  63746. get cutoff(): NodeMaterialConnectionPoint;
  63747. protected _buildBlock(state: NodeMaterialBuildState): this;
  63748. }
  63749. }
  63750. declare module BABYLON {
  63751. /**
  63752. * Block used to test if the fragment shader is front facing
  63753. */
  63754. export class FrontFacingBlock extends NodeMaterialBlock {
  63755. /**
  63756. * Creates a new FrontFacingBlock
  63757. * @param name defines the block name
  63758. */
  63759. constructor(name: string);
  63760. /**
  63761. * Gets the current class name
  63762. * @returns the class name
  63763. */
  63764. getClassName(): string;
  63765. /**
  63766. * Gets the output component
  63767. */
  63768. get output(): NodeMaterialConnectionPoint;
  63769. protected _buildBlock(state: NodeMaterialBuildState): this;
  63770. }
  63771. }
  63772. declare module BABYLON {
  63773. /**
  63774. * Block used to get the derivative value on x and y of a given input
  63775. */
  63776. export class DerivativeBlock extends NodeMaterialBlock {
  63777. /**
  63778. * Create a new DerivativeBlock
  63779. * @param name defines the block name
  63780. */
  63781. constructor(name: string);
  63782. /**
  63783. * Gets the current class name
  63784. * @returns the class name
  63785. */
  63786. getClassName(): string;
  63787. /**
  63788. * Gets the input component
  63789. */
  63790. get input(): NodeMaterialConnectionPoint;
  63791. /**
  63792. * Gets the derivative output on x
  63793. */
  63794. get dx(): NodeMaterialConnectionPoint;
  63795. /**
  63796. * Gets the derivative output on y
  63797. */
  63798. get dy(): NodeMaterialConnectionPoint;
  63799. protected _buildBlock(state: NodeMaterialBuildState): this;
  63800. }
  63801. }
  63802. declare module BABYLON {
  63803. /**
  63804. * Block used to make gl_FragCoord available
  63805. */
  63806. export class FragCoordBlock extends NodeMaterialBlock {
  63807. /**
  63808. * Creates a new FragCoordBlock
  63809. * @param name defines the block name
  63810. */
  63811. constructor(name: string);
  63812. /**
  63813. * Gets the current class name
  63814. * @returns the class name
  63815. */
  63816. getClassName(): string;
  63817. /**
  63818. * Gets the xy component
  63819. */
  63820. get xy(): NodeMaterialConnectionPoint;
  63821. /**
  63822. * Gets the xyz component
  63823. */
  63824. get xyz(): NodeMaterialConnectionPoint;
  63825. /**
  63826. * Gets the xyzw component
  63827. */
  63828. get xyzw(): NodeMaterialConnectionPoint;
  63829. /**
  63830. * Gets the x component
  63831. */
  63832. get x(): NodeMaterialConnectionPoint;
  63833. /**
  63834. * Gets the y component
  63835. */
  63836. get y(): NodeMaterialConnectionPoint;
  63837. /**
  63838. * Gets the z component
  63839. */
  63840. get z(): NodeMaterialConnectionPoint;
  63841. /**
  63842. * Gets the w component
  63843. */
  63844. get output(): NodeMaterialConnectionPoint;
  63845. protected writeOutputs(state: NodeMaterialBuildState): string;
  63846. protected _buildBlock(state: NodeMaterialBuildState): this;
  63847. }
  63848. }
  63849. declare module BABYLON {
  63850. /**
  63851. * Block used to get the screen sizes
  63852. */
  63853. export class ScreenSizeBlock extends NodeMaterialBlock {
  63854. private _varName;
  63855. private _scene;
  63856. /**
  63857. * Creates a new ScreenSizeBlock
  63858. * @param name defines the block name
  63859. */
  63860. constructor(name: string);
  63861. /**
  63862. * Gets the current class name
  63863. * @returns the class name
  63864. */
  63865. getClassName(): string;
  63866. /**
  63867. * Gets the xy component
  63868. */
  63869. get xy(): NodeMaterialConnectionPoint;
  63870. /**
  63871. * Gets the x component
  63872. */
  63873. get x(): NodeMaterialConnectionPoint;
  63874. /**
  63875. * Gets the y component
  63876. */
  63877. get y(): NodeMaterialConnectionPoint;
  63878. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63879. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  63880. protected _buildBlock(state: NodeMaterialBuildState): this;
  63881. }
  63882. }
  63883. declare module BABYLON {
  63884. /**
  63885. * Block used to add support for scene fog
  63886. */
  63887. export class FogBlock extends NodeMaterialBlock {
  63888. private _fogDistanceName;
  63889. private _fogParameters;
  63890. /**
  63891. * Create a new FogBlock
  63892. * @param name defines the block name
  63893. */
  63894. constructor(name: string);
  63895. /**
  63896. * Gets the current class name
  63897. * @returns the class name
  63898. */
  63899. getClassName(): string;
  63900. /**
  63901. * Gets the world position input component
  63902. */
  63903. get worldPosition(): NodeMaterialConnectionPoint;
  63904. /**
  63905. * Gets the view input component
  63906. */
  63907. get view(): NodeMaterialConnectionPoint;
  63908. /**
  63909. * Gets the color input component
  63910. */
  63911. get input(): NodeMaterialConnectionPoint;
  63912. /**
  63913. * Gets the fog color input component
  63914. */
  63915. get fogColor(): NodeMaterialConnectionPoint;
  63916. /**
  63917. * Gets the output component
  63918. */
  63919. get output(): NodeMaterialConnectionPoint;
  63920. autoConfigure(material: NodeMaterial): void;
  63921. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63922. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63923. protected _buildBlock(state: NodeMaterialBuildState): this;
  63924. }
  63925. }
  63926. declare module BABYLON {
  63927. /**
  63928. * Block used to add light in the fragment shader
  63929. */
  63930. export class LightBlock extends NodeMaterialBlock {
  63931. private _lightId;
  63932. /**
  63933. * Gets or sets the light associated with this block
  63934. */
  63935. light: Nullable<Light>;
  63936. /**
  63937. * Create a new LightBlock
  63938. * @param name defines the block name
  63939. */
  63940. constructor(name: string);
  63941. /**
  63942. * Gets the current class name
  63943. * @returns the class name
  63944. */
  63945. getClassName(): string;
  63946. /**
  63947. * Gets the world position input component
  63948. */
  63949. get worldPosition(): NodeMaterialConnectionPoint;
  63950. /**
  63951. * Gets the world normal input component
  63952. */
  63953. get worldNormal(): NodeMaterialConnectionPoint;
  63954. /**
  63955. * Gets the camera (or eye) position component
  63956. */
  63957. get cameraPosition(): NodeMaterialConnectionPoint;
  63958. /**
  63959. * Gets the glossiness component
  63960. */
  63961. get glossiness(): NodeMaterialConnectionPoint;
  63962. /**
  63963. * Gets the glossinness power component
  63964. */
  63965. get glossPower(): NodeMaterialConnectionPoint;
  63966. /**
  63967. * Gets the diffuse color component
  63968. */
  63969. get diffuseColor(): NodeMaterialConnectionPoint;
  63970. /**
  63971. * Gets the specular color component
  63972. */
  63973. get specularColor(): NodeMaterialConnectionPoint;
  63974. /**
  63975. * Gets the view matrix component
  63976. */
  63977. get view(): NodeMaterialConnectionPoint;
  63978. /**
  63979. * Gets the diffuse output component
  63980. */
  63981. get diffuseOutput(): NodeMaterialConnectionPoint;
  63982. /**
  63983. * Gets the specular output component
  63984. */
  63985. get specularOutput(): NodeMaterialConnectionPoint;
  63986. /**
  63987. * Gets the shadow output component
  63988. */
  63989. get shadow(): NodeMaterialConnectionPoint;
  63990. autoConfigure(material: NodeMaterial): void;
  63991. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63992. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  63993. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63994. private _injectVertexCode;
  63995. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63996. serialize(): any;
  63997. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63998. }
  63999. }
  64000. declare module BABYLON {
  64001. /**
  64002. * Block used to read a reflection texture from a sampler
  64003. */
  64004. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  64005. /**
  64006. * Create a new ReflectionTextureBlock
  64007. * @param name defines the block name
  64008. */
  64009. constructor(name: string);
  64010. /**
  64011. * Gets the current class name
  64012. * @returns the class name
  64013. */
  64014. getClassName(): string;
  64015. /**
  64016. * Gets the world position input component
  64017. */
  64018. get position(): NodeMaterialConnectionPoint;
  64019. /**
  64020. * Gets the world position input component
  64021. */
  64022. get worldPosition(): NodeMaterialConnectionPoint;
  64023. /**
  64024. * Gets the world normal input component
  64025. */
  64026. get worldNormal(): NodeMaterialConnectionPoint;
  64027. /**
  64028. * Gets the world input component
  64029. */
  64030. get world(): NodeMaterialConnectionPoint;
  64031. /**
  64032. * Gets the camera (or eye) position component
  64033. */
  64034. get cameraPosition(): NodeMaterialConnectionPoint;
  64035. /**
  64036. * Gets the view input component
  64037. */
  64038. get view(): NodeMaterialConnectionPoint;
  64039. /**
  64040. * Gets the rgb output component
  64041. */
  64042. get rgb(): NodeMaterialConnectionPoint;
  64043. /**
  64044. * Gets the rgba output component
  64045. */
  64046. get rgba(): NodeMaterialConnectionPoint;
  64047. /**
  64048. * Gets the r output component
  64049. */
  64050. get r(): NodeMaterialConnectionPoint;
  64051. /**
  64052. * Gets the g output component
  64053. */
  64054. get g(): NodeMaterialConnectionPoint;
  64055. /**
  64056. * Gets the b output component
  64057. */
  64058. get b(): NodeMaterialConnectionPoint;
  64059. /**
  64060. * Gets the a output component
  64061. */
  64062. get a(): NodeMaterialConnectionPoint;
  64063. autoConfigure(material: NodeMaterial): void;
  64064. protected _buildBlock(state: NodeMaterialBuildState): this;
  64065. }
  64066. }
  64067. declare module BABYLON {
  64068. /**
  64069. * Block used to add 2 vectors
  64070. */
  64071. export class AddBlock extends NodeMaterialBlock {
  64072. /**
  64073. * Creates a new AddBlock
  64074. * @param name defines the block name
  64075. */
  64076. constructor(name: string);
  64077. /**
  64078. * Gets the current class name
  64079. * @returns the class name
  64080. */
  64081. getClassName(): string;
  64082. /**
  64083. * Gets the left operand input component
  64084. */
  64085. get left(): NodeMaterialConnectionPoint;
  64086. /**
  64087. * Gets the right operand input component
  64088. */
  64089. get right(): NodeMaterialConnectionPoint;
  64090. /**
  64091. * Gets the output component
  64092. */
  64093. get output(): NodeMaterialConnectionPoint;
  64094. protected _buildBlock(state: NodeMaterialBuildState): this;
  64095. }
  64096. }
  64097. declare module BABYLON {
  64098. /**
  64099. * Block used to scale a vector by a float
  64100. */
  64101. export class ScaleBlock extends NodeMaterialBlock {
  64102. /**
  64103. * Creates a new ScaleBlock
  64104. * @param name defines the block name
  64105. */
  64106. constructor(name: string);
  64107. /**
  64108. * Gets the current class name
  64109. * @returns the class name
  64110. */
  64111. getClassName(): string;
  64112. /**
  64113. * Gets the input component
  64114. */
  64115. get input(): NodeMaterialConnectionPoint;
  64116. /**
  64117. * Gets the factor input component
  64118. */
  64119. get factor(): NodeMaterialConnectionPoint;
  64120. /**
  64121. * Gets the output component
  64122. */
  64123. get output(): NodeMaterialConnectionPoint;
  64124. protected _buildBlock(state: NodeMaterialBuildState): this;
  64125. }
  64126. }
  64127. declare module BABYLON {
  64128. /**
  64129. * Block used to clamp a float
  64130. */
  64131. export class ClampBlock extends NodeMaterialBlock {
  64132. /** Gets or sets the minimum range */
  64133. minimum: number;
  64134. /** Gets or sets the maximum range */
  64135. maximum: number;
  64136. /**
  64137. * Creates a new ClampBlock
  64138. * @param name defines the block name
  64139. */
  64140. constructor(name: string);
  64141. /**
  64142. * Gets the current class name
  64143. * @returns the class name
  64144. */
  64145. getClassName(): string;
  64146. /**
  64147. * Gets the value input component
  64148. */
  64149. get value(): NodeMaterialConnectionPoint;
  64150. /**
  64151. * Gets the output component
  64152. */
  64153. get output(): NodeMaterialConnectionPoint;
  64154. protected _buildBlock(state: NodeMaterialBuildState): this;
  64155. protected _dumpPropertiesCode(): string;
  64156. serialize(): any;
  64157. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64158. }
  64159. }
  64160. declare module BABYLON {
  64161. /**
  64162. * Block used to apply a cross product between 2 vectors
  64163. */
  64164. export class CrossBlock extends NodeMaterialBlock {
  64165. /**
  64166. * Creates a new CrossBlock
  64167. * @param name defines the block name
  64168. */
  64169. constructor(name: string);
  64170. /**
  64171. * Gets the current class name
  64172. * @returns the class name
  64173. */
  64174. getClassName(): string;
  64175. /**
  64176. * Gets the left operand input component
  64177. */
  64178. get left(): NodeMaterialConnectionPoint;
  64179. /**
  64180. * Gets the right operand input component
  64181. */
  64182. get right(): NodeMaterialConnectionPoint;
  64183. /**
  64184. * Gets the output component
  64185. */
  64186. get output(): NodeMaterialConnectionPoint;
  64187. protected _buildBlock(state: NodeMaterialBuildState): this;
  64188. }
  64189. }
  64190. declare module BABYLON {
  64191. /**
  64192. * Block used to apply a dot product between 2 vectors
  64193. */
  64194. export class DotBlock extends NodeMaterialBlock {
  64195. /**
  64196. * Creates a new DotBlock
  64197. * @param name defines the block name
  64198. */
  64199. constructor(name: string);
  64200. /**
  64201. * Gets the current class name
  64202. * @returns the class name
  64203. */
  64204. getClassName(): string;
  64205. /**
  64206. * Gets the left operand input component
  64207. */
  64208. get left(): NodeMaterialConnectionPoint;
  64209. /**
  64210. * Gets the right operand input component
  64211. */
  64212. get right(): NodeMaterialConnectionPoint;
  64213. /**
  64214. * Gets the output component
  64215. */
  64216. get output(): NodeMaterialConnectionPoint;
  64217. protected _buildBlock(state: NodeMaterialBuildState): this;
  64218. }
  64219. }
  64220. declare module BABYLON {
  64221. /**
  64222. * Block used to normalize a vector
  64223. */
  64224. export class NormalizeBlock extends NodeMaterialBlock {
  64225. /**
  64226. * Creates a new NormalizeBlock
  64227. * @param name defines the block name
  64228. */
  64229. constructor(name: string);
  64230. /**
  64231. * Gets the current class name
  64232. * @returns the class name
  64233. */
  64234. getClassName(): string;
  64235. /**
  64236. * Gets the input component
  64237. */
  64238. get input(): NodeMaterialConnectionPoint;
  64239. /**
  64240. * Gets the output component
  64241. */
  64242. get output(): NodeMaterialConnectionPoint;
  64243. protected _buildBlock(state: NodeMaterialBuildState): this;
  64244. }
  64245. }
  64246. declare module BABYLON {
  64247. /**
  64248. * Block used to create a Color3/4 out of individual inputs (one for each component)
  64249. */
  64250. export class ColorMergerBlock extends NodeMaterialBlock {
  64251. /**
  64252. * Create a new ColorMergerBlock
  64253. * @param name defines the block name
  64254. */
  64255. constructor(name: string);
  64256. /**
  64257. * Gets the current class name
  64258. * @returns the class name
  64259. */
  64260. getClassName(): string;
  64261. /**
  64262. * Gets the rgb component (input)
  64263. */
  64264. get rgbIn(): NodeMaterialConnectionPoint;
  64265. /**
  64266. * Gets the r component (input)
  64267. */
  64268. get r(): NodeMaterialConnectionPoint;
  64269. /**
  64270. * Gets the g component (input)
  64271. */
  64272. get g(): NodeMaterialConnectionPoint;
  64273. /**
  64274. * Gets the b component (input)
  64275. */
  64276. get b(): NodeMaterialConnectionPoint;
  64277. /**
  64278. * Gets the a component (input)
  64279. */
  64280. get a(): NodeMaterialConnectionPoint;
  64281. /**
  64282. * Gets the rgba component (output)
  64283. */
  64284. get rgba(): NodeMaterialConnectionPoint;
  64285. /**
  64286. * Gets the rgb component (output)
  64287. */
  64288. get rgbOut(): NodeMaterialConnectionPoint;
  64289. /**
  64290. * Gets the rgb component (output)
  64291. * @deprecated Please use rgbOut instead.
  64292. */
  64293. get rgb(): NodeMaterialConnectionPoint;
  64294. protected _buildBlock(state: NodeMaterialBuildState): this;
  64295. }
  64296. }
  64297. declare module BABYLON {
  64298. /**
  64299. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  64300. */
  64301. export class VectorSplitterBlock extends NodeMaterialBlock {
  64302. /**
  64303. * Create a new VectorSplitterBlock
  64304. * @param name defines the block name
  64305. */
  64306. constructor(name: string);
  64307. /**
  64308. * Gets the current class name
  64309. * @returns the class name
  64310. */
  64311. getClassName(): string;
  64312. /**
  64313. * Gets the xyzw component (input)
  64314. */
  64315. get xyzw(): NodeMaterialConnectionPoint;
  64316. /**
  64317. * Gets the xyz component (input)
  64318. */
  64319. get xyzIn(): NodeMaterialConnectionPoint;
  64320. /**
  64321. * Gets the xy component (input)
  64322. */
  64323. get xyIn(): NodeMaterialConnectionPoint;
  64324. /**
  64325. * Gets the xyz component (output)
  64326. */
  64327. get xyzOut(): NodeMaterialConnectionPoint;
  64328. /**
  64329. * Gets the xy component (output)
  64330. */
  64331. get xyOut(): NodeMaterialConnectionPoint;
  64332. /**
  64333. * Gets the x component (output)
  64334. */
  64335. get x(): NodeMaterialConnectionPoint;
  64336. /**
  64337. * Gets the y component (output)
  64338. */
  64339. get y(): NodeMaterialConnectionPoint;
  64340. /**
  64341. * Gets the z component (output)
  64342. */
  64343. get z(): NodeMaterialConnectionPoint;
  64344. /**
  64345. * Gets the w component (output)
  64346. */
  64347. get w(): NodeMaterialConnectionPoint;
  64348. protected _inputRename(name: string): string;
  64349. protected _outputRename(name: string): string;
  64350. protected _buildBlock(state: NodeMaterialBuildState): this;
  64351. }
  64352. }
  64353. declare module BABYLON {
  64354. /**
  64355. * Block used to lerp between 2 values
  64356. */
  64357. export class LerpBlock extends NodeMaterialBlock {
  64358. /**
  64359. * Creates a new LerpBlock
  64360. * @param name defines the block name
  64361. */
  64362. constructor(name: string);
  64363. /**
  64364. * Gets the current class name
  64365. * @returns the class name
  64366. */
  64367. getClassName(): string;
  64368. /**
  64369. * Gets the left operand input component
  64370. */
  64371. get left(): NodeMaterialConnectionPoint;
  64372. /**
  64373. * Gets the right operand input component
  64374. */
  64375. get right(): NodeMaterialConnectionPoint;
  64376. /**
  64377. * Gets the gradient operand input component
  64378. */
  64379. get gradient(): NodeMaterialConnectionPoint;
  64380. /**
  64381. * Gets the output component
  64382. */
  64383. get output(): NodeMaterialConnectionPoint;
  64384. protected _buildBlock(state: NodeMaterialBuildState): this;
  64385. }
  64386. }
  64387. declare module BABYLON {
  64388. /**
  64389. * Block used to divide 2 vectors
  64390. */
  64391. export class DivideBlock extends NodeMaterialBlock {
  64392. /**
  64393. * Creates a new DivideBlock
  64394. * @param name defines the block name
  64395. */
  64396. constructor(name: string);
  64397. /**
  64398. * Gets the current class name
  64399. * @returns the class name
  64400. */
  64401. getClassName(): string;
  64402. /**
  64403. * Gets the left operand input component
  64404. */
  64405. get left(): NodeMaterialConnectionPoint;
  64406. /**
  64407. * Gets the right operand input component
  64408. */
  64409. get right(): NodeMaterialConnectionPoint;
  64410. /**
  64411. * Gets the output component
  64412. */
  64413. get output(): NodeMaterialConnectionPoint;
  64414. protected _buildBlock(state: NodeMaterialBuildState): this;
  64415. }
  64416. }
  64417. declare module BABYLON {
  64418. /**
  64419. * Block used to subtract 2 vectors
  64420. */
  64421. export class SubtractBlock extends NodeMaterialBlock {
  64422. /**
  64423. * Creates a new SubtractBlock
  64424. * @param name defines the block name
  64425. */
  64426. constructor(name: string);
  64427. /**
  64428. * Gets the current class name
  64429. * @returns the class name
  64430. */
  64431. getClassName(): string;
  64432. /**
  64433. * Gets the left operand input component
  64434. */
  64435. get left(): NodeMaterialConnectionPoint;
  64436. /**
  64437. * Gets the right operand input component
  64438. */
  64439. get right(): NodeMaterialConnectionPoint;
  64440. /**
  64441. * Gets the output component
  64442. */
  64443. get output(): NodeMaterialConnectionPoint;
  64444. protected _buildBlock(state: NodeMaterialBuildState): this;
  64445. }
  64446. }
  64447. declare module BABYLON {
  64448. /**
  64449. * Block used to step a value
  64450. */
  64451. export class StepBlock extends NodeMaterialBlock {
  64452. /**
  64453. * Creates a new StepBlock
  64454. * @param name defines the block name
  64455. */
  64456. constructor(name: string);
  64457. /**
  64458. * Gets the current class name
  64459. * @returns the class name
  64460. */
  64461. getClassName(): string;
  64462. /**
  64463. * Gets the value operand input component
  64464. */
  64465. get value(): NodeMaterialConnectionPoint;
  64466. /**
  64467. * Gets the edge operand input component
  64468. */
  64469. get edge(): NodeMaterialConnectionPoint;
  64470. /**
  64471. * Gets the output component
  64472. */
  64473. get output(): NodeMaterialConnectionPoint;
  64474. protected _buildBlock(state: NodeMaterialBuildState): this;
  64475. }
  64476. }
  64477. declare module BABYLON {
  64478. /**
  64479. * Block used to get the opposite (1 - x) of a value
  64480. */
  64481. export class OneMinusBlock extends NodeMaterialBlock {
  64482. /**
  64483. * Creates a new OneMinusBlock
  64484. * @param name defines the block name
  64485. */
  64486. constructor(name: string);
  64487. /**
  64488. * Gets the current class name
  64489. * @returns the class name
  64490. */
  64491. getClassName(): string;
  64492. /**
  64493. * Gets the input component
  64494. */
  64495. get input(): NodeMaterialConnectionPoint;
  64496. /**
  64497. * Gets the output component
  64498. */
  64499. get output(): NodeMaterialConnectionPoint;
  64500. protected _buildBlock(state: NodeMaterialBuildState): this;
  64501. }
  64502. }
  64503. declare module BABYLON {
  64504. /**
  64505. * Block used to get the view direction
  64506. */
  64507. export class ViewDirectionBlock extends NodeMaterialBlock {
  64508. /**
  64509. * Creates a new ViewDirectionBlock
  64510. * @param name defines the block name
  64511. */
  64512. constructor(name: string);
  64513. /**
  64514. * Gets the current class name
  64515. * @returns the class name
  64516. */
  64517. getClassName(): string;
  64518. /**
  64519. * Gets the world position component
  64520. */
  64521. get worldPosition(): NodeMaterialConnectionPoint;
  64522. /**
  64523. * Gets the camera position component
  64524. */
  64525. get cameraPosition(): NodeMaterialConnectionPoint;
  64526. /**
  64527. * Gets the output component
  64528. */
  64529. get output(): NodeMaterialConnectionPoint;
  64530. autoConfigure(material: NodeMaterial): void;
  64531. protected _buildBlock(state: NodeMaterialBuildState): this;
  64532. }
  64533. }
  64534. declare module BABYLON {
  64535. /**
  64536. * Block used to compute fresnel value
  64537. */
  64538. export class FresnelBlock extends NodeMaterialBlock {
  64539. /**
  64540. * Create a new FresnelBlock
  64541. * @param name defines the block name
  64542. */
  64543. constructor(name: string);
  64544. /**
  64545. * Gets the current class name
  64546. * @returns the class name
  64547. */
  64548. getClassName(): string;
  64549. /**
  64550. * Gets the world normal input component
  64551. */
  64552. get worldNormal(): NodeMaterialConnectionPoint;
  64553. /**
  64554. * Gets the view direction input component
  64555. */
  64556. get viewDirection(): NodeMaterialConnectionPoint;
  64557. /**
  64558. * Gets the bias input component
  64559. */
  64560. get bias(): NodeMaterialConnectionPoint;
  64561. /**
  64562. * Gets the camera (or eye) position component
  64563. */
  64564. get power(): NodeMaterialConnectionPoint;
  64565. /**
  64566. * Gets the fresnel output component
  64567. */
  64568. get fresnel(): NodeMaterialConnectionPoint;
  64569. autoConfigure(material: NodeMaterial): void;
  64570. protected _buildBlock(state: NodeMaterialBuildState): this;
  64571. }
  64572. }
  64573. declare module BABYLON {
  64574. /**
  64575. * Block used to get the max of 2 values
  64576. */
  64577. export class MaxBlock extends NodeMaterialBlock {
  64578. /**
  64579. * Creates a new MaxBlock
  64580. * @param name defines the block name
  64581. */
  64582. constructor(name: string);
  64583. /**
  64584. * Gets the current class name
  64585. * @returns the class name
  64586. */
  64587. getClassName(): string;
  64588. /**
  64589. * Gets the left operand input component
  64590. */
  64591. get left(): NodeMaterialConnectionPoint;
  64592. /**
  64593. * Gets the right operand input component
  64594. */
  64595. get right(): NodeMaterialConnectionPoint;
  64596. /**
  64597. * Gets the output component
  64598. */
  64599. get output(): NodeMaterialConnectionPoint;
  64600. protected _buildBlock(state: NodeMaterialBuildState): this;
  64601. }
  64602. }
  64603. declare module BABYLON {
  64604. /**
  64605. * Block used to get the min of 2 values
  64606. */
  64607. export class MinBlock extends NodeMaterialBlock {
  64608. /**
  64609. * Creates a new MinBlock
  64610. * @param name defines the block name
  64611. */
  64612. constructor(name: string);
  64613. /**
  64614. * Gets the current class name
  64615. * @returns the class name
  64616. */
  64617. getClassName(): string;
  64618. /**
  64619. * Gets the left operand input component
  64620. */
  64621. get left(): NodeMaterialConnectionPoint;
  64622. /**
  64623. * Gets the right operand input component
  64624. */
  64625. get right(): NodeMaterialConnectionPoint;
  64626. /**
  64627. * Gets the output component
  64628. */
  64629. get output(): NodeMaterialConnectionPoint;
  64630. protected _buildBlock(state: NodeMaterialBuildState): this;
  64631. }
  64632. }
  64633. declare module BABYLON {
  64634. /**
  64635. * Block used to get the distance between 2 values
  64636. */
  64637. export class DistanceBlock extends NodeMaterialBlock {
  64638. /**
  64639. * Creates a new DistanceBlock
  64640. * @param name defines the block name
  64641. */
  64642. constructor(name: string);
  64643. /**
  64644. * Gets the current class name
  64645. * @returns the class name
  64646. */
  64647. getClassName(): string;
  64648. /**
  64649. * Gets the left operand input component
  64650. */
  64651. get left(): NodeMaterialConnectionPoint;
  64652. /**
  64653. * Gets the right operand input component
  64654. */
  64655. get right(): NodeMaterialConnectionPoint;
  64656. /**
  64657. * Gets the output component
  64658. */
  64659. get output(): NodeMaterialConnectionPoint;
  64660. protected _buildBlock(state: NodeMaterialBuildState): this;
  64661. }
  64662. }
  64663. declare module BABYLON {
  64664. /**
  64665. * Block used to get the length of a vector
  64666. */
  64667. export class LengthBlock extends NodeMaterialBlock {
  64668. /**
  64669. * Creates a new LengthBlock
  64670. * @param name defines the block name
  64671. */
  64672. constructor(name: string);
  64673. /**
  64674. * Gets the current class name
  64675. * @returns the class name
  64676. */
  64677. getClassName(): string;
  64678. /**
  64679. * Gets the value input component
  64680. */
  64681. get value(): NodeMaterialConnectionPoint;
  64682. /**
  64683. * Gets the output component
  64684. */
  64685. get output(): NodeMaterialConnectionPoint;
  64686. protected _buildBlock(state: NodeMaterialBuildState): this;
  64687. }
  64688. }
  64689. declare module BABYLON {
  64690. /**
  64691. * Block used to get negative version of a value (i.e. x * -1)
  64692. */
  64693. export class NegateBlock extends NodeMaterialBlock {
  64694. /**
  64695. * Creates a new NegateBlock
  64696. * @param name defines the block name
  64697. */
  64698. constructor(name: string);
  64699. /**
  64700. * Gets the current class name
  64701. * @returns the class name
  64702. */
  64703. getClassName(): string;
  64704. /**
  64705. * Gets the value input component
  64706. */
  64707. get value(): NodeMaterialConnectionPoint;
  64708. /**
  64709. * Gets the output component
  64710. */
  64711. get output(): NodeMaterialConnectionPoint;
  64712. protected _buildBlock(state: NodeMaterialBuildState): this;
  64713. }
  64714. }
  64715. declare module BABYLON {
  64716. /**
  64717. * Block used to get the value of the first parameter raised to the power of the second
  64718. */
  64719. export class PowBlock extends NodeMaterialBlock {
  64720. /**
  64721. * Creates a new PowBlock
  64722. * @param name defines the block name
  64723. */
  64724. constructor(name: string);
  64725. /**
  64726. * Gets the current class name
  64727. * @returns the class name
  64728. */
  64729. getClassName(): string;
  64730. /**
  64731. * Gets the value operand input component
  64732. */
  64733. get value(): NodeMaterialConnectionPoint;
  64734. /**
  64735. * Gets the power operand input component
  64736. */
  64737. get power(): NodeMaterialConnectionPoint;
  64738. /**
  64739. * Gets the output component
  64740. */
  64741. get output(): NodeMaterialConnectionPoint;
  64742. protected _buildBlock(state: NodeMaterialBuildState): this;
  64743. }
  64744. }
  64745. declare module BABYLON {
  64746. /**
  64747. * Block used to get a random number
  64748. */
  64749. export class RandomNumberBlock extends NodeMaterialBlock {
  64750. /**
  64751. * Creates a new RandomNumberBlock
  64752. * @param name defines the block name
  64753. */
  64754. constructor(name: string);
  64755. /**
  64756. * Gets the current class name
  64757. * @returns the class name
  64758. */
  64759. getClassName(): string;
  64760. /**
  64761. * Gets the seed input component
  64762. */
  64763. get seed(): NodeMaterialConnectionPoint;
  64764. /**
  64765. * Gets the output component
  64766. */
  64767. get output(): NodeMaterialConnectionPoint;
  64768. protected _buildBlock(state: NodeMaterialBuildState): this;
  64769. }
  64770. }
  64771. declare module BABYLON {
  64772. /**
  64773. * Block used to compute arc tangent of 2 values
  64774. */
  64775. export class ArcTan2Block extends NodeMaterialBlock {
  64776. /**
  64777. * Creates a new ArcTan2Block
  64778. * @param name defines the block name
  64779. */
  64780. constructor(name: string);
  64781. /**
  64782. * Gets the current class name
  64783. * @returns the class name
  64784. */
  64785. getClassName(): string;
  64786. /**
  64787. * Gets the x operand input component
  64788. */
  64789. get x(): NodeMaterialConnectionPoint;
  64790. /**
  64791. * Gets the y operand input component
  64792. */
  64793. get y(): NodeMaterialConnectionPoint;
  64794. /**
  64795. * Gets the output component
  64796. */
  64797. get output(): NodeMaterialConnectionPoint;
  64798. protected _buildBlock(state: NodeMaterialBuildState): this;
  64799. }
  64800. }
  64801. declare module BABYLON {
  64802. /**
  64803. * Block used to smooth step a value
  64804. */
  64805. export class SmoothStepBlock extends NodeMaterialBlock {
  64806. /**
  64807. * Creates a new SmoothStepBlock
  64808. * @param name defines the block name
  64809. */
  64810. constructor(name: string);
  64811. /**
  64812. * Gets the current class name
  64813. * @returns the class name
  64814. */
  64815. getClassName(): string;
  64816. /**
  64817. * Gets the value operand input component
  64818. */
  64819. get value(): NodeMaterialConnectionPoint;
  64820. /**
  64821. * Gets the first edge operand input component
  64822. */
  64823. get edge0(): NodeMaterialConnectionPoint;
  64824. /**
  64825. * Gets the second edge operand input component
  64826. */
  64827. get edge1(): NodeMaterialConnectionPoint;
  64828. /**
  64829. * Gets the output component
  64830. */
  64831. get output(): NodeMaterialConnectionPoint;
  64832. protected _buildBlock(state: NodeMaterialBuildState): this;
  64833. }
  64834. }
  64835. declare module BABYLON {
  64836. /**
  64837. * Block used to get the reciprocal (1 / x) of a value
  64838. */
  64839. export class ReciprocalBlock extends NodeMaterialBlock {
  64840. /**
  64841. * Creates a new ReciprocalBlock
  64842. * @param name defines the block name
  64843. */
  64844. constructor(name: string);
  64845. /**
  64846. * Gets the current class name
  64847. * @returns the class name
  64848. */
  64849. getClassName(): string;
  64850. /**
  64851. * Gets the input component
  64852. */
  64853. get input(): NodeMaterialConnectionPoint;
  64854. /**
  64855. * Gets the output component
  64856. */
  64857. get output(): NodeMaterialConnectionPoint;
  64858. protected _buildBlock(state: NodeMaterialBuildState): this;
  64859. }
  64860. }
  64861. declare module BABYLON {
  64862. /**
  64863. * Block used to replace a color by another one
  64864. */
  64865. export class ReplaceColorBlock extends NodeMaterialBlock {
  64866. /**
  64867. * Creates a new ReplaceColorBlock
  64868. * @param name defines the block name
  64869. */
  64870. constructor(name: string);
  64871. /**
  64872. * Gets the current class name
  64873. * @returns the class name
  64874. */
  64875. getClassName(): string;
  64876. /**
  64877. * Gets the value input component
  64878. */
  64879. get value(): NodeMaterialConnectionPoint;
  64880. /**
  64881. * Gets the reference input component
  64882. */
  64883. get reference(): NodeMaterialConnectionPoint;
  64884. /**
  64885. * Gets the distance input component
  64886. */
  64887. get distance(): NodeMaterialConnectionPoint;
  64888. /**
  64889. * Gets the replacement input component
  64890. */
  64891. get replacement(): NodeMaterialConnectionPoint;
  64892. /**
  64893. * Gets the output component
  64894. */
  64895. get output(): NodeMaterialConnectionPoint;
  64896. protected _buildBlock(state: NodeMaterialBuildState): this;
  64897. }
  64898. }
  64899. declare module BABYLON {
  64900. /**
  64901. * Block used to posterize a value
  64902. * @see https://en.wikipedia.org/wiki/Posterization
  64903. */
  64904. export class PosterizeBlock extends NodeMaterialBlock {
  64905. /**
  64906. * Creates a new PosterizeBlock
  64907. * @param name defines the block name
  64908. */
  64909. constructor(name: string);
  64910. /**
  64911. * Gets the current class name
  64912. * @returns the class name
  64913. */
  64914. getClassName(): string;
  64915. /**
  64916. * Gets the value input component
  64917. */
  64918. get value(): NodeMaterialConnectionPoint;
  64919. /**
  64920. * Gets the steps input component
  64921. */
  64922. get steps(): NodeMaterialConnectionPoint;
  64923. /**
  64924. * Gets the output component
  64925. */
  64926. get output(): NodeMaterialConnectionPoint;
  64927. protected _buildBlock(state: NodeMaterialBuildState): this;
  64928. }
  64929. }
  64930. declare module BABYLON {
  64931. /**
  64932. * Operations supported by the Wave block
  64933. */
  64934. export enum WaveBlockKind {
  64935. /** SawTooth */
  64936. SawTooth = 0,
  64937. /** Square */
  64938. Square = 1,
  64939. /** Triangle */
  64940. Triangle = 2
  64941. }
  64942. /**
  64943. * Block used to apply wave operation to floats
  64944. */
  64945. export class WaveBlock extends NodeMaterialBlock {
  64946. /**
  64947. * Gets or sets the kibnd of wave to be applied by the block
  64948. */
  64949. kind: WaveBlockKind;
  64950. /**
  64951. * Creates a new WaveBlock
  64952. * @param name defines the block name
  64953. */
  64954. constructor(name: string);
  64955. /**
  64956. * Gets the current class name
  64957. * @returns the class name
  64958. */
  64959. getClassName(): string;
  64960. /**
  64961. * Gets the input component
  64962. */
  64963. get input(): NodeMaterialConnectionPoint;
  64964. /**
  64965. * Gets the output component
  64966. */
  64967. get output(): NodeMaterialConnectionPoint;
  64968. protected _buildBlock(state: NodeMaterialBuildState): this;
  64969. serialize(): any;
  64970. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64971. }
  64972. }
  64973. declare module BABYLON {
  64974. /**
  64975. * Class used to store a color step for the GradientBlock
  64976. */
  64977. export class GradientBlockColorStep {
  64978. private _step;
  64979. /**
  64980. * Gets value indicating which step this color is associated with (between 0 and 1)
  64981. */
  64982. get step(): number;
  64983. /**
  64984. * Sets a value indicating which step this color is associated with (between 0 and 1)
  64985. */
  64986. set step(val: number);
  64987. private _color;
  64988. /**
  64989. * Gets the color associated with this step
  64990. */
  64991. get color(): Color3;
  64992. /**
  64993. * Sets the color associated with this step
  64994. */
  64995. set color(val: Color3);
  64996. /**
  64997. * Creates a new GradientBlockColorStep
  64998. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  64999. * @param color defines the color associated with this step
  65000. */
  65001. constructor(step: number, color: Color3);
  65002. }
  65003. /**
  65004. * Block used to return a color from a gradient based on an input value between 0 and 1
  65005. */
  65006. export class GradientBlock extends NodeMaterialBlock {
  65007. /**
  65008. * Gets or sets the list of color steps
  65009. */
  65010. colorSteps: GradientBlockColorStep[];
  65011. /** Gets an observable raised when the value is changed */
  65012. onValueChangedObservable: Observable<GradientBlock>;
  65013. /** calls observable when the value is changed*/
  65014. colorStepsUpdated(): void;
  65015. /**
  65016. * Creates a new GradientBlock
  65017. * @param name defines the block name
  65018. */
  65019. constructor(name: string);
  65020. /**
  65021. * Gets the current class name
  65022. * @returns the class name
  65023. */
  65024. getClassName(): string;
  65025. /**
  65026. * Gets the gradient input component
  65027. */
  65028. get gradient(): NodeMaterialConnectionPoint;
  65029. /**
  65030. * Gets the output component
  65031. */
  65032. get output(): NodeMaterialConnectionPoint;
  65033. private _writeColorConstant;
  65034. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65035. serialize(): any;
  65036. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65037. protected _dumpPropertiesCode(): string;
  65038. }
  65039. }
  65040. declare module BABYLON {
  65041. /**
  65042. * Block used to normalize lerp between 2 values
  65043. */
  65044. export class NLerpBlock extends NodeMaterialBlock {
  65045. /**
  65046. * Creates a new NLerpBlock
  65047. * @param name defines the block name
  65048. */
  65049. constructor(name: string);
  65050. /**
  65051. * Gets the current class name
  65052. * @returns the class name
  65053. */
  65054. getClassName(): string;
  65055. /**
  65056. * Gets the left operand input component
  65057. */
  65058. get left(): NodeMaterialConnectionPoint;
  65059. /**
  65060. * Gets the right operand input component
  65061. */
  65062. get right(): NodeMaterialConnectionPoint;
  65063. /**
  65064. * Gets the gradient operand input component
  65065. */
  65066. get gradient(): NodeMaterialConnectionPoint;
  65067. /**
  65068. * Gets the output component
  65069. */
  65070. get output(): NodeMaterialConnectionPoint;
  65071. protected _buildBlock(state: NodeMaterialBuildState): this;
  65072. }
  65073. }
  65074. declare module BABYLON {
  65075. /**
  65076. * block used to Generate a Worley Noise 3D Noise Pattern
  65077. */
  65078. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  65079. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65080. manhattanDistance: boolean;
  65081. /**
  65082. * Creates a new WorleyNoise3DBlock
  65083. * @param name defines the block name
  65084. */
  65085. constructor(name: string);
  65086. /**
  65087. * Gets the current class name
  65088. * @returns the class name
  65089. */
  65090. getClassName(): string;
  65091. /**
  65092. * Gets the seed input component
  65093. */
  65094. get seed(): NodeMaterialConnectionPoint;
  65095. /**
  65096. * Gets the jitter input component
  65097. */
  65098. get jitter(): NodeMaterialConnectionPoint;
  65099. /**
  65100. * Gets the output component
  65101. */
  65102. get output(): NodeMaterialConnectionPoint;
  65103. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65104. /**
  65105. * Exposes the properties to the UI?
  65106. */
  65107. protected _dumpPropertiesCode(): string;
  65108. /**
  65109. * Exposes the properties to the Seralize?
  65110. */
  65111. serialize(): any;
  65112. /**
  65113. * Exposes the properties to the deseralize?
  65114. */
  65115. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65116. }
  65117. }
  65118. declare module BABYLON {
  65119. /**
  65120. * block used to Generate a Simplex Perlin 3d Noise Pattern
  65121. */
  65122. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  65123. /**
  65124. * Creates a new SimplexPerlin3DBlock
  65125. * @param name defines the block name
  65126. */
  65127. constructor(name: string);
  65128. /**
  65129. * Gets the current class name
  65130. * @returns the class name
  65131. */
  65132. getClassName(): string;
  65133. /**
  65134. * Gets the seed operand input component
  65135. */
  65136. get seed(): NodeMaterialConnectionPoint;
  65137. /**
  65138. * Gets the output component
  65139. */
  65140. get output(): NodeMaterialConnectionPoint;
  65141. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65142. }
  65143. }
  65144. declare module BABYLON {
  65145. /**
  65146. * Block used to blend normals
  65147. */
  65148. export class NormalBlendBlock extends NodeMaterialBlock {
  65149. /**
  65150. * Creates a new NormalBlendBlock
  65151. * @param name defines the block name
  65152. */
  65153. constructor(name: string);
  65154. /**
  65155. * Gets the current class name
  65156. * @returns the class name
  65157. */
  65158. getClassName(): string;
  65159. /**
  65160. * Gets the first input component
  65161. */
  65162. get normalMap0(): NodeMaterialConnectionPoint;
  65163. /**
  65164. * Gets the second input component
  65165. */
  65166. get normalMap1(): NodeMaterialConnectionPoint;
  65167. /**
  65168. * Gets the output component
  65169. */
  65170. get output(): NodeMaterialConnectionPoint;
  65171. protected _buildBlock(state: NodeMaterialBuildState): this;
  65172. }
  65173. }
  65174. declare module BABYLON {
  65175. /**
  65176. * Block used to rotate a 2d vector by a given angle
  65177. */
  65178. export class Rotate2dBlock extends NodeMaterialBlock {
  65179. /**
  65180. * Creates a new Rotate2dBlock
  65181. * @param name defines the block name
  65182. */
  65183. constructor(name: string);
  65184. /**
  65185. * Gets the current class name
  65186. * @returns the class name
  65187. */
  65188. getClassName(): string;
  65189. /**
  65190. * Gets the input vector
  65191. */
  65192. get input(): NodeMaterialConnectionPoint;
  65193. /**
  65194. * Gets the input angle
  65195. */
  65196. get angle(): NodeMaterialConnectionPoint;
  65197. /**
  65198. * Gets the output component
  65199. */
  65200. get output(): NodeMaterialConnectionPoint;
  65201. autoConfigure(material: NodeMaterial): void;
  65202. protected _buildBlock(state: NodeMaterialBuildState): this;
  65203. }
  65204. }
  65205. declare module BABYLON {
  65206. /**
  65207. * Block used to get the reflected vector from a direction and a normal
  65208. */
  65209. export class ReflectBlock extends NodeMaterialBlock {
  65210. /**
  65211. * Creates a new ReflectBlock
  65212. * @param name defines the block name
  65213. */
  65214. constructor(name: string);
  65215. /**
  65216. * Gets the current class name
  65217. * @returns the class name
  65218. */
  65219. getClassName(): string;
  65220. /**
  65221. * Gets the incident component
  65222. */
  65223. get incident(): NodeMaterialConnectionPoint;
  65224. /**
  65225. * Gets the normal component
  65226. */
  65227. get normal(): NodeMaterialConnectionPoint;
  65228. /**
  65229. * Gets the output component
  65230. */
  65231. get output(): NodeMaterialConnectionPoint;
  65232. protected _buildBlock(state: NodeMaterialBuildState): this;
  65233. }
  65234. }
  65235. declare module BABYLON {
  65236. /**
  65237. * Block used to get the refracted vector from a direction and a normal
  65238. */
  65239. export class RefractBlock extends NodeMaterialBlock {
  65240. /**
  65241. * Creates a new RefractBlock
  65242. * @param name defines the block name
  65243. */
  65244. constructor(name: string);
  65245. /**
  65246. * Gets the current class name
  65247. * @returns the class name
  65248. */
  65249. getClassName(): string;
  65250. /**
  65251. * Gets the incident component
  65252. */
  65253. get incident(): NodeMaterialConnectionPoint;
  65254. /**
  65255. * Gets the normal component
  65256. */
  65257. get normal(): NodeMaterialConnectionPoint;
  65258. /**
  65259. * Gets the index of refraction component
  65260. */
  65261. get ior(): NodeMaterialConnectionPoint;
  65262. /**
  65263. * Gets the output component
  65264. */
  65265. get output(): NodeMaterialConnectionPoint;
  65266. protected _buildBlock(state: NodeMaterialBuildState): this;
  65267. }
  65268. }
  65269. declare module BABYLON {
  65270. /**
  65271. * Block used to desaturate a color
  65272. */
  65273. export class DesaturateBlock extends NodeMaterialBlock {
  65274. /**
  65275. * Creates a new DesaturateBlock
  65276. * @param name defines the block name
  65277. */
  65278. constructor(name: string);
  65279. /**
  65280. * Gets the current class name
  65281. * @returns the class name
  65282. */
  65283. getClassName(): string;
  65284. /**
  65285. * Gets the color operand input component
  65286. */
  65287. get color(): NodeMaterialConnectionPoint;
  65288. /**
  65289. * Gets the level operand input component
  65290. */
  65291. get level(): NodeMaterialConnectionPoint;
  65292. /**
  65293. * Gets the output component
  65294. */
  65295. get output(): NodeMaterialConnectionPoint;
  65296. protected _buildBlock(state: NodeMaterialBuildState): this;
  65297. }
  65298. }
  65299. declare module BABYLON {
  65300. /**
  65301. * Block used to implement the ambient occlusion module of the PBR material
  65302. */
  65303. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  65304. /**
  65305. * Create a new AmbientOcclusionBlock
  65306. * @param name defines the block name
  65307. */
  65308. constructor(name: string);
  65309. /**
  65310. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  65311. */
  65312. useAmbientInGrayScale: boolean;
  65313. /**
  65314. * Initialize the block and prepare the context for build
  65315. * @param state defines the state that will be used for the build
  65316. */
  65317. initialize(state: NodeMaterialBuildState): void;
  65318. /**
  65319. * Gets the current class name
  65320. * @returns the class name
  65321. */
  65322. getClassName(): string;
  65323. /**
  65324. * Gets the texture input component
  65325. */
  65326. get texture(): NodeMaterialConnectionPoint;
  65327. /**
  65328. * Gets the texture intensity component
  65329. */
  65330. get intensity(): NodeMaterialConnectionPoint;
  65331. /**
  65332. * Gets the direct light intensity input component
  65333. */
  65334. get directLightIntensity(): NodeMaterialConnectionPoint;
  65335. /**
  65336. * Gets the ambient occlusion object output component
  65337. */
  65338. get ambientOcc(): NodeMaterialConnectionPoint;
  65339. /**
  65340. * Gets the main code of the block (fragment side)
  65341. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  65342. * @returns the shader code
  65343. */
  65344. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  65345. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65346. protected _buildBlock(state: NodeMaterialBuildState): this;
  65347. protected _dumpPropertiesCode(): string;
  65348. serialize(): any;
  65349. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65350. }
  65351. }
  65352. declare module BABYLON {
  65353. /**
  65354. * Block used to implement the reflection module of the PBR material
  65355. */
  65356. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  65357. /** @hidden */
  65358. _defineLODReflectionAlpha: string;
  65359. /** @hidden */
  65360. _defineLinearSpecularReflection: string;
  65361. private _vEnvironmentIrradianceName;
  65362. /** @hidden */
  65363. _vReflectionMicrosurfaceInfosName: string;
  65364. /** @hidden */
  65365. _vReflectionInfosName: string;
  65366. /** @hidden */
  65367. _vReflectionFilteringInfoName: string;
  65368. private _scene;
  65369. /**
  65370. * The three properties below are set by the main PBR block prior to calling methods of this class.
  65371. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65372. * It's less burden on the user side in the editor part.
  65373. */
  65374. /** @hidden */
  65375. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65376. /** @hidden */
  65377. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65378. /** @hidden */
  65379. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  65380. /**
  65381. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  65382. * diffuse part of the IBL.
  65383. */
  65384. useSphericalHarmonics: boolean;
  65385. /**
  65386. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  65387. */
  65388. forceIrradianceInFragment: boolean;
  65389. /**
  65390. * Create a new ReflectionBlock
  65391. * @param name defines the block name
  65392. */
  65393. constructor(name: string);
  65394. /**
  65395. * Gets the current class name
  65396. * @returns the class name
  65397. */
  65398. getClassName(): string;
  65399. /**
  65400. * Gets the position input component
  65401. */
  65402. get position(): NodeMaterialConnectionPoint;
  65403. /**
  65404. * Gets the world position input component
  65405. */
  65406. get worldPosition(): NodeMaterialConnectionPoint;
  65407. /**
  65408. * Gets the world normal input component
  65409. */
  65410. get worldNormal(): NodeMaterialConnectionPoint;
  65411. /**
  65412. * Gets the world input component
  65413. */
  65414. get world(): NodeMaterialConnectionPoint;
  65415. /**
  65416. * Gets the camera (or eye) position component
  65417. */
  65418. get cameraPosition(): NodeMaterialConnectionPoint;
  65419. /**
  65420. * Gets the view input component
  65421. */
  65422. get view(): NodeMaterialConnectionPoint;
  65423. /**
  65424. * Gets the color input component
  65425. */
  65426. get color(): NodeMaterialConnectionPoint;
  65427. /**
  65428. * Gets the reflection object output component
  65429. */
  65430. get reflection(): NodeMaterialConnectionPoint;
  65431. /**
  65432. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  65433. */
  65434. get hasTexture(): boolean;
  65435. /**
  65436. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  65437. */
  65438. get reflectionColor(): string;
  65439. protected _getTexture(): Nullable<BaseTexture>;
  65440. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65441. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65442. /**
  65443. * Gets the code to inject in the vertex shader
  65444. * @param state current state of the node material building
  65445. * @returns the shader code
  65446. */
  65447. handleVertexSide(state: NodeMaterialBuildState): string;
  65448. /**
  65449. * Gets the main code of the block (fragment side)
  65450. * @param state current state of the node material building
  65451. * @param normalVarName name of the existing variable corresponding to the normal
  65452. * @returns the shader code
  65453. */
  65454. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  65455. protected _buildBlock(state: NodeMaterialBuildState): this;
  65456. protected _dumpPropertiesCode(): string;
  65457. serialize(): any;
  65458. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65459. }
  65460. }
  65461. declare module BABYLON {
  65462. /**
  65463. * Block used to implement the sheen module of the PBR material
  65464. */
  65465. export class SheenBlock extends NodeMaterialBlock {
  65466. /**
  65467. * Create a new SheenBlock
  65468. * @param name defines the block name
  65469. */
  65470. constructor(name: string);
  65471. /**
  65472. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  65473. * It allows the strength of the sheen effect to not depend on the base color of the material,
  65474. * making it easier to setup and tweak the effect
  65475. */
  65476. albedoScaling: boolean;
  65477. /**
  65478. * Defines if the sheen is linked to the sheen color.
  65479. */
  65480. linkSheenWithAlbedo: boolean;
  65481. /**
  65482. * Initialize the block and prepare the context for build
  65483. * @param state defines the state that will be used for the build
  65484. */
  65485. initialize(state: NodeMaterialBuildState): void;
  65486. /**
  65487. * Gets the current class name
  65488. * @returns the class name
  65489. */
  65490. getClassName(): string;
  65491. /**
  65492. * Gets the intensity input component
  65493. */
  65494. get intensity(): NodeMaterialConnectionPoint;
  65495. /**
  65496. * Gets the color input component
  65497. */
  65498. get color(): NodeMaterialConnectionPoint;
  65499. /**
  65500. * Gets the roughness input component
  65501. */
  65502. get roughness(): NodeMaterialConnectionPoint;
  65503. /**
  65504. * Gets the sheen object output component
  65505. */
  65506. get sheen(): NodeMaterialConnectionPoint;
  65507. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65508. /**
  65509. * Gets the main code of the block (fragment side)
  65510. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65511. * @returns the shader code
  65512. */
  65513. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  65514. protected _buildBlock(state: NodeMaterialBuildState): this;
  65515. protected _dumpPropertiesCode(): string;
  65516. serialize(): any;
  65517. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65518. }
  65519. }
  65520. declare module BABYLON {
  65521. /**
  65522. * Block used to implement the reflectivity module of the PBR material
  65523. */
  65524. export class ReflectivityBlock extends NodeMaterialBlock {
  65525. private _metallicReflectanceColor;
  65526. private _metallicF0Factor;
  65527. /** @hidden */
  65528. _vMetallicReflectanceFactorsName: string;
  65529. /**
  65530. * The property below is set by the main PBR block prior to calling methods of this class.
  65531. */
  65532. /** @hidden */
  65533. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  65534. /**
  65535. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  65536. */
  65537. useAmbientOcclusionFromMetallicTextureRed: boolean;
  65538. /**
  65539. * Specifies if the metallic texture contains the metallness information in its blue channel.
  65540. */
  65541. useMetallnessFromMetallicTextureBlue: boolean;
  65542. /**
  65543. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  65544. */
  65545. useRoughnessFromMetallicTextureAlpha: boolean;
  65546. /**
  65547. * Specifies if the metallic texture contains the roughness information in its green channel.
  65548. */
  65549. useRoughnessFromMetallicTextureGreen: boolean;
  65550. /**
  65551. * Create a new ReflectivityBlock
  65552. * @param name defines the block name
  65553. */
  65554. constructor(name: string);
  65555. /**
  65556. * Initialize the block and prepare the context for build
  65557. * @param state defines the state that will be used for the build
  65558. */
  65559. initialize(state: NodeMaterialBuildState): void;
  65560. /**
  65561. * Gets the current class name
  65562. * @returns the class name
  65563. */
  65564. getClassName(): string;
  65565. /**
  65566. * Gets the metallic input component
  65567. */
  65568. get metallic(): NodeMaterialConnectionPoint;
  65569. /**
  65570. * Gets the roughness input component
  65571. */
  65572. get roughness(): NodeMaterialConnectionPoint;
  65573. /**
  65574. * Gets the texture input component
  65575. */
  65576. get texture(): NodeMaterialConnectionPoint;
  65577. /**
  65578. * Gets the reflectivity object output component
  65579. */
  65580. get reflectivity(): NodeMaterialConnectionPoint;
  65581. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65582. /**
  65583. * Gets the main code of the block (fragment side)
  65584. * @param state current state of the node material building
  65585. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  65586. * @returns the shader code
  65587. */
  65588. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  65589. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65590. protected _buildBlock(state: NodeMaterialBuildState): this;
  65591. protected _dumpPropertiesCode(): string;
  65592. serialize(): any;
  65593. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65594. }
  65595. }
  65596. declare module BABYLON {
  65597. /**
  65598. * Block used to implement the anisotropy module of the PBR material
  65599. */
  65600. export class AnisotropyBlock extends NodeMaterialBlock {
  65601. /**
  65602. * The two properties below are set by the main PBR block prior to calling methods of this class.
  65603. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65604. * It's less burden on the user side in the editor part.
  65605. */
  65606. /** @hidden */
  65607. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65608. /** @hidden */
  65609. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65610. /**
  65611. * Create a new AnisotropyBlock
  65612. * @param name defines the block name
  65613. */
  65614. constructor(name: string);
  65615. /**
  65616. * Initialize the block and prepare the context for build
  65617. * @param state defines the state that will be used for the build
  65618. */
  65619. initialize(state: NodeMaterialBuildState): void;
  65620. /**
  65621. * Gets the current class name
  65622. * @returns the class name
  65623. */
  65624. getClassName(): string;
  65625. /**
  65626. * Gets the intensity input component
  65627. */
  65628. get intensity(): NodeMaterialConnectionPoint;
  65629. /**
  65630. * Gets the direction input component
  65631. */
  65632. get direction(): NodeMaterialConnectionPoint;
  65633. /**
  65634. * Gets the texture input component
  65635. */
  65636. get texture(): NodeMaterialConnectionPoint;
  65637. /**
  65638. * Gets the uv input component
  65639. */
  65640. get uv(): NodeMaterialConnectionPoint;
  65641. /**
  65642. * Gets the worldTangent input component
  65643. */
  65644. get worldTangent(): NodeMaterialConnectionPoint;
  65645. /**
  65646. * Gets the anisotropy object output component
  65647. */
  65648. get anisotropy(): NodeMaterialConnectionPoint;
  65649. private _generateTBNSpace;
  65650. /**
  65651. * Gets the main code of the block (fragment side)
  65652. * @param state current state of the node material building
  65653. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  65654. * @returns the shader code
  65655. */
  65656. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  65657. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65658. protected _buildBlock(state: NodeMaterialBuildState): this;
  65659. }
  65660. }
  65661. declare module BABYLON {
  65662. /**
  65663. * Block used to implement the clear coat module of the PBR material
  65664. */
  65665. export class ClearCoatBlock extends NodeMaterialBlock {
  65666. private _scene;
  65667. /**
  65668. * Create a new ClearCoatBlock
  65669. * @param name defines the block name
  65670. */
  65671. constructor(name: string);
  65672. /**
  65673. * Initialize the block and prepare the context for build
  65674. * @param state defines the state that will be used for the build
  65675. */
  65676. initialize(state: NodeMaterialBuildState): void;
  65677. /**
  65678. * Gets the current class name
  65679. * @returns the class name
  65680. */
  65681. getClassName(): string;
  65682. /**
  65683. * Gets the intensity input component
  65684. */
  65685. get intensity(): NodeMaterialConnectionPoint;
  65686. /**
  65687. * Gets the roughness input component
  65688. */
  65689. get roughness(): NodeMaterialConnectionPoint;
  65690. /**
  65691. * Gets the ior input component
  65692. */
  65693. get ior(): NodeMaterialConnectionPoint;
  65694. /**
  65695. * Gets the texture input component
  65696. */
  65697. get texture(): NodeMaterialConnectionPoint;
  65698. /**
  65699. * Gets the bump texture input component
  65700. */
  65701. get bumpTexture(): NodeMaterialConnectionPoint;
  65702. /**
  65703. * Gets the uv input component
  65704. */
  65705. get uv(): NodeMaterialConnectionPoint;
  65706. /**
  65707. * Gets the tint color input component
  65708. */
  65709. get tintColor(): NodeMaterialConnectionPoint;
  65710. /**
  65711. * Gets the tint "at distance" input component
  65712. */
  65713. get tintAtDistance(): NodeMaterialConnectionPoint;
  65714. /**
  65715. * Gets the tint thickness input component
  65716. */
  65717. get tintThickness(): NodeMaterialConnectionPoint;
  65718. /**
  65719. * Gets the world tangent input component
  65720. */
  65721. get worldTangent(): NodeMaterialConnectionPoint;
  65722. /**
  65723. * Gets the clear coat object output component
  65724. */
  65725. get clearcoat(): NodeMaterialConnectionPoint;
  65726. autoConfigure(material: NodeMaterial): void;
  65727. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65728. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65729. private _generateTBNSpace;
  65730. /**
  65731. * Gets the main code of the block (fragment side)
  65732. * @param state current state of the node material building
  65733. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  65734. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65735. * @param worldPosVarName name of the variable holding the world position
  65736. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  65737. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  65738. * @param worldNormalVarName name of the variable holding the world normal
  65739. * @returns the shader code
  65740. */
  65741. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  65742. protected _buildBlock(state: NodeMaterialBuildState): this;
  65743. }
  65744. }
  65745. declare module BABYLON {
  65746. /**
  65747. * Block used to implement the sub surface module of the PBR material
  65748. */
  65749. export class SubSurfaceBlock extends NodeMaterialBlock {
  65750. /**
  65751. * Create a new SubSurfaceBlock
  65752. * @param name defines the block name
  65753. */
  65754. constructor(name: string);
  65755. /**
  65756. * Stores the intensity of the different subsurface effects in the thickness texture.
  65757. * * the green channel is the translucency intensity.
  65758. * * the blue channel is the scattering intensity.
  65759. * * the alpha channel is the refraction intensity.
  65760. */
  65761. useMaskFromThicknessTexture: boolean;
  65762. /**
  65763. * Initialize the block and prepare the context for build
  65764. * @param state defines the state that will be used for the build
  65765. */
  65766. initialize(state: NodeMaterialBuildState): void;
  65767. /**
  65768. * Gets the current class name
  65769. * @returns the class name
  65770. */
  65771. getClassName(): string;
  65772. /**
  65773. * Gets the min thickness input component
  65774. */
  65775. get minThickness(): NodeMaterialConnectionPoint;
  65776. /**
  65777. * Gets the max thickness input component
  65778. */
  65779. get maxThickness(): NodeMaterialConnectionPoint;
  65780. /**
  65781. * Gets the thickness texture component
  65782. */
  65783. get thicknessTexture(): NodeMaterialConnectionPoint;
  65784. /**
  65785. * Gets the tint color input component
  65786. */
  65787. get tintColor(): NodeMaterialConnectionPoint;
  65788. /**
  65789. * Gets the translucency intensity input component
  65790. */
  65791. get translucencyIntensity(): NodeMaterialConnectionPoint;
  65792. /**
  65793. * Gets the translucency diffusion distance input component
  65794. */
  65795. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  65796. /**
  65797. * Gets the refraction object parameters
  65798. */
  65799. get refraction(): NodeMaterialConnectionPoint;
  65800. /**
  65801. * Gets the sub surface object output component
  65802. */
  65803. get subsurface(): NodeMaterialConnectionPoint;
  65804. autoConfigure(material: NodeMaterial): void;
  65805. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65806. /**
  65807. * Gets the main code of the block (fragment side)
  65808. * @param state current state of the node material building
  65809. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  65810. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65811. * @param worldPosVarName name of the variable holding the world position
  65812. * @returns the shader code
  65813. */
  65814. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  65815. protected _buildBlock(state: NodeMaterialBuildState): this;
  65816. }
  65817. }
  65818. declare module BABYLON {
  65819. /**
  65820. * Block used to implement the PBR metallic/roughness model
  65821. */
  65822. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  65823. /**
  65824. * Gets or sets the light associated with this block
  65825. */
  65826. light: Nullable<Light>;
  65827. private _lightId;
  65828. private _scene;
  65829. private _environmentBRDFTexture;
  65830. private _environmentBrdfSamplerName;
  65831. private _vNormalWName;
  65832. private _invertNormalName;
  65833. /**
  65834. * Create a new ReflectionBlock
  65835. * @param name defines the block name
  65836. */
  65837. constructor(name: string);
  65838. /**
  65839. * Intensity of the direct lights e.g. the four lights available in your scene.
  65840. * This impacts both the direct diffuse and specular highlights.
  65841. */
  65842. directIntensity: number;
  65843. /**
  65844. * Intensity of the environment e.g. how much the environment will light the object
  65845. * either through harmonics for rough material or through the refelction for shiny ones.
  65846. */
  65847. environmentIntensity: number;
  65848. /**
  65849. * This is a special control allowing the reduction of the specular highlights coming from the
  65850. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  65851. */
  65852. specularIntensity: number;
  65853. /**
  65854. * Defines the falloff type used in this material.
  65855. * It by default is Physical.
  65856. */
  65857. lightFalloff: number;
  65858. /**
  65859. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  65860. */
  65861. useAlphaFromAlbedoTexture: boolean;
  65862. /**
  65863. * Specifies that alpha test should be used
  65864. */
  65865. useAlphaTest: boolean;
  65866. /**
  65867. * Defines the alpha limits in alpha test mode.
  65868. */
  65869. alphaTestCutoff: number;
  65870. /**
  65871. * Specifies that alpha blending should be used
  65872. */
  65873. useAlphaBlending: boolean;
  65874. /**
  65875. * Defines if the alpha value should be determined via the rgb values.
  65876. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  65877. */
  65878. opacityRGB: boolean;
  65879. /**
  65880. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  65881. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  65882. */
  65883. useRadianceOverAlpha: boolean;
  65884. /**
  65885. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  65886. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  65887. */
  65888. useSpecularOverAlpha: boolean;
  65889. /**
  65890. * Enables specular anti aliasing in the PBR shader.
  65891. * It will both interacts on the Geometry for analytical and IBL lighting.
  65892. * It also prefilter the roughness map based on the bump values.
  65893. */
  65894. enableSpecularAntiAliasing: boolean;
  65895. /**
  65896. * Enables realtime filtering on the texture.
  65897. */
  65898. realTimeFiltering: boolean;
  65899. /**
  65900. * Quality switch for realtime filtering
  65901. */
  65902. realTimeFilteringQuality: number;
  65903. /**
  65904. * Defines if the material uses energy conservation.
  65905. */
  65906. useEnergyConservation: boolean;
  65907. /**
  65908. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  65909. * too much the area relying on ambient texture to define their ambient occlusion.
  65910. */
  65911. useRadianceOcclusion: boolean;
  65912. /**
  65913. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  65914. * makes the reflect vector face the model (under horizon).
  65915. */
  65916. useHorizonOcclusion: boolean;
  65917. /**
  65918. * If set to true, no lighting calculations will be applied.
  65919. */
  65920. unlit: boolean;
  65921. /**
  65922. * Force normal to face away from face.
  65923. */
  65924. forceNormalForward: boolean;
  65925. /**
  65926. * Defines the material debug mode.
  65927. * It helps seeing only some components of the material while troubleshooting.
  65928. */
  65929. debugMode: number;
  65930. /**
  65931. * Specify from where on screen the debug mode should start.
  65932. * The value goes from -1 (full screen) to 1 (not visible)
  65933. * It helps with side by side comparison against the final render
  65934. * This defaults to 0
  65935. */
  65936. debugLimit: number;
  65937. /**
  65938. * As the default viewing range might not be enough (if the ambient is really small for instance)
  65939. * You can use the factor to better multiply the final value.
  65940. */
  65941. debugFactor: number;
  65942. /**
  65943. * Initialize the block and prepare the context for build
  65944. * @param state defines the state that will be used for the build
  65945. */
  65946. initialize(state: NodeMaterialBuildState): void;
  65947. /**
  65948. * Gets the current class name
  65949. * @returns the class name
  65950. */
  65951. getClassName(): string;
  65952. /**
  65953. * Gets the world position input component
  65954. */
  65955. get worldPosition(): NodeMaterialConnectionPoint;
  65956. /**
  65957. * Gets the world normal input component
  65958. */
  65959. get worldNormal(): NodeMaterialConnectionPoint;
  65960. /**
  65961. * Gets the perturbed normal input component
  65962. */
  65963. get perturbedNormal(): NodeMaterialConnectionPoint;
  65964. /**
  65965. * Gets the camera position input component
  65966. */
  65967. get cameraPosition(): NodeMaterialConnectionPoint;
  65968. /**
  65969. * Gets the base color input component
  65970. */
  65971. get baseColor(): NodeMaterialConnectionPoint;
  65972. /**
  65973. * Gets the opacity texture input component
  65974. */
  65975. get opacityTexture(): NodeMaterialConnectionPoint;
  65976. /**
  65977. * Gets the ambient color input component
  65978. */
  65979. get ambientColor(): NodeMaterialConnectionPoint;
  65980. /**
  65981. * Gets the reflectivity object parameters
  65982. */
  65983. get reflectivity(): NodeMaterialConnectionPoint;
  65984. /**
  65985. * Gets the ambient occlusion object parameters
  65986. */
  65987. get ambientOcc(): NodeMaterialConnectionPoint;
  65988. /**
  65989. * Gets the reflection object parameters
  65990. */
  65991. get reflection(): NodeMaterialConnectionPoint;
  65992. /**
  65993. * Gets the sheen object parameters
  65994. */
  65995. get sheen(): NodeMaterialConnectionPoint;
  65996. /**
  65997. * Gets the clear coat object parameters
  65998. */
  65999. get clearcoat(): NodeMaterialConnectionPoint;
  66000. /**
  66001. * Gets the sub surface object parameters
  66002. */
  66003. get subsurface(): NodeMaterialConnectionPoint;
  66004. /**
  66005. * Gets the anisotropy object parameters
  66006. */
  66007. get anisotropy(): NodeMaterialConnectionPoint;
  66008. /**
  66009. * Gets the view matrix parameter
  66010. */
  66011. get view(): NodeMaterialConnectionPoint;
  66012. /**
  66013. * Gets the ambient output component
  66014. */
  66015. get ambient(): NodeMaterialConnectionPoint;
  66016. /**
  66017. * Gets the diffuse output component
  66018. */
  66019. get diffuse(): NodeMaterialConnectionPoint;
  66020. /**
  66021. * Gets the specular output component
  66022. */
  66023. get specular(): NodeMaterialConnectionPoint;
  66024. /**
  66025. * Gets the sheen output component
  66026. */
  66027. get sheenDir(): NodeMaterialConnectionPoint;
  66028. /**
  66029. * Gets the clear coat output component
  66030. */
  66031. get clearcoatDir(): NodeMaterialConnectionPoint;
  66032. /**
  66033. * Gets the indirect diffuse output component
  66034. */
  66035. get diffuseIndirect(): NodeMaterialConnectionPoint;
  66036. /**
  66037. * Gets the indirect specular output component
  66038. */
  66039. get specularIndirect(): NodeMaterialConnectionPoint;
  66040. /**
  66041. * Gets the indirect sheen output component
  66042. */
  66043. get sheenIndirect(): NodeMaterialConnectionPoint;
  66044. /**
  66045. * Gets the indirect clear coat output component
  66046. */
  66047. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  66048. /**
  66049. * Gets the refraction output component
  66050. */
  66051. get refraction(): NodeMaterialConnectionPoint;
  66052. /**
  66053. * Gets the global lighting output component
  66054. */
  66055. get lighting(): NodeMaterialConnectionPoint;
  66056. /**
  66057. * Gets the shadow output component
  66058. */
  66059. get shadow(): NodeMaterialConnectionPoint;
  66060. /**
  66061. * Gets the alpha output component
  66062. */
  66063. get alpha(): NodeMaterialConnectionPoint;
  66064. autoConfigure(material: NodeMaterial): void;
  66065. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66066. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  66067. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66068. private _injectVertexCode;
  66069. /**
  66070. * Gets the code corresponding to the albedo/opacity module
  66071. * @returns the shader code
  66072. */
  66073. getAlbedoOpacityCode(): string;
  66074. protected _buildBlock(state: NodeMaterialBuildState): this;
  66075. protected _dumpPropertiesCode(): string;
  66076. serialize(): any;
  66077. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66078. }
  66079. }
  66080. declare module BABYLON {
  66081. /**
  66082. * Block used to compute value of one parameter modulo another
  66083. */
  66084. export class ModBlock extends NodeMaterialBlock {
  66085. /**
  66086. * Creates a new ModBlock
  66087. * @param name defines the block name
  66088. */
  66089. constructor(name: string);
  66090. /**
  66091. * Gets the current class name
  66092. * @returns the class name
  66093. */
  66094. getClassName(): string;
  66095. /**
  66096. * Gets the left operand input component
  66097. */
  66098. get left(): NodeMaterialConnectionPoint;
  66099. /**
  66100. * Gets the right operand input component
  66101. */
  66102. get right(): NodeMaterialConnectionPoint;
  66103. /**
  66104. * Gets the output component
  66105. */
  66106. get output(): NodeMaterialConnectionPoint;
  66107. protected _buildBlock(state: NodeMaterialBuildState): this;
  66108. }
  66109. }
  66110. declare module BABYLON {
  66111. /**
  66112. * Configuration for Draco compression
  66113. */
  66114. export interface IDracoCompressionConfiguration {
  66115. /**
  66116. * Configuration for the decoder.
  66117. */
  66118. decoder: {
  66119. /**
  66120. * The url to the WebAssembly module.
  66121. */
  66122. wasmUrl?: string;
  66123. /**
  66124. * The url to the WebAssembly binary.
  66125. */
  66126. wasmBinaryUrl?: string;
  66127. /**
  66128. * The url to the fallback JavaScript module.
  66129. */
  66130. fallbackUrl?: string;
  66131. };
  66132. }
  66133. /**
  66134. * Draco compression (https://google.github.io/draco/)
  66135. *
  66136. * This class wraps the Draco module.
  66137. *
  66138. * **Encoder**
  66139. *
  66140. * The encoder is not currently implemented.
  66141. *
  66142. * **Decoder**
  66143. *
  66144. * 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.
  66145. *
  66146. * To update the configuration, use the following code:
  66147. * ```javascript
  66148. * DracoCompression.Configuration = {
  66149. * decoder: {
  66150. * wasmUrl: "<url to the WebAssembly library>",
  66151. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  66152. * fallbackUrl: "<url to the fallback JavaScript library>",
  66153. * }
  66154. * };
  66155. * ```
  66156. *
  66157. * 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.
  66158. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  66159. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  66160. *
  66161. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  66162. * ```javascript
  66163. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  66164. * ```
  66165. *
  66166. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  66167. */
  66168. export class DracoCompression implements IDisposable {
  66169. private _workerPoolPromise?;
  66170. private _decoderModulePromise?;
  66171. /**
  66172. * The configuration. Defaults to the following urls:
  66173. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  66174. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  66175. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  66176. */
  66177. static Configuration: IDracoCompressionConfiguration;
  66178. /**
  66179. * Returns true if the decoder configuration is available.
  66180. */
  66181. static get DecoderAvailable(): boolean;
  66182. /**
  66183. * Default number of workers to create when creating the draco compression object.
  66184. */
  66185. static DefaultNumWorkers: number;
  66186. private static GetDefaultNumWorkers;
  66187. private static _Default;
  66188. /**
  66189. * Default instance for the draco compression object.
  66190. */
  66191. static get Default(): DracoCompression;
  66192. /**
  66193. * Constructor
  66194. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  66195. */
  66196. constructor(numWorkers?: number);
  66197. /**
  66198. * Stop all async operations and release resources.
  66199. */
  66200. dispose(): void;
  66201. /**
  66202. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  66203. * @returns a promise that resolves when ready
  66204. */
  66205. whenReadyAsync(): Promise<void>;
  66206. /**
  66207. * Decode Draco compressed mesh data to vertex data.
  66208. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  66209. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  66210. * @returns A promise that resolves with the decoded vertex data
  66211. */
  66212. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  66213. [kind: string]: number;
  66214. }): Promise<VertexData>;
  66215. }
  66216. }
  66217. declare module BABYLON {
  66218. /**
  66219. * Class for building Constructive Solid Geometry
  66220. */
  66221. export class CSG {
  66222. private polygons;
  66223. /**
  66224. * The world matrix
  66225. */
  66226. matrix: Matrix;
  66227. /**
  66228. * Stores the position
  66229. */
  66230. position: Vector3;
  66231. /**
  66232. * Stores the rotation
  66233. */
  66234. rotation: Vector3;
  66235. /**
  66236. * Stores the rotation quaternion
  66237. */
  66238. rotationQuaternion: Nullable<Quaternion>;
  66239. /**
  66240. * Stores the scaling vector
  66241. */
  66242. scaling: Vector3;
  66243. /**
  66244. * Convert the Mesh to CSG
  66245. * @param mesh The Mesh to convert to CSG
  66246. * @returns A new CSG from the Mesh
  66247. */
  66248. static FromMesh(mesh: Mesh): CSG;
  66249. /**
  66250. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  66251. * @param polygons Polygons used to construct a CSG solid
  66252. */
  66253. private static FromPolygons;
  66254. /**
  66255. * Clones, or makes a deep copy, of the CSG
  66256. * @returns A new CSG
  66257. */
  66258. clone(): CSG;
  66259. /**
  66260. * Unions this CSG with another CSG
  66261. * @param csg The CSG to union against this CSG
  66262. * @returns The unioned CSG
  66263. */
  66264. union(csg: CSG): CSG;
  66265. /**
  66266. * Unions this CSG with another CSG in place
  66267. * @param csg The CSG to union against this CSG
  66268. */
  66269. unionInPlace(csg: CSG): void;
  66270. /**
  66271. * Subtracts this CSG with another CSG
  66272. * @param csg The CSG to subtract against this CSG
  66273. * @returns A new CSG
  66274. */
  66275. subtract(csg: CSG): CSG;
  66276. /**
  66277. * Subtracts this CSG with another CSG in place
  66278. * @param csg The CSG to subtact against this CSG
  66279. */
  66280. subtractInPlace(csg: CSG): void;
  66281. /**
  66282. * Intersect this CSG with another CSG
  66283. * @param csg The CSG to intersect against this CSG
  66284. * @returns A new CSG
  66285. */
  66286. intersect(csg: CSG): CSG;
  66287. /**
  66288. * Intersects this CSG with another CSG in place
  66289. * @param csg The CSG to intersect against this CSG
  66290. */
  66291. intersectInPlace(csg: CSG): void;
  66292. /**
  66293. * Return a new CSG solid with solid and empty space switched. This solid is
  66294. * not modified.
  66295. * @returns A new CSG solid with solid and empty space switched
  66296. */
  66297. inverse(): CSG;
  66298. /**
  66299. * Inverses the CSG in place
  66300. */
  66301. inverseInPlace(): void;
  66302. /**
  66303. * This is used to keep meshes transformations so they can be restored
  66304. * when we build back a Babylon Mesh
  66305. * NB : All CSG operations are performed in world coordinates
  66306. * @param csg The CSG to copy the transform attributes from
  66307. * @returns This CSG
  66308. */
  66309. copyTransformAttributes(csg: CSG): CSG;
  66310. /**
  66311. * Build Raw mesh from CSG
  66312. * Coordinates here are in world space
  66313. * @param name The name of the mesh geometry
  66314. * @param scene The Scene
  66315. * @param keepSubMeshes Specifies if the submeshes should be kept
  66316. * @returns A new Mesh
  66317. */
  66318. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66319. /**
  66320. * Build Mesh from CSG taking material and transforms into account
  66321. * @param name The name of the Mesh
  66322. * @param material The material of the Mesh
  66323. * @param scene The Scene
  66324. * @param keepSubMeshes Specifies if submeshes should be kept
  66325. * @returns The new Mesh
  66326. */
  66327. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66328. }
  66329. }
  66330. declare module BABYLON {
  66331. /**
  66332. * Class used to create a trail following a mesh
  66333. */
  66334. export class TrailMesh extends Mesh {
  66335. private _generator;
  66336. private _autoStart;
  66337. private _running;
  66338. private _diameter;
  66339. private _length;
  66340. private _sectionPolygonPointsCount;
  66341. private _sectionVectors;
  66342. private _sectionNormalVectors;
  66343. private _beforeRenderObserver;
  66344. /**
  66345. * @constructor
  66346. * @param name The value used by scene.getMeshByName() to do a lookup.
  66347. * @param generator The mesh or transform node to generate a trail.
  66348. * @param scene The scene to add this mesh to.
  66349. * @param diameter Diameter of trailing mesh. Default is 1.
  66350. * @param length Length of trailing mesh. Default is 60.
  66351. * @param autoStart Automatically start trailing mesh. Default true.
  66352. */
  66353. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  66354. /**
  66355. * "TrailMesh"
  66356. * @returns "TrailMesh"
  66357. */
  66358. getClassName(): string;
  66359. private _createMesh;
  66360. /**
  66361. * Start trailing mesh.
  66362. */
  66363. start(): void;
  66364. /**
  66365. * Stop trailing mesh.
  66366. */
  66367. stop(): void;
  66368. /**
  66369. * Update trailing mesh geometry.
  66370. */
  66371. update(): void;
  66372. /**
  66373. * Returns a new TrailMesh object.
  66374. * @param name is a string, the name given to the new mesh
  66375. * @param newGenerator use new generator object for cloned trail mesh
  66376. * @returns a new mesh
  66377. */
  66378. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  66379. /**
  66380. * Serializes this trail mesh
  66381. * @param serializationObject object to write serialization to
  66382. */
  66383. serialize(serializationObject: any): void;
  66384. /**
  66385. * Parses a serialized trail mesh
  66386. * @param parsedMesh the serialized mesh
  66387. * @param scene the scene to create the trail mesh in
  66388. * @returns the created trail mesh
  66389. */
  66390. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  66391. }
  66392. }
  66393. declare module BABYLON {
  66394. /**
  66395. * Class containing static functions to help procedurally build meshes
  66396. */
  66397. export class TiledBoxBuilder {
  66398. /**
  66399. * Creates a box mesh
  66400. * 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)
  66401. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66402. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66403. * * 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
  66404. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66405. * @param name defines the name of the mesh
  66406. * @param options defines the options used to create the mesh
  66407. * @param scene defines the hosting scene
  66408. * @returns the box mesh
  66409. */
  66410. static CreateTiledBox(name: string, options: {
  66411. pattern?: number;
  66412. width?: number;
  66413. height?: number;
  66414. depth?: number;
  66415. tileSize?: number;
  66416. tileWidth?: number;
  66417. tileHeight?: number;
  66418. alignHorizontal?: number;
  66419. alignVertical?: number;
  66420. faceUV?: Vector4[];
  66421. faceColors?: Color4[];
  66422. sideOrientation?: number;
  66423. updatable?: boolean;
  66424. }, scene?: Nullable<Scene>): Mesh;
  66425. }
  66426. }
  66427. declare module BABYLON {
  66428. /**
  66429. * Class containing static functions to help procedurally build meshes
  66430. */
  66431. export class TorusKnotBuilder {
  66432. /**
  66433. * Creates a torus knot mesh
  66434. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66435. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66436. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66437. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66438. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66439. * * 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
  66440. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66441. * @param name defines the name of the mesh
  66442. * @param options defines the options used to create the mesh
  66443. * @param scene defines the hosting scene
  66444. * @returns the torus knot mesh
  66445. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66446. */
  66447. static CreateTorusKnot(name: string, options: {
  66448. radius?: number;
  66449. tube?: number;
  66450. radialSegments?: number;
  66451. tubularSegments?: number;
  66452. p?: number;
  66453. q?: number;
  66454. updatable?: boolean;
  66455. sideOrientation?: number;
  66456. frontUVs?: Vector4;
  66457. backUVs?: Vector4;
  66458. }, scene: any): Mesh;
  66459. }
  66460. }
  66461. declare module BABYLON {
  66462. /**
  66463. * Polygon
  66464. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  66465. */
  66466. export class Polygon {
  66467. /**
  66468. * Creates a rectangle
  66469. * @param xmin bottom X coord
  66470. * @param ymin bottom Y coord
  66471. * @param xmax top X coord
  66472. * @param ymax top Y coord
  66473. * @returns points that make the resulting rectation
  66474. */
  66475. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  66476. /**
  66477. * Creates a circle
  66478. * @param radius radius of circle
  66479. * @param cx scale in x
  66480. * @param cy scale in y
  66481. * @param numberOfSides number of sides that make up the circle
  66482. * @returns points that make the resulting circle
  66483. */
  66484. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  66485. /**
  66486. * Creates a polygon from input string
  66487. * @param input Input polygon data
  66488. * @returns the parsed points
  66489. */
  66490. static Parse(input: string): Vector2[];
  66491. /**
  66492. * Starts building a polygon from x and y coordinates
  66493. * @param x x coordinate
  66494. * @param y y coordinate
  66495. * @returns the started path2
  66496. */
  66497. static StartingAt(x: number, y: number): Path2;
  66498. }
  66499. /**
  66500. * Builds a polygon
  66501. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  66502. */
  66503. export class PolygonMeshBuilder {
  66504. private _points;
  66505. private _outlinepoints;
  66506. private _holes;
  66507. private _name;
  66508. private _scene;
  66509. private _epoints;
  66510. private _eholes;
  66511. private _addToepoint;
  66512. /**
  66513. * Babylon reference to the earcut plugin.
  66514. */
  66515. bjsEarcut: any;
  66516. /**
  66517. * Creates a PolygonMeshBuilder
  66518. * @param name name of the builder
  66519. * @param contours Path of the polygon
  66520. * @param scene scene to add to when creating the mesh
  66521. * @param earcutInjection can be used to inject your own earcut reference
  66522. */
  66523. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  66524. /**
  66525. * Adds a whole within the polygon
  66526. * @param hole Array of points defining the hole
  66527. * @returns this
  66528. */
  66529. addHole(hole: Vector2[]): PolygonMeshBuilder;
  66530. /**
  66531. * Creates the polygon
  66532. * @param updatable If the mesh should be updatable
  66533. * @param depth The depth of the mesh created
  66534. * @returns the created mesh
  66535. */
  66536. build(updatable?: boolean, depth?: number): Mesh;
  66537. /**
  66538. * Creates the polygon
  66539. * @param depth The depth of the mesh created
  66540. * @returns the created VertexData
  66541. */
  66542. buildVertexData(depth?: number): VertexData;
  66543. /**
  66544. * Adds a side to the polygon
  66545. * @param positions points that make the polygon
  66546. * @param normals normals of the polygon
  66547. * @param uvs uvs of the polygon
  66548. * @param indices indices of the polygon
  66549. * @param bounds bounds of the polygon
  66550. * @param points points of the polygon
  66551. * @param depth depth of the polygon
  66552. * @param flip flip of the polygon
  66553. */
  66554. private addSide;
  66555. }
  66556. }
  66557. declare module BABYLON {
  66558. /**
  66559. * Class containing static functions to help procedurally build meshes
  66560. */
  66561. export class PolygonBuilder {
  66562. /**
  66563. * Creates a polygon mesh
  66564. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66565. * * 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
  66566. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66567. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66568. * * 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)
  66569. * * Remember you can only change the shape positions, not their number when updating a polygon
  66570. * @param name defines the name of the mesh
  66571. * @param options defines the options used to create the mesh
  66572. * @param scene defines the hosting scene
  66573. * @param earcutInjection can be used to inject your own earcut reference
  66574. * @returns the polygon mesh
  66575. */
  66576. static CreatePolygon(name: string, options: {
  66577. shape: Vector3[];
  66578. holes?: Vector3[][];
  66579. depth?: number;
  66580. faceUV?: Vector4[];
  66581. faceColors?: Color4[];
  66582. updatable?: boolean;
  66583. sideOrientation?: number;
  66584. frontUVs?: Vector4;
  66585. backUVs?: Vector4;
  66586. wrap?: boolean;
  66587. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66588. /**
  66589. * Creates an extruded polygon mesh, with depth in the Y direction.
  66590. * * 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)
  66591. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66592. * @param name defines the name of the mesh
  66593. * @param options defines the options used to create the mesh
  66594. * @param scene defines the hosting scene
  66595. * @param earcutInjection can be used to inject your own earcut reference
  66596. * @returns the polygon mesh
  66597. */
  66598. static ExtrudePolygon(name: string, options: {
  66599. shape: Vector3[];
  66600. holes?: Vector3[][];
  66601. depth?: number;
  66602. faceUV?: Vector4[];
  66603. faceColors?: Color4[];
  66604. updatable?: boolean;
  66605. sideOrientation?: number;
  66606. frontUVs?: Vector4;
  66607. backUVs?: Vector4;
  66608. wrap?: boolean;
  66609. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66610. }
  66611. }
  66612. declare module BABYLON {
  66613. /**
  66614. * Class containing static functions to help procedurally build meshes
  66615. */
  66616. export class LatheBuilder {
  66617. /**
  66618. * Creates lathe mesh.
  66619. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66620. * * 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
  66621. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66622. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66623. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66624. * * 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
  66625. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66626. * * 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
  66627. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66628. * * 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
  66629. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66630. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66631. * @param name defines the name of the mesh
  66632. * @param options defines the options used to create the mesh
  66633. * @param scene defines the hosting scene
  66634. * @returns the lathe mesh
  66635. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66636. */
  66637. static CreateLathe(name: string, options: {
  66638. shape: Vector3[];
  66639. radius?: number;
  66640. tessellation?: number;
  66641. clip?: number;
  66642. arc?: number;
  66643. closed?: boolean;
  66644. updatable?: boolean;
  66645. sideOrientation?: number;
  66646. frontUVs?: Vector4;
  66647. backUVs?: Vector4;
  66648. cap?: number;
  66649. invertUV?: boolean;
  66650. }, scene?: Nullable<Scene>): Mesh;
  66651. }
  66652. }
  66653. declare module BABYLON {
  66654. /**
  66655. * Class containing static functions to help procedurally build meshes
  66656. */
  66657. export class TiledPlaneBuilder {
  66658. /**
  66659. * Creates a tiled plane mesh
  66660. * * The parameter `pattern` will, depending on value, do nothing or
  66661. * * * flip (reflect about central vertical) alternate tiles across and up
  66662. * * * flip every tile on alternate rows
  66663. * * * rotate (180 degs) alternate tiles across and up
  66664. * * * rotate every tile on alternate rows
  66665. * * * flip and rotate alternate tiles across and up
  66666. * * * flip and rotate every tile on alternate rows
  66667. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  66668. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  66669. * * 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
  66670. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66671. * * 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)
  66672. * * 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)
  66673. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  66674. * @param name defines the name of the mesh
  66675. * @param options defines the options used to create the mesh
  66676. * @param scene defines the hosting scene
  66677. * @returns the box mesh
  66678. */
  66679. static CreateTiledPlane(name: string, options: {
  66680. pattern?: number;
  66681. tileSize?: number;
  66682. tileWidth?: number;
  66683. tileHeight?: number;
  66684. size?: number;
  66685. width?: number;
  66686. height?: number;
  66687. alignHorizontal?: number;
  66688. alignVertical?: number;
  66689. sideOrientation?: number;
  66690. frontUVs?: Vector4;
  66691. backUVs?: Vector4;
  66692. updatable?: boolean;
  66693. }, scene?: Nullable<Scene>): Mesh;
  66694. }
  66695. }
  66696. declare module BABYLON {
  66697. /**
  66698. * Class containing static functions to help procedurally build meshes
  66699. */
  66700. export class TubeBuilder {
  66701. /**
  66702. * Creates a tube mesh.
  66703. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66704. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  66705. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  66706. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  66707. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  66708. * * 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)
  66709. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  66710. * * 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
  66711. * * 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
  66712. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66713. * * 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
  66714. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66715. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66716. * @param name defines the name of the mesh
  66717. * @param options defines the options used to create the mesh
  66718. * @param scene defines the hosting scene
  66719. * @returns the tube mesh
  66720. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66721. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  66722. */
  66723. static CreateTube(name: string, options: {
  66724. path: Vector3[];
  66725. radius?: number;
  66726. tessellation?: number;
  66727. radiusFunction?: {
  66728. (i: number, distance: number): number;
  66729. };
  66730. cap?: number;
  66731. arc?: number;
  66732. updatable?: boolean;
  66733. sideOrientation?: number;
  66734. frontUVs?: Vector4;
  66735. backUVs?: Vector4;
  66736. instance?: Mesh;
  66737. invertUV?: boolean;
  66738. }, scene?: Nullable<Scene>): Mesh;
  66739. }
  66740. }
  66741. declare module BABYLON {
  66742. /**
  66743. * Class containing static functions to help procedurally build meshes
  66744. */
  66745. export class IcoSphereBuilder {
  66746. /**
  66747. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  66748. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  66749. * * 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`)
  66750. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  66751. * * 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
  66752. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66753. * * 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
  66754. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66755. * @param name defines the name of the mesh
  66756. * @param options defines the options used to create the mesh
  66757. * @param scene defines the hosting scene
  66758. * @returns the icosahedron mesh
  66759. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  66760. */
  66761. static CreateIcoSphere(name: string, options: {
  66762. radius?: number;
  66763. radiusX?: number;
  66764. radiusY?: number;
  66765. radiusZ?: number;
  66766. flat?: boolean;
  66767. subdivisions?: number;
  66768. sideOrientation?: number;
  66769. frontUVs?: Vector4;
  66770. backUVs?: Vector4;
  66771. updatable?: boolean;
  66772. }, scene?: Nullable<Scene>): Mesh;
  66773. }
  66774. }
  66775. declare module BABYLON {
  66776. /**
  66777. * Class containing static functions to help procedurally build meshes
  66778. */
  66779. export class DecalBuilder {
  66780. /**
  66781. * Creates a decal mesh.
  66782. * 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
  66783. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  66784. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  66785. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  66786. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  66787. * @param name defines the name of the mesh
  66788. * @param sourceMesh defines the mesh where the decal must be applied
  66789. * @param options defines the options used to create the mesh
  66790. * @param scene defines the hosting scene
  66791. * @returns the decal mesh
  66792. * @see https://doc.babylonjs.com/how_to/decals
  66793. */
  66794. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  66795. position?: Vector3;
  66796. normal?: Vector3;
  66797. size?: Vector3;
  66798. angle?: number;
  66799. }): Mesh;
  66800. }
  66801. }
  66802. declare module BABYLON {
  66803. /**
  66804. * Class containing static functions to help procedurally build meshes
  66805. */
  66806. export class MeshBuilder {
  66807. /**
  66808. * Creates a box mesh
  66809. * * The parameter `size` sets the size (float) of each box side (default 1)
  66810. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  66811. * * 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)
  66812. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66813. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66814. * * 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
  66815. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66816. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  66817. * @param name defines the name of the mesh
  66818. * @param options defines the options used to create the mesh
  66819. * @param scene defines the hosting scene
  66820. * @returns the box mesh
  66821. */
  66822. static CreateBox(name: string, options: {
  66823. size?: number;
  66824. width?: number;
  66825. height?: number;
  66826. depth?: number;
  66827. faceUV?: Vector4[];
  66828. faceColors?: Color4[];
  66829. sideOrientation?: number;
  66830. frontUVs?: Vector4;
  66831. backUVs?: Vector4;
  66832. wrap?: boolean;
  66833. topBaseAt?: number;
  66834. bottomBaseAt?: number;
  66835. updatable?: boolean;
  66836. }, scene?: Nullable<Scene>): Mesh;
  66837. /**
  66838. * Creates a tiled box mesh
  66839. * * faceTiles sets the pattern, tile size and number of tiles for a face
  66840. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66841. * @param name defines the name of the mesh
  66842. * @param options defines the options used to create the mesh
  66843. * @param scene defines the hosting scene
  66844. * @returns the tiled box mesh
  66845. */
  66846. static CreateTiledBox(name: string, options: {
  66847. pattern?: number;
  66848. size?: number;
  66849. width?: number;
  66850. height?: number;
  66851. depth: number;
  66852. tileSize?: number;
  66853. tileWidth?: number;
  66854. tileHeight?: number;
  66855. faceUV?: Vector4[];
  66856. faceColors?: Color4[];
  66857. alignHorizontal?: number;
  66858. alignVertical?: number;
  66859. sideOrientation?: number;
  66860. updatable?: boolean;
  66861. }, scene?: Nullable<Scene>): Mesh;
  66862. /**
  66863. * Creates a sphere mesh
  66864. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  66865. * * 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`)
  66866. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  66867. * * 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
  66868. * * 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)
  66869. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66870. * * 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
  66871. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66872. * @param name defines the name of the mesh
  66873. * @param options defines the options used to create the mesh
  66874. * @param scene defines the hosting scene
  66875. * @returns the sphere mesh
  66876. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  66877. */
  66878. static CreateSphere(name: string, options: {
  66879. segments?: number;
  66880. diameter?: number;
  66881. diameterX?: number;
  66882. diameterY?: number;
  66883. diameterZ?: number;
  66884. arc?: number;
  66885. slice?: number;
  66886. sideOrientation?: number;
  66887. frontUVs?: Vector4;
  66888. backUVs?: Vector4;
  66889. updatable?: boolean;
  66890. }, scene?: Nullable<Scene>): Mesh;
  66891. /**
  66892. * Creates a plane polygonal mesh. By default, this is a disc
  66893. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  66894. * * 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
  66895. * * 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
  66896. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66897. * * 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
  66898. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66899. * @param name defines the name of the mesh
  66900. * @param options defines the options used to create the mesh
  66901. * @param scene defines the hosting scene
  66902. * @returns the plane polygonal mesh
  66903. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  66904. */
  66905. static CreateDisc(name: string, options: {
  66906. radius?: number;
  66907. tessellation?: number;
  66908. arc?: number;
  66909. updatable?: boolean;
  66910. sideOrientation?: number;
  66911. frontUVs?: Vector4;
  66912. backUVs?: Vector4;
  66913. }, scene?: Nullable<Scene>): Mesh;
  66914. /**
  66915. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  66916. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  66917. * * 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`)
  66918. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  66919. * * 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
  66920. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66921. * * 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
  66922. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66923. * @param name defines the name of the mesh
  66924. * @param options defines the options used to create the mesh
  66925. * @param scene defines the hosting scene
  66926. * @returns the icosahedron mesh
  66927. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  66928. */
  66929. static CreateIcoSphere(name: string, options: {
  66930. radius?: number;
  66931. radiusX?: number;
  66932. radiusY?: number;
  66933. radiusZ?: number;
  66934. flat?: boolean;
  66935. subdivisions?: number;
  66936. sideOrientation?: number;
  66937. frontUVs?: Vector4;
  66938. backUVs?: Vector4;
  66939. updatable?: boolean;
  66940. }, scene?: Nullable<Scene>): Mesh;
  66941. /**
  66942. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66943. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  66944. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  66945. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  66946. * * 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
  66947. * * 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
  66948. * * 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
  66949. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66950. * * 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
  66951. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66952. * * 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
  66953. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  66954. * * 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
  66955. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  66956. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66957. * @param name defines the name of the mesh
  66958. * @param options defines the options used to create the mesh
  66959. * @param scene defines the hosting scene
  66960. * @returns the ribbon mesh
  66961. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  66962. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66963. */
  66964. static CreateRibbon(name: string, options: {
  66965. pathArray: Vector3[][];
  66966. closeArray?: boolean;
  66967. closePath?: boolean;
  66968. offset?: number;
  66969. updatable?: boolean;
  66970. sideOrientation?: number;
  66971. frontUVs?: Vector4;
  66972. backUVs?: Vector4;
  66973. instance?: Mesh;
  66974. invertUV?: boolean;
  66975. uvs?: Vector2[];
  66976. colors?: Color4[];
  66977. }, scene?: Nullable<Scene>): Mesh;
  66978. /**
  66979. * Creates a cylinder or a cone mesh
  66980. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  66981. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  66982. * * 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.
  66983. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  66984. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  66985. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  66986. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  66987. * * 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).
  66988. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  66989. * * 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).
  66990. * * 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
  66991. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  66992. * * 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
  66993. * * 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.
  66994. * * If `enclose` is false, a ring surface is one element.
  66995. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  66996. * * 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
  66997. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66998. * * 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
  66999. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67000. * @param name defines the name of the mesh
  67001. * @param options defines the options used to create the mesh
  67002. * @param scene defines the hosting scene
  67003. * @returns the cylinder mesh
  67004. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  67005. */
  67006. static CreateCylinder(name: string, options: {
  67007. height?: number;
  67008. diameterTop?: number;
  67009. diameterBottom?: number;
  67010. diameter?: number;
  67011. tessellation?: number;
  67012. subdivisions?: number;
  67013. arc?: number;
  67014. faceColors?: Color4[];
  67015. faceUV?: Vector4[];
  67016. updatable?: boolean;
  67017. hasRings?: boolean;
  67018. enclose?: boolean;
  67019. cap?: number;
  67020. sideOrientation?: number;
  67021. frontUVs?: Vector4;
  67022. backUVs?: Vector4;
  67023. }, scene?: Nullable<Scene>): Mesh;
  67024. /**
  67025. * Creates a torus mesh
  67026. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  67027. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  67028. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  67029. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67030. * * 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
  67031. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67032. * @param name defines the name of the mesh
  67033. * @param options defines the options used to create the mesh
  67034. * @param scene defines the hosting scene
  67035. * @returns the torus mesh
  67036. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  67037. */
  67038. static CreateTorus(name: string, options: {
  67039. diameter?: number;
  67040. thickness?: number;
  67041. tessellation?: number;
  67042. updatable?: boolean;
  67043. sideOrientation?: number;
  67044. frontUVs?: Vector4;
  67045. backUVs?: Vector4;
  67046. }, scene?: Nullable<Scene>): Mesh;
  67047. /**
  67048. * Creates a torus knot mesh
  67049. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  67050. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  67051. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  67052. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  67053. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67054. * * 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
  67055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67056. * @param name defines the name of the mesh
  67057. * @param options defines the options used to create the mesh
  67058. * @param scene defines the hosting scene
  67059. * @returns the torus knot mesh
  67060. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  67061. */
  67062. static CreateTorusKnot(name: string, options: {
  67063. radius?: number;
  67064. tube?: number;
  67065. radialSegments?: number;
  67066. tubularSegments?: number;
  67067. p?: number;
  67068. q?: number;
  67069. updatable?: boolean;
  67070. sideOrientation?: number;
  67071. frontUVs?: Vector4;
  67072. backUVs?: Vector4;
  67073. }, scene?: Nullable<Scene>): Mesh;
  67074. /**
  67075. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  67076. * * 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
  67077. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  67078. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  67079. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  67080. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  67081. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  67082. * * 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
  67083. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  67084. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67085. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  67086. * @param name defines the name of the new line system
  67087. * @param options defines the options used to create the line system
  67088. * @param scene defines the hosting scene
  67089. * @returns a new line system mesh
  67090. */
  67091. static CreateLineSystem(name: string, options: {
  67092. lines: Vector3[][];
  67093. updatable?: boolean;
  67094. instance?: Nullable<LinesMesh>;
  67095. colors?: Nullable<Color4[][]>;
  67096. useVertexAlpha?: boolean;
  67097. }, scene: Nullable<Scene>): LinesMesh;
  67098. /**
  67099. * Creates a line mesh
  67100. * 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
  67101. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  67102. * * The parameter `points` is an array successive Vector3
  67103. * * 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
  67104. * * The optional parameter `colors` is an array of successive Color4, one per line point
  67105. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  67106. * * When updating an instance, remember that only point positions can change, not the number of points
  67107. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67108. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  67109. * @param name defines the name of the new line system
  67110. * @param options defines the options used to create the line system
  67111. * @param scene defines the hosting scene
  67112. * @returns a new line mesh
  67113. */
  67114. static CreateLines(name: string, options: {
  67115. points: Vector3[];
  67116. updatable?: boolean;
  67117. instance?: Nullable<LinesMesh>;
  67118. colors?: Color4[];
  67119. useVertexAlpha?: boolean;
  67120. }, scene?: Nullable<Scene>): LinesMesh;
  67121. /**
  67122. * Creates a dashed line mesh
  67123. * * 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
  67124. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  67125. * * The parameter `points` is an array successive Vector3
  67126. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  67127. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  67128. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  67129. * * 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
  67130. * * When updating an instance, remember that only point positions can change, not the number of points
  67131. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67132. * @param name defines the name of the mesh
  67133. * @param options defines the options used to create the mesh
  67134. * @param scene defines the hosting scene
  67135. * @returns the dashed line mesh
  67136. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  67137. */
  67138. static CreateDashedLines(name: string, options: {
  67139. points: Vector3[];
  67140. dashSize?: number;
  67141. gapSize?: number;
  67142. dashNb?: number;
  67143. updatable?: boolean;
  67144. instance?: LinesMesh;
  67145. }, scene?: Nullable<Scene>): LinesMesh;
  67146. /**
  67147. * 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.
  67148. * * 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.
  67149. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  67150. * * 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.
  67151. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  67152. * * 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
  67153. * * 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
  67154. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  67155. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67156. * * 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
  67157. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  67158. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67159. * @param name defines the name of the mesh
  67160. * @param options defines the options used to create the mesh
  67161. * @param scene defines the hosting scene
  67162. * @returns the extruded shape mesh
  67163. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67164. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  67165. */
  67166. static ExtrudeShape(name: string, options: {
  67167. shape: Vector3[];
  67168. path: Vector3[];
  67169. scale?: number;
  67170. rotation?: number;
  67171. cap?: number;
  67172. updatable?: boolean;
  67173. sideOrientation?: number;
  67174. frontUVs?: Vector4;
  67175. backUVs?: Vector4;
  67176. instance?: Mesh;
  67177. invertUV?: boolean;
  67178. }, scene?: Nullable<Scene>): Mesh;
  67179. /**
  67180. * Creates an custom extruded shape mesh.
  67181. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  67182. * * 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.
  67183. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  67184. * * 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
  67185. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  67186. * * 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
  67187. * * It must returns a float value that will be the scale value applied to the shape on each path point
  67188. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  67189. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  67190. * * 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
  67191. * * 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
  67192. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  67193. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67194. * * 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
  67195. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67196. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67197. * @param name defines the name of the mesh
  67198. * @param options defines the options used to create the mesh
  67199. * @param scene defines the hosting scene
  67200. * @returns the custom extruded shape mesh
  67201. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  67202. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67203. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  67204. */
  67205. static ExtrudeShapeCustom(name: string, options: {
  67206. shape: Vector3[];
  67207. path: Vector3[];
  67208. scaleFunction?: any;
  67209. rotationFunction?: any;
  67210. ribbonCloseArray?: boolean;
  67211. ribbonClosePath?: boolean;
  67212. cap?: number;
  67213. updatable?: boolean;
  67214. sideOrientation?: number;
  67215. frontUVs?: Vector4;
  67216. backUVs?: Vector4;
  67217. instance?: Mesh;
  67218. invertUV?: boolean;
  67219. }, scene?: Nullable<Scene>): Mesh;
  67220. /**
  67221. * Creates lathe mesh.
  67222. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  67223. * * 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
  67224. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  67225. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  67226. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  67227. * * 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
  67228. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  67229. * * 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
  67230. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67231. * * 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
  67232. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67233. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67234. * @param name defines the name of the mesh
  67235. * @param options defines the options used to create the mesh
  67236. * @param scene defines the hosting scene
  67237. * @returns the lathe mesh
  67238. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  67239. */
  67240. static CreateLathe(name: string, options: {
  67241. shape: Vector3[];
  67242. radius?: number;
  67243. tessellation?: number;
  67244. clip?: number;
  67245. arc?: number;
  67246. closed?: boolean;
  67247. updatable?: boolean;
  67248. sideOrientation?: number;
  67249. frontUVs?: Vector4;
  67250. backUVs?: Vector4;
  67251. cap?: number;
  67252. invertUV?: boolean;
  67253. }, scene?: Nullable<Scene>): Mesh;
  67254. /**
  67255. * Creates a tiled plane mesh
  67256. * * You can set a limited pattern arrangement with the tiles
  67257. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67258. * * 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
  67259. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67260. * @param name defines the name of the mesh
  67261. * @param options defines the options used to create the mesh
  67262. * @param scene defines the hosting scene
  67263. * @returns the plane mesh
  67264. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  67265. */
  67266. static CreateTiledPlane(name: string, options: {
  67267. pattern?: number;
  67268. tileSize?: number;
  67269. tileWidth?: number;
  67270. tileHeight?: number;
  67271. size?: number;
  67272. width?: number;
  67273. height?: number;
  67274. alignHorizontal?: number;
  67275. alignVertical?: number;
  67276. sideOrientation?: number;
  67277. frontUVs?: Vector4;
  67278. backUVs?: Vector4;
  67279. updatable?: boolean;
  67280. }, scene?: Nullable<Scene>): Mesh;
  67281. /**
  67282. * Creates a plane mesh
  67283. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  67284. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  67285. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  67286. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67287. * * 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
  67288. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67289. * @param name defines the name of the mesh
  67290. * @param options defines the options used to create the mesh
  67291. * @param scene defines the hosting scene
  67292. * @returns the plane mesh
  67293. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  67294. */
  67295. static CreatePlane(name: string, options: {
  67296. size?: number;
  67297. width?: number;
  67298. height?: number;
  67299. sideOrientation?: number;
  67300. frontUVs?: Vector4;
  67301. backUVs?: Vector4;
  67302. updatable?: boolean;
  67303. sourcePlane?: Plane;
  67304. }, scene?: Nullable<Scene>): Mesh;
  67305. /**
  67306. * Creates a ground mesh
  67307. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  67308. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  67309. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67310. * @param name defines the name of the mesh
  67311. * @param options defines the options used to create the mesh
  67312. * @param scene defines the hosting scene
  67313. * @returns the ground mesh
  67314. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  67315. */
  67316. static CreateGround(name: string, options: {
  67317. width?: number;
  67318. height?: number;
  67319. subdivisions?: number;
  67320. subdivisionsX?: number;
  67321. subdivisionsY?: number;
  67322. updatable?: boolean;
  67323. }, scene?: Nullable<Scene>): Mesh;
  67324. /**
  67325. * Creates a tiled ground mesh
  67326. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  67327. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  67328. * * 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
  67329. * * 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
  67330. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67331. * @param name defines the name of the mesh
  67332. * @param options defines the options used to create the mesh
  67333. * @param scene defines the hosting scene
  67334. * @returns the tiled ground mesh
  67335. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  67336. */
  67337. static CreateTiledGround(name: string, options: {
  67338. xmin: number;
  67339. zmin: number;
  67340. xmax: number;
  67341. zmax: number;
  67342. subdivisions?: {
  67343. w: number;
  67344. h: number;
  67345. };
  67346. precision?: {
  67347. w: number;
  67348. h: number;
  67349. };
  67350. updatable?: boolean;
  67351. }, scene?: Nullable<Scene>): Mesh;
  67352. /**
  67353. * Creates a ground mesh from a height map
  67354. * * The parameter `url` sets the URL of the height map image resource.
  67355. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  67356. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  67357. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  67358. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  67359. * * 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.
  67360. * * 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).
  67361. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  67362. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67363. * @param name defines the name of the mesh
  67364. * @param url defines the url to the height map
  67365. * @param options defines the options used to create the mesh
  67366. * @param scene defines the hosting scene
  67367. * @returns the ground mesh
  67368. * @see https://doc.babylonjs.com/babylon101/height_map
  67369. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  67370. */
  67371. static CreateGroundFromHeightMap(name: string, url: string, options: {
  67372. width?: number;
  67373. height?: number;
  67374. subdivisions?: number;
  67375. minHeight?: number;
  67376. maxHeight?: number;
  67377. colorFilter?: Color3;
  67378. alphaFilter?: number;
  67379. updatable?: boolean;
  67380. onReady?: (mesh: GroundMesh) => void;
  67381. }, scene?: Nullable<Scene>): GroundMesh;
  67382. /**
  67383. * Creates a polygon mesh
  67384. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  67385. * * 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
  67386. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67387. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67388. * * 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)
  67389. * * Remember you can only change the shape positions, not their number when updating a polygon
  67390. * @param name defines the name of the mesh
  67391. * @param options defines the options used to create the mesh
  67392. * @param scene defines the hosting scene
  67393. * @param earcutInjection can be used to inject your own earcut reference
  67394. * @returns the polygon mesh
  67395. */
  67396. static CreatePolygon(name: string, options: {
  67397. shape: Vector3[];
  67398. holes?: Vector3[][];
  67399. depth?: number;
  67400. faceUV?: Vector4[];
  67401. faceColors?: Color4[];
  67402. updatable?: boolean;
  67403. sideOrientation?: number;
  67404. frontUVs?: Vector4;
  67405. backUVs?: Vector4;
  67406. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67407. /**
  67408. * Creates an extruded polygon mesh, with depth in the Y direction.
  67409. * * 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)
  67410. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67411. * @param name defines the name of the mesh
  67412. * @param options defines the options used to create the mesh
  67413. * @param scene defines the hosting scene
  67414. * @param earcutInjection can be used to inject your own earcut reference
  67415. * @returns the polygon mesh
  67416. */
  67417. static ExtrudePolygon(name: string, options: {
  67418. shape: Vector3[];
  67419. holes?: Vector3[][];
  67420. depth?: number;
  67421. faceUV?: Vector4[];
  67422. faceColors?: Color4[];
  67423. updatable?: boolean;
  67424. sideOrientation?: number;
  67425. frontUVs?: Vector4;
  67426. backUVs?: Vector4;
  67427. wrap?: boolean;
  67428. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67429. /**
  67430. * Creates a tube mesh.
  67431. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67432. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67433. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67434. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67435. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67436. * * 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)
  67437. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  67438. * * 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
  67439. * * 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
  67440. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67441. * * 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
  67442. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67443. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67444. * @param name defines the name of the mesh
  67445. * @param options defines the options used to create the mesh
  67446. * @param scene defines the hosting scene
  67447. * @returns the tube mesh
  67448. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67449. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  67450. */
  67451. static CreateTube(name: string, options: {
  67452. path: Vector3[];
  67453. radius?: number;
  67454. tessellation?: number;
  67455. radiusFunction?: {
  67456. (i: number, distance: number): number;
  67457. };
  67458. cap?: number;
  67459. arc?: number;
  67460. updatable?: boolean;
  67461. sideOrientation?: number;
  67462. frontUVs?: Vector4;
  67463. backUVs?: Vector4;
  67464. instance?: Mesh;
  67465. invertUV?: boolean;
  67466. }, scene?: Nullable<Scene>): Mesh;
  67467. /**
  67468. * Creates a polyhedron mesh
  67469. * * 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
  67470. * * The parameter `size` (positive float, default 1) sets the polygon size
  67471. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  67472. * * 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`
  67473. * * 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
  67474. * * 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)`)
  67475. * * 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
  67476. * * 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
  67477. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67478. * * 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
  67479. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67480. * @param name defines the name of the mesh
  67481. * @param options defines the options used to create the mesh
  67482. * @param scene defines the hosting scene
  67483. * @returns the polyhedron mesh
  67484. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  67485. */
  67486. static CreatePolyhedron(name: string, options: {
  67487. type?: number;
  67488. size?: number;
  67489. sizeX?: number;
  67490. sizeY?: number;
  67491. sizeZ?: number;
  67492. custom?: any;
  67493. faceUV?: Vector4[];
  67494. faceColors?: Color4[];
  67495. flat?: boolean;
  67496. updatable?: boolean;
  67497. sideOrientation?: number;
  67498. frontUVs?: Vector4;
  67499. backUVs?: Vector4;
  67500. }, scene?: Nullable<Scene>): Mesh;
  67501. /**
  67502. * Creates a decal mesh.
  67503. * 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
  67504. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  67505. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67506. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67507. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67508. * @param name defines the name of the mesh
  67509. * @param sourceMesh defines the mesh where the decal must be applied
  67510. * @param options defines the options used to create the mesh
  67511. * @param scene defines the hosting scene
  67512. * @returns the decal mesh
  67513. * @see https://doc.babylonjs.com/how_to/decals
  67514. */
  67515. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  67516. position?: Vector3;
  67517. normal?: Vector3;
  67518. size?: Vector3;
  67519. angle?: number;
  67520. }): Mesh;
  67521. /**
  67522. * Creates a Capsule Mesh
  67523. * @param name defines the name of the mesh.
  67524. * @param options the constructors options used to shape the mesh.
  67525. * @param scene defines the scene the mesh is scoped to.
  67526. * @returns the capsule mesh
  67527. * @see https://doc.babylonjs.com/how_to/capsule_shape
  67528. */
  67529. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  67530. }
  67531. }
  67532. declare module BABYLON {
  67533. /**
  67534. * A simplifier interface for future simplification implementations
  67535. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67536. */
  67537. export interface ISimplifier {
  67538. /**
  67539. * Simplification of a given mesh according to the given settings.
  67540. * Since this requires computation, it is assumed that the function runs async.
  67541. * @param settings The settings of the simplification, including quality and distance
  67542. * @param successCallback A callback that will be called after the mesh was simplified.
  67543. * @param errorCallback in case of an error, this callback will be called. optional.
  67544. */
  67545. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  67546. }
  67547. /**
  67548. * Expected simplification settings.
  67549. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  67550. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67551. */
  67552. export interface ISimplificationSettings {
  67553. /**
  67554. * Gets or sets the expected quality
  67555. */
  67556. quality: number;
  67557. /**
  67558. * Gets or sets the distance when this optimized version should be used
  67559. */
  67560. distance: number;
  67561. /**
  67562. * Gets an already optimized mesh
  67563. */
  67564. optimizeMesh?: boolean;
  67565. }
  67566. /**
  67567. * Class used to specify simplification options
  67568. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67569. */
  67570. export class SimplificationSettings implements ISimplificationSettings {
  67571. /** expected quality */
  67572. quality: number;
  67573. /** distance when this optimized version should be used */
  67574. distance: number;
  67575. /** already optimized mesh */
  67576. optimizeMesh?: boolean | undefined;
  67577. /**
  67578. * Creates a SimplificationSettings
  67579. * @param quality expected quality
  67580. * @param distance distance when this optimized version should be used
  67581. * @param optimizeMesh already optimized mesh
  67582. */
  67583. constructor(
  67584. /** expected quality */
  67585. quality: number,
  67586. /** distance when this optimized version should be used */
  67587. distance: number,
  67588. /** already optimized mesh */
  67589. optimizeMesh?: boolean | undefined);
  67590. }
  67591. /**
  67592. * Interface used to define a simplification task
  67593. */
  67594. export interface ISimplificationTask {
  67595. /**
  67596. * Array of settings
  67597. */
  67598. settings: Array<ISimplificationSettings>;
  67599. /**
  67600. * Simplification type
  67601. */
  67602. simplificationType: SimplificationType;
  67603. /**
  67604. * Mesh to simplify
  67605. */
  67606. mesh: Mesh;
  67607. /**
  67608. * Callback called on success
  67609. */
  67610. successCallback?: () => void;
  67611. /**
  67612. * Defines if parallel processing can be used
  67613. */
  67614. parallelProcessing: boolean;
  67615. }
  67616. /**
  67617. * Queue used to order the simplification tasks
  67618. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67619. */
  67620. export class SimplificationQueue {
  67621. private _simplificationArray;
  67622. /**
  67623. * Gets a boolean indicating that the process is still running
  67624. */
  67625. running: boolean;
  67626. /**
  67627. * Creates a new queue
  67628. */
  67629. constructor();
  67630. /**
  67631. * Adds a new simplification task
  67632. * @param task defines a task to add
  67633. */
  67634. addTask(task: ISimplificationTask): void;
  67635. /**
  67636. * Execute next task
  67637. */
  67638. executeNext(): void;
  67639. /**
  67640. * Execute a simplification task
  67641. * @param task defines the task to run
  67642. */
  67643. runSimplification(task: ISimplificationTask): void;
  67644. private getSimplifier;
  67645. }
  67646. /**
  67647. * The implemented types of simplification
  67648. * At the moment only Quadratic Error Decimation is implemented
  67649. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67650. */
  67651. export enum SimplificationType {
  67652. /** Quadratic error decimation */
  67653. QUADRATIC = 0
  67654. }
  67655. /**
  67656. * An implementation of the Quadratic Error simplification algorithm.
  67657. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  67658. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  67659. * @author RaananW
  67660. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67661. */
  67662. export class QuadraticErrorSimplification implements ISimplifier {
  67663. private _mesh;
  67664. private triangles;
  67665. private vertices;
  67666. private references;
  67667. private _reconstructedMesh;
  67668. /** Gets or sets the number pf sync interations */
  67669. syncIterations: number;
  67670. /** Gets or sets the aggressiveness of the simplifier */
  67671. aggressiveness: number;
  67672. /** Gets or sets the number of allowed iterations for decimation */
  67673. decimationIterations: number;
  67674. /** Gets or sets the espilon to use for bounding box computation */
  67675. boundingBoxEpsilon: number;
  67676. /**
  67677. * Creates a new QuadraticErrorSimplification
  67678. * @param _mesh defines the target mesh
  67679. */
  67680. constructor(_mesh: Mesh);
  67681. /**
  67682. * Simplification of a given mesh according to the given settings.
  67683. * Since this requires computation, it is assumed that the function runs async.
  67684. * @param settings The settings of the simplification, including quality and distance
  67685. * @param successCallback A callback that will be called after the mesh was simplified.
  67686. */
  67687. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  67688. private runDecimation;
  67689. private initWithMesh;
  67690. private init;
  67691. private reconstructMesh;
  67692. private initDecimatedMesh;
  67693. private isFlipped;
  67694. private updateTriangles;
  67695. private identifyBorder;
  67696. private updateMesh;
  67697. private vertexError;
  67698. private calculateError;
  67699. }
  67700. }
  67701. declare module BABYLON {
  67702. interface Scene {
  67703. /** @hidden (Backing field) */
  67704. _simplificationQueue: SimplificationQueue;
  67705. /**
  67706. * Gets or sets the simplification queue attached to the scene
  67707. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67708. */
  67709. simplificationQueue: SimplificationQueue;
  67710. }
  67711. interface Mesh {
  67712. /**
  67713. * Simplify the mesh according to the given array of settings.
  67714. * Function will return immediately and will simplify async
  67715. * @param settings a collection of simplification settings
  67716. * @param parallelProcessing should all levels calculate parallel or one after the other
  67717. * @param simplificationType the type of simplification to run
  67718. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  67719. * @returns the current mesh
  67720. */
  67721. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  67722. }
  67723. /**
  67724. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  67725. * created in a scene
  67726. */
  67727. export class SimplicationQueueSceneComponent implements ISceneComponent {
  67728. /**
  67729. * The component name helpfull to identify the component in the list of scene components.
  67730. */
  67731. readonly name: string;
  67732. /**
  67733. * The scene the component belongs to.
  67734. */
  67735. scene: Scene;
  67736. /**
  67737. * Creates a new instance of the component for the given scene
  67738. * @param scene Defines the scene to register the component in
  67739. */
  67740. constructor(scene: Scene);
  67741. /**
  67742. * Registers the component in a given scene
  67743. */
  67744. register(): void;
  67745. /**
  67746. * Rebuilds the elements related to this component in case of
  67747. * context lost for instance.
  67748. */
  67749. rebuild(): void;
  67750. /**
  67751. * Disposes the component and the associated ressources
  67752. */
  67753. dispose(): void;
  67754. private _beforeCameraUpdate;
  67755. }
  67756. }
  67757. declare module BABYLON {
  67758. interface Mesh {
  67759. /**
  67760. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  67761. */
  67762. thinInstanceEnablePicking: boolean;
  67763. /**
  67764. * Creates a new thin instance
  67765. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  67766. * @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
  67767. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  67768. */
  67769. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  67770. /**
  67771. * Adds the transformation (matrix) of the current mesh as a thin instance
  67772. * @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
  67773. * @returns the thin instance index number
  67774. */
  67775. thinInstanceAddSelf(refresh: boolean): number;
  67776. /**
  67777. * Registers a custom attribute to be used with thin instances
  67778. * @param kind name of the attribute
  67779. * @param stride size in floats of the attribute
  67780. */
  67781. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  67782. /**
  67783. * Sets the matrix of a thin instance
  67784. * @param index index of the thin instance
  67785. * @param matrix matrix to set
  67786. * @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
  67787. */
  67788. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  67789. /**
  67790. * Sets the value of a custom attribute for a thin instance
  67791. * @param kind name of the attribute
  67792. * @param index index of the thin instance
  67793. * @param value value to set
  67794. * @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
  67795. */
  67796. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  67797. /**
  67798. * 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.
  67799. */
  67800. thinInstanceCount: number;
  67801. /**
  67802. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  67803. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  67804. * @param buffer buffer to set
  67805. * @param stride size in floats of each value of the buffer
  67806. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  67807. */
  67808. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  67809. /**
  67810. * Gets the list of world matrices
  67811. * @return an array containing all the world matrices from the thin instances
  67812. */
  67813. thinInstanceGetWorldMatrices(): Matrix[];
  67814. /**
  67815. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  67816. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  67817. */
  67818. thinInstanceBufferUpdated(kind: string): void;
  67819. /**
  67820. * Applies a partial update to a buffer directly on the GPU
  67821. * 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
  67822. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  67823. * @param data the data to set in the GPU buffer
  67824. * @param offset the offset in the GPU buffer where to update the data
  67825. */
  67826. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  67827. /**
  67828. * Refreshes the bounding info, taking into account all the thin instances defined
  67829. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  67830. */
  67831. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  67832. /** @hidden */
  67833. _thinInstanceInitializeUserStorage(): void;
  67834. /** @hidden */
  67835. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  67836. /** @hidden */
  67837. _userThinInstanceBuffersStorage: {
  67838. data: {
  67839. [key: string]: Float32Array;
  67840. };
  67841. sizes: {
  67842. [key: string]: number;
  67843. };
  67844. vertexBuffers: {
  67845. [key: string]: Nullable<VertexBuffer>;
  67846. };
  67847. strides: {
  67848. [key: string]: number;
  67849. };
  67850. };
  67851. }
  67852. }
  67853. declare module BABYLON {
  67854. /**
  67855. * Navigation plugin interface to add navigation constrained by a navigation mesh
  67856. */
  67857. export interface INavigationEnginePlugin {
  67858. /**
  67859. * plugin name
  67860. */
  67861. name: string;
  67862. /**
  67863. * Creates a navigation mesh
  67864. * @param meshes array of all the geometry used to compute the navigatio mesh
  67865. * @param parameters bunch of parameters used to filter geometry
  67866. */
  67867. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  67868. /**
  67869. * Create a navigation mesh debug mesh
  67870. * @param scene is where the mesh will be added
  67871. * @returns debug display mesh
  67872. */
  67873. createDebugNavMesh(scene: Scene): Mesh;
  67874. /**
  67875. * Get a navigation mesh constrained position, closest to the parameter position
  67876. * @param position world position
  67877. * @returns the closest point to position constrained by the navigation mesh
  67878. */
  67879. getClosestPoint(position: Vector3): Vector3;
  67880. /**
  67881. * Get a navigation mesh constrained position, closest to the parameter position
  67882. * @param position world position
  67883. * @param result output the closest point to position constrained by the navigation mesh
  67884. */
  67885. getClosestPointToRef(position: Vector3, result: Vector3): void;
  67886. /**
  67887. * Get a navigation mesh constrained position, within a particular radius
  67888. * @param position world position
  67889. * @param maxRadius the maximum distance to the constrained world position
  67890. * @returns the closest point to position constrained by the navigation mesh
  67891. */
  67892. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  67893. /**
  67894. * Get a navigation mesh constrained position, within a particular radius
  67895. * @param position world position
  67896. * @param maxRadius the maximum distance to the constrained world position
  67897. * @param result output the closest point to position constrained by the navigation mesh
  67898. */
  67899. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67900. /**
  67901. * Compute the final position from a segment made of destination-position
  67902. * @param position world position
  67903. * @param destination world position
  67904. * @returns the resulting point along the navmesh
  67905. */
  67906. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67907. /**
  67908. * Compute the final position from a segment made of destination-position
  67909. * @param position world position
  67910. * @param destination world position
  67911. * @param result output the resulting point along the navmesh
  67912. */
  67913. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67914. /**
  67915. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67916. * @param start world position
  67917. * @param end world position
  67918. * @returns array containing world position composing the path
  67919. */
  67920. computePath(start: Vector3, end: Vector3): Vector3[];
  67921. /**
  67922. * If this plugin is supported
  67923. * @returns true if plugin is supported
  67924. */
  67925. isSupported(): boolean;
  67926. /**
  67927. * Create a new Crowd so you can add agents
  67928. * @param maxAgents the maximum agent count in the crowd
  67929. * @param maxAgentRadius the maximum radius an agent can have
  67930. * @param scene to attach the crowd to
  67931. * @returns the crowd you can add agents to
  67932. */
  67933. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67934. /**
  67935. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67936. * The queries will try to find a solution within those bounds
  67937. * default is (1,1,1)
  67938. * @param extent x,y,z value that define the extent around the queries point of reference
  67939. */
  67940. setDefaultQueryExtent(extent: Vector3): void;
  67941. /**
  67942. * Get the Bounding box extent specified by setDefaultQueryExtent
  67943. * @returns the box extent values
  67944. */
  67945. getDefaultQueryExtent(): Vector3;
  67946. /**
  67947. * build the navmesh from a previously saved state using getNavmeshData
  67948. * @param data the Uint8Array returned by getNavmeshData
  67949. */
  67950. buildFromNavmeshData(data: Uint8Array): void;
  67951. /**
  67952. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67953. * @returns data the Uint8Array that can be saved and reused
  67954. */
  67955. getNavmeshData(): Uint8Array;
  67956. /**
  67957. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67958. * @param result output the box extent values
  67959. */
  67960. getDefaultQueryExtentToRef(result: Vector3): void;
  67961. /**
  67962. * Release all resources
  67963. */
  67964. dispose(): void;
  67965. }
  67966. /**
  67967. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  67968. */
  67969. export interface ICrowd {
  67970. /**
  67971. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67972. * You can attach anything to that node. The node position is updated in the scene update tick.
  67973. * @param pos world position that will be constrained by the navigation mesh
  67974. * @param parameters agent parameters
  67975. * @param transform hooked to the agent that will be update by the scene
  67976. * @returns agent index
  67977. */
  67978. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67979. /**
  67980. * Returns the agent position in world space
  67981. * @param index agent index returned by addAgent
  67982. * @returns world space position
  67983. */
  67984. getAgentPosition(index: number): Vector3;
  67985. /**
  67986. * Gets the agent position result in world space
  67987. * @param index agent index returned by addAgent
  67988. * @param result output world space position
  67989. */
  67990. getAgentPositionToRef(index: number, result: Vector3): void;
  67991. /**
  67992. * Gets the agent velocity in world space
  67993. * @param index agent index returned by addAgent
  67994. * @returns world space velocity
  67995. */
  67996. getAgentVelocity(index: number): Vector3;
  67997. /**
  67998. * Gets the agent velocity result in world space
  67999. * @param index agent index returned by addAgent
  68000. * @param result output world space velocity
  68001. */
  68002. getAgentVelocityToRef(index: number, result: Vector3): void;
  68003. /**
  68004. * Gets the agent next target point on the path
  68005. * @param index agent index returned by addAgent
  68006. * @returns world space position
  68007. */
  68008. getAgentNextTargetPath(index: number): Vector3;
  68009. /**
  68010. * Gets the agent state
  68011. * @param index agent index returned by addAgent
  68012. * @returns agent state
  68013. */
  68014. getAgentState(index: number): number;
  68015. /**
  68016. * returns true if the agent in over an off mesh link connection
  68017. * @param index agent index returned by addAgent
  68018. * @returns true if over an off mesh link connection
  68019. */
  68020. overOffmeshConnection(index: number): boolean;
  68021. /**
  68022. * Gets the agent next target point on the path
  68023. * @param index agent index returned by addAgent
  68024. * @param result output world space position
  68025. */
  68026. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  68027. /**
  68028. * remove a particular agent previously created
  68029. * @param index agent index returned by addAgent
  68030. */
  68031. removeAgent(index: number): void;
  68032. /**
  68033. * get the list of all agents attached to this crowd
  68034. * @returns list of agent indices
  68035. */
  68036. getAgents(): number[];
  68037. /**
  68038. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68039. * @param deltaTime in seconds
  68040. */
  68041. update(deltaTime: number): void;
  68042. /**
  68043. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68044. * @param index agent index returned by addAgent
  68045. * @param destination targeted world position
  68046. */
  68047. agentGoto(index: number, destination: Vector3): void;
  68048. /**
  68049. * Teleport the agent to a new position
  68050. * @param index agent index returned by addAgent
  68051. * @param destination targeted world position
  68052. */
  68053. agentTeleport(index: number, destination: Vector3): void;
  68054. /**
  68055. * Update agent parameters
  68056. * @param index agent index returned by addAgent
  68057. * @param parameters agent parameters
  68058. */
  68059. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68060. /**
  68061. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68062. * The queries will try to find a solution within those bounds
  68063. * default is (1,1,1)
  68064. * @param extent x,y,z value that define the extent around the queries point of reference
  68065. */
  68066. setDefaultQueryExtent(extent: Vector3): void;
  68067. /**
  68068. * Get the Bounding box extent specified by setDefaultQueryExtent
  68069. * @returns the box extent values
  68070. */
  68071. getDefaultQueryExtent(): Vector3;
  68072. /**
  68073. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68074. * @param result output the box extent values
  68075. */
  68076. getDefaultQueryExtentToRef(result: Vector3): void;
  68077. /**
  68078. * Release all resources
  68079. */
  68080. dispose(): void;
  68081. }
  68082. /**
  68083. * Configures an agent
  68084. */
  68085. export interface IAgentParameters {
  68086. /**
  68087. * Agent radius. [Limit: >= 0]
  68088. */
  68089. radius: number;
  68090. /**
  68091. * Agent height. [Limit: > 0]
  68092. */
  68093. height: number;
  68094. /**
  68095. * Maximum allowed acceleration. [Limit: >= 0]
  68096. */
  68097. maxAcceleration: number;
  68098. /**
  68099. * Maximum allowed speed. [Limit: >= 0]
  68100. */
  68101. maxSpeed: number;
  68102. /**
  68103. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  68104. */
  68105. collisionQueryRange: number;
  68106. /**
  68107. * The path visibility optimization range. [Limit: > 0]
  68108. */
  68109. pathOptimizationRange: number;
  68110. /**
  68111. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  68112. */
  68113. separationWeight: number;
  68114. }
  68115. /**
  68116. * Configures the navigation mesh creation
  68117. */
  68118. export interface INavMeshParameters {
  68119. /**
  68120. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  68121. */
  68122. cs: number;
  68123. /**
  68124. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  68125. */
  68126. ch: number;
  68127. /**
  68128. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  68129. */
  68130. walkableSlopeAngle: number;
  68131. /**
  68132. * Minimum floor to 'ceiling' height that will still allow the floor area to
  68133. * be considered walkable. [Limit: >= 3] [Units: vx]
  68134. */
  68135. walkableHeight: number;
  68136. /**
  68137. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  68138. */
  68139. walkableClimb: number;
  68140. /**
  68141. * The distance to erode/shrink the walkable area of the heightfield away from
  68142. * obstructions. [Limit: >=0] [Units: vx]
  68143. */
  68144. walkableRadius: number;
  68145. /**
  68146. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  68147. */
  68148. maxEdgeLen: number;
  68149. /**
  68150. * The maximum distance a simplfied contour's border edges should deviate
  68151. * the original raw contour. [Limit: >=0] [Units: vx]
  68152. */
  68153. maxSimplificationError: number;
  68154. /**
  68155. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  68156. */
  68157. minRegionArea: number;
  68158. /**
  68159. * Any regions with a span count smaller than this value will, if possible,
  68160. * be merged with larger regions. [Limit: >=0] [Units: vx]
  68161. */
  68162. mergeRegionArea: number;
  68163. /**
  68164. * The maximum number of vertices allowed for polygons generated during the
  68165. * contour to polygon conversion process. [Limit: >= 3]
  68166. */
  68167. maxVertsPerPoly: number;
  68168. /**
  68169. * Sets the sampling distance to use when generating the detail mesh.
  68170. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  68171. */
  68172. detailSampleDist: number;
  68173. /**
  68174. * The maximum distance the detail mesh surface should deviate from heightfield
  68175. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  68176. */
  68177. detailSampleMaxError: number;
  68178. }
  68179. }
  68180. declare module BABYLON {
  68181. /**
  68182. * RecastJS navigation plugin
  68183. */
  68184. export class RecastJSPlugin implements INavigationEnginePlugin {
  68185. /**
  68186. * Reference to the Recast library
  68187. */
  68188. bjsRECAST: any;
  68189. /**
  68190. * plugin name
  68191. */
  68192. name: string;
  68193. /**
  68194. * the first navmesh created. We might extend this to support multiple navmeshes
  68195. */
  68196. navMesh: any;
  68197. /**
  68198. * Initializes the recastJS plugin
  68199. * @param recastInjection can be used to inject your own recast reference
  68200. */
  68201. constructor(recastInjection?: any);
  68202. /**
  68203. * Creates a navigation mesh
  68204. * @param meshes array of all the geometry used to compute the navigatio mesh
  68205. * @param parameters bunch of parameters used to filter geometry
  68206. */
  68207. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  68208. /**
  68209. * Create a navigation mesh debug mesh
  68210. * @param scene is where the mesh will be added
  68211. * @returns debug display mesh
  68212. */
  68213. createDebugNavMesh(scene: Scene): Mesh;
  68214. /**
  68215. * Get a navigation mesh constrained position, closest to the parameter position
  68216. * @param position world position
  68217. * @returns the closest point to position constrained by the navigation mesh
  68218. */
  68219. getClosestPoint(position: Vector3): Vector3;
  68220. /**
  68221. * Get a navigation mesh constrained position, closest to the parameter position
  68222. * @param position world position
  68223. * @param result output the closest point to position constrained by the navigation mesh
  68224. */
  68225. getClosestPointToRef(position: Vector3, result: Vector3): void;
  68226. /**
  68227. * Get a navigation mesh constrained position, within a particular radius
  68228. * @param position world position
  68229. * @param maxRadius the maximum distance to the constrained world position
  68230. * @returns the closest point to position constrained by the navigation mesh
  68231. */
  68232. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  68233. /**
  68234. * Get a navigation mesh constrained position, within a particular radius
  68235. * @param position world position
  68236. * @param maxRadius the maximum distance to the constrained world position
  68237. * @param result output the closest point to position constrained by the navigation mesh
  68238. */
  68239. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  68240. /**
  68241. * Compute the final position from a segment made of destination-position
  68242. * @param position world position
  68243. * @param destination world position
  68244. * @returns the resulting point along the navmesh
  68245. */
  68246. moveAlong(position: Vector3, destination: Vector3): Vector3;
  68247. /**
  68248. * Compute the final position from a segment made of destination-position
  68249. * @param position world position
  68250. * @param destination world position
  68251. * @param result output the resulting point along the navmesh
  68252. */
  68253. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  68254. /**
  68255. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  68256. * @param start world position
  68257. * @param end world position
  68258. * @returns array containing world position composing the path
  68259. */
  68260. computePath(start: Vector3, end: Vector3): Vector3[];
  68261. /**
  68262. * Create a new Crowd so you can add agents
  68263. * @param maxAgents the maximum agent count in the crowd
  68264. * @param maxAgentRadius the maximum radius an agent can have
  68265. * @param scene to attach the crowd to
  68266. * @returns the crowd you can add agents to
  68267. */
  68268. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  68269. /**
  68270. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68271. * The queries will try to find a solution within those bounds
  68272. * default is (1,1,1)
  68273. * @param extent x,y,z value that define the extent around the queries point of reference
  68274. */
  68275. setDefaultQueryExtent(extent: Vector3): void;
  68276. /**
  68277. * Get the Bounding box extent specified by setDefaultQueryExtent
  68278. * @returns the box extent values
  68279. */
  68280. getDefaultQueryExtent(): Vector3;
  68281. /**
  68282. * build the navmesh from a previously saved state using getNavmeshData
  68283. * @param data the Uint8Array returned by getNavmeshData
  68284. */
  68285. buildFromNavmeshData(data: Uint8Array): void;
  68286. /**
  68287. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  68288. * @returns data the Uint8Array that can be saved and reused
  68289. */
  68290. getNavmeshData(): Uint8Array;
  68291. /**
  68292. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68293. * @param result output the box extent values
  68294. */
  68295. getDefaultQueryExtentToRef(result: Vector3): void;
  68296. /**
  68297. * Disposes
  68298. */
  68299. dispose(): void;
  68300. /**
  68301. * If this plugin is supported
  68302. * @returns true if plugin is supported
  68303. */
  68304. isSupported(): boolean;
  68305. }
  68306. /**
  68307. * Recast detour crowd implementation
  68308. */
  68309. export class RecastJSCrowd implements ICrowd {
  68310. /**
  68311. * Recast/detour plugin
  68312. */
  68313. bjsRECASTPlugin: RecastJSPlugin;
  68314. /**
  68315. * Link to the detour crowd
  68316. */
  68317. recastCrowd: any;
  68318. /**
  68319. * One transform per agent
  68320. */
  68321. transforms: TransformNode[];
  68322. /**
  68323. * All agents created
  68324. */
  68325. agents: number[];
  68326. /**
  68327. * Link to the scene is kept to unregister the crowd from the scene
  68328. */
  68329. private _scene;
  68330. /**
  68331. * Observer for crowd updates
  68332. */
  68333. private _onBeforeAnimationsObserver;
  68334. /**
  68335. * Constructor
  68336. * @param plugin recastJS plugin
  68337. * @param maxAgents the maximum agent count in the crowd
  68338. * @param maxAgentRadius the maximum radius an agent can have
  68339. * @param scene to attach the crowd to
  68340. * @returns the crowd you can add agents to
  68341. */
  68342. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  68343. /**
  68344. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  68345. * You can attach anything to that node. The node position is updated in the scene update tick.
  68346. * @param pos world position that will be constrained by the navigation mesh
  68347. * @param parameters agent parameters
  68348. * @param transform hooked to the agent that will be update by the scene
  68349. * @returns agent index
  68350. */
  68351. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  68352. /**
  68353. * Returns the agent position in world space
  68354. * @param index agent index returned by addAgent
  68355. * @returns world space position
  68356. */
  68357. getAgentPosition(index: number): Vector3;
  68358. /**
  68359. * Returns the agent position result in world space
  68360. * @param index agent index returned by addAgent
  68361. * @param result output world space position
  68362. */
  68363. getAgentPositionToRef(index: number, result: Vector3): void;
  68364. /**
  68365. * Returns the agent velocity in world space
  68366. * @param index agent index returned by addAgent
  68367. * @returns world space velocity
  68368. */
  68369. getAgentVelocity(index: number): Vector3;
  68370. /**
  68371. * Returns the agent velocity result in world space
  68372. * @param index agent index returned by addAgent
  68373. * @param result output world space velocity
  68374. */
  68375. getAgentVelocityToRef(index: number, result: Vector3): void;
  68376. /**
  68377. * Returns the agent next target point on the path
  68378. * @param index agent index returned by addAgent
  68379. * @returns world space position
  68380. */
  68381. getAgentNextTargetPath(index: number): Vector3;
  68382. /**
  68383. * Returns the agent next target point on the path
  68384. * @param index agent index returned by addAgent
  68385. * @param result output world space position
  68386. */
  68387. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  68388. /**
  68389. * Gets the agent state
  68390. * @param index agent index returned by addAgent
  68391. * @returns agent state
  68392. */
  68393. getAgentState(index: number): number;
  68394. /**
  68395. * returns true if the agent in over an off mesh link connection
  68396. * @param index agent index returned by addAgent
  68397. * @returns true if over an off mesh link connection
  68398. */
  68399. overOffmeshConnection(index: number): boolean;
  68400. /**
  68401. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68402. * @param index agent index returned by addAgent
  68403. * @param destination targeted world position
  68404. */
  68405. agentGoto(index: number, destination: Vector3): void;
  68406. /**
  68407. * Teleport the agent to a new position
  68408. * @param index agent index returned by addAgent
  68409. * @param destination targeted world position
  68410. */
  68411. agentTeleport(index: number, destination: Vector3): void;
  68412. /**
  68413. * Update agent parameters
  68414. * @param index agent index returned by addAgent
  68415. * @param parameters agent parameters
  68416. */
  68417. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68418. /**
  68419. * remove a particular agent previously created
  68420. * @param index agent index returned by addAgent
  68421. */
  68422. removeAgent(index: number): void;
  68423. /**
  68424. * get the list of all agents attached to this crowd
  68425. * @returns list of agent indices
  68426. */
  68427. getAgents(): number[];
  68428. /**
  68429. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68430. * @param deltaTime in seconds
  68431. */
  68432. update(deltaTime: number): void;
  68433. /**
  68434. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68435. * The queries will try to find a solution within those bounds
  68436. * default is (1,1,1)
  68437. * @param extent x,y,z value that define the extent around the queries point of reference
  68438. */
  68439. setDefaultQueryExtent(extent: Vector3): void;
  68440. /**
  68441. * Get the Bounding box extent specified by setDefaultQueryExtent
  68442. * @returns the box extent values
  68443. */
  68444. getDefaultQueryExtent(): Vector3;
  68445. /**
  68446. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68447. * @param result output the box extent values
  68448. */
  68449. getDefaultQueryExtentToRef(result: Vector3): void;
  68450. /**
  68451. * Release all resources
  68452. */
  68453. dispose(): void;
  68454. }
  68455. }
  68456. declare module BABYLON {
  68457. /**
  68458. * Class used to enable access to IndexedDB
  68459. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  68460. */
  68461. export class Database implements IOfflineProvider {
  68462. private _callbackManifestChecked;
  68463. private _currentSceneUrl;
  68464. private _db;
  68465. private _enableSceneOffline;
  68466. private _enableTexturesOffline;
  68467. private _manifestVersionFound;
  68468. private _mustUpdateRessources;
  68469. private _hasReachedQuota;
  68470. private _isSupported;
  68471. private _idbFactory;
  68472. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  68473. private static IsUASupportingBlobStorage;
  68474. /**
  68475. * Gets a boolean indicating if Database storate is enabled (off by default)
  68476. */
  68477. static IDBStorageEnabled: boolean;
  68478. /**
  68479. * Gets a boolean indicating if scene must be saved in the database
  68480. */
  68481. get enableSceneOffline(): boolean;
  68482. /**
  68483. * Gets a boolean indicating if textures must be saved in the database
  68484. */
  68485. get enableTexturesOffline(): boolean;
  68486. /**
  68487. * Creates a new Database
  68488. * @param urlToScene defines the url to load the scene
  68489. * @param callbackManifestChecked defines the callback to use when manifest is checked
  68490. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  68491. */
  68492. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  68493. private static _ParseURL;
  68494. private static _ReturnFullUrlLocation;
  68495. private _checkManifestFile;
  68496. /**
  68497. * Open the database and make it available
  68498. * @param successCallback defines the callback to call on success
  68499. * @param errorCallback defines the callback to call on error
  68500. */
  68501. open(successCallback: () => void, errorCallback: () => void): void;
  68502. /**
  68503. * Loads an image from the database
  68504. * @param url defines the url to load from
  68505. * @param image defines the target DOM image
  68506. */
  68507. loadImage(url: string, image: HTMLImageElement): void;
  68508. private _loadImageFromDBAsync;
  68509. private _saveImageIntoDBAsync;
  68510. private _checkVersionFromDB;
  68511. private _loadVersionFromDBAsync;
  68512. private _saveVersionIntoDBAsync;
  68513. /**
  68514. * Loads a file from database
  68515. * @param url defines the URL to load from
  68516. * @param sceneLoaded defines a callback to call on success
  68517. * @param progressCallBack defines a callback to call when progress changed
  68518. * @param errorCallback defines a callback to call on error
  68519. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  68520. */
  68521. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  68522. private _loadFileAsync;
  68523. private _saveFileAsync;
  68524. /**
  68525. * Validates if xhr data is correct
  68526. * @param xhr defines the request to validate
  68527. * @param dataType defines the expected data type
  68528. * @returns true if data is correct
  68529. */
  68530. private static _ValidateXHRData;
  68531. }
  68532. }
  68533. declare module BABYLON {
  68534. /** @hidden */
  68535. export var gpuUpdateParticlesPixelShader: {
  68536. name: string;
  68537. shader: string;
  68538. };
  68539. }
  68540. declare module BABYLON {
  68541. /** @hidden */
  68542. export var gpuUpdateParticlesVertexShader: {
  68543. name: string;
  68544. shader: string;
  68545. };
  68546. }
  68547. declare module BABYLON {
  68548. /** @hidden */
  68549. export var clipPlaneFragmentDeclaration2: {
  68550. name: string;
  68551. shader: string;
  68552. };
  68553. }
  68554. declare module BABYLON {
  68555. /** @hidden */
  68556. export var gpuRenderParticlesPixelShader: {
  68557. name: string;
  68558. shader: string;
  68559. };
  68560. }
  68561. declare module BABYLON {
  68562. /** @hidden */
  68563. export var clipPlaneVertexDeclaration2: {
  68564. name: string;
  68565. shader: string;
  68566. };
  68567. }
  68568. declare module BABYLON {
  68569. /** @hidden */
  68570. export var gpuRenderParticlesVertexShader: {
  68571. name: string;
  68572. shader: string;
  68573. };
  68574. }
  68575. declare module BABYLON {
  68576. /**
  68577. * This represents a GPU particle system in Babylon
  68578. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  68579. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  68580. */
  68581. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  68582. /**
  68583. * The layer mask we are rendering the particles through.
  68584. */
  68585. layerMask: number;
  68586. private _capacity;
  68587. private _activeCount;
  68588. private _currentActiveCount;
  68589. private _accumulatedCount;
  68590. private _renderEffect;
  68591. private _updateEffect;
  68592. private _buffer0;
  68593. private _buffer1;
  68594. private _spriteBuffer;
  68595. private _updateVAO;
  68596. private _renderVAO;
  68597. private _targetIndex;
  68598. private _sourceBuffer;
  68599. private _targetBuffer;
  68600. private _currentRenderId;
  68601. private _started;
  68602. private _stopped;
  68603. private _timeDelta;
  68604. private _randomTexture;
  68605. private _randomTexture2;
  68606. private _attributesStrideSize;
  68607. private _updateEffectOptions;
  68608. private _randomTextureSize;
  68609. private _actualFrame;
  68610. private _customEffect;
  68611. private readonly _rawTextureWidth;
  68612. /**
  68613. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  68614. */
  68615. static get IsSupported(): boolean;
  68616. /**
  68617. * An event triggered when the system is disposed.
  68618. */
  68619. onDisposeObservable: Observable<IParticleSystem>;
  68620. /**
  68621. * An event triggered when the system is stopped
  68622. */
  68623. onStoppedObservable: Observable<IParticleSystem>;
  68624. /**
  68625. * Gets the maximum number of particles active at the same time.
  68626. * @returns The max number of active particles.
  68627. */
  68628. getCapacity(): number;
  68629. /**
  68630. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  68631. * to override the particles.
  68632. */
  68633. forceDepthWrite: boolean;
  68634. /**
  68635. * Gets or set the number of active particles
  68636. */
  68637. get activeParticleCount(): number;
  68638. set activeParticleCount(value: number);
  68639. private _preWarmDone;
  68640. /**
  68641. * Specifies if the particles are updated in emitter local space or world space.
  68642. */
  68643. isLocal: boolean;
  68644. /** Gets or sets a matrix to use to compute projection */
  68645. defaultProjectionMatrix: Matrix;
  68646. /**
  68647. * Is this system ready to be used/rendered
  68648. * @return true if the system is ready
  68649. */
  68650. isReady(): boolean;
  68651. /**
  68652. * Gets if the system has been started. (Note: this will still be true after stop is called)
  68653. * @returns True if it has been started, otherwise false.
  68654. */
  68655. isStarted(): boolean;
  68656. /**
  68657. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  68658. * @returns True if it has been stopped, otherwise false.
  68659. */
  68660. isStopped(): boolean;
  68661. /**
  68662. * Gets a boolean indicating that the system is stopping
  68663. * @returns true if the system is currently stopping
  68664. */
  68665. isStopping(): boolean;
  68666. /**
  68667. * Gets the number of particles active at the same time.
  68668. * @returns The number of active particles.
  68669. */
  68670. getActiveCount(): number;
  68671. /**
  68672. * Starts the particle system and begins to emit
  68673. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  68674. */
  68675. start(delay?: number): void;
  68676. /**
  68677. * Stops the particle system.
  68678. */
  68679. stop(): void;
  68680. /**
  68681. * Remove all active particles
  68682. */
  68683. reset(): void;
  68684. /**
  68685. * Returns the string "GPUParticleSystem"
  68686. * @returns a string containing the class name
  68687. */
  68688. getClassName(): string;
  68689. /**
  68690. * Gets the custom effect used to render the particles
  68691. * @param blendMode Blend mode for which the effect should be retrieved
  68692. * @returns The effect
  68693. */
  68694. getCustomEffect(blendMode?: number): Nullable<Effect>;
  68695. /**
  68696. * Sets the custom effect used to render the particles
  68697. * @param effect The effect to set
  68698. * @param blendMode Blend mode for which the effect should be set
  68699. */
  68700. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  68701. /** @hidden */
  68702. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  68703. /**
  68704. * Observable that will be called just before the particles are drawn
  68705. */
  68706. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  68707. /**
  68708. * Gets the name of the particle vertex shader
  68709. */
  68710. get vertexShaderName(): string;
  68711. private _colorGradientsTexture;
  68712. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  68713. /**
  68714. * Adds a new color gradient
  68715. * @param gradient defines the gradient to use (between 0 and 1)
  68716. * @param color1 defines the color to affect to the specified gradient
  68717. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  68718. * @returns the current particle system
  68719. */
  68720. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  68721. private _refreshColorGradient;
  68722. /** Force the system to rebuild all gradients that need to be resync */
  68723. forceRefreshGradients(): void;
  68724. /**
  68725. * Remove a specific color gradient
  68726. * @param gradient defines the gradient to remove
  68727. * @returns the current particle system
  68728. */
  68729. removeColorGradient(gradient: number): GPUParticleSystem;
  68730. private _angularSpeedGradientsTexture;
  68731. private _sizeGradientsTexture;
  68732. private _velocityGradientsTexture;
  68733. private _limitVelocityGradientsTexture;
  68734. private _dragGradientsTexture;
  68735. private _addFactorGradient;
  68736. /**
  68737. * Adds a new size gradient
  68738. * @param gradient defines the gradient to use (between 0 and 1)
  68739. * @param factor defines the size factor to affect to the specified gradient
  68740. * @returns the current particle system
  68741. */
  68742. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  68743. /**
  68744. * Remove a specific size gradient
  68745. * @param gradient defines the gradient to remove
  68746. * @returns the current particle system
  68747. */
  68748. removeSizeGradient(gradient: number): GPUParticleSystem;
  68749. private _refreshFactorGradient;
  68750. /**
  68751. * Adds a new angular speed gradient
  68752. * @param gradient defines the gradient to use (between 0 and 1)
  68753. * @param factor defines the angular speed to affect to the specified gradient
  68754. * @returns the current particle system
  68755. */
  68756. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  68757. /**
  68758. * Remove a specific angular speed gradient
  68759. * @param gradient defines the gradient to remove
  68760. * @returns the current particle system
  68761. */
  68762. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  68763. /**
  68764. * Adds a new velocity gradient
  68765. * @param gradient defines the gradient to use (between 0 and 1)
  68766. * @param factor defines the velocity to affect to the specified gradient
  68767. * @returns the current particle system
  68768. */
  68769. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  68770. /**
  68771. * Remove a specific velocity gradient
  68772. * @param gradient defines the gradient to remove
  68773. * @returns the current particle system
  68774. */
  68775. removeVelocityGradient(gradient: number): GPUParticleSystem;
  68776. /**
  68777. * Adds a new limit velocity gradient
  68778. * @param gradient defines the gradient to use (between 0 and 1)
  68779. * @param factor defines the limit velocity value to affect to the specified gradient
  68780. * @returns the current particle system
  68781. */
  68782. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  68783. /**
  68784. * Remove a specific limit velocity gradient
  68785. * @param gradient defines the gradient to remove
  68786. * @returns the current particle system
  68787. */
  68788. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  68789. /**
  68790. * Adds a new drag gradient
  68791. * @param gradient defines the gradient to use (between 0 and 1)
  68792. * @param factor defines the drag value to affect to the specified gradient
  68793. * @returns the current particle system
  68794. */
  68795. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  68796. /**
  68797. * Remove a specific drag gradient
  68798. * @param gradient defines the gradient to remove
  68799. * @returns the current particle system
  68800. */
  68801. removeDragGradient(gradient: number): GPUParticleSystem;
  68802. /**
  68803. * Not supported by GPUParticleSystem
  68804. * @param gradient defines the gradient to use (between 0 and 1)
  68805. * @param factor defines the emit rate value to affect to the specified gradient
  68806. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68807. * @returns the current particle system
  68808. */
  68809. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68810. /**
  68811. * Not supported by GPUParticleSystem
  68812. * @param gradient defines the gradient to remove
  68813. * @returns the current particle system
  68814. */
  68815. removeEmitRateGradient(gradient: number): IParticleSystem;
  68816. /**
  68817. * Not supported by GPUParticleSystem
  68818. * @param gradient defines the gradient to use (between 0 and 1)
  68819. * @param factor defines the start size value to affect to the specified gradient
  68820. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68821. * @returns the current particle system
  68822. */
  68823. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68824. /**
  68825. * Not supported by GPUParticleSystem
  68826. * @param gradient defines the gradient to remove
  68827. * @returns the current particle system
  68828. */
  68829. removeStartSizeGradient(gradient: number): IParticleSystem;
  68830. /**
  68831. * Not supported by GPUParticleSystem
  68832. * @param gradient defines the gradient to use (between 0 and 1)
  68833. * @param min defines the color remap minimal range
  68834. * @param max defines the color remap maximal range
  68835. * @returns the current particle system
  68836. */
  68837. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  68838. /**
  68839. * Not supported by GPUParticleSystem
  68840. * @param gradient defines the gradient to remove
  68841. * @returns the current particle system
  68842. */
  68843. removeColorRemapGradient(): IParticleSystem;
  68844. /**
  68845. * Not supported by GPUParticleSystem
  68846. * @param gradient defines the gradient to use (between 0 and 1)
  68847. * @param min defines the alpha remap minimal range
  68848. * @param max defines the alpha remap maximal range
  68849. * @returns the current particle system
  68850. */
  68851. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  68852. /**
  68853. * Not supported by GPUParticleSystem
  68854. * @param gradient defines the gradient to remove
  68855. * @returns the current particle system
  68856. */
  68857. removeAlphaRemapGradient(): IParticleSystem;
  68858. /**
  68859. * Not supported by GPUParticleSystem
  68860. * @param gradient defines the gradient to use (between 0 and 1)
  68861. * @param color defines the color to affect to the specified gradient
  68862. * @returns the current particle system
  68863. */
  68864. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  68865. /**
  68866. * Not supported by GPUParticleSystem
  68867. * @param gradient defines the gradient to remove
  68868. * @returns the current particle system
  68869. */
  68870. removeRampGradient(): IParticleSystem;
  68871. /**
  68872. * Not supported by GPUParticleSystem
  68873. * @returns the list of ramp gradients
  68874. */
  68875. getRampGradients(): Nullable<Array<Color3Gradient>>;
  68876. /**
  68877. * Not supported by GPUParticleSystem
  68878. * Gets or sets a boolean indicating that ramp gradients must be used
  68879. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  68880. */
  68881. get useRampGradients(): boolean;
  68882. set useRampGradients(value: boolean);
  68883. /**
  68884. * Not supported by GPUParticleSystem
  68885. * @param gradient defines the gradient to use (between 0 and 1)
  68886. * @param factor defines the life time factor to affect to the specified gradient
  68887. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68888. * @returns the current particle system
  68889. */
  68890. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68891. /**
  68892. * Not supported by GPUParticleSystem
  68893. * @param gradient defines the gradient to remove
  68894. * @returns the current particle system
  68895. */
  68896. removeLifeTimeGradient(gradient: number): IParticleSystem;
  68897. /**
  68898. * Instantiates a GPU particle system.
  68899. * 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.
  68900. * @param name The name of the particle system
  68901. * @param options The options used to create the system
  68902. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  68903. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  68904. * @param customEffect a custom effect used to change the way particles are rendered by default
  68905. */
  68906. constructor(name: string, options: Partial<{
  68907. capacity: number;
  68908. randomTextureSize: number;
  68909. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  68910. protected _reset(): void;
  68911. private _createUpdateVAO;
  68912. private _createRenderVAO;
  68913. private _initialize;
  68914. /** @hidden */
  68915. _recreateUpdateEffect(): void;
  68916. private _getEffect;
  68917. /**
  68918. * Fill the defines array according to the current settings of the particle system
  68919. * @param defines Array to be updated
  68920. * @param blendMode blend mode to take into account when updating the array
  68921. */
  68922. fillDefines(defines: Array<string>, blendMode?: number): void;
  68923. /**
  68924. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  68925. * @param uniforms Uniforms array to fill
  68926. * @param attributes Attributes array to fill
  68927. * @param samplers Samplers array to fill
  68928. */
  68929. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  68930. /** @hidden */
  68931. _recreateRenderEffect(): Effect;
  68932. /**
  68933. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  68934. * @param preWarm defines if we are in the pre-warmimg phase
  68935. */
  68936. animate(preWarm?: boolean): void;
  68937. private _createFactorGradientTexture;
  68938. private _createSizeGradientTexture;
  68939. private _createAngularSpeedGradientTexture;
  68940. private _createVelocityGradientTexture;
  68941. private _createLimitVelocityGradientTexture;
  68942. private _createDragGradientTexture;
  68943. private _createColorGradientTexture;
  68944. /**
  68945. * Renders the particle system in its current state
  68946. * @param preWarm defines if the system should only update the particles but not render them
  68947. * @returns the current number of particles
  68948. */
  68949. render(preWarm?: boolean): number;
  68950. /**
  68951. * Rebuilds the particle system
  68952. */
  68953. rebuild(): void;
  68954. private _releaseBuffers;
  68955. private _releaseVAOs;
  68956. /**
  68957. * Disposes the particle system and free the associated resources
  68958. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  68959. */
  68960. dispose(disposeTexture?: boolean): void;
  68961. /**
  68962. * Clones the particle system.
  68963. * @param name The name of the cloned object
  68964. * @param newEmitter The new emitter to use
  68965. * @returns the cloned particle system
  68966. */
  68967. clone(name: string, newEmitter: any): GPUParticleSystem;
  68968. /**
  68969. * Serializes the particle system to a JSON object
  68970. * @param serializeTexture defines if the texture must be serialized as well
  68971. * @returns the JSON object
  68972. */
  68973. serialize(serializeTexture?: boolean): any;
  68974. /**
  68975. * Parses a JSON object to create a GPU particle system.
  68976. * @param parsedParticleSystem The JSON object to parse
  68977. * @param sceneOrEngine The scene or the engine to create the particle system in
  68978. * @param rootUrl The root url to use to load external dependencies like texture
  68979. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  68980. * @returns the parsed GPU particle system
  68981. */
  68982. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  68983. }
  68984. }
  68985. declare module BABYLON {
  68986. /**
  68987. * Represents a set of particle systems working together to create a specific effect
  68988. */
  68989. export class ParticleSystemSet implements IDisposable {
  68990. /**
  68991. * Gets or sets base Assets URL
  68992. */
  68993. static BaseAssetsUrl: string;
  68994. private _emitterCreationOptions;
  68995. private _emitterNode;
  68996. /**
  68997. * Gets the particle system list
  68998. */
  68999. systems: IParticleSystem[];
  69000. /**
  69001. * Gets the emitter node used with this set
  69002. */
  69003. get emitterNode(): Nullable<TransformNode>;
  69004. /**
  69005. * Creates a new emitter mesh as a sphere
  69006. * @param options defines the options used to create the sphere
  69007. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  69008. * @param scene defines the hosting scene
  69009. */
  69010. setEmitterAsSphere(options: {
  69011. diameter: number;
  69012. segments: number;
  69013. color: Color3;
  69014. }, renderingGroupId: number, scene: Scene): void;
  69015. /**
  69016. * Starts all particle systems of the set
  69017. * @param emitter defines an optional mesh to use as emitter for the particle systems
  69018. */
  69019. start(emitter?: AbstractMesh): void;
  69020. /**
  69021. * Release all associated resources
  69022. */
  69023. dispose(): void;
  69024. /**
  69025. * Serialize the set into a JSON compatible object
  69026. * @param serializeTexture defines if the texture must be serialized as well
  69027. * @returns a JSON compatible representation of the set
  69028. */
  69029. serialize(serializeTexture?: boolean): any;
  69030. /**
  69031. * Parse a new ParticleSystemSet from a serialized source
  69032. * @param data defines a JSON compatible representation of the set
  69033. * @param scene defines the hosting scene
  69034. * @param gpu defines if we want GPU particles or CPU particles
  69035. * @returns a new ParticleSystemSet
  69036. */
  69037. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  69038. }
  69039. }
  69040. declare module BABYLON {
  69041. /**
  69042. * This class is made for on one-liner static method to help creating particle system set.
  69043. */
  69044. export class ParticleHelper {
  69045. /**
  69046. * Gets or sets base Assets URL
  69047. */
  69048. static BaseAssetsUrl: string;
  69049. /** Define the Url to load snippets */
  69050. static SnippetUrl: string;
  69051. /**
  69052. * Create a default particle system that you can tweak
  69053. * @param emitter defines the emitter to use
  69054. * @param capacity defines the system capacity (default is 500 particles)
  69055. * @param scene defines the hosting scene
  69056. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  69057. * @returns the new Particle system
  69058. */
  69059. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  69060. /**
  69061. * This is the main static method (one-liner) of this helper to create different particle systems
  69062. * @param type This string represents the type to the particle system to create
  69063. * @param scene The scene where the particle system should live
  69064. * @param gpu If the system will use gpu
  69065. * @returns the ParticleSystemSet created
  69066. */
  69067. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  69068. /**
  69069. * Static function used to export a particle system to a ParticleSystemSet variable.
  69070. * Please note that the emitter shape is not exported
  69071. * @param systems defines the particle systems to export
  69072. * @returns the created particle system set
  69073. */
  69074. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  69075. /**
  69076. * Creates a particle system from a snippet saved in a remote file
  69077. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  69078. * @param url defines the url to load from
  69079. * @param scene defines the hosting scene
  69080. * @param gpu If the system will use gpu
  69081. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69082. * @returns a promise that will resolve to the new particle system
  69083. */
  69084. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  69085. /**
  69086. * Creates a particle system from a snippet saved by the particle system editor
  69087. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  69088. * @param scene defines the hosting scene
  69089. * @param gpu If the system will use gpu
  69090. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69091. * @returns a promise that will resolve to the new particle system
  69092. */
  69093. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  69094. }
  69095. }
  69096. declare module BABYLON {
  69097. interface Engine {
  69098. /**
  69099. * Create an effect to use with particle systems.
  69100. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  69101. * the particle system for which you want to create a custom effect in the last parameter
  69102. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  69103. * @param uniformsNames defines a list of attribute names
  69104. * @param samplers defines an array of string used to represent textures
  69105. * @param defines defines the string containing the defines to use to compile the shaders
  69106. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  69107. * @param onCompiled defines a function to call when the effect creation is successful
  69108. * @param onError defines a function to call when the effect creation has failed
  69109. * @param particleSystem the particle system you want to create the effect for
  69110. * @returns the new Effect
  69111. */
  69112. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  69113. }
  69114. interface Mesh {
  69115. /**
  69116. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  69117. * @returns an array of IParticleSystem
  69118. */
  69119. getEmittedParticleSystems(): IParticleSystem[];
  69120. /**
  69121. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  69122. * @returns an array of IParticleSystem
  69123. */
  69124. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  69125. }
  69126. }
  69127. declare module BABYLON {
  69128. /** Defines the 4 color options */
  69129. export enum PointColor {
  69130. /** color value */
  69131. Color = 2,
  69132. /** uv value */
  69133. UV = 1,
  69134. /** random value */
  69135. Random = 0,
  69136. /** stated value */
  69137. Stated = 3
  69138. }
  69139. /**
  69140. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  69141. * 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.
  69142. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  69143. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  69144. *
  69145. * Full documentation here : TO BE ENTERED
  69146. */
  69147. export class PointsCloudSystem implements IDisposable {
  69148. /**
  69149. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  69150. * Example : var p = SPS.particles[i];
  69151. */
  69152. particles: CloudPoint[];
  69153. /**
  69154. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  69155. */
  69156. nbParticles: number;
  69157. /**
  69158. * This a counter for your own usage. It's not set by any SPS functions.
  69159. */
  69160. counter: number;
  69161. /**
  69162. * The PCS name. This name is also given to the underlying mesh.
  69163. */
  69164. name: string;
  69165. /**
  69166. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  69167. */
  69168. mesh: Mesh;
  69169. /**
  69170. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  69171. * Please read :
  69172. */
  69173. vars: any;
  69174. /**
  69175. * @hidden
  69176. */
  69177. _size: number;
  69178. private _scene;
  69179. private _promises;
  69180. private _positions;
  69181. private _indices;
  69182. private _normals;
  69183. private _colors;
  69184. private _uvs;
  69185. private _indices32;
  69186. private _positions32;
  69187. private _colors32;
  69188. private _uvs32;
  69189. private _updatable;
  69190. private _isVisibilityBoxLocked;
  69191. private _alwaysVisible;
  69192. private _groups;
  69193. private _groupCounter;
  69194. private _computeParticleColor;
  69195. private _computeParticleTexture;
  69196. private _computeParticleRotation;
  69197. private _computeBoundingBox;
  69198. private _isReady;
  69199. /**
  69200. * Creates a PCS (Points Cloud System) object
  69201. * @param name (String) is the PCS name, this will be the underlying mesh name
  69202. * @param pointSize (number) is the size for each point
  69203. * @param scene (Scene) is the scene in which the PCS is added
  69204. * @param options defines the options of the PCS e.g.
  69205. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  69206. */
  69207. constructor(name: string, pointSize: number, scene: Scene, options?: {
  69208. updatable?: boolean;
  69209. });
  69210. /**
  69211. * Builds the PCS underlying mesh. Returns a standard Mesh.
  69212. * If no points were added to the PCS, the returned mesh is just a single point.
  69213. * @returns a promise for the created mesh
  69214. */
  69215. buildMeshAsync(): Promise<Mesh>;
  69216. /**
  69217. * @hidden
  69218. */
  69219. private _buildMesh;
  69220. private _addParticle;
  69221. private _randomUnitVector;
  69222. private _getColorIndicesForCoord;
  69223. private _setPointsColorOrUV;
  69224. private _colorFromTexture;
  69225. private _calculateDensity;
  69226. /**
  69227. * Adds points to the PCS in random positions within a unit sphere
  69228. * @param nb (positive integer) the number of particles to be created from this model
  69229. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  69230. * @returns the number of groups in the system
  69231. */
  69232. addPoints(nb: number, pointFunction?: any): number;
  69233. /**
  69234. * Adds points to the PCS from the surface of the model shape
  69235. * @param mesh is any Mesh object that will be used as a surface model for the points
  69236. * @param nb (positive integer) the number of particles to be created from this model
  69237. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  69238. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  69239. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  69240. * @returns the number of groups in the system
  69241. */
  69242. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  69243. /**
  69244. * Adds points to the PCS inside the model shape
  69245. * @param mesh is any Mesh object that will be used as a surface model for the points
  69246. * @param nb (positive integer) the number of particles to be created from this model
  69247. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  69248. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  69249. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  69250. * @returns the number of groups in the system
  69251. */
  69252. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  69253. /**
  69254. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  69255. * This method calls `updateParticle()` for each particle of the SPS.
  69256. * For an animated SPS, it is usually called within the render loop.
  69257. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  69258. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  69259. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  69260. * @returns the PCS.
  69261. */
  69262. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  69263. /**
  69264. * Disposes the PCS.
  69265. */
  69266. dispose(): void;
  69267. /**
  69268. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  69269. * doc :
  69270. * @returns the PCS.
  69271. */
  69272. refreshVisibleSize(): PointsCloudSystem;
  69273. /**
  69274. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  69275. * @param size the size (float) of the visibility box
  69276. * note : this doesn't lock the PCS mesh bounding box.
  69277. * doc :
  69278. */
  69279. setVisibilityBox(size: number): void;
  69280. /**
  69281. * Gets whether the PCS is always visible or not
  69282. * doc :
  69283. */
  69284. get isAlwaysVisible(): boolean;
  69285. /**
  69286. * Sets the PCS as always visible or not
  69287. * doc :
  69288. */
  69289. set isAlwaysVisible(val: boolean);
  69290. /**
  69291. * Tells to `setParticles()` to compute the particle rotations or not
  69292. * Default value : false. The PCS is faster when it's set to false
  69293. * Note : particle rotations are only applied to parent particles
  69294. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  69295. */
  69296. set computeParticleRotation(val: boolean);
  69297. /**
  69298. * Tells to `setParticles()` to compute the particle colors or not.
  69299. * Default value : true. The PCS is faster when it's set to false.
  69300. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  69301. */
  69302. set computeParticleColor(val: boolean);
  69303. set computeParticleTexture(val: boolean);
  69304. /**
  69305. * Gets if `setParticles()` computes the particle colors or not.
  69306. * Default value : false. The PCS is faster when it's set to false.
  69307. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  69308. */
  69309. get computeParticleColor(): boolean;
  69310. /**
  69311. * Gets if `setParticles()` computes the particle textures or not.
  69312. * Default value : false. The PCS is faster when it's set to false.
  69313. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  69314. */
  69315. get computeParticleTexture(): boolean;
  69316. /**
  69317. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  69318. */
  69319. set computeBoundingBox(val: boolean);
  69320. /**
  69321. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  69322. */
  69323. get computeBoundingBox(): boolean;
  69324. /**
  69325. * This function does nothing. It may be overwritten to set all the particle first values.
  69326. * The PCS doesn't call this function, you may have to call it by your own.
  69327. * doc :
  69328. */
  69329. initParticles(): void;
  69330. /**
  69331. * This function does nothing. It may be overwritten to recycle a particle
  69332. * The PCS doesn't call this function, you can to call it
  69333. * doc :
  69334. * @param particle The particle to recycle
  69335. * @returns the recycled particle
  69336. */
  69337. recycleParticle(particle: CloudPoint): CloudPoint;
  69338. /**
  69339. * Updates a particle : this function should be overwritten by the user.
  69340. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  69341. * doc :
  69342. * @example : just set a particle position or velocity and recycle conditions
  69343. * @param particle The particle to update
  69344. * @returns the updated particle
  69345. */
  69346. updateParticle(particle: CloudPoint): CloudPoint;
  69347. /**
  69348. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  69349. * This does nothing and may be overwritten by the user.
  69350. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  69351. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  69352. * @param update the boolean update value actually passed to setParticles()
  69353. */
  69354. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  69355. /**
  69356. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  69357. * This will be passed three parameters.
  69358. * This does nothing and may be overwritten by the user.
  69359. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  69360. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  69361. * @param update the boolean update value actually passed to setParticles()
  69362. */
  69363. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  69364. }
  69365. }
  69366. declare module BABYLON {
  69367. /**
  69368. * Represents one particle of a points cloud system.
  69369. */
  69370. export class CloudPoint {
  69371. /**
  69372. * particle global index
  69373. */
  69374. idx: number;
  69375. /**
  69376. * The color of the particle
  69377. */
  69378. color: Nullable<Color4>;
  69379. /**
  69380. * The world space position of the particle.
  69381. */
  69382. position: Vector3;
  69383. /**
  69384. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  69385. */
  69386. rotation: Vector3;
  69387. /**
  69388. * The world space rotation quaternion of the particle.
  69389. */
  69390. rotationQuaternion: Nullable<Quaternion>;
  69391. /**
  69392. * The uv of the particle.
  69393. */
  69394. uv: Nullable<Vector2>;
  69395. /**
  69396. * The current speed of the particle.
  69397. */
  69398. velocity: Vector3;
  69399. /**
  69400. * The pivot point in the particle local space.
  69401. */
  69402. pivot: Vector3;
  69403. /**
  69404. * Must the particle be translated from its pivot point in its local space ?
  69405. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  69406. * Default : false
  69407. */
  69408. translateFromPivot: boolean;
  69409. /**
  69410. * Index of this particle in the global "positions" array (Internal use)
  69411. * @hidden
  69412. */
  69413. _pos: number;
  69414. /**
  69415. * @hidden Index of this particle in the global "indices" array (Internal use)
  69416. */
  69417. _ind: number;
  69418. /**
  69419. * Group this particle belongs to
  69420. */
  69421. _group: PointsGroup;
  69422. /**
  69423. * Group id of this particle
  69424. */
  69425. groupId: number;
  69426. /**
  69427. * Index of the particle in its group id (Internal use)
  69428. */
  69429. idxInGroup: number;
  69430. /**
  69431. * @hidden Particle BoundingInfo object (Internal use)
  69432. */
  69433. _boundingInfo: BoundingInfo;
  69434. /**
  69435. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  69436. */
  69437. _pcs: PointsCloudSystem;
  69438. /**
  69439. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  69440. */
  69441. _stillInvisible: boolean;
  69442. /**
  69443. * @hidden Last computed particle rotation matrix
  69444. */
  69445. _rotationMatrix: number[];
  69446. /**
  69447. * Parent particle Id, if any.
  69448. * Default null.
  69449. */
  69450. parentId: Nullable<number>;
  69451. /**
  69452. * @hidden Internal global position in the PCS.
  69453. */
  69454. _globalPosition: Vector3;
  69455. /**
  69456. * Creates a Point Cloud object.
  69457. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  69458. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  69459. * @param group (PointsGroup) is the group the particle belongs to
  69460. * @param groupId (integer) is the group identifier in the PCS.
  69461. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  69462. * @param pcs defines the PCS it is associated to
  69463. */
  69464. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  69465. /**
  69466. * get point size
  69467. */
  69468. get size(): Vector3;
  69469. /**
  69470. * Set point size
  69471. */
  69472. set size(scale: Vector3);
  69473. /**
  69474. * Legacy support, changed quaternion to rotationQuaternion
  69475. */
  69476. get quaternion(): Nullable<Quaternion>;
  69477. /**
  69478. * Legacy support, changed quaternion to rotationQuaternion
  69479. */
  69480. set quaternion(q: Nullable<Quaternion>);
  69481. /**
  69482. * Returns a boolean. True if the particle intersects a mesh, else false
  69483. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  69484. * @param target is the object (point or mesh) what the intersection is computed against
  69485. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  69486. * @returns true if it intersects
  69487. */
  69488. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  69489. /**
  69490. * get the rotation matrix of the particle
  69491. * @hidden
  69492. */
  69493. getRotationMatrix(m: Matrix): void;
  69494. }
  69495. /**
  69496. * Represents a group of points in a points cloud system
  69497. * * PCS internal tool, don't use it manually.
  69498. */
  69499. export class PointsGroup {
  69500. /**
  69501. * The group id
  69502. * @hidden
  69503. */
  69504. groupID: number;
  69505. /**
  69506. * image data for group (internal use)
  69507. * @hidden
  69508. */
  69509. _groupImageData: Nullable<ArrayBufferView>;
  69510. /**
  69511. * Image Width (internal use)
  69512. * @hidden
  69513. */
  69514. _groupImgWidth: number;
  69515. /**
  69516. * Image Height (internal use)
  69517. * @hidden
  69518. */
  69519. _groupImgHeight: number;
  69520. /**
  69521. * Custom position function (internal use)
  69522. * @hidden
  69523. */
  69524. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  69525. /**
  69526. * density per facet for surface points
  69527. * @hidden
  69528. */
  69529. _groupDensity: number[];
  69530. /**
  69531. * Only when points are colored by texture carries pointer to texture list array
  69532. * @hidden
  69533. */
  69534. _textureNb: number;
  69535. /**
  69536. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  69537. * PCS internal tool, don't use it manually.
  69538. * @hidden
  69539. */
  69540. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  69541. }
  69542. }
  69543. declare module BABYLON {
  69544. interface Scene {
  69545. /** @hidden (Backing field) */
  69546. _physicsEngine: Nullable<IPhysicsEngine>;
  69547. /** @hidden */
  69548. _physicsTimeAccumulator: number;
  69549. /**
  69550. * Gets the current physics engine
  69551. * @returns a IPhysicsEngine or null if none attached
  69552. */
  69553. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  69554. /**
  69555. * Enables physics to the current scene
  69556. * @param gravity defines the scene's gravity for the physics engine
  69557. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  69558. * @return a boolean indicating if the physics engine was initialized
  69559. */
  69560. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  69561. /**
  69562. * Disables and disposes the physics engine associated with the scene
  69563. */
  69564. disablePhysicsEngine(): void;
  69565. /**
  69566. * Gets a boolean indicating if there is an active physics engine
  69567. * @returns a boolean indicating if there is an active physics engine
  69568. */
  69569. isPhysicsEnabled(): boolean;
  69570. /**
  69571. * Deletes a physics compound impostor
  69572. * @param compound defines the compound to delete
  69573. */
  69574. deleteCompoundImpostor(compound: any): void;
  69575. /**
  69576. * An event triggered when physic simulation is about to be run
  69577. */
  69578. onBeforePhysicsObservable: Observable<Scene>;
  69579. /**
  69580. * An event triggered when physic simulation has been done
  69581. */
  69582. onAfterPhysicsObservable: Observable<Scene>;
  69583. }
  69584. interface AbstractMesh {
  69585. /** @hidden */
  69586. _physicsImpostor: Nullable<PhysicsImpostor>;
  69587. /**
  69588. * Gets or sets impostor used for physic simulation
  69589. * @see https://doc.babylonjs.com/features/physics_engine
  69590. */
  69591. physicsImpostor: Nullable<PhysicsImpostor>;
  69592. /**
  69593. * Gets the current physics impostor
  69594. * @see https://doc.babylonjs.com/features/physics_engine
  69595. * @returns a physics impostor or null
  69596. */
  69597. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  69598. /** Apply a physic impulse to the mesh
  69599. * @param force defines the force to apply
  69600. * @param contactPoint defines where to apply the force
  69601. * @returns the current mesh
  69602. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  69603. */
  69604. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  69605. /**
  69606. * Creates a physic joint between two meshes
  69607. * @param otherMesh defines the other mesh to use
  69608. * @param pivot1 defines the pivot to use on this mesh
  69609. * @param pivot2 defines the pivot to use on the other mesh
  69610. * @param options defines additional options (can be plugin dependent)
  69611. * @returns the current mesh
  69612. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  69613. */
  69614. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  69615. /** @hidden */
  69616. _disposePhysicsObserver: Nullable<Observer<Node>>;
  69617. }
  69618. /**
  69619. * Defines the physics engine scene component responsible to manage a physics engine
  69620. */
  69621. export class PhysicsEngineSceneComponent implements ISceneComponent {
  69622. /**
  69623. * The component name helpful to identify the component in the list of scene components.
  69624. */
  69625. readonly name: string;
  69626. /**
  69627. * The scene the component belongs to.
  69628. */
  69629. scene: Scene;
  69630. /**
  69631. * Creates a new instance of the component for the given scene
  69632. * @param scene Defines the scene to register the component in
  69633. */
  69634. constructor(scene: Scene);
  69635. /**
  69636. * Registers the component in a given scene
  69637. */
  69638. register(): void;
  69639. /**
  69640. * Rebuilds the elements related to this component in case of
  69641. * context lost for instance.
  69642. */
  69643. rebuild(): void;
  69644. /**
  69645. * Disposes the component and the associated ressources
  69646. */
  69647. dispose(): void;
  69648. }
  69649. }
  69650. declare module BABYLON {
  69651. /**
  69652. * A helper for physics simulations
  69653. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69654. */
  69655. export class PhysicsHelper {
  69656. private _scene;
  69657. private _physicsEngine;
  69658. /**
  69659. * Initializes the Physics helper
  69660. * @param scene Babylon.js scene
  69661. */
  69662. constructor(scene: Scene);
  69663. /**
  69664. * Applies a radial explosion impulse
  69665. * @param origin the origin of the explosion
  69666. * @param radiusOrEventOptions the radius or the options of radial explosion
  69667. * @param strength the explosion strength
  69668. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69669. * @returns A physics radial explosion event, or null
  69670. */
  69671. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  69672. /**
  69673. * Applies a radial explosion force
  69674. * @param origin the origin of the explosion
  69675. * @param radiusOrEventOptions the radius or the options of radial explosion
  69676. * @param strength the explosion strength
  69677. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69678. * @returns A physics radial explosion event, or null
  69679. */
  69680. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  69681. /**
  69682. * Creates a gravitational field
  69683. * @param origin the origin of the explosion
  69684. * @param radiusOrEventOptions the radius or the options of radial explosion
  69685. * @param strength the explosion strength
  69686. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69687. * @returns A physics gravitational field event, or null
  69688. */
  69689. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  69690. /**
  69691. * Creates a physics updraft event
  69692. * @param origin the origin of the updraft
  69693. * @param radiusOrEventOptions the radius or the options of the updraft
  69694. * @param strength the strength of the updraft
  69695. * @param height the height of the updraft
  69696. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  69697. * @returns A physics updraft event, or null
  69698. */
  69699. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  69700. /**
  69701. * Creates a physics vortex event
  69702. * @param origin the of the vortex
  69703. * @param radiusOrEventOptions the radius or the options of the vortex
  69704. * @param strength the strength of the vortex
  69705. * @param height the height of the vortex
  69706. * @returns a Physics vortex event, or null
  69707. * A physics vortex event or null
  69708. */
  69709. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  69710. }
  69711. /**
  69712. * Represents a physics radial explosion event
  69713. */
  69714. class PhysicsRadialExplosionEvent {
  69715. private _scene;
  69716. private _options;
  69717. private _sphere;
  69718. private _dataFetched;
  69719. /**
  69720. * Initializes a radial explosioin event
  69721. * @param _scene BabylonJS scene
  69722. * @param _options The options for the vortex event
  69723. */
  69724. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  69725. /**
  69726. * Returns the data related to the radial explosion event (sphere).
  69727. * @returns The radial explosion event data
  69728. */
  69729. getData(): PhysicsRadialExplosionEventData;
  69730. /**
  69731. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  69732. * @param impostor A physics imposter
  69733. * @param origin the origin of the explosion
  69734. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  69735. */
  69736. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  69737. /**
  69738. * Triggers affecterd impostors callbacks
  69739. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  69740. */
  69741. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  69742. /**
  69743. * Disposes the sphere.
  69744. * @param force Specifies if the sphere should be disposed by force
  69745. */
  69746. dispose(force?: boolean): void;
  69747. /*** Helpers ***/
  69748. private _prepareSphere;
  69749. private _intersectsWithSphere;
  69750. }
  69751. /**
  69752. * Represents a gravitational field event
  69753. */
  69754. class PhysicsGravitationalFieldEvent {
  69755. private _physicsHelper;
  69756. private _scene;
  69757. private _origin;
  69758. private _options;
  69759. private _tickCallback;
  69760. private _sphere;
  69761. private _dataFetched;
  69762. /**
  69763. * Initializes the physics gravitational field event
  69764. * @param _physicsHelper A physics helper
  69765. * @param _scene BabylonJS scene
  69766. * @param _origin The origin position of the gravitational field event
  69767. * @param _options The options for the vortex event
  69768. */
  69769. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  69770. /**
  69771. * Returns the data related to the gravitational field event (sphere).
  69772. * @returns A gravitational field event
  69773. */
  69774. getData(): PhysicsGravitationalFieldEventData;
  69775. /**
  69776. * Enables the gravitational field.
  69777. */
  69778. enable(): void;
  69779. /**
  69780. * Disables the gravitational field.
  69781. */
  69782. disable(): void;
  69783. /**
  69784. * Disposes the sphere.
  69785. * @param force The force to dispose from the gravitational field event
  69786. */
  69787. dispose(force?: boolean): void;
  69788. private _tick;
  69789. }
  69790. /**
  69791. * Represents a physics updraft event
  69792. */
  69793. class PhysicsUpdraftEvent {
  69794. private _scene;
  69795. private _origin;
  69796. private _options;
  69797. private _physicsEngine;
  69798. private _originTop;
  69799. private _originDirection;
  69800. private _tickCallback;
  69801. private _cylinder;
  69802. private _cylinderPosition;
  69803. private _dataFetched;
  69804. /**
  69805. * Initializes the physics updraft event
  69806. * @param _scene BabylonJS scene
  69807. * @param _origin The origin position of the updraft
  69808. * @param _options The options for the updraft event
  69809. */
  69810. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  69811. /**
  69812. * Returns the data related to the updraft event (cylinder).
  69813. * @returns A physics updraft event
  69814. */
  69815. getData(): PhysicsUpdraftEventData;
  69816. /**
  69817. * Enables the updraft.
  69818. */
  69819. enable(): void;
  69820. /**
  69821. * Disables the updraft.
  69822. */
  69823. disable(): void;
  69824. /**
  69825. * Disposes the cylinder.
  69826. * @param force Specifies if the updraft should be disposed by force
  69827. */
  69828. dispose(force?: boolean): void;
  69829. private getImpostorHitData;
  69830. private _tick;
  69831. /*** Helpers ***/
  69832. private _prepareCylinder;
  69833. private _intersectsWithCylinder;
  69834. }
  69835. /**
  69836. * Represents a physics vortex event
  69837. */
  69838. class PhysicsVortexEvent {
  69839. private _scene;
  69840. private _origin;
  69841. private _options;
  69842. private _physicsEngine;
  69843. private _originTop;
  69844. private _tickCallback;
  69845. private _cylinder;
  69846. private _cylinderPosition;
  69847. private _dataFetched;
  69848. /**
  69849. * Initializes the physics vortex event
  69850. * @param _scene The BabylonJS scene
  69851. * @param _origin The origin position of the vortex
  69852. * @param _options The options for the vortex event
  69853. */
  69854. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  69855. /**
  69856. * Returns the data related to the vortex event (cylinder).
  69857. * @returns The physics vortex event data
  69858. */
  69859. getData(): PhysicsVortexEventData;
  69860. /**
  69861. * Enables the vortex.
  69862. */
  69863. enable(): void;
  69864. /**
  69865. * Disables the cortex.
  69866. */
  69867. disable(): void;
  69868. /**
  69869. * Disposes the sphere.
  69870. * @param force
  69871. */
  69872. dispose(force?: boolean): void;
  69873. private getImpostorHitData;
  69874. private _tick;
  69875. /*** Helpers ***/
  69876. private _prepareCylinder;
  69877. private _intersectsWithCylinder;
  69878. }
  69879. /**
  69880. * Options fot the radial explosion event
  69881. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69882. */
  69883. export class PhysicsRadialExplosionEventOptions {
  69884. /**
  69885. * The radius of the sphere for the radial explosion.
  69886. */
  69887. radius: number;
  69888. /**
  69889. * The strenth of the explosion.
  69890. */
  69891. strength: number;
  69892. /**
  69893. * The strenght of the force in correspondence to the distance of the affected object
  69894. */
  69895. falloff: PhysicsRadialImpulseFalloff;
  69896. /**
  69897. * Sphere options for the radial explosion.
  69898. */
  69899. sphere: {
  69900. segments: number;
  69901. diameter: number;
  69902. };
  69903. /**
  69904. * Sphere options for the radial explosion.
  69905. */
  69906. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  69907. }
  69908. /**
  69909. * Options fot the updraft event
  69910. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69911. */
  69912. export class PhysicsUpdraftEventOptions {
  69913. /**
  69914. * The radius of the cylinder for the vortex
  69915. */
  69916. radius: number;
  69917. /**
  69918. * The strenth of the updraft.
  69919. */
  69920. strength: number;
  69921. /**
  69922. * The height of the cylinder for the updraft.
  69923. */
  69924. height: number;
  69925. /**
  69926. * The mode for the the updraft.
  69927. */
  69928. updraftMode: PhysicsUpdraftMode;
  69929. }
  69930. /**
  69931. * Options fot the vortex event
  69932. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69933. */
  69934. export class PhysicsVortexEventOptions {
  69935. /**
  69936. * The radius of the cylinder for the vortex
  69937. */
  69938. radius: number;
  69939. /**
  69940. * The strenth of the vortex.
  69941. */
  69942. strength: number;
  69943. /**
  69944. * The height of the cylinder for the vortex.
  69945. */
  69946. height: number;
  69947. /**
  69948. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  69949. */
  69950. centripetalForceThreshold: number;
  69951. /**
  69952. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  69953. */
  69954. centripetalForceMultiplier: number;
  69955. /**
  69956. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  69957. */
  69958. centrifugalForceMultiplier: number;
  69959. /**
  69960. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  69961. */
  69962. updraftForceMultiplier: number;
  69963. }
  69964. /**
  69965. * The strenght of the force in correspondence to the distance of the affected object
  69966. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69967. */
  69968. export enum PhysicsRadialImpulseFalloff {
  69969. /** Defines that impulse is constant in strength across it's whole radius */
  69970. Constant = 0,
  69971. /** Defines that impulse gets weaker if it's further from the origin */
  69972. Linear = 1
  69973. }
  69974. /**
  69975. * The strength of the force in correspondence to the distance of the affected object
  69976. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69977. */
  69978. export enum PhysicsUpdraftMode {
  69979. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  69980. Center = 0,
  69981. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  69982. Perpendicular = 1
  69983. }
  69984. /**
  69985. * Interface for a physics hit data
  69986. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69987. */
  69988. export interface PhysicsHitData {
  69989. /**
  69990. * The force applied at the contact point
  69991. */
  69992. force: Vector3;
  69993. /**
  69994. * The contact point
  69995. */
  69996. contactPoint: Vector3;
  69997. /**
  69998. * The distance from the origin to the contact point
  69999. */
  70000. distanceFromOrigin: number;
  70001. }
  70002. /**
  70003. * Interface for radial explosion event data
  70004. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70005. */
  70006. export interface PhysicsRadialExplosionEventData {
  70007. /**
  70008. * A sphere used for the radial explosion event
  70009. */
  70010. sphere: Mesh;
  70011. }
  70012. /**
  70013. * Interface for gravitational field event data
  70014. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70015. */
  70016. export interface PhysicsGravitationalFieldEventData {
  70017. /**
  70018. * A sphere mesh used for the gravitational field event
  70019. */
  70020. sphere: Mesh;
  70021. }
  70022. /**
  70023. * Interface for updraft event data
  70024. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70025. */
  70026. export interface PhysicsUpdraftEventData {
  70027. /**
  70028. * A cylinder used for the updraft event
  70029. */
  70030. cylinder: Mesh;
  70031. }
  70032. /**
  70033. * Interface for vortex event data
  70034. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70035. */
  70036. export interface PhysicsVortexEventData {
  70037. /**
  70038. * A cylinder used for the vortex event
  70039. */
  70040. cylinder: Mesh;
  70041. }
  70042. /**
  70043. * Interface for an affected physics impostor
  70044. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70045. */
  70046. export interface PhysicsAffectedImpostorWithData {
  70047. /**
  70048. * The impostor affected by the effect
  70049. */
  70050. impostor: PhysicsImpostor;
  70051. /**
  70052. * The data about the hit/horce from the explosion
  70053. */
  70054. hitData: PhysicsHitData;
  70055. }
  70056. }
  70057. declare module BABYLON {
  70058. /** @hidden */
  70059. export var blackAndWhitePixelShader: {
  70060. name: string;
  70061. shader: string;
  70062. };
  70063. }
  70064. declare module BABYLON {
  70065. /**
  70066. * Post process used to render in black and white
  70067. */
  70068. export class BlackAndWhitePostProcess extends PostProcess {
  70069. /**
  70070. * Linear about to convert he result to black and white (default: 1)
  70071. */
  70072. degree: number;
  70073. /**
  70074. * Gets a string identifying the name of the class
  70075. * @returns "BlackAndWhitePostProcess" string
  70076. */
  70077. getClassName(): string;
  70078. /**
  70079. * Creates a black and white post process
  70080. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  70081. * @param name The name of the effect.
  70082. * @param options The required width/height ratio to downsize to before computing the render pass.
  70083. * @param camera The camera to apply the render pass to.
  70084. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70085. * @param engine The engine which the post process will be applied. (default: current engine)
  70086. * @param reusable If the post process can be reused on the same frame. (default: false)
  70087. */
  70088. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70089. /** @hidden */
  70090. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  70091. }
  70092. }
  70093. declare module BABYLON {
  70094. /**
  70095. * This represents a set of one or more post processes in Babylon.
  70096. * A post process can be used to apply a shader to a texture after it is rendered.
  70097. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70098. */
  70099. export class PostProcessRenderEffect {
  70100. private _postProcesses;
  70101. private _getPostProcesses;
  70102. private _singleInstance;
  70103. private _cameras;
  70104. private _indicesForCamera;
  70105. /**
  70106. * Name of the effect
  70107. * @hidden
  70108. */
  70109. _name: string;
  70110. /**
  70111. * Instantiates a post process render effect.
  70112. * A post process can be used to apply a shader to a texture after it is rendered.
  70113. * @param engine The engine the effect is tied to
  70114. * @param name The name of the effect
  70115. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  70116. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  70117. */
  70118. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  70119. /**
  70120. * Checks if all the post processes in the effect are supported.
  70121. */
  70122. get isSupported(): boolean;
  70123. /**
  70124. * Updates the current state of the effect
  70125. * @hidden
  70126. */
  70127. _update(): void;
  70128. /**
  70129. * Attaches the effect on cameras
  70130. * @param cameras The camera to attach to.
  70131. * @hidden
  70132. */
  70133. _attachCameras(cameras: Camera): void;
  70134. /**
  70135. * Attaches the effect on cameras
  70136. * @param cameras The camera to attach to.
  70137. * @hidden
  70138. */
  70139. _attachCameras(cameras: Camera[]): void;
  70140. /**
  70141. * Detaches the effect on cameras
  70142. * @param cameras The camera to detatch from.
  70143. * @hidden
  70144. */
  70145. _detachCameras(cameras: Camera): void;
  70146. /**
  70147. * Detatches the effect on cameras
  70148. * @param cameras The camera to detatch from.
  70149. * @hidden
  70150. */
  70151. _detachCameras(cameras: Camera[]): void;
  70152. /**
  70153. * Enables the effect on given cameras
  70154. * @param cameras The camera to enable.
  70155. * @hidden
  70156. */
  70157. _enable(cameras: Camera): void;
  70158. /**
  70159. * Enables the effect on given cameras
  70160. * @param cameras The camera to enable.
  70161. * @hidden
  70162. */
  70163. _enable(cameras: Nullable<Camera[]>): void;
  70164. /**
  70165. * Disables the effect on the given cameras
  70166. * @param cameras The camera to disable.
  70167. * @hidden
  70168. */
  70169. _disable(cameras: Camera): void;
  70170. /**
  70171. * Disables the effect on the given cameras
  70172. * @param cameras The camera to disable.
  70173. * @hidden
  70174. */
  70175. _disable(cameras: Nullable<Camera[]>): void;
  70176. /**
  70177. * Gets a list of the post processes contained in the effect.
  70178. * @param camera The camera to get the post processes on.
  70179. * @returns The list of the post processes in the effect.
  70180. */
  70181. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  70182. }
  70183. }
  70184. declare module BABYLON {
  70185. /** @hidden */
  70186. export var extractHighlightsPixelShader: {
  70187. name: string;
  70188. shader: string;
  70189. };
  70190. }
  70191. declare module BABYLON {
  70192. /**
  70193. * 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.
  70194. */
  70195. export class ExtractHighlightsPostProcess extends PostProcess {
  70196. /**
  70197. * The luminance threshold, pixels below this value will be set to black.
  70198. */
  70199. threshold: number;
  70200. /** @hidden */
  70201. _exposure: number;
  70202. /**
  70203. * Post process which has the input texture to be used when performing highlight extraction
  70204. * @hidden
  70205. */
  70206. _inputPostProcess: Nullable<PostProcess>;
  70207. /**
  70208. * Gets a string identifying the name of the class
  70209. * @returns "ExtractHighlightsPostProcess" string
  70210. */
  70211. getClassName(): string;
  70212. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70213. }
  70214. }
  70215. declare module BABYLON {
  70216. /** @hidden */
  70217. export var bloomMergePixelShader: {
  70218. name: string;
  70219. shader: string;
  70220. };
  70221. }
  70222. declare module BABYLON {
  70223. /**
  70224. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  70225. */
  70226. export class BloomMergePostProcess extends PostProcess {
  70227. /** Weight of the bloom to be added to the original input. */
  70228. weight: number;
  70229. /**
  70230. * Gets a string identifying the name of the class
  70231. * @returns "BloomMergePostProcess" string
  70232. */
  70233. getClassName(): string;
  70234. /**
  70235. * Creates a new instance of @see BloomMergePostProcess
  70236. * @param name The name of the effect.
  70237. * @param originalFromInput Post process which's input will be used for the merge.
  70238. * @param blurred Blurred highlights post process which's output will be used.
  70239. * @param weight Weight of the bloom to be added to the original input.
  70240. * @param options The required width/height ratio to downsize to before computing the render pass.
  70241. * @param camera The camera to apply the render pass to.
  70242. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70243. * @param engine The engine which the post process will be applied. (default: current engine)
  70244. * @param reusable If the post process can be reused on the same frame. (default: false)
  70245. * @param textureType Type of textures used when performing the post process. (default: 0)
  70246. * @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)
  70247. */
  70248. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  70249. /** Weight of the bloom to be added to the original input. */
  70250. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70251. }
  70252. }
  70253. declare module BABYLON {
  70254. /**
  70255. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  70256. */
  70257. export class BloomEffect extends PostProcessRenderEffect {
  70258. private bloomScale;
  70259. /**
  70260. * @hidden Internal
  70261. */
  70262. _effects: Array<PostProcess>;
  70263. /**
  70264. * @hidden Internal
  70265. */
  70266. _downscale: ExtractHighlightsPostProcess;
  70267. private _blurX;
  70268. private _blurY;
  70269. private _merge;
  70270. /**
  70271. * The luminance threshold to find bright areas of the image to bloom.
  70272. */
  70273. get threshold(): number;
  70274. set threshold(value: number);
  70275. /**
  70276. * The strength of the bloom.
  70277. */
  70278. get weight(): number;
  70279. set weight(value: number);
  70280. /**
  70281. * Specifies the size of the bloom blur kernel, relative to the final output size
  70282. */
  70283. get kernel(): number;
  70284. set kernel(value: number);
  70285. /**
  70286. * Creates a new instance of @see BloomEffect
  70287. * @param scene The scene the effect belongs to.
  70288. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  70289. * @param bloomKernel The size of the kernel to be used when applying the blur.
  70290. * @param bloomWeight The the strength of bloom.
  70291. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  70292. * @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)
  70293. */
  70294. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  70295. /**
  70296. * Disposes each of the internal effects for a given camera.
  70297. * @param camera The camera to dispose the effect on.
  70298. */
  70299. disposeEffects(camera: Camera): void;
  70300. /**
  70301. * @hidden Internal
  70302. */
  70303. _updateEffects(): void;
  70304. /**
  70305. * Internal
  70306. * @returns if all the contained post processes are ready.
  70307. * @hidden
  70308. */
  70309. _isReady(): boolean;
  70310. }
  70311. }
  70312. declare module BABYLON {
  70313. /** @hidden */
  70314. export var chromaticAberrationPixelShader: {
  70315. name: string;
  70316. shader: string;
  70317. };
  70318. }
  70319. declare module BABYLON {
  70320. /**
  70321. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  70322. */
  70323. export class ChromaticAberrationPostProcess extends PostProcess {
  70324. /**
  70325. * The amount of seperation of rgb channels (default: 30)
  70326. */
  70327. aberrationAmount: number;
  70328. /**
  70329. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  70330. */
  70331. radialIntensity: number;
  70332. /**
  70333. * 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))
  70334. */
  70335. direction: Vector2;
  70336. /**
  70337. * 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))
  70338. */
  70339. centerPosition: Vector2;
  70340. /** The width of the screen to apply the effect on */
  70341. screenWidth: number;
  70342. /** The height of the screen to apply the effect on */
  70343. screenHeight: number;
  70344. /**
  70345. * Gets a string identifying the name of the class
  70346. * @returns "ChromaticAberrationPostProcess" string
  70347. */
  70348. getClassName(): string;
  70349. /**
  70350. * Creates a new instance ChromaticAberrationPostProcess
  70351. * @param name The name of the effect.
  70352. * @param screenWidth The width of the screen to apply the effect on.
  70353. * @param screenHeight The height of the screen to apply the effect on.
  70354. * @param options The required width/height ratio to downsize to before computing the render pass.
  70355. * @param camera The camera to apply the render pass to.
  70356. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70357. * @param engine The engine which the post process will be applied. (default: current engine)
  70358. * @param reusable If the post process can be reused on the same frame. (default: false)
  70359. * @param textureType Type of textures used when performing the post process. (default: 0)
  70360. * @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)
  70361. */
  70362. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70363. /** @hidden */
  70364. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  70365. }
  70366. }
  70367. declare module BABYLON {
  70368. /** @hidden */
  70369. export var circleOfConfusionPixelShader: {
  70370. name: string;
  70371. shader: string;
  70372. };
  70373. }
  70374. declare module BABYLON {
  70375. /**
  70376. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  70377. */
  70378. export class CircleOfConfusionPostProcess extends PostProcess {
  70379. /**
  70380. * 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.
  70381. */
  70382. lensSize: number;
  70383. /**
  70384. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  70385. */
  70386. fStop: number;
  70387. /**
  70388. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  70389. */
  70390. focusDistance: number;
  70391. /**
  70392. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  70393. */
  70394. focalLength: number;
  70395. /**
  70396. * Gets a string identifying the name of the class
  70397. * @returns "CircleOfConfusionPostProcess" string
  70398. */
  70399. getClassName(): string;
  70400. private _depthTexture;
  70401. /**
  70402. * Creates a new instance CircleOfConfusionPostProcess
  70403. * @param name The name of the effect.
  70404. * @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.
  70405. * @param options The required width/height ratio to downsize to before computing the render pass.
  70406. * @param camera The camera to apply the render pass to.
  70407. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70408. * @param engine The engine which the post process will be applied. (default: current engine)
  70409. * @param reusable If the post process can be reused on the same frame. (default: false)
  70410. * @param textureType Type of textures used when performing the post process. (default: 0)
  70411. * @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)
  70412. */
  70413. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70414. /**
  70415. * 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.
  70416. */
  70417. set depthTexture(value: RenderTargetTexture);
  70418. }
  70419. }
  70420. declare module BABYLON {
  70421. /** @hidden */
  70422. export var colorCorrectionPixelShader: {
  70423. name: string;
  70424. shader: string;
  70425. };
  70426. }
  70427. declare module BABYLON {
  70428. /**
  70429. *
  70430. * This post-process allows the modification of rendered colors by using
  70431. * a 'look-up table' (LUT). This effect is also called Color Grading.
  70432. *
  70433. * The object needs to be provided an url to a texture containing the color
  70434. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  70435. * Use an image editing software to tweak the LUT to match your needs.
  70436. *
  70437. * For an example of a color LUT, see here:
  70438. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  70439. * For explanations on color grading, see here:
  70440. * @see http://udn.epicgames.com/Three/ColorGrading.html
  70441. *
  70442. */
  70443. export class ColorCorrectionPostProcess extends PostProcess {
  70444. private _colorTableTexture;
  70445. /**
  70446. * Gets the color table url used to create the LUT texture
  70447. */
  70448. colorTableUrl: string;
  70449. /**
  70450. * Gets a string identifying the name of the class
  70451. * @returns "ColorCorrectionPostProcess" string
  70452. */
  70453. getClassName(): string;
  70454. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70455. /** @hidden */
  70456. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  70457. }
  70458. }
  70459. declare module BABYLON {
  70460. /** @hidden */
  70461. export var convolutionPixelShader: {
  70462. name: string;
  70463. shader: string;
  70464. };
  70465. }
  70466. declare module BABYLON {
  70467. /**
  70468. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  70469. * input texture to perform effects such as edge detection or sharpening
  70470. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70471. */
  70472. export class ConvolutionPostProcess extends PostProcess {
  70473. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  70474. kernel: number[];
  70475. /**
  70476. * Gets a string identifying the name of the class
  70477. * @returns "ConvolutionPostProcess" string
  70478. */
  70479. getClassName(): string;
  70480. /**
  70481. * Creates a new instance ConvolutionPostProcess
  70482. * @param name The name of the effect.
  70483. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  70484. * @param options The required width/height ratio to downsize to before computing the render pass.
  70485. * @param camera The camera to apply the render pass to.
  70486. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70487. * @param engine The engine which the post process will be applied. (default: current engine)
  70488. * @param reusable If the post process can be reused on the same frame. (default: false)
  70489. * @param textureType Type of textures used when performing the post process. (default: 0)
  70490. */
  70491. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70492. /** @hidden */
  70493. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  70494. /**
  70495. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70496. */
  70497. static EdgeDetect0Kernel: number[];
  70498. /**
  70499. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70500. */
  70501. static EdgeDetect1Kernel: number[];
  70502. /**
  70503. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70504. */
  70505. static EdgeDetect2Kernel: number[];
  70506. /**
  70507. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70508. */
  70509. static SharpenKernel: number[];
  70510. /**
  70511. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70512. */
  70513. static EmbossKernel: number[];
  70514. /**
  70515. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70516. */
  70517. static GaussianKernel: number[];
  70518. }
  70519. }
  70520. declare module BABYLON {
  70521. /**
  70522. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  70523. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  70524. * based on samples that have a large difference in distance than the center pixel.
  70525. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  70526. */
  70527. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  70528. /**
  70529. * The direction the blur should be applied
  70530. */
  70531. direction: Vector2;
  70532. /**
  70533. * Gets a string identifying the name of the class
  70534. * @returns "DepthOfFieldBlurPostProcess" string
  70535. */
  70536. getClassName(): string;
  70537. /**
  70538. * Creates a new instance CircleOfConfusionPostProcess
  70539. * @param name The name of the effect.
  70540. * @param scene The scene the effect belongs to.
  70541. * @param direction The direction the blur should be applied.
  70542. * @param kernel The size of the kernel used to blur.
  70543. * @param options The required width/height ratio to downsize to before computing the render pass.
  70544. * @param camera The camera to apply the render pass to.
  70545. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  70546. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  70547. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70548. * @param engine The engine which the post process will be applied. (default: current engine)
  70549. * @param reusable If the post process can be reused on the same frame. (default: false)
  70550. * @param textureType Type of textures used when performing the post process. (default: 0)
  70551. * @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)
  70552. */
  70553. 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);
  70554. }
  70555. }
  70556. declare module BABYLON {
  70557. /** @hidden */
  70558. export var depthOfFieldMergePixelShader: {
  70559. name: string;
  70560. shader: string;
  70561. };
  70562. }
  70563. declare module BABYLON {
  70564. /**
  70565. * Options to be set when merging outputs from the default pipeline.
  70566. */
  70567. export class DepthOfFieldMergePostProcessOptions {
  70568. /**
  70569. * The original image to merge on top of
  70570. */
  70571. originalFromInput: PostProcess;
  70572. /**
  70573. * Parameters to perform the merge of the depth of field effect
  70574. */
  70575. depthOfField?: {
  70576. circleOfConfusion: PostProcess;
  70577. blurSteps: Array<PostProcess>;
  70578. };
  70579. /**
  70580. * Parameters to perform the merge of bloom effect
  70581. */
  70582. bloom?: {
  70583. blurred: PostProcess;
  70584. weight: number;
  70585. };
  70586. }
  70587. /**
  70588. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  70589. */
  70590. export class DepthOfFieldMergePostProcess extends PostProcess {
  70591. private blurSteps;
  70592. /**
  70593. * Gets a string identifying the name of the class
  70594. * @returns "DepthOfFieldMergePostProcess" string
  70595. */
  70596. getClassName(): string;
  70597. /**
  70598. * Creates a new instance of DepthOfFieldMergePostProcess
  70599. * @param name The name of the effect.
  70600. * @param originalFromInput Post process which's input will be used for the merge.
  70601. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  70602. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  70603. * @param options The required width/height ratio to downsize to before computing the render pass.
  70604. * @param camera The camera to apply the render pass to.
  70605. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70606. * @param engine The engine which the post process will be applied. (default: current engine)
  70607. * @param reusable If the post process can be reused on the same frame. (default: false)
  70608. * @param textureType Type of textures used when performing the post process. (default: 0)
  70609. * @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)
  70610. */
  70611. 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);
  70612. /**
  70613. * Updates the effect with the current post process compile time values and recompiles the shader.
  70614. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  70615. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  70616. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  70617. * @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
  70618. * @param onCompiled Called when the shader has been compiled.
  70619. * @param onError Called if there is an error when compiling a shader.
  70620. */
  70621. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  70622. }
  70623. }
  70624. declare module BABYLON {
  70625. /**
  70626. * Specifies the level of max blur that should be applied when using the depth of field effect
  70627. */
  70628. export enum DepthOfFieldEffectBlurLevel {
  70629. /**
  70630. * Subtle blur
  70631. */
  70632. Low = 0,
  70633. /**
  70634. * Medium blur
  70635. */
  70636. Medium = 1,
  70637. /**
  70638. * Large blur
  70639. */
  70640. High = 2
  70641. }
  70642. /**
  70643. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  70644. */
  70645. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  70646. private _circleOfConfusion;
  70647. /**
  70648. * @hidden Internal, blurs from high to low
  70649. */
  70650. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  70651. private _depthOfFieldBlurY;
  70652. private _dofMerge;
  70653. /**
  70654. * @hidden Internal post processes in depth of field effect
  70655. */
  70656. _effects: Array<PostProcess>;
  70657. /**
  70658. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  70659. */
  70660. set focalLength(value: number);
  70661. get focalLength(): number;
  70662. /**
  70663. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  70664. */
  70665. set fStop(value: number);
  70666. get fStop(): number;
  70667. /**
  70668. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  70669. */
  70670. set focusDistance(value: number);
  70671. get focusDistance(): number;
  70672. /**
  70673. * 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.
  70674. */
  70675. set lensSize(value: number);
  70676. get lensSize(): number;
  70677. /**
  70678. * Creates a new instance DepthOfFieldEffect
  70679. * @param scene The scene the effect belongs to.
  70680. * @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.
  70681. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  70682. * @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)
  70683. */
  70684. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  70685. /**
  70686. * Get the current class name of the current effet
  70687. * @returns "DepthOfFieldEffect"
  70688. */
  70689. getClassName(): string;
  70690. /**
  70691. * 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.
  70692. */
  70693. set depthTexture(value: RenderTargetTexture);
  70694. /**
  70695. * Disposes each of the internal effects for a given camera.
  70696. * @param camera The camera to dispose the effect on.
  70697. */
  70698. disposeEffects(camera: Camera): void;
  70699. /**
  70700. * @hidden Internal
  70701. */
  70702. _updateEffects(): void;
  70703. /**
  70704. * Internal
  70705. * @returns if all the contained post processes are ready.
  70706. * @hidden
  70707. */
  70708. _isReady(): boolean;
  70709. }
  70710. }
  70711. declare module BABYLON {
  70712. /** @hidden */
  70713. export var displayPassPixelShader: {
  70714. name: string;
  70715. shader: string;
  70716. };
  70717. }
  70718. declare module BABYLON {
  70719. /**
  70720. * DisplayPassPostProcess which produces an output the same as it's input
  70721. */
  70722. export class DisplayPassPostProcess extends PostProcess {
  70723. /**
  70724. * Gets a string identifying the name of the class
  70725. * @returns "DisplayPassPostProcess" string
  70726. */
  70727. getClassName(): string;
  70728. /**
  70729. * Creates the DisplayPassPostProcess
  70730. * @param name The name of the effect.
  70731. * @param options The required width/height ratio to downsize to before computing the render pass.
  70732. * @param camera The camera to apply the render pass to.
  70733. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70734. * @param engine The engine which the post process will be applied. (default: current engine)
  70735. * @param reusable If the post process can be reused on the same frame. (default: false)
  70736. */
  70737. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70738. /** @hidden */
  70739. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  70740. }
  70741. }
  70742. declare module BABYLON {
  70743. /** @hidden */
  70744. export var filterPixelShader: {
  70745. name: string;
  70746. shader: string;
  70747. };
  70748. }
  70749. declare module BABYLON {
  70750. /**
  70751. * Applies a kernel filter to the image
  70752. */
  70753. export class FilterPostProcess extends PostProcess {
  70754. /** The matrix to be applied to the image */
  70755. kernelMatrix: Matrix;
  70756. /**
  70757. * Gets a string identifying the name of the class
  70758. * @returns "FilterPostProcess" string
  70759. */
  70760. getClassName(): string;
  70761. /**
  70762. *
  70763. * @param name The name of the effect.
  70764. * @param kernelMatrix The matrix to be applied to the image
  70765. * @param options The required width/height ratio to downsize to before computing the render pass.
  70766. * @param camera The camera to apply the render pass to.
  70767. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70768. * @param engine The engine which the post process will be applied. (default: current engine)
  70769. * @param reusable If the post process can be reused on the same frame. (default: false)
  70770. */
  70771. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70772. /** @hidden */
  70773. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  70774. }
  70775. }
  70776. declare module BABYLON {
  70777. /** @hidden */
  70778. export var fxaaPixelShader: {
  70779. name: string;
  70780. shader: string;
  70781. };
  70782. }
  70783. declare module BABYLON {
  70784. /** @hidden */
  70785. export var fxaaVertexShader: {
  70786. name: string;
  70787. shader: string;
  70788. };
  70789. }
  70790. declare module BABYLON {
  70791. /**
  70792. * Fxaa post process
  70793. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  70794. */
  70795. export class FxaaPostProcess extends PostProcess {
  70796. /**
  70797. * Gets a string identifying the name of the class
  70798. * @returns "FxaaPostProcess" string
  70799. */
  70800. getClassName(): string;
  70801. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70802. private _getDefines;
  70803. /** @hidden */
  70804. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  70805. }
  70806. }
  70807. declare module BABYLON {
  70808. /** @hidden */
  70809. export var grainPixelShader: {
  70810. name: string;
  70811. shader: string;
  70812. };
  70813. }
  70814. declare module BABYLON {
  70815. /**
  70816. * The GrainPostProcess adds noise to the image at mid luminance levels
  70817. */
  70818. export class GrainPostProcess extends PostProcess {
  70819. /**
  70820. * The intensity of the grain added (default: 30)
  70821. */
  70822. intensity: number;
  70823. /**
  70824. * If the grain should be randomized on every frame
  70825. */
  70826. animated: boolean;
  70827. /**
  70828. * Gets a string identifying the name of the class
  70829. * @returns "GrainPostProcess" string
  70830. */
  70831. getClassName(): string;
  70832. /**
  70833. * Creates a new instance of @see GrainPostProcess
  70834. * @param name The name of the effect.
  70835. * @param options The required width/height ratio to downsize to before computing the render pass.
  70836. * @param camera The camera to apply the render pass to.
  70837. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70838. * @param engine The engine which the post process will be applied. (default: current engine)
  70839. * @param reusable If the post process can be reused on the same frame. (default: false)
  70840. * @param textureType Type of textures used when performing the post process. (default: 0)
  70841. * @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)
  70842. */
  70843. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70844. /** @hidden */
  70845. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  70846. }
  70847. }
  70848. declare module BABYLON {
  70849. /** @hidden */
  70850. export var highlightsPixelShader: {
  70851. name: string;
  70852. shader: string;
  70853. };
  70854. }
  70855. declare module BABYLON {
  70856. /**
  70857. * Extracts highlights from the image
  70858. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70859. */
  70860. export class HighlightsPostProcess extends PostProcess {
  70861. /**
  70862. * Gets a string identifying the name of the class
  70863. * @returns "HighlightsPostProcess" string
  70864. */
  70865. getClassName(): string;
  70866. /**
  70867. * Extracts highlights from the image
  70868. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70869. * @param name The name of the effect.
  70870. * @param options The required width/height ratio to downsize to before computing the render pass.
  70871. * @param camera The camera to apply the render pass to.
  70872. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70873. * @param engine The engine which the post process will be applied. (default: current engine)
  70874. * @param reusable If the post process can be reused on the same frame. (default: false)
  70875. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  70876. */
  70877. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70878. }
  70879. }
  70880. declare module BABYLON {
  70881. /**
  70882. * Contains all parameters needed for the prepass to perform
  70883. * motion blur
  70884. */
  70885. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  70886. /**
  70887. * Is motion blur enabled
  70888. */
  70889. enabled: boolean;
  70890. /**
  70891. * Name of the configuration
  70892. */
  70893. name: string;
  70894. /**
  70895. * Textures that should be present in the MRT for this effect to work
  70896. */
  70897. readonly texturesRequired: number[];
  70898. }
  70899. }
  70900. declare module BABYLON {
  70901. interface Scene {
  70902. /** @hidden (Backing field) */
  70903. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70904. /**
  70905. * Gets or Sets the current geometry buffer associated to the scene.
  70906. */
  70907. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70908. /**
  70909. * Enables a GeometryBufferRender and associates it with the scene
  70910. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  70911. * @returns the GeometryBufferRenderer
  70912. */
  70913. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  70914. /**
  70915. * Disables the GeometryBufferRender associated with the scene
  70916. */
  70917. disableGeometryBufferRenderer(): void;
  70918. }
  70919. /**
  70920. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  70921. * in several rendering techniques.
  70922. */
  70923. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  70924. /**
  70925. * The component name helpful to identify the component in the list of scene components.
  70926. */
  70927. readonly name: string;
  70928. /**
  70929. * The scene the component belongs to.
  70930. */
  70931. scene: Scene;
  70932. /**
  70933. * Creates a new instance of the component for the given scene
  70934. * @param scene Defines the scene to register the component in
  70935. */
  70936. constructor(scene: Scene);
  70937. /**
  70938. * Registers the component in a given scene
  70939. */
  70940. register(): void;
  70941. /**
  70942. * Rebuilds the elements related to this component in case of
  70943. * context lost for instance.
  70944. */
  70945. rebuild(): void;
  70946. /**
  70947. * Disposes the component and the associated ressources
  70948. */
  70949. dispose(): void;
  70950. private _gatherRenderTargets;
  70951. }
  70952. }
  70953. declare module BABYLON {
  70954. /** @hidden */
  70955. export var motionBlurPixelShader: {
  70956. name: string;
  70957. shader: string;
  70958. };
  70959. }
  70960. declare module BABYLON {
  70961. /**
  70962. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  70963. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  70964. * As an example, all you have to do is to create the post-process:
  70965. * var mb = new BABYLON.MotionBlurPostProcess(
  70966. * 'mb', // The name of the effect.
  70967. * scene, // The scene containing the objects to blur according to their velocity.
  70968. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  70969. * camera // The camera to apply the render pass to.
  70970. * );
  70971. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  70972. */
  70973. export class MotionBlurPostProcess extends PostProcess {
  70974. /**
  70975. * Defines how much the image is blurred by the movement. Default value is equal to 1
  70976. */
  70977. motionStrength: number;
  70978. /**
  70979. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  70980. */
  70981. get motionBlurSamples(): number;
  70982. /**
  70983. * Sets the number of iterations to be used for motion blur quality
  70984. */
  70985. set motionBlurSamples(samples: number);
  70986. private _motionBlurSamples;
  70987. private _forceGeometryBuffer;
  70988. private _geometryBufferRenderer;
  70989. private _prePassRenderer;
  70990. /**
  70991. * Gets a string identifying the name of the class
  70992. * @returns "MotionBlurPostProcess" string
  70993. */
  70994. getClassName(): string;
  70995. /**
  70996. * Creates a new instance MotionBlurPostProcess
  70997. * @param name The name of the effect.
  70998. * @param scene The scene containing the objects to blur according to their velocity.
  70999. * @param options The required width/height ratio to downsize to before computing the render pass.
  71000. * @param camera The camera to apply the render pass to.
  71001. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71002. * @param engine The engine which the post process will be applied. (default: current engine)
  71003. * @param reusable If the post process can be reused on the same frame. (default: false)
  71004. * @param textureType Type of textures used when performing the post process. (default: 0)
  71005. * @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)
  71006. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  71007. */
  71008. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  71009. /**
  71010. * Excludes the given skinned mesh from computing bones velocities.
  71011. * 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.
  71012. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  71013. */
  71014. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  71015. /**
  71016. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  71017. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  71018. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  71019. */
  71020. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  71021. /**
  71022. * Disposes the post process.
  71023. * @param camera The camera to dispose the post process on.
  71024. */
  71025. dispose(camera?: Camera): void;
  71026. /** @hidden */
  71027. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  71028. }
  71029. }
  71030. declare module BABYLON {
  71031. /** @hidden */
  71032. export var refractionPixelShader: {
  71033. name: string;
  71034. shader: string;
  71035. };
  71036. }
  71037. declare module BABYLON {
  71038. /**
  71039. * Post process which applies a refractin texture
  71040. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  71041. */
  71042. export class RefractionPostProcess extends PostProcess {
  71043. private _refTexture;
  71044. private _ownRefractionTexture;
  71045. /** the base color of the refraction (used to taint the rendering) */
  71046. color: Color3;
  71047. /** simulated refraction depth */
  71048. depth: number;
  71049. /** the coefficient of the base color (0 to remove base color tainting) */
  71050. colorLevel: number;
  71051. /** Gets the url used to load the refraction texture */
  71052. refractionTextureUrl: string;
  71053. /**
  71054. * Gets or sets the refraction texture
  71055. * Please note that you are responsible for disposing the texture if you set it manually
  71056. */
  71057. get refractionTexture(): Texture;
  71058. set refractionTexture(value: Texture);
  71059. /**
  71060. * Gets a string identifying the name of the class
  71061. * @returns "RefractionPostProcess" string
  71062. */
  71063. getClassName(): string;
  71064. /**
  71065. * Initializes the RefractionPostProcess
  71066. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  71067. * @param name The name of the effect.
  71068. * @param refractionTextureUrl Url of the refraction texture to use
  71069. * @param color the base color of the refraction (used to taint the rendering)
  71070. * @param depth simulated refraction depth
  71071. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  71072. * @param camera The camera to apply the render pass to.
  71073. * @param options The required width/height ratio to downsize to before computing the render pass.
  71074. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71075. * @param engine The engine which the post process will be applied. (default: current engine)
  71076. * @param reusable If the post process can be reused on the same frame. (default: false)
  71077. */
  71078. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71079. /**
  71080. * Disposes of the post process
  71081. * @param camera Camera to dispose post process on
  71082. */
  71083. dispose(camera: Camera): void;
  71084. /** @hidden */
  71085. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  71086. }
  71087. }
  71088. declare module BABYLON {
  71089. /** @hidden */
  71090. export var sharpenPixelShader: {
  71091. name: string;
  71092. shader: string;
  71093. };
  71094. }
  71095. declare module BABYLON {
  71096. /**
  71097. * The SharpenPostProcess applies a sharpen kernel to every pixel
  71098. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  71099. */
  71100. export class SharpenPostProcess extends PostProcess {
  71101. /**
  71102. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  71103. */
  71104. colorAmount: number;
  71105. /**
  71106. * How much sharpness should be applied (default: 0.3)
  71107. */
  71108. edgeAmount: number;
  71109. /**
  71110. * Gets a string identifying the name of the class
  71111. * @returns "SharpenPostProcess" string
  71112. */
  71113. getClassName(): string;
  71114. /**
  71115. * Creates a new instance ConvolutionPostProcess
  71116. * @param name The name of the effect.
  71117. * @param options The required width/height ratio to downsize to before computing the render pass.
  71118. * @param camera The camera to apply the render pass to.
  71119. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71120. * @param engine The engine which the post process will be applied. (default: current engine)
  71121. * @param reusable If the post process can be reused on the same frame. (default: false)
  71122. * @param textureType Type of textures used when performing the post process. (default: 0)
  71123. * @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)
  71124. */
  71125. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71126. /** @hidden */
  71127. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  71128. }
  71129. }
  71130. declare module BABYLON {
  71131. /**
  71132. * PostProcessRenderPipeline
  71133. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71134. */
  71135. export class PostProcessRenderPipeline {
  71136. private engine;
  71137. private _renderEffects;
  71138. private _renderEffectsForIsolatedPass;
  71139. /**
  71140. * List of inspectable custom properties (used by the Inspector)
  71141. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  71142. */
  71143. inspectableCustomProperties: IInspectable[];
  71144. /**
  71145. * @hidden
  71146. */
  71147. protected _cameras: Camera[];
  71148. /** @hidden */
  71149. _name: string;
  71150. /**
  71151. * Gets pipeline name
  71152. */
  71153. get name(): string;
  71154. /** Gets the list of attached cameras */
  71155. get cameras(): Camera[];
  71156. /**
  71157. * Initializes a PostProcessRenderPipeline
  71158. * @param engine engine to add the pipeline to
  71159. * @param name name of the pipeline
  71160. */
  71161. constructor(engine: Engine, name: string);
  71162. /**
  71163. * Gets the class name
  71164. * @returns "PostProcessRenderPipeline"
  71165. */
  71166. getClassName(): string;
  71167. /**
  71168. * If all the render effects in the pipeline are supported
  71169. */
  71170. get isSupported(): boolean;
  71171. /**
  71172. * Adds an effect to the pipeline
  71173. * @param renderEffect the effect to add
  71174. */
  71175. addEffect(renderEffect: PostProcessRenderEffect): void;
  71176. /** @hidden */
  71177. _rebuild(): void;
  71178. /** @hidden */
  71179. _enableEffect(renderEffectName: string, cameras: Camera): void;
  71180. /** @hidden */
  71181. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  71182. /** @hidden */
  71183. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  71184. /** @hidden */
  71185. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  71186. /** @hidden */
  71187. _attachCameras(cameras: Camera, unique: boolean): void;
  71188. /** @hidden */
  71189. _attachCameras(cameras: Camera[], unique: boolean): void;
  71190. /** @hidden */
  71191. _detachCameras(cameras: Camera): void;
  71192. /** @hidden */
  71193. _detachCameras(cameras: Nullable<Camera[]>): void;
  71194. /** @hidden */
  71195. _update(): void;
  71196. /** @hidden */
  71197. _reset(): void;
  71198. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  71199. /**
  71200. * Sets the required values to the prepass renderer.
  71201. * @param prePassRenderer defines the prepass renderer to setup.
  71202. * @returns true if the pre pass is needed.
  71203. */
  71204. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  71205. /**
  71206. * Disposes of the pipeline
  71207. */
  71208. dispose(): void;
  71209. }
  71210. }
  71211. declare module BABYLON {
  71212. /**
  71213. * PostProcessRenderPipelineManager class
  71214. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71215. */
  71216. export class PostProcessRenderPipelineManager {
  71217. private _renderPipelines;
  71218. /**
  71219. * Initializes a PostProcessRenderPipelineManager
  71220. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71221. */
  71222. constructor();
  71223. /**
  71224. * Gets the list of supported render pipelines
  71225. */
  71226. get supportedPipelines(): PostProcessRenderPipeline[];
  71227. /**
  71228. * Adds a pipeline to the manager
  71229. * @param renderPipeline The pipeline to add
  71230. */
  71231. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  71232. /**
  71233. * Attaches a camera to the pipeline
  71234. * @param renderPipelineName The name of the pipeline to attach to
  71235. * @param cameras the camera to attach
  71236. * @param unique if the camera can be attached multiple times to the pipeline
  71237. */
  71238. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  71239. /**
  71240. * Detaches a camera from the pipeline
  71241. * @param renderPipelineName The name of the pipeline to detach from
  71242. * @param cameras the camera to detach
  71243. */
  71244. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  71245. /**
  71246. * Enables an effect by name on a pipeline
  71247. * @param renderPipelineName the name of the pipeline to enable the effect in
  71248. * @param renderEffectName the name of the effect to enable
  71249. * @param cameras the cameras that the effect should be enabled on
  71250. */
  71251. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  71252. /**
  71253. * Disables an effect by name on a pipeline
  71254. * @param renderPipelineName the name of the pipeline to disable the effect in
  71255. * @param renderEffectName the name of the effect to disable
  71256. * @param cameras the cameras that the effect should be disabled on
  71257. */
  71258. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  71259. /**
  71260. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  71261. */
  71262. update(): void;
  71263. /** @hidden */
  71264. _rebuild(): void;
  71265. /**
  71266. * Disposes of the manager and pipelines
  71267. */
  71268. dispose(): void;
  71269. }
  71270. }
  71271. declare module BABYLON {
  71272. interface Scene {
  71273. /** @hidden (Backing field) */
  71274. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  71275. /**
  71276. * Gets the postprocess render pipeline manager
  71277. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71278. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  71279. */
  71280. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  71281. }
  71282. /**
  71283. * Defines the Render Pipeline scene component responsible to rendering pipelines
  71284. */
  71285. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  71286. /**
  71287. * The component name helpfull to identify the component in the list of scene components.
  71288. */
  71289. readonly name: string;
  71290. /**
  71291. * The scene the component belongs to.
  71292. */
  71293. scene: Scene;
  71294. /**
  71295. * Creates a new instance of the component for the given scene
  71296. * @param scene Defines the scene to register the component in
  71297. */
  71298. constructor(scene: Scene);
  71299. /**
  71300. * Registers the component in a given scene
  71301. */
  71302. register(): void;
  71303. /**
  71304. * Rebuilds the elements related to this component in case of
  71305. * context lost for instance.
  71306. */
  71307. rebuild(): void;
  71308. /**
  71309. * Disposes the component and the associated ressources
  71310. */
  71311. dispose(): void;
  71312. private _gatherRenderTargets;
  71313. }
  71314. }
  71315. declare module BABYLON {
  71316. /**
  71317. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  71318. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  71319. */
  71320. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71321. private _scene;
  71322. private _camerasToBeAttached;
  71323. /**
  71324. * ID of the sharpen post process,
  71325. */
  71326. private readonly SharpenPostProcessId;
  71327. /**
  71328. * @ignore
  71329. * ID of the image processing post process;
  71330. */
  71331. readonly ImageProcessingPostProcessId: string;
  71332. /**
  71333. * @ignore
  71334. * ID of the Fast Approximate Anti-Aliasing post process;
  71335. */
  71336. readonly FxaaPostProcessId: string;
  71337. /**
  71338. * ID of the chromatic aberration post process,
  71339. */
  71340. private readonly ChromaticAberrationPostProcessId;
  71341. /**
  71342. * ID of the grain post process
  71343. */
  71344. private readonly GrainPostProcessId;
  71345. /**
  71346. * Sharpen post process which will apply a sharpen convolution to enhance edges
  71347. */
  71348. sharpen: SharpenPostProcess;
  71349. private _sharpenEffect;
  71350. private bloom;
  71351. /**
  71352. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  71353. */
  71354. depthOfField: DepthOfFieldEffect;
  71355. /**
  71356. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71357. */
  71358. fxaa: FxaaPostProcess;
  71359. /**
  71360. * Image post processing pass used to perform operations such as tone mapping or color grading.
  71361. */
  71362. imageProcessing: ImageProcessingPostProcess;
  71363. /**
  71364. * Chromatic aberration post process which will shift rgb colors in the image
  71365. */
  71366. chromaticAberration: ChromaticAberrationPostProcess;
  71367. private _chromaticAberrationEffect;
  71368. /**
  71369. * Grain post process which add noise to the image
  71370. */
  71371. grain: GrainPostProcess;
  71372. private _grainEffect;
  71373. /**
  71374. * Glow post process which adds a glow to emissive areas of the image
  71375. */
  71376. private _glowLayer;
  71377. /**
  71378. * Animations which can be used to tweak settings over a period of time
  71379. */
  71380. animations: Animation[];
  71381. private _imageProcessingConfigurationObserver;
  71382. private _sharpenEnabled;
  71383. private _bloomEnabled;
  71384. private _depthOfFieldEnabled;
  71385. private _depthOfFieldBlurLevel;
  71386. private _fxaaEnabled;
  71387. private _imageProcessingEnabled;
  71388. private _defaultPipelineTextureType;
  71389. private _bloomScale;
  71390. private _chromaticAberrationEnabled;
  71391. private _grainEnabled;
  71392. private _buildAllowed;
  71393. /**
  71394. * Gets active scene
  71395. */
  71396. get scene(): Scene;
  71397. /**
  71398. * Enable or disable the sharpen process from the pipeline
  71399. */
  71400. set sharpenEnabled(enabled: boolean);
  71401. get sharpenEnabled(): boolean;
  71402. private _resizeObserver;
  71403. private _hardwareScaleLevel;
  71404. private _bloomKernel;
  71405. /**
  71406. * Specifies the size of the bloom blur kernel, relative to the final output size
  71407. */
  71408. get bloomKernel(): number;
  71409. set bloomKernel(value: number);
  71410. /**
  71411. * Specifies the weight of the bloom in the final rendering
  71412. */
  71413. private _bloomWeight;
  71414. /**
  71415. * Specifies the luma threshold for the area that will be blurred by the bloom
  71416. */
  71417. private _bloomThreshold;
  71418. private _hdr;
  71419. /**
  71420. * The strength of the bloom.
  71421. */
  71422. set bloomWeight(value: number);
  71423. get bloomWeight(): number;
  71424. /**
  71425. * The strength of the bloom.
  71426. */
  71427. set bloomThreshold(value: number);
  71428. get bloomThreshold(): number;
  71429. /**
  71430. * The scale of the bloom, lower value will provide better performance.
  71431. */
  71432. set bloomScale(value: number);
  71433. get bloomScale(): number;
  71434. /**
  71435. * Enable or disable the bloom from the pipeline
  71436. */
  71437. set bloomEnabled(enabled: boolean);
  71438. get bloomEnabled(): boolean;
  71439. private _rebuildBloom;
  71440. /**
  71441. * If the depth of field is enabled.
  71442. */
  71443. get depthOfFieldEnabled(): boolean;
  71444. set depthOfFieldEnabled(enabled: boolean);
  71445. /**
  71446. * Blur level of the depth of field effect. (Higher blur will effect performance)
  71447. */
  71448. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  71449. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  71450. /**
  71451. * If the anti aliasing is enabled.
  71452. */
  71453. set fxaaEnabled(enabled: boolean);
  71454. get fxaaEnabled(): boolean;
  71455. private _samples;
  71456. /**
  71457. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  71458. */
  71459. set samples(sampleCount: number);
  71460. get samples(): number;
  71461. /**
  71462. * If image processing is enabled.
  71463. */
  71464. set imageProcessingEnabled(enabled: boolean);
  71465. get imageProcessingEnabled(): boolean;
  71466. /**
  71467. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  71468. */
  71469. set glowLayerEnabled(enabled: boolean);
  71470. get glowLayerEnabled(): boolean;
  71471. /**
  71472. * Gets the glow layer (or null if not defined)
  71473. */
  71474. get glowLayer(): Nullable<GlowLayer>;
  71475. /**
  71476. * Enable or disable the chromaticAberration process from the pipeline
  71477. */
  71478. set chromaticAberrationEnabled(enabled: boolean);
  71479. get chromaticAberrationEnabled(): boolean;
  71480. /**
  71481. * Enable or disable the grain process from the pipeline
  71482. */
  71483. set grainEnabled(enabled: boolean);
  71484. get grainEnabled(): boolean;
  71485. /**
  71486. * @constructor
  71487. * @param name - The rendering pipeline name (default: "")
  71488. * @param hdr - If high dynamic range textures should be used (default: true)
  71489. * @param scene - The scene linked to this pipeline (default: the last created scene)
  71490. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  71491. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  71492. */
  71493. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  71494. /**
  71495. * Get the class name
  71496. * @returns "DefaultRenderingPipeline"
  71497. */
  71498. getClassName(): string;
  71499. /**
  71500. * Force the compilation of the entire pipeline.
  71501. */
  71502. prepare(): void;
  71503. private _hasCleared;
  71504. private _prevPostProcess;
  71505. private _prevPrevPostProcess;
  71506. private _setAutoClearAndTextureSharing;
  71507. private _depthOfFieldSceneObserver;
  71508. private _buildPipeline;
  71509. private _disposePostProcesses;
  71510. /**
  71511. * Adds a camera to the pipeline
  71512. * @param camera the camera to be added
  71513. */
  71514. addCamera(camera: Camera): void;
  71515. /**
  71516. * Removes a camera from the pipeline
  71517. * @param camera the camera to remove
  71518. */
  71519. removeCamera(camera: Camera): void;
  71520. /**
  71521. * Dispose of the pipeline and stop all post processes
  71522. */
  71523. dispose(): void;
  71524. /**
  71525. * Serialize the rendering pipeline (Used when exporting)
  71526. * @returns the serialized object
  71527. */
  71528. serialize(): any;
  71529. /**
  71530. * Parse the serialized pipeline
  71531. * @param source Source pipeline.
  71532. * @param scene The scene to load the pipeline to.
  71533. * @param rootUrl The URL of the serialized pipeline.
  71534. * @returns An instantiated pipeline from the serialized object.
  71535. */
  71536. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  71537. }
  71538. }
  71539. declare module BABYLON {
  71540. /** @hidden */
  71541. export var lensHighlightsPixelShader: {
  71542. name: string;
  71543. shader: string;
  71544. };
  71545. }
  71546. declare module BABYLON {
  71547. /** @hidden */
  71548. export var depthOfFieldPixelShader: {
  71549. name: string;
  71550. shader: string;
  71551. };
  71552. }
  71553. declare module BABYLON {
  71554. /**
  71555. * BABYLON.JS Chromatic Aberration GLSL Shader
  71556. * Author: Olivier Guyot
  71557. * Separates very slightly R, G and B colors on the edges of the screen
  71558. * Inspired by Francois Tarlier & Martins Upitis
  71559. */
  71560. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  71561. /**
  71562. * @ignore
  71563. * The chromatic aberration PostProcess id in the pipeline
  71564. */
  71565. LensChromaticAberrationEffect: string;
  71566. /**
  71567. * @ignore
  71568. * The highlights enhancing PostProcess id in the pipeline
  71569. */
  71570. HighlightsEnhancingEffect: string;
  71571. /**
  71572. * @ignore
  71573. * The depth-of-field PostProcess id in the pipeline
  71574. */
  71575. LensDepthOfFieldEffect: string;
  71576. private _scene;
  71577. private _depthTexture;
  71578. private _grainTexture;
  71579. private _chromaticAberrationPostProcess;
  71580. private _highlightsPostProcess;
  71581. private _depthOfFieldPostProcess;
  71582. private _edgeBlur;
  71583. private _grainAmount;
  71584. private _chromaticAberration;
  71585. private _distortion;
  71586. private _highlightsGain;
  71587. private _highlightsThreshold;
  71588. private _dofDistance;
  71589. private _dofAperture;
  71590. private _dofDarken;
  71591. private _dofPentagon;
  71592. private _blurNoise;
  71593. /**
  71594. * @constructor
  71595. *
  71596. * Effect parameters are as follow:
  71597. * {
  71598. * chromatic_aberration: number; // from 0 to x (1 for realism)
  71599. * edge_blur: number; // from 0 to x (1 for realism)
  71600. * distortion: number; // from 0 to x (1 for realism)
  71601. * grain_amount: number; // from 0 to 1
  71602. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  71603. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  71604. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  71605. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  71606. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  71607. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  71608. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  71609. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  71610. * }
  71611. * Note: if an effect parameter is unset, effect is disabled
  71612. *
  71613. * @param name The rendering pipeline name
  71614. * @param parameters - An object containing all parameters (see above)
  71615. * @param scene The scene linked to this pipeline
  71616. * @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)
  71617. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71618. */
  71619. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  71620. /**
  71621. * Get the class name
  71622. * @returns "LensRenderingPipeline"
  71623. */
  71624. getClassName(): string;
  71625. /**
  71626. * Gets associated scene
  71627. */
  71628. get scene(): Scene;
  71629. /**
  71630. * Gets or sets the edge blur
  71631. */
  71632. get edgeBlur(): number;
  71633. set edgeBlur(value: number);
  71634. /**
  71635. * Gets or sets the grain amount
  71636. */
  71637. get grainAmount(): number;
  71638. set grainAmount(value: number);
  71639. /**
  71640. * Gets or sets the chromatic aberration amount
  71641. */
  71642. get chromaticAberration(): number;
  71643. set chromaticAberration(value: number);
  71644. /**
  71645. * Gets or sets the depth of field aperture
  71646. */
  71647. get dofAperture(): number;
  71648. set dofAperture(value: number);
  71649. /**
  71650. * Gets or sets the edge distortion
  71651. */
  71652. get edgeDistortion(): number;
  71653. set edgeDistortion(value: number);
  71654. /**
  71655. * Gets or sets the depth of field distortion
  71656. */
  71657. get dofDistortion(): number;
  71658. set dofDistortion(value: number);
  71659. /**
  71660. * Gets or sets the darken out of focus amount
  71661. */
  71662. get darkenOutOfFocus(): number;
  71663. set darkenOutOfFocus(value: number);
  71664. /**
  71665. * Gets or sets a boolean indicating if blur noise is enabled
  71666. */
  71667. get blurNoise(): boolean;
  71668. set blurNoise(value: boolean);
  71669. /**
  71670. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  71671. */
  71672. get pentagonBokeh(): boolean;
  71673. set pentagonBokeh(value: boolean);
  71674. /**
  71675. * Gets or sets the highlight grain amount
  71676. */
  71677. get highlightsGain(): number;
  71678. set highlightsGain(value: number);
  71679. /**
  71680. * Gets or sets the highlight threshold
  71681. */
  71682. get highlightsThreshold(): number;
  71683. set highlightsThreshold(value: number);
  71684. /**
  71685. * Sets the amount of blur at the edges
  71686. * @param amount blur amount
  71687. */
  71688. setEdgeBlur(amount: number): void;
  71689. /**
  71690. * Sets edge blur to 0
  71691. */
  71692. disableEdgeBlur(): void;
  71693. /**
  71694. * Sets the amout of grain
  71695. * @param amount Amount of grain
  71696. */
  71697. setGrainAmount(amount: number): void;
  71698. /**
  71699. * Set grain amount to 0
  71700. */
  71701. disableGrain(): void;
  71702. /**
  71703. * Sets the chromatic aberration amount
  71704. * @param amount amount of chromatic aberration
  71705. */
  71706. setChromaticAberration(amount: number): void;
  71707. /**
  71708. * Sets chromatic aberration amount to 0
  71709. */
  71710. disableChromaticAberration(): void;
  71711. /**
  71712. * Sets the EdgeDistortion amount
  71713. * @param amount amount of EdgeDistortion
  71714. */
  71715. setEdgeDistortion(amount: number): void;
  71716. /**
  71717. * Sets edge distortion to 0
  71718. */
  71719. disableEdgeDistortion(): void;
  71720. /**
  71721. * Sets the FocusDistance amount
  71722. * @param amount amount of FocusDistance
  71723. */
  71724. setFocusDistance(amount: number): void;
  71725. /**
  71726. * Disables depth of field
  71727. */
  71728. disableDepthOfField(): void;
  71729. /**
  71730. * Sets the Aperture amount
  71731. * @param amount amount of Aperture
  71732. */
  71733. setAperture(amount: number): void;
  71734. /**
  71735. * Sets the DarkenOutOfFocus amount
  71736. * @param amount amount of DarkenOutOfFocus
  71737. */
  71738. setDarkenOutOfFocus(amount: number): void;
  71739. private _pentagonBokehIsEnabled;
  71740. /**
  71741. * Creates a pentagon bokeh effect
  71742. */
  71743. enablePentagonBokeh(): void;
  71744. /**
  71745. * Disables the pentagon bokeh effect
  71746. */
  71747. disablePentagonBokeh(): void;
  71748. /**
  71749. * Enables noise blur
  71750. */
  71751. enableNoiseBlur(): void;
  71752. /**
  71753. * Disables noise blur
  71754. */
  71755. disableNoiseBlur(): void;
  71756. /**
  71757. * Sets the HighlightsGain amount
  71758. * @param amount amount of HighlightsGain
  71759. */
  71760. setHighlightsGain(amount: number): void;
  71761. /**
  71762. * Sets the HighlightsThreshold amount
  71763. * @param amount amount of HighlightsThreshold
  71764. */
  71765. setHighlightsThreshold(amount: number): void;
  71766. /**
  71767. * Disables highlights
  71768. */
  71769. disableHighlights(): void;
  71770. /**
  71771. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  71772. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  71773. */
  71774. dispose(disableDepthRender?: boolean): void;
  71775. private _createChromaticAberrationPostProcess;
  71776. private _createHighlightsPostProcess;
  71777. private _createDepthOfFieldPostProcess;
  71778. private _createGrainTexture;
  71779. }
  71780. }
  71781. declare module BABYLON {
  71782. /**
  71783. * Contains all parameters needed for the prepass to perform
  71784. * screen space subsurface scattering
  71785. */
  71786. export class SSAO2Configuration implements PrePassEffectConfiguration {
  71787. /**
  71788. * Is subsurface enabled
  71789. */
  71790. enabled: boolean;
  71791. /**
  71792. * Name of the configuration
  71793. */
  71794. name: string;
  71795. /**
  71796. * Textures that should be present in the MRT for this effect to work
  71797. */
  71798. readonly texturesRequired: number[];
  71799. }
  71800. }
  71801. declare module BABYLON {
  71802. /** @hidden */
  71803. export var ssao2PixelShader: {
  71804. name: string;
  71805. shader: string;
  71806. };
  71807. }
  71808. declare module BABYLON {
  71809. /** @hidden */
  71810. export var ssaoCombinePixelShader: {
  71811. name: string;
  71812. shader: string;
  71813. };
  71814. }
  71815. declare module BABYLON {
  71816. /**
  71817. * Render pipeline to produce ssao effect
  71818. */
  71819. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  71820. /**
  71821. * @ignore
  71822. * The PassPostProcess id in the pipeline that contains the original scene color
  71823. */
  71824. SSAOOriginalSceneColorEffect: string;
  71825. /**
  71826. * @ignore
  71827. * The SSAO PostProcess id in the pipeline
  71828. */
  71829. SSAORenderEffect: string;
  71830. /**
  71831. * @ignore
  71832. * The horizontal blur PostProcess id in the pipeline
  71833. */
  71834. SSAOBlurHRenderEffect: string;
  71835. /**
  71836. * @ignore
  71837. * The vertical blur PostProcess id in the pipeline
  71838. */
  71839. SSAOBlurVRenderEffect: string;
  71840. /**
  71841. * @ignore
  71842. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71843. */
  71844. SSAOCombineRenderEffect: string;
  71845. /**
  71846. * The output strength of the SSAO post-process. Default value is 1.0.
  71847. */
  71848. totalStrength: number;
  71849. /**
  71850. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  71851. */
  71852. maxZ: number;
  71853. /**
  71854. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  71855. */
  71856. minZAspect: number;
  71857. private _samples;
  71858. /**
  71859. * Number of samples used for the SSAO calculations. Default value is 8
  71860. */
  71861. set samples(n: number);
  71862. get samples(): number;
  71863. private _textureSamples;
  71864. /**
  71865. * Number of samples to use for antialiasing
  71866. */
  71867. set textureSamples(n: number);
  71868. get textureSamples(): number;
  71869. /**
  71870. * Force rendering the geometry through geometry buffer
  71871. */
  71872. private _forceGeometryBuffer;
  71873. /**
  71874. * Ratio object used for SSAO ratio and blur ratio
  71875. */
  71876. private _ratio;
  71877. /**
  71878. * Dynamically generated sphere sampler.
  71879. */
  71880. private _sampleSphere;
  71881. /**
  71882. * Blur filter offsets
  71883. */
  71884. private _samplerOffsets;
  71885. private _expensiveBlur;
  71886. /**
  71887. * If bilateral blur should be used
  71888. */
  71889. set expensiveBlur(b: boolean);
  71890. get expensiveBlur(): boolean;
  71891. /**
  71892. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  71893. */
  71894. radius: number;
  71895. /**
  71896. * The base color of the SSAO post-process
  71897. * The final result is "base + ssao" between [0, 1]
  71898. */
  71899. base: number;
  71900. /**
  71901. * Support test.
  71902. */
  71903. static get IsSupported(): boolean;
  71904. private _scene;
  71905. private _randomTexture;
  71906. private _originalColorPostProcess;
  71907. private _ssaoPostProcess;
  71908. private _blurHPostProcess;
  71909. private _blurVPostProcess;
  71910. private _ssaoCombinePostProcess;
  71911. private _prePassRenderer;
  71912. /**
  71913. * Gets active scene
  71914. */
  71915. get scene(): Scene;
  71916. /**
  71917. * @constructor
  71918. * @param name The rendering pipeline name
  71919. * @param scene The scene linked to this pipeline
  71920. * @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 }
  71921. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71922. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  71923. */
  71924. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  71925. /**
  71926. * Get the class name
  71927. * @returns "SSAO2RenderingPipeline"
  71928. */
  71929. getClassName(): string;
  71930. /**
  71931. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71932. */
  71933. dispose(disableGeometryBufferRenderer?: boolean): void;
  71934. private _createBlurPostProcess;
  71935. /** @hidden */
  71936. _rebuild(): void;
  71937. private _bits;
  71938. private _radicalInverse_VdC;
  71939. private _hammersley;
  71940. private _hemisphereSample_uniform;
  71941. private _generateHemisphere;
  71942. private _getDefinesForSSAO;
  71943. private _createSSAOPostProcess;
  71944. private _createSSAOCombinePostProcess;
  71945. private _createRandomTexture;
  71946. /**
  71947. * Serialize the rendering pipeline (Used when exporting)
  71948. * @returns the serialized object
  71949. */
  71950. serialize(): any;
  71951. /**
  71952. * Parse the serialized pipeline
  71953. * @param source Source pipeline.
  71954. * @param scene The scene to load the pipeline to.
  71955. * @param rootUrl The URL of the serialized pipeline.
  71956. * @returns An instantiated pipeline from the serialized object.
  71957. */
  71958. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  71959. }
  71960. }
  71961. declare module BABYLON {
  71962. /** @hidden */
  71963. export var ssaoPixelShader: {
  71964. name: string;
  71965. shader: string;
  71966. };
  71967. }
  71968. declare module BABYLON {
  71969. /**
  71970. * Render pipeline to produce ssao effect
  71971. */
  71972. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  71973. /**
  71974. * @ignore
  71975. * The PassPostProcess id in the pipeline that contains the original scene color
  71976. */
  71977. SSAOOriginalSceneColorEffect: string;
  71978. /**
  71979. * @ignore
  71980. * The SSAO PostProcess id in the pipeline
  71981. */
  71982. SSAORenderEffect: string;
  71983. /**
  71984. * @ignore
  71985. * The horizontal blur PostProcess id in the pipeline
  71986. */
  71987. SSAOBlurHRenderEffect: string;
  71988. /**
  71989. * @ignore
  71990. * The vertical blur PostProcess id in the pipeline
  71991. */
  71992. SSAOBlurVRenderEffect: string;
  71993. /**
  71994. * @ignore
  71995. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71996. */
  71997. SSAOCombineRenderEffect: string;
  71998. /**
  71999. * The output strength of the SSAO post-process. Default value is 1.0.
  72000. */
  72001. totalStrength: number;
  72002. /**
  72003. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  72004. */
  72005. radius: number;
  72006. /**
  72007. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  72008. * Must not be equal to fallOff and superior to fallOff.
  72009. * Default value is 0.0075
  72010. */
  72011. area: number;
  72012. /**
  72013. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  72014. * Must not be equal to area and inferior to area.
  72015. * Default value is 0.000001
  72016. */
  72017. fallOff: number;
  72018. /**
  72019. * The base color of the SSAO post-process
  72020. * The final result is "base + ssao" between [0, 1]
  72021. */
  72022. base: number;
  72023. private _scene;
  72024. private _depthTexture;
  72025. private _randomTexture;
  72026. private _originalColorPostProcess;
  72027. private _ssaoPostProcess;
  72028. private _blurHPostProcess;
  72029. private _blurVPostProcess;
  72030. private _ssaoCombinePostProcess;
  72031. private _firstUpdate;
  72032. /**
  72033. * Gets active scene
  72034. */
  72035. get scene(): Scene;
  72036. /**
  72037. * @constructor
  72038. * @param name - The rendering pipeline name
  72039. * @param scene - The scene linked to this pipeline
  72040. * @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 }
  72041. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  72042. */
  72043. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  72044. /**
  72045. * Get the class name
  72046. * @returns "SSAORenderingPipeline"
  72047. */
  72048. getClassName(): string;
  72049. /**
  72050. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  72051. */
  72052. dispose(disableDepthRender?: boolean): void;
  72053. private _createBlurPostProcess;
  72054. /** @hidden */
  72055. _rebuild(): void;
  72056. private _createSSAOPostProcess;
  72057. private _createSSAOCombinePostProcess;
  72058. private _createRandomTexture;
  72059. }
  72060. }
  72061. declare module BABYLON {
  72062. /**
  72063. * Contains all parameters needed for the prepass to perform
  72064. * screen space reflections
  72065. */
  72066. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  72067. /**
  72068. * Is ssr enabled
  72069. */
  72070. enabled: boolean;
  72071. /**
  72072. * Name of the configuration
  72073. */
  72074. name: string;
  72075. /**
  72076. * Textures that should be present in the MRT for this effect to work
  72077. */
  72078. readonly texturesRequired: number[];
  72079. }
  72080. }
  72081. declare module BABYLON {
  72082. /** @hidden */
  72083. export var screenSpaceReflectionPixelShader: {
  72084. name: string;
  72085. shader: string;
  72086. };
  72087. }
  72088. declare module BABYLON {
  72089. /**
  72090. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  72091. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  72092. */
  72093. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  72094. /**
  72095. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  72096. */
  72097. threshold: number;
  72098. /**
  72099. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  72100. */
  72101. strength: number;
  72102. /**
  72103. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  72104. */
  72105. reflectionSpecularFalloffExponent: number;
  72106. /**
  72107. * 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]
  72108. */
  72109. step: number;
  72110. /**
  72111. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  72112. */
  72113. roughnessFactor: number;
  72114. private _forceGeometryBuffer;
  72115. private _geometryBufferRenderer;
  72116. private _prePassRenderer;
  72117. private _enableSmoothReflections;
  72118. private _reflectionSamples;
  72119. private _smoothSteps;
  72120. /**
  72121. * Gets a string identifying the name of the class
  72122. * @returns "ScreenSpaceReflectionPostProcess" string
  72123. */
  72124. getClassName(): string;
  72125. /**
  72126. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  72127. * @param name The name of the effect.
  72128. * @param scene The scene containing the objects to calculate reflections.
  72129. * @param options The required width/height ratio to downsize to before computing the render pass.
  72130. * @param camera The camera to apply the render pass to.
  72131. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72132. * @param engine The engine which the post process will be applied. (default: current engine)
  72133. * @param reusable If the post process can be reused on the same frame. (default: false)
  72134. * @param textureType Type of textures used when performing the post process. (default: 0)
  72135. * @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)
  72136. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  72137. */
  72138. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  72139. /**
  72140. * Gets wether or not smoothing reflections is enabled.
  72141. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  72142. */
  72143. get enableSmoothReflections(): boolean;
  72144. /**
  72145. * Sets wether or not smoothing reflections is enabled.
  72146. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  72147. */
  72148. set enableSmoothReflections(enabled: boolean);
  72149. /**
  72150. * Gets the number of samples taken while computing reflections. More samples count is high,
  72151. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  72152. */
  72153. get reflectionSamples(): number;
  72154. /**
  72155. * Sets the number of samples taken while computing reflections. More samples count is high,
  72156. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  72157. */
  72158. set reflectionSamples(samples: number);
  72159. /**
  72160. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  72161. * more the post-process will require GPU power and can generate a drop in FPS.
  72162. * Default value (5.0) work pretty well in all cases but can be adjusted.
  72163. */
  72164. get smoothSteps(): number;
  72165. set smoothSteps(steps: number);
  72166. private _updateEffectDefines;
  72167. /** @hidden */
  72168. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  72169. }
  72170. }
  72171. declare module BABYLON {
  72172. /** @hidden */
  72173. export var standardPixelShader: {
  72174. name: string;
  72175. shader: string;
  72176. };
  72177. }
  72178. declare module BABYLON {
  72179. /**
  72180. * Standard rendering pipeline
  72181. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  72182. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  72183. */
  72184. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  72185. /**
  72186. * Public members
  72187. */
  72188. /**
  72189. * Post-process which contains the original scene color before the pipeline applies all the effects
  72190. */
  72191. originalPostProcess: Nullable<PostProcess>;
  72192. /**
  72193. * Post-process used to down scale an image x4
  72194. */
  72195. downSampleX4PostProcess: Nullable<PostProcess>;
  72196. /**
  72197. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  72198. */
  72199. brightPassPostProcess: Nullable<PostProcess>;
  72200. /**
  72201. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  72202. */
  72203. blurHPostProcesses: PostProcess[];
  72204. /**
  72205. * Post-process array storing all the vertical blur post-processes used by the pipeline
  72206. */
  72207. blurVPostProcesses: PostProcess[];
  72208. /**
  72209. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  72210. */
  72211. textureAdderPostProcess: Nullable<PostProcess>;
  72212. /**
  72213. * Post-process used to create volumetric lighting effect
  72214. */
  72215. volumetricLightPostProcess: Nullable<PostProcess>;
  72216. /**
  72217. * Post-process used to smooth the previous volumetric light post-process on the X axis
  72218. */
  72219. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  72220. /**
  72221. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  72222. */
  72223. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  72224. /**
  72225. * Post-process used to merge the volumetric light effect and the real scene color
  72226. */
  72227. volumetricLightMergePostProces: Nullable<PostProcess>;
  72228. /**
  72229. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  72230. */
  72231. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  72232. /**
  72233. * Base post-process used to calculate the average luminance of the final image for HDR
  72234. */
  72235. luminancePostProcess: Nullable<PostProcess>;
  72236. /**
  72237. * Post-processes used to create down sample post-processes in order to get
  72238. * the average luminance of the final image for HDR
  72239. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  72240. */
  72241. luminanceDownSamplePostProcesses: PostProcess[];
  72242. /**
  72243. * Post-process used to create a HDR effect (light adaptation)
  72244. */
  72245. hdrPostProcess: Nullable<PostProcess>;
  72246. /**
  72247. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  72248. */
  72249. textureAdderFinalPostProcess: Nullable<PostProcess>;
  72250. /**
  72251. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  72252. */
  72253. lensFlareFinalPostProcess: Nullable<PostProcess>;
  72254. /**
  72255. * Post-process used to merge the final HDR post-process and the real scene color
  72256. */
  72257. hdrFinalPostProcess: Nullable<PostProcess>;
  72258. /**
  72259. * Post-process used to create a lens flare effect
  72260. */
  72261. lensFlarePostProcess: Nullable<PostProcess>;
  72262. /**
  72263. * Post-process that merges the result of the lens flare post-process and the real scene color
  72264. */
  72265. lensFlareComposePostProcess: Nullable<PostProcess>;
  72266. /**
  72267. * Post-process used to create a motion blur effect
  72268. */
  72269. motionBlurPostProcess: Nullable<PostProcess>;
  72270. /**
  72271. * Post-process used to create a depth of field effect
  72272. */
  72273. depthOfFieldPostProcess: Nullable<PostProcess>;
  72274. /**
  72275. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  72276. */
  72277. fxaaPostProcess: Nullable<FxaaPostProcess>;
  72278. /**
  72279. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  72280. */
  72281. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  72282. /**
  72283. * Represents the brightness threshold in order to configure the illuminated surfaces
  72284. */
  72285. brightThreshold: number;
  72286. /**
  72287. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  72288. */
  72289. blurWidth: number;
  72290. /**
  72291. * Sets if the blur for highlighted surfaces must be only horizontal
  72292. */
  72293. horizontalBlur: boolean;
  72294. /**
  72295. * Gets the overall exposure used by the pipeline
  72296. */
  72297. get exposure(): number;
  72298. /**
  72299. * Sets the overall exposure used by the pipeline
  72300. */
  72301. set exposure(value: number);
  72302. /**
  72303. * Texture used typically to simulate "dirty" on camera lens
  72304. */
  72305. lensTexture: Nullable<Texture>;
  72306. /**
  72307. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  72308. */
  72309. volumetricLightCoefficient: number;
  72310. /**
  72311. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  72312. */
  72313. volumetricLightPower: number;
  72314. /**
  72315. * Used the set the blur intensity to smooth the volumetric lights
  72316. */
  72317. volumetricLightBlurScale: number;
  72318. /**
  72319. * Light (spot or directional) used to generate the volumetric lights rays
  72320. * The source light must have a shadow generate so the pipeline can get its
  72321. * depth map
  72322. */
  72323. sourceLight: Nullable<SpotLight | DirectionalLight>;
  72324. /**
  72325. * For eye adaptation, represents the minimum luminance the eye can see
  72326. */
  72327. hdrMinimumLuminance: number;
  72328. /**
  72329. * For eye adaptation, represents the decrease luminance speed
  72330. */
  72331. hdrDecreaseRate: number;
  72332. /**
  72333. * For eye adaptation, represents the increase luminance speed
  72334. */
  72335. hdrIncreaseRate: number;
  72336. /**
  72337. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  72338. */
  72339. get hdrAutoExposure(): boolean;
  72340. /**
  72341. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  72342. */
  72343. set hdrAutoExposure(value: boolean);
  72344. /**
  72345. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  72346. */
  72347. lensColorTexture: Nullable<Texture>;
  72348. /**
  72349. * The overall strengh for the lens flare effect
  72350. */
  72351. lensFlareStrength: number;
  72352. /**
  72353. * Dispersion coefficient for lens flare ghosts
  72354. */
  72355. lensFlareGhostDispersal: number;
  72356. /**
  72357. * Main lens flare halo width
  72358. */
  72359. lensFlareHaloWidth: number;
  72360. /**
  72361. * Based on the lens distortion effect, defines how much the lens flare result
  72362. * is distorted
  72363. */
  72364. lensFlareDistortionStrength: number;
  72365. /**
  72366. * Configures the blur intensity used for for lens flare (halo)
  72367. */
  72368. lensFlareBlurWidth: number;
  72369. /**
  72370. * Lens star texture must be used to simulate rays on the flares and is available
  72371. * in the documentation
  72372. */
  72373. lensStarTexture: Nullable<Texture>;
  72374. /**
  72375. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  72376. * flare effect by taking account of the dirt texture
  72377. */
  72378. lensFlareDirtTexture: Nullable<Texture>;
  72379. /**
  72380. * Represents the focal length for the depth of field effect
  72381. */
  72382. depthOfFieldDistance: number;
  72383. /**
  72384. * Represents the blur intensity for the blurred part of the depth of field effect
  72385. */
  72386. depthOfFieldBlurWidth: number;
  72387. /**
  72388. * Gets how much the image is blurred by the movement while using the motion blur post-process
  72389. */
  72390. get motionStrength(): number;
  72391. /**
  72392. * Sets how much the image is blurred by the movement while using the motion blur post-process
  72393. */
  72394. set motionStrength(strength: number);
  72395. /**
  72396. * Gets wether or not the motion blur post-process is object based or screen based.
  72397. */
  72398. get objectBasedMotionBlur(): boolean;
  72399. /**
  72400. * Sets wether or not the motion blur post-process should be object based or screen based
  72401. */
  72402. set objectBasedMotionBlur(value: boolean);
  72403. /**
  72404. * List of animations for the pipeline (IAnimatable implementation)
  72405. */
  72406. animations: Animation[];
  72407. /**
  72408. * Private members
  72409. */
  72410. private _scene;
  72411. private _currentDepthOfFieldSource;
  72412. private _basePostProcess;
  72413. private _fixedExposure;
  72414. private _currentExposure;
  72415. private _hdrAutoExposure;
  72416. private _hdrCurrentLuminance;
  72417. private _motionStrength;
  72418. private _isObjectBasedMotionBlur;
  72419. private _floatTextureType;
  72420. private _camerasToBeAttached;
  72421. private _ratio;
  72422. private _bloomEnabled;
  72423. private _depthOfFieldEnabled;
  72424. private _vlsEnabled;
  72425. private _lensFlareEnabled;
  72426. private _hdrEnabled;
  72427. private _motionBlurEnabled;
  72428. private _fxaaEnabled;
  72429. private _screenSpaceReflectionsEnabled;
  72430. private _motionBlurSamples;
  72431. private _volumetricLightStepsCount;
  72432. private _samples;
  72433. /**
  72434. * @ignore
  72435. * Specifies if the bloom pipeline is enabled
  72436. */
  72437. get BloomEnabled(): boolean;
  72438. set BloomEnabled(enabled: boolean);
  72439. /**
  72440. * @ignore
  72441. * Specifies if the depth of field pipeline is enabed
  72442. */
  72443. get DepthOfFieldEnabled(): boolean;
  72444. set DepthOfFieldEnabled(enabled: boolean);
  72445. /**
  72446. * @ignore
  72447. * Specifies if the lens flare pipeline is enabed
  72448. */
  72449. get LensFlareEnabled(): boolean;
  72450. set LensFlareEnabled(enabled: boolean);
  72451. /**
  72452. * @ignore
  72453. * Specifies if the HDR pipeline is enabled
  72454. */
  72455. get HDREnabled(): boolean;
  72456. set HDREnabled(enabled: boolean);
  72457. /**
  72458. * @ignore
  72459. * Specifies if the volumetric lights scattering effect is enabled
  72460. */
  72461. get VLSEnabled(): boolean;
  72462. set VLSEnabled(enabled: boolean);
  72463. /**
  72464. * @ignore
  72465. * Specifies if the motion blur effect is enabled
  72466. */
  72467. get MotionBlurEnabled(): boolean;
  72468. set MotionBlurEnabled(enabled: boolean);
  72469. /**
  72470. * Specifies if anti-aliasing is enabled
  72471. */
  72472. get fxaaEnabled(): boolean;
  72473. set fxaaEnabled(enabled: boolean);
  72474. /**
  72475. * Specifies if screen space reflections are enabled.
  72476. */
  72477. get screenSpaceReflectionsEnabled(): boolean;
  72478. set screenSpaceReflectionsEnabled(enabled: boolean);
  72479. /**
  72480. * Specifies the number of steps used to calculate the volumetric lights
  72481. * Typically in interval [50, 200]
  72482. */
  72483. get volumetricLightStepsCount(): number;
  72484. set volumetricLightStepsCount(count: number);
  72485. /**
  72486. * Specifies the number of samples used for the motion blur effect
  72487. * Typically in interval [16, 64]
  72488. */
  72489. get motionBlurSamples(): number;
  72490. set motionBlurSamples(samples: number);
  72491. /**
  72492. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  72493. */
  72494. get samples(): number;
  72495. set samples(sampleCount: number);
  72496. /**
  72497. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  72498. * @constructor
  72499. * @param name The rendering pipeline name
  72500. * @param scene The scene linked to this pipeline
  72501. * @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)
  72502. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  72503. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72504. */
  72505. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  72506. private _buildPipeline;
  72507. private _createDownSampleX4PostProcess;
  72508. private _createBrightPassPostProcess;
  72509. private _createBlurPostProcesses;
  72510. private _createTextureAdderPostProcess;
  72511. private _createVolumetricLightPostProcess;
  72512. private _createLuminancePostProcesses;
  72513. private _createHdrPostProcess;
  72514. private _createLensFlarePostProcess;
  72515. private _createDepthOfFieldPostProcess;
  72516. private _createMotionBlurPostProcess;
  72517. private _getDepthTexture;
  72518. private _disposePostProcesses;
  72519. /**
  72520. * Dispose of the pipeline and stop all post processes
  72521. */
  72522. dispose(): void;
  72523. /**
  72524. * Serialize the rendering pipeline (Used when exporting)
  72525. * @returns the serialized object
  72526. */
  72527. serialize(): any;
  72528. /**
  72529. * Parse the serialized pipeline
  72530. * @param source Source pipeline.
  72531. * @param scene The scene to load the pipeline to.
  72532. * @param rootUrl The URL of the serialized pipeline.
  72533. * @returns An instantiated pipeline from the serialized object.
  72534. */
  72535. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  72536. /**
  72537. * Luminance steps
  72538. */
  72539. static LuminanceSteps: number;
  72540. }
  72541. }
  72542. declare module BABYLON {
  72543. /** @hidden */
  72544. export var stereoscopicInterlacePixelShader: {
  72545. name: string;
  72546. shader: string;
  72547. };
  72548. }
  72549. declare module BABYLON {
  72550. /**
  72551. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  72552. */
  72553. export class StereoscopicInterlacePostProcessI extends PostProcess {
  72554. private _stepSize;
  72555. private _passedProcess;
  72556. /**
  72557. * Gets a string identifying the name of the class
  72558. * @returns "StereoscopicInterlacePostProcessI" string
  72559. */
  72560. getClassName(): string;
  72561. /**
  72562. * Initializes a StereoscopicInterlacePostProcessI
  72563. * @param name The name of the effect.
  72564. * @param rigCameras The rig cameras to be appled to the post process
  72565. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  72566. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  72567. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72568. * @param engine The engine which the post process will be applied. (default: current engine)
  72569. * @param reusable If the post process can be reused on the same frame. (default: false)
  72570. */
  72571. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72572. }
  72573. /**
  72574. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  72575. */
  72576. export class StereoscopicInterlacePostProcess extends PostProcess {
  72577. private _stepSize;
  72578. private _passedProcess;
  72579. /**
  72580. * Gets a string identifying the name of the class
  72581. * @returns "StereoscopicInterlacePostProcess" string
  72582. */
  72583. getClassName(): string;
  72584. /**
  72585. * Initializes a StereoscopicInterlacePostProcess
  72586. * @param name The name of the effect.
  72587. * @param rigCameras The rig cameras to be appled to the post process
  72588. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  72589. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72590. * @param engine The engine which the post process will be applied. (default: current engine)
  72591. * @param reusable If the post process can be reused on the same frame. (default: false)
  72592. */
  72593. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72594. }
  72595. }
  72596. declare module BABYLON {
  72597. /** @hidden */
  72598. export var tonemapPixelShader: {
  72599. name: string;
  72600. shader: string;
  72601. };
  72602. }
  72603. declare module BABYLON {
  72604. /** Defines operator used for tonemapping */
  72605. export enum TonemappingOperator {
  72606. /** Hable */
  72607. Hable = 0,
  72608. /** Reinhard */
  72609. Reinhard = 1,
  72610. /** HejiDawson */
  72611. HejiDawson = 2,
  72612. /** Photographic */
  72613. Photographic = 3
  72614. }
  72615. /**
  72616. * Defines a post process to apply tone mapping
  72617. */
  72618. export class TonemapPostProcess extends PostProcess {
  72619. private _operator;
  72620. /** Defines the required exposure adjustement */
  72621. exposureAdjustment: number;
  72622. /**
  72623. * Gets a string identifying the name of the class
  72624. * @returns "TonemapPostProcess" string
  72625. */
  72626. getClassName(): string;
  72627. /**
  72628. * Creates a new TonemapPostProcess
  72629. * @param name defines the name of the postprocess
  72630. * @param _operator defines the operator to use
  72631. * @param exposureAdjustment defines the required exposure adjustement
  72632. * @param camera defines the camera to use (can be null)
  72633. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  72634. * @param engine defines the hosting engine (can be ignore if camera is set)
  72635. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72636. */
  72637. constructor(name: string, _operator: TonemappingOperator,
  72638. /** Defines the required exposure adjustement */
  72639. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  72640. }
  72641. }
  72642. declare module BABYLON {
  72643. /** @hidden */
  72644. export var volumetricLightScatteringPixelShader: {
  72645. name: string;
  72646. shader: string;
  72647. };
  72648. }
  72649. declare module BABYLON {
  72650. /** @hidden */
  72651. export var volumetricLightScatteringPassVertexShader: {
  72652. name: string;
  72653. shader: string;
  72654. };
  72655. }
  72656. declare module BABYLON {
  72657. /** @hidden */
  72658. export var volumetricLightScatteringPassPixelShader: {
  72659. name: string;
  72660. shader: string;
  72661. };
  72662. }
  72663. declare module BABYLON {
  72664. /**
  72665. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  72666. */
  72667. export class VolumetricLightScatteringPostProcess extends PostProcess {
  72668. private _volumetricLightScatteringPass;
  72669. private _volumetricLightScatteringRTT;
  72670. private _viewPort;
  72671. private _screenCoordinates;
  72672. private _cachedDefines;
  72673. /**
  72674. * If not undefined, the mesh position is computed from the attached node position
  72675. */
  72676. attachedNode: {
  72677. position: Vector3;
  72678. };
  72679. /**
  72680. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  72681. */
  72682. customMeshPosition: Vector3;
  72683. /**
  72684. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  72685. */
  72686. useCustomMeshPosition: boolean;
  72687. /**
  72688. * If the post-process should inverse the light scattering direction
  72689. */
  72690. invert: boolean;
  72691. /**
  72692. * The internal mesh used by the post-process
  72693. */
  72694. mesh: Mesh;
  72695. /**
  72696. * @hidden
  72697. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  72698. */
  72699. get useDiffuseColor(): boolean;
  72700. set useDiffuseColor(useDiffuseColor: boolean);
  72701. /**
  72702. * Array containing the excluded meshes not rendered in the internal pass
  72703. */
  72704. excludedMeshes: AbstractMesh[];
  72705. /**
  72706. * Controls the overall intensity of the post-process
  72707. */
  72708. exposure: number;
  72709. /**
  72710. * Dissipates each sample's contribution in range [0, 1]
  72711. */
  72712. decay: number;
  72713. /**
  72714. * Controls the overall intensity of each sample
  72715. */
  72716. weight: number;
  72717. /**
  72718. * Controls the density of each sample
  72719. */
  72720. density: number;
  72721. /**
  72722. * @constructor
  72723. * @param name The post-process name
  72724. * @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)
  72725. * @param camera The camera that the post-process will be attached to
  72726. * @param mesh The mesh used to create the light scattering
  72727. * @param samples The post-process quality, default 100
  72728. * @param samplingModeThe post-process filtering mode
  72729. * @param engine The babylon engine
  72730. * @param reusable If the post-process is reusable
  72731. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  72732. */
  72733. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  72734. /**
  72735. * Returns the string "VolumetricLightScatteringPostProcess"
  72736. * @returns "VolumetricLightScatteringPostProcess"
  72737. */
  72738. getClassName(): string;
  72739. private _isReady;
  72740. /**
  72741. * Sets the new light position for light scattering effect
  72742. * @param position The new custom light position
  72743. */
  72744. setCustomMeshPosition(position: Vector3): void;
  72745. /**
  72746. * Returns the light position for light scattering effect
  72747. * @return Vector3 The custom light position
  72748. */
  72749. getCustomMeshPosition(): Vector3;
  72750. /**
  72751. * Disposes the internal assets and detaches the post-process from the camera
  72752. */
  72753. dispose(camera: Camera): void;
  72754. /**
  72755. * Returns the render target texture used by the post-process
  72756. * @return the render target texture used by the post-process
  72757. */
  72758. getPass(): RenderTargetTexture;
  72759. private _meshExcluded;
  72760. private _createPass;
  72761. private _updateMeshScreenCoordinates;
  72762. /**
  72763. * Creates a default mesh for the Volumeric Light Scattering post-process
  72764. * @param name The mesh name
  72765. * @param scene The scene where to create the mesh
  72766. * @return the default mesh
  72767. */
  72768. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  72769. }
  72770. }
  72771. declare module BABYLON {
  72772. /** @hidden */
  72773. export var screenSpaceCurvaturePixelShader: {
  72774. name: string;
  72775. shader: string;
  72776. };
  72777. }
  72778. declare module BABYLON {
  72779. /**
  72780. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  72781. */
  72782. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  72783. /**
  72784. * Defines how much ridge the curvature effect displays.
  72785. */
  72786. ridge: number;
  72787. /**
  72788. * Defines how much valley the curvature effect displays.
  72789. */
  72790. valley: number;
  72791. private _geometryBufferRenderer;
  72792. /**
  72793. * Gets a string identifying the name of the class
  72794. * @returns "ScreenSpaceCurvaturePostProcess" string
  72795. */
  72796. getClassName(): string;
  72797. /**
  72798. * Creates a new instance ScreenSpaceCurvaturePostProcess
  72799. * @param name The name of the effect.
  72800. * @param scene The scene containing the objects to blur according to their velocity.
  72801. * @param options The required width/height ratio to downsize to before computing the render pass.
  72802. * @param camera The camera to apply the render pass to.
  72803. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72804. * @param engine The engine which the post process will be applied. (default: current engine)
  72805. * @param reusable If the post process can be reused on the same frame. (default: false)
  72806. * @param textureType Type of textures used when performing the post process. (default: 0)
  72807. * @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)
  72808. */
  72809. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72810. /**
  72811. * Support test.
  72812. */
  72813. static get IsSupported(): boolean;
  72814. /** @hidden */
  72815. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  72816. }
  72817. }
  72818. declare module BABYLON {
  72819. interface Scene {
  72820. /** @hidden (Backing field) */
  72821. _boundingBoxRenderer: BoundingBoxRenderer;
  72822. /** @hidden (Backing field) */
  72823. _forceShowBoundingBoxes: boolean;
  72824. /**
  72825. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  72826. */
  72827. forceShowBoundingBoxes: boolean;
  72828. /**
  72829. * Gets the bounding box renderer associated with the scene
  72830. * @returns a BoundingBoxRenderer
  72831. */
  72832. getBoundingBoxRenderer(): BoundingBoxRenderer;
  72833. }
  72834. interface AbstractMesh {
  72835. /** @hidden (Backing field) */
  72836. _showBoundingBox: boolean;
  72837. /**
  72838. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  72839. */
  72840. showBoundingBox: boolean;
  72841. }
  72842. /**
  72843. * Component responsible of rendering the bounding box of the meshes in a scene.
  72844. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  72845. */
  72846. export class BoundingBoxRenderer implements ISceneComponent {
  72847. /**
  72848. * The component name helpfull to identify the component in the list of scene components.
  72849. */
  72850. readonly name: string;
  72851. /**
  72852. * The scene the component belongs to.
  72853. */
  72854. scene: Scene;
  72855. /**
  72856. * Color of the bounding box lines placed in front of an object
  72857. */
  72858. frontColor: Color3;
  72859. /**
  72860. * Color of the bounding box lines placed behind an object
  72861. */
  72862. backColor: Color3;
  72863. /**
  72864. * Defines if the renderer should show the back lines or not
  72865. */
  72866. showBackLines: boolean;
  72867. /**
  72868. * Observable raised before rendering a bounding box
  72869. */
  72870. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  72871. /**
  72872. * Observable raised after rendering a bounding box
  72873. */
  72874. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  72875. /**
  72876. * Observable raised after resources are created
  72877. */
  72878. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  72879. /**
  72880. * When false, no bounding boxes will be rendered
  72881. */
  72882. enabled: boolean;
  72883. /**
  72884. * @hidden
  72885. */
  72886. renderList: SmartArray<BoundingBox>;
  72887. private _colorShader;
  72888. private _vertexBuffers;
  72889. private _indexBuffer;
  72890. private _fillIndexBuffer;
  72891. private _fillIndexData;
  72892. /**
  72893. * Instantiates a new bounding box renderer in a scene.
  72894. * @param scene the scene the renderer renders in
  72895. */
  72896. constructor(scene: Scene);
  72897. /**
  72898. * Registers the component in a given scene
  72899. */
  72900. register(): void;
  72901. private _evaluateSubMesh;
  72902. private _preActiveMesh;
  72903. private _prepareResources;
  72904. private _createIndexBuffer;
  72905. /**
  72906. * Rebuilds the elements related to this component in case of
  72907. * context lost for instance.
  72908. */
  72909. rebuild(): void;
  72910. /**
  72911. * @hidden
  72912. */
  72913. reset(): void;
  72914. /**
  72915. * Render the bounding boxes of a specific rendering group
  72916. * @param renderingGroupId defines the rendering group to render
  72917. */
  72918. render(renderingGroupId: number): void;
  72919. /**
  72920. * In case of occlusion queries, we can render the occlusion bounding box through this method
  72921. * @param mesh Define the mesh to render the occlusion bounding box for
  72922. */
  72923. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  72924. /**
  72925. * Dispose and release the resources attached to this renderer.
  72926. */
  72927. dispose(): void;
  72928. }
  72929. }
  72930. declare module BABYLON {
  72931. interface Scene {
  72932. /** @hidden (Backing field) */
  72933. _depthRenderer: {
  72934. [id: string]: DepthRenderer;
  72935. };
  72936. /**
  72937. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  72938. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  72939. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  72940. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  72941. * @returns the created depth renderer
  72942. */
  72943. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  72944. /**
  72945. * Disables a depth renderer for a given camera
  72946. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  72947. */
  72948. disableDepthRenderer(camera?: Nullable<Camera>): void;
  72949. }
  72950. /**
  72951. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  72952. * in several rendering techniques.
  72953. */
  72954. export class DepthRendererSceneComponent implements ISceneComponent {
  72955. /**
  72956. * The component name helpfull to identify the component in the list of scene components.
  72957. */
  72958. readonly name: string;
  72959. /**
  72960. * The scene the component belongs to.
  72961. */
  72962. scene: Scene;
  72963. /**
  72964. * Creates a new instance of the component for the given scene
  72965. * @param scene Defines the scene to register the component in
  72966. */
  72967. constructor(scene: Scene);
  72968. /**
  72969. * Registers the component in a given scene
  72970. */
  72971. register(): void;
  72972. /**
  72973. * Rebuilds the elements related to this component in case of
  72974. * context lost for instance.
  72975. */
  72976. rebuild(): void;
  72977. /**
  72978. * Disposes the component and the associated ressources
  72979. */
  72980. dispose(): void;
  72981. private _gatherRenderTargets;
  72982. private _gatherActiveCameraRenderTargets;
  72983. }
  72984. }
  72985. declare module BABYLON {
  72986. interface AbstractScene {
  72987. /** @hidden (Backing field) */
  72988. _prePassRenderer: Nullable<PrePassRenderer>;
  72989. /**
  72990. * Gets or Sets the current prepass renderer associated to the scene.
  72991. */
  72992. prePassRenderer: Nullable<PrePassRenderer>;
  72993. /**
  72994. * Enables the prepass and associates it with the scene
  72995. * @returns the PrePassRenderer
  72996. */
  72997. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  72998. /**
  72999. * Disables the prepass associated with the scene
  73000. */
  73001. disablePrePassRenderer(): void;
  73002. }
  73003. /**
  73004. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73005. * in several rendering techniques.
  73006. */
  73007. export class PrePassRendererSceneComponent implements ISceneComponent {
  73008. /**
  73009. * The component name helpful to identify the component in the list of scene components.
  73010. */
  73011. readonly name: string;
  73012. /**
  73013. * The scene the component belongs to.
  73014. */
  73015. scene: Scene;
  73016. /**
  73017. * Creates a new instance of the component for the given scene
  73018. * @param scene Defines the scene to register the component in
  73019. */
  73020. constructor(scene: Scene);
  73021. /**
  73022. * Registers the component in a given scene
  73023. */
  73024. register(): void;
  73025. private _beforeCameraDraw;
  73026. private _afterCameraDraw;
  73027. private _beforeClearStage;
  73028. /**
  73029. * Rebuilds the elements related to this component in case of
  73030. * context lost for instance.
  73031. */
  73032. rebuild(): void;
  73033. /**
  73034. * Disposes the component and the associated ressources
  73035. */
  73036. dispose(): void;
  73037. }
  73038. }
  73039. declare module BABYLON {
  73040. /** @hidden */
  73041. export var fibonacci: {
  73042. name: string;
  73043. shader: string;
  73044. };
  73045. }
  73046. declare module BABYLON {
  73047. /** @hidden */
  73048. export var diffusionProfile: {
  73049. name: string;
  73050. shader: string;
  73051. };
  73052. }
  73053. declare module BABYLON {
  73054. /** @hidden */
  73055. export var subSurfaceScatteringPixelShader: {
  73056. name: string;
  73057. shader: string;
  73058. };
  73059. }
  73060. declare module BABYLON {
  73061. /**
  73062. * Sub surface scattering post process
  73063. */
  73064. export class SubSurfaceScatteringPostProcess extends PostProcess {
  73065. /**
  73066. * Gets a string identifying the name of the class
  73067. * @returns "SubSurfaceScatteringPostProcess" string
  73068. */
  73069. getClassName(): string;
  73070. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73071. }
  73072. }
  73073. declare module BABYLON {
  73074. /**
  73075. * Contains all parameters needed for the prepass to perform
  73076. * screen space subsurface scattering
  73077. */
  73078. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  73079. /** @hidden */
  73080. static _SceneComponentInitialization: (scene: Scene) => void;
  73081. private _ssDiffusionS;
  73082. private _ssFilterRadii;
  73083. private _ssDiffusionD;
  73084. /**
  73085. * Post process to attach for screen space subsurface scattering
  73086. */
  73087. postProcess: SubSurfaceScatteringPostProcess;
  73088. /**
  73089. * Diffusion profile color for subsurface scattering
  73090. */
  73091. get ssDiffusionS(): number[];
  73092. /**
  73093. * Diffusion profile max color channel value for subsurface scattering
  73094. */
  73095. get ssDiffusionD(): number[];
  73096. /**
  73097. * Diffusion profile filter radius for subsurface scattering
  73098. */
  73099. get ssFilterRadii(): number[];
  73100. /**
  73101. * Is subsurface enabled
  73102. */
  73103. enabled: boolean;
  73104. /**
  73105. * Name of the configuration
  73106. */
  73107. name: string;
  73108. /**
  73109. * Diffusion profile colors for subsurface scattering
  73110. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  73111. * See ...
  73112. * Note that you can only store up to 5 of them
  73113. */
  73114. ssDiffusionProfileColors: Color3[];
  73115. /**
  73116. * Defines the ratio real world => scene units.
  73117. * Used for subsurface scattering
  73118. */
  73119. metersPerUnit: number;
  73120. /**
  73121. * Textures that should be present in the MRT for this effect to work
  73122. */
  73123. readonly texturesRequired: number[];
  73124. private _scene;
  73125. /**
  73126. * Builds a subsurface configuration object
  73127. * @param scene The scene
  73128. */
  73129. constructor(scene: Scene);
  73130. /**
  73131. * Adds a new diffusion profile.
  73132. * Useful for more realistic subsurface scattering on diverse materials.
  73133. * @param color The color of the diffusion profile. Should be the average color of the material.
  73134. * @return The index of the diffusion profile for the material subsurface configuration
  73135. */
  73136. addDiffusionProfile(color: Color3): number;
  73137. /**
  73138. * Creates the sss post process
  73139. * @return The created post process
  73140. */
  73141. createPostProcess(): SubSurfaceScatteringPostProcess;
  73142. /**
  73143. * Deletes all diffusion profiles.
  73144. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  73145. */
  73146. clearAllDiffusionProfiles(): void;
  73147. /**
  73148. * Disposes this object
  73149. */
  73150. dispose(): void;
  73151. /**
  73152. * @hidden
  73153. * https://zero-radiance.github.io/post/sampling-diffusion/
  73154. *
  73155. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  73156. * ------------------------------------------------------------------------------------
  73157. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  73158. * PDF[r, phi, s] = r * R[r, phi, s]
  73159. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  73160. * ------------------------------------------------------------------------------------
  73161. * We importance sample the color channel with the widest scattering distance.
  73162. */
  73163. getDiffusionProfileParameters(color: Color3): number;
  73164. /**
  73165. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  73166. * 'u' is the random number (the value of the CDF): [0, 1).
  73167. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  73168. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  73169. */
  73170. private _sampleBurleyDiffusionProfile;
  73171. }
  73172. }
  73173. declare module BABYLON {
  73174. interface AbstractScene {
  73175. /** @hidden (Backing field) */
  73176. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  73177. /**
  73178. * Gets or Sets the current prepass renderer associated to the scene.
  73179. */
  73180. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  73181. /**
  73182. * Enables the subsurface effect for prepass
  73183. * @returns the SubSurfaceConfiguration
  73184. */
  73185. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  73186. /**
  73187. * Disables the subsurface effect for prepass
  73188. */
  73189. disableSubSurfaceForPrePass(): void;
  73190. }
  73191. /**
  73192. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73193. * in several rendering techniques.
  73194. */
  73195. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  73196. /**
  73197. * The component name helpful to identify the component in the list of scene components.
  73198. */
  73199. readonly name: string;
  73200. /**
  73201. * The scene the component belongs to.
  73202. */
  73203. scene: Scene;
  73204. /**
  73205. * Creates a new instance of the component for the given scene
  73206. * @param scene Defines the scene to register the component in
  73207. */
  73208. constructor(scene: Scene);
  73209. /**
  73210. * Registers the component in a given scene
  73211. */
  73212. register(): void;
  73213. /**
  73214. * Serializes the component data to the specified json object
  73215. * @param serializationObject The object to serialize to
  73216. */
  73217. serialize(serializationObject: any): void;
  73218. /**
  73219. * Adds all the elements from the container to the scene
  73220. * @param container the container holding the elements
  73221. */
  73222. addFromContainer(container: AbstractScene): void;
  73223. /**
  73224. * Removes all the elements in the container from the scene
  73225. * @param container contains the elements to remove
  73226. * @param dispose if the removed element should be disposed (default: false)
  73227. */
  73228. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  73229. /**
  73230. * Rebuilds the elements related to this component in case of
  73231. * context lost for instance.
  73232. */
  73233. rebuild(): void;
  73234. /**
  73235. * Disposes the component and the associated ressources
  73236. */
  73237. dispose(): void;
  73238. }
  73239. }
  73240. declare module BABYLON {
  73241. /** @hidden */
  73242. export var outlinePixelShader: {
  73243. name: string;
  73244. shader: string;
  73245. };
  73246. }
  73247. declare module BABYLON {
  73248. /** @hidden */
  73249. export var outlineVertexShader: {
  73250. name: string;
  73251. shader: string;
  73252. };
  73253. }
  73254. declare module BABYLON {
  73255. interface Scene {
  73256. /** @hidden */
  73257. _outlineRenderer: OutlineRenderer;
  73258. /**
  73259. * Gets the outline renderer associated with the scene
  73260. * @returns a OutlineRenderer
  73261. */
  73262. getOutlineRenderer(): OutlineRenderer;
  73263. }
  73264. interface AbstractMesh {
  73265. /** @hidden (Backing field) */
  73266. _renderOutline: boolean;
  73267. /**
  73268. * Gets or sets a boolean indicating if the outline must be rendered as well
  73269. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  73270. */
  73271. renderOutline: boolean;
  73272. /** @hidden (Backing field) */
  73273. _renderOverlay: boolean;
  73274. /**
  73275. * Gets or sets a boolean indicating if the overlay must be rendered as well
  73276. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  73277. */
  73278. renderOverlay: boolean;
  73279. }
  73280. /**
  73281. * This class is responsible to draw bothe outline/overlay of meshes.
  73282. * It should not be used directly but through the available method on mesh.
  73283. */
  73284. export class OutlineRenderer implements ISceneComponent {
  73285. /**
  73286. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  73287. */
  73288. private static _StencilReference;
  73289. /**
  73290. * The name of the component. Each component must have a unique name.
  73291. */
  73292. name: string;
  73293. /**
  73294. * The scene the component belongs to.
  73295. */
  73296. scene: Scene;
  73297. /**
  73298. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  73299. */
  73300. zOffset: number;
  73301. private _engine;
  73302. private _effect;
  73303. private _cachedDefines;
  73304. private _savedDepthWrite;
  73305. /**
  73306. * Instantiates a new outline renderer. (There could be only one per scene).
  73307. * @param scene Defines the scene it belongs to
  73308. */
  73309. constructor(scene: Scene);
  73310. /**
  73311. * Register the component to one instance of a scene.
  73312. */
  73313. register(): void;
  73314. /**
  73315. * Rebuilds the elements related to this component in case of
  73316. * context lost for instance.
  73317. */
  73318. rebuild(): void;
  73319. /**
  73320. * Disposes the component and the associated ressources.
  73321. */
  73322. dispose(): void;
  73323. /**
  73324. * Renders the outline in the canvas.
  73325. * @param subMesh Defines the sumesh to render
  73326. * @param batch Defines the batch of meshes in case of instances
  73327. * @param useOverlay Defines if the rendering is for the overlay or the outline
  73328. */
  73329. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  73330. /**
  73331. * Returns whether or not the outline renderer is ready for a given submesh.
  73332. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  73333. * @param subMesh Defines the submesh to check readyness for
  73334. * @param useInstances Defines wheter wee are trying to render instances or not
  73335. * @returns true if ready otherwise false
  73336. */
  73337. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73338. private _beforeRenderingMesh;
  73339. private _afterRenderingMesh;
  73340. }
  73341. }
  73342. declare module BABYLON {
  73343. /**
  73344. * Defines the basic options interface of a Sprite Frame Source Size.
  73345. */
  73346. export interface ISpriteJSONSpriteSourceSize {
  73347. /**
  73348. * number of the original width of the Frame
  73349. */
  73350. w: number;
  73351. /**
  73352. * number of the original height of the Frame
  73353. */
  73354. h: number;
  73355. }
  73356. /**
  73357. * Defines the basic options interface of a Sprite Frame Data.
  73358. */
  73359. export interface ISpriteJSONSpriteFrameData {
  73360. /**
  73361. * number of the x offset of the Frame
  73362. */
  73363. x: number;
  73364. /**
  73365. * number of the y offset of the Frame
  73366. */
  73367. y: number;
  73368. /**
  73369. * number of the width of the Frame
  73370. */
  73371. w: number;
  73372. /**
  73373. * number of the height of the Frame
  73374. */
  73375. h: number;
  73376. }
  73377. /**
  73378. * Defines the basic options interface of a JSON Sprite.
  73379. */
  73380. export interface ISpriteJSONSprite {
  73381. /**
  73382. * string name of the Frame
  73383. */
  73384. filename: string;
  73385. /**
  73386. * ISpriteJSONSpriteFrame basic object of the frame data
  73387. */
  73388. frame: ISpriteJSONSpriteFrameData;
  73389. /**
  73390. * boolean to flag is the frame was rotated.
  73391. */
  73392. rotated: boolean;
  73393. /**
  73394. * boolean to flag is the frame was trimmed.
  73395. */
  73396. trimmed: boolean;
  73397. /**
  73398. * ISpriteJSONSpriteFrame basic object of the source data
  73399. */
  73400. spriteSourceSize: ISpriteJSONSpriteFrameData;
  73401. /**
  73402. * ISpriteJSONSpriteFrame basic object of the source data
  73403. */
  73404. sourceSize: ISpriteJSONSpriteSourceSize;
  73405. }
  73406. /**
  73407. * Defines the basic options interface of a JSON atlas.
  73408. */
  73409. export interface ISpriteJSONAtlas {
  73410. /**
  73411. * Array of objects that contain the frame data.
  73412. */
  73413. frames: Array<ISpriteJSONSprite>;
  73414. /**
  73415. * object basic object containing the sprite meta data.
  73416. */
  73417. meta?: object;
  73418. }
  73419. }
  73420. declare module BABYLON {
  73421. /** @hidden */
  73422. export var spriteMapPixelShader: {
  73423. name: string;
  73424. shader: string;
  73425. };
  73426. }
  73427. declare module BABYLON {
  73428. /** @hidden */
  73429. export var spriteMapVertexShader: {
  73430. name: string;
  73431. shader: string;
  73432. };
  73433. }
  73434. declare module BABYLON {
  73435. /**
  73436. * Defines the basic options interface of a SpriteMap
  73437. */
  73438. export interface ISpriteMapOptions {
  73439. /**
  73440. * Vector2 of the number of cells in the grid.
  73441. */
  73442. stageSize?: Vector2;
  73443. /**
  73444. * Vector2 of the size of the output plane in World Units.
  73445. */
  73446. outputSize?: Vector2;
  73447. /**
  73448. * Vector3 of the position of the output plane in World Units.
  73449. */
  73450. outputPosition?: Vector3;
  73451. /**
  73452. * Vector3 of the rotation of the output plane.
  73453. */
  73454. outputRotation?: Vector3;
  73455. /**
  73456. * number of layers that the system will reserve in resources.
  73457. */
  73458. layerCount?: number;
  73459. /**
  73460. * number of max animation frames a single cell will reserve in resources.
  73461. */
  73462. maxAnimationFrames?: number;
  73463. /**
  73464. * number cell index of the base tile when the system compiles.
  73465. */
  73466. baseTile?: number;
  73467. /**
  73468. * boolean flip the sprite after its been repositioned by the framing data.
  73469. */
  73470. flipU?: boolean;
  73471. /**
  73472. * Vector3 scalar of the global RGB values of the SpriteMap.
  73473. */
  73474. colorMultiply?: Vector3;
  73475. }
  73476. /**
  73477. * Defines the IDisposable interface in order to be cleanable from resources.
  73478. */
  73479. export interface ISpriteMap extends IDisposable {
  73480. /**
  73481. * String name of the SpriteMap.
  73482. */
  73483. name: string;
  73484. /**
  73485. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  73486. */
  73487. atlasJSON: ISpriteJSONAtlas;
  73488. /**
  73489. * Texture of the SpriteMap.
  73490. */
  73491. spriteSheet: Texture;
  73492. /**
  73493. * The parameters to initialize the SpriteMap with.
  73494. */
  73495. options: ISpriteMapOptions;
  73496. }
  73497. /**
  73498. * Class used to manage a grid restricted sprite deployment on an Output plane.
  73499. */
  73500. export class SpriteMap implements ISpriteMap {
  73501. /** The Name of the spriteMap */
  73502. name: string;
  73503. /** The JSON file with the frame and meta data */
  73504. atlasJSON: ISpriteJSONAtlas;
  73505. /** The systems Sprite Sheet Texture */
  73506. spriteSheet: Texture;
  73507. /** Arguments passed with the Constructor */
  73508. options: ISpriteMapOptions;
  73509. /** Public Sprite Storage array, parsed from atlasJSON */
  73510. sprites: Array<ISpriteJSONSprite>;
  73511. /** Returns the Number of Sprites in the System */
  73512. get spriteCount(): number;
  73513. /** Returns the Position of Output Plane*/
  73514. get position(): Vector3;
  73515. /** Returns the Position of Output Plane*/
  73516. set position(v: Vector3);
  73517. /** Returns the Rotation of Output Plane*/
  73518. get rotation(): Vector3;
  73519. /** Returns the Rotation of Output Plane*/
  73520. set rotation(v: Vector3);
  73521. /** Sets the AnimationMap*/
  73522. get animationMap(): RawTexture;
  73523. /** Sets the AnimationMap*/
  73524. set animationMap(v: RawTexture);
  73525. /** Scene that the SpriteMap was created in */
  73526. private _scene;
  73527. /** Texture Buffer of Float32 that holds tile frame data*/
  73528. private _frameMap;
  73529. /** Texture Buffers of Float32 that holds tileMap data*/
  73530. private _tileMaps;
  73531. /** Texture Buffer of Float32 that holds Animation Data*/
  73532. private _animationMap;
  73533. /** Custom ShaderMaterial Central to the System*/
  73534. private _material;
  73535. /** Custom ShaderMaterial Central to the System*/
  73536. private _output;
  73537. /** Systems Time Ticker*/
  73538. private _time;
  73539. /**
  73540. * Creates a new SpriteMap
  73541. * @param name defines the SpriteMaps Name
  73542. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  73543. * @param spriteSheet is the Texture that the Sprites are on.
  73544. * @param options a basic deployment configuration
  73545. * @param scene The Scene that the map is deployed on
  73546. */
  73547. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  73548. /**
  73549. * Returns tileID location
  73550. * @returns Vector2 the cell position ID
  73551. */
  73552. getTileID(): Vector2;
  73553. /**
  73554. * Gets the UV location of the mouse over the SpriteMap.
  73555. * @returns Vector2 the UV position of the mouse interaction
  73556. */
  73557. getMousePosition(): Vector2;
  73558. /**
  73559. * Creates the "frame" texture Buffer
  73560. * -------------------------------------
  73561. * Structure of frames
  73562. * "filename": "Falling-Water-2.png",
  73563. * "frame": {"x":69,"y":103,"w":24,"h":32},
  73564. * "rotated": true,
  73565. * "trimmed": true,
  73566. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  73567. * "sourceSize": {"w":32,"h":32}
  73568. * @returns RawTexture of the frameMap
  73569. */
  73570. private _createFrameBuffer;
  73571. /**
  73572. * Creates the tileMap texture Buffer
  73573. * @param buffer normally and array of numbers, or a false to generate from scratch
  73574. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  73575. * @returns RawTexture of the tileMap
  73576. */
  73577. private _createTileBuffer;
  73578. /**
  73579. * Modifies the data of the tileMaps
  73580. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  73581. * @param pos is the iVector2 Coordinates of the Tile
  73582. * @param tile The SpriteIndex of the new Tile
  73583. */
  73584. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  73585. /**
  73586. * Creates the animationMap texture Buffer
  73587. * @param buffer normally and array of numbers, or a false to generate from scratch
  73588. * @returns RawTexture of the animationMap
  73589. */
  73590. private _createTileAnimationBuffer;
  73591. /**
  73592. * Modifies the data of the animationMap
  73593. * @param cellID is the Index of the Sprite
  73594. * @param _frame is the target Animation frame
  73595. * @param toCell is the Target Index of the next frame of the animation
  73596. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  73597. * @param speed is a global scalar of the time variable on the map.
  73598. */
  73599. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  73600. /**
  73601. * Exports the .tilemaps file
  73602. */
  73603. saveTileMaps(): void;
  73604. /**
  73605. * Imports the .tilemaps file
  73606. * @param url of the .tilemaps file
  73607. */
  73608. loadTileMaps(url: string): void;
  73609. /**
  73610. * Release associated resources
  73611. */
  73612. dispose(): void;
  73613. }
  73614. }
  73615. declare module BABYLON {
  73616. /**
  73617. * Class used to manage multiple sprites of different sizes on the same spritesheet
  73618. * @see https://doc.babylonjs.com/babylon101/sprites
  73619. */
  73620. export class SpritePackedManager extends SpriteManager {
  73621. /** defines the packed manager's name */
  73622. name: string;
  73623. /**
  73624. * Creates a new sprite manager from a packed sprite sheet
  73625. * @param name defines the manager's name
  73626. * @param imgUrl defines the sprite sheet url
  73627. * @param capacity defines the maximum allowed number of sprites
  73628. * @param scene defines the hosting scene
  73629. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  73630. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  73631. * @param samplingMode defines the smapling mode to use with spritesheet
  73632. * @param fromPacked set to true; do not alter
  73633. */
  73634. constructor(
  73635. /** defines the packed manager's name */
  73636. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  73637. }
  73638. }
  73639. declare module BABYLON {
  73640. /**
  73641. * Defines the list of states available for a task inside a AssetsManager
  73642. */
  73643. export enum AssetTaskState {
  73644. /**
  73645. * Initialization
  73646. */
  73647. INIT = 0,
  73648. /**
  73649. * Running
  73650. */
  73651. RUNNING = 1,
  73652. /**
  73653. * Done
  73654. */
  73655. DONE = 2,
  73656. /**
  73657. * Error
  73658. */
  73659. ERROR = 3
  73660. }
  73661. /**
  73662. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  73663. */
  73664. export abstract class AbstractAssetTask {
  73665. /**
  73666. * Task name
  73667. */ name: string;
  73668. /**
  73669. * Callback called when the task is successful
  73670. */
  73671. onSuccess: (task: any) => void;
  73672. /**
  73673. * Callback called when the task is not successful
  73674. */
  73675. onError: (task: any, message?: string, exception?: any) => void;
  73676. /**
  73677. * Creates a new AssetsManager
  73678. * @param name defines the name of the task
  73679. */
  73680. constructor(
  73681. /**
  73682. * Task name
  73683. */ name: string);
  73684. private _isCompleted;
  73685. private _taskState;
  73686. private _errorObject;
  73687. /**
  73688. * Get if the task is completed
  73689. */
  73690. get isCompleted(): boolean;
  73691. /**
  73692. * Gets the current state of the task
  73693. */
  73694. get taskState(): AssetTaskState;
  73695. /**
  73696. * Gets the current error object (if task is in error)
  73697. */
  73698. get errorObject(): {
  73699. message?: string;
  73700. exception?: any;
  73701. };
  73702. /**
  73703. * Internal only
  73704. * @hidden
  73705. */
  73706. _setErrorObject(message?: string, exception?: any): void;
  73707. /**
  73708. * Execute the current task
  73709. * @param scene defines the scene where you want your assets to be loaded
  73710. * @param onSuccess is a callback called when the task is successfully executed
  73711. * @param onError is a callback called if an error occurs
  73712. */
  73713. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73714. /**
  73715. * Execute the current task
  73716. * @param scene defines the scene where you want your assets to be loaded
  73717. * @param onSuccess is a callback called when the task is successfully executed
  73718. * @param onError is a callback called if an error occurs
  73719. */
  73720. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73721. /**
  73722. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  73723. * This can be used with failed tasks that have the reason for failure fixed.
  73724. */
  73725. reset(): void;
  73726. private onErrorCallback;
  73727. private onDoneCallback;
  73728. }
  73729. /**
  73730. * Define the interface used by progress events raised during assets loading
  73731. */
  73732. export interface IAssetsProgressEvent {
  73733. /**
  73734. * Defines the number of remaining tasks to process
  73735. */
  73736. remainingCount: number;
  73737. /**
  73738. * Defines the total number of tasks
  73739. */
  73740. totalCount: number;
  73741. /**
  73742. * Defines the task that was just processed
  73743. */
  73744. task: AbstractAssetTask;
  73745. }
  73746. /**
  73747. * Class used to share progress information about assets loading
  73748. */
  73749. export class AssetsProgressEvent implements IAssetsProgressEvent {
  73750. /**
  73751. * Defines the number of remaining tasks to process
  73752. */
  73753. remainingCount: number;
  73754. /**
  73755. * Defines the total number of tasks
  73756. */
  73757. totalCount: number;
  73758. /**
  73759. * Defines the task that was just processed
  73760. */
  73761. task: AbstractAssetTask;
  73762. /**
  73763. * Creates a AssetsProgressEvent
  73764. * @param remainingCount defines the number of remaining tasks to process
  73765. * @param totalCount defines the total number of tasks
  73766. * @param task defines the task that was just processed
  73767. */
  73768. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  73769. }
  73770. /**
  73771. * Define a task used by AssetsManager to load assets into a container
  73772. */
  73773. export class ContainerAssetTask extends AbstractAssetTask {
  73774. /**
  73775. * Defines the name of the task
  73776. */
  73777. name: string;
  73778. /**
  73779. * Defines the list of mesh's names you want to load
  73780. */
  73781. meshesNames: any;
  73782. /**
  73783. * Defines the root url to use as a base to load your meshes and associated resources
  73784. */
  73785. rootUrl: string;
  73786. /**
  73787. * Defines the filename or File of the scene to load from
  73788. */
  73789. sceneFilename: string | File;
  73790. /**
  73791. * Get the loaded asset container
  73792. */
  73793. loadedContainer: AssetContainer;
  73794. /**
  73795. * Gets the list of loaded meshes
  73796. */
  73797. loadedMeshes: Array<AbstractMesh>;
  73798. /**
  73799. * Gets the list of loaded particle systems
  73800. */
  73801. loadedParticleSystems: Array<IParticleSystem>;
  73802. /**
  73803. * Gets the list of loaded skeletons
  73804. */
  73805. loadedSkeletons: Array<Skeleton>;
  73806. /**
  73807. * Gets the list of loaded animation groups
  73808. */
  73809. loadedAnimationGroups: Array<AnimationGroup>;
  73810. /**
  73811. * Callback called when the task is successful
  73812. */
  73813. onSuccess: (task: ContainerAssetTask) => void;
  73814. /**
  73815. * Callback called when the task is successful
  73816. */
  73817. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  73818. /**
  73819. * Creates a new ContainerAssetTask
  73820. * @param name defines the name of the task
  73821. * @param meshesNames defines the list of mesh's names you want to load
  73822. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  73823. * @param sceneFilename defines the filename or File of the scene to load from
  73824. */
  73825. constructor(
  73826. /**
  73827. * Defines the name of the task
  73828. */
  73829. name: string,
  73830. /**
  73831. * Defines the list of mesh's names you want to load
  73832. */
  73833. meshesNames: any,
  73834. /**
  73835. * Defines the root url to use as a base to load your meshes and associated resources
  73836. */
  73837. rootUrl: string,
  73838. /**
  73839. * Defines the filename or File of the scene to load from
  73840. */
  73841. sceneFilename: string | File);
  73842. /**
  73843. * Execute the current task
  73844. * @param scene defines the scene where you want your assets to be loaded
  73845. * @param onSuccess is a callback called when the task is successfully executed
  73846. * @param onError is a callback called if an error occurs
  73847. */
  73848. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73849. }
  73850. /**
  73851. * Define a task used by AssetsManager to load meshes
  73852. */
  73853. export class MeshAssetTask extends AbstractAssetTask {
  73854. /**
  73855. * Defines the name of the task
  73856. */
  73857. name: string;
  73858. /**
  73859. * Defines the list of mesh's names you want to load
  73860. */
  73861. meshesNames: any;
  73862. /**
  73863. * Defines the root url to use as a base to load your meshes and associated resources
  73864. */
  73865. rootUrl: string;
  73866. /**
  73867. * Defines the filename or File of the scene to load from
  73868. */
  73869. sceneFilename: string | File;
  73870. /**
  73871. * Gets the list of loaded meshes
  73872. */
  73873. loadedMeshes: Array<AbstractMesh>;
  73874. /**
  73875. * Gets the list of loaded particle systems
  73876. */
  73877. loadedParticleSystems: Array<IParticleSystem>;
  73878. /**
  73879. * Gets the list of loaded skeletons
  73880. */
  73881. loadedSkeletons: Array<Skeleton>;
  73882. /**
  73883. * Gets the list of loaded animation groups
  73884. */
  73885. loadedAnimationGroups: Array<AnimationGroup>;
  73886. /**
  73887. * Callback called when the task is successful
  73888. */
  73889. onSuccess: (task: MeshAssetTask) => void;
  73890. /**
  73891. * Callback called when the task is successful
  73892. */
  73893. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  73894. /**
  73895. * Creates a new MeshAssetTask
  73896. * @param name defines the name of the task
  73897. * @param meshesNames defines the list of mesh's names you want to load
  73898. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  73899. * @param sceneFilename defines the filename or File of the scene to load from
  73900. */
  73901. constructor(
  73902. /**
  73903. * Defines the name of the task
  73904. */
  73905. name: string,
  73906. /**
  73907. * Defines the list of mesh's names you want to load
  73908. */
  73909. meshesNames: any,
  73910. /**
  73911. * Defines the root url to use as a base to load your meshes and associated resources
  73912. */
  73913. rootUrl: string,
  73914. /**
  73915. * Defines the filename or File of the scene to load from
  73916. */
  73917. sceneFilename: string | File);
  73918. /**
  73919. * Execute the current task
  73920. * @param scene defines the scene where you want your assets to be loaded
  73921. * @param onSuccess is a callback called when the task is successfully executed
  73922. * @param onError is a callback called if an error occurs
  73923. */
  73924. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73925. }
  73926. /**
  73927. * Define a task used by AssetsManager to load text content
  73928. */
  73929. export class TextFileAssetTask extends AbstractAssetTask {
  73930. /**
  73931. * Defines the name of the task
  73932. */
  73933. name: string;
  73934. /**
  73935. * Defines the location of the file to load
  73936. */
  73937. url: string;
  73938. /**
  73939. * Gets the loaded text string
  73940. */
  73941. text: string;
  73942. /**
  73943. * Callback called when the task is successful
  73944. */
  73945. onSuccess: (task: TextFileAssetTask) => void;
  73946. /**
  73947. * Callback called when the task is successful
  73948. */
  73949. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  73950. /**
  73951. * Creates a new TextFileAssetTask object
  73952. * @param name defines the name of the task
  73953. * @param url defines the location of the file to load
  73954. */
  73955. constructor(
  73956. /**
  73957. * Defines the name of the task
  73958. */
  73959. name: string,
  73960. /**
  73961. * Defines the location of the file to load
  73962. */
  73963. url: string);
  73964. /**
  73965. * Execute the current task
  73966. * @param scene defines the scene where you want your assets to be loaded
  73967. * @param onSuccess is a callback called when the task is successfully executed
  73968. * @param onError is a callback called if an error occurs
  73969. */
  73970. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73971. }
  73972. /**
  73973. * Define a task used by AssetsManager to load binary data
  73974. */
  73975. export class BinaryFileAssetTask extends AbstractAssetTask {
  73976. /**
  73977. * Defines the name of the task
  73978. */
  73979. name: string;
  73980. /**
  73981. * Defines the location of the file to load
  73982. */
  73983. url: string;
  73984. /**
  73985. * Gets the lodaded data (as an array buffer)
  73986. */
  73987. data: ArrayBuffer;
  73988. /**
  73989. * Callback called when the task is successful
  73990. */
  73991. onSuccess: (task: BinaryFileAssetTask) => void;
  73992. /**
  73993. * Callback called when the task is successful
  73994. */
  73995. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  73996. /**
  73997. * Creates a new BinaryFileAssetTask object
  73998. * @param name defines the name of the new task
  73999. * @param url defines the location of the file to load
  74000. */
  74001. constructor(
  74002. /**
  74003. * Defines the name of the task
  74004. */
  74005. name: string,
  74006. /**
  74007. * Defines the location of the file to load
  74008. */
  74009. url: string);
  74010. /**
  74011. * Execute the current task
  74012. * @param scene defines the scene where you want your assets to be loaded
  74013. * @param onSuccess is a callback called when the task is successfully executed
  74014. * @param onError is a callback called if an error occurs
  74015. */
  74016. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74017. }
  74018. /**
  74019. * Define a task used by AssetsManager to load images
  74020. */
  74021. export class ImageAssetTask extends AbstractAssetTask {
  74022. /**
  74023. * Defines the name of the task
  74024. */
  74025. name: string;
  74026. /**
  74027. * Defines the location of the image to load
  74028. */
  74029. url: string;
  74030. /**
  74031. * Gets the loaded images
  74032. */
  74033. image: HTMLImageElement;
  74034. /**
  74035. * Callback called when the task is successful
  74036. */
  74037. onSuccess: (task: ImageAssetTask) => void;
  74038. /**
  74039. * Callback called when the task is successful
  74040. */
  74041. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  74042. /**
  74043. * Creates a new ImageAssetTask
  74044. * @param name defines the name of the task
  74045. * @param url defines the location of the image to load
  74046. */
  74047. constructor(
  74048. /**
  74049. * Defines the name of the task
  74050. */
  74051. name: string,
  74052. /**
  74053. * Defines the location of the image to load
  74054. */
  74055. url: string);
  74056. /**
  74057. * Execute the current task
  74058. * @param scene defines the scene where you want your assets to be loaded
  74059. * @param onSuccess is a callback called when the task is successfully executed
  74060. * @param onError is a callback called if an error occurs
  74061. */
  74062. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74063. }
  74064. /**
  74065. * Defines the interface used by texture loading tasks
  74066. */
  74067. export interface ITextureAssetTask<TEX extends BaseTexture> {
  74068. /**
  74069. * Gets the loaded texture
  74070. */
  74071. texture: TEX;
  74072. }
  74073. /**
  74074. * Define a task used by AssetsManager to load 2D textures
  74075. */
  74076. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  74077. /**
  74078. * Defines the name of the task
  74079. */
  74080. name: string;
  74081. /**
  74082. * Defines the location of the file to load
  74083. */
  74084. url: string;
  74085. /**
  74086. * Defines if mipmap should not be generated (default is false)
  74087. */
  74088. noMipmap?: boolean | undefined;
  74089. /**
  74090. * Defines if texture must be inverted on Y axis (default is true)
  74091. */
  74092. invertY: boolean;
  74093. /**
  74094. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74095. */
  74096. samplingMode: number;
  74097. /**
  74098. * Gets the loaded texture
  74099. */
  74100. texture: Texture;
  74101. /**
  74102. * Callback called when the task is successful
  74103. */
  74104. onSuccess: (task: TextureAssetTask) => void;
  74105. /**
  74106. * Callback called when the task is successful
  74107. */
  74108. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  74109. /**
  74110. * Creates a new TextureAssetTask object
  74111. * @param name defines the name of the task
  74112. * @param url defines the location of the file to load
  74113. * @param noMipmap defines if mipmap should not be generated (default is false)
  74114. * @param invertY defines if texture must be inverted on Y axis (default is true)
  74115. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74116. */
  74117. constructor(
  74118. /**
  74119. * Defines the name of the task
  74120. */
  74121. name: string,
  74122. /**
  74123. * Defines the location of the file to load
  74124. */
  74125. url: string,
  74126. /**
  74127. * Defines if mipmap should not be generated (default is false)
  74128. */
  74129. noMipmap?: boolean | undefined,
  74130. /**
  74131. * Defines if texture must be inverted on Y axis (default is true)
  74132. */
  74133. invertY?: boolean,
  74134. /**
  74135. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74136. */
  74137. samplingMode?: number);
  74138. /**
  74139. * Execute the current task
  74140. * @param scene defines the scene where you want your assets to be loaded
  74141. * @param onSuccess is a callback called when the task is successfully executed
  74142. * @param onError is a callback called if an error occurs
  74143. */
  74144. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74145. }
  74146. /**
  74147. * Define a task used by AssetsManager to load cube textures
  74148. */
  74149. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  74150. /**
  74151. * Defines the name of the task
  74152. */
  74153. name: string;
  74154. /**
  74155. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74156. */
  74157. url: string;
  74158. /**
  74159. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74160. */
  74161. extensions?: string[] | undefined;
  74162. /**
  74163. * Defines if mipmaps should not be generated (default is false)
  74164. */
  74165. noMipmap?: boolean | undefined;
  74166. /**
  74167. * Defines the explicit list of files (undefined by default)
  74168. */
  74169. files?: string[] | undefined;
  74170. /**
  74171. * Gets the loaded texture
  74172. */
  74173. texture: CubeTexture;
  74174. /**
  74175. * Callback called when the task is successful
  74176. */
  74177. onSuccess: (task: CubeTextureAssetTask) => void;
  74178. /**
  74179. * Callback called when the task is successful
  74180. */
  74181. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  74182. /**
  74183. * Creates a new CubeTextureAssetTask
  74184. * @param name defines the name of the task
  74185. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74186. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74187. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74188. * @param files defines the explicit list of files (undefined by default)
  74189. */
  74190. constructor(
  74191. /**
  74192. * Defines the name of the task
  74193. */
  74194. name: string,
  74195. /**
  74196. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74197. */
  74198. url: string,
  74199. /**
  74200. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74201. */
  74202. extensions?: string[] | undefined,
  74203. /**
  74204. * Defines if mipmaps should not be generated (default is false)
  74205. */
  74206. noMipmap?: boolean | undefined,
  74207. /**
  74208. * Defines the explicit list of files (undefined by default)
  74209. */
  74210. files?: string[] | undefined);
  74211. /**
  74212. * Execute the current task
  74213. * @param scene defines the scene where you want your assets to be loaded
  74214. * @param onSuccess is a callback called when the task is successfully executed
  74215. * @param onError is a callback called if an error occurs
  74216. */
  74217. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74218. }
  74219. /**
  74220. * Define a task used by AssetsManager to load HDR cube textures
  74221. */
  74222. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  74223. /**
  74224. * Defines the name of the task
  74225. */
  74226. name: string;
  74227. /**
  74228. * Defines the location of the file to load
  74229. */
  74230. url: string;
  74231. /**
  74232. * Defines the desired size (the more it increases the longer the generation will be)
  74233. */
  74234. size: number;
  74235. /**
  74236. * Defines if mipmaps should not be generated (default is false)
  74237. */
  74238. noMipmap: boolean;
  74239. /**
  74240. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74241. */
  74242. generateHarmonics: boolean;
  74243. /**
  74244. * 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)
  74245. */
  74246. gammaSpace: boolean;
  74247. /**
  74248. * Internal Use Only
  74249. */
  74250. reserved: boolean;
  74251. /**
  74252. * Gets the loaded texture
  74253. */
  74254. texture: HDRCubeTexture;
  74255. /**
  74256. * Callback called when the task is successful
  74257. */
  74258. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  74259. /**
  74260. * Callback called when the task is successful
  74261. */
  74262. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  74263. /**
  74264. * Creates a new HDRCubeTextureAssetTask object
  74265. * @param name defines the name of the task
  74266. * @param url defines the location of the file to load
  74267. * @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.
  74268. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74269. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74270. * @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)
  74271. * @param reserved Internal use only
  74272. */
  74273. constructor(
  74274. /**
  74275. * Defines the name of the task
  74276. */
  74277. name: string,
  74278. /**
  74279. * Defines the location of the file to load
  74280. */
  74281. url: string,
  74282. /**
  74283. * Defines the desired size (the more it increases the longer the generation will be)
  74284. */
  74285. size: number,
  74286. /**
  74287. * Defines if mipmaps should not be generated (default is false)
  74288. */
  74289. noMipmap?: boolean,
  74290. /**
  74291. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74292. */
  74293. generateHarmonics?: boolean,
  74294. /**
  74295. * 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)
  74296. */
  74297. gammaSpace?: boolean,
  74298. /**
  74299. * Internal Use Only
  74300. */
  74301. reserved?: boolean);
  74302. /**
  74303. * Execute the current task
  74304. * @param scene defines the scene where you want your assets to be loaded
  74305. * @param onSuccess is a callback called when the task is successfully executed
  74306. * @param onError is a callback called if an error occurs
  74307. */
  74308. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74309. }
  74310. /**
  74311. * Define a task used by AssetsManager to load Equirectangular cube textures
  74312. */
  74313. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  74314. /**
  74315. * Defines the name of the task
  74316. */
  74317. name: string;
  74318. /**
  74319. * Defines the location of the file to load
  74320. */
  74321. url: string;
  74322. /**
  74323. * Defines the desired size (the more it increases the longer the generation will be)
  74324. */
  74325. size: number;
  74326. /**
  74327. * Defines if mipmaps should not be generated (default is false)
  74328. */
  74329. noMipmap: boolean;
  74330. /**
  74331. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  74332. * but the standard material would require them in Gamma space) (default is true)
  74333. */
  74334. gammaSpace: boolean;
  74335. /**
  74336. * Gets the loaded texture
  74337. */
  74338. texture: EquiRectangularCubeTexture;
  74339. /**
  74340. * Callback called when the task is successful
  74341. */
  74342. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  74343. /**
  74344. * Callback called when the task is successful
  74345. */
  74346. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  74347. /**
  74348. * Creates a new EquiRectangularCubeTextureAssetTask object
  74349. * @param name defines the name of the task
  74350. * @param url defines the location of the file to load
  74351. * @param size defines the desired size (the more it increases the longer the generation will be)
  74352. * If the size is omitted this implies you are using a preprocessed cubemap.
  74353. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74354. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  74355. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  74356. * (default is true)
  74357. */
  74358. constructor(
  74359. /**
  74360. * Defines the name of the task
  74361. */
  74362. name: string,
  74363. /**
  74364. * Defines the location of the file to load
  74365. */
  74366. url: string,
  74367. /**
  74368. * Defines the desired size (the more it increases the longer the generation will be)
  74369. */
  74370. size: number,
  74371. /**
  74372. * Defines if mipmaps should not be generated (default is false)
  74373. */
  74374. noMipmap?: boolean,
  74375. /**
  74376. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  74377. * but the standard material would require them in Gamma space) (default is true)
  74378. */
  74379. gammaSpace?: boolean);
  74380. /**
  74381. * Execute the current task
  74382. * @param scene defines the scene where you want your assets to be loaded
  74383. * @param onSuccess is a callback called when the task is successfully executed
  74384. * @param onError is a callback called if an error occurs
  74385. */
  74386. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74387. }
  74388. /**
  74389. * This class can be used to easily import assets into a scene
  74390. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  74391. */
  74392. export class AssetsManager {
  74393. private _scene;
  74394. private _isLoading;
  74395. protected _tasks: AbstractAssetTask[];
  74396. protected _waitingTasksCount: number;
  74397. protected _totalTasksCount: number;
  74398. /**
  74399. * Callback called when all tasks are processed
  74400. */
  74401. onFinish: (tasks: AbstractAssetTask[]) => void;
  74402. /**
  74403. * Callback called when a task is successful
  74404. */
  74405. onTaskSuccess: (task: AbstractAssetTask) => void;
  74406. /**
  74407. * Callback called when a task had an error
  74408. */
  74409. onTaskError: (task: AbstractAssetTask) => void;
  74410. /**
  74411. * Callback called when a task is done (whatever the result is)
  74412. */
  74413. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  74414. /**
  74415. * Observable called when all tasks are processed
  74416. */
  74417. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  74418. /**
  74419. * Observable called when a task had an error
  74420. */
  74421. onTaskErrorObservable: Observable<AbstractAssetTask>;
  74422. /**
  74423. * Observable called when all tasks were executed
  74424. */
  74425. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  74426. /**
  74427. * Observable called when a task is done (whatever the result is)
  74428. */
  74429. onProgressObservable: Observable<IAssetsProgressEvent>;
  74430. /**
  74431. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  74432. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  74433. */
  74434. useDefaultLoadingScreen: boolean;
  74435. /**
  74436. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  74437. * when all assets have been downloaded.
  74438. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  74439. */
  74440. autoHideLoadingUI: boolean;
  74441. /**
  74442. * Creates a new AssetsManager
  74443. * @param scene defines the scene to work on
  74444. */
  74445. constructor(scene: Scene);
  74446. /**
  74447. * Add a ContainerAssetTask to the list of active tasks
  74448. * @param taskName defines the name of the new task
  74449. * @param meshesNames defines the name of meshes to load
  74450. * @param rootUrl defines the root url to use to locate files
  74451. * @param sceneFilename defines the filename of the scene file
  74452. * @returns a new ContainerAssetTask object
  74453. */
  74454. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  74455. /**
  74456. * Add a MeshAssetTask to the list of active tasks
  74457. * @param taskName defines the name of the new task
  74458. * @param meshesNames defines the name of meshes to load
  74459. * @param rootUrl defines the root url to use to locate files
  74460. * @param sceneFilename defines the filename of the scene file
  74461. * @returns a new MeshAssetTask object
  74462. */
  74463. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  74464. /**
  74465. * Add a TextFileAssetTask to the list of active tasks
  74466. * @param taskName defines the name of the new task
  74467. * @param url defines the url of the file to load
  74468. * @returns a new TextFileAssetTask object
  74469. */
  74470. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  74471. /**
  74472. * Add a BinaryFileAssetTask to the list of active tasks
  74473. * @param taskName defines the name of the new task
  74474. * @param url defines the url of the file to load
  74475. * @returns a new BinaryFileAssetTask object
  74476. */
  74477. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  74478. /**
  74479. * Add a ImageAssetTask to the list of active tasks
  74480. * @param taskName defines the name of the new task
  74481. * @param url defines the url of the file to load
  74482. * @returns a new ImageAssetTask object
  74483. */
  74484. addImageTask(taskName: string, url: string): ImageAssetTask;
  74485. /**
  74486. * Add a TextureAssetTask to the list of active tasks
  74487. * @param taskName defines the name of the new task
  74488. * @param url defines the url of the file to load
  74489. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74490. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  74491. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  74492. * @returns a new TextureAssetTask object
  74493. */
  74494. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  74495. /**
  74496. * Add a CubeTextureAssetTask to the list of active tasks
  74497. * @param taskName defines the name of the new task
  74498. * @param url defines the url of the file to load
  74499. * @param extensions defines the extension to use to load the cube map (can be null)
  74500. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74501. * @param files defines the list of files to load (can be null)
  74502. * @returns a new CubeTextureAssetTask object
  74503. */
  74504. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  74505. /**
  74506. *
  74507. * Add a HDRCubeTextureAssetTask to the list of active tasks
  74508. * @param taskName defines the name of the new task
  74509. * @param url defines the url of the file to load
  74510. * @param size defines the size you want for the cubemap (can be null)
  74511. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74512. * @param generateHarmonics defines if you want to automatically generate (true by default)
  74513. * @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)
  74514. * @param reserved Internal use only
  74515. * @returns a new HDRCubeTextureAssetTask object
  74516. */
  74517. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  74518. /**
  74519. *
  74520. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  74521. * @param taskName defines the name of the new task
  74522. * @param url defines the url of the file to load
  74523. * @param size defines the size you want for the cubemap (can be null)
  74524. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74525. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  74526. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  74527. * @returns a new EquiRectangularCubeTextureAssetTask object
  74528. */
  74529. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  74530. /**
  74531. * Remove a task from the assets manager.
  74532. * @param task the task to remove
  74533. */
  74534. removeTask(task: AbstractAssetTask): void;
  74535. private _decreaseWaitingTasksCount;
  74536. private _runTask;
  74537. /**
  74538. * Reset the AssetsManager and remove all tasks
  74539. * @return the current instance of the AssetsManager
  74540. */
  74541. reset(): AssetsManager;
  74542. /**
  74543. * Start the loading process
  74544. * @return the current instance of the AssetsManager
  74545. */
  74546. load(): AssetsManager;
  74547. /**
  74548. * Start the loading process as an async operation
  74549. * @return a promise returning the list of failed tasks
  74550. */
  74551. loadAsync(): Promise<void>;
  74552. }
  74553. }
  74554. declare module BABYLON {
  74555. /**
  74556. * Wrapper class for promise with external resolve and reject.
  74557. */
  74558. export class Deferred<T> {
  74559. /**
  74560. * The promise associated with this deferred object.
  74561. */
  74562. readonly promise: Promise<T>;
  74563. private _resolve;
  74564. private _reject;
  74565. /**
  74566. * The resolve method of the promise associated with this deferred object.
  74567. */
  74568. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  74569. /**
  74570. * The reject method of the promise associated with this deferred object.
  74571. */
  74572. get reject(): (reason?: any) => void;
  74573. /**
  74574. * Constructor for this deferred object.
  74575. */
  74576. constructor();
  74577. }
  74578. }
  74579. declare module BABYLON {
  74580. /**
  74581. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  74582. */
  74583. export class MeshExploder {
  74584. private _centerMesh;
  74585. private _meshes;
  74586. private _meshesOrigins;
  74587. private _toCenterVectors;
  74588. private _scaledDirection;
  74589. private _newPosition;
  74590. private _centerPosition;
  74591. /**
  74592. * Explodes meshes from a center mesh.
  74593. * @param meshes The meshes to explode.
  74594. * @param centerMesh The mesh to be center of explosion.
  74595. */
  74596. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  74597. private _setCenterMesh;
  74598. /**
  74599. * Get class name
  74600. * @returns "MeshExploder"
  74601. */
  74602. getClassName(): string;
  74603. /**
  74604. * "Exploded meshes"
  74605. * @returns Array of meshes with the centerMesh at index 0.
  74606. */
  74607. getMeshes(): Array<Mesh>;
  74608. /**
  74609. * Explodes meshes giving a specific direction
  74610. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  74611. */
  74612. explode(direction?: number): void;
  74613. }
  74614. }
  74615. declare module BABYLON {
  74616. /**
  74617. * Class used to help managing file picking and drag'n'drop
  74618. */
  74619. export class FilesInput {
  74620. /**
  74621. * List of files ready to be loaded
  74622. */
  74623. static get FilesToLoad(): {
  74624. [key: string]: File;
  74625. };
  74626. /**
  74627. * Callback called when a file is processed
  74628. */
  74629. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  74630. private _engine;
  74631. private _currentScene;
  74632. private _sceneLoadedCallback;
  74633. private _progressCallback;
  74634. private _additionalRenderLoopLogicCallback;
  74635. private _textureLoadingCallback;
  74636. private _startingProcessingFilesCallback;
  74637. private _onReloadCallback;
  74638. private _errorCallback;
  74639. private _elementToMonitor;
  74640. private _sceneFileToLoad;
  74641. private _filesToLoad;
  74642. /**
  74643. * Creates a new FilesInput
  74644. * @param engine defines the rendering engine
  74645. * @param scene defines the hosting scene
  74646. * @param sceneLoadedCallback callback called when scene is loaded
  74647. * @param progressCallback callback called to track progress
  74648. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  74649. * @param textureLoadingCallback callback called when a texture is loading
  74650. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  74651. * @param onReloadCallback callback called when a reload is requested
  74652. * @param errorCallback callback call if an error occurs
  74653. */
  74654. 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>);
  74655. private _dragEnterHandler;
  74656. private _dragOverHandler;
  74657. private _dropHandler;
  74658. /**
  74659. * Calls this function to listen to drag'n'drop events on a specific DOM element
  74660. * @param elementToMonitor defines the DOM element to track
  74661. */
  74662. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  74663. /** Gets the current list of files to load */
  74664. get filesToLoad(): File[];
  74665. /**
  74666. * Release all associated resources
  74667. */
  74668. dispose(): void;
  74669. private renderFunction;
  74670. private drag;
  74671. private drop;
  74672. private _traverseFolder;
  74673. private _processFiles;
  74674. /**
  74675. * Load files from a drop event
  74676. * @param event defines the drop event to use as source
  74677. */
  74678. loadFiles(event: any): void;
  74679. private _processReload;
  74680. /**
  74681. * Reload the current scene from the loaded files
  74682. */
  74683. reload(): void;
  74684. }
  74685. }
  74686. declare module BABYLON {
  74687. /**
  74688. * Defines the root class used to create scene optimization to use with SceneOptimizer
  74689. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74690. */
  74691. export class SceneOptimization {
  74692. /**
  74693. * Defines the priority of this optimization (0 by default which means first in the list)
  74694. */
  74695. priority: number;
  74696. /**
  74697. * Gets a string describing the action executed by the current optimization
  74698. * @returns description string
  74699. */
  74700. getDescription(): string;
  74701. /**
  74702. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74703. * @param scene defines the current scene where to apply this optimization
  74704. * @param optimizer defines the current optimizer
  74705. * @returns true if everything that can be done was applied
  74706. */
  74707. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74708. /**
  74709. * Creates the SceneOptimization object
  74710. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74711. * @param desc defines the description associated with the optimization
  74712. */
  74713. constructor(
  74714. /**
  74715. * Defines the priority of this optimization (0 by default which means first in the list)
  74716. */
  74717. priority?: number);
  74718. }
  74719. /**
  74720. * Defines an optimization used to reduce the size of render target textures
  74721. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74722. */
  74723. export class TextureOptimization extends SceneOptimization {
  74724. /**
  74725. * Defines the priority of this optimization (0 by default which means first in the list)
  74726. */
  74727. priority: number;
  74728. /**
  74729. * 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
  74730. */
  74731. maximumSize: number;
  74732. /**
  74733. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74734. */
  74735. step: number;
  74736. /**
  74737. * Gets a string describing the action executed by the current optimization
  74738. * @returns description string
  74739. */
  74740. getDescription(): string;
  74741. /**
  74742. * Creates the TextureOptimization object
  74743. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74744. * @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
  74745. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74746. */
  74747. constructor(
  74748. /**
  74749. * Defines the priority of this optimization (0 by default which means first in the list)
  74750. */
  74751. priority?: number,
  74752. /**
  74753. * 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
  74754. */
  74755. maximumSize?: number,
  74756. /**
  74757. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74758. */
  74759. step?: number);
  74760. /**
  74761. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74762. * @param scene defines the current scene where to apply this optimization
  74763. * @param optimizer defines the current optimizer
  74764. * @returns true if everything that can be done was applied
  74765. */
  74766. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74767. }
  74768. /**
  74769. * Defines an optimization used to increase or decrease the rendering resolution
  74770. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74771. */
  74772. export class HardwareScalingOptimization extends SceneOptimization {
  74773. /**
  74774. * Defines the priority of this optimization (0 by default which means first in the list)
  74775. */
  74776. priority: number;
  74777. /**
  74778. * Defines the maximum scale to use (2 by default)
  74779. */
  74780. maximumScale: number;
  74781. /**
  74782. * Defines the step to use between two passes (0.5 by default)
  74783. */
  74784. step: number;
  74785. private _currentScale;
  74786. private _directionOffset;
  74787. /**
  74788. * Gets a string describing the action executed by the current optimization
  74789. * @return description string
  74790. */
  74791. getDescription(): string;
  74792. /**
  74793. * Creates the HardwareScalingOptimization object
  74794. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74795. * @param maximumScale defines the maximum scale to use (2 by default)
  74796. * @param step defines the step to use between two passes (0.5 by default)
  74797. */
  74798. constructor(
  74799. /**
  74800. * Defines the priority of this optimization (0 by default which means first in the list)
  74801. */
  74802. priority?: number,
  74803. /**
  74804. * Defines the maximum scale to use (2 by default)
  74805. */
  74806. maximumScale?: number,
  74807. /**
  74808. * Defines the step to use between two passes (0.5 by default)
  74809. */
  74810. step?: number);
  74811. /**
  74812. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74813. * @param scene defines the current scene where to apply this optimization
  74814. * @param optimizer defines the current optimizer
  74815. * @returns true if everything that can be done was applied
  74816. */
  74817. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74818. }
  74819. /**
  74820. * Defines an optimization used to remove shadows
  74821. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74822. */
  74823. export class ShadowsOptimization extends SceneOptimization {
  74824. /**
  74825. * Gets a string describing the action executed by the current optimization
  74826. * @return description string
  74827. */
  74828. getDescription(): string;
  74829. /**
  74830. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74831. * @param scene defines the current scene where to apply this optimization
  74832. * @param optimizer defines the current optimizer
  74833. * @returns true if everything that can be done was applied
  74834. */
  74835. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74836. }
  74837. /**
  74838. * Defines an optimization used to turn post-processes off
  74839. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74840. */
  74841. export class PostProcessesOptimization extends SceneOptimization {
  74842. /**
  74843. * Gets a string describing the action executed by the current optimization
  74844. * @return description string
  74845. */
  74846. getDescription(): string;
  74847. /**
  74848. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74849. * @param scene defines the current scene where to apply this optimization
  74850. * @param optimizer defines the current optimizer
  74851. * @returns true if everything that can be done was applied
  74852. */
  74853. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74854. }
  74855. /**
  74856. * Defines an optimization used to turn lens flares off
  74857. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74858. */
  74859. export class LensFlaresOptimization extends SceneOptimization {
  74860. /**
  74861. * Gets a string describing the action executed by the current optimization
  74862. * @return description string
  74863. */
  74864. getDescription(): string;
  74865. /**
  74866. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74867. * @param scene defines the current scene where to apply this optimization
  74868. * @param optimizer defines the current optimizer
  74869. * @returns true if everything that can be done was applied
  74870. */
  74871. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74872. }
  74873. /**
  74874. * Defines an optimization based on user defined callback.
  74875. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74876. */
  74877. export class CustomOptimization extends SceneOptimization {
  74878. /**
  74879. * Callback called to apply the custom optimization.
  74880. */
  74881. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  74882. /**
  74883. * Callback called to get custom description
  74884. */
  74885. onGetDescription: () => string;
  74886. /**
  74887. * Gets a string describing the action executed by the current optimization
  74888. * @returns description string
  74889. */
  74890. getDescription(): string;
  74891. /**
  74892. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74893. * @param scene defines the current scene where to apply this optimization
  74894. * @param optimizer defines the current optimizer
  74895. * @returns true if everything that can be done was applied
  74896. */
  74897. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74898. }
  74899. /**
  74900. * Defines an optimization used to turn particles off
  74901. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74902. */
  74903. export class ParticlesOptimization extends SceneOptimization {
  74904. /**
  74905. * Gets a string describing the action executed by the current optimization
  74906. * @return description string
  74907. */
  74908. getDescription(): string;
  74909. /**
  74910. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74911. * @param scene defines the current scene where to apply this optimization
  74912. * @param optimizer defines the current optimizer
  74913. * @returns true if everything that can be done was applied
  74914. */
  74915. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74916. }
  74917. /**
  74918. * Defines an optimization used to turn render targets off
  74919. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74920. */
  74921. export class RenderTargetsOptimization extends SceneOptimization {
  74922. /**
  74923. * Gets a string describing the action executed by the current optimization
  74924. * @return description string
  74925. */
  74926. getDescription(): string;
  74927. /**
  74928. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74929. * @param scene defines the current scene where to apply this optimization
  74930. * @param optimizer defines the current optimizer
  74931. * @returns true if everything that can be done was applied
  74932. */
  74933. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74934. }
  74935. /**
  74936. * Defines an optimization used to merge meshes with compatible materials
  74937. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74938. */
  74939. export class MergeMeshesOptimization extends SceneOptimization {
  74940. private static _UpdateSelectionTree;
  74941. /**
  74942. * Gets or sets a boolean which defines if optimization octree has to be updated
  74943. */
  74944. static get UpdateSelectionTree(): boolean;
  74945. /**
  74946. * Gets or sets a boolean which defines if optimization octree has to be updated
  74947. */
  74948. static set UpdateSelectionTree(value: boolean);
  74949. /**
  74950. * Gets a string describing the action executed by the current optimization
  74951. * @return description string
  74952. */
  74953. getDescription(): string;
  74954. private _canBeMerged;
  74955. /**
  74956. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74957. * @param scene defines the current scene where to apply this optimization
  74958. * @param optimizer defines the current optimizer
  74959. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  74960. * @returns true if everything that can be done was applied
  74961. */
  74962. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  74963. }
  74964. /**
  74965. * Defines a list of options used by SceneOptimizer
  74966. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74967. */
  74968. export class SceneOptimizerOptions {
  74969. /**
  74970. * Defines the target frame rate to reach (60 by default)
  74971. */
  74972. targetFrameRate: number;
  74973. /**
  74974. * Defines the interval between two checkes (2000ms by default)
  74975. */
  74976. trackerDuration: number;
  74977. /**
  74978. * Gets the list of optimizations to apply
  74979. */
  74980. optimizations: SceneOptimization[];
  74981. /**
  74982. * Creates a new list of options used by SceneOptimizer
  74983. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  74984. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  74985. */
  74986. constructor(
  74987. /**
  74988. * Defines the target frame rate to reach (60 by default)
  74989. */
  74990. targetFrameRate?: number,
  74991. /**
  74992. * Defines the interval between two checkes (2000ms by default)
  74993. */
  74994. trackerDuration?: number);
  74995. /**
  74996. * Add a new optimization
  74997. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  74998. * @returns the current SceneOptimizerOptions
  74999. */
  75000. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  75001. /**
  75002. * Add a new custom optimization
  75003. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  75004. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  75005. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75006. * @returns the current SceneOptimizerOptions
  75007. */
  75008. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  75009. /**
  75010. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  75011. * @param targetFrameRate defines the target frame rate (60 by default)
  75012. * @returns a SceneOptimizerOptions object
  75013. */
  75014. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75015. /**
  75016. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  75017. * @param targetFrameRate defines the target frame rate (60 by default)
  75018. * @returns a SceneOptimizerOptions object
  75019. */
  75020. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75021. /**
  75022. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  75023. * @param targetFrameRate defines the target frame rate (60 by default)
  75024. * @returns a SceneOptimizerOptions object
  75025. */
  75026. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75027. }
  75028. /**
  75029. * Class used to run optimizations in order to reach a target frame rate
  75030. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75031. */
  75032. export class SceneOptimizer implements IDisposable {
  75033. private _isRunning;
  75034. private _options;
  75035. private _scene;
  75036. private _currentPriorityLevel;
  75037. private _targetFrameRate;
  75038. private _trackerDuration;
  75039. private _currentFrameRate;
  75040. private _sceneDisposeObserver;
  75041. private _improvementMode;
  75042. /**
  75043. * Defines an observable called when the optimizer reaches the target frame rate
  75044. */
  75045. onSuccessObservable: Observable<SceneOptimizer>;
  75046. /**
  75047. * Defines an observable called when the optimizer enables an optimization
  75048. */
  75049. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  75050. /**
  75051. * Defines an observable called when the optimizer is not able to reach the target frame rate
  75052. */
  75053. onFailureObservable: Observable<SceneOptimizer>;
  75054. /**
  75055. * Gets a boolean indicating if the optimizer is in improvement mode
  75056. */
  75057. get isInImprovementMode(): boolean;
  75058. /**
  75059. * Gets the current priority level (0 at start)
  75060. */
  75061. get currentPriorityLevel(): number;
  75062. /**
  75063. * Gets the current frame rate checked by the SceneOptimizer
  75064. */
  75065. get currentFrameRate(): number;
  75066. /**
  75067. * Gets or sets the current target frame rate (60 by default)
  75068. */
  75069. get targetFrameRate(): number;
  75070. /**
  75071. * Gets or sets the current target frame rate (60 by default)
  75072. */
  75073. set targetFrameRate(value: number);
  75074. /**
  75075. * Gets or sets the current interval between two checks (every 2000ms by default)
  75076. */
  75077. get trackerDuration(): number;
  75078. /**
  75079. * Gets or sets the current interval between two checks (every 2000ms by default)
  75080. */
  75081. set trackerDuration(value: number);
  75082. /**
  75083. * Gets the list of active optimizations
  75084. */
  75085. get optimizations(): SceneOptimization[];
  75086. /**
  75087. * Creates a new SceneOptimizer
  75088. * @param scene defines the scene to work on
  75089. * @param options defines the options to use with the SceneOptimizer
  75090. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  75091. * @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)
  75092. */
  75093. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  75094. /**
  75095. * Stops the current optimizer
  75096. */
  75097. stop(): void;
  75098. /**
  75099. * Reset the optimizer to initial step (current priority level = 0)
  75100. */
  75101. reset(): void;
  75102. /**
  75103. * Start the optimizer. By default it will try to reach a specific framerate
  75104. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  75105. */
  75106. start(): void;
  75107. private _checkCurrentState;
  75108. /**
  75109. * Release all resources
  75110. */
  75111. dispose(): void;
  75112. /**
  75113. * Helper function to create a SceneOptimizer with one single line of code
  75114. * @param scene defines the scene to work on
  75115. * @param options defines the options to use with the SceneOptimizer
  75116. * @param onSuccess defines a callback to call on success
  75117. * @param onFailure defines a callback to call on failure
  75118. * @returns the new SceneOptimizer object
  75119. */
  75120. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  75121. }
  75122. }
  75123. declare module BABYLON {
  75124. /**
  75125. * Class used to serialize a scene into a string
  75126. */
  75127. export class SceneSerializer {
  75128. /**
  75129. * Clear cache used by a previous serialization
  75130. */
  75131. static ClearCache(): void;
  75132. /**
  75133. * Serialize a scene into a JSON compatible object
  75134. * @param scene defines the scene to serialize
  75135. * @returns a JSON compatible object
  75136. */
  75137. static Serialize(scene: Scene): any;
  75138. /**
  75139. * Serialize a mesh into a JSON compatible object
  75140. * @param toSerialize defines the mesh to serialize
  75141. * @param withParents defines if parents must be serialized as well
  75142. * @param withChildren defines if children must be serialized as well
  75143. * @returns a JSON compatible object
  75144. */
  75145. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  75146. }
  75147. }
  75148. declare module BABYLON {
  75149. /**
  75150. * Class used to host texture specific utilities
  75151. */
  75152. export class TextureTools {
  75153. /**
  75154. * Uses the GPU to create a copy texture rescaled at a given size
  75155. * @param texture Texture to copy from
  75156. * @param width defines the desired width
  75157. * @param height defines the desired height
  75158. * @param useBilinearMode defines if bilinear mode has to be used
  75159. * @return the generated texture
  75160. */
  75161. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  75162. }
  75163. }
  75164. declare module BABYLON {
  75165. /**
  75166. * This represents the different options available for the video capture.
  75167. */
  75168. export interface VideoRecorderOptions {
  75169. /** Defines the mime type of the video. */
  75170. mimeType: string;
  75171. /** Defines the FPS the video should be recorded at. */
  75172. fps: number;
  75173. /** Defines the chunk size for the recording data. */
  75174. recordChunckSize: number;
  75175. /** The audio tracks to attach to the recording. */
  75176. audioTracks?: MediaStreamTrack[];
  75177. }
  75178. /**
  75179. * This can help with recording videos from BabylonJS.
  75180. * This is based on the available WebRTC functionalities of the browser.
  75181. *
  75182. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  75183. */
  75184. export class VideoRecorder {
  75185. private static readonly _defaultOptions;
  75186. /**
  75187. * Returns whether or not the VideoRecorder is available in your browser.
  75188. * @param engine Defines the Babylon Engine.
  75189. * @returns true if supported otherwise false.
  75190. */
  75191. static IsSupported(engine: Engine): boolean;
  75192. private readonly _options;
  75193. private _canvas;
  75194. private _mediaRecorder;
  75195. private _recordedChunks;
  75196. private _fileName;
  75197. private _resolve;
  75198. private _reject;
  75199. /**
  75200. * True when a recording is already in progress.
  75201. */
  75202. get isRecording(): boolean;
  75203. /**
  75204. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  75205. * @param engine Defines the BabylonJS Engine you wish to record.
  75206. * @param options Defines options that can be used to customize the capture.
  75207. */
  75208. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  75209. /**
  75210. * Stops the current recording before the default capture timeout passed in the startRecording function.
  75211. */
  75212. stopRecording(): void;
  75213. /**
  75214. * Starts recording the canvas for a max duration specified in parameters.
  75215. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  75216. * If null no automatic download will start and you can rely on the promise to get the data back.
  75217. * @param maxDuration Defines the maximum recording time in seconds.
  75218. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  75219. * @return A promise callback at the end of the recording with the video data in Blob.
  75220. */
  75221. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  75222. /**
  75223. * Releases internal resources used during the recording.
  75224. */
  75225. dispose(): void;
  75226. private _handleDataAvailable;
  75227. private _handleError;
  75228. private _handleStop;
  75229. }
  75230. }
  75231. declare module BABYLON {
  75232. /**
  75233. * Class containing a set of static utilities functions for screenshots
  75234. */
  75235. export class ScreenshotTools {
  75236. /**
  75237. * Captures a screenshot of the current rendering
  75238. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75239. * @param engine defines the rendering engine
  75240. * @param camera defines the source camera
  75241. * @param size This parameter can be set to a single number or to an object with the
  75242. * following (optional) properties: precision, width, height. If a single number is passed,
  75243. * it will be used for both width and height. If an object is passed, the screenshot size
  75244. * will be derived from the parameters. The precision property is a multiplier allowing
  75245. * rendering at a higher or lower resolution
  75246. * @param successCallback defines the callback receives a single parameter which contains the
  75247. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  75248. * src parameter of an <img> to display it
  75249. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  75250. * Check your browser for supported MIME types
  75251. */
  75252. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  75253. /**
  75254. * Captures a screenshot of the current rendering
  75255. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75256. * @param engine defines the rendering engine
  75257. * @param camera defines the source camera
  75258. * @param size This parameter can be set to a single number or to an object with the
  75259. * following (optional) properties: precision, width, height. If a single number is passed,
  75260. * it will be used for both width and height. If an object is passed, the screenshot size
  75261. * will be derived from the parameters. The precision property is a multiplier allowing
  75262. * rendering at a higher or lower resolution
  75263. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  75264. * Check your browser for supported MIME types
  75265. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  75266. * to the src parameter of an <img> to display it
  75267. */
  75268. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  75269. /**
  75270. * Generates an image screenshot from the specified camera.
  75271. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75272. * @param engine The engine to use for rendering
  75273. * @param camera The camera to use for rendering
  75274. * @param size This parameter can be set to a single number or to an object with the
  75275. * following (optional) properties: precision, width, height. If a single number is passed,
  75276. * it will be used for both width and height. If an object is passed, the screenshot size
  75277. * will be derived from the parameters. The precision property is a multiplier allowing
  75278. * rendering at a higher or lower resolution
  75279. * @param successCallback The callback receives a single parameter which contains the
  75280. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  75281. * src parameter of an <img> to display it
  75282. * @param mimeType The MIME type of the screenshot image (default: image/png).
  75283. * Check your browser for supported MIME types
  75284. * @param samples Texture samples (default: 1)
  75285. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  75286. * @param fileName A name for for the downloaded file.
  75287. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  75288. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  75289. */
  75290. 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;
  75291. /**
  75292. * Generates an image screenshot from the specified camera.
  75293. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75294. * @param engine The engine to use for rendering
  75295. * @param camera The camera to use for rendering
  75296. * @param size This parameter can be set to a single number or to an object with the
  75297. * following (optional) properties: precision, width, height. If a single number is passed,
  75298. * it will be used for both width and height. If an object is passed, the screenshot size
  75299. * will be derived from the parameters. The precision property is a multiplier allowing
  75300. * rendering at a higher or lower resolution
  75301. * @param mimeType The MIME type of the screenshot image (default: image/png).
  75302. * Check your browser for supported MIME types
  75303. * @param samples Texture samples (default: 1)
  75304. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  75305. * @param fileName A name for for the downloaded file.
  75306. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  75307. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  75308. * to the src parameter of an <img> to display it
  75309. */
  75310. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  75311. /**
  75312. * Gets height and width for screenshot size
  75313. * @private
  75314. */
  75315. private static _getScreenshotSize;
  75316. }
  75317. }
  75318. declare module BABYLON {
  75319. /**
  75320. * Interface for a data buffer
  75321. */
  75322. export interface IDataBuffer {
  75323. /**
  75324. * Reads bytes from the data buffer.
  75325. * @param byteOffset The byte offset to read
  75326. * @param byteLength The byte length to read
  75327. * @returns A promise that resolves when the bytes are read
  75328. */
  75329. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  75330. /**
  75331. * The byte length of the buffer.
  75332. */
  75333. readonly byteLength: number;
  75334. }
  75335. /**
  75336. * Utility class for reading from a data buffer
  75337. */
  75338. export class DataReader {
  75339. /**
  75340. * The data buffer associated with this data reader.
  75341. */
  75342. readonly buffer: IDataBuffer;
  75343. /**
  75344. * The current byte offset from the beginning of the data buffer.
  75345. */
  75346. byteOffset: number;
  75347. private _dataView;
  75348. private _dataByteOffset;
  75349. /**
  75350. * Constructor
  75351. * @param buffer The buffer to read
  75352. */
  75353. constructor(buffer: IDataBuffer);
  75354. /**
  75355. * Loads the given byte length.
  75356. * @param byteLength The byte length to load
  75357. * @returns A promise that resolves when the load is complete
  75358. */
  75359. loadAsync(byteLength: number): Promise<void>;
  75360. /**
  75361. * Read a unsigned 32-bit integer from the currently loaded data range.
  75362. * @returns The 32-bit integer read
  75363. */
  75364. readUint32(): number;
  75365. /**
  75366. * Read a byte array from the currently loaded data range.
  75367. * @param byteLength The byte length to read
  75368. * @returns The byte array read
  75369. */
  75370. readUint8Array(byteLength: number): Uint8Array;
  75371. /**
  75372. * Read a string from the currently loaded data range.
  75373. * @param byteLength The byte length to read
  75374. * @returns The string read
  75375. */
  75376. readString(byteLength: number): string;
  75377. /**
  75378. * Skips the given byte length the currently loaded data range.
  75379. * @param byteLength The byte length to skip
  75380. */
  75381. skipBytes(byteLength: number): void;
  75382. }
  75383. }
  75384. declare module BABYLON {
  75385. /**
  75386. * Class for storing data to local storage if available or in-memory storage otherwise
  75387. */
  75388. export class DataStorage {
  75389. private static _Storage;
  75390. private static _GetStorage;
  75391. /**
  75392. * Reads a string from the data storage
  75393. * @param key The key to read
  75394. * @param defaultValue The value if the key doesn't exist
  75395. * @returns The string value
  75396. */
  75397. static ReadString(key: string, defaultValue: string): string;
  75398. /**
  75399. * Writes a string to the data storage
  75400. * @param key The key to write
  75401. * @param value The value to write
  75402. */
  75403. static WriteString(key: string, value: string): void;
  75404. /**
  75405. * Reads a boolean from the data storage
  75406. * @param key The key to read
  75407. * @param defaultValue The value if the key doesn't exist
  75408. * @returns The boolean value
  75409. */
  75410. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  75411. /**
  75412. * Writes a boolean to the data storage
  75413. * @param key The key to write
  75414. * @param value The value to write
  75415. */
  75416. static WriteBoolean(key: string, value: boolean): void;
  75417. /**
  75418. * Reads a number from the data storage
  75419. * @param key The key to read
  75420. * @param defaultValue The value if the key doesn't exist
  75421. * @returns The number value
  75422. */
  75423. static ReadNumber(key: string, defaultValue: number): number;
  75424. /**
  75425. * Writes a number to the data storage
  75426. * @param key The key to write
  75427. * @param value The value to write
  75428. */
  75429. static WriteNumber(key: string, value: number): void;
  75430. }
  75431. }
  75432. declare module BABYLON {
  75433. /**
  75434. * Class used to record delta files between 2 scene states
  75435. */
  75436. export class SceneRecorder {
  75437. private _trackedScene;
  75438. private _savedJSON;
  75439. /**
  75440. * Track a given scene. This means the current scene state will be considered the original state
  75441. * @param scene defines the scene to track
  75442. */
  75443. track(scene: Scene): void;
  75444. /**
  75445. * Get the delta between current state and original state
  75446. * @returns a string containing the delta
  75447. */
  75448. getDelta(): any;
  75449. private _compareArray;
  75450. private _compareObjects;
  75451. private _compareCollections;
  75452. private static GetShadowGeneratorById;
  75453. /**
  75454. * Apply a given delta to a given scene
  75455. * @param deltaJSON defines the JSON containing the delta
  75456. * @param scene defines the scene to apply the delta to
  75457. */
  75458. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  75459. private static _ApplyPropertiesToEntity;
  75460. private static _ApplyDeltaForEntity;
  75461. }
  75462. }
  75463. declare module BABYLON {
  75464. /**
  75465. * A 3D trajectory consisting of an order list of vectors describing a
  75466. * path of motion through 3D space.
  75467. */
  75468. export class Trajectory {
  75469. private _points;
  75470. private readonly _segmentLength;
  75471. /**
  75472. * Serialize to JSON.
  75473. * @returns serialized JSON string
  75474. */
  75475. serialize(): string;
  75476. /**
  75477. * Deserialize from JSON.
  75478. * @param json serialized JSON string
  75479. * @returns deserialized Trajectory
  75480. */
  75481. static Deserialize(json: string): Trajectory;
  75482. /**
  75483. * Create a new empty Trajectory.
  75484. * @param segmentLength radius of discretization for Trajectory points
  75485. */
  75486. constructor(segmentLength?: number);
  75487. /**
  75488. * Get the length of the Trajectory.
  75489. * @returns length of the Trajectory
  75490. */
  75491. getLength(): number;
  75492. /**
  75493. * Append a new point to the Trajectory.
  75494. * NOTE: This implementation has many allocations.
  75495. * @param point point to append to the Trajectory
  75496. */
  75497. add(point: DeepImmutable<Vector3>): void;
  75498. /**
  75499. * Create a new Trajectory with a segment length chosen to make it
  75500. * probable that the new Trajectory will have a specified number of
  75501. * segments. This operation is imprecise.
  75502. * @param targetResolution number of segments desired
  75503. * @returns new Trajectory with approximately the requested number of segments
  75504. */
  75505. resampleAtTargetResolution(targetResolution: number): Trajectory;
  75506. /**
  75507. * Convert Trajectory segments into tokenized representation. This
  75508. * representation is an array of numbers where each nth number is the
  75509. * index of the token which is most similar to the nth segment of the
  75510. * Trajectory.
  75511. * @param tokens list of vectors which serve as discrete tokens
  75512. * @returns list of indices of most similar token per segment
  75513. */
  75514. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  75515. private static _forwardDir;
  75516. private static _inverseFromVec;
  75517. private static _upDir;
  75518. private static _fromToVec;
  75519. private static _lookMatrix;
  75520. /**
  75521. * Transform the rotation (i.e., direction) of a segment to isolate
  75522. * the relative transformation represented by the segment. This operation
  75523. * may or may not succeed due to singularities in the equations that define
  75524. * motion relativity in this context.
  75525. * @param priorVec the origin of the prior segment
  75526. * @param fromVec the origin of the current segment
  75527. * @param toVec the destination of the current segment
  75528. * @param result reference to output variable
  75529. * @returns whether or not transformation was successful
  75530. */
  75531. private static _transformSegmentDirToRef;
  75532. private static _bestMatch;
  75533. private static _score;
  75534. private static _bestScore;
  75535. /**
  75536. * Determine which token vector is most similar to the
  75537. * segment vector.
  75538. * @param segment segment vector
  75539. * @param tokens token vector list
  75540. * @returns index of the most similar token to the segment
  75541. */
  75542. private static _tokenizeSegment;
  75543. }
  75544. /**
  75545. * Class representing a set of known, named trajectories to which Trajectories can be
  75546. * added and using which Trajectories can be recognized.
  75547. */
  75548. export class TrajectoryClassifier {
  75549. private _maximumAllowableMatchCost;
  75550. private _vector3Alphabet;
  75551. private _levenshteinAlphabet;
  75552. private _nameToDescribedTrajectory;
  75553. /**
  75554. * Serialize to JSON.
  75555. * @returns JSON serialization
  75556. */
  75557. serialize(): string;
  75558. /**
  75559. * Deserialize from JSON.
  75560. * @param json JSON serialization
  75561. * @returns deserialized TrajectorySet
  75562. */
  75563. static Deserialize(json: string): TrajectoryClassifier;
  75564. /**
  75565. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  75566. * VERY naive, need to be generating these things from known
  75567. * sets. Better version later, probably eliminating this one.
  75568. * @returns auto-generated TrajectorySet
  75569. */
  75570. static Generate(): TrajectoryClassifier;
  75571. private constructor();
  75572. /**
  75573. * Add a new Trajectory to the set with a given name.
  75574. * @param trajectory new Trajectory to be added
  75575. * @param classification name to which to add the Trajectory
  75576. */
  75577. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  75578. /**
  75579. * Remove a known named trajectory and all Trajectories associated with it.
  75580. * @param classification name to remove
  75581. * @returns whether anything was removed
  75582. */
  75583. deleteClassification(classification: string): boolean;
  75584. /**
  75585. * Attempt to recognize a Trajectory from among all the classifications
  75586. * already known to the classifier.
  75587. * @param trajectory Trajectory to be recognized
  75588. * @returns classification of Trajectory if recognized, null otherwise
  75589. */
  75590. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  75591. }
  75592. }
  75593. declare module BABYLON {
  75594. /**
  75595. * An interface for all Hit test features
  75596. */
  75597. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  75598. /**
  75599. * Triggered when new babylon (transformed) hit test results are available
  75600. */
  75601. onHitTestResultObservable: Observable<T[]>;
  75602. }
  75603. /**
  75604. * Options used for hit testing
  75605. */
  75606. export interface IWebXRLegacyHitTestOptions {
  75607. /**
  75608. * Only test when user interacted with the scene. Default - hit test every frame
  75609. */
  75610. testOnPointerDownOnly?: boolean;
  75611. /**
  75612. * The node to use to transform the local results to world coordinates
  75613. */
  75614. worldParentNode?: TransformNode;
  75615. }
  75616. /**
  75617. * Interface defining the babylon result of raycasting/hit-test
  75618. */
  75619. export interface IWebXRLegacyHitResult {
  75620. /**
  75621. * Transformation matrix that can be applied to a node that will put it in the hit point location
  75622. */
  75623. transformationMatrix: Matrix;
  75624. /**
  75625. * The native hit test result
  75626. */
  75627. xrHitResult: XRHitResult | XRHitTestResult;
  75628. }
  75629. /**
  75630. * The currently-working hit-test module.
  75631. * Hit test (or Ray-casting) is used to interact with the real world.
  75632. * For further information read here - https://github.com/immersive-web/hit-test
  75633. */
  75634. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  75635. /**
  75636. * options to use when constructing this feature
  75637. */
  75638. readonly options: IWebXRLegacyHitTestOptions;
  75639. private _direction;
  75640. private _mat;
  75641. private _onSelectEnabled;
  75642. private _origin;
  75643. /**
  75644. * The module's name
  75645. */
  75646. static readonly Name: string;
  75647. /**
  75648. * The (Babylon) version of this module.
  75649. * This is an integer representing the implementation version.
  75650. * This number does not correspond to the WebXR specs version
  75651. */
  75652. static readonly Version: number;
  75653. /**
  75654. * Populated with the last native XR Hit Results
  75655. */
  75656. lastNativeXRHitResults: XRHitResult[];
  75657. /**
  75658. * Triggered when new babylon (transformed) hit test results are available
  75659. */
  75660. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  75661. /**
  75662. * Creates a new instance of the (legacy version) hit test feature
  75663. * @param _xrSessionManager an instance of WebXRSessionManager
  75664. * @param options options to use when constructing this feature
  75665. */
  75666. constructor(_xrSessionManager: WebXRSessionManager,
  75667. /**
  75668. * options to use when constructing this feature
  75669. */
  75670. options?: IWebXRLegacyHitTestOptions);
  75671. /**
  75672. * execute a hit test with an XR Ray
  75673. *
  75674. * @param xrSession a native xrSession that will execute this hit test
  75675. * @param xrRay the ray (position and direction) to use for ray-casting
  75676. * @param referenceSpace native XR reference space to use for the hit-test
  75677. * @param filter filter function that will filter the results
  75678. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  75679. */
  75680. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  75681. /**
  75682. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  75683. * @param event the (select) event to use to select with
  75684. * @param referenceSpace the reference space to use for this hit test
  75685. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  75686. */
  75687. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  75688. /**
  75689. * attach this feature
  75690. * Will usually be called by the features manager
  75691. *
  75692. * @returns true if successful.
  75693. */
  75694. attach(): boolean;
  75695. /**
  75696. * detach this feature.
  75697. * Will usually be called by the features manager
  75698. *
  75699. * @returns true if successful.
  75700. */
  75701. detach(): boolean;
  75702. /**
  75703. * Dispose this feature and all of the resources attached
  75704. */
  75705. dispose(): void;
  75706. protected _onXRFrame(frame: XRFrame): void;
  75707. private _onHitTestResults;
  75708. private _onSelect;
  75709. }
  75710. }
  75711. declare module BABYLON {
  75712. /**
  75713. * Options used for hit testing (version 2)
  75714. */
  75715. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  75716. /**
  75717. * Do not create a permanent hit test. Will usually be used when only
  75718. * transient inputs are needed.
  75719. */
  75720. disablePermanentHitTest?: boolean;
  75721. /**
  75722. * Enable transient (for example touch-based) hit test inspections
  75723. */
  75724. enableTransientHitTest?: boolean;
  75725. /**
  75726. * Offset ray for the permanent hit test
  75727. */
  75728. offsetRay?: Vector3;
  75729. /**
  75730. * Offset ray for the transient hit test
  75731. */
  75732. transientOffsetRay?: Vector3;
  75733. /**
  75734. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  75735. */
  75736. useReferenceSpace?: boolean;
  75737. /**
  75738. * Override the default entity type(s) of the hit-test result
  75739. */
  75740. entityTypes?: XRHitTestTrackableType[];
  75741. }
  75742. /**
  75743. * Interface defining the babylon result of hit-test
  75744. */
  75745. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  75746. /**
  75747. * The input source that generated this hit test (if transient)
  75748. */
  75749. inputSource?: XRInputSource;
  75750. /**
  75751. * Is this a transient hit test
  75752. */
  75753. isTransient?: boolean;
  75754. /**
  75755. * Position of the hit test result
  75756. */
  75757. position: Vector3;
  75758. /**
  75759. * Rotation of the hit test result
  75760. */
  75761. rotationQuaternion: Quaternion;
  75762. /**
  75763. * The native hit test result
  75764. */
  75765. xrHitResult: XRHitTestResult;
  75766. }
  75767. /**
  75768. * The currently-working hit-test module.
  75769. * Hit test (or Ray-casting) is used to interact with the real world.
  75770. * For further information read here - https://github.com/immersive-web/hit-test
  75771. *
  75772. * Tested on chrome (mobile) 80.
  75773. */
  75774. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  75775. /**
  75776. * options to use when constructing this feature
  75777. */
  75778. readonly options: IWebXRHitTestOptions;
  75779. private _tmpMat;
  75780. private _tmpPos;
  75781. private _tmpQuat;
  75782. private _transientXrHitTestSource;
  75783. private _xrHitTestSource;
  75784. private initHitTestSource;
  75785. /**
  75786. * The module's name
  75787. */
  75788. static readonly Name: string;
  75789. /**
  75790. * The (Babylon) version of this module.
  75791. * This is an integer representing the implementation version.
  75792. * This number does not correspond to the WebXR specs version
  75793. */
  75794. static readonly Version: number;
  75795. /**
  75796. * When set to true, each hit test will have its own position/rotation objects
  75797. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  75798. * the developers will clone them or copy them as they see fit.
  75799. */
  75800. autoCloneTransformation: boolean;
  75801. /**
  75802. * Triggered when new babylon (transformed) hit test results are available
  75803. * Note - this will be called when results come back from the device. It can be an empty array!!
  75804. */
  75805. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  75806. /**
  75807. * Use this to temporarily pause hit test checks.
  75808. */
  75809. paused: boolean;
  75810. /**
  75811. * Creates a new instance of the hit test feature
  75812. * @param _xrSessionManager an instance of WebXRSessionManager
  75813. * @param options options to use when constructing this feature
  75814. */
  75815. constructor(_xrSessionManager: WebXRSessionManager,
  75816. /**
  75817. * options to use when constructing this feature
  75818. */
  75819. options?: IWebXRHitTestOptions);
  75820. /**
  75821. * attach this feature
  75822. * Will usually be called by the features manager
  75823. *
  75824. * @returns true if successful.
  75825. */
  75826. attach(): boolean;
  75827. /**
  75828. * detach this feature.
  75829. * Will usually be called by the features manager
  75830. *
  75831. * @returns true if successful.
  75832. */
  75833. detach(): boolean;
  75834. /**
  75835. * Dispose this feature and all of the resources attached
  75836. */
  75837. dispose(): void;
  75838. protected _onXRFrame(frame: XRFrame): void;
  75839. private _processWebXRHitTestResult;
  75840. }
  75841. }
  75842. declare module BABYLON {
  75843. /**
  75844. * Configuration options of the anchor system
  75845. */
  75846. export interface IWebXRAnchorSystemOptions {
  75847. /**
  75848. * a node that will be used to convert local to world coordinates
  75849. */
  75850. worldParentNode?: TransformNode;
  75851. /**
  75852. * If set to true a reference of the created anchors will be kept until the next session starts
  75853. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  75854. */
  75855. doNotRemoveAnchorsOnSessionEnded?: boolean;
  75856. }
  75857. /**
  75858. * A babylon container for an XR Anchor
  75859. */
  75860. export interface IWebXRAnchor {
  75861. /**
  75862. * A babylon-assigned ID for this anchor
  75863. */
  75864. id: number;
  75865. /**
  75866. * Transformation matrix to apply to an object attached to this anchor
  75867. */
  75868. transformationMatrix: Matrix;
  75869. /**
  75870. * The native anchor object
  75871. */
  75872. xrAnchor: XRAnchor;
  75873. /**
  75874. * if defined, this object will be constantly updated by the anchor's position and rotation
  75875. */
  75876. attachedNode?: TransformNode;
  75877. }
  75878. /**
  75879. * An implementation of the anchor system for WebXR.
  75880. * For further information see https://github.com/immersive-web/anchors/
  75881. */
  75882. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  75883. private _options;
  75884. private _lastFrameDetected;
  75885. private _trackedAnchors;
  75886. private _referenceSpaceForFrameAnchors;
  75887. private _futureAnchors;
  75888. /**
  75889. * The module's name
  75890. */
  75891. static readonly Name: string;
  75892. /**
  75893. * The (Babylon) version of this module.
  75894. * This is an integer representing the implementation version.
  75895. * This number does not correspond to the WebXR specs version
  75896. */
  75897. static readonly Version: number;
  75898. /**
  75899. * Observers registered here will be executed when a new anchor was added to the session
  75900. */
  75901. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  75902. /**
  75903. * Observers registered here will be executed when an anchor was removed from the session
  75904. */
  75905. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  75906. /**
  75907. * Observers registered here will be executed when an existing anchor updates
  75908. * This can execute N times every frame
  75909. */
  75910. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  75911. /**
  75912. * Set the reference space to use for anchor creation, when not using a hit test.
  75913. * Will default to the session's reference space if not defined
  75914. */
  75915. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  75916. /**
  75917. * constructs a new anchor system
  75918. * @param _xrSessionManager an instance of WebXRSessionManager
  75919. * @param _options configuration object for this feature
  75920. */
  75921. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  75922. private _tmpVector;
  75923. private _tmpQuaternion;
  75924. private _populateTmpTransformation;
  75925. /**
  75926. * Create a new anchor point using a hit test result at a specific point in the scene
  75927. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  75928. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  75929. *
  75930. * @param hitTestResult The hit test result to use for this anchor creation
  75931. * @param position an optional position offset for this anchor
  75932. * @param rotationQuaternion an optional rotation offset for this anchor
  75933. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  75934. */
  75935. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  75936. /**
  75937. * Add a new anchor at a specific position and rotation
  75938. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  75939. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  75940. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  75941. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  75942. *
  75943. * @param position the position in which to add an anchor
  75944. * @param rotationQuaternion an optional rotation for the anchor transformation
  75945. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  75946. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  75947. */
  75948. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  75949. /**
  75950. * detach this feature.
  75951. * Will usually be called by the features manager
  75952. *
  75953. * @returns true if successful.
  75954. */
  75955. detach(): boolean;
  75956. /**
  75957. * Dispose this feature and all of the resources attached
  75958. */
  75959. dispose(): void;
  75960. protected _onXRFrame(frame: XRFrame): void;
  75961. /**
  75962. * avoiding using Array.find for global support.
  75963. * @param xrAnchor the plane to find in the array
  75964. */
  75965. private _findIndexInAnchorArray;
  75966. private _updateAnchorWithXRFrame;
  75967. private _createAnchorAtTransformation;
  75968. }
  75969. }
  75970. declare module BABYLON {
  75971. /**
  75972. * Options used in the plane detector module
  75973. */
  75974. export interface IWebXRPlaneDetectorOptions {
  75975. /**
  75976. * The node to use to transform the local results to world coordinates
  75977. */
  75978. worldParentNode?: TransformNode;
  75979. /**
  75980. * If set to true a reference of the created planes will be kept until the next session starts
  75981. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  75982. */
  75983. doNotRemovePlanesOnSessionEnded?: boolean;
  75984. }
  75985. /**
  75986. * A babylon interface for a WebXR plane.
  75987. * A Plane is actually a polygon, built from N points in space
  75988. *
  75989. * Supported in chrome 79, not supported in canary 81 ATM
  75990. */
  75991. export interface IWebXRPlane {
  75992. /**
  75993. * a babylon-assigned ID for this polygon
  75994. */
  75995. id: number;
  75996. /**
  75997. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  75998. */
  75999. polygonDefinition: Array<Vector3>;
  76000. /**
  76001. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  76002. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  76003. */
  76004. transformationMatrix: Matrix;
  76005. /**
  76006. * the native xr-plane object
  76007. */
  76008. xrPlane: XRPlane;
  76009. }
  76010. /**
  76011. * The plane detector is used to detect planes in the real world when in AR
  76012. * For more information see https://github.com/immersive-web/real-world-geometry/
  76013. */
  76014. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  76015. private _options;
  76016. private _detectedPlanes;
  76017. private _enabled;
  76018. private _lastFrameDetected;
  76019. /**
  76020. * The module's name
  76021. */
  76022. static readonly Name: string;
  76023. /**
  76024. * The (Babylon) version of this module.
  76025. * This is an integer representing the implementation version.
  76026. * This number does not correspond to the WebXR specs version
  76027. */
  76028. static readonly Version: number;
  76029. /**
  76030. * Observers registered here will be executed when a new plane was added to the session
  76031. */
  76032. onPlaneAddedObservable: Observable<IWebXRPlane>;
  76033. /**
  76034. * Observers registered here will be executed when a plane is no longer detected in the session
  76035. */
  76036. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  76037. /**
  76038. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  76039. * This can execute N times every frame
  76040. */
  76041. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  76042. /**
  76043. * construct a new Plane Detector
  76044. * @param _xrSessionManager an instance of xr Session manager
  76045. * @param _options configuration to use when constructing this feature
  76046. */
  76047. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  76048. /**
  76049. * detach this feature.
  76050. * Will usually be called by the features manager
  76051. *
  76052. * @returns true if successful.
  76053. */
  76054. detach(): boolean;
  76055. /**
  76056. * Dispose this feature and all of the resources attached
  76057. */
  76058. dispose(): void;
  76059. /**
  76060. * Check if the needed objects are defined.
  76061. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  76062. */
  76063. isCompatible(): boolean;
  76064. protected _onXRFrame(frame: XRFrame): void;
  76065. private _init;
  76066. private _updatePlaneWithXRPlane;
  76067. /**
  76068. * avoiding using Array.find for global support.
  76069. * @param xrPlane the plane to find in the array
  76070. */
  76071. private findIndexInPlaneArray;
  76072. }
  76073. }
  76074. declare module BABYLON {
  76075. /**
  76076. * Options interface for the background remover plugin
  76077. */
  76078. export interface IWebXRBackgroundRemoverOptions {
  76079. /**
  76080. * Further background meshes to disable when entering AR
  76081. */
  76082. backgroundMeshes?: AbstractMesh[];
  76083. /**
  76084. * flags to configure the removal of the environment helper.
  76085. * If not set, the entire background will be removed. If set, flags should be set as well.
  76086. */
  76087. environmentHelperRemovalFlags?: {
  76088. /**
  76089. * Should the skybox be removed (default false)
  76090. */
  76091. skyBox?: boolean;
  76092. /**
  76093. * Should the ground be removed (default false)
  76094. */
  76095. ground?: boolean;
  76096. };
  76097. /**
  76098. * don't disable the environment helper
  76099. */
  76100. ignoreEnvironmentHelper?: boolean;
  76101. }
  76102. /**
  76103. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  76104. */
  76105. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  76106. /**
  76107. * read-only options to be used in this module
  76108. */
  76109. readonly options: IWebXRBackgroundRemoverOptions;
  76110. /**
  76111. * The module's name
  76112. */
  76113. static readonly Name: string;
  76114. /**
  76115. * The (Babylon) version of this module.
  76116. * This is an integer representing the implementation version.
  76117. * This number does not correspond to the WebXR specs version
  76118. */
  76119. static readonly Version: number;
  76120. /**
  76121. * registered observers will be triggered when the background state changes
  76122. */
  76123. onBackgroundStateChangedObservable: Observable<boolean>;
  76124. /**
  76125. * constructs a new background remover module
  76126. * @param _xrSessionManager the session manager for this module
  76127. * @param options read-only options to be used in this module
  76128. */
  76129. constructor(_xrSessionManager: WebXRSessionManager,
  76130. /**
  76131. * read-only options to be used in this module
  76132. */
  76133. options?: IWebXRBackgroundRemoverOptions);
  76134. /**
  76135. * attach this feature
  76136. * Will usually be called by the features manager
  76137. *
  76138. * @returns true if successful.
  76139. */
  76140. attach(): boolean;
  76141. /**
  76142. * detach this feature.
  76143. * Will usually be called by the features manager
  76144. *
  76145. * @returns true if successful.
  76146. */
  76147. detach(): boolean;
  76148. /**
  76149. * Dispose this feature and all of the resources attached
  76150. */
  76151. dispose(): void;
  76152. protected _onXRFrame(_xrFrame: XRFrame): void;
  76153. private _setBackgroundState;
  76154. }
  76155. }
  76156. declare module BABYLON {
  76157. /**
  76158. * Options for the controller physics feature
  76159. */
  76160. export class IWebXRControllerPhysicsOptions {
  76161. /**
  76162. * Should the headset get its own impostor
  76163. */
  76164. enableHeadsetImpostor?: boolean;
  76165. /**
  76166. * Optional parameters for the headset impostor
  76167. */
  76168. headsetImpostorParams?: {
  76169. /**
  76170. * The type of impostor to create. Default is sphere
  76171. */
  76172. impostorType: number;
  76173. /**
  76174. * the size of the impostor. Defaults to 10cm
  76175. */
  76176. impostorSize?: number | {
  76177. width: number;
  76178. height: number;
  76179. depth: number;
  76180. };
  76181. /**
  76182. * Friction definitions
  76183. */
  76184. friction?: number;
  76185. /**
  76186. * Restitution
  76187. */
  76188. restitution?: number;
  76189. };
  76190. /**
  76191. * The physics properties of the future impostors
  76192. */
  76193. physicsProperties?: {
  76194. /**
  76195. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  76196. * Note that this requires a physics engine that supports mesh impostors!
  76197. */
  76198. useControllerMesh?: boolean;
  76199. /**
  76200. * The type of impostor to create. Default is sphere
  76201. */
  76202. impostorType?: number;
  76203. /**
  76204. * the size of the impostor. Defaults to 10cm
  76205. */
  76206. impostorSize?: number | {
  76207. width: number;
  76208. height: number;
  76209. depth: number;
  76210. };
  76211. /**
  76212. * Friction definitions
  76213. */
  76214. friction?: number;
  76215. /**
  76216. * Restitution
  76217. */
  76218. restitution?: number;
  76219. };
  76220. /**
  76221. * the xr input to use with this pointer selection
  76222. */
  76223. xrInput: WebXRInput;
  76224. }
  76225. /**
  76226. * Add physics impostor to your webxr controllers,
  76227. * including naive calculation of their linear and angular velocity
  76228. */
  76229. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  76230. private readonly _options;
  76231. private _attachController;
  76232. private _controllers;
  76233. private _debugMode;
  76234. private _delta;
  76235. private _headsetImpostor?;
  76236. private _headsetMesh?;
  76237. private _lastTimestamp;
  76238. private _tmpQuaternion;
  76239. private _tmpVector;
  76240. /**
  76241. * The module's name
  76242. */
  76243. static readonly Name: string;
  76244. /**
  76245. * The (Babylon) version of this module.
  76246. * This is an integer representing the implementation version.
  76247. * This number does not correspond to the webxr specs version
  76248. */
  76249. static readonly Version: number;
  76250. /**
  76251. * Construct a new Controller Physics Feature
  76252. * @param _xrSessionManager the corresponding xr session manager
  76253. * @param _options options to create this feature with
  76254. */
  76255. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  76256. /**
  76257. * @hidden
  76258. * enable debugging - will show console outputs and the impostor mesh
  76259. */
  76260. _enablePhysicsDebug(): void;
  76261. /**
  76262. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  76263. * @param xrController the controller to add
  76264. */
  76265. addController(xrController: WebXRInputSource): void;
  76266. /**
  76267. * attach this feature
  76268. * Will usually be called by the features manager
  76269. *
  76270. * @returns true if successful.
  76271. */
  76272. attach(): boolean;
  76273. /**
  76274. * detach this feature.
  76275. * Will usually be called by the features manager
  76276. *
  76277. * @returns true if successful.
  76278. */
  76279. detach(): boolean;
  76280. /**
  76281. * Get the headset impostor, if enabled
  76282. * @returns the impostor
  76283. */
  76284. getHeadsetImpostor(): PhysicsImpostor | undefined;
  76285. /**
  76286. * Get the physics impostor of a specific controller.
  76287. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  76288. * @param controller the controller or the controller id of which to get the impostor
  76289. * @returns the impostor or null
  76290. */
  76291. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  76292. /**
  76293. * Update the physics properties provided in the constructor
  76294. * @param newProperties the new properties object
  76295. */
  76296. setPhysicsProperties(newProperties: {
  76297. impostorType?: number;
  76298. impostorSize?: number | {
  76299. width: number;
  76300. height: number;
  76301. depth: number;
  76302. };
  76303. friction?: number;
  76304. restitution?: number;
  76305. }): void;
  76306. protected _onXRFrame(_xrFrame: any): void;
  76307. private _detachController;
  76308. }
  76309. }
  76310. declare module BABYLON {
  76311. /**
  76312. * A babylon interface for a "WebXR" feature point.
  76313. * Represents the position and confidence value of a given feature point.
  76314. */
  76315. export interface IWebXRFeaturePoint {
  76316. /**
  76317. * Represents the position of the feature point in world space.
  76318. */
  76319. position: Vector3;
  76320. /**
  76321. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  76322. */
  76323. confidenceValue: number;
  76324. }
  76325. /**
  76326. * The feature point system is used to detect feature points from real world geometry.
  76327. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  76328. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  76329. */
  76330. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  76331. private _enabled;
  76332. private _featurePointCloud;
  76333. /**
  76334. * The module's name
  76335. */
  76336. static readonly Name: string;
  76337. /**
  76338. * The (Babylon) version of this module.
  76339. * This is an integer representing the implementation version.
  76340. * This number does not correspond to the WebXR specs version
  76341. */
  76342. static readonly Version: number;
  76343. /**
  76344. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  76345. * Will notify the observers about which feature points have been added.
  76346. */
  76347. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  76348. /**
  76349. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  76350. * Will notify the observers about which feature points have been updated.
  76351. */
  76352. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  76353. /**
  76354. * The current feature point cloud maintained across frames.
  76355. */
  76356. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  76357. /**
  76358. * construct the feature point system
  76359. * @param _xrSessionManager an instance of xr Session manager
  76360. */
  76361. constructor(_xrSessionManager: WebXRSessionManager);
  76362. /**
  76363. * Detach this feature.
  76364. * Will usually be called by the features manager
  76365. *
  76366. * @returns true if successful.
  76367. */
  76368. detach(): boolean;
  76369. /**
  76370. * Dispose this feature and all of the resources attached
  76371. */
  76372. dispose(): void;
  76373. /**
  76374. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  76375. */
  76376. protected _onXRFrame(frame: XRFrame): void;
  76377. /**
  76378. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  76379. */
  76380. private _init;
  76381. }
  76382. }
  76383. declare module BABYLON {
  76384. /**
  76385. * Configuration interface for the hand tracking feature
  76386. */
  76387. export interface IWebXRHandTrackingOptions {
  76388. /**
  76389. * The xrInput that will be used as source for new hands
  76390. */
  76391. xrInput: WebXRInput;
  76392. /**
  76393. * Configuration object for the joint meshes
  76394. */
  76395. jointMeshes?: {
  76396. /**
  76397. * Should the meshes created be invisible (defaults to false)
  76398. */
  76399. invisible?: boolean;
  76400. /**
  76401. * A source mesh to be used to create instances. Defaults to a sphere.
  76402. * This mesh will be the source for all other (25) meshes.
  76403. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  76404. */
  76405. sourceMesh?: Mesh;
  76406. /**
  76407. * This function will be called after a mesh was created for a specific joint.
  76408. * Using this function you can either manipulate the instance or return a new mesh.
  76409. * When returning a new mesh the instance created before will be disposed
  76410. */
  76411. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  76412. /**
  76413. * Should the source mesh stay visible. Defaults to false
  76414. */
  76415. keepOriginalVisible?: boolean;
  76416. /**
  76417. * Scale factor for all instances (defaults to 2)
  76418. */
  76419. scaleFactor?: number;
  76420. /**
  76421. * Should each instance have its own physics impostor
  76422. */
  76423. enablePhysics?: boolean;
  76424. /**
  76425. * If enabled, override default physics properties
  76426. */
  76427. physicsProps?: {
  76428. friction?: number;
  76429. restitution?: number;
  76430. impostorType?: number;
  76431. };
  76432. /**
  76433. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  76434. */
  76435. handMesh?: AbstractMesh;
  76436. };
  76437. }
  76438. /**
  76439. * Parts of the hands divided to writs and finger names
  76440. */
  76441. export const enum HandPart {
  76442. /**
  76443. * HandPart - Wrist
  76444. */
  76445. WRIST = "wrist",
  76446. /**
  76447. * HandPart - The THumb
  76448. */
  76449. THUMB = "thumb",
  76450. /**
  76451. * HandPart - Index finger
  76452. */
  76453. INDEX = "index",
  76454. /**
  76455. * HandPart - Middle finger
  76456. */
  76457. MIDDLE = "middle",
  76458. /**
  76459. * HandPart - Ring finger
  76460. */
  76461. RING = "ring",
  76462. /**
  76463. * HandPart - Little finger
  76464. */
  76465. LITTLE = "little"
  76466. }
  76467. /**
  76468. * Representing a single hand (with its corresponding native XRHand object)
  76469. */
  76470. export class WebXRHand implements IDisposable {
  76471. /** the controller to which the hand correlates */
  76472. readonly xrController: WebXRInputSource;
  76473. /** the meshes to be used to track the hand joints */
  76474. readonly trackedMeshes: AbstractMesh[];
  76475. /**
  76476. * Hand-parts definition (key is HandPart)
  76477. */
  76478. handPartsDefinition: {
  76479. [key: string]: number[];
  76480. };
  76481. /**
  76482. * Populate the HandPartsDefinition object.
  76483. * This is called as a side effect since certain browsers don't have XRHand defined.
  76484. */
  76485. private generateHandPartsDefinition;
  76486. /**
  76487. * Construct a new hand object
  76488. * @param xrController the controller to which the hand correlates
  76489. * @param trackedMeshes the meshes to be used to track the hand joints
  76490. */
  76491. constructor(
  76492. /** the controller to which the hand correlates */
  76493. xrController: WebXRInputSource,
  76494. /** the meshes to be used to track the hand joints */
  76495. trackedMeshes: AbstractMesh[]);
  76496. /**
  76497. * Update this hand from the latest xr frame
  76498. * @param xrFrame xrFrame to update from
  76499. * @param referenceSpace The current viewer reference space
  76500. * @param scaleFactor optional scale factor for the meshes
  76501. */
  76502. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  76503. /**
  76504. * Get meshes of part of the hand
  76505. * @param part the part of hand to get
  76506. * @returns An array of meshes that correlate to the hand part requested
  76507. */
  76508. getHandPartMeshes(part: HandPart): AbstractMesh[];
  76509. /**
  76510. * Dispose this Hand object
  76511. */
  76512. dispose(): void;
  76513. }
  76514. /**
  76515. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  76516. */
  76517. export class WebXRHandTracking extends WebXRAbstractFeature {
  76518. /**
  76519. * options to use when constructing this feature
  76520. */
  76521. readonly options: IWebXRHandTrackingOptions;
  76522. private static _idCounter;
  76523. /**
  76524. * The module's name
  76525. */
  76526. static readonly Name: string;
  76527. /**
  76528. * The (Babylon) version of this module.
  76529. * This is an integer representing the implementation version.
  76530. * This number does not correspond to the WebXR specs version
  76531. */
  76532. static readonly Version: number;
  76533. /**
  76534. * This observable will notify registered observers when a new hand object was added and initialized
  76535. */
  76536. onHandAddedObservable: Observable<WebXRHand>;
  76537. /**
  76538. * This observable will notify its observers right before the hand object is disposed
  76539. */
  76540. onHandRemovedObservable: Observable<WebXRHand>;
  76541. private _hands;
  76542. /**
  76543. * Creates a new instance of the hit test feature
  76544. * @param _xrSessionManager an instance of WebXRSessionManager
  76545. * @param options options to use when constructing this feature
  76546. */
  76547. constructor(_xrSessionManager: WebXRSessionManager,
  76548. /**
  76549. * options to use when constructing this feature
  76550. */
  76551. options: IWebXRHandTrackingOptions);
  76552. /**
  76553. * Check if the needed objects are defined.
  76554. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  76555. */
  76556. isCompatible(): boolean;
  76557. /**
  76558. * attach this feature
  76559. * Will usually be called by the features manager
  76560. *
  76561. * @returns true if successful.
  76562. */
  76563. attach(): boolean;
  76564. /**
  76565. * detach this feature.
  76566. * Will usually be called by the features manager
  76567. *
  76568. * @returns true if successful.
  76569. */
  76570. detach(): boolean;
  76571. /**
  76572. * Dispose this feature and all of the resources attached
  76573. */
  76574. dispose(): void;
  76575. /**
  76576. * Get the hand object according to the controller id
  76577. * @param controllerId the controller id to which we want to get the hand
  76578. * @returns null if not found or the WebXRHand object if found
  76579. */
  76580. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  76581. /**
  76582. * Get a hand object according to the requested handedness
  76583. * @param handedness the handedness to request
  76584. * @returns null if not found or the WebXRHand object if found
  76585. */
  76586. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  76587. protected _onXRFrame(_xrFrame: XRFrame): void;
  76588. private _attachHand;
  76589. private _detachHand;
  76590. }
  76591. }
  76592. declare module BABYLON {
  76593. /**
  76594. * The motion controller class for all microsoft mixed reality controllers
  76595. */
  76596. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  76597. protected readonly _mapping: {
  76598. defaultButton: {
  76599. valueNodeName: string;
  76600. unpressedNodeName: string;
  76601. pressedNodeName: string;
  76602. };
  76603. defaultAxis: {
  76604. valueNodeName: string;
  76605. minNodeName: string;
  76606. maxNodeName: string;
  76607. };
  76608. buttons: {
  76609. "xr-standard-trigger": {
  76610. rootNodeName: string;
  76611. componentProperty: string;
  76612. states: string[];
  76613. };
  76614. "xr-standard-squeeze": {
  76615. rootNodeName: string;
  76616. componentProperty: string;
  76617. states: string[];
  76618. };
  76619. "xr-standard-touchpad": {
  76620. rootNodeName: string;
  76621. labelAnchorNodeName: string;
  76622. touchPointNodeName: string;
  76623. };
  76624. "xr-standard-thumbstick": {
  76625. rootNodeName: string;
  76626. componentProperty: string;
  76627. states: string[];
  76628. };
  76629. };
  76630. axes: {
  76631. "xr-standard-touchpad": {
  76632. "x-axis": {
  76633. rootNodeName: string;
  76634. };
  76635. "y-axis": {
  76636. rootNodeName: string;
  76637. };
  76638. };
  76639. "xr-standard-thumbstick": {
  76640. "x-axis": {
  76641. rootNodeName: string;
  76642. };
  76643. "y-axis": {
  76644. rootNodeName: string;
  76645. };
  76646. };
  76647. };
  76648. };
  76649. /**
  76650. * The base url used to load the left and right controller models
  76651. */
  76652. static MODEL_BASE_URL: string;
  76653. /**
  76654. * The name of the left controller model file
  76655. */
  76656. static MODEL_LEFT_FILENAME: string;
  76657. /**
  76658. * The name of the right controller model file
  76659. */
  76660. static MODEL_RIGHT_FILENAME: string;
  76661. profileId: string;
  76662. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  76663. protected _getFilenameAndPath(): {
  76664. filename: string;
  76665. path: string;
  76666. };
  76667. protected _getModelLoadingConstraints(): boolean;
  76668. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76669. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76670. protected _updateModel(): void;
  76671. }
  76672. }
  76673. declare module BABYLON {
  76674. /**
  76675. * The motion controller class for oculus touch (quest, rift).
  76676. * This class supports legacy mapping as well the standard xr mapping
  76677. */
  76678. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  76679. private _forceLegacyControllers;
  76680. private _modelRootNode;
  76681. /**
  76682. * The base url used to load the left and right controller models
  76683. */
  76684. static MODEL_BASE_URL: string;
  76685. /**
  76686. * The name of the left controller model file
  76687. */
  76688. static MODEL_LEFT_FILENAME: string;
  76689. /**
  76690. * The name of the right controller model file
  76691. */
  76692. static MODEL_RIGHT_FILENAME: string;
  76693. /**
  76694. * Base Url for the Quest controller model.
  76695. */
  76696. static QUEST_MODEL_BASE_URL: string;
  76697. profileId: string;
  76698. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  76699. protected _getFilenameAndPath(): {
  76700. filename: string;
  76701. path: string;
  76702. };
  76703. protected _getModelLoadingConstraints(): boolean;
  76704. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76705. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76706. protected _updateModel(): void;
  76707. /**
  76708. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  76709. * between the touch and touch 2.
  76710. */
  76711. private _isQuest;
  76712. }
  76713. }
  76714. declare module BABYLON {
  76715. /**
  76716. * The motion controller class for the standard HTC-Vive controllers
  76717. */
  76718. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  76719. private _modelRootNode;
  76720. /**
  76721. * The base url used to load the left and right controller models
  76722. */
  76723. static MODEL_BASE_URL: string;
  76724. /**
  76725. * File name for the controller model.
  76726. */
  76727. static MODEL_FILENAME: string;
  76728. profileId: string;
  76729. /**
  76730. * Create a new Vive motion controller object
  76731. * @param scene the scene to use to create this controller
  76732. * @param gamepadObject the corresponding gamepad object
  76733. * @param handedness the handedness of the controller
  76734. */
  76735. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  76736. protected _getFilenameAndPath(): {
  76737. filename: string;
  76738. path: string;
  76739. };
  76740. protected _getModelLoadingConstraints(): boolean;
  76741. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76742. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76743. protected _updateModel(): void;
  76744. }
  76745. }
  76746. declare module BABYLON {
  76747. /**
  76748. * A cursor which tracks a point on a path
  76749. */
  76750. export class PathCursor {
  76751. private path;
  76752. /**
  76753. * Stores path cursor callbacks for when an onchange event is triggered
  76754. */
  76755. private _onchange;
  76756. /**
  76757. * The value of the path cursor
  76758. */
  76759. value: number;
  76760. /**
  76761. * The animation array of the path cursor
  76762. */
  76763. animations: Animation[];
  76764. /**
  76765. * Initializes the path cursor
  76766. * @param path The path to track
  76767. */
  76768. constructor(path: Path2);
  76769. /**
  76770. * Gets the cursor point on the path
  76771. * @returns A point on the path cursor at the cursor location
  76772. */
  76773. getPoint(): Vector3;
  76774. /**
  76775. * Moves the cursor ahead by the step amount
  76776. * @param step The amount to move the cursor forward
  76777. * @returns This path cursor
  76778. */
  76779. moveAhead(step?: number): PathCursor;
  76780. /**
  76781. * Moves the cursor behind by the step amount
  76782. * @param step The amount to move the cursor back
  76783. * @returns This path cursor
  76784. */
  76785. moveBack(step?: number): PathCursor;
  76786. /**
  76787. * Moves the cursor by the step amount
  76788. * If the step amount is greater than one, an exception is thrown
  76789. * @param step The amount to move the cursor
  76790. * @returns This path cursor
  76791. */
  76792. move(step: number): PathCursor;
  76793. /**
  76794. * Ensures that the value is limited between zero and one
  76795. * @returns This path cursor
  76796. */
  76797. private ensureLimits;
  76798. /**
  76799. * Runs onchange callbacks on change (used by the animation engine)
  76800. * @returns This path cursor
  76801. */
  76802. private raiseOnChange;
  76803. /**
  76804. * Executes a function on change
  76805. * @param f A path cursor onchange callback
  76806. * @returns This path cursor
  76807. */
  76808. onchange(f: (cursor: PathCursor) => void): PathCursor;
  76809. }
  76810. }
  76811. declare module BABYLON {
  76812. /** @hidden */
  76813. export var blurPixelShader: {
  76814. name: string;
  76815. shader: string;
  76816. };
  76817. }
  76818. declare module BABYLON {
  76819. /** @hidden */
  76820. export var pointCloudVertexDeclaration: {
  76821. name: string;
  76822. shader: string;
  76823. };
  76824. }
  76825. // Mixins
  76826. interface Window {
  76827. mozIndexedDB: IDBFactory;
  76828. webkitIndexedDB: IDBFactory;
  76829. msIndexedDB: IDBFactory;
  76830. webkitURL: typeof URL;
  76831. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  76832. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  76833. WebGLRenderingContext: WebGLRenderingContext;
  76834. MSGesture: MSGesture;
  76835. CANNON: any;
  76836. AudioContext: AudioContext;
  76837. webkitAudioContext: AudioContext;
  76838. PointerEvent: any;
  76839. Math: Math;
  76840. Uint8Array: Uint8ArrayConstructor;
  76841. Float32Array: Float32ArrayConstructor;
  76842. mozURL: typeof URL;
  76843. msURL: typeof URL;
  76844. VRFrameData: any; // WebVR, from specs 1.1
  76845. DracoDecoderModule: any;
  76846. setImmediate(handler: (...args: any[]) => void): number;
  76847. }
  76848. interface HTMLCanvasElement {
  76849. requestPointerLock(): void;
  76850. msRequestPointerLock?(): void;
  76851. mozRequestPointerLock?(): void;
  76852. webkitRequestPointerLock?(): void;
  76853. /** Track wether a record is in progress */
  76854. isRecording: boolean;
  76855. /** Capture Stream method defined by some browsers */
  76856. captureStream(fps?: number): MediaStream;
  76857. }
  76858. interface CanvasRenderingContext2D {
  76859. msImageSmoothingEnabled: boolean;
  76860. }
  76861. interface MouseEvent {
  76862. mozMovementX: number;
  76863. mozMovementY: number;
  76864. webkitMovementX: number;
  76865. webkitMovementY: number;
  76866. msMovementX: number;
  76867. msMovementY: number;
  76868. }
  76869. interface Navigator {
  76870. mozGetVRDevices: (any: any) => any;
  76871. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76872. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76873. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76874. webkitGetGamepads(): Gamepad[];
  76875. msGetGamepads(): Gamepad[];
  76876. webkitGamepads(): Gamepad[];
  76877. }
  76878. interface HTMLVideoElement {
  76879. mozSrcObject: any;
  76880. }
  76881. interface Math {
  76882. fround(x: number): number;
  76883. imul(a: number, b: number): number;
  76884. }
  76885. interface WebGLRenderingContext {
  76886. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  76887. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  76888. vertexAttribDivisor(index: number, divisor: number): void;
  76889. createVertexArray(): any;
  76890. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  76891. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  76892. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  76893. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  76894. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  76895. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  76896. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  76897. // Queries
  76898. createQuery(): WebGLQuery;
  76899. deleteQuery(query: WebGLQuery): void;
  76900. beginQuery(target: number, query: WebGLQuery): void;
  76901. endQuery(target: number): void;
  76902. getQueryParameter(query: WebGLQuery, pname: number): any;
  76903. getQuery(target: number, pname: number): any;
  76904. MAX_SAMPLES: number;
  76905. RGBA8: number;
  76906. READ_FRAMEBUFFER: number;
  76907. DRAW_FRAMEBUFFER: number;
  76908. UNIFORM_BUFFER: number;
  76909. HALF_FLOAT_OES: number;
  76910. RGBA16F: number;
  76911. RGBA32F: number;
  76912. R32F: number;
  76913. RG32F: number;
  76914. RGB32F: number;
  76915. R16F: number;
  76916. RG16F: number;
  76917. RGB16F: number;
  76918. RED: number;
  76919. RG: number;
  76920. R8: number;
  76921. RG8: number;
  76922. UNSIGNED_INT_24_8: number;
  76923. DEPTH24_STENCIL8: number;
  76924. MIN: number;
  76925. MAX: number;
  76926. /* Multiple Render Targets */
  76927. drawBuffers(buffers: number[]): void;
  76928. readBuffer(src: number): void;
  76929. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  76930. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  76931. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  76932. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  76933. // Occlusion Query
  76934. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  76935. ANY_SAMPLES_PASSED: number;
  76936. QUERY_RESULT_AVAILABLE: number;
  76937. QUERY_RESULT: number;
  76938. }
  76939. interface WebGLProgram {
  76940. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  76941. }
  76942. interface EXT_disjoint_timer_query {
  76943. QUERY_COUNTER_BITS_EXT: number;
  76944. TIME_ELAPSED_EXT: number;
  76945. TIMESTAMP_EXT: number;
  76946. GPU_DISJOINT_EXT: number;
  76947. QUERY_RESULT_EXT: number;
  76948. QUERY_RESULT_AVAILABLE_EXT: number;
  76949. queryCounterEXT(query: WebGLQuery, target: number): void;
  76950. createQueryEXT(): WebGLQuery;
  76951. beginQueryEXT(target: number, query: WebGLQuery): void;
  76952. endQueryEXT(target: number): void;
  76953. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  76954. deleteQueryEXT(query: WebGLQuery): void;
  76955. }
  76956. interface WebGLUniformLocation {
  76957. _currentState: any;
  76958. }
  76959. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  76960. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  76961. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  76962. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  76963. interface WebGLRenderingContext {
  76964. readonly RASTERIZER_DISCARD: number;
  76965. readonly DEPTH_COMPONENT24: number;
  76966. readonly TEXTURE_3D: number;
  76967. readonly TEXTURE_2D_ARRAY: number;
  76968. readonly TEXTURE_COMPARE_FUNC: number;
  76969. readonly TEXTURE_COMPARE_MODE: number;
  76970. readonly COMPARE_REF_TO_TEXTURE: number;
  76971. readonly TEXTURE_WRAP_R: number;
  76972. readonly HALF_FLOAT: number;
  76973. readonly RGB8: number;
  76974. readonly RED_INTEGER: number;
  76975. readonly RG_INTEGER: number;
  76976. readonly RGB_INTEGER: number;
  76977. readonly RGBA_INTEGER: number;
  76978. readonly R8_SNORM: number;
  76979. readonly RG8_SNORM: number;
  76980. readonly RGB8_SNORM: number;
  76981. readonly RGBA8_SNORM: number;
  76982. readonly R8I: number;
  76983. readonly RG8I: number;
  76984. readonly RGB8I: number;
  76985. readonly RGBA8I: number;
  76986. readonly R8UI: number;
  76987. readonly RG8UI: number;
  76988. readonly RGB8UI: number;
  76989. readonly RGBA8UI: number;
  76990. readonly R16I: number;
  76991. readonly RG16I: number;
  76992. readonly RGB16I: number;
  76993. readonly RGBA16I: number;
  76994. readonly R16UI: number;
  76995. readonly RG16UI: number;
  76996. readonly RGB16UI: number;
  76997. readonly RGBA16UI: number;
  76998. readonly R32I: number;
  76999. readonly RG32I: number;
  77000. readonly RGB32I: number;
  77001. readonly RGBA32I: number;
  77002. readonly R32UI: number;
  77003. readonly RG32UI: number;
  77004. readonly RGB32UI: number;
  77005. readonly RGBA32UI: number;
  77006. readonly RGB10_A2UI: number;
  77007. readonly R11F_G11F_B10F: number;
  77008. readonly RGB9_E5: number;
  77009. readonly RGB10_A2: number;
  77010. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  77011. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  77012. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  77013. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  77014. readonly DEPTH_COMPONENT32F: number;
  77015. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  77016. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  77017. 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;
  77018. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  77019. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  77020. readonly TRANSFORM_FEEDBACK: number;
  77021. readonly INTERLEAVED_ATTRIBS: number;
  77022. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  77023. createTransformFeedback(): WebGLTransformFeedback;
  77024. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  77025. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  77026. beginTransformFeedback(primitiveMode: number): void;
  77027. endTransformFeedback(): void;
  77028. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  77029. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  77030. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  77031. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  77032. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  77033. }
  77034. interface ImageBitmap {
  77035. readonly width: number;
  77036. readonly height: number;
  77037. close(): void;
  77038. }
  77039. interface WebGLQuery extends WebGLObject {
  77040. }
  77041. declare var WebGLQuery: {
  77042. prototype: WebGLQuery;
  77043. new(): WebGLQuery;
  77044. };
  77045. interface WebGLSampler extends WebGLObject {
  77046. }
  77047. declare var WebGLSampler: {
  77048. prototype: WebGLSampler;
  77049. new(): WebGLSampler;
  77050. };
  77051. interface WebGLSync extends WebGLObject {
  77052. }
  77053. declare var WebGLSync: {
  77054. prototype: WebGLSync;
  77055. new(): WebGLSync;
  77056. };
  77057. interface WebGLTransformFeedback extends WebGLObject {
  77058. }
  77059. declare var WebGLTransformFeedback: {
  77060. prototype: WebGLTransformFeedback;
  77061. new(): WebGLTransformFeedback;
  77062. };
  77063. interface WebGLVertexArrayObject extends WebGLObject {
  77064. }
  77065. declare var WebGLVertexArrayObject: {
  77066. prototype: WebGLVertexArrayObject;
  77067. new(): WebGLVertexArrayObject;
  77068. };
  77069. // Type definitions for WebVR API
  77070. // Project: https://w3c.github.io/webvr/
  77071. // Definitions by: six a <https://github.com/lostfictions>
  77072. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  77073. interface VRDisplay extends EventTarget {
  77074. /**
  77075. * Dictionary of capabilities describing the VRDisplay.
  77076. */
  77077. readonly capabilities: VRDisplayCapabilities;
  77078. /**
  77079. * z-depth defining the far plane of the eye view frustum
  77080. * enables mapping of values in the render target depth
  77081. * attachment to scene coordinates. Initially set to 10000.0.
  77082. */
  77083. depthFar: number;
  77084. /**
  77085. * z-depth defining the near plane of the eye view frustum
  77086. * enables mapping of values in the render target depth
  77087. * attachment to scene coordinates. Initially set to 0.01.
  77088. */
  77089. depthNear: number;
  77090. /**
  77091. * An identifier for this distinct VRDisplay. Used as an
  77092. * association point in the Gamepad API.
  77093. */
  77094. readonly displayId: number;
  77095. /**
  77096. * A display name, a user-readable name identifying it.
  77097. */
  77098. readonly displayName: string;
  77099. readonly isConnected: boolean;
  77100. readonly isPresenting: boolean;
  77101. /**
  77102. * If this VRDisplay supports room-scale experiences, the optional
  77103. * stage attribute contains details on the room-scale parameters.
  77104. */
  77105. readonly stageParameters: VRStageParameters | null;
  77106. /**
  77107. * Passing the value returned by `requestAnimationFrame` to
  77108. * `cancelAnimationFrame` will unregister the callback.
  77109. * @param handle Define the hanle of the request to cancel
  77110. */
  77111. cancelAnimationFrame(handle: number): void;
  77112. /**
  77113. * Stops presenting to the VRDisplay.
  77114. * @returns a promise to know when it stopped
  77115. */
  77116. exitPresent(): Promise<void>;
  77117. /**
  77118. * Return the current VREyeParameters for the given eye.
  77119. * @param whichEye Define the eye we want the parameter for
  77120. * @returns the eye parameters
  77121. */
  77122. getEyeParameters(whichEye: string): VREyeParameters;
  77123. /**
  77124. * Populates the passed VRFrameData with the information required to render
  77125. * the current frame.
  77126. * @param frameData Define the data structure to populate
  77127. * @returns true if ok otherwise false
  77128. */
  77129. getFrameData(frameData: VRFrameData): boolean;
  77130. /**
  77131. * Get the layers currently being presented.
  77132. * @returns the list of VR layers
  77133. */
  77134. getLayers(): VRLayer[];
  77135. /**
  77136. * Return a VRPose containing the future predicted pose of the VRDisplay
  77137. * when the current frame will be presented. The value returned will not
  77138. * change until JavaScript has returned control to the browser.
  77139. *
  77140. * The VRPose will contain the position, orientation, velocity,
  77141. * and acceleration of each of these properties.
  77142. * @returns the pose object
  77143. */
  77144. getPose(): VRPose;
  77145. /**
  77146. * Return the current instantaneous pose of the VRDisplay, with no
  77147. * prediction applied.
  77148. * @returns the current instantaneous pose
  77149. */
  77150. getImmediatePose(): VRPose;
  77151. /**
  77152. * The callback passed to `requestAnimationFrame` will be called
  77153. * any time a new frame should be rendered. When the VRDisplay is
  77154. * presenting the callback will be called at the native refresh
  77155. * rate of the HMD. When not presenting this function acts
  77156. * identically to how window.requestAnimationFrame acts. Content should
  77157. * make no assumptions of frame rate or vsync behavior as the HMD runs
  77158. * asynchronously from other displays and at differing refresh rates.
  77159. * @param callback Define the eaction to run next frame
  77160. * @returns the request handle it
  77161. */
  77162. requestAnimationFrame(callback: FrameRequestCallback): number;
  77163. /**
  77164. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  77165. * Repeat calls while already presenting will update the VRLayers being displayed.
  77166. * @param layers Define the list of layer to present
  77167. * @returns a promise to know when the request has been fulfilled
  77168. */
  77169. requestPresent(layers: VRLayer[]): Promise<void>;
  77170. /**
  77171. * Reset the pose for this display, treating its current position and
  77172. * orientation as the "origin/zero" values. VRPose.position,
  77173. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  77174. * updated when calling resetPose(). This should be called in only
  77175. * sitting-space experiences.
  77176. */
  77177. resetPose(): void;
  77178. /**
  77179. * The VRLayer provided to the VRDisplay will be captured and presented
  77180. * in the HMD. Calling this function has the same effect on the source
  77181. * canvas as any other operation that uses its source image, and canvases
  77182. * created without preserveDrawingBuffer set to true will be cleared.
  77183. * @param pose Define the pose to submit
  77184. */
  77185. submitFrame(pose?: VRPose): void;
  77186. }
  77187. declare var VRDisplay: {
  77188. prototype: VRDisplay;
  77189. new(): VRDisplay;
  77190. };
  77191. interface VRLayer {
  77192. leftBounds?: number[] | Float32Array | null;
  77193. rightBounds?: number[] | Float32Array | null;
  77194. source?: HTMLCanvasElement | null;
  77195. }
  77196. interface VRDisplayCapabilities {
  77197. readonly canPresent: boolean;
  77198. readonly hasExternalDisplay: boolean;
  77199. readonly hasOrientation: boolean;
  77200. readonly hasPosition: boolean;
  77201. readonly maxLayers: number;
  77202. }
  77203. interface VREyeParameters {
  77204. /** @deprecated */
  77205. readonly fieldOfView: VRFieldOfView;
  77206. readonly offset: Float32Array;
  77207. readonly renderHeight: number;
  77208. readonly renderWidth: number;
  77209. }
  77210. interface VRFieldOfView {
  77211. readonly downDegrees: number;
  77212. readonly leftDegrees: number;
  77213. readonly rightDegrees: number;
  77214. readonly upDegrees: number;
  77215. }
  77216. interface VRFrameData {
  77217. readonly leftProjectionMatrix: Float32Array;
  77218. readonly leftViewMatrix: Float32Array;
  77219. readonly pose: VRPose;
  77220. readonly rightProjectionMatrix: Float32Array;
  77221. readonly rightViewMatrix: Float32Array;
  77222. readonly timestamp: number;
  77223. }
  77224. interface VRPose {
  77225. readonly angularAcceleration: Float32Array | null;
  77226. readonly angularVelocity: Float32Array | null;
  77227. readonly linearAcceleration: Float32Array | null;
  77228. readonly linearVelocity: Float32Array | null;
  77229. readonly orientation: Float32Array | null;
  77230. readonly position: Float32Array | null;
  77231. readonly timestamp: number;
  77232. }
  77233. interface VRStageParameters {
  77234. sittingToStandingTransform?: Float32Array;
  77235. sizeX?: number;
  77236. sizeY?: number;
  77237. }
  77238. interface Navigator {
  77239. getVRDisplays(): Promise<VRDisplay[]>;
  77240. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  77241. }
  77242. interface Window {
  77243. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  77244. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  77245. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  77246. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  77247. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  77248. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  77249. }
  77250. interface Gamepad {
  77251. readonly displayId: number;
  77252. }
  77253. /**
  77254. * Available session modes
  77255. */
  77256. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  77257. /**
  77258. * Reference space types
  77259. */
  77260. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  77261. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  77262. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  77263. /**
  77264. * Handedness types
  77265. */
  77266. type XRHandedness = "none" | "left" | "right";
  77267. /**
  77268. * InputSource target ray modes
  77269. */
  77270. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  77271. /**
  77272. * Eye types
  77273. */
  77274. type XREye = "none" | "left" | "right";
  77275. /**
  77276. * Type of XR events available
  77277. */
  77278. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  77279. type XRFrameRequestCallback = (time: DOMHighResTimeStamp, frame: XRFrame) => void;
  77280. type XRPlaneSet = Set<XRPlane>;
  77281. type XRAnchorSet = Set<XRAnchor>;
  77282. type XREventHandler = (callback: any) => void;
  77283. interface XRLayer extends EventTarget {}
  77284. interface XRSessionInit {
  77285. optionalFeatures?: string[];
  77286. requiredFeatures?: string[];
  77287. }
  77288. interface XRSessionEvent extends Event {
  77289. readonly session: XRSession;
  77290. }
  77291. interface XRSystem {
  77292. isSessionSupported: (sessionMode: XRSessionMode) => Promise<boolean>;
  77293. requestSession: (sessionMode: XRSessionMode, sessionInit?: any) => Promise<XRSession>;
  77294. }
  77295. interface XRViewport {
  77296. readonly x: number;
  77297. readonly y: number;
  77298. readonly width: number;
  77299. readonly height: number;
  77300. }
  77301. interface XRWebGLLayerInit {
  77302. antialias?: boolean;
  77303. depth?: boolean;
  77304. stencil?: boolean;
  77305. alpha?: boolean;
  77306. multiview?: boolean;
  77307. framebufferScaleFactor?: number;
  77308. }
  77309. declare class XRWebGLLayer {
  77310. static getNativeFramebufferScaleFactor(session: XRSession): number;
  77311. constructor(session: XRSession, context: WebGLRenderingContext | WebGL2RenderingContext, layerInit?: XRWebGLLayerInit);
  77312. readonly antialias: boolean;
  77313. readonly framebuffer: WebGLFramebuffer;
  77314. readonly framebufferWidth: number;
  77315. readonly framebufferHeight: number;
  77316. readonly ignoreDepthValues: boolean;
  77317. getViewport: (view: XRView) => XRViewport;
  77318. }
  77319. // tslint:disable-next-line no-empty-interface
  77320. interface XRSpace extends EventTarget {}
  77321. interface XRRenderState {
  77322. readonly baseLayer?: XRWebGLLayer;
  77323. readonly depthFar: number;
  77324. readonly depthNear: number;
  77325. readonly inlineVerticalFieldOfView?: number;
  77326. }
  77327. interface XRRenderStateInit extends XRRenderState {
  77328. baseLayer: XRWebGLLayer;
  77329. depthFar: number;
  77330. depthNear: number;
  77331. inlineVerticalFieldOfView?: number;
  77332. layers?: XRLayer[];
  77333. }
  77334. interface XRReferenceSpace extends XRSpace {
  77335. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  77336. onreset: XREventHandler;
  77337. }
  77338. interface XRBoundedReferenceSpace extends XRSpace {
  77339. readonly boundsGeometry: DOMPointReadOnly[];
  77340. }
  77341. interface XRInputSource {
  77342. readonly handedness: XRHandedness;
  77343. readonly targetRayMode: XRTargetRayMode;
  77344. readonly targetRaySpace: XRSpace;
  77345. readonly gripSpace?: XRSpace;
  77346. readonly gamepad?: Gamepad;
  77347. readonly profiles: Array<string>;
  77348. readonly hand?: XRHand;
  77349. }
  77350. interface XRPose {
  77351. readonly transform: XRRigidTransform;
  77352. readonly emulatedPosition: boolean;
  77353. }
  77354. interface XRFrame {
  77355. readonly session: XRSession;
  77356. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  77357. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  77358. // AR
  77359. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  77360. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  77361. // Anchors
  77362. trackedAnchors?: XRAnchorSet;
  77363. createAnchor?(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  77364. // Planes
  77365. worldInformation?: {
  77366. detectedPlanes?: XRPlaneSet;
  77367. };
  77368. // Hand tracking
  77369. getJointPose?(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  77370. }
  77371. interface XRInputSourceEvent extends Event {
  77372. readonly frame: XRFrame;
  77373. readonly inputSource: XRInputSource;
  77374. }
  77375. type XRInputSourceArray = XRInputSource[];
  77376. interface XRSession {
  77377. addEventListener(type: XREventType, listener: XREventHandler, options?: boolean | AddEventListenerOptions): void;
  77378. removeEventListener(type: XREventType, listener: XREventHandler, options?: boolean | EventListenerOptions): void;
  77379. /**
  77380. * Returns a list of this session's XRInputSources, each representing an input device
  77381. * used to control the camera and/or scene.
  77382. */
  77383. readonly inputSources: Array<XRInputSource>;
  77384. /**
  77385. * object which contains options affecting how the imagery is rendered.
  77386. * This includes things such as the near and far clipping planes
  77387. */
  77388. readonly renderState: XRRenderState;
  77389. readonly visibilityState: XRVisibilityState;
  77390. /**
  77391. * Removes a callback from the animation frame painting callback from
  77392. * XRSession's set of animation frame rendering callbacks, given the
  77393. * identifying handle returned by a previous call to requestAnimationFrame().
  77394. */
  77395. cancelAnimationFrame: (handle: number) => void;
  77396. /**
  77397. * Ends the WebXR session. Returns a promise which resolves when the
  77398. * session has been shut down.
  77399. */
  77400. end(): Promise<void>;
  77401. /**
  77402. * Schedules the specified method to be called the next time the user agent
  77403. * is working on rendering an animation frame for the WebXR device. Returns an
  77404. * integer value which can be used to identify the request for the purposes of
  77405. * canceling the callback using cancelAnimationFrame(). This method is comparable
  77406. * to the Window.requestAnimationFrame() method.
  77407. */
  77408. requestAnimationFrame: XRFrameRequestCallback;
  77409. /**
  77410. * Requests that a new XRReferenceSpace of the specified type be created.
  77411. * Returns a promise which resolves with the XRReferenceSpace or
  77412. * XRBoundedReferenceSpace which was requested, or throws a NotSupportedError if
  77413. * the requested space type isn't supported by the device.
  77414. */
  77415. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace | XRBoundedReferenceSpace>;
  77416. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  77417. onend: XREventHandler;
  77418. oninputsourceschange: XREventHandler;
  77419. onselect: XREventHandler;
  77420. onselectstart: XREventHandler;
  77421. onselectend: XREventHandler;
  77422. onsqueeze: XREventHandler;
  77423. onsqueezestart: XREventHandler;
  77424. onsqueezeend: XREventHandler;
  77425. onvisibilitychange: XREventHandler;
  77426. // hit test
  77427. requestHitTestSource?(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  77428. requestHitTestSourceForTransientInput?(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  77429. // legacy AR hit test
  77430. requestHitTest?(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  77431. // legacy plane detection
  77432. updateWorldTrackingState?(options: { planeDetectionState?: { enabled: boolean } }): void;
  77433. }
  77434. interface XRViewerPose extends XRPose {
  77435. readonly views: Array<XRView>;
  77436. }
  77437. declare class XRRigidTransform {
  77438. constructor(position?: DOMPointInit, direction?: DOMPointInit);
  77439. position: DOMPointReadOnly;
  77440. orientation: DOMPointReadOnly;
  77441. matrix: Float32Array;
  77442. inverse: XRRigidTransform;
  77443. }
  77444. interface XRView {
  77445. readonly eye: XREye;
  77446. readonly projectionMatrix: Float32Array;
  77447. readonly transform: XRRigidTransform;
  77448. readonly recommendedViewportScale?: number;
  77449. requestViewportScale(scale: number): void;
  77450. }
  77451. interface XRInputSourceChangeEvent extends Event {
  77452. session: XRSession;
  77453. removed: Array<XRInputSource>;
  77454. added: Array<XRInputSource>;
  77455. }
  77456. // Experimental/Draft features
  77457. declare class XRRay {
  77458. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  77459. origin: DOMPointReadOnly;
  77460. direction: DOMPointReadOnly;
  77461. matrix: Float32Array;
  77462. }
  77463. declare enum XRHitTestTrackableType {
  77464. "point",
  77465. "plane",
  77466. "mesh",
  77467. }
  77468. interface XRHitResult {
  77469. hitMatrix: Float32Array;
  77470. }
  77471. interface XRTransientInputHitTestResult {
  77472. readonly inputSource: XRInputSource;
  77473. readonly results: Array<XRHitTestResult>;
  77474. }
  77475. interface XRHitTestResult {
  77476. getPose(baseSpace: XRSpace): XRPose | undefined;
  77477. // When anchor system is enabled
  77478. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  77479. }
  77480. interface XRHitTestSource {
  77481. cancel(): void;
  77482. }
  77483. interface XRTransientInputHitTestSource {
  77484. cancel(): void;
  77485. }
  77486. interface XRHitTestOptionsInit {
  77487. space: XRSpace;
  77488. entityTypes?: Array<XRHitTestTrackableType>;
  77489. offsetRay?: XRRay;
  77490. }
  77491. interface XRTransientInputHitTestOptionsInit {
  77492. profile: string;
  77493. entityTypes?: Array<XRHitTestTrackableType>;
  77494. offsetRay?: XRRay;
  77495. }
  77496. interface XRAnchor {
  77497. anchorSpace: XRSpace;
  77498. delete(): void;
  77499. }
  77500. interface XRPlane {
  77501. orientation: "Horizontal" | "Vertical";
  77502. planeSpace: XRSpace;
  77503. polygon: Array<DOMPointReadOnly>;
  77504. lastChangedTime: number;
  77505. }
  77506. interface XRJointSpace extends XRSpace {}
  77507. interface XRJointPose extends XRPose {
  77508. radius: number | undefined;
  77509. }
  77510. interface XRHand extends Iterable<XRJointSpace> {
  77511. readonly length: number;
  77512. [index: number]: XRJointSpace;
  77513. readonly WRIST: number;
  77514. readonly THUMB_METACARPAL: number;
  77515. readonly THUMB_PHALANX_PROXIMAL: number;
  77516. readonly THUMB_PHALANX_DISTAL: number;
  77517. readonly THUMB_PHALANX_TIP: number;
  77518. readonly INDEX_METACARPAL: number;
  77519. readonly INDEX_PHALANX_PROXIMAL: number;
  77520. readonly INDEX_PHALANX_INTERMEDIATE: number;
  77521. readonly INDEX_PHALANX_DISTAL: number;
  77522. readonly INDEX_PHALANX_TIP: number;
  77523. readonly MIDDLE_METACARPAL: number;
  77524. readonly MIDDLE_PHALANX_PROXIMAL: number;
  77525. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  77526. readonly MIDDLE_PHALANX_DISTAL: number;
  77527. readonly MIDDLE_PHALANX_TIP: number;
  77528. readonly RING_METACARPAL: number;
  77529. readonly RING_PHALANX_PROXIMAL: number;
  77530. readonly RING_PHALANX_INTERMEDIATE: number;
  77531. readonly RING_PHALANX_DISTAL: number;
  77532. readonly RING_PHALANX_TIP: number;
  77533. readonly LITTLE_METACARPAL: number;
  77534. readonly LITTLE_PHALANX_PROXIMAL: number;
  77535. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  77536. readonly LITTLE_PHALANX_DISTAL: number;
  77537. readonly LITTLE_PHALANX_TIP: number;
  77538. }
  77539. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  77540. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  77541. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  77542. interface XRSession {
  77543. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  77544. }
  77545. interface XRFrame {
  77546. featurePointCloud? : Array<number>;
  77547. }
  77548. /**
  77549. * @ignore
  77550. */
  77551. declare module BABYLON.GLTF2.Exporter {
  77552. }
  77553. /**
  77554. * @ignore
  77555. */
  77556. declare module BABYLON.GLTF1 {
  77557. }
  77558. declare module BABYLON.GUI {
  77559. /**
  77560. * Class used to specific a value and its associated unit
  77561. */
  77562. export class ValueAndUnit {
  77563. /** defines the unit to store */
  77564. unit: number;
  77565. /** defines a boolean indicating if the value can be negative */
  77566. negativeValueAllowed: boolean;
  77567. private _value;
  77568. private _originalUnit;
  77569. /**
  77570. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  77571. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77572. */
  77573. ignoreAdaptiveScaling: boolean;
  77574. /**
  77575. * Creates a new ValueAndUnit
  77576. * @param value defines the value to store
  77577. * @param unit defines the unit to store
  77578. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  77579. */
  77580. constructor(value: number,
  77581. /** defines the unit to store */
  77582. unit?: number,
  77583. /** defines a boolean indicating if the value can be negative */
  77584. negativeValueAllowed?: boolean);
  77585. /** Gets a boolean indicating if the value is a percentage */
  77586. get isPercentage(): boolean;
  77587. /** Gets a boolean indicating if the value is store as pixel */
  77588. get isPixel(): boolean;
  77589. /** Gets direct internal value */
  77590. get internalValue(): number;
  77591. /**
  77592. * Gets value as pixel
  77593. * @param host defines the root host
  77594. * @param refValue defines the reference value for percentages
  77595. * @returns the value as pixel
  77596. */
  77597. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  77598. /**
  77599. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  77600. * @param value defines the value to store
  77601. * @param unit defines the unit to store
  77602. * @returns the current ValueAndUnit
  77603. */
  77604. updateInPlace(value: number, unit?: number): ValueAndUnit;
  77605. /**
  77606. * Gets the value accordingly to its unit
  77607. * @param host defines the root host
  77608. * @returns the value
  77609. */
  77610. getValue(host: AdvancedDynamicTexture): number;
  77611. /**
  77612. * Gets a string representation of the value
  77613. * @param host defines the root host
  77614. * @param decimals defines an optional number of decimals to display
  77615. * @returns a string
  77616. */
  77617. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  77618. /**
  77619. * Store a value parsed from a string
  77620. * @param source defines the source string
  77621. * @returns true if the value was successfully parsed
  77622. */
  77623. fromString(source: string | number): boolean;
  77624. private static _Regex;
  77625. private static _UNITMODE_PERCENTAGE;
  77626. private static _UNITMODE_PIXEL;
  77627. /** UNITMODE_PERCENTAGE */
  77628. static get UNITMODE_PERCENTAGE(): number;
  77629. /** UNITMODE_PIXEL */
  77630. static get UNITMODE_PIXEL(): number;
  77631. }
  77632. }
  77633. declare module BABYLON.GUI {
  77634. /**
  77635. * Define a style used by control to automatically setup properties based on a template.
  77636. * Only support font related properties so far
  77637. */
  77638. export class Style implements BABYLON.IDisposable {
  77639. private _fontFamily;
  77640. private _fontStyle;
  77641. private _fontWeight;
  77642. /** @hidden */
  77643. _host: AdvancedDynamicTexture;
  77644. /** @hidden */
  77645. _fontSize: ValueAndUnit;
  77646. /**
  77647. * BABYLON.Observable raised when the style values are changed
  77648. */
  77649. onChangedObservable: BABYLON.Observable<Style>;
  77650. /**
  77651. * Creates a new style object
  77652. * @param host defines the AdvancedDynamicTexture which hosts this style
  77653. */
  77654. constructor(host: AdvancedDynamicTexture);
  77655. /**
  77656. * Gets or sets the font size
  77657. */
  77658. get fontSize(): string | number;
  77659. set fontSize(value: string | number);
  77660. /**
  77661. * Gets or sets the font family
  77662. */
  77663. get fontFamily(): string;
  77664. set fontFamily(value: string);
  77665. /**
  77666. * Gets or sets the font style
  77667. */
  77668. get fontStyle(): string;
  77669. set fontStyle(value: string);
  77670. /** Gets or sets font weight */
  77671. get fontWeight(): string;
  77672. set fontWeight(value: string);
  77673. /** Dispose all associated resources */
  77674. dispose(): void;
  77675. }
  77676. }
  77677. declare module BABYLON.GUI {
  77678. /**
  77679. * Class used to transport BABYLON.Vector2 information for pointer events
  77680. */
  77681. export class Vector2WithInfo extends BABYLON.Vector2 {
  77682. /** defines the current mouse button index */
  77683. buttonIndex: number;
  77684. /**
  77685. * Creates a new Vector2WithInfo
  77686. * @param source defines the vector2 data to transport
  77687. * @param buttonIndex defines the current mouse button index
  77688. */
  77689. constructor(source: BABYLON.Vector2,
  77690. /** defines the current mouse button index */
  77691. buttonIndex?: number);
  77692. }
  77693. /** Class used to provide 2D matrix features */
  77694. export class Matrix2D {
  77695. /** Gets the internal array of 6 floats used to store matrix data */
  77696. m: Float32Array;
  77697. /**
  77698. * Creates a new matrix
  77699. * @param m00 defines value for (0, 0)
  77700. * @param m01 defines value for (0, 1)
  77701. * @param m10 defines value for (1, 0)
  77702. * @param m11 defines value for (1, 1)
  77703. * @param m20 defines value for (2, 0)
  77704. * @param m21 defines value for (2, 1)
  77705. */
  77706. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  77707. /**
  77708. * Fills the matrix from direct values
  77709. * @param m00 defines value for (0, 0)
  77710. * @param m01 defines value for (0, 1)
  77711. * @param m10 defines value for (1, 0)
  77712. * @param m11 defines value for (1, 1)
  77713. * @param m20 defines value for (2, 0)
  77714. * @param m21 defines value for (2, 1)
  77715. * @returns the current modified matrix
  77716. */
  77717. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  77718. /**
  77719. * Gets matrix determinant
  77720. * @returns the determinant
  77721. */
  77722. determinant(): number;
  77723. /**
  77724. * Inverses the matrix and stores it in a target matrix
  77725. * @param result defines the target matrix
  77726. * @returns the current matrix
  77727. */
  77728. invertToRef(result: Matrix2D): Matrix2D;
  77729. /**
  77730. * Multiplies the current matrix with another one
  77731. * @param other defines the second operand
  77732. * @param result defines the target matrix
  77733. * @returns the current matrix
  77734. */
  77735. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  77736. /**
  77737. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  77738. * @param x defines the x coordinate to transform
  77739. * @param y defines the x coordinate to transform
  77740. * @param result defines the target vector2
  77741. * @returns the current matrix
  77742. */
  77743. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  77744. /**
  77745. * Creates an identity matrix
  77746. * @returns a new matrix
  77747. */
  77748. static Identity(): Matrix2D;
  77749. /**
  77750. * Creates a translation matrix and stores it in a target matrix
  77751. * @param x defines the x coordinate of the translation
  77752. * @param y defines the y coordinate of the translation
  77753. * @param result defines the target matrix
  77754. */
  77755. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  77756. /**
  77757. * Creates a scaling matrix and stores it in a target matrix
  77758. * @param x defines the x coordinate of the scaling
  77759. * @param y defines the y coordinate of the scaling
  77760. * @param result defines the target matrix
  77761. */
  77762. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  77763. /**
  77764. * Creates a rotation matrix and stores it in a target matrix
  77765. * @param angle defines the rotation angle
  77766. * @param result defines the target matrix
  77767. */
  77768. static RotationToRef(angle: number, result: Matrix2D): void;
  77769. private static _TempPreTranslationMatrix;
  77770. private static _TempPostTranslationMatrix;
  77771. private static _TempRotationMatrix;
  77772. private static _TempScalingMatrix;
  77773. private static _TempCompose0;
  77774. private static _TempCompose1;
  77775. private static _TempCompose2;
  77776. /**
  77777. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  77778. * @param tx defines the x coordinate of the translation
  77779. * @param ty defines the y coordinate of the translation
  77780. * @param angle defines the rotation angle
  77781. * @param scaleX defines the x coordinate of the scaling
  77782. * @param scaleY defines the y coordinate of the scaling
  77783. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  77784. * @param result defines the target matrix
  77785. */
  77786. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  77787. }
  77788. }
  77789. declare module BABYLON.GUI {
  77790. /**
  77791. * Class used to store 2D control sizes
  77792. */
  77793. export class Measure {
  77794. /** defines left coordinate */
  77795. left: number;
  77796. /** defines top coordinate */
  77797. top: number;
  77798. /** defines width dimension */
  77799. width: number;
  77800. /** defines height dimension */
  77801. height: number;
  77802. /**
  77803. * Creates a new measure
  77804. * @param left defines left coordinate
  77805. * @param top defines top coordinate
  77806. * @param width defines width dimension
  77807. * @param height defines height dimension
  77808. */
  77809. constructor(
  77810. /** defines left coordinate */
  77811. left: number,
  77812. /** defines top coordinate */
  77813. top: number,
  77814. /** defines width dimension */
  77815. width: number,
  77816. /** defines height dimension */
  77817. height: number);
  77818. /**
  77819. * Copy from another measure
  77820. * @param other defines the other measure to copy from
  77821. */
  77822. copyFrom(other: Measure): void;
  77823. /**
  77824. * Copy from a group of 4 floats
  77825. * @param left defines left coordinate
  77826. * @param top defines top coordinate
  77827. * @param width defines width dimension
  77828. * @param height defines height dimension
  77829. */
  77830. copyFromFloats(left: number, top: number, width: number, height: number): void;
  77831. /**
  77832. * Computes the axis aligned bounding box measure for two given measures
  77833. * @param a Input measure
  77834. * @param b Input measure
  77835. * @param result the resulting bounding measure
  77836. */
  77837. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  77838. /**
  77839. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  77840. * @param transform the matrix to transform the measure before computing the AABB
  77841. * @param addX number to add to left
  77842. * @param addY number to add to top
  77843. * @param addWidth number to add to width
  77844. * @param addHeight number to add to height
  77845. * @param result the resulting AABB
  77846. */
  77847. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  77848. /**
  77849. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  77850. * @param transform the matrix to transform the measure before computing the AABB
  77851. * @param result the resulting AABB
  77852. */
  77853. transformToRef(transform: Matrix2D, result: Measure): void;
  77854. /**
  77855. * Check equality between this measure and another one
  77856. * @param other defines the other measures
  77857. * @returns true if both measures are equals
  77858. */
  77859. isEqualsTo(other: Measure): boolean;
  77860. /**
  77861. * Creates an empty measure
  77862. * @returns a new measure
  77863. */
  77864. static Empty(): Measure;
  77865. }
  77866. }
  77867. declare module BABYLON.GUI {
  77868. /**
  77869. * Interface used to define a control that can receive focus
  77870. */
  77871. export interface IFocusableControl {
  77872. /**
  77873. * Function called when the control receives the focus
  77874. */
  77875. onFocus(): void;
  77876. /**
  77877. * Function called when the control loses the focus
  77878. */
  77879. onBlur(): void;
  77880. /**
  77881. * Function called to let the control handle keyboard events
  77882. * @param evt defines the current keyboard event
  77883. */
  77884. processKeyboard(evt: KeyboardEvent): void;
  77885. /**
  77886. * Function called to get the list of controls that should not steal the focus from this control
  77887. * @returns an array of controls
  77888. */
  77889. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  77890. }
  77891. /**
  77892. * Class used to create texture to support 2D GUI elements
  77893. * @see https://doc.babylonjs.com/how_to/gui
  77894. */
  77895. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  77896. private _isDirty;
  77897. private _renderObserver;
  77898. private _resizeObserver;
  77899. private _preKeyboardObserver;
  77900. private _pointerMoveObserver;
  77901. private _pointerObserver;
  77902. private _canvasPointerOutObserver;
  77903. private _canvasBlurObserver;
  77904. private _background;
  77905. /** @hidden */
  77906. _rootContainer: Container;
  77907. /** @hidden */
  77908. _lastPickedControl: Control;
  77909. /** @hidden */
  77910. _lastControlOver: {
  77911. [pointerId: number]: Control;
  77912. };
  77913. /** @hidden */
  77914. _lastControlDown: {
  77915. [pointerId: number]: Control;
  77916. };
  77917. /** @hidden */
  77918. _capturingControl: {
  77919. [pointerId: number]: Control;
  77920. };
  77921. /** @hidden */
  77922. _shouldBlockPointer: boolean;
  77923. /** @hidden */
  77924. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  77925. /** @hidden */
  77926. _linkedControls: Control[];
  77927. private _isFullscreen;
  77928. private _fullscreenViewport;
  77929. private _idealWidth;
  77930. private _idealHeight;
  77931. private _useSmallestIdeal;
  77932. private _renderAtIdealSize;
  77933. private _focusedControl;
  77934. private _blockNextFocusCheck;
  77935. private _renderScale;
  77936. private _rootElement;
  77937. private _cursorChanged;
  77938. private _defaultMousePointerId;
  77939. /** @hidden */
  77940. _numLayoutCalls: number;
  77941. /** Gets the number of layout calls made the last time the ADT has been rendered */
  77942. get numLayoutCalls(): number;
  77943. /** @hidden */
  77944. _numRenderCalls: number;
  77945. /** Gets the number of render calls made the last time the ADT has been rendered */
  77946. get numRenderCalls(): number;
  77947. /**
  77948. * Define type to string to ensure compatibility across browsers
  77949. * Safari doesn't support DataTransfer constructor
  77950. */
  77951. private _clipboardData;
  77952. /**
  77953. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  77954. */
  77955. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  77956. /**
  77957. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  77958. */
  77959. onControlPickedObservable: BABYLON.Observable<Control>;
  77960. /**
  77961. * BABYLON.Observable event triggered before layout is evaluated
  77962. */
  77963. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77964. /**
  77965. * BABYLON.Observable event triggered after the layout was evaluated
  77966. */
  77967. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77968. /**
  77969. * BABYLON.Observable event triggered before the texture is rendered
  77970. */
  77971. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77972. /**
  77973. * BABYLON.Observable event triggered after the texture was rendered
  77974. */
  77975. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77976. /**
  77977. * Gets or sets a boolean defining if alpha is stored as premultiplied
  77978. */
  77979. premulAlpha: boolean;
  77980. /**
  77981. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  77982. * Useful when you want more antialiasing
  77983. */
  77984. get renderScale(): number;
  77985. set renderScale(value: number);
  77986. /** Gets or sets the background color */
  77987. get background(): string;
  77988. set background(value: string);
  77989. /**
  77990. * Gets or sets the ideal width used to design controls.
  77991. * The GUI will then rescale everything accordingly
  77992. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77993. */
  77994. get idealWidth(): number;
  77995. set idealWidth(value: number);
  77996. /**
  77997. * Gets or sets the ideal height used to design controls.
  77998. * The GUI will then rescale everything accordingly
  77999. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78000. */
  78001. get idealHeight(): number;
  78002. set idealHeight(value: number);
  78003. /**
  78004. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  78005. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78006. */
  78007. get useSmallestIdeal(): boolean;
  78008. set useSmallestIdeal(value: boolean);
  78009. /**
  78010. * Gets or sets a boolean indicating if adaptive scaling must be used
  78011. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78012. */
  78013. get renderAtIdealSize(): boolean;
  78014. set renderAtIdealSize(value: boolean);
  78015. /**
  78016. * Gets the ratio used when in "ideal mode"
  78017. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78018. * */
  78019. get idealRatio(): number;
  78020. /**
  78021. * Gets the underlying layer used to render the texture when in fullscreen mode
  78022. */
  78023. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  78024. /**
  78025. * Gets the root container control
  78026. */
  78027. get rootContainer(): Container;
  78028. /**
  78029. * Returns an array containing the root container.
  78030. * This is mostly used to let the Inspector introspects the ADT
  78031. * @returns an array containing the rootContainer
  78032. */
  78033. getChildren(): Array<Container>;
  78034. /**
  78035. * Will return all controls that are inside this texture
  78036. * @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
  78037. * @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
  78038. * @return all child controls
  78039. */
  78040. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  78041. /**
  78042. * Gets or sets the current focused control
  78043. */
  78044. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  78045. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  78046. /**
  78047. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  78048. */
  78049. get isForeground(): boolean;
  78050. set isForeground(value: boolean);
  78051. /**
  78052. * Gets or set information about clipboardData
  78053. */
  78054. get clipboardData(): string;
  78055. set clipboardData(value: string);
  78056. /**
  78057. * Creates a new AdvancedDynamicTexture
  78058. * @param name defines the name of the texture
  78059. * @param width defines the width of the texture
  78060. * @param height defines the height of the texture
  78061. * @param scene defines the hosting scene
  78062. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  78063. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  78064. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  78065. */
  78066. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number, invertY?: boolean);
  78067. /**
  78068. * Get the current class name of the texture useful for serialization or dynamic coding.
  78069. * @returns "AdvancedDynamicTexture"
  78070. */
  78071. getClassName(): string;
  78072. /**
  78073. * Function used to execute a function on all controls
  78074. * @param func defines the function to execute
  78075. * @param container defines the container where controls belong. If null the root container will be used
  78076. */
  78077. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  78078. private _useInvalidateRectOptimization;
  78079. /**
  78080. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  78081. */
  78082. get useInvalidateRectOptimization(): boolean;
  78083. set useInvalidateRectOptimization(value: boolean);
  78084. private _invalidatedRectangle;
  78085. /**
  78086. * Invalidates a rectangle area on the gui texture
  78087. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  78088. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  78089. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  78090. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  78091. */
  78092. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  78093. /**
  78094. * Marks the texture as dirty forcing a complete update
  78095. */
  78096. markAsDirty(): void;
  78097. /**
  78098. * Helper function used to create a new style
  78099. * @returns a new style
  78100. * @see https://doc.babylonjs.com/how_to/gui#styles
  78101. */
  78102. createStyle(): Style;
  78103. /**
  78104. * Adds a new control to the root container
  78105. * @param control defines the control to add
  78106. * @returns the current texture
  78107. */
  78108. addControl(control: Control): AdvancedDynamicTexture;
  78109. /**
  78110. * Removes a control from the root container
  78111. * @param control defines the control to remove
  78112. * @returns the current texture
  78113. */
  78114. removeControl(control: Control): AdvancedDynamicTexture;
  78115. /**
  78116. * Release all resources
  78117. */
  78118. dispose(): void;
  78119. private _onResize;
  78120. /** @hidden */
  78121. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  78122. /**
  78123. * Get screen coordinates for a vector3
  78124. * @param position defines the position to project
  78125. * @param worldMatrix defines the world matrix to use
  78126. * @returns the projected position
  78127. */
  78128. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  78129. private _checkUpdate;
  78130. private _clearMeasure;
  78131. private _render;
  78132. /** @hidden */
  78133. _changeCursor(cursor: string): void;
  78134. /** @hidden */
  78135. _registerLastControlDown(control: Control, pointerId: number): void;
  78136. private _doPicking;
  78137. /** @hidden */
  78138. _cleanControlAfterRemovalFromList(list: {
  78139. [pointerId: number]: Control;
  78140. }, control: Control): void;
  78141. /** @hidden */
  78142. _cleanControlAfterRemoval(control: Control): void;
  78143. /** Attach to all scene events required to support pointer events */
  78144. attach(): void;
  78145. /** @hidden */
  78146. private onClipboardCopy;
  78147. /** @hidden */
  78148. private onClipboardCut;
  78149. /** @hidden */
  78150. private onClipboardPaste;
  78151. /**
  78152. * Register the clipboard Events onto the canvas
  78153. */
  78154. registerClipboardEvents(): void;
  78155. /**
  78156. * Unregister the clipboard Events from the canvas
  78157. */
  78158. unRegisterClipboardEvents(): void;
  78159. /**
  78160. * Connect the texture to a hosting mesh to enable interactions
  78161. * @param mesh defines the mesh to attach to
  78162. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  78163. */
  78164. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  78165. /**
  78166. * Move the focus to a specific control
  78167. * @param control defines the control which will receive the focus
  78168. */
  78169. moveFocusToControl(control: IFocusableControl): void;
  78170. private _manageFocus;
  78171. private _attachToOnPointerOut;
  78172. private _attachToOnBlur;
  78173. /**
  78174. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  78175. * @param mesh defines the mesh which will receive the texture
  78176. * @param width defines the texture width (1024 by default)
  78177. * @param height defines the texture height (1024 by default)
  78178. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  78179. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  78180. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  78181. * @returns a new AdvancedDynamicTexture
  78182. */
  78183. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  78184. /**
  78185. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  78186. * In this mode the texture will rely on a layer for its rendering.
  78187. * This allows it to be treated like any other layer.
  78188. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  78189. * LayerMask is set through advancedTexture.layer.layerMask
  78190. * @param name defines name for the texture
  78191. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  78192. * @param scene defines the hsoting scene
  78193. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  78194. * @returns a new AdvancedDynamicTexture
  78195. */
  78196. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  78197. }
  78198. }
  78199. declare module BABYLON.GUI {
  78200. /**
  78201. * Root class used for all 2D controls
  78202. * @see https://doc.babylonjs.com/how_to/gui#controls
  78203. */
  78204. export class Control {
  78205. /** defines the name of the control */
  78206. name?: string | undefined;
  78207. /**
  78208. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  78209. */
  78210. static AllowAlphaInheritance: boolean;
  78211. private _alpha;
  78212. private _alphaSet;
  78213. private _zIndex;
  78214. /** @hidden */
  78215. _host: AdvancedDynamicTexture;
  78216. /** Gets or sets the control parent */
  78217. parent: BABYLON.Nullable<Container>;
  78218. /** @hidden */
  78219. _currentMeasure: Measure;
  78220. private _fontFamily;
  78221. private _fontStyle;
  78222. private _fontWeight;
  78223. private _fontSize;
  78224. private _font;
  78225. /** @hidden */
  78226. _width: ValueAndUnit;
  78227. /** @hidden */
  78228. _height: ValueAndUnit;
  78229. /** @hidden */
  78230. protected _fontOffset: {
  78231. ascent: number;
  78232. height: number;
  78233. descent: number;
  78234. };
  78235. private _color;
  78236. private _style;
  78237. private _styleObserver;
  78238. /** @hidden */
  78239. protected _horizontalAlignment: number;
  78240. /** @hidden */
  78241. protected _verticalAlignment: number;
  78242. /** @hidden */
  78243. protected _isDirty: boolean;
  78244. /** @hidden */
  78245. protected _wasDirty: boolean;
  78246. /** @hidden */
  78247. _tempParentMeasure: Measure;
  78248. /** @hidden */
  78249. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  78250. /** @hidden */
  78251. protected _cachedParentMeasure: Measure;
  78252. private _paddingLeft;
  78253. private _paddingRight;
  78254. private _paddingTop;
  78255. private _paddingBottom;
  78256. /** @hidden */
  78257. _left: ValueAndUnit;
  78258. /** @hidden */
  78259. _top: ValueAndUnit;
  78260. private _scaleX;
  78261. private _scaleY;
  78262. private _rotation;
  78263. private _transformCenterX;
  78264. private _transformCenterY;
  78265. /** @hidden */
  78266. _transformMatrix: Matrix2D;
  78267. /** @hidden */
  78268. protected _invertTransformMatrix: Matrix2D;
  78269. /** @hidden */
  78270. protected _transformedPosition: BABYLON.Vector2;
  78271. private _isMatrixDirty;
  78272. private _cachedOffsetX;
  78273. private _cachedOffsetY;
  78274. private _isVisible;
  78275. private _isHighlighted;
  78276. /** @hidden */
  78277. _linkedMesh: BABYLON.Nullable<BABYLON.TransformNode>;
  78278. private _fontSet;
  78279. private _dummyVector2;
  78280. private _downCount;
  78281. private _enterCount;
  78282. private _doNotRender;
  78283. private _downPointerIds;
  78284. protected _isEnabled: boolean;
  78285. protected _disabledColor: string;
  78286. protected _disabledColorItem: string;
  78287. /** @hidden */
  78288. protected _rebuildLayout: boolean;
  78289. /** @hidden */
  78290. _customData: any;
  78291. /** @hidden */
  78292. _isClipped: boolean;
  78293. /** @hidden */
  78294. _automaticSize: boolean;
  78295. /** @hidden */
  78296. _tag: any;
  78297. /**
  78298. * 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
  78299. */
  78300. uniqueId: number;
  78301. /**
  78302. * Gets or sets an object used to store user defined information for the node
  78303. */
  78304. metadata: any;
  78305. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  78306. isHitTestVisible: boolean;
  78307. /** Gets or sets a boolean indicating if the control can block pointer events */
  78308. isPointerBlocker: boolean;
  78309. /** Gets or sets a boolean indicating if the control can be focusable */
  78310. isFocusInvisible: boolean;
  78311. /**
  78312. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  78313. * 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
  78314. */
  78315. clipChildren: boolean;
  78316. /**
  78317. * Gets or sets a boolean indicating that control content must be clipped
  78318. * 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
  78319. */
  78320. clipContent: boolean;
  78321. /**
  78322. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  78323. */
  78324. useBitmapCache: boolean;
  78325. private _cacheData;
  78326. private _shadowOffsetX;
  78327. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  78328. get shadowOffsetX(): number;
  78329. set shadowOffsetX(value: number);
  78330. private _shadowOffsetY;
  78331. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  78332. get shadowOffsetY(): number;
  78333. set shadowOffsetY(value: number);
  78334. private _shadowBlur;
  78335. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  78336. get shadowBlur(): number;
  78337. set shadowBlur(value: number);
  78338. private _shadowColor;
  78339. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  78340. get shadowColor(): string;
  78341. set shadowColor(value: string);
  78342. /** Gets or sets the cursor to use when the control is hovered */
  78343. hoverCursor: string;
  78344. /** @hidden */
  78345. protected _linkOffsetX: ValueAndUnit;
  78346. /** @hidden */
  78347. protected _linkOffsetY: ValueAndUnit;
  78348. /** Gets the control type name */
  78349. get typeName(): string;
  78350. /**
  78351. * Get the current class name of the control.
  78352. * @returns current class name
  78353. */
  78354. getClassName(): string;
  78355. /**
  78356. * An event triggered when pointer wheel is scrolled
  78357. */
  78358. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  78359. /**
  78360. * An event triggered when the pointer move over the control.
  78361. */
  78362. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  78363. /**
  78364. * An event triggered when the pointer move out of the control.
  78365. */
  78366. onPointerOutObservable: BABYLON.Observable<Control>;
  78367. /**
  78368. * An event triggered when the pointer taps the control
  78369. */
  78370. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  78371. /**
  78372. * An event triggered when pointer up
  78373. */
  78374. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  78375. /**
  78376. * An event triggered when a control is clicked on
  78377. */
  78378. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  78379. /**
  78380. * An event triggered when pointer enters the control
  78381. */
  78382. onPointerEnterObservable: BABYLON.Observable<Control>;
  78383. /**
  78384. * An event triggered when the control is marked as dirty
  78385. */
  78386. onDirtyObservable: BABYLON.Observable<Control>;
  78387. /**
  78388. * An event triggered before drawing the control
  78389. */
  78390. onBeforeDrawObservable: BABYLON.Observable<Control>;
  78391. /**
  78392. * An event triggered after the control was drawn
  78393. */
  78394. onAfterDrawObservable: BABYLON.Observable<Control>;
  78395. /**
  78396. * An event triggered when the control has been disposed
  78397. */
  78398. onDisposeObservable: BABYLON.Observable<Control>;
  78399. /**
  78400. * Get the hosting AdvancedDynamicTexture
  78401. */
  78402. get host(): AdvancedDynamicTexture;
  78403. /** Gets or set information about font offsets (used to render and align text) */
  78404. get fontOffset(): {
  78405. ascent: number;
  78406. height: number;
  78407. descent: number;
  78408. };
  78409. set fontOffset(offset: {
  78410. ascent: number;
  78411. height: number;
  78412. descent: number;
  78413. });
  78414. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  78415. get alpha(): number;
  78416. set alpha(value: number);
  78417. /**
  78418. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  78419. */
  78420. get isHighlighted(): boolean;
  78421. set isHighlighted(value: boolean);
  78422. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  78423. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78424. */
  78425. get scaleX(): number;
  78426. set scaleX(value: number);
  78427. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  78428. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78429. */
  78430. get scaleY(): number;
  78431. set scaleY(value: number);
  78432. /** Gets or sets the rotation angle (0 by default)
  78433. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78434. */
  78435. get rotation(): number;
  78436. set rotation(value: number);
  78437. /** Gets or sets the transformation center on Y axis (0 by default)
  78438. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78439. */
  78440. get transformCenterY(): number;
  78441. set transformCenterY(value: number);
  78442. /** Gets or sets the transformation center on X axis (0 by default)
  78443. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78444. */
  78445. get transformCenterX(): number;
  78446. set transformCenterX(value: number);
  78447. /**
  78448. * Gets or sets the horizontal alignment
  78449. * @see https://doc.babylonjs.com/how_to/gui#alignments
  78450. */
  78451. get horizontalAlignment(): number;
  78452. set horizontalAlignment(value: number);
  78453. /**
  78454. * Gets or sets the vertical alignment
  78455. * @see https://doc.babylonjs.com/how_to/gui#alignments
  78456. */
  78457. get verticalAlignment(): number;
  78458. set verticalAlignment(value: number);
  78459. /**
  78460. * Gets or sets a fixed ratio for this control.
  78461. * When different from 0, the ratio is used to compute the "second" dimension.
  78462. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  78463. * second dimension is computed as first dimension * fixedRatio
  78464. */
  78465. fixedRatio: number;
  78466. private _fixedRatioMasterIsWidth;
  78467. /**
  78468. * Gets or sets control width
  78469. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78470. */
  78471. get width(): string | number;
  78472. set width(value: string | number);
  78473. /**
  78474. * Gets or sets the control width in pixel
  78475. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78476. */
  78477. get widthInPixels(): number;
  78478. set widthInPixels(value: number);
  78479. /**
  78480. * Gets or sets control height
  78481. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78482. */
  78483. get height(): string | number;
  78484. set height(value: string | number);
  78485. /**
  78486. * Gets or sets control height in pixel
  78487. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78488. */
  78489. get heightInPixels(): number;
  78490. set heightInPixels(value: number);
  78491. /** Gets or set font family */
  78492. get fontFamily(): string;
  78493. set fontFamily(value: string);
  78494. /** Gets or sets font style */
  78495. get fontStyle(): string;
  78496. set fontStyle(value: string);
  78497. /** Gets or sets font weight */
  78498. get fontWeight(): string;
  78499. set fontWeight(value: string);
  78500. /**
  78501. * Gets or sets style
  78502. * @see https://doc.babylonjs.com/how_to/gui#styles
  78503. */
  78504. get style(): BABYLON.Nullable<Style>;
  78505. set style(value: BABYLON.Nullable<Style>);
  78506. /** @hidden */
  78507. get _isFontSizeInPercentage(): boolean;
  78508. /** Gets or sets font size in pixels */
  78509. get fontSizeInPixels(): number;
  78510. set fontSizeInPixels(value: number);
  78511. /** Gets or sets font size */
  78512. get fontSize(): string | number;
  78513. set fontSize(value: string | number);
  78514. /** Gets or sets foreground color */
  78515. get color(): string;
  78516. set color(value: string);
  78517. /** Gets or sets z index which is used to reorder controls on the z axis */
  78518. get zIndex(): number;
  78519. set zIndex(value: number);
  78520. /** Gets or sets a boolean indicating if the control can be rendered */
  78521. get notRenderable(): boolean;
  78522. set notRenderable(value: boolean);
  78523. /** Gets or sets a boolean indicating if the control is visible */
  78524. get isVisible(): boolean;
  78525. set isVisible(value: boolean);
  78526. /** Gets a boolean indicating that the control needs to update its rendering */
  78527. get isDirty(): boolean;
  78528. /**
  78529. * Gets the current linked mesh (or null if none)
  78530. */
  78531. get linkedMesh(): BABYLON.Nullable<BABYLON.TransformNode>;
  78532. /**
  78533. * Gets or sets a value indicating the padding to use on the left of the control
  78534. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78535. */
  78536. get paddingLeft(): string | number;
  78537. set paddingLeft(value: string | number);
  78538. /**
  78539. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  78540. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78541. */
  78542. get paddingLeftInPixels(): number;
  78543. set paddingLeftInPixels(value: number);
  78544. /**
  78545. * Gets or sets a value indicating the padding to use on the right of the control
  78546. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78547. */
  78548. get paddingRight(): string | number;
  78549. set paddingRight(value: string | number);
  78550. /**
  78551. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  78552. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78553. */
  78554. get paddingRightInPixels(): number;
  78555. set paddingRightInPixels(value: number);
  78556. /**
  78557. * Gets or sets a value indicating the padding to use on the top of the control
  78558. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78559. */
  78560. get paddingTop(): string | number;
  78561. set paddingTop(value: string | number);
  78562. /**
  78563. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  78564. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78565. */
  78566. get paddingTopInPixels(): number;
  78567. set paddingTopInPixels(value: number);
  78568. /**
  78569. * Gets or sets a value indicating the padding to use on the bottom of the control
  78570. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78571. */
  78572. get paddingBottom(): string | number;
  78573. set paddingBottom(value: string | number);
  78574. /**
  78575. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  78576. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78577. */
  78578. get paddingBottomInPixels(): number;
  78579. set paddingBottomInPixels(value: number);
  78580. /**
  78581. * Gets or sets a value indicating the left coordinate of the control
  78582. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78583. */
  78584. get left(): string | number;
  78585. set left(value: string | number);
  78586. /**
  78587. * Gets or sets a value indicating the left coordinate in pixels of the control
  78588. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78589. */
  78590. get leftInPixels(): number;
  78591. set leftInPixels(value: number);
  78592. /**
  78593. * Gets or sets a value indicating the top coordinate of the control
  78594. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78595. */
  78596. get top(): string | number;
  78597. set top(value: string | number);
  78598. /**
  78599. * Gets or sets a value indicating the top coordinate in pixels of the control
  78600. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78601. */
  78602. get topInPixels(): number;
  78603. set topInPixels(value: number);
  78604. /**
  78605. * Gets or sets a value indicating the offset on X axis to the linked mesh
  78606. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78607. */
  78608. get linkOffsetX(): string | number;
  78609. set linkOffsetX(value: string | number);
  78610. /**
  78611. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  78612. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78613. */
  78614. get linkOffsetXInPixels(): number;
  78615. set linkOffsetXInPixels(value: number);
  78616. /**
  78617. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  78618. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78619. */
  78620. get linkOffsetY(): string | number;
  78621. set linkOffsetY(value: string | number);
  78622. /**
  78623. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  78624. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78625. */
  78626. get linkOffsetYInPixels(): number;
  78627. set linkOffsetYInPixels(value: number);
  78628. /** Gets the center coordinate on X axis */
  78629. get centerX(): number;
  78630. /** Gets the center coordinate on Y axis */
  78631. get centerY(): number;
  78632. /** Gets or sets if control is Enabled*/
  78633. get isEnabled(): boolean;
  78634. set isEnabled(value: boolean);
  78635. /** Gets or sets background color of control if it's disabled*/
  78636. get disabledColor(): string;
  78637. set disabledColor(value: string);
  78638. /** Gets or sets front color of control if it's disabled*/
  78639. get disabledColorItem(): string;
  78640. set disabledColorItem(value: string);
  78641. /**
  78642. * Creates a new control
  78643. * @param name defines the name of the control
  78644. */
  78645. constructor(
  78646. /** defines the name of the control */
  78647. name?: string | undefined);
  78648. /** @hidden */
  78649. protected _getTypeName(): string;
  78650. /**
  78651. * Gets the first ascendant in the hierarchy of the given type
  78652. * @param className defines the required type
  78653. * @returns the ascendant or null if not found
  78654. */
  78655. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  78656. /** @hidden */
  78657. _resetFontCache(): void;
  78658. /**
  78659. * Determines if a container is an ascendant of the current control
  78660. * @param container defines the container to look for
  78661. * @returns true if the container is one of the ascendant of the control
  78662. */
  78663. isAscendant(container: Control): boolean;
  78664. /**
  78665. * Gets coordinates in local control space
  78666. * @param globalCoordinates defines the coordinates to transform
  78667. * @returns the new coordinates in local space
  78668. */
  78669. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  78670. /**
  78671. * Gets coordinates in local control space
  78672. * @param globalCoordinates defines the coordinates to transform
  78673. * @param result defines the target vector2 where to store the result
  78674. * @returns the current control
  78675. */
  78676. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  78677. /**
  78678. * Gets coordinates in parent local control space
  78679. * @param globalCoordinates defines the coordinates to transform
  78680. * @returns the new coordinates in parent local space
  78681. */
  78682. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  78683. /**
  78684. * Move the current control to a vector3 position projected onto the screen.
  78685. * @param position defines the target position
  78686. * @param scene defines the hosting scene
  78687. */
  78688. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  78689. /**
  78690. * Will store all controls that have this control as ascendant in a given array
  78691. * @param results defines the array where to store the descendants
  78692. * @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
  78693. * @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
  78694. */
  78695. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  78696. /**
  78697. * Will return all controls that have this control as ascendant
  78698. * @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
  78699. * @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
  78700. * @return all child controls
  78701. */
  78702. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  78703. /**
  78704. * Link current control with a target mesh
  78705. * @param mesh defines the mesh to link with
  78706. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78707. */
  78708. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.TransformNode>): void;
  78709. /** @hidden */
  78710. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  78711. /** @hidden */
  78712. _offsetLeft(offset: number): void;
  78713. /** @hidden */
  78714. _offsetTop(offset: number): void;
  78715. /** @hidden */
  78716. _markMatrixAsDirty(): void;
  78717. /** @hidden */
  78718. _flagDescendantsAsMatrixDirty(): void;
  78719. /** @hidden */
  78720. _intersectsRect(rect: Measure): boolean;
  78721. /** @hidden */
  78722. protected invalidateRect(): void;
  78723. /** @hidden */
  78724. _markAsDirty(force?: boolean): void;
  78725. /** @hidden */
  78726. _markAllAsDirty(): void;
  78727. /** @hidden */
  78728. _link(host: AdvancedDynamicTexture): void;
  78729. /** @hidden */
  78730. protected _transform(context?: CanvasRenderingContext2D): void;
  78731. /** @hidden */
  78732. _renderHighlight(context: CanvasRenderingContext2D): void;
  78733. /** @hidden */
  78734. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  78735. /** @hidden */
  78736. protected _applyStates(context: CanvasRenderingContext2D): void;
  78737. /** @hidden */
  78738. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  78739. /** @hidden */
  78740. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78741. protected _evaluateClippingState(parentMeasure: Measure): void;
  78742. /** @hidden */
  78743. _measure(): void;
  78744. /** @hidden */
  78745. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78746. /** @hidden */
  78747. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78748. /** @hidden */
  78749. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78750. /** @hidden */
  78751. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  78752. private static _ClipMeasure;
  78753. private _tmpMeasureA;
  78754. private _clip;
  78755. /** @hidden */
  78756. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  78757. /** @hidden */
  78758. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78759. /**
  78760. * Tests if a given coordinates belong to the current control
  78761. * @param x defines x coordinate to test
  78762. * @param y defines y coordinate to test
  78763. * @returns true if the coordinates are inside the control
  78764. */
  78765. contains(x: number, y: number): boolean;
  78766. /** @hidden */
  78767. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78768. /** @hidden */
  78769. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  78770. /** @hidden */
  78771. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  78772. /** @hidden */
  78773. _onPointerOut(target: Control, pi: BABYLON.Nullable<BABYLON.PointerInfoBase>, force?: boolean): void;
  78774. /** @hidden */
  78775. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  78776. /** @hidden */
  78777. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi?: BABYLON.PointerInfoBase): void;
  78778. /** @hidden */
  78779. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  78780. /** @hidden */
  78781. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  78782. /** @hidden */
  78783. _onCanvasBlur(): void;
  78784. /** @hidden */
  78785. _processObservables(type: number, x: number, y: number, pi: BABYLON.PointerInfoBase, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78786. private _prepareFont;
  78787. /** Releases associated resources */
  78788. dispose(): void;
  78789. private static _HORIZONTAL_ALIGNMENT_LEFT;
  78790. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  78791. private static _HORIZONTAL_ALIGNMENT_CENTER;
  78792. private static _VERTICAL_ALIGNMENT_TOP;
  78793. private static _VERTICAL_ALIGNMENT_BOTTOM;
  78794. private static _VERTICAL_ALIGNMENT_CENTER;
  78795. /** HORIZONTAL_ALIGNMENT_LEFT */
  78796. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  78797. /** HORIZONTAL_ALIGNMENT_RIGHT */
  78798. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  78799. /** HORIZONTAL_ALIGNMENT_CENTER */
  78800. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  78801. /** VERTICAL_ALIGNMENT_TOP */
  78802. static get VERTICAL_ALIGNMENT_TOP(): number;
  78803. /** VERTICAL_ALIGNMENT_BOTTOM */
  78804. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  78805. /** VERTICAL_ALIGNMENT_CENTER */
  78806. static get VERTICAL_ALIGNMENT_CENTER(): number;
  78807. private static _FontHeightSizes;
  78808. /** @hidden */
  78809. static _GetFontOffset(font: string): {
  78810. ascent: number;
  78811. height: number;
  78812. descent: number;
  78813. };
  78814. /**
  78815. * Creates a stack panel that can be used to render headers
  78816. * @param control defines the control to associate with the header
  78817. * @param text defines the text of the header
  78818. * @param size defines the size of the header
  78819. * @param options defines options used to configure the header
  78820. * @returns a new StackPanel
  78821. * @ignore
  78822. * @hidden
  78823. */
  78824. static AddHeader: (control: Control, text: string, size: string | number, options: {
  78825. isHorizontal: boolean;
  78826. controlFirst: boolean;
  78827. }) => any;
  78828. /** @hidden */
  78829. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  78830. }
  78831. }
  78832. declare module BABYLON.GUI {
  78833. /**
  78834. * Root class for 2D containers
  78835. * @see https://doc.babylonjs.com/how_to/gui#containers
  78836. */
  78837. export class Container extends Control {
  78838. name?: string | undefined;
  78839. /** @hidden */
  78840. _children: Control[];
  78841. /** @hidden */
  78842. protected _measureForChildren: Measure;
  78843. /** @hidden */
  78844. protected _background: string;
  78845. /** @hidden */
  78846. protected _adaptWidthToChildren: boolean;
  78847. /** @hidden */
  78848. protected _adaptHeightToChildren: boolean;
  78849. /**
  78850. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  78851. */
  78852. logLayoutCycleErrors: boolean;
  78853. /**
  78854. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  78855. */
  78856. maxLayoutCycle: number;
  78857. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  78858. get adaptHeightToChildren(): boolean;
  78859. set adaptHeightToChildren(value: boolean);
  78860. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  78861. get adaptWidthToChildren(): boolean;
  78862. set adaptWidthToChildren(value: boolean);
  78863. /** Gets or sets background color */
  78864. get background(): string;
  78865. set background(value: string);
  78866. /** Gets the list of children */
  78867. get children(): Control[];
  78868. /**
  78869. * Creates a new Container
  78870. * @param name defines the name of the container
  78871. */
  78872. constructor(name?: string | undefined);
  78873. protected _getTypeName(): string;
  78874. _flagDescendantsAsMatrixDirty(): void;
  78875. /**
  78876. * Gets a child using its name
  78877. * @param name defines the child name to look for
  78878. * @returns the child control if found
  78879. */
  78880. getChildByName(name: string): BABYLON.Nullable<Control>;
  78881. /**
  78882. * Gets a child using its type and its name
  78883. * @param name defines the child name to look for
  78884. * @param type defines the child type to look for
  78885. * @returns the child control if found
  78886. */
  78887. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  78888. /**
  78889. * Search for a specific control in children
  78890. * @param control defines the control to look for
  78891. * @returns true if the control is in child list
  78892. */
  78893. containsControl(control: Control): boolean;
  78894. /**
  78895. * Adds a new control to the current container
  78896. * @param control defines the control to add
  78897. * @returns the current container
  78898. */
  78899. addControl(control: BABYLON.Nullable<Control>): Container;
  78900. /**
  78901. * Removes all controls from the current container
  78902. * @returns the current container
  78903. */
  78904. clearControls(): Container;
  78905. /**
  78906. * Removes a control from the current container
  78907. * @param control defines the control to remove
  78908. * @returns the current container
  78909. */
  78910. removeControl(control: Control): Container;
  78911. /** @hidden */
  78912. _reOrderControl(control: Control): void;
  78913. /** @hidden */
  78914. _offsetLeft(offset: number): void;
  78915. /** @hidden */
  78916. _offsetTop(offset: number): void;
  78917. /** @hidden */
  78918. _markAllAsDirty(): void;
  78919. /** @hidden */
  78920. protected _localDraw(context: CanvasRenderingContext2D): void;
  78921. /** @hidden */
  78922. _link(host: AdvancedDynamicTexture): void;
  78923. /** @hidden */
  78924. protected _beforeLayout(): void;
  78925. /** @hidden */
  78926. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78927. /** @hidden */
  78928. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  78929. protected _postMeasure(): void;
  78930. /** @hidden */
  78931. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  78932. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  78933. /** @hidden */
  78934. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78935. /** @hidden */
  78936. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78937. /** Releases associated resources */
  78938. dispose(): void;
  78939. }
  78940. }
  78941. declare module BABYLON.GUI {
  78942. /** Class used to create rectangle container */
  78943. export class Rectangle extends Container {
  78944. name?: string | undefined;
  78945. private _thickness;
  78946. private _cornerRadius;
  78947. /** Gets or sets border thickness */
  78948. get thickness(): number;
  78949. set thickness(value: number);
  78950. /** Gets or sets the corner radius angle */
  78951. get cornerRadius(): number;
  78952. set cornerRadius(value: number);
  78953. /**
  78954. * Creates a new Rectangle
  78955. * @param name defines the control name
  78956. */
  78957. constructor(name?: string | undefined);
  78958. protected _getTypeName(): string;
  78959. protected _localDraw(context: CanvasRenderingContext2D): void;
  78960. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78961. private _drawRoundedRect;
  78962. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  78963. }
  78964. }
  78965. declare module BABYLON.GUI {
  78966. /**
  78967. * Enum that determines the text-wrapping mode to use.
  78968. */
  78969. export enum TextWrapping {
  78970. /**
  78971. * Clip the text when it's larger than Control.width; this is the default mode.
  78972. */
  78973. Clip = 0,
  78974. /**
  78975. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  78976. */
  78977. WordWrap = 1,
  78978. /**
  78979. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  78980. */
  78981. Ellipsis = 2
  78982. }
  78983. /**
  78984. * Class used to create text block control
  78985. */
  78986. export class TextBlock extends Control {
  78987. /**
  78988. * Defines the name of the control
  78989. */
  78990. name?: string | undefined;
  78991. private _text;
  78992. private _textWrapping;
  78993. private _textHorizontalAlignment;
  78994. private _textVerticalAlignment;
  78995. private _lines;
  78996. private _resizeToFit;
  78997. private _lineSpacing;
  78998. private _outlineWidth;
  78999. private _outlineColor;
  79000. private _underline;
  79001. private _lineThrough;
  79002. /**
  79003. * An event triggered after the text is changed
  79004. */
  79005. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  79006. /**
  79007. * An event triggered after the text was broken up into lines
  79008. */
  79009. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  79010. /**
  79011. * Function used to split a string into words. By default, a string is split at each space character found
  79012. */
  79013. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  79014. /**
  79015. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  79016. */
  79017. get lines(): any[];
  79018. /**
  79019. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  79020. */
  79021. get resizeToFit(): boolean;
  79022. /**
  79023. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  79024. */
  79025. set resizeToFit(value: boolean);
  79026. /**
  79027. * Gets or sets a boolean indicating if text must be wrapped
  79028. */
  79029. get textWrapping(): TextWrapping | boolean;
  79030. /**
  79031. * Gets or sets a boolean indicating if text must be wrapped
  79032. */
  79033. set textWrapping(value: TextWrapping | boolean);
  79034. /**
  79035. * Gets or sets text to display
  79036. */
  79037. get text(): string;
  79038. /**
  79039. * Gets or sets text to display
  79040. */
  79041. set text(value: string);
  79042. /**
  79043. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  79044. */
  79045. get textHorizontalAlignment(): number;
  79046. /**
  79047. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  79048. */
  79049. set textHorizontalAlignment(value: number);
  79050. /**
  79051. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  79052. */
  79053. get textVerticalAlignment(): number;
  79054. /**
  79055. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  79056. */
  79057. set textVerticalAlignment(value: number);
  79058. /**
  79059. * Gets or sets line spacing value
  79060. */
  79061. set lineSpacing(value: string | number);
  79062. /**
  79063. * Gets or sets line spacing value
  79064. */
  79065. get lineSpacing(): string | number;
  79066. /**
  79067. * Gets or sets outlineWidth of the text to display
  79068. */
  79069. get outlineWidth(): number;
  79070. /**
  79071. * Gets or sets outlineWidth of the text to display
  79072. */
  79073. set outlineWidth(value: number);
  79074. /**
  79075. * Gets or sets a boolean indicating that text must have underline
  79076. */
  79077. get underline(): boolean;
  79078. /**
  79079. * Gets or sets a boolean indicating that text must have underline
  79080. */
  79081. set underline(value: boolean);
  79082. /**
  79083. * Gets or sets an boolean indicating that text must be crossed out
  79084. */
  79085. get lineThrough(): boolean;
  79086. /**
  79087. * Gets or sets an boolean indicating that text must be crossed out
  79088. */
  79089. set lineThrough(value: boolean);
  79090. /**
  79091. * Gets or sets outlineColor of the text to display
  79092. */
  79093. get outlineColor(): string;
  79094. /**
  79095. * Gets or sets outlineColor of the text to display
  79096. */
  79097. set outlineColor(value: string);
  79098. /**
  79099. * Creates a new TextBlock object
  79100. * @param name defines the name of the control
  79101. * @param text defines the text to display (emptry string by default)
  79102. */
  79103. constructor(
  79104. /**
  79105. * Defines the name of the control
  79106. */
  79107. name?: string | undefined, text?: string);
  79108. protected _getTypeName(): string;
  79109. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79110. private _drawText;
  79111. /** @hidden */
  79112. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79113. protected _applyStates(context: CanvasRenderingContext2D): void;
  79114. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  79115. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  79116. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  79117. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  79118. protected _renderLines(context: CanvasRenderingContext2D): void;
  79119. /**
  79120. * Given a width constraint applied on the text block, find the expected height
  79121. * @returns expected height
  79122. */
  79123. computeExpectedHeight(): number;
  79124. dispose(): void;
  79125. }
  79126. }
  79127. declare module BABYLON.GUI {
  79128. /**
  79129. * Class used to create 2D images
  79130. */
  79131. export class Image extends Control {
  79132. name?: string | undefined;
  79133. private _workingCanvas;
  79134. private _domImage;
  79135. private _imageWidth;
  79136. private _imageHeight;
  79137. private _loaded;
  79138. private _stretch;
  79139. private _source;
  79140. private _autoScale;
  79141. private _sourceLeft;
  79142. private _sourceTop;
  79143. private _sourceWidth;
  79144. private _sourceHeight;
  79145. private _svgAttributesComputationCompleted;
  79146. private _isSVG;
  79147. private _cellWidth;
  79148. private _cellHeight;
  79149. private _cellId;
  79150. private _populateNinePatchSlicesFromImage;
  79151. private _sliceLeft;
  79152. private _sliceRight;
  79153. private _sliceTop;
  79154. private _sliceBottom;
  79155. private _detectPointerOnOpaqueOnly;
  79156. private _imageDataCache;
  79157. /**
  79158. * BABYLON.Observable notified when the content is loaded
  79159. */
  79160. onImageLoadedObservable: BABYLON.Observable<Image>;
  79161. /**
  79162. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  79163. */
  79164. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  79165. /**
  79166. * Gets a boolean indicating that the content is loaded
  79167. */
  79168. get isLoaded(): boolean;
  79169. /**
  79170. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  79171. */
  79172. get populateNinePatchSlicesFromImage(): boolean;
  79173. set populateNinePatchSlicesFromImage(value: boolean);
  79174. /**
  79175. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  79176. * Beware using this as this will comsume more memory as the image has to be stored twice
  79177. */
  79178. get detectPointerOnOpaqueOnly(): boolean;
  79179. set detectPointerOnOpaqueOnly(value: boolean);
  79180. /**
  79181. * Gets or sets the left value for slicing (9-patch)
  79182. */
  79183. get sliceLeft(): number;
  79184. set sliceLeft(value: number);
  79185. /**
  79186. * Gets or sets the right value for slicing (9-patch)
  79187. */
  79188. get sliceRight(): number;
  79189. set sliceRight(value: number);
  79190. /**
  79191. * Gets or sets the top value for slicing (9-patch)
  79192. */
  79193. get sliceTop(): number;
  79194. set sliceTop(value: number);
  79195. /**
  79196. * Gets or sets the bottom value for slicing (9-patch)
  79197. */
  79198. get sliceBottom(): number;
  79199. set sliceBottom(value: number);
  79200. /**
  79201. * Gets or sets the left coordinate in the source image
  79202. */
  79203. get sourceLeft(): number;
  79204. set sourceLeft(value: number);
  79205. /**
  79206. * Gets or sets the top coordinate in the source image
  79207. */
  79208. get sourceTop(): number;
  79209. set sourceTop(value: number);
  79210. /**
  79211. * Gets or sets the width to capture in the source image
  79212. */
  79213. get sourceWidth(): number;
  79214. set sourceWidth(value: number);
  79215. /**
  79216. * Gets or sets the height to capture in the source image
  79217. */
  79218. get sourceHeight(): number;
  79219. set sourceHeight(value: number);
  79220. /** Indicates if the format of the image is SVG */
  79221. get isSVG(): boolean;
  79222. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  79223. get svgAttributesComputationCompleted(): boolean;
  79224. /**
  79225. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  79226. * @see https://doc.babylonjs.com/how_to/gui#image
  79227. */
  79228. get autoScale(): boolean;
  79229. set autoScale(value: boolean);
  79230. /** Gets or sets the streching mode used by the image */
  79231. get stretch(): number;
  79232. set stretch(value: number);
  79233. /** @hidden */
  79234. _rotate90(n: number, preserveProperties?: boolean): Image;
  79235. private _handleRotationForSVGImage;
  79236. private _rotate90SourceProperties;
  79237. /**
  79238. * Gets or sets the internal DOM image used to render the control
  79239. */
  79240. set domImage(value: HTMLImageElement);
  79241. get domImage(): HTMLImageElement;
  79242. private _onImageLoaded;
  79243. private _extractNinePatchSliceDataFromImage;
  79244. /**
  79245. * Gets or sets image source url
  79246. */
  79247. set source(value: BABYLON.Nullable<string>);
  79248. /**
  79249. * Checks for svg document with icon id present
  79250. */
  79251. private _svgCheck;
  79252. /**
  79253. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  79254. * given external svg file and icon id
  79255. */
  79256. private _getSVGAttribs;
  79257. /**
  79258. * Gets or sets the cell width to use when animation sheet is enabled
  79259. * @see https://doc.babylonjs.com/how_to/gui#image
  79260. */
  79261. get cellWidth(): number;
  79262. set cellWidth(value: number);
  79263. /**
  79264. * Gets or sets the cell height to use when animation sheet is enabled
  79265. * @see https://doc.babylonjs.com/how_to/gui#image
  79266. */
  79267. get cellHeight(): number;
  79268. set cellHeight(value: number);
  79269. /**
  79270. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  79271. * @see https://doc.babylonjs.com/how_to/gui#image
  79272. */
  79273. get cellId(): number;
  79274. set cellId(value: number);
  79275. /**
  79276. * Creates a new Image
  79277. * @param name defines the control name
  79278. * @param url defines the image url
  79279. */
  79280. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  79281. /**
  79282. * Tests if a given coordinates belong to the current control
  79283. * @param x defines x coordinate to test
  79284. * @param y defines y coordinate to test
  79285. * @returns true if the coordinates are inside the control
  79286. */
  79287. contains(x: number, y: number): boolean;
  79288. protected _getTypeName(): string;
  79289. /** Force the control to synchronize with its content */
  79290. synchronizeSizeWithContent(): void;
  79291. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79292. private _prepareWorkingCanvasForOpaqueDetection;
  79293. private _drawImage;
  79294. _draw(context: CanvasRenderingContext2D): void;
  79295. private _renderCornerPatch;
  79296. private _renderNinePatch;
  79297. dispose(): void;
  79298. /** STRETCH_NONE */
  79299. static readonly STRETCH_NONE: number;
  79300. /** STRETCH_FILL */
  79301. static readonly STRETCH_FILL: number;
  79302. /** STRETCH_UNIFORM */
  79303. static readonly STRETCH_UNIFORM: number;
  79304. /** STRETCH_EXTEND */
  79305. static readonly STRETCH_EXTEND: number;
  79306. /** NINE_PATCH */
  79307. static readonly STRETCH_NINE_PATCH: number;
  79308. }
  79309. }
  79310. declare module BABYLON.GUI {
  79311. /**
  79312. * Class used to create 2D buttons
  79313. */
  79314. export class Button extends Rectangle {
  79315. name?: string | undefined;
  79316. /**
  79317. * Function called to generate a pointer enter animation
  79318. */
  79319. pointerEnterAnimation: () => void;
  79320. /**
  79321. * Function called to generate a pointer out animation
  79322. */
  79323. pointerOutAnimation: () => void;
  79324. /**
  79325. * Function called to generate a pointer down animation
  79326. */
  79327. pointerDownAnimation: () => void;
  79328. /**
  79329. * Function called to generate a pointer up animation
  79330. */
  79331. pointerUpAnimation: () => void;
  79332. /**
  79333. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  79334. */
  79335. delegatePickingToChildren: boolean;
  79336. private _image;
  79337. /**
  79338. * Returns the image part of the button (if any)
  79339. */
  79340. get image(): BABYLON.Nullable<Image>;
  79341. private _textBlock;
  79342. /**
  79343. * Returns the image part of the button (if any)
  79344. */
  79345. get textBlock(): BABYLON.Nullable<TextBlock>;
  79346. /**
  79347. * Creates a new Button
  79348. * @param name defines the name of the button
  79349. */
  79350. constructor(name?: string | undefined);
  79351. protected _getTypeName(): string;
  79352. /** @hidden */
  79353. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  79354. /** @hidden */
  79355. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  79356. /** @hidden */
  79357. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  79358. /** @hidden */
  79359. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79360. /** @hidden */
  79361. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  79362. /**
  79363. * Creates a new button made with an image and a text
  79364. * @param name defines the name of the button
  79365. * @param text defines the text of the button
  79366. * @param imageUrl defines the url of the image
  79367. * @returns a new Button
  79368. */
  79369. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  79370. /**
  79371. * Creates a new button made with an image
  79372. * @param name defines the name of the button
  79373. * @param imageUrl defines the url of the image
  79374. * @returns a new Button
  79375. */
  79376. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  79377. /**
  79378. * Creates a new button made with a text
  79379. * @param name defines the name of the button
  79380. * @param text defines the text of the button
  79381. * @returns a new Button
  79382. */
  79383. static CreateSimpleButton(name: string, text: string): Button;
  79384. /**
  79385. * Creates a new button made with an image and a centered text
  79386. * @param name defines the name of the button
  79387. * @param text defines the text of the button
  79388. * @param imageUrl defines the url of the image
  79389. * @returns a new Button
  79390. */
  79391. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  79392. }
  79393. }
  79394. declare module BABYLON.GUI {
  79395. /**
  79396. * Class used to create a 2D stack panel container
  79397. */
  79398. export class StackPanel extends Container {
  79399. name?: string | undefined;
  79400. private _isVertical;
  79401. private _manualWidth;
  79402. private _manualHeight;
  79403. private _doNotTrackManualChanges;
  79404. /**
  79405. * Gets or sets a boolean indicating that layou warnings should be ignored
  79406. */
  79407. ignoreLayoutWarnings: boolean;
  79408. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  79409. get isVertical(): boolean;
  79410. set isVertical(value: boolean);
  79411. /**
  79412. * Gets or sets panel width.
  79413. * This value should not be set when in horizontal mode as it will be computed automatically
  79414. */
  79415. set width(value: string | number);
  79416. get width(): string | number;
  79417. /**
  79418. * Gets or sets panel height.
  79419. * This value should not be set when in vertical mode as it will be computed automatically
  79420. */
  79421. set height(value: string | number);
  79422. get height(): string | number;
  79423. /**
  79424. * Creates a new StackPanel
  79425. * @param name defines control name
  79426. */
  79427. constructor(name?: string | undefined);
  79428. protected _getTypeName(): string;
  79429. /** @hidden */
  79430. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79431. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79432. protected _postMeasure(): void;
  79433. }
  79434. }
  79435. declare module BABYLON.GUI {
  79436. /**
  79437. * Class used to represent a 2D checkbox
  79438. */
  79439. export class Checkbox extends Control {
  79440. name?: string | undefined;
  79441. private _isChecked;
  79442. private _background;
  79443. private _checkSizeRatio;
  79444. private _thickness;
  79445. /** Gets or sets border thickness */
  79446. get thickness(): number;
  79447. set thickness(value: number);
  79448. /**
  79449. * BABYLON.Observable raised when isChecked property changes
  79450. */
  79451. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  79452. /** Gets or sets a value indicating the ratio between overall size and check size */
  79453. get checkSizeRatio(): number;
  79454. set checkSizeRatio(value: number);
  79455. /** Gets or sets background color */
  79456. get background(): string;
  79457. set background(value: string);
  79458. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  79459. get isChecked(): boolean;
  79460. set isChecked(value: boolean);
  79461. /**
  79462. * Creates a new CheckBox
  79463. * @param name defines the control name
  79464. */
  79465. constructor(name?: string | undefined);
  79466. protected _getTypeName(): string;
  79467. /** @hidden */
  79468. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79469. /** @hidden */
  79470. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79471. /**
  79472. * Utility function to easily create a checkbox with a header
  79473. * @param title defines the label to use for the header
  79474. * @param onValueChanged defines the callback to call when value changes
  79475. * @returns a StackPanel containing the checkbox and a textBlock
  79476. */
  79477. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  79478. }
  79479. }
  79480. declare module BABYLON.GUI {
  79481. /**
  79482. * Class used to store key control properties
  79483. */
  79484. export class KeyPropertySet {
  79485. /** Width */
  79486. width?: string;
  79487. /** Height */
  79488. height?: string;
  79489. /** Left padding */
  79490. paddingLeft?: string;
  79491. /** Right padding */
  79492. paddingRight?: string;
  79493. /** Top padding */
  79494. paddingTop?: string;
  79495. /** Bottom padding */
  79496. paddingBottom?: string;
  79497. /** Foreground color */
  79498. color?: string;
  79499. /** Background color */
  79500. background?: string;
  79501. }
  79502. /**
  79503. * Class used to create virtual keyboard
  79504. */
  79505. export class VirtualKeyboard extends StackPanel {
  79506. /** BABYLON.Observable raised when a key is pressed */
  79507. onKeyPressObservable: BABYLON.Observable<string>;
  79508. /** Gets or sets default key button width */
  79509. defaultButtonWidth: string;
  79510. /** Gets or sets default key button height */
  79511. defaultButtonHeight: string;
  79512. /** Gets or sets default key button left padding */
  79513. defaultButtonPaddingLeft: string;
  79514. /** Gets or sets default key button right padding */
  79515. defaultButtonPaddingRight: string;
  79516. /** Gets or sets default key button top padding */
  79517. defaultButtonPaddingTop: string;
  79518. /** Gets or sets default key button bottom padding */
  79519. defaultButtonPaddingBottom: string;
  79520. /** Gets or sets default key button foreground color */
  79521. defaultButtonColor: string;
  79522. /** Gets or sets default key button background color */
  79523. defaultButtonBackground: string;
  79524. /** Gets or sets shift button foreground color */
  79525. shiftButtonColor: string;
  79526. /** Gets or sets shift button thickness*/
  79527. selectedShiftThickness: number;
  79528. /** Gets shift key state */
  79529. shiftState: number;
  79530. protected _getTypeName(): string;
  79531. private _createKey;
  79532. /**
  79533. * Adds a new row of keys
  79534. * @param keys defines the list of keys to add
  79535. * @param propertySets defines the associated property sets
  79536. */
  79537. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  79538. /**
  79539. * Set the shift key to a specific state
  79540. * @param shiftState defines the new shift state
  79541. */
  79542. applyShiftState(shiftState: number): void;
  79543. private _currentlyConnectedInputText;
  79544. private _connectedInputTexts;
  79545. private _onKeyPressObserver;
  79546. /** Gets the input text control currently attached to the keyboard */
  79547. get connectedInputText(): BABYLON.Nullable<InputText>;
  79548. /**
  79549. * Connects the keyboard with an input text control
  79550. *
  79551. * @param input defines the target control
  79552. */
  79553. connect(input: InputText): void;
  79554. /**
  79555. * Disconnects the keyboard from connected InputText controls
  79556. *
  79557. * @param input optionally defines a target control, otherwise all are disconnected
  79558. */
  79559. disconnect(input?: InputText): void;
  79560. private _removeConnectedInputObservables;
  79561. /**
  79562. * Release all resources
  79563. */
  79564. dispose(): void;
  79565. /**
  79566. * Creates a new keyboard using a default layout
  79567. *
  79568. * @param name defines control name
  79569. * @returns a new VirtualKeyboard
  79570. */
  79571. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  79572. }
  79573. }
  79574. declare module BABYLON.GUI {
  79575. /**
  79576. * Class used to create input text control
  79577. */
  79578. export class InputText extends Control implements IFocusableControl {
  79579. name?: string | undefined;
  79580. private _text;
  79581. private _placeholderText;
  79582. private _background;
  79583. private _focusedBackground;
  79584. private _focusedColor;
  79585. private _placeholderColor;
  79586. private _thickness;
  79587. private _margin;
  79588. private _autoStretchWidth;
  79589. private _maxWidth;
  79590. private _isFocused;
  79591. private _blinkTimeout;
  79592. private _blinkIsEven;
  79593. private _cursorOffset;
  79594. private _scrollLeft;
  79595. private _textWidth;
  79596. private _clickedCoordinate;
  79597. private _deadKey;
  79598. private _addKey;
  79599. private _currentKey;
  79600. private _isTextHighlightOn;
  79601. private _textHighlightColor;
  79602. private _highligherOpacity;
  79603. private _highlightedText;
  79604. private _startHighlightIndex;
  79605. private _endHighlightIndex;
  79606. private _cursorIndex;
  79607. private _onFocusSelectAll;
  79608. private _isPointerDown;
  79609. private _onClipboardObserver;
  79610. private _onPointerDblTapObserver;
  79611. /** @hidden */
  79612. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  79613. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  79614. promptMessage: string;
  79615. /** Force disable prompt on mobile device */
  79616. disableMobilePrompt: boolean;
  79617. /** BABYLON.Observable raised when the text changes */
  79618. onTextChangedObservable: BABYLON.Observable<InputText>;
  79619. /** BABYLON.Observable raised just before an entered character is to be added */
  79620. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  79621. /** BABYLON.Observable raised when the control gets the focus */
  79622. onFocusObservable: BABYLON.Observable<InputText>;
  79623. /** BABYLON.Observable raised when the control loses the focus */
  79624. onBlurObservable: BABYLON.Observable<InputText>;
  79625. /**Observable raised when the text is highlighted */
  79626. onTextHighlightObservable: BABYLON.Observable<InputText>;
  79627. /**Observable raised when copy event is triggered */
  79628. onTextCopyObservable: BABYLON.Observable<InputText>;
  79629. /** BABYLON.Observable raised when cut event is triggered */
  79630. onTextCutObservable: BABYLON.Observable<InputText>;
  79631. /** BABYLON.Observable raised when paste event is triggered */
  79632. onTextPasteObservable: BABYLON.Observable<InputText>;
  79633. /** BABYLON.Observable raised when a key event was processed */
  79634. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  79635. /** Gets or sets the maximum width allowed by the control */
  79636. get maxWidth(): string | number;
  79637. /** Gets the maximum width allowed by the control in pixels */
  79638. get maxWidthInPixels(): number;
  79639. set maxWidth(value: string | number);
  79640. /** Gets or sets the text highlighter transparency; default: 0.4 */
  79641. get highligherOpacity(): number;
  79642. set highligherOpacity(value: number);
  79643. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  79644. get onFocusSelectAll(): boolean;
  79645. set onFocusSelectAll(value: boolean);
  79646. /** Gets or sets the text hightlight color */
  79647. get textHighlightColor(): string;
  79648. set textHighlightColor(value: string);
  79649. /** Gets or sets control margin */
  79650. get margin(): string;
  79651. /** Gets control margin in pixels */
  79652. get marginInPixels(): number;
  79653. set margin(value: string);
  79654. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  79655. get autoStretchWidth(): boolean;
  79656. set autoStretchWidth(value: boolean);
  79657. /** Gets or sets border thickness */
  79658. get thickness(): number;
  79659. set thickness(value: number);
  79660. /** Gets or sets the background color when focused */
  79661. get focusedBackground(): string;
  79662. set focusedBackground(value: string);
  79663. /** Gets or sets the background color when focused */
  79664. get focusedColor(): string;
  79665. set focusedColor(value: string);
  79666. /** Gets or sets the background color */
  79667. get background(): string;
  79668. set background(value: string);
  79669. /** Gets or sets the placeholder color */
  79670. get placeholderColor(): string;
  79671. set placeholderColor(value: string);
  79672. /** Gets or sets the text displayed when the control is empty */
  79673. get placeholderText(): string;
  79674. set placeholderText(value: string);
  79675. /** Gets or sets the dead key flag */
  79676. get deadKey(): boolean;
  79677. set deadKey(flag: boolean);
  79678. /** Gets or sets the highlight text */
  79679. get highlightedText(): string;
  79680. set highlightedText(text: string);
  79681. /** Gets or sets if the current key should be added */
  79682. get addKey(): boolean;
  79683. set addKey(flag: boolean);
  79684. /** Gets or sets the value of the current key being entered */
  79685. get currentKey(): string;
  79686. set currentKey(key: string);
  79687. /** Gets or sets the text displayed in the control */
  79688. get text(): string;
  79689. set text(value: string);
  79690. /** Gets or sets control width */
  79691. get width(): string | number;
  79692. set width(value: string | number);
  79693. /**
  79694. * Creates a new InputText
  79695. * @param name defines the control name
  79696. * @param text defines the text of the control
  79697. */
  79698. constructor(name?: string | undefined, text?: string);
  79699. /** @hidden */
  79700. onBlur(): void;
  79701. /** @hidden */
  79702. onFocus(): void;
  79703. protected _getTypeName(): string;
  79704. /**
  79705. * Function called to get the list of controls that should not steal the focus from this control
  79706. * @returns an array of controls
  79707. */
  79708. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  79709. /** @hidden */
  79710. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  79711. /** @hidden */
  79712. private _updateValueFromCursorIndex;
  79713. /** @hidden */
  79714. private _processDblClick;
  79715. /** @hidden */
  79716. private _selectAllText;
  79717. /**
  79718. * Handles the keyboard event
  79719. * @param evt Defines the KeyboardEvent
  79720. */
  79721. processKeyboard(evt: KeyboardEvent): void;
  79722. /** @hidden */
  79723. private _onCopyText;
  79724. /** @hidden */
  79725. private _onCutText;
  79726. /** @hidden */
  79727. private _onPasteText;
  79728. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79729. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79730. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  79731. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  79732. protected _beforeRenderText(text: string): string;
  79733. dispose(): void;
  79734. }
  79735. }
  79736. declare module BABYLON.GUI {
  79737. /**
  79738. * Class used to create a 2D grid container
  79739. */
  79740. export class Grid extends Container {
  79741. name?: string | undefined;
  79742. private _rowDefinitions;
  79743. private _columnDefinitions;
  79744. private _cells;
  79745. private _childControls;
  79746. /**
  79747. * Gets the number of columns
  79748. */
  79749. get columnCount(): number;
  79750. /**
  79751. * Gets the number of rows
  79752. */
  79753. get rowCount(): number;
  79754. /** Gets the list of children */
  79755. get children(): Control[];
  79756. /** Gets the list of cells (e.g. the containers) */
  79757. get cells(): {
  79758. [key: string]: Container;
  79759. };
  79760. /**
  79761. * Gets the definition of a specific row
  79762. * @param index defines the index of the row
  79763. * @returns the row definition
  79764. */
  79765. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  79766. /**
  79767. * Gets the definition of a specific column
  79768. * @param index defines the index of the column
  79769. * @returns the column definition
  79770. */
  79771. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  79772. /**
  79773. * Adds a new row to the grid
  79774. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  79775. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  79776. * @returns the current grid
  79777. */
  79778. addRowDefinition(height: number, isPixel?: boolean): Grid;
  79779. /**
  79780. * Adds a new column to the grid
  79781. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  79782. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  79783. * @returns the current grid
  79784. */
  79785. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  79786. /**
  79787. * Update a row definition
  79788. * @param index defines the index of the row to update
  79789. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  79790. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  79791. * @returns the current grid
  79792. */
  79793. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  79794. /**
  79795. * Update a column definition
  79796. * @param index defines the index of the column to update
  79797. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  79798. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  79799. * @returns the current grid
  79800. */
  79801. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  79802. /**
  79803. * Gets the list of children stored in a specific cell
  79804. * @param row defines the row to check
  79805. * @param column defines the column to check
  79806. * @returns the list of controls
  79807. */
  79808. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  79809. /**
  79810. * Gets a string representing the child cell info (row x column)
  79811. * @param child defines the control to get info from
  79812. * @returns a string containing the child cell info (row x column)
  79813. */
  79814. getChildCellInfo(child: Control): string;
  79815. private _removeCell;
  79816. private _offsetCell;
  79817. /**
  79818. * Remove a column definition at specified index
  79819. * @param index defines the index of the column to remove
  79820. * @returns the current grid
  79821. */
  79822. removeColumnDefinition(index: number): Grid;
  79823. /**
  79824. * Remove a row definition at specified index
  79825. * @param index defines the index of the row to remove
  79826. * @returns the current grid
  79827. */
  79828. removeRowDefinition(index: number): Grid;
  79829. /**
  79830. * Adds a new control to the current grid
  79831. * @param control defines the control to add
  79832. * @param row defines the row where to add the control (0 by default)
  79833. * @param column defines the column where to add the control (0 by default)
  79834. * @returns the current grid
  79835. */
  79836. addControl(control: Control, row?: number, column?: number): Grid;
  79837. /**
  79838. * Removes a control from the current container
  79839. * @param control defines the control to remove
  79840. * @returns the current container
  79841. */
  79842. removeControl(control: Control): Container;
  79843. /**
  79844. * Creates a new Grid
  79845. * @param name defines control name
  79846. */
  79847. constructor(name?: string | undefined);
  79848. protected _getTypeName(): string;
  79849. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  79850. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79851. _flagDescendantsAsMatrixDirty(): void;
  79852. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  79853. /** Releases associated resources */
  79854. dispose(): void;
  79855. }
  79856. }
  79857. declare module BABYLON.GUI {
  79858. /** Class used to create color pickers */
  79859. export class ColorPicker extends Control {
  79860. name?: string | undefined;
  79861. private static _Epsilon;
  79862. private _colorWheelCanvas;
  79863. private _value;
  79864. private _tmpColor;
  79865. private _pointerStartedOnSquare;
  79866. private _pointerStartedOnWheel;
  79867. private _squareLeft;
  79868. private _squareTop;
  79869. private _squareSize;
  79870. private _h;
  79871. private _s;
  79872. private _v;
  79873. private _lastPointerDownID;
  79874. /**
  79875. * BABYLON.Observable raised when the value changes
  79876. */
  79877. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  79878. /** Gets or sets the color of the color picker */
  79879. get value(): BABYLON.Color3;
  79880. set value(value: BABYLON.Color3);
  79881. /**
  79882. * Gets or sets control width
  79883. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79884. */
  79885. get width(): string | number;
  79886. set width(value: string | number);
  79887. /**
  79888. * Gets or sets control height
  79889. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79890. */
  79891. get height(): string | number;
  79892. /** Gets or sets control height */
  79893. set height(value: string | number);
  79894. /** Gets or sets control size */
  79895. get size(): string | number;
  79896. set size(value: string | number);
  79897. /**
  79898. * Creates a new ColorPicker
  79899. * @param name defines the control name
  79900. */
  79901. constructor(name?: string | undefined);
  79902. protected _getTypeName(): string;
  79903. /** @hidden */
  79904. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79905. private _updateSquareProps;
  79906. private _drawGradientSquare;
  79907. private _drawCircle;
  79908. private _createColorWheelCanvas;
  79909. /** @hidden */
  79910. _draw(context: CanvasRenderingContext2D): void;
  79911. private _pointerIsDown;
  79912. private _updateValueFromPointer;
  79913. private _isPointOnSquare;
  79914. private _isPointOnWheel;
  79915. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79916. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  79917. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  79918. _onCanvasBlur(): void;
  79919. /**
  79920. * This function expands the color picker by creating a color picker dialog with manual
  79921. * color value input and the ability to save colors into an array to be used later in
  79922. * subsequent launches of the dialogue.
  79923. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  79924. * @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.
  79925. * @returns picked color as a hex string and the saved colors array as hex strings.
  79926. */
  79927. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  79928. pickerWidth?: string;
  79929. pickerHeight?: string;
  79930. headerHeight?: string;
  79931. lastColor?: string;
  79932. swatchLimit?: number;
  79933. numSwatchesPerLine?: number;
  79934. savedColors?: Array<string>;
  79935. }): Promise<{
  79936. savedColors?: string[];
  79937. pickedColor: string;
  79938. }>;
  79939. }
  79940. }
  79941. declare module BABYLON.GUI {
  79942. /** Class used to create 2D ellipse containers */
  79943. export class Ellipse extends Container {
  79944. name?: string | undefined;
  79945. private _thickness;
  79946. /** Gets or sets border thickness */
  79947. get thickness(): number;
  79948. set thickness(value: number);
  79949. /**
  79950. * Creates a new Ellipse
  79951. * @param name defines the control name
  79952. */
  79953. constructor(name?: string | undefined);
  79954. protected _getTypeName(): string;
  79955. protected _localDraw(context: CanvasRenderingContext2D): void;
  79956. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79957. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  79958. }
  79959. }
  79960. declare module BABYLON.GUI {
  79961. /**
  79962. * Class used to create a password control
  79963. */
  79964. export class InputPassword extends InputText {
  79965. protected _beforeRenderText(text: string): string;
  79966. }
  79967. }
  79968. declare module BABYLON.GUI {
  79969. /** Class used to render 2D lines */
  79970. export class Line extends Control {
  79971. name?: string | undefined;
  79972. private _lineWidth;
  79973. private _x1;
  79974. private _y1;
  79975. private _x2;
  79976. private _y2;
  79977. private _dash;
  79978. private _connectedControl;
  79979. private _connectedControlDirtyObserver;
  79980. /** Gets or sets the dash pattern */
  79981. get dash(): Array<number>;
  79982. set dash(value: Array<number>);
  79983. /** Gets or sets the control connected with the line end */
  79984. get connectedControl(): Control;
  79985. set connectedControl(value: Control);
  79986. /** Gets or sets start coordinates on X axis */
  79987. get x1(): string | number;
  79988. set x1(value: string | number);
  79989. /** Gets or sets start coordinates on Y axis */
  79990. get y1(): string | number;
  79991. set y1(value: string | number);
  79992. /** Gets or sets end coordinates on X axis */
  79993. get x2(): string | number;
  79994. set x2(value: string | number);
  79995. /** Gets or sets end coordinates on Y axis */
  79996. get y2(): string | number;
  79997. set y2(value: string | number);
  79998. /** Gets or sets line width */
  79999. get lineWidth(): number;
  80000. set lineWidth(value: number);
  80001. /** Gets or sets horizontal alignment */
  80002. set horizontalAlignment(value: number);
  80003. /** Gets or sets vertical alignment */
  80004. set verticalAlignment(value: number);
  80005. private get _effectiveX2();
  80006. private get _effectiveY2();
  80007. /**
  80008. * Creates a new Line
  80009. * @param name defines the control name
  80010. */
  80011. constructor(name?: string | undefined);
  80012. protected _getTypeName(): string;
  80013. _draw(context: CanvasRenderingContext2D): void;
  80014. _measure(): void;
  80015. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80016. /**
  80017. * Move one end of the line given 3D cartesian coordinates.
  80018. * @param position Targeted world position
  80019. * @param scene BABYLON.Scene
  80020. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  80021. */
  80022. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  80023. /**
  80024. * Move one end of the line to a position in screen absolute space.
  80025. * @param projectedPosition Position in screen absolute space (X, Y)
  80026. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  80027. */
  80028. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  80029. }
  80030. }
  80031. declare module BABYLON.GUI {
  80032. /**
  80033. * Class used to store a point for a MultiLine object.
  80034. * The point can be pure 2D coordinates, a mesh or a control
  80035. */
  80036. export class MultiLinePoint {
  80037. private _multiLine;
  80038. private _x;
  80039. private _y;
  80040. private _control;
  80041. private _mesh;
  80042. private _controlObserver;
  80043. private _meshObserver;
  80044. /** @hidden */
  80045. _point: BABYLON.Vector2;
  80046. /**
  80047. * Creates a new MultiLinePoint
  80048. * @param multiLine defines the source MultiLine object
  80049. */
  80050. constructor(multiLine: MultiLine);
  80051. /** Gets or sets x coordinate */
  80052. get x(): string | number;
  80053. set x(value: string | number);
  80054. /** Gets or sets y coordinate */
  80055. get y(): string | number;
  80056. set y(value: string | number);
  80057. /** Gets or sets the control associated with this point */
  80058. get control(): BABYLON.Nullable<Control>;
  80059. set control(value: BABYLON.Nullable<Control>);
  80060. /** Gets or sets the mesh associated with this point */
  80061. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  80062. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  80063. /** Resets links */
  80064. resetLinks(): void;
  80065. /**
  80066. * Gets a translation vector
  80067. * @returns the translation vector
  80068. */
  80069. translate(): BABYLON.Vector2;
  80070. private _translatePoint;
  80071. /** Release associated resources */
  80072. dispose(): void;
  80073. }
  80074. }
  80075. declare module BABYLON.GUI {
  80076. /**
  80077. * Class used to create multi line control
  80078. */
  80079. export class MultiLine extends Control {
  80080. name?: string | undefined;
  80081. private _lineWidth;
  80082. private _dash;
  80083. private _points;
  80084. private _minX;
  80085. private _minY;
  80086. private _maxX;
  80087. private _maxY;
  80088. /**
  80089. * Creates a new MultiLine
  80090. * @param name defines the control name
  80091. */
  80092. constructor(name?: string | undefined);
  80093. /** Gets or sets dash pattern */
  80094. get dash(): Array<number>;
  80095. set dash(value: Array<number>);
  80096. /**
  80097. * Gets point stored at specified index
  80098. * @param index defines the index to look for
  80099. * @returns the requested point if found
  80100. */
  80101. getAt(index: number): MultiLinePoint;
  80102. /** Function called when a point is updated */
  80103. onPointUpdate: () => void;
  80104. /**
  80105. * Adds new points to the point collection
  80106. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  80107. * @returns the list of created MultiLinePoint
  80108. */
  80109. add(...items: (AbstractMesh | Control | {
  80110. x: string | number;
  80111. y: string | number;
  80112. })[]): MultiLinePoint[];
  80113. /**
  80114. * Adds a new point to the point collection
  80115. * @param item defines the item (mesh, control or 2d coordiantes) to add
  80116. * @returns the created MultiLinePoint
  80117. */
  80118. push(item?: (AbstractMesh | Control | {
  80119. x: string | number;
  80120. y: string | number;
  80121. })): MultiLinePoint;
  80122. /**
  80123. * Remove a specific value or point from the active point collection
  80124. * @param value defines the value or point to remove
  80125. */
  80126. remove(value: number | MultiLinePoint): void;
  80127. /**
  80128. * Resets this object to initial state (no point)
  80129. */
  80130. reset(): void;
  80131. /**
  80132. * Resets all links
  80133. */
  80134. resetLinks(): void;
  80135. /** Gets or sets line width */
  80136. get lineWidth(): number;
  80137. set lineWidth(value: number);
  80138. set horizontalAlignment(value: number);
  80139. set verticalAlignment(value: number);
  80140. protected _getTypeName(): string;
  80141. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80142. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80143. _measure(): void;
  80144. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80145. dispose(): void;
  80146. }
  80147. }
  80148. declare module BABYLON.GUI {
  80149. /**
  80150. * Class used to create radio button controls
  80151. */
  80152. export class RadioButton extends Control {
  80153. name?: string | undefined;
  80154. private _isChecked;
  80155. private _background;
  80156. private _checkSizeRatio;
  80157. private _thickness;
  80158. /** Gets or sets border thickness */
  80159. get thickness(): number;
  80160. set thickness(value: number);
  80161. /** Gets or sets group name */
  80162. group: string;
  80163. /** BABYLON.Observable raised when isChecked is changed */
  80164. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  80165. /** Gets or sets a value indicating the ratio between overall size and check size */
  80166. get checkSizeRatio(): number;
  80167. set checkSizeRatio(value: number);
  80168. /** Gets or sets background color */
  80169. get background(): string;
  80170. set background(value: string);
  80171. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  80172. get isChecked(): boolean;
  80173. set isChecked(value: boolean);
  80174. /**
  80175. * Creates a new RadioButton
  80176. * @param name defines the control name
  80177. */
  80178. constructor(name?: string | undefined);
  80179. protected _getTypeName(): string;
  80180. _draw(context: CanvasRenderingContext2D): void;
  80181. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80182. /**
  80183. * Utility function to easily create a radio button with a header
  80184. * @param title defines the label to use for the header
  80185. * @param group defines the group to use for the radio button
  80186. * @param isChecked defines the initial state of the radio button
  80187. * @param onValueChanged defines the callback to call when value changes
  80188. * @returns a StackPanel containing the radio button and a textBlock
  80189. */
  80190. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  80191. }
  80192. }
  80193. declare module BABYLON.GUI {
  80194. /**
  80195. * Class used to create slider controls
  80196. */
  80197. export class BaseSlider extends Control {
  80198. name?: string | undefined;
  80199. protected _thumbWidth: ValueAndUnit;
  80200. private _minimum;
  80201. private _maximum;
  80202. private _value;
  80203. private _isVertical;
  80204. protected _barOffset: ValueAndUnit;
  80205. private _isThumbClamped;
  80206. protected _displayThumb: boolean;
  80207. private _step;
  80208. private _lastPointerDownID;
  80209. protected _effectiveBarOffset: number;
  80210. protected _renderLeft: number;
  80211. protected _renderTop: number;
  80212. protected _renderWidth: number;
  80213. protected _renderHeight: number;
  80214. protected _backgroundBoxLength: number;
  80215. protected _backgroundBoxThickness: number;
  80216. protected _effectiveThumbThickness: number;
  80217. /** BABYLON.Observable raised when the sldier value changes */
  80218. onValueChangedObservable: BABYLON.Observable<number>;
  80219. /** Gets or sets a boolean indicating if the thumb must be rendered */
  80220. get displayThumb(): boolean;
  80221. set displayThumb(value: boolean);
  80222. /** Gets or sets a step to apply to values (0 by default) */
  80223. get step(): number;
  80224. set step(value: number);
  80225. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  80226. get barOffset(): string | number;
  80227. /** Gets main bar offset in pixels*/
  80228. get barOffsetInPixels(): number;
  80229. set barOffset(value: string | number);
  80230. /** Gets or sets thumb width */
  80231. get thumbWidth(): string | number;
  80232. /** Gets thumb width in pixels */
  80233. get thumbWidthInPixels(): number;
  80234. set thumbWidth(value: string | number);
  80235. /** Gets or sets minimum value */
  80236. get minimum(): number;
  80237. set minimum(value: number);
  80238. /** Gets or sets maximum value */
  80239. get maximum(): number;
  80240. set maximum(value: number);
  80241. /** Gets or sets current value */
  80242. get value(): number;
  80243. set value(value: number);
  80244. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  80245. get isVertical(): boolean;
  80246. set isVertical(value: boolean);
  80247. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  80248. get isThumbClamped(): boolean;
  80249. set isThumbClamped(value: boolean);
  80250. /**
  80251. * Creates a new BaseSlider
  80252. * @param name defines the control name
  80253. */
  80254. constructor(name?: string | undefined);
  80255. protected _getTypeName(): string;
  80256. protected _getThumbPosition(): number;
  80257. protected _getThumbThickness(type: string): number;
  80258. protected _prepareRenderingData(type: string): void;
  80259. private _pointerIsDown;
  80260. /** @hidden */
  80261. protected _updateValueFromPointer(x: number, y: number): void;
  80262. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80263. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  80264. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  80265. _onCanvasBlur(): void;
  80266. }
  80267. }
  80268. declare module BABYLON.GUI {
  80269. /**
  80270. * Class used to create slider controls
  80271. */
  80272. export class Slider extends BaseSlider {
  80273. name?: string | undefined;
  80274. private _background;
  80275. private _borderColor;
  80276. private _thumbColor;
  80277. private _isThumbCircle;
  80278. protected _displayValueBar: boolean;
  80279. /** Gets or sets a boolean indicating if the value bar must be rendered */
  80280. get displayValueBar(): boolean;
  80281. set displayValueBar(value: boolean);
  80282. /** Gets or sets border color */
  80283. get borderColor(): string;
  80284. set borderColor(value: string);
  80285. /** Gets or sets background color */
  80286. get background(): string;
  80287. set background(value: string);
  80288. /** Gets or sets thumb's color */
  80289. get thumbColor(): string;
  80290. set thumbColor(value: string);
  80291. /** Gets or sets a boolean indicating if the thumb should be round or square */
  80292. get isThumbCircle(): boolean;
  80293. set isThumbCircle(value: boolean);
  80294. /**
  80295. * Creates a new Slider
  80296. * @param name defines the control name
  80297. */
  80298. constructor(name?: string | undefined);
  80299. protected _getTypeName(): string;
  80300. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80301. }
  80302. }
  80303. declare module BABYLON.GUI {
  80304. /** Class used to create a RadioGroup
  80305. * which contains groups of radio buttons
  80306. */
  80307. export class SelectorGroup {
  80308. /** name of SelectorGroup */
  80309. name: string;
  80310. private _groupPanel;
  80311. private _selectors;
  80312. private _groupHeader;
  80313. /**
  80314. * Creates a new SelectorGroup
  80315. * @param name of group, used as a group heading
  80316. */
  80317. constructor(
  80318. /** name of SelectorGroup */
  80319. name: string);
  80320. /** Gets the groupPanel of the SelectorGroup */
  80321. get groupPanel(): StackPanel;
  80322. /** Gets the selectors array */
  80323. get selectors(): StackPanel[];
  80324. /** Gets and sets the group header */
  80325. get header(): string;
  80326. set header(label: string);
  80327. /** @hidden */
  80328. private _addGroupHeader;
  80329. /** @hidden*/
  80330. _getSelector(selectorNb: number): StackPanel | undefined;
  80331. /** Removes the selector at the given position
  80332. * @param selectorNb the position of the selector within the group
  80333. */
  80334. removeSelector(selectorNb: number): void;
  80335. }
  80336. /** Class used to create a CheckboxGroup
  80337. * which contains groups of checkbox buttons
  80338. */
  80339. export class CheckboxGroup extends SelectorGroup {
  80340. /** Adds a checkbox as a control
  80341. * @param text is the label for the selector
  80342. * @param func is the function called when the Selector is checked
  80343. * @param checked is true when Selector is checked
  80344. */
  80345. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  80346. /** @hidden */
  80347. _setSelectorLabel(selectorNb: number, label: string): void;
  80348. /** @hidden */
  80349. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80350. /** @hidden */
  80351. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80352. /** @hidden */
  80353. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80354. }
  80355. /** Class used to create a RadioGroup
  80356. * which contains groups of radio buttons
  80357. */
  80358. export class RadioGroup extends SelectorGroup {
  80359. private _selectNb;
  80360. /** Adds a radio button as a control
  80361. * @param label is the label for the selector
  80362. * @param func is the function called when the Selector is checked
  80363. * @param checked is true when Selector is checked
  80364. */
  80365. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  80366. /** @hidden */
  80367. _setSelectorLabel(selectorNb: number, label: string): void;
  80368. /** @hidden */
  80369. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80370. /** @hidden */
  80371. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80372. /** @hidden */
  80373. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80374. }
  80375. /** Class used to create a SliderGroup
  80376. * which contains groups of slider buttons
  80377. */
  80378. export class SliderGroup extends SelectorGroup {
  80379. /**
  80380. * Adds a slider to the SelectorGroup
  80381. * @param label is the label for the SliderBar
  80382. * @param func is the function called when the Slider moves
  80383. * @param unit is a string describing the units used, eg degrees or metres
  80384. * @param min is the minimum value for the Slider
  80385. * @param max is the maximum value for the Slider
  80386. * @param value is the start value for the Slider between min and max
  80387. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  80388. */
  80389. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  80390. /** @hidden */
  80391. _setSelectorLabel(selectorNb: number, label: string): void;
  80392. /** @hidden */
  80393. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80394. /** @hidden */
  80395. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80396. /** @hidden */
  80397. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80398. }
  80399. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  80400. * @see https://doc.babylonjs.com/how_to/selector
  80401. */
  80402. export class SelectionPanel extends Rectangle {
  80403. /** name of SelectionPanel */
  80404. name: string;
  80405. /** an array of SelectionGroups */
  80406. groups: SelectorGroup[];
  80407. private _panel;
  80408. private _buttonColor;
  80409. private _buttonBackground;
  80410. private _headerColor;
  80411. private _barColor;
  80412. private _barHeight;
  80413. private _spacerHeight;
  80414. private _labelColor;
  80415. private _groups;
  80416. private _bars;
  80417. /**
  80418. * Creates a new SelectionPanel
  80419. * @param name of SelectionPanel
  80420. * @param groups is an array of SelectionGroups
  80421. */
  80422. constructor(
  80423. /** name of SelectionPanel */
  80424. name: string,
  80425. /** an array of SelectionGroups */
  80426. groups?: SelectorGroup[]);
  80427. protected _getTypeName(): string;
  80428. /** Gets the (stack) panel of the SelectionPanel */
  80429. get panel(): StackPanel;
  80430. /** Gets or sets the headerColor */
  80431. get headerColor(): string;
  80432. set headerColor(color: string);
  80433. private _setHeaderColor;
  80434. /** Gets or sets the button color */
  80435. get buttonColor(): string;
  80436. set buttonColor(color: string);
  80437. private _setbuttonColor;
  80438. /** Gets or sets the label color */
  80439. get labelColor(): string;
  80440. set labelColor(color: string);
  80441. private _setLabelColor;
  80442. /** Gets or sets the button background */
  80443. get buttonBackground(): string;
  80444. set buttonBackground(color: string);
  80445. private _setButtonBackground;
  80446. /** Gets or sets the color of separator bar */
  80447. get barColor(): string;
  80448. set barColor(color: string);
  80449. private _setBarColor;
  80450. /** Gets or sets the height of separator bar */
  80451. get barHeight(): string;
  80452. set barHeight(value: string);
  80453. private _setBarHeight;
  80454. /** Gets or sets the height of spacers*/
  80455. get spacerHeight(): string;
  80456. set spacerHeight(value: string);
  80457. private _setSpacerHeight;
  80458. /** Adds a bar between groups */
  80459. private _addSpacer;
  80460. /** Add a group to the selection panel
  80461. * @param group is the selector group to add
  80462. */
  80463. addGroup(group: SelectorGroup): void;
  80464. /** Remove the group from the given position
  80465. * @param groupNb is the position of the group in the list
  80466. */
  80467. removeGroup(groupNb: number): void;
  80468. /** Change a group header label
  80469. * @param label is the new group header label
  80470. * @param groupNb is the number of the group to relabel
  80471. * */
  80472. setHeaderName(label: string, groupNb: number): void;
  80473. /** Change selector label to the one given
  80474. * @param label is the new selector label
  80475. * @param groupNb is the number of the groupcontaining the selector
  80476. * @param selectorNb is the number of the selector within a group to relabel
  80477. * */
  80478. relabel(label: string, groupNb: number, selectorNb: number): void;
  80479. /** For a given group position remove the selector at the given position
  80480. * @param groupNb is the number of the group to remove the selector from
  80481. * @param selectorNb is the number of the selector within the group
  80482. */
  80483. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  80484. /** For a given group position of correct type add a checkbox button
  80485. * @param groupNb is the number of the group to remove the selector from
  80486. * @param label is the label for the selector
  80487. * @param func is the function called when the Selector is checked
  80488. * @param checked is true when Selector is checked
  80489. */
  80490. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  80491. /** For a given group position of correct type add a radio button
  80492. * @param groupNb is the number of the group to remove the selector from
  80493. * @param label is the label for the selector
  80494. * @param func is the function called when the Selector is checked
  80495. * @param checked is true when Selector is checked
  80496. */
  80497. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  80498. /**
  80499. * For a given slider group add a slider
  80500. * @param groupNb is the number of the group to add the slider to
  80501. * @param label is the label for the Slider
  80502. * @param func is the function called when the Slider moves
  80503. * @param unit is a string describing the units used, eg degrees or metres
  80504. * @param min is the minimum value for the Slider
  80505. * @param max is the maximum value for the Slider
  80506. * @param value is the start value for the Slider between min and max
  80507. * @param onVal is the function used to format the value displayed, eg radians to degrees
  80508. */
  80509. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  80510. }
  80511. }
  80512. declare module BABYLON.GUI {
  80513. /**
  80514. * Class used to hold a the container for ScrollViewer
  80515. * @hidden
  80516. */
  80517. export class _ScrollViewerWindow extends Container {
  80518. parentClientWidth: number;
  80519. parentClientHeight: number;
  80520. private _freezeControls;
  80521. private _parentMeasure;
  80522. private _oldLeft;
  80523. private _oldTop;
  80524. get freezeControls(): boolean;
  80525. set freezeControls(value: boolean);
  80526. private _bucketWidth;
  80527. private _bucketHeight;
  80528. private _buckets;
  80529. private _bucketLen;
  80530. get bucketWidth(): number;
  80531. get bucketHeight(): number;
  80532. setBucketSizes(width: number, height: number): void;
  80533. private _useBuckets;
  80534. private _makeBuckets;
  80535. private _dispatchInBuckets;
  80536. private _updateMeasures;
  80537. private _updateChildrenMeasures;
  80538. private _restoreMeasures;
  80539. /**
  80540. * Creates a new ScrollViewerWindow
  80541. * @param name of ScrollViewerWindow
  80542. */
  80543. constructor(name?: string);
  80544. protected _getTypeName(): string;
  80545. /** @hidden */
  80546. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80547. /** @hidden */
  80548. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  80549. private _scrollChildren;
  80550. private _scrollChildrenWithBuckets;
  80551. /** @hidden */
  80552. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  80553. protected _postMeasure(): void;
  80554. }
  80555. }
  80556. declare module BABYLON.GUI {
  80557. /**
  80558. * Class used to create slider controls
  80559. */
  80560. export class ScrollBar extends BaseSlider {
  80561. name?: string | undefined;
  80562. private _background;
  80563. private _borderColor;
  80564. private _tempMeasure;
  80565. /** Gets or sets border color */
  80566. get borderColor(): string;
  80567. set borderColor(value: string);
  80568. /** Gets or sets background color */
  80569. get background(): string;
  80570. set background(value: string);
  80571. /**
  80572. * Creates a new Slider
  80573. * @param name defines the control name
  80574. */
  80575. constructor(name?: string | undefined);
  80576. protected _getTypeName(): string;
  80577. protected _getThumbThickness(): number;
  80578. _draw(context: CanvasRenderingContext2D): void;
  80579. private _first;
  80580. private _originX;
  80581. private _originY;
  80582. /** @hidden */
  80583. protected _updateValueFromPointer(x: number, y: number): void;
  80584. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80585. }
  80586. }
  80587. declare module BABYLON.GUI {
  80588. /**
  80589. * Class used to create slider controls
  80590. */
  80591. export class ImageScrollBar extends BaseSlider {
  80592. name?: string | undefined;
  80593. private _backgroundBaseImage;
  80594. private _backgroundImage;
  80595. private _thumbImage;
  80596. private _thumbBaseImage;
  80597. private _thumbLength;
  80598. private _thumbHeight;
  80599. private _barImageHeight;
  80600. private _tempMeasure;
  80601. /** Number of 90° rotation to apply on the images when in vertical mode */
  80602. num90RotationInVerticalMode: number;
  80603. /**
  80604. * Gets or sets the image used to render the background for horizontal bar
  80605. */
  80606. get backgroundImage(): Image;
  80607. set backgroundImage(value: Image);
  80608. /**
  80609. * Gets or sets the image used to render the thumb
  80610. */
  80611. get thumbImage(): Image;
  80612. set thumbImage(value: Image);
  80613. /**
  80614. * Gets or sets the length of the thumb
  80615. */
  80616. get thumbLength(): number;
  80617. set thumbLength(value: number);
  80618. /**
  80619. * Gets or sets the height of the thumb
  80620. */
  80621. get thumbHeight(): number;
  80622. set thumbHeight(value: number);
  80623. /**
  80624. * Gets or sets the height of the bar image
  80625. */
  80626. get barImageHeight(): number;
  80627. set barImageHeight(value: number);
  80628. /**
  80629. * Creates a new ImageScrollBar
  80630. * @param name defines the control name
  80631. */
  80632. constructor(name?: string | undefined);
  80633. protected _getTypeName(): string;
  80634. protected _getThumbThickness(): number;
  80635. _draw(context: CanvasRenderingContext2D): void;
  80636. private _first;
  80637. private _originX;
  80638. private _originY;
  80639. /** @hidden */
  80640. protected _updateValueFromPointer(x: number, y: number): void;
  80641. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80642. }
  80643. }
  80644. declare module BABYLON.GUI {
  80645. /**
  80646. * Class used to hold a viewer window and sliders in a grid
  80647. */
  80648. export class ScrollViewer extends Rectangle {
  80649. private _grid;
  80650. private _horizontalBarSpace;
  80651. private _verticalBarSpace;
  80652. private _dragSpace;
  80653. private _horizontalBar;
  80654. private _verticalBar;
  80655. private _barColor;
  80656. private _barBackground;
  80657. private _barImage;
  80658. private _horizontalBarImage;
  80659. private _verticalBarImage;
  80660. private _barBackgroundImage;
  80661. private _horizontalBarBackgroundImage;
  80662. private _verticalBarBackgroundImage;
  80663. private _barSize;
  80664. private _window;
  80665. private _pointerIsOver;
  80666. private _wheelPrecision;
  80667. private _onWheelObserver;
  80668. private _clientWidth;
  80669. private _clientHeight;
  80670. private _useImageBar;
  80671. private _thumbLength;
  80672. private _thumbHeight;
  80673. private _barImageHeight;
  80674. private _horizontalBarImageHeight;
  80675. private _verticalBarImageHeight;
  80676. private _oldWindowContentsWidth;
  80677. private _oldWindowContentsHeight;
  80678. /**
  80679. * Gets the horizontal scrollbar
  80680. */
  80681. get horizontalBar(): ScrollBar | ImageScrollBar;
  80682. /**
  80683. * Gets the vertical scrollbar
  80684. */
  80685. get verticalBar(): ScrollBar | ImageScrollBar;
  80686. /**
  80687. * Adds a new control to the current container
  80688. * @param control defines the control to add
  80689. * @returns the current container
  80690. */
  80691. addControl(control: BABYLON.Nullable<Control>): Container;
  80692. /**
  80693. * Removes a control from the current container
  80694. * @param control defines the control to remove
  80695. * @returns the current container
  80696. */
  80697. removeControl(control: Control): Container;
  80698. /** Gets the list of children */
  80699. get children(): Control[];
  80700. _flagDescendantsAsMatrixDirty(): void;
  80701. /**
  80702. * Freezes or unfreezes the controls in the window.
  80703. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  80704. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  80705. */
  80706. get freezeControls(): boolean;
  80707. set freezeControls(value: boolean);
  80708. /** Gets the bucket width */
  80709. get bucketWidth(): number;
  80710. /** Gets the bucket height */
  80711. get bucketHeight(): number;
  80712. /**
  80713. * Sets the bucket sizes.
  80714. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  80715. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  80716. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  80717. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  80718. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  80719. * used), that's why it is not enabled by default.
  80720. * @param width width of the bucket
  80721. * @param height height of the bucket
  80722. */
  80723. setBucketSizes(width: number, height: number): void;
  80724. private _forceHorizontalBar;
  80725. private _forceVerticalBar;
  80726. /**
  80727. * Forces the horizontal scroll bar to be displayed
  80728. */
  80729. get forceHorizontalBar(): boolean;
  80730. set forceHorizontalBar(value: boolean);
  80731. /**
  80732. * Forces the vertical scroll bar to be displayed
  80733. */
  80734. get forceVerticalBar(): boolean;
  80735. set forceVerticalBar(value: boolean);
  80736. /**
  80737. * Creates a new ScrollViewer
  80738. * @param name of ScrollViewer
  80739. */
  80740. constructor(name?: string, isImageBased?: boolean);
  80741. /** Reset the scroll viewer window to initial size */
  80742. resetWindow(): void;
  80743. protected _getTypeName(): string;
  80744. private _buildClientSizes;
  80745. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80746. protected _postMeasure(): void;
  80747. /**
  80748. * Gets or sets the mouse wheel precision
  80749. * from 0 to 1 with a default value of 0.05
  80750. * */
  80751. get wheelPrecision(): number;
  80752. set wheelPrecision(value: number);
  80753. /** Gets or sets the scroll bar container background color */
  80754. get scrollBackground(): string;
  80755. set scrollBackground(color: string);
  80756. /** Gets or sets the bar color */
  80757. get barColor(): string;
  80758. set barColor(color: string);
  80759. /** Gets or sets the bar image */
  80760. get thumbImage(): Image;
  80761. set thumbImage(value: Image);
  80762. /** Gets or sets the horizontal bar image */
  80763. get horizontalThumbImage(): Image;
  80764. set horizontalThumbImage(value: Image);
  80765. /** Gets or sets the vertical bar image */
  80766. get verticalThumbImage(): Image;
  80767. set verticalThumbImage(value: Image);
  80768. /** Gets or sets the size of the bar */
  80769. get barSize(): number;
  80770. set barSize(value: number);
  80771. /** Gets or sets the length of the thumb */
  80772. get thumbLength(): number;
  80773. set thumbLength(value: number);
  80774. /** Gets or sets the height of the thumb */
  80775. get thumbHeight(): number;
  80776. set thumbHeight(value: number);
  80777. /** Gets or sets the height of the bar image */
  80778. get barImageHeight(): number;
  80779. set barImageHeight(value: number);
  80780. /** Gets or sets the height of the horizontal bar image */
  80781. get horizontalBarImageHeight(): number;
  80782. set horizontalBarImageHeight(value: number);
  80783. /** Gets or sets the height of the vertical bar image */
  80784. get verticalBarImageHeight(): number;
  80785. set verticalBarImageHeight(value: number);
  80786. /** Gets or sets the bar background */
  80787. get barBackground(): string;
  80788. set barBackground(color: string);
  80789. /** Gets or sets the bar background image */
  80790. get barImage(): Image;
  80791. set barImage(value: Image);
  80792. /** Gets or sets the horizontal bar background image */
  80793. get horizontalBarImage(): Image;
  80794. set horizontalBarImage(value: Image);
  80795. /** Gets or sets the vertical bar background image */
  80796. get verticalBarImage(): Image;
  80797. set verticalBarImage(value: Image);
  80798. private _setWindowPosition;
  80799. /** @hidden */
  80800. private _updateScroller;
  80801. _link(host: AdvancedDynamicTexture): void;
  80802. /** @hidden */
  80803. private _addBar;
  80804. /** @hidden */
  80805. private _attachWheel;
  80806. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  80807. /** Releases associated resources */
  80808. dispose(): void;
  80809. }
  80810. }
  80811. declare module BABYLON.GUI {
  80812. /** Class used to render a grid */
  80813. export class DisplayGrid extends Control {
  80814. name?: string | undefined;
  80815. private _cellWidth;
  80816. private _cellHeight;
  80817. private _minorLineTickness;
  80818. private _minorLineColor;
  80819. private _majorLineTickness;
  80820. private _majorLineColor;
  80821. private _majorLineFrequency;
  80822. private _background;
  80823. private _displayMajorLines;
  80824. private _displayMinorLines;
  80825. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  80826. get displayMinorLines(): boolean;
  80827. set displayMinorLines(value: boolean);
  80828. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  80829. get displayMajorLines(): boolean;
  80830. set displayMajorLines(value: boolean);
  80831. /** Gets or sets background color (Black by default) */
  80832. get background(): string;
  80833. set background(value: string);
  80834. /** Gets or sets the width of each cell (20 by default) */
  80835. get cellWidth(): number;
  80836. set cellWidth(value: number);
  80837. /** Gets or sets the height of each cell (20 by default) */
  80838. get cellHeight(): number;
  80839. set cellHeight(value: number);
  80840. /** Gets or sets the tickness of minor lines (1 by default) */
  80841. get minorLineTickness(): number;
  80842. set minorLineTickness(value: number);
  80843. /** Gets or sets the color of minor lines (DarkGray by default) */
  80844. get minorLineColor(): string;
  80845. set minorLineColor(value: string);
  80846. /** Gets or sets the tickness of major lines (2 by default) */
  80847. get majorLineTickness(): number;
  80848. set majorLineTickness(value: number);
  80849. /** Gets or sets the color of major lines (White by default) */
  80850. get majorLineColor(): string;
  80851. set majorLineColor(value: string);
  80852. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  80853. get majorLineFrequency(): number;
  80854. set majorLineFrequency(value: number);
  80855. /**
  80856. * Creates a new GridDisplayRectangle
  80857. * @param name defines the control name
  80858. */
  80859. constructor(name?: string | undefined);
  80860. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80861. protected _getTypeName(): string;
  80862. }
  80863. }
  80864. declare module BABYLON.GUI {
  80865. /**
  80866. * Class used to create slider controls based on images
  80867. */
  80868. export class ImageBasedSlider extends BaseSlider {
  80869. name?: string | undefined;
  80870. private _backgroundImage;
  80871. private _thumbImage;
  80872. private _valueBarImage;
  80873. private _tempMeasure;
  80874. get displayThumb(): boolean;
  80875. set displayThumb(value: boolean);
  80876. /**
  80877. * Gets or sets the image used to render the background
  80878. */
  80879. get backgroundImage(): Image;
  80880. set backgroundImage(value: Image);
  80881. /**
  80882. * Gets or sets the image used to render the value bar
  80883. */
  80884. get valueBarImage(): Image;
  80885. set valueBarImage(value: Image);
  80886. /**
  80887. * Gets or sets the image used to render the thumb
  80888. */
  80889. get thumbImage(): Image;
  80890. set thumbImage(value: Image);
  80891. /**
  80892. * Creates a new ImageBasedSlider
  80893. * @param name defines the control name
  80894. */
  80895. constructor(name?: string | undefined);
  80896. protected _getTypeName(): string;
  80897. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80898. }
  80899. }
  80900. declare module BABYLON.GUI {
  80901. /**
  80902. * Forcing an export so that this code will execute
  80903. * @hidden
  80904. */
  80905. const name = "Statics";
  80906. }
  80907. declare module BABYLON.GUI {
  80908. /**
  80909. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  80910. */
  80911. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  80912. /**
  80913. * Define the instrumented AdvancedDynamicTexture.
  80914. */
  80915. texture: AdvancedDynamicTexture;
  80916. private _captureRenderTime;
  80917. private _renderTime;
  80918. private _captureLayoutTime;
  80919. private _layoutTime;
  80920. private _onBeginRenderObserver;
  80921. private _onEndRenderObserver;
  80922. private _onBeginLayoutObserver;
  80923. private _onEndLayoutObserver;
  80924. /**
  80925. * Gets the perf counter used to capture render time
  80926. */
  80927. get renderTimeCounter(): BABYLON.PerfCounter;
  80928. /**
  80929. * Gets the perf counter used to capture layout time
  80930. */
  80931. get layoutTimeCounter(): BABYLON.PerfCounter;
  80932. /**
  80933. * Enable or disable the render time capture
  80934. */
  80935. get captureRenderTime(): boolean;
  80936. set captureRenderTime(value: boolean);
  80937. /**
  80938. * Enable or disable the layout time capture
  80939. */
  80940. get captureLayoutTime(): boolean;
  80941. set captureLayoutTime(value: boolean);
  80942. /**
  80943. * Instantiates a new advanced dynamic texture instrumentation.
  80944. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  80945. * @param texture Defines the AdvancedDynamicTexture to instrument
  80946. */
  80947. constructor(
  80948. /**
  80949. * Define the instrumented AdvancedDynamicTexture.
  80950. */
  80951. texture: AdvancedDynamicTexture);
  80952. /**
  80953. * Dispose and release associated resources.
  80954. */
  80955. dispose(): void;
  80956. }
  80957. }
  80958. declare module BABYLON.GUI {
  80959. /**
  80960. * Class used to load GUI via XML.
  80961. */
  80962. export class XmlLoader {
  80963. private _nodes;
  80964. private _nodeTypes;
  80965. private _isLoaded;
  80966. private _objectAttributes;
  80967. private _parentClass;
  80968. /**
  80969. * Create a new xml loader
  80970. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  80971. */
  80972. constructor(parentClass?: null);
  80973. private _getChainElement;
  80974. private _getClassAttribute;
  80975. private _createGuiElement;
  80976. private _parseGrid;
  80977. private _parseElement;
  80978. private _prepareSourceElement;
  80979. private _parseElementsFromSource;
  80980. private _parseXml;
  80981. /**
  80982. * Gets if the loading has finished.
  80983. * @returns whether the loading has finished or not
  80984. */
  80985. isLoaded(): boolean;
  80986. /**
  80987. * Gets a loaded node / control by id.
  80988. * @param id the Controls id set in the xml
  80989. * @returns element of type Control
  80990. */
  80991. getNodeById(id: string): any;
  80992. /**
  80993. * Gets all loaded nodes / controls
  80994. * @returns Array of controls
  80995. */
  80996. getNodes(): any;
  80997. /**
  80998. * Initiates the xml layout loading
  80999. * @param xmlFile defines the xml layout to load
  81000. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  81001. * @param callback defines the callback called on layout load.
  81002. */
  81003. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  81004. }
  81005. }
  81006. declare module BABYLON.GUI {
  81007. /**
  81008. * Class used to create containers for controls
  81009. */
  81010. export class Container3D extends Control3D {
  81011. private _blockLayout;
  81012. /**
  81013. * Gets the list of child controls
  81014. */
  81015. protected _children: Control3D[];
  81016. /**
  81017. * Gets the list of child controls
  81018. */
  81019. get children(): Array<Control3D>;
  81020. /**
  81021. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  81022. * This is helpful to optimize layout operation when adding multiple children in a row
  81023. */
  81024. get blockLayout(): boolean;
  81025. set blockLayout(value: boolean);
  81026. /**
  81027. * Creates a new container
  81028. * @param name defines the container name
  81029. */
  81030. constructor(name?: string);
  81031. /**
  81032. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  81033. * @returns the current container
  81034. */
  81035. updateLayout(): Container3D;
  81036. /**
  81037. * Gets a boolean indicating if the given control is in the children of this control
  81038. * @param control defines the control to check
  81039. * @returns true if the control is in the child list
  81040. */
  81041. containsControl(control: Control3D): boolean;
  81042. /**
  81043. * Adds a control to the children of this control
  81044. * @param control defines the control to add
  81045. * @returns the current container
  81046. */
  81047. addControl(control: Control3D): Container3D;
  81048. /**
  81049. * This function will be called everytime a new control is added
  81050. */
  81051. protected _arrangeChildren(): void;
  81052. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  81053. /**
  81054. * Removes a control from the children of this control
  81055. * @param control defines the control to remove
  81056. * @returns the current container
  81057. */
  81058. removeControl(control: Control3D): Container3D;
  81059. protected _getTypeName(): string;
  81060. /**
  81061. * Releases all associated resources
  81062. */
  81063. dispose(): void;
  81064. /** Control rotation will remain unchanged */
  81065. static readonly UNSET_ORIENTATION: number;
  81066. /** Control will rotate to make it look at sphere central axis */
  81067. static readonly FACEORIGIN_ORIENTATION: number;
  81068. /** Control will rotate to make it look back at sphere central axis */
  81069. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  81070. /** Control will rotate to look at z axis (0, 0, 1) */
  81071. static readonly FACEFORWARD_ORIENTATION: number;
  81072. /** Control will rotate to look at negative z axis (0, 0, -1) */
  81073. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  81074. }
  81075. }
  81076. declare module BABYLON.GUI {
  81077. /**
  81078. * Class used to manage 3D user interface
  81079. * @see https://doc.babylonjs.com/how_to/gui3d
  81080. */
  81081. export class GUI3DManager implements BABYLON.IDisposable {
  81082. private _scene;
  81083. private _sceneDisposeObserver;
  81084. private _utilityLayer;
  81085. private _rootContainer;
  81086. private _pointerObserver;
  81087. private _pointerOutObserver;
  81088. /** @hidden */
  81089. _lastPickedControl: Control3D;
  81090. /** @hidden */
  81091. _lastControlOver: {
  81092. [pointerId: number]: Control3D;
  81093. };
  81094. /** @hidden */
  81095. _lastControlDown: {
  81096. [pointerId: number]: Control3D;
  81097. };
  81098. /**
  81099. * BABYLON.Observable raised when the point picked by the pointer events changed
  81100. */
  81101. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  81102. /** @hidden */
  81103. _sharedMaterials: {
  81104. [key: string]: BABYLON.Material;
  81105. };
  81106. /** Gets the hosting scene */
  81107. get scene(): BABYLON.Scene;
  81108. /** Gets associated utility layer */
  81109. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  81110. /**
  81111. * Creates a new GUI3DManager
  81112. * @param scene
  81113. */
  81114. constructor(scene?: BABYLON.Scene);
  81115. private _handlePointerOut;
  81116. private _doPicking;
  81117. /**
  81118. * Gets the root container
  81119. */
  81120. get rootContainer(): Container3D;
  81121. /**
  81122. * Gets a boolean indicating if the given control is in the root child list
  81123. * @param control defines the control to check
  81124. * @returns true if the control is in the root child list
  81125. */
  81126. containsControl(control: Control3D): boolean;
  81127. /**
  81128. * Adds a control to the root child list
  81129. * @param control defines the control to add
  81130. * @returns the current manager
  81131. */
  81132. addControl(control: Control3D): GUI3DManager;
  81133. /**
  81134. * Removes a control from the root child list
  81135. * @param control defines the control to remove
  81136. * @returns the current container
  81137. */
  81138. removeControl(control: Control3D): GUI3DManager;
  81139. /**
  81140. * Releases all associated resources
  81141. */
  81142. dispose(): void;
  81143. }
  81144. }
  81145. declare module BABYLON.GUI {
  81146. /**
  81147. * Class used to transport BABYLON.Vector3 information for pointer events
  81148. */
  81149. export class Vector3WithInfo extends BABYLON.Vector3 {
  81150. /** defines the current mouse button index */
  81151. buttonIndex: number;
  81152. /**
  81153. * Creates a new Vector3WithInfo
  81154. * @param source defines the vector3 data to transport
  81155. * @param buttonIndex defines the current mouse button index
  81156. */
  81157. constructor(source: BABYLON.Vector3,
  81158. /** defines the current mouse button index */
  81159. buttonIndex?: number);
  81160. }
  81161. }
  81162. declare module BABYLON.GUI {
  81163. /**
  81164. * Class used as base class for controls
  81165. */
  81166. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  81167. /** Defines the control name */
  81168. name?: string | undefined;
  81169. /** @hidden */
  81170. _host: GUI3DManager;
  81171. private _node;
  81172. private _downCount;
  81173. private _enterCount;
  81174. private _downPointerIds;
  81175. private _isVisible;
  81176. /** Gets or sets the control position in world space */
  81177. get position(): BABYLON.Vector3;
  81178. set position(value: BABYLON.Vector3);
  81179. /** Gets or sets the control scaling in world space */
  81180. get scaling(): BABYLON.Vector3;
  81181. set scaling(value: BABYLON.Vector3);
  81182. /** Callback used to start pointer enter animation */
  81183. pointerEnterAnimation: () => void;
  81184. /** Callback used to start pointer out animation */
  81185. pointerOutAnimation: () => void;
  81186. /** Callback used to start pointer down animation */
  81187. pointerDownAnimation: () => void;
  81188. /** Callback used to start pointer up animation */
  81189. pointerUpAnimation: () => void;
  81190. /**
  81191. * An event triggered when the pointer move over the control
  81192. */
  81193. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  81194. /**
  81195. * An event triggered when the pointer move out of the control
  81196. */
  81197. onPointerOutObservable: BABYLON.Observable<Control3D>;
  81198. /**
  81199. * An event triggered when the pointer taps the control
  81200. */
  81201. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  81202. /**
  81203. * An event triggered when pointer is up
  81204. */
  81205. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  81206. /**
  81207. * An event triggered when a control is clicked on (with a mouse)
  81208. */
  81209. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  81210. /**
  81211. * An event triggered when pointer enters the control
  81212. */
  81213. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  81214. /**
  81215. * Gets or sets the parent container
  81216. */
  81217. parent: BABYLON.Nullable<Container3D>;
  81218. private _behaviors;
  81219. /**
  81220. * Gets the list of attached behaviors
  81221. * @see https://doc.babylonjs.com/features/behaviour
  81222. */
  81223. get behaviors(): BABYLON.Behavior<Control3D>[];
  81224. /**
  81225. * Attach a behavior to the control
  81226. * @see https://doc.babylonjs.com/features/behaviour
  81227. * @param behavior defines the behavior to attach
  81228. * @returns the current control
  81229. */
  81230. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  81231. /**
  81232. * Remove an attached behavior
  81233. * @see https://doc.babylonjs.com/features/behaviour
  81234. * @param behavior defines the behavior to attach
  81235. * @returns the current control
  81236. */
  81237. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  81238. /**
  81239. * Gets an attached behavior by name
  81240. * @param name defines the name of the behavior to look for
  81241. * @see https://doc.babylonjs.com/features/behaviour
  81242. * @returns null if behavior was not found else the requested behavior
  81243. */
  81244. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  81245. /** Gets or sets a boolean indicating if the control is visible */
  81246. get isVisible(): boolean;
  81247. set isVisible(value: boolean);
  81248. /**
  81249. * Creates a new control
  81250. * @param name defines the control name
  81251. */
  81252. constructor(
  81253. /** Defines the control name */
  81254. name?: string | undefined);
  81255. /**
  81256. * Gets a string representing the class name
  81257. */
  81258. get typeName(): string;
  81259. /**
  81260. * Get the current class name of the control.
  81261. * @returns current class name
  81262. */
  81263. getClassName(): string;
  81264. protected _getTypeName(): string;
  81265. /**
  81266. * Gets the transform node used by this control
  81267. */
  81268. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  81269. /**
  81270. * Gets the mesh used to render this control
  81271. */
  81272. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  81273. /**
  81274. * Link the control as child of the given node
  81275. * @param node defines the node to link to. Use null to unlink the control
  81276. * @returns the current control
  81277. */
  81278. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  81279. /** @hidden **/
  81280. _prepareNode(scene: BABYLON.Scene): void;
  81281. /**
  81282. * Node creation.
  81283. * Can be overriden by children
  81284. * @param scene defines the scene where the node must be attached
  81285. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  81286. */
  81287. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  81288. /**
  81289. * Affect a material to the given mesh
  81290. * @param mesh defines the mesh which will represent the control
  81291. */
  81292. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81293. /** @hidden */
  81294. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  81295. /** @hidden */
  81296. _onPointerEnter(target: Control3D): boolean;
  81297. /** @hidden */
  81298. _onPointerOut(target: Control3D): void;
  81299. /** @hidden */
  81300. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  81301. /** @hidden */
  81302. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  81303. /** @hidden */
  81304. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  81305. /** @hidden */
  81306. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  81307. /** @hidden */
  81308. _disposeNode(): void;
  81309. /**
  81310. * Releases all associated resources
  81311. */
  81312. dispose(): void;
  81313. }
  81314. }
  81315. declare module BABYLON.GUI {
  81316. /**
  81317. * Class used as a root to all buttons
  81318. */
  81319. export class AbstractButton3D extends Control3D {
  81320. /**
  81321. * Creates a new button
  81322. * @param name defines the control name
  81323. */
  81324. constructor(name?: string);
  81325. protected _getTypeName(): string;
  81326. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81327. }
  81328. }
  81329. declare module BABYLON.GUI {
  81330. /**
  81331. * Class used to create a button in 3D
  81332. */
  81333. export class Button3D extends AbstractButton3D {
  81334. /** @hidden */
  81335. protected _currentMaterial: BABYLON.Material;
  81336. private _facadeTexture;
  81337. private _content;
  81338. private _contentResolution;
  81339. private _contentScaleRatio;
  81340. /**
  81341. * Gets or sets the texture resolution used to render content (512 by default)
  81342. */
  81343. get contentResolution(): BABYLON.int;
  81344. set contentResolution(value: BABYLON.int);
  81345. /**
  81346. * Gets or sets the texture scale ratio used to render content (2 by default)
  81347. */
  81348. get contentScaleRatio(): number;
  81349. set contentScaleRatio(value: number);
  81350. protected _disposeFacadeTexture(): void;
  81351. protected _resetContent(): void;
  81352. /**
  81353. * Creates a new button
  81354. * @param name defines the control name
  81355. */
  81356. constructor(name?: string);
  81357. /**
  81358. * Gets or sets the GUI 2D content used to display the button's facade
  81359. */
  81360. get content(): Control;
  81361. set content(value: Control);
  81362. /**
  81363. * Apply the facade texture (created from the content property).
  81364. * This function can be overloaded by child classes
  81365. * @param facadeTexture defines the AdvancedDynamicTexture to use
  81366. */
  81367. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  81368. protected _getTypeName(): string;
  81369. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81370. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81371. /**
  81372. * Releases all associated resources
  81373. */
  81374. dispose(): void;
  81375. }
  81376. }
  81377. declare module BABYLON.GUI {
  81378. /**
  81379. * Abstract class used to create a container panel deployed on the surface of a volume
  81380. */
  81381. export abstract class VolumeBasedPanel extends Container3D {
  81382. private _columns;
  81383. private _rows;
  81384. private _rowThenColum;
  81385. private _orientation;
  81386. protected _cellWidth: number;
  81387. protected _cellHeight: number;
  81388. /**
  81389. * Gets or sets the distance between elements
  81390. */
  81391. margin: number;
  81392. /**
  81393. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  81394. * | Value | Type | Description |
  81395. * | ----- | ----------------------------------- | ----------- |
  81396. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  81397. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  81398. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  81399. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  81400. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  81401. */
  81402. get orientation(): number;
  81403. set orientation(value: number);
  81404. /**
  81405. * Gets or sets the number of columns requested (10 by default).
  81406. * The panel will automatically compute the number of rows based on number of child controls.
  81407. */
  81408. get columns(): BABYLON.int;
  81409. set columns(value: BABYLON.int);
  81410. /**
  81411. * Gets or sets a the number of rows requested.
  81412. * The panel will automatically compute the number of columns based on number of child controls.
  81413. */
  81414. get rows(): BABYLON.int;
  81415. set rows(value: BABYLON.int);
  81416. /**
  81417. * Creates new VolumeBasedPanel
  81418. */
  81419. constructor();
  81420. protected _arrangeChildren(): void;
  81421. /** Child classes must implement this function to provide correct control positioning */
  81422. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81423. /** Child classes can implement this function to provide additional processing */
  81424. protected _finalProcessing(): void;
  81425. }
  81426. }
  81427. declare module BABYLON.GUI {
  81428. /**
  81429. * Class used to create a container panel deployed on the surface of a cylinder
  81430. */
  81431. export class CylinderPanel extends VolumeBasedPanel {
  81432. private _radius;
  81433. /**
  81434. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  81435. */
  81436. get radius(): BABYLON.float;
  81437. set radius(value: BABYLON.float);
  81438. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81439. private _cylindricalMapping;
  81440. }
  81441. }
  81442. declare module BABYLON.GUI {
  81443. /** @hidden */
  81444. export var fluentVertexShader: {
  81445. name: string;
  81446. shader: string;
  81447. };
  81448. }
  81449. declare module BABYLON.GUI {
  81450. /** @hidden */
  81451. export var fluentPixelShader: {
  81452. name: string;
  81453. shader: string;
  81454. };
  81455. }
  81456. declare module BABYLON.GUI {
  81457. /** @hidden */
  81458. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  81459. INNERGLOW: boolean;
  81460. BORDER: boolean;
  81461. HOVERLIGHT: boolean;
  81462. TEXTURE: boolean;
  81463. constructor();
  81464. }
  81465. /**
  81466. * Class used to render controls with fluent desgin
  81467. */
  81468. export class FluentMaterial extends BABYLON.PushMaterial {
  81469. /**
  81470. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  81471. */
  81472. innerGlowColorIntensity: number;
  81473. /**
  81474. * Gets or sets the inner glow color (white by default)
  81475. */
  81476. innerGlowColor: BABYLON.Color3;
  81477. /**
  81478. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  81479. */
  81480. albedoColor: BABYLON.Color3;
  81481. /**
  81482. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  81483. */
  81484. renderBorders: boolean;
  81485. /**
  81486. * Gets or sets border width (default is 0.5)
  81487. */
  81488. borderWidth: number;
  81489. /**
  81490. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  81491. */
  81492. edgeSmoothingValue: number;
  81493. /**
  81494. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  81495. */
  81496. borderMinValue: number;
  81497. /**
  81498. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  81499. */
  81500. renderHoverLight: boolean;
  81501. /**
  81502. * Gets or sets the radius used to render the hover light (default is 1.0)
  81503. */
  81504. hoverRadius: number;
  81505. /**
  81506. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  81507. */
  81508. hoverColor: BABYLON.Color4;
  81509. /**
  81510. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  81511. */
  81512. hoverPosition: BABYLON.Vector3;
  81513. private _albedoTexture;
  81514. /** Gets or sets the texture to use for albedo color */
  81515. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  81516. /**
  81517. * Creates a new Fluent material
  81518. * @param name defines the name of the material
  81519. * @param scene defines the hosting scene
  81520. */
  81521. constructor(name: string, scene: BABYLON.Scene);
  81522. needAlphaBlending(): boolean;
  81523. needAlphaTesting(): boolean;
  81524. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81525. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81526. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81527. getActiveTextures(): BABYLON.BaseTexture[];
  81528. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81529. dispose(forceDisposeEffect?: boolean): void;
  81530. clone(name: string): FluentMaterial;
  81531. serialize(): any;
  81532. getClassName(): string;
  81533. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  81534. }
  81535. }
  81536. declare module BABYLON.GUI {
  81537. /**
  81538. * Class used to create a holographic button in 3D
  81539. */
  81540. export class HolographicButton extends Button3D {
  81541. private _backPlate;
  81542. private _textPlate;
  81543. private _frontPlate;
  81544. private _text;
  81545. private _imageUrl;
  81546. private _shareMaterials;
  81547. private _frontMaterial;
  81548. private _backMaterial;
  81549. private _plateMaterial;
  81550. private _pickedPointObserver;
  81551. private _tooltipFade;
  81552. private _tooltipTextBlock;
  81553. private _tooltipTexture;
  81554. private _tooltipMesh;
  81555. private _tooltipHoverObserver;
  81556. private _tooltipOutObserver;
  81557. private _disposeTooltip;
  81558. /**
  81559. * Rendering ground id of all the mesh in the button
  81560. */
  81561. set renderingGroupId(id: number);
  81562. get renderingGroupId(): number;
  81563. /**
  81564. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  81565. */
  81566. set tooltipText(text: BABYLON.Nullable<string>);
  81567. get tooltipText(): BABYLON.Nullable<string>;
  81568. /**
  81569. * Gets or sets text for the button
  81570. */
  81571. get text(): string;
  81572. set text(value: string);
  81573. /**
  81574. * Gets or sets the image url for the button
  81575. */
  81576. get imageUrl(): string;
  81577. set imageUrl(value: string);
  81578. /**
  81579. * Gets the back material used by this button
  81580. */
  81581. get backMaterial(): FluentMaterial;
  81582. /**
  81583. * Gets the front material used by this button
  81584. */
  81585. get frontMaterial(): FluentMaterial;
  81586. /**
  81587. * Gets the plate material used by this button
  81588. */
  81589. get plateMaterial(): BABYLON.StandardMaterial;
  81590. /**
  81591. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  81592. */
  81593. get shareMaterials(): boolean;
  81594. /**
  81595. * Creates a new button
  81596. * @param name defines the control name
  81597. */
  81598. constructor(name?: string, shareMaterials?: boolean);
  81599. protected _getTypeName(): string;
  81600. private _rebuildContent;
  81601. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81602. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  81603. private _createBackMaterial;
  81604. private _createFrontMaterial;
  81605. private _createPlateMaterial;
  81606. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  81607. /**
  81608. * Releases all associated resources
  81609. */
  81610. dispose(): void;
  81611. }
  81612. }
  81613. declare module BABYLON.GUI {
  81614. /**
  81615. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  81616. */
  81617. export class MeshButton3D extends Button3D {
  81618. /** @hidden */
  81619. protected _currentMesh: BABYLON.Mesh;
  81620. /**
  81621. * Creates a new 3D button based on a mesh
  81622. * @param mesh mesh to become a 3D button
  81623. * @param name defines the control name
  81624. */
  81625. constructor(mesh: BABYLON.Mesh, name?: string);
  81626. protected _getTypeName(): string;
  81627. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81628. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81629. }
  81630. }
  81631. declare module BABYLON.GUI {
  81632. /**
  81633. * Class used to create a container panel deployed on the surface of a plane
  81634. */
  81635. export class PlanePanel extends VolumeBasedPanel {
  81636. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81637. }
  81638. }
  81639. declare module BABYLON.GUI {
  81640. /**
  81641. * Class used to create a container panel where items get randomized planar mapping
  81642. */
  81643. export class ScatterPanel extends VolumeBasedPanel {
  81644. private _iteration;
  81645. /**
  81646. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  81647. */
  81648. get iteration(): BABYLON.float;
  81649. set iteration(value: BABYLON.float);
  81650. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81651. private _scatterMapping;
  81652. protected _finalProcessing(): void;
  81653. }
  81654. }
  81655. declare module BABYLON.GUI {
  81656. /**
  81657. * Class used to create a container panel deployed on the surface of a sphere
  81658. */
  81659. export class SpherePanel extends VolumeBasedPanel {
  81660. private _radius;
  81661. /**
  81662. * Gets or sets the radius of the sphere where to project controls (5 by default)
  81663. */
  81664. get radius(): BABYLON.float;
  81665. set radius(value: BABYLON.float);
  81666. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81667. private _sphericalMapping;
  81668. }
  81669. }
  81670. declare module BABYLON.GUI {
  81671. /**
  81672. * Class used to create a stack panel in 3D on XY plane
  81673. */
  81674. export class StackPanel3D extends Container3D {
  81675. private _isVertical;
  81676. /**
  81677. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  81678. */
  81679. get isVertical(): boolean;
  81680. set isVertical(value: boolean);
  81681. /**
  81682. * Gets or sets the distance between elements
  81683. */
  81684. margin: number;
  81685. /**
  81686. * Creates new StackPanel
  81687. * @param isVertical
  81688. */
  81689. constructor(isVertical?: boolean);
  81690. protected _arrangeChildren(): void;
  81691. }
  81692. }
  81693. declare module BABYLON {
  81694. /**
  81695. * Configuration for glTF validation
  81696. */
  81697. export interface IGLTFValidationConfiguration {
  81698. /**
  81699. * The url of the glTF validator.
  81700. */
  81701. url: string;
  81702. }
  81703. /**
  81704. * glTF validation
  81705. */
  81706. export class GLTFValidation {
  81707. /**
  81708. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  81709. */
  81710. static Configuration: IGLTFValidationConfiguration;
  81711. private static _LoadScriptPromise;
  81712. /**
  81713. * Validate a glTF asset using the glTF-Validator.
  81714. * @param data The JSON of a glTF or the array buffer of a binary glTF
  81715. * @param rootUrl The root url for the glTF
  81716. * @param fileName The file name for the glTF
  81717. * @param getExternalResource The callback to get external resources for the glTF validator
  81718. * @returns A promise that resolves with the glTF validation results once complete
  81719. */
  81720. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  81721. }
  81722. }
  81723. declare module BABYLON {
  81724. /**
  81725. * Mode that determines the coordinate system to use.
  81726. */
  81727. export enum GLTFLoaderCoordinateSystemMode {
  81728. /**
  81729. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  81730. */
  81731. AUTO = 0,
  81732. /**
  81733. * Sets the useRightHandedSystem flag on the scene.
  81734. */
  81735. FORCE_RIGHT_HANDED = 1
  81736. }
  81737. /**
  81738. * Mode that determines what animations will start.
  81739. */
  81740. export enum GLTFLoaderAnimationStartMode {
  81741. /**
  81742. * No animation will start.
  81743. */
  81744. NONE = 0,
  81745. /**
  81746. * The first animation will start.
  81747. */
  81748. FIRST = 1,
  81749. /**
  81750. * All animations will start.
  81751. */
  81752. ALL = 2
  81753. }
  81754. /**
  81755. * Interface that contains the data for the glTF asset.
  81756. */
  81757. export interface IGLTFLoaderData {
  81758. /**
  81759. * The object that represents the glTF JSON.
  81760. */
  81761. json: Object;
  81762. /**
  81763. * The BIN chunk of a binary glTF.
  81764. */
  81765. bin: Nullable<IDataBuffer>;
  81766. }
  81767. /**
  81768. * Interface for extending the loader.
  81769. */
  81770. export interface IGLTFLoaderExtension {
  81771. /**
  81772. * The name of this extension.
  81773. */
  81774. readonly name: string;
  81775. /**
  81776. * Defines whether this extension is enabled.
  81777. */
  81778. enabled: boolean;
  81779. /**
  81780. * Defines the order of this extension.
  81781. * The loader sorts the extensions using these values when loading.
  81782. */
  81783. order?: number;
  81784. }
  81785. /**
  81786. * Loader state.
  81787. */
  81788. export enum GLTFLoaderState {
  81789. /**
  81790. * The asset is loading.
  81791. */
  81792. LOADING = 0,
  81793. /**
  81794. * The asset is ready for rendering.
  81795. */
  81796. READY = 1,
  81797. /**
  81798. * The asset is completely loaded.
  81799. */
  81800. COMPLETE = 2
  81801. }
  81802. /** @hidden */
  81803. export interface IImportMeshAsyncOutput {
  81804. meshes: AbstractMesh[];
  81805. geometries: Geometry[];
  81806. particleSystems: IParticleSystem[];
  81807. skeletons: Skeleton[];
  81808. animationGroups: AnimationGroup[];
  81809. lights: Light[];
  81810. transformNodes: TransformNode[];
  81811. }
  81812. /** @hidden */
  81813. export interface IGLTFLoader extends IDisposable {
  81814. readonly state: Nullable<GLTFLoaderState>;
  81815. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  81816. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  81817. }
  81818. /**
  81819. * File loader for loading glTF files into a scene.
  81820. */
  81821. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  81822. /** @hidden */
  81823. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  81824. /** @hidden */
  81825. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  81826. /**
  81827. * Raised when the asset has been parsed
  81828. */
  81829. onParsedObservable: Observable<IGLTFLoaderData>;
  81830. private _onParsedObserver;
  81831. /**
  81832. * Raised when the asset has been parsed
  81833. */
  81834. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  81835. /**
  81836. * 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.
  81837. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  81838. * Defaults to true.
  81839. * @hidden
  81840. */
  81841. static IncrementalLoading: boolean;
  81842. /**
  81843. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  81844. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  81845. * @hidden
  81846. */
  81847. static HomogeneousCoordinates: boolean;
  81848. /**
  81849. * The coordinate system mode. Defaults to AUTO.
  81850. */
  81851. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  81852. /**
  81853. * The animation start mode. Defaults to FIRST.
  81854. */
  81855. animationStartMode: GLTFLoaderAnimationStartMode;
  81856. /**
  81857. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  81858. */
  81859. compileMaterials: boolean;
  81860. /**
  81861. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  81862. */
  81863. useClipPlane: boolean;
  81864. /**
  81865. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  81866. */
  81867. compileShadowGenerators: boolean;
  81868. /**
  81869. * Defines if the Alpha blended materials are only applied as coverage.
  81870. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  81871. * If true, no extra effects are applied to transparent pixels.
  81872. */
  81873. transparencyAsCoverage: boolean;
  81874. /**
  81875. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  81876. * Enabling will disable offline support and glTF validator.
  81877. * Defaults to false.
  81878. */
  81879. useRangeRequests: boolean;
  81880. /**
  81881. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  81882. */
  81883. createInstances: boolean;
  81884. /**
  81885. * 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.
  81886. */
  81887. alwaysComputeBoundingBox: boolean;
  81888. /**
  81889. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  81890. */
  81891. loadAllMaterials: boolean;
  81892. /**
  81893. * Function called before loading a url referenced by the asset.
  81894. */
  81895. preprocessUrlAsync: (url: string) => Promise<string>;
  81896. /**
  81897. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  81898. * 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, ...)
  81899. */
  81900. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  81901. private _onMeshLoadedObserver;
  81902. /**
  81903. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  81904. * 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, ...)
  81905. */
  81906. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  81907. /**
  81908. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  81909. */
  81910. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  81911. private _onTextureLoadedObserver;
  81912. /**
  81913. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  81914. */
  81915. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  81916. /**
  81917. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  81918. */
  81919. readonly onMaterialLoadedObservable: Observable<Material>;
  81920. private _onMaterialLoadedObserver;
  81921. /**
  81922. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  81923. */
  81924. set onMaterialLoaded(callback: (material: Material) => void);
  81925. /**
  81926. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  81927. */
  81928. readonly onCameraLoadedObservable: Observable<Camera>;
  81929. private _onCameraLoadedObserver;
  81930. /**
  81931. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  81932. */
  81933. set onCameraLoaded(callback: (camera: Camera) => void);
  81934. /**
  81935. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  81936. * For assets with LODs, raised when all of the LODs are complete.
  81937. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  81938. */
  81939. readonly onCompleteObservable: Observable<void>;
  81940. private _onCompleteObserver;
  81941. /**
  81942. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  81943. * For assets with LODs, raised when all of the LODs are complete.
  81944. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  81945. */
  81946. set onComplete(callback: () => void);
  81947. /**
  81948. * Observable raised when an error occurs.
  81949. */
  81950. readonly onErrorObservable: Observable<any>;
  81951. private _onErrorObserver;
  81952. /**
  81953. * Callback raised when an error occurs.
  81954. */
  81955. set onError(callback: (reason: any) => void);
  81956. /**
  81957. * Observable raised after the loader is disposed.
  81958. */
  81959. readonly onDisposeObservable: Observable<void>;
  81960. private _onDisposeObserver;
  81961. /**
  81962. * Callback raised after the loader is disposed.
  81963. */
  81964. set onDispose(callback: () => void);
  81965. /**
  81966. * Observable raised after a loader extension is created.
  81967. * Set additional options for a loader extension in this event.
  81968. */
  81969. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  81970. private _onExtensionLoadedObserver;
  81971. /**
  81972. * Callback raised after a loader extension is created.
  81973. */
  81974. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  81975. /**
  81976. * Defines if the loader logging is enabled.
  81977. */
  81978. get loggingEnabled(): boolean;
  81979. set loggingEnabled(value: boolean);
  81980. /**
  81981. * Defines if the loader should capture performance counters.
  81982. */
  81983. get capturePerformanceCounters(): boolean;
  81984. set capturePerformanceCounters(value: boolean);
  81985. /**
  81986. * Defines if the loader should validate the asset.
  81987. */
  81988. validate: boolean;
  81989. /**
  81990. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  81991. */
  81992. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  81993. private _onValidatedObserver;
  81994. /**
  81995. * Callback raised after a loader extension is created.
  81996. */
  81997. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  81998. private _loader;
  81999. private _progressCallback?;
  82000. private _requests;
  82001. private static magicBase64Encoded;
  82002. /**
  82003. * Name of the loader ("gltf")
  82004. */
  82005. name: string;
  82006. /** @hidden */
  82007. extensions: ISceneLoaderPluginExtensions;
  82008. /**
  82009. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  82010. */
  82011. dispose(): void;
  82012. /** @hidden */
  82013. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  82014. /** @hidden */
  82015. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  82016. /** @hidden */
  82017. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  82018. meshes: AbstractMesh[];
  82019. particleSystems: IParticleSystem[];
  82020. skeletons: Skeleton[];
  82021. animationGroups: AnimationGroup[];
  82022. }>;
  82023. /** @hidden */
  82024. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  82025. /** @hidden */
  82026. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  82027. /** @hidden */
  82028. canDirectLoad(data: string): boolean;
  82029. /** @hidden */
  82030. directLoad(scene: Scene, data: string): Promise<any>;
  82031. /**
  82032. * The callback that allows custom handling of the root url based on the response url.
  82033. * @param rootUrl the original root url
  82034. * @param responseURL the response url if available
  82035. * @returns the new root url
  82036. */
  82037. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  82038. /** @hidden */
  82039. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  82040. /**
  82041. * The loader state or null if the loader is not active.
  82042. */
  82043. get loaderState(): Nullable<GLTFLoaderState>;
  82044. /**
  82045. * Returns a promise that resolves when the asset is completely loaded.
  82046. * @returns a promise that resolves when the asset is completely loaded.
  82047. */
  82048. whenCompleteAsync(): Promise<void>;
  82049. /** @hidden */
  82050. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  82051. /** @hidden */
  82052. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  82053. private _onProgress;
  82054. private _validate;
  82055. private _getLoader;
  82056. private _parseJson;
  82057. private _unpackBinaryAsync;
  82058. private _unpackBinaryV1Async;
  82059. private _unpackBinaryV2Async;
  82060. private static _parseVersion;
  82061. private static _compareVersion;
  82062. private static readonly _logSpaces;
  82063. private _logIndentLevel;
  82064. private _loggingEnabled;
  82065. /** @hidden */
  82066. _log: (message: string) => void;
  82067. /** @hidden */
  82068. _logOpen(message: string): void;
  82069. /** @hidden */
  82070. _logClose(): void;
  82071. private _logEnabled;
  82072. private _logDisabled;
  82073. private _capturePerformanceCounters;
  82074. /** @hidden */
  82075. _startPerformanceCounter: (counterName: string) => void;
  82076. /** @hidden */
  82077. _endPerformanceCounter: (counterName: string) => void;
  82078. private _startPerformanceCounterEnabled;
  82079. private _startPerformanceCounterDisabled;
  82080. private _endPerformanceCounterEnabled;
  82081. private _endPerformanceCounterDisabled;
  82082. }
  82083. }
  82084. declare module BABYLON.GLTF1 {
  82085. /**
  82086. * Enums
  82087. * @hidden
  82088. */
  82089. export enum EComponentType {
  82090. BYTE = 5120,
  82091. UNSIGNED_BYTE = 5121,
  82092. SHORT = 5122,
  82093. UNSIGNED_SHORT = 5123,
  82094. FLOAT = 5126
  82095. }
  82096. /** @hidden */
  82097. export enum EShaderType {
  82098. FRAGMENT = 35632,
  82099. VERTEX = 35633
  82100. }
  82101. /** @hidden */
  82102. export enum EParameterType {
  82103. BYTE = 5120,
  82104. UNSIGNED_BYTE = 5121,
  82105. SHORT = 5122,
  82106. UNSIGNED_SHORT = 5123,
  82107. INT = 5124,
  82108. UNSIGNED_INT = 5125,
  82109. FLOAT = 5126,
  82110. FLOAT_VEC2 = 35664,
  82111. FLOAT_VEC3 = 35665,
  82112. FLOAT_VEC4 = 35666,
  82113. INT_VEC2 = 35667,
  82114. INT_VEC3 = 35668,
  82115. INT_VEC4 = 35669,
  82116. BOOL = 35670,
  82117. BOOL_VEC2 = 35671,
  82118. BOOL_VEC3 = 35672,
  82119. BOOL_VEC4 = 35673,
  82120. FLOAT_MAT2 = 35674,
  82121. FLOAT_MAT3 = 35675,
  82122. FLOAT_MAT4 = 35676,
  82123. SAMPLER_2D = 35678
  82124. }
  82125. /** @hidden */
  82126. export enum ETextureWrapMode {
  82127. CLAMP_TO_EDGE = 33071,
  82128. MIRRORED_REPEAT = 33648,
  82129. REPEAT = 10497
  82130. }
  82131. /** @hidden */
  82132. export enum ETextureFilterType {
  82133. NEAREST = 9728,
  82134. LINEAR = 9728,
  82135. NEAREST_MIPMAP_NEAREST = 9984,
  82136. LINEAR_MIPMAP_NEAREST = 9985,
  82137. NEAREST_MIPMAP_LINEAR = 9986,
  82138. LINEAR_MIPMAP_LINEAR = 9987
  82139. }
  82140. /** @hidden */
  82141. export enum ETextureFormat {
  82142. ALPHA = 6406,
  82143. RGB = 6407,
  82144. RGBA = 6408,
  82145. LUMINANCE = 6409,
  82146. LUMINANCE_ALPHA = 6410
  82147. }
  82148. /** @hidden */
  82149. export enum ECullingType {
  82150. FRONT = 1028,
  82151. BACK = 1029,
  82152. FRONT_AND_BACK = 1032
  82153. }
  82154. /** @hidden */
  82155. export enum EBlendingFunction {
  82156. ZERO = 0,
  82157. ONE = 1,
  82158. SRC_COLOR = 768,
  82159. ONE_MINUS_SRC_COLOR = 769,
  82160. DST_COLOR = 774,
  82161. ONE_MINUS_DST_COLOR = 775,
  82162. SRC_ALPHA = 770,
  82163. ONE_MINUS_SRC_ALPHA = 771,
  82164. DST_ALPHA = 772,
  82165. ONE_MINUS_DST_ALPHA = 773,
  82166. CONSTANT_COLOR = 32769,
  82167. ONE_MINUS_CONSTANT_COLOR = 32770,
  82168. CONSTANT_ALPHA = 32771,
  82169. ONE_MINUS_CONSTANT_ALPHA = 32772,
  82170. SRC_ALPHA_SATURATE = 776
  82171. }
  82172. /** @hidden */
  82173. export interface IGLTFProperty {
  82174. extensions?: {
  82175. [key: string]: any;
  82176. };
  82177. extras?: Object;
  82178. }
  82179. /** @hidden */
  82180. export interface IGLTFChildRootProperty extends IGLTFProperty {
  82181. name?: string;
  82182. }
  82183. /** @hidden */
  82184. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  82185. bufferView: string;
  82186. byteOffset: number;
  82187. byteStride: number;
  82188. count: number;
  82189. type: string;
  82190. componentType: EComponentType;
  82191. max?: number[];
  82192. min?: number[];
  82193. name?: string;
  82194. }
  82195. /** @hidden */
  82196. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  82197. buffer: string;
  82198. byteOffset: number;
  82199. byteLength: number;
  82200. byteStride: number;
  82201. target?: number;
  82202. }
  82203. /** @hidden */
  82204. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  82205. uri: string;
  82206. byteLength?: number;
  82207. type?: string;
  82208. }
  82209. /** @hidden */
  82210. export interface IGLTFShader extends IGLTFChildRootProperty {
  82211. uri: string;
  82212. type: EShaderType;
  82213. }
  82214. /** @hidden */
  82215. export interface IGLTFProgram extends IGLTFChildRootProperty {
  82216. attributes: string[];
  82217. fragmentShader: string;
  82218. vertexShader: string;
  82219. }
  82220. /** @hidden */
  82221. export interface IGLTFTechniqueParameter {
  82222. type: number;
  82223. count?: number;
  82224. semantic?: string;
  82225. node?: string;
  82226. value?: number | boolean | string | Array<any>;
  82227. source?: string;
  82228. babylonValue?: any;
  82229. }
  82230. /** @hidden */
  82231. export interface IGLTFTechniqueCommonProfile {
  82232. lightingModel: string;
  82233. texcoordBindings: Object;
  82234. parameters?: Array<any>;
  82235. }
  82236. /** @hidden */
  82237. export interface IGLTFTechniqueStatesFunctions {
  82238. blendColor?: number[];
  82239. blendEquationSeparate?: number[];
  82240. blendFuncSeparate?: number[];
  82241. colorMask: boolean[];
  82242. cullFace: number[];
  82243. }
  82244. /** @hidden */
  82245. export interface IGLTFTechniqueStates {
  82246. enable: number[];
  82247. functions: IGLTFTechniqueStatesFunctions;
  82248. }
  82249. /** @hidden */
  82250. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  82251. parameters: {
  82252. [key: string]: IGLTFTechniqueParameter;
  82253. };
  82254. program: string;
  82255. attributes: {
  82256. [key: string]: string;
  82257. };
  82258. uniforms: {
  82259. [key: string]: string;
  82260. };
  82261. states: IGLTFTechniqueStates;
  82262. }
  82263. /** @hidden */
  82264. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  82265. technique?: string;
  82266. values: string[];
  82267. }
  82268. /** @hidden */
  82269. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  82270. attributes: {
  82271. [key: string]: string;
  82272. };
  82273. indices: string;
  82274. material: string;
  82275. mode?: number;
  82276. }
  82277. /** @hidden */
  82278. export interface IGLTFMesh extends IGLTFChildRootProperty {
  82279. primitives: IGLTFMeshPrimitive[];
  82280. }
  82281. /** @hidden */
  82282. export interface IGLTFImage extends IGLTFChildRootProperty {
  82283. uri: string;
  82284. }
  82285. /** @hidden */
  82286. export interface IGLTFSampler extends IGLTFChildRootProperty {
  82287. magFilter?: number;
  82288. minFilter?: number;
  82289. wrapS?: number;
  82290. wrapT?: number;
  82291. }
  82292. /** @hidden */
  82293. export interface IGLTFTexture extends IGLTFChildRootProperty {
  82294. sampler: string;
  82295. source: string;
  82296. format?: ETextureFormat;
  82297. internalFormat?: ETextureFormat;
  82298. target?: number;
  82299. type?: number;
  82300. babylonTexture?: Texture;
  82301. }
  82302. /** @hidden */
  82303. export interface IGLTFAmbienLight {
  82304. color?: number[];
  82305. }
  82306. /** @hidden */
  82307. export interface IGLTFDirectionalLight {
  82308. color?: number[];
  82309. }
  82310. /** @hidden */
  82311. export interface IGLTFPointLight {
  82312. color?: number[];
  82313. constantAttenuation?: number;
  82314. linearAttenuation?: number;
  82315. quadraticAttenuation?: number;
  82316. }
  82317. /** @hidden */
  82318. export interface IGLTFSpotLight {
  82319. color?: number[];
  82320. constantAttenuation?: number;
  82321. fallOfAngle?: number;
  82322. fallOffExponent?: number;
  82323. linearAttenuation?: number;
  82324. quadraticAttenuation?: number;
  82325. }
  82326. /** @hidden */
  82327. export interface IGLTFLight extends IGLTFChildRootProperty {
  82328. type: string;
  82329. }
  82330. /** @hidden */
  82331. export interface IGLTFCameraOrthographic {
  82332. xmag: number;
  82333. ymag: number;
  82334. zfar: number;
  82335. znear: number;
  82336. }
  82337. /** @hidden */
  82338. export interface IGLTFCameraPerspective {
  82339. aspectRatio: number;
  82340. yfov: number;
  82341. zfar: number;
  82342. znear: number;
  82343. }
  82344. /** @hidden */
  82345. export interface IGLTFCamera extends IGLTFChildRootProperty {
  82346. type: string;
  82347. }
  82348. /** @hidden */
  82349. export interface IGLTFAnimationChannelTarget {
  82350. id: string;
  82351. path: string;
  82352. }
  82353. /** @hidden */
  82354. export interface IGLTFAnimationChannel {
  82355. sampler: string;
  82356. target: IGLTFAnimationChannelTarget;
  82357. }
  82358. /** @hidden */
  82359. export interface IGLTFAnimationSampler {
  82360. input: string;
  82361. output: string;
  82362. interpolation?: string;
  82363. }
  82364. /** @hidden */
  82365. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  82366. channels?: IGLTFAnimationChannel[];
  82367. parameters?: {
  82368. [key: string]: string;
  82369. };
  82370. samplers?: {
  82371. [key: string]: IGLTFAnimationSampler;
  82372. };
  82373. }
  82374. /** @hidden */
  82375. export interface IGLTFNodeInstanceSkin {
  82376. skeletons: string[];
  82377. skin: string;
  82378. meshes: string[];
  82379. }
  82380. /** @hidden */
  82381. export interface IGLTFSkins extends IGLTFChildRootProperty {
  82382. bindShapeMatrix: number[];
  82383. inverseBindMatrices: string;
  82384. jointNames: string[];
  82385. babylonSkeleton?: Skeleton;
  82386. }
  82387. /** @hidden */
  82388. export interface IGLTFNode extends IGLTFChildRootProperty {
  82389. camera?: string;
  82390. children: string[];
  82391. skin?: string;
  82392. jointName?: string;
  82393. light?: string;
  82394. matrix: number[];
  82395. mesh?: string;
  82396. meshes?: string[];
  82397. rotation?: number[];
  82398. scale?: number[];
  82399. translation?: number[];
  82400. babylonNode?: Node;
  82401. }
  82402. /** @hidden */
  82403. export interface IGLTFScene extends IGLTFChildRootProperty {
  82404. nodes: string[];
  82405. }
  82406. /** @hidden */
  82407. export interface IGLTFRuntime {
  82408. extensions: {
  82409. [key: string]: any;
  82410. };
  82411. accessors: {
  82412. [key: string]: IGLTFAccessor;
  82413. };
  82414. buffers: {
  82415. [key: string]: IGLTFBuffer;
  82416. };
  82417. bufferViews: {
  82418. [key: string]: IGLTFBufferView;
  82419. };
  82420. meshes: {
  82421. [key: string]: IGLTFMesh;
  82422. };
  82423. lights: {
  82424. [key: string]: IGLTFLight;
  82425. };
  82426. cameras: {
  82427. [key: string]: IGLTFCamera;
  82428. };
  82429. nodes: {
  82430. [key: string]: IGLTFNode;
  82431. };
  82432. images: {
  82433. [key: string]: IGLTFImage;
  82434. };
  82435. textures: {
  82436. [key: string]: IGLTFTexture;
  82437. };
  82438. shaders: {
  82439. [key: string]: IGLTFShader;
  82440. };
  82441. programs: {
  82442. [key: string]: IGLTFProgram;
  82443. };
  82444. samplers: {
  82445. [key: string]: IGLTFSampler;
  82446. };
  82447. techniques: {
  82448. [key: string]: IGLTFTechnique;
  82449. };
  82450. materials: {
  82451. [key: string]: IGLTFMaterial;
  82452. };
  82453. animations: {
  82454. [key: string]: IGLTFAnimation;
  82455. };
  82456. skins: {
  82457. [key: string]: IGLTFSkins;
  82458. };
  82459. currentScene?: Object;
  82460. scenes: {
  82461. [key: string]: IGLTFScene;
  82462. };
  82463. extensionsUsed: string[];
  82464. extensionsRequired?: string[];
  82465. buffersCount: number;
  82466. shaderscount: number;
  82467. scene: Scene;
  82468. rootUrl: string;
  82469. loadedBufferCount: number;
  82470. loadedBufferViews: {
  82471. [name: string]: ArrayBufferView;
  82472. };
  82473. loadedShaderCount: number;
  82474. importOnlyMeshes: boolean;
  82475. importMeshesNames?: string[];
  82476. dummyNodes: Node[];
  82477. forAssetContainer: boolean;
  82478. }
  82479. /** @hidden */
  82480. export interface INodeToRoot {
  82481. bone: Bone;
  82482. node: IGLTFNode;
  82483. id: string;
  82484. }
  82485. /** @hidden */
  82486. export interface IJointNode {
  82487. node: IGLTFNode;
  82488. id: string;
  82489. }
  82490. }
  82491. declare module BABYLON.GLTF1 {
  82492. /**
  82493. * Utils functions for GLTF
  82494. * @hidden
  82495. */
  82496. export class GLTFUtils {
  82497. /**
  82498. * Sets the given "parameter" matrix
  82499. * @param scene: the Scene object
  82500. * @param source: the source node where to pick the matrix
  82501. * @param parameter: the GLTF technique parameter
  82502. * @param uniformName: the name of the shader's uniform
  82503. * @param shaderMaterial: the shader material
  82504. */
  82505. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  82506. /**
  82507. * Sets the given "parameter" matrix
  82508. * @param shaderMaterial: the shader material
  82509. * @param uniform: the name of the shader's uniform
  82510. * @param value: the value of the uniform
  82511. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  82512. */
  82513. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  82514. /**
  82515. * Returns the wrap mode of the texture
  82516. * @param mode: the mode value
  82517. */
  82518. static GetWrapMode(mode: number): number;
  82519. /**
  82520. * Returns the byte stride giving an accessor
  82521. * @param accessor: the GLTF accessor objet
  82522. */
  82523. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  82524. /**
  82525. * Returns the texture filter mode giving a mode value
  82526. * @param mode: the filter mode value
  82527. */
  82528. static GetTextureFilterMode(mode: number): ETextureFilterType;
  82529. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  82530. /**
  82531. * Returns a buffer from its accessor
  82532. * @param gltfRuntime: the GLTF runtime
  82533. * @param accessor: the GLTF accessor
  82534. */
  82535. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  82536. /**
  82537. * Decodes a buffer view into a string
  82538. * @param view: the buffer view
  82539. */
  82540. static DecodeBufferToText(view: ArrayBufferView): string;
  82541. /**
  82542. * Returns the default material of gltf. Related to
  82543. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  82544. * @param scene: the Babylon.js scene
  82545. */
  82546. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  82547. private static _DefaultMaterial;
  82548. }
  82549. }
  82550. declare module BABYLON.GLTF1 {
  82551. /**
  82552. * Implementation of the base glTF spec
  82553. * @hidden
  82554. */
  82555. export class GLTFLoaderBase {
  82556. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  82557. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  82558. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  82559. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  82560. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  82561. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  82562. }
  82563. /**
  82564. * glTF V1 Loader
  82565. * @hidden
  82566. */
  82567. export class GLTFLoader implements IGLTFLoader {
  82568. static Extensions: {
  82569. [name: string]: GLTFLoaderExtension;
  82570. };
  82571. static RegisterExtension(extension: GLTFLoaderExtension): void;
  82572. state: Nullable<GLTFLoaderState>;
  82573. dispose(): void;
  82574. private _importMeshAsync;
  82575. /**
  82576. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  82577. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  82578. * @param scene the scene the meshes should be added to
  82579. * @param forAssetContainer defines if the entities must be stored in the scene
  82580. * @param data gltf data containing information of the meshes in a loaded file
  82581. * @param rootUrl root url to load from
  82582. * @param onProgress event that fires when loading progress has occured
  82583. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  82584. */
  82585. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  82586. private _loadAsync;
  82587. /**
  82588. * Imports all objects from a loaded gltf file and adds them to the scene
  82589. * @param scene the scene the objects should be added to
  82590. * @param data gltf data containing information of the meshes in a loaded file
  82591. * @param rootUrl root url to load from
  82592. * @param onProgress event that fires when loading progress has occured
  82593. * @returns a promise which completes when objects have been loaded to the scene
  82594. */
  82595. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  82596. private _loadShadersAsync;
  82597. private _loadBuffersAsync;
  82598. private _createNodes;
  82599. }
  82600. /** @hidden */
  82601. export abstract class GLTFLoaderExtension {
  82602. private _name;
  82603. constructor(name: string);
  82604. get name(): string;
  82605. /**
  82606. * Defines an override for loading the runtime
  82607. * Return true to stop further extensions from loading the runtime
  82608. */
  82609. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  82610. /**
  82611. * Defines an onverride for creating gltf runtime
  82612. * Return true to stop further extensions from creating the runtime
  82613. */
  82614. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  82615. /**
  82616. * Defines an override for loading buffers
  82617. * Return true to stop further extensions from loading this buffer
  82618. */
  82619. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  82620. /**
  82621. * Defines an override for loading texture buffers
  82622. * Return true to stop further extensions from loading this texture data
  82623. */
  82624. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82625. /**
  82626. * Defines an override for creating textures
  82627. * Return true to stop further extensions from loading this texture
  82628. */
  82629. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  82630. /**
  82631. * Defines an override for loading shader strings
  82632. * Return true to stop further extensions from loading this shader data
  82633. */
  82634. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  82635. /**
  82636. * Defines an override for loading materials
  82637. * Return true to stop further extensions from loading this material
  82638. */
  82639. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  82640. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  82641. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  82642. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  82643. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  82644. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  82645. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  82646. private static LoadTextureBufferAsync;
  82647. private static CreateTextureAsync;
  82648. private static ApplyExtensions;
  82649. }
  82650. }
  82651. declare module BABYLON.GLTF1 {
  82652. /** @hidden */
  82653. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  82654. private _bin;
  82655. constructor();
  82656. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  82657. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82658. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82659. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  82660. }
  82661. }
  82662. declare module BABYLON.GLTF1 {
  82663. /** @hidden */
  82664. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  82665. constructor();
  82666. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  82667. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  82668. private _loadTexture;
  82669. }
  82670. }
  82671. declare module BABYLON.GLTF2.Loader {
  82672. /**
  82673. * Loader interface with an index field.
  82674. */
  82675. export interface IArrayItem {
  82676. /**
  82677. * The index of this item in the array.
  82678. */
  82679. index: number;
  82680. }
  82681. /**
  82682. * Loader interface with additional members.
  82683. */
  82684. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  82685. /** @hidden */
  82686. _data?: Promise<ArrayBufferView>;
  82687. /** @hidden */
  82688. _babylonVertexBuffer?: Promise<VertexBuffer>;
  82689. }
  82690. /**
  82691. * Loader interface with additional members.
  82692. */
  82693. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  82694. }
  82695. /** @hidden */
  82696. export interface _IAnimationSamplerData {
  82697. input: Float32Array;
  82698. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  82699. output: Float32Array;
  82700. }
  82701. /**
  82702. * Loader interface with additional members.
  82703. */
  82704. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  82705. /** @hidden */
  82706. _data?: Promise<_IAnimationSamplerData>;
  82707. }
  82708. /**
  82709. * Loader interface with additional members.
  82710. */
  82711. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  82712. channels: IAnimationChannel[];
  82713. samplers: IAnimationSampler[];
  82714. /** @hidden */
  82715. _babylonAnimationGroup?: AnimationGroup;
  82716. }
  82717. /**
  82718. * Loader interface with additional members.
  82719. */
  82720. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  82721. /** @hidden */
  82722. _data?: Promise<ArrayBufferView>;
  82723. }
  82724. /**
  82725. * Loader interface with additional members.
  82726. */
  82727. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  82728. /** @hidden */
  82729. _data?: Promise<ArrayBufferView>;
  82730. /** @hidden */
  82731. _babylonBuffer?: Promise<Buffer>;
  82732. }
  82733. /**
  82734. * Loader interface with additional members.
  82735. */
  82736. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  82737. }
  82738. /**
  82739. * Loader interface with additional members.
  82740. */
  82741. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  82742. /** @hidden */
  82743. _data?: Promise<ArrayBufferView>;
  82744. }
  82745. /**
  82746. * Loader interface with additional members.
  82747. */
  82748. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  82749. }
  82750. /**
  82751. * Loader interface with additional members.
  82752. */
  82753. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  82754. }
  82755. /**
  82756. * Loader interface with additional members.
  82757. */
  82758. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  82759. baseColorTexture?: ITextureInfo;
  82760. metallicRoughnessTexture?: ITextureInfo;
  82761. }
  82762. /**
  82763. * Loader interface with additional members.
  82764. */
  82765. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  82766. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  82767. normalTexture?: IMaterialNormalTextureInfo;
  82768. occlusionTexture?: IMaterialOcclusionTextureInfo;
  82769. emissiveTexture?: ITextureInfo;
  82770. /** @hidden */
  82771. _data?: {
  82772. [babylonDrawMode: number]: {
  82773. babylonMaterial: Material;
  82774. babylonMeshes: AbstractMesh[];
  82775. promise: Promise<void>;
  82776. };
  82777. };
  82778. }
  82779. /**
  82780. * Loader interface with additional members.
  82781. */
  82782. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  82783. primitives: IMeshPrimitive[];
  82784. }
  82785. /**
  82786. * Loader interface with additional members.
  82787. */
  82788. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  82789. /** @hidden */
  82790. _instanceData?: {
  82791. babylonSourceMesh: Mesh;
  82792. promise: Promise<any>;
  82793. };
  82794. }
  82795. /**
  82796. * Loader interface with additional members.
  82797. */
  82798. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  82799. /**
  82800. * The parent glTF node.
  82801. */
  82802. parent?: INode;
  82803. /** @hidden */
  82804. _babylonTransformNode?: TransformNode;
  82805. /** @hidden */
  82806. _primitiveBabylonMeshes?: AbstractMesh[];
  82807. /** @hidden */
  82808. _babylonBones?: Bone[];
  82809. /** @hidden */
  82810. _numMorphTargets?: number;
  82811. }
  82812. /** @hidden */
  82813. export interface _ISamplerData {
  82814. noMipMaps: boolean;
  82815. samplingMode: number;
  82816. wrapU: number;
  82817. wrapV: number;
  82818. }
  82819. /**
  82820. * Loader interface with additional members.
  82821. */
  82822. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  82823. /** @hidden */
  82824. _data?: _ISamplerData;
  82825. }
  82826. /**
  82827. * Loader interface with additional members.
  82828. */
  82829. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  82830. }
  82831. /**
  82832. * Loader interface with additional members.
  82833. */
  82834. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  82835. /** @hidden */
  82836. _data?: {
  82837. babylonSkeleton: Skeleton;
  82838. promise: Promise<void>;
  82839. };
  82840. }
  82841. /**
  82842. * Loader interface with additional members.
  82843. */
  82844. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  82845. /** @hidden */
  82846. _textureInfo: ITextureInfo;
  82847. }
  82848. /**
  82849. * Loader interface with additional members.
  82850. */
  82851. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  82852. /** false or undefined if the texture holds color data (true if data are roughness, normal, ...) */
  82853. nonColorData?: boolean;
  82854. }
  82855. /**
  82856. * Loader interface with additional members.
  82857. */
  82858. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  82859. accessors?: IAccessor[];
  82860. animations?: IAnimation[];
  82861. buffers?: IBuffer[];
  82862. bufferViews?: IBufferView[];
  82863. cameras?: ICamera[];
  82864. images?: IImage[];
  82865. materials?: IMaterial[];
  82866. meshes?: IMesh[];
  82867. nodes?: INode[];
  82868. samplers?: ISampler[];
  82869. scenes?: IScene[];
  82870. skins?: ISkin[];
  82871. textures?: ITexture[];
  82872. }
  82873. }
  82874. declare module BABYLON.GLTF2 {
  82875. /**
  82876. * Interface for a glTF loader extension.
  82877. */
  82878. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  82879. /**
  82880. * Called after the loader state changes to LOADING.
  82881. */
  82882. onLoading?(): void;
  82883. /**
  82884. * Called after the loader state changes to READY.
  82885. */
  82886. onReady?(): void;
  82887. /**
  82888. * Define this method to modify the default behavior when loading scenes.
  82889. * @param context The context when loading the asset
  82890. * @param scene The glTF scene property
  82891. * @returns A promise that resolves when the load is complete or null if not handled
  82892. */
  82893. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  82894. /**
  82895. * Define this method to modify the default behavior when loading nodes.
  82896. * @param context The context when loading the asset
  82897. * @param node The glTF node property
  82898. * @param assign A function called synchronously after parsing the glTF properties
  82899. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  82900. */
  82901. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82902. /**
  82903. * Define this method to modify the default behavior when loading cameras.
  82904. * @param context The context when loading the asset
  82905. * @param camera The glTF camera property
  82906. * @param assign A function called synchronously after parsing the glTF properties
  82907. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  82908. */
  82909. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  82910. /**
  82911. * @hidden
  82912. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  82913. * @param context The context when loading the asset
  82914. * @param primitive The glTF mesh primitive property
  82915. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  82916. */
  82917. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  82918. /**
  82919. * @hidden
  82920. * Define this method to modify the default behavior when loading data for mesh primitives.
  82921. * @param context The context when loading the asset
  82922. * @param name The mesh name when loading the asset
  82923. * @param node The glTF node when loading the asset
  82924. * @param mesh The glTF mesh when loading the asset
  82925. * @param primitive The glTF mesh primitive property
  82926. * @param assign A function called synchronously after parsing the glTF properties
  82927. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  82928. */
  82929. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  82930. /**
  82931. * @hidden
  82932. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  82933. * @param context The context when loading the asset
  82934. * @param material The glTF material property
  82935. * @param assign A function called synchronously after parsing the glTF properties
  82936. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  82937. */
  82938. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  82939. /**
  82940. * Define this method to modify the default behavior when creating materials.
  82941. * @param context The context when loading the asset
  82942. * @param material The glTF material property
  82943. * @param babylonDrawMode The draw mode for the Babylon material
  82944. * @returns The Babylon material or null if not handled
  82945. */
  82946. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  82947. /**
  82948. * Define this method to modify the default behavior when loading material properties.
  82949. * @param context The context when loading the asset
  82950. * @param material The glTF material property
  82951. * @param babylonMaterial The Babylon material
  82952. * @returns A promise that resolves when the load is complete or null if not handled
  82953. */
  82954. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82955. /**
  82956. * Define this method to modify the default behavior when loading texture infos.
  82957. * @param context The context when loading the asset
  82958. * @param textureInfo The glTF texture info property
  82959. * @param assign A function called synchronously after parsing the glTF properties
  82960. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  82961. */
  82962. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82963. /**
  82964. * @hidden
  82965. * Define this method to modify the default behavior when loading textures.
  82966. * @param context The context when loading the asset
  82967. * @param texture The glTF texture property
  82968. * @param assign A function called synchronously after parsing the glTF properties
  82969. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  82970. */
  82971. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82972. /**
  82973. * Define this method to modify the default behavior when loading animations.
  82974. * @param context The context when loading the asset
  82975. * @param animation The glTF animation property
  82976. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  82977. */
  82978. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  82979. /**
  82980. * @hidden
  82981. * Define this method to modify the default behavior when loading skins.
  82982. * @param context The context when loading the asset
  82983. * @param node The glTF node property
  82984. * @param skin The glTF skin property
  82985. * @returns A promise that resolves when the load is complete or null if not handled
  82986. */
  82987. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  82988. /**
  82989. * @hidden
  82990. * Define this method to modify the default behavior when loading uris.
  82991. * @param context The context when loading the asset
  82992. * @param property The glTF property associated with the uri
  82993. * @param uri The uri to load
  82994. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  82995. */
  82996. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  82997. /**
  82998. * Define this method to modify the default behavior when loading buffer views.
  82999. * @param context The context when loading the asset
  83000. * @param bufferView The glTF buffer view property
  83001. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  83002. */
  83003. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  83004. /**
  83005. * Define this method to modify the default behavior when loading buffers.
  83006. * @param context The context when loading the asset
  83007. * @param buffer The glTF buffer property
  83008. * @param byteOffset The byte offset to load
  83009. * @param byteLength The byte length to load
  83010. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  83011. */
  83012. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  83013. }
  83014. }
  83015. declare module BABYLON.GLTF2 {
  83016. /**
  83017. * Helper class for working with arrays when loading the glTF asset
  83018. */
  83019. export class ArrayItem {
  83020. /**
  83021. * Gets an item from the given array.
  83022. * @param context The context when loading the asset
  83023. * @param array The array to get the item from
  83024. * @param index The index to the array
  83025. * @returns The array item
  83026. */
  83027. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  83028. /**
  83029. * Assign an `index` field to each item of the given array.
  83030. * @param array The array of items
  83031. */
  83032. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  83033. }
  83034. /**
  83035. * The glTF 2.0 loader
  83036. */
  83037. export class GLTFLoader implements IGLTFLoader {
  83038. /** @hidden */
  83039. _completePromises: Promise<any>[];
  83040. /** @hidden */
  83041. _forAssetContainer: boolean;
  83042. /** Storage */
  83043. _babylonLights: Light[];
  83044. /** @hidden */
  83045. _disableInstancedMesh: number;
  83046. private _disposed;
  83047. private _parent;
  83048. private _state;
  83049. private _extensions;
  83050. private _rootUrl;
  83051. private _fileName;
  83052. private _uniqueRootUrl;
  83053. private _gltf;
  83054. private _bin;
  83055. private _babylonScene;
  83056. private _rootBabylonMesh;
  83057. private _defaultBabylonMaterialData;
  83058. private static _RegisteredExtensions;
  83059. /**
  83060. * The default glTF sampler.
  83061. */
  83062. static readonly DefaultSampler: ISampler;
  83063. /**
  83064. * Registers a loader extension.
  83065. * @param name The name of the loader extension.
  83066. * @param factory The factory function that creates the loader extension.
  83067. */
  83068. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  83069. /**
  83070. * Unregisters a loader extension.
  83071. * @param name The name of the loader extension.
  83072. * @returns A boolean indicating whether the extension has been unregistered
  83073. */
  83074. static UnregisterExtension(name: string): boolean;
  83075. /**
  83076. * The loader state.
  83077. */
  83078. get state(): Nullable<GLTFLoaderState>;
  83079. /**
  83080. * The object that represents the glTF JSON.
  83081. */
  83082. get gltf(): IGLTF;
  83083. /**
  83084. * The BIN chunk of a binary glTF.
  83085. */
  83086. get bin(): Nullable<IDataBuffer>;
  83087. /**
  83088. * The parent file loader.
  83089. */
  83090. get parent(): GLTFFileLoader;
  83091. /**
  83092. * The Babylon scene when loading the asset.
  83093. */
  83094. get babylonScene(): Scene;
  83095. /**
  83096. * The root Babylon mesh when loading the asset.
  83097. */
  83098. get rootBabylonMesh(): Mesh;
  83099. /** @hidden */
  83100. constructor(parent: GLTFFileLoader);
  83101. /** @hidden */
  83102. dispose(): void;
  83103. /** @hidden */
  83104. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  83105. /** @hidden */
  83106. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  83107. private _loadAsync;
  83108. private _loadData;
  83109. private _setupData;
  83110. private _loadExtensions;
  83111. private _checkExtensions;
  83112. private _setState;
  83113. private _createRootNode;
  83114. /**
  83115. * Loads a glTF scene.
  83116. * @param context The context when loading the asset
  83117. * @param scene The glTF scene property
  83118. * @returns A promise that resolves when the load is complete
  83119. */
  83120. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  83121. private _forEachPrimitive;
  83122. private _getGeometries;
  83123. private _getMeshes;
  83124. private _getTransformNodes;
  83125. private _getSkeletons;
  83126. private _getAnimationGroups;
  83127. private _startAnimations;
  83128. /**
  83129. * Loads a glTF node.
  83130. * @param context The context when loading the asset
  83131. * @param node The glTF node property
  83132. * @param assign A function called synchronously after parsing the glTF properties
  83133. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  83134. */
  83135. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  83136. private _loadMeshAsync;
  83137. /**
  83138. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  83139. * @param context The context when loading the asset
  83140. * @param name The mesh name when loading the asset
  83141. * @param node The glTF node when loading the asset
  83142. * @param mesh The glTF mesh when loading the asset
  83143. * @param primitive The glTF mesh primitive property
  83144. * @param assign A function called synchronously after parsing the glTF properties
  83145. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  83146. */
  83147. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  83148. private _loadVertexDataAsync;
  83149. private _createMorphTargets;
  83150. private _loadMorphTargetsAsync;
  83151. private _loadMorphTargetVertexDataAsync;
  83152. private static _LoadTransform;
  83153. private _loadSkinAsync;
  83154. private _loadBones;
  83155. private _loadBone;
  83156. private _loadSkinInverseBindMatricesDataAsync;
  83157. private _updateBoneMatrices;
  83158. private _getNodeMatrix;
  83159. /**
  83160. * Loads a glTF camera.
  83161. * @param context The context when loading the asset
  83162. * @param camera The glTF camera property
  83163. * @param assign A function called synchronously after parsing the glTF properties
  83164. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  83165. */
  83166. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  83167. private _loadAnimationsAsync;
  83168. /**
  83169. * Loads a glTF animation.
  83170. * @param context The context when loading the asset
  83171. * @param animation The glTF animation property
  83172. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  83173. */
  83174. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  83175. /**
  83176. * @hidden Loads a glTF animation channel.
  83177. * @param context The context when loading the asset
  83178. * @param animationContext The context of the animation when loading the asset
  83179. * @param animation The glTF animation property
  83180. * @param channel The glTF animation channel property
  83181. * @param babylonAnimationGroup The babylon animation group property
  83182. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  83183. * @returns A void promise when the channel load is complete
  83184. */
  83185. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  83186. private _loadAnimationSamplerAsync;
  83187. private _loadBufferAsync;
  83188. /**
  83189. * Loads a glTF buffer view.
  83190. * @param context The context when loading the asset
  83191. * @param bufferView The glTF buffer view property
  83192. * @returns A promise that resolves with the loaded data when the load is complete
  83193. */
  83194. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  83195. private _loadAccessorAsync;
  83196. /** @hidden */
  83197. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  83198. private _loadIndicesAccessorAsync;
  83199. private _loadVertexBufferViewAsync;
  83200. private _loadVertexAccessorAsync;
  83201. private _loadMaterialMetallicRoughnessPropertiesAsync;
  83202. /** @hidden */
  83203. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  83204. private _createDefaultMaterial;
  83205. /**
  83206. * Creates a Babylon material from a glTF material.
  83207. * @param context The context when loading the asset
  83208. * @param material The glTF material property
  83209. * @param babylonDrawMode The draw mode for the Babylon material
  83210. * @returns The Babylon material
  83211. */
  83212. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  83213. /**
  83214. * Loads properties from a glTF material into a Babylon material.
  83215. * @param context The context when loading the asset
  83216. * @param material The glTF material property
  83217. * @param babylonMaterial The Babylon material
  83218. * @returns A promise that resolves when the load is complete
  83219. */
  83220. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  83221. /**
  83222. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  83223. * @param context The context when loading the asset
  83224. * @param material The glTF material property
  83225. * @param babylonMaterial The Babylon material
  83226. * @returns A promise that resolves when the load is complete
  83227. */
  83228. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  83229. /**
  83230. * Loads the alpha properties from a glTF material into a Babylon material.
  83231. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  83232. * @param context The context when loading the asset
  83233. * @param material The glTF material property
  83234. * @param babylonMaterial The Babylon material
  83235. */
  83236. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  83237. /**
  83238. * Loads a glTF texture info.
  83239. * @param context The context when loading the asset
  83240. * @param textureInfo The glTF texture info property
  83241. * @param assign A function called synchronously after parsing the glTF properties
  83242. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  83243. */
  83244. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  83245. /** @hidden */
  83246. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  83247. /** @hidden */
  83248. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void, textureLoaderOptions?: any): Promise<BaseTexture>;
  83249. private _loadSampler;
  83250. /**
  83251. * Loads a glTF image.
  83252. * @param context The context when loading the asset
  83253. * @param image The glTF image property
  83254. * @returns A promise that resolves with the loaded data when the load is complete
  83255. */
  83256. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  83257. /**
  83258. * Loads a glTF uri.
  83259. * @param context The context when loading the asset
  83260. * @param property The glTF property associated with the uri
  83261. * @param uri The base64 or relative uri
  83262. * @returns A promise that resolves with the loaded data when the load is complete
  83263. */
  83264. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  83265. /**
  83266. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  83267. * @param babylonObject the Babylon object with metadata
  83268. * @param pointer the JSON pointer
  83269. */
  83270. static AddPointerMetadata(babylonObject: {
  83271. metadata: any;
  83272. }, pointer: string): void;
  83273. private static _GetTextureWrapMode;
  83274. private static _GetTextureSamplingMode;
  83275. private static _GetTypedArrayConstructor;
  83276. private static _GetTypedArray;
  83277. private static _GetNumComponents;
  83278. private static _ValidateUri;
  83279. /** @hidden */
  83280. static _GetDrawMode(context: string, mode: number | undefined): number;
  83281. private _compileMaterialsAsync;
  83282. private _compileShadowGeneratorsAsync;
  83283. private _forEachExtensions;
  83284. private _applyExtensions;
  83285. private _extensionsOnLoading;
  83286. private _extensionsOnReady;
  83287. private _extensionsLoadSceneAsync;
  83288. private _extensionsLoadNodeAsync;
  83289. private _extensionsLoadCameraAsync;
  83290. private _extensionsLoadVertexDataAsync;
  83291. private _extensionsLoadMeshPrimitiveAsync;
  83292. private _extensionsLoadMaterialAsync;
  83293. private _extensionsCreateMaterial;
  83294. private _extensionsLoadMaterialPropertiesAsync;
  83295. private _extensionsLoadTextureInfoAsync;
  83296. private _extensionsLoadTextureAsync;
  83297. private _extensionsLoadAnimationAsync;
  83298. private _extensionsLoadSkinAsync;
  83299. private _extensionsLoadUriAsync;
  83300. private _extensionsLoadBufferViewAsync;
  83301. private _extensionsLoadBufferAsync;
  83302. /**
  83303. * Helper method called by a loader extension to load an glTF extension.
  83304. * @param context The context when loading the asset
  83305. * @param property The glTF property to load the extension from
  83306. * @param extensionName The name of the extension to load
  83307. * @param actionAsync The action to run
  83308. * @returns The promise returned by actionAsync or null if the extension does not exist
  83309. */
  83310. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  83311. /**
  83312. * Helper method called by a loader extension to load a glTF extra.
  83313. * @param context The context when loading the asset
  83314. * @param property The glTF property to load the extra from
  83315. * @param extensionName The name of the extension to load
  83316. * @param actionAsync The action to run
  83317. * @returns The promise returned by actionAsync or null if the extra does not exist
  83318. */
  83319. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  83320. /**
  83321. * Checks for presence of an extension.
  83322. * @param name The name of the extension to check
  83323. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  83324. */
  83325. isExtensionUsed(name: string): boolean;
  83326. /**
  83327. * Increments the indentation level and logs a message.
  83328. * @param message The message to log
  83329. */
  83330. logOpen(message: string): void;
  83331. /**
  83332. * Decrements the indentation level.
  83333. */
  83334. logClose(): void;
  83335. /**
  83336. * Logs a message
  83337. * @param message The message to log
  83338. */
  83339. log(message: string): void;
  83340. /**
  83341. * Starts a performance counter.
  83342. * @param counterName The name of the performance counter
  83343. */
  83344. startPerformanceCounter(counterName: string): void;
  83345. /**
  83346. * Ends a performance counter.
  83347. * @param counterName The name of the performance counter
  83348. */
  83349. endPerformanceCounter(counterName: string): void;
  83350. }
  83351. }
  83352. declare module BABYLON.GLTF2.Loader.Extensions {
  83353. /** @hidden */
  83354. interface IEXTLightsImageBased_LightImageBased {
  83355. _babylonTexture?: BaseTexture;
  83356. _loaded?: Promise<void>;
  83357. }
  83358. /**
  83359. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  83360. */
  83361. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  83362. /**
  83363. * The name of this extension.
  83364. */
  83365. readonly name: string;
  83366. /**
  83367. * Defines whether this extension is enabled.
  83368. */
  83369. enabled: boolean;
  83370. private _loader;
  83371. private _lights?;
  83372. /** @hidden */
  83373. constructor(loader: GLTFLoader);
  83374. /** @hidden */
  83375. dispose(): void;
  83376. /** @hidden */
  83377. onLoading(): void;
  83378. /** @hidden */
  83379. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  83380. private _loadLightAsync;
  83381. }
  83382. }
  83383. declare module BABYLON.GLTF2.Loader.Extensions {
  83384. /**
  83385. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  83386. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  83387. * !!! Experimental Extension Subject to Changes !!!
  83388. */
  83389. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  83390. /**
  83391. * The name of this extension.
  83392. */
  83393. readonly name: string;
  83394. /**
  83395. * Defines whether this extension is enabled.
  83396. */
  83397. enabled: boolean;
  83398. private _loader;
  83399. /** @hidden */
  83400. constructor(loader: GLTFLoader);
  83401. /** @hidden */
  83402. dispose(): void;
  83403. /** @hidden */
  83404. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83405. }
  83406. }
  83407. declare module BABYLON.GLTF2.Loader.Extensions {
  83408. /**
  83409. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  83410. */
  83411. export class EXT_texture_webp implements IGLTFLoaderExtension {
  83412. /** The name of this extension. */
  83413. readonly name: string;
  83414. /** Defines whether this extension is enabled. */
  83415. enabled: boolean;
  83416. private _loader;
  83417. /** @hidden */
  83418. constructor(loader: GLTFLoader);
  83419. /** @hidden */
  83420. dispose(): void;
  83421. /** @hidden */
  83422. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83423. }
  83424. }
  83425. declare module BABYLON.GLTF2.Loader.Extensions {
  83426. /**
  83427. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  83428. */
  83429. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  83430. /**
  83431. * The name of this extension.
  83432. */
  83433. readonly name: string;
  83434. /**
  83435. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  83436. */
  83437. dracoCompression?: DracoCompression;
  83438. /**
  83439. * Defines whether this extension is enabled.
  83440. */
  83441. enabled: boolean;
  83442. private _loader;
  83443. /** @hidden */
  83444. constructor(loader: GLTFLoader);
  83445. /** @hidden */
  83446. dispose(): void;
  83447. /** @hidden */
  83448. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  83449. }
  83450. }
  83451. declare module BABYLON.GLTF2.Loader.Extensions {
  83452. /**
  83453. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  83454. */
  83455. export class KHR_lights implements IGLTFLoaderExtension {
  83456. /**
  83457. * The name of this extension.
  83458. */
  83459. readonly name: string;
  83460. /**
  83461. * Defines whether this extension is enabled.
  83462. */
  83463. enabled: boolean;
  83464. private _loader;
  83465. private _lights?;
  83466. /** @hidden */
  83467. constructor(loader: GLTFLoader);
  83468. /** @hidden */
  83469. dispose(): void;
  83470. /** @hidden */
  83471. onLoading(): void;
  83472. /** @hidden */
  83473. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83474. }
  83475. }
  83476. declare module BABYLON.GLTF2.Loader.Extensions {
  83477. /**
  83478. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  83479. */
  83480. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  83481. /**
  83482. * The name of this extension.
  83483. */
  83484. readonly name: string;
  83485. /**
  83486. * Defines whether this extension is enabled.
  83487. */
  83488. enabled: boolean;
  83489. /**
  83490. * Defines a number that determines the order the extensions are applied.
  83491. */
  83492. order: number;
  83493. private _loader;
  83494. /** @hidden */
  83495. constructor(loader: GLTFLoader);
  83496. /** @hidden */
  83497. dispose(): void;
  83498. /** @hidden */
  83499. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83500. private _loadSpecularGlossinessPropertiesAsync;
  83501. }
  83502. }
  83503. declare module BABYLON.GLTF2.Loader.Extensions {
  83504. /**
  83505. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  83506. */
  83507. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  83508. /**
  83509. * The name of this extension.
  83510. */
  83511. readonly name: string;
  83512. /**
  83513. * Defines whether this extension is enabled.
  83514. */
  83515. enabled: boolean;
  83516. /**
  83517. * Defines a number that determines the order the extensions are applied.
  83518. */
  83519. order: number;
  83520. private _loader;
  83521. /** @hidden */
  83522. constructor(loader: GLTFLoader);
  83523. /** @hidden */
  83524. dispose(): void;
  83525. /** @hidden */
  83526. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83527. private _loadUnlitPropertiesAsync;
  83528. }
  83529. }
  83530. declare module BABYLON.GLTF2.Loader.Extensions {
  83531. /**
  83532. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_clearcoat/README.md)
  83533. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  83534. */
  83535. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  83536. /**
  83537. * The name of this extension.
  83538. */
  83539. readonly name: string;
  83540. /**
  83541. * Defines whether this extension is enabled.
  83542. */
  83543. enabled: boolean;
  83544. /**
  83545. * Defines a number that determines the order the extensions are applied.
  83546. */
  83547. order: number;
  83548. private _loader;
  83549. /** @hidden */
  83550. constructor(loader: GLTFLoader);
  83551. /** @hidden */
  83552. dispose(): void;
  83553. /** @hidden */
  83554. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83555. private _loadClearCoatPropertiesAsync;
  83556. }
  83557. }
  83558. declare module BABYLON.GLTF2.Loader.Extensions {
  83559. /**
  83560. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  83561. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  83562. * !!! Experimental Extension Subject to Changes !!!
  83563. */
  83564. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  83565. /**
  83566. * The name of this extension.
  83567. */
  83568. readonly name: string;
  83569. /**
  83570. * Defines whether this extension is enabled.
  83571. */
  83572. enabled: boolean;
  83573. /**
  83574. * Defines a number that determines the order the extensions are applied.
  83575. */
  83576. order: number;
  83577. private _loader;
  83578. /** @hidden */
  83579. constructor(loader: GLTFLoader);
  83580. /** @hidden */
  83581. dispose(): void;
  83582. /** @hidden */
  83583. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83584. private _loadSheenPropertiesAsync;
  83585. }
  83586. }
  83587. declare module BABYLON.GLTF2.Loader.Extensions {
  83588. /**
  83589. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  83590. * !!! Experimental Extension Subject to Changes !!!
  83591. */
  83592. export class KHR_materials_specular implements IGLTFLoaderExtension {
  83593. /**
  83594. * The name of this extension.
  83595. */
  83596. readonly name: string;
  83597. /**
  83598. * Defines whether this extension is enabled.
  83599. */
  83600. enabled: boolean;
  83601. /**
  83602. * Defines a number that determines the order the extensions are applied.
  83603. */
  83604. order: number;
  83605. private _loader;
  83606. /** @hidden */
  83607. constructor(loader: GLTFLoader);
  83608. /** @hidden */
  83609. dispose(): void;
  83610. /** @hidden */
  83611. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83612. private _loadSpecularPropertiesAsync;
  83613. }
  83614. }
  83615. declare module BABYLON.GLTF2.Loader.Extensions {
  83616. /**
  83617. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  83618. * !!! Experimental Extension Subject to Changes !!!
  83619. */
  83620. export class KHR_materials_ior implements IGLTFLoaderExtension {
  83621. /**
  83622. * Default ior Value from the spec.
  83623. */
  83624. private static readonly _DEFAULT_IOR;
  83625. /**
  83626. * The name of this extension.
  83627. */
  83628. readonly name: string;
  83629. /**
  83630. * Defines whether this extension is enabled.
  83631. */
  83632. enabled: boolean;
  83633. /**
  83634. * Defines a number that determines the order the extensions are applied.
  83635. */
  83636. order: number;
  83637. private _loader;
  83638. /** @hidden */
  83639. constructor(loader: GLTFLoader);
  83640. /** @hidden */
  83641. dispose(): void;
  83642. /** @hidden */
  83643. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83644. private _loadIorPropertiesAsync;
  83645. }
  83646. }
  83647. declare module BABYLON.GLTF2.Loader.Extensions {
  83648. /**
  83649. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  83650. * !!! Experimental Extension Subject to Changes !!!
  83651. */
  83652. export class KHR_materials_variants implements IGLTFLoaderExtension {
  83653. /**
  83654. * The name of this extension.
  83655. */
  83656. readonly name: string;
  83657. /**
  83658. * Defines whether this extension is enabled.
  83659. */
  83660. enabled: boolean;
  83661. private _loader;
  83662. private _variants?;
  83663. /** @hidden */
  83664. constructor(loader: GLTFLoader);
  83665. /** @hidden */
  83666. dispose(): void;
  83667. /**
  83668. * Gets the list of available variant names for this asset.
  83669. * @param rootMesh The glTF root mesh
  83670. * @returns the list of all the variant names for this model
  83671. */
  83672. static GetAvailableVariants(rootMesh: Mesh): string[];
  83673. /**
  83674. * Gets the list of available variant names for this asset.
  83675. * @param rootMesh The glTF root mesh
  83676. * @returns the list of all the variant names for this model
  83677. */
  83678. getAvailableVariants(rootMesh: Mesh): string[];
  83679. /**
  83680. * Select a variant given a variant name or a list of variant names.
  83681. * @param rootMesh The glTF root mesh
  83682. * @param variantName The variant name(s) to select.
  83683. */
  83684. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  83685. /**
  83686. * Select a variant given a variant name or a list of variant names.
  83687. * @param rootMesh The glTF root mesh
  83688. * @param variantName The variant name(s) to select.
  83689. */
  83690. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  83691. /**
  83692. * Reset back to the original before selecting a variant.
  83693. * @param rootMesh The glTF root mesh
  83694. */
  83695. static Reset(rootMesh: Mesh): void;
  83696. /**
  83697. * Reset back to the original before selecting a variant.
  83698. * @param rootMesh The glTF root mesh
  83699. */
  83700. reset(rootMesh: Mesh): void;
  83701. /**
  83702. * Gets the last selected variant name(s) or null if original.
  83703. * @param rootMesh The glTF root mesh
  83704. * @returns The selected variant name(s).
  83705. */
  83706. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  83707. /**
  83708. * Gets the last selected variant name(s) or null if original.
  83709. * @param rootMesh The glTF root mesh
  83710. * @returns The selected variant name(s).
  83711. */
  83712. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  83713. private static _GetExtensionMetadata;
  83714. /** @hidden */
  83715. onLoading(): void;
  83716. /** @hidden */
  83717. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  83718. }
  83719. }
  83720. declare module BABYLON.GLTF2.Loader.Extensions {
  83721. /**
  83722. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  83723. * !!! Experimental Extension Subject to Changes !!!
  83724. */
  83725. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  83726. /**
  83727. * The name of this extension.
  83728. */
  83729. readonly name: string;
  83730. /**
  83731. * Defines whether this extension is enabled.
  83732. */
  83733. enabled: boolean;
  83734. /**
  83735. * Defines a number that determines the order the extensions are applied.
  83736. */
  83737. order: number;
  83738. private _loader;
  83739. /** @hidden */
  83740. constructor(loader: GLTFLoader);
  83741. /** @hidden */
  83742. dispose(): void;
  83743. /** @hidden */
  83744. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83745. private _loadTransparentPropertiesAsync;
  83746. }
  83747. }
  83748. declare module BABYLON.GLTF2.Loader.Extensions {
  83749. /**
  83750. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  83751. */
  83752. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  83753. /**
  83754. * The name of this extension.
  83755. */
  83756. readonly name: string;
  83757. /**
  83758. * Defines whether this extension is enabled.
  83759. */
  83760. enabled: boolean;
  83761. /** @hidden */
  83762. constructor(loader: GLTFLoader);
  83763. /** @hidden */
  83764. dispose(): void;
  83765. }
  83766. }
  83767. declare module BABYLON.GLTF2.Loader.Extensions {
  83768. /**
  83769. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  83770. * !!! Experimental Extension Subject to Changes !!!
  83771. */
  83772. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  83773. /** The name of this extension. */
  83774. readonly name: string;
  83775. /** Defines whether this extension is enabled. */
  83776. enabled: boolean;
  83777. private _loader;
  83778. /** @hidden */
  83779. constructor(loader: GLTFLoader);
  83780. /** @hidden */
  83781. dispose(): void;
  83782. /** @hidden */
  83783. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83784. }
  83785. }
  83786. declare module BABYLON.GLTF2.Loader.Extensions {
  83787. /**
  83788. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  83789. */
  83790. export class KHR_texture_transform implements IGLTFLoaderExtension {
  83791. /**
  83792. * The name of this extension.
  83793. */
  83794. readonly name: string;
  83795. /**
  83796. * Defines whether this extension is enabled.
  83797. */
  83798. enabled: boolean;
  83799. private _loader;
  83800. /** @hidden */
  83801. constructor(loader: GLTFLoader);
  83802. /** @hidden */
  83803. dispose(): void;
  83804. /** @hidden */
  83805. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83806. }
  83807. }
  83808. declare module BABYLON.GLTF2.Loader.Extensions {
  83809. /**
  83810. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  83811. * !!! Experimental Extension Subject to Changes !!!
  83812. */
  83813. export class KHR_xmp implements IGLTFLoaderExtension {
  83814. /**
  83815. * The name of this extension.
  83816. */
  83817. readonly name: string;
  83818. /**
  83819. * Defines whether this extension is enabled.
  83820. */
  83821. enabled: boolean;
  83822. /**
  83823. * Defines a number that determines the order the extensions are applied.
  83824. */
  83825. order: number;
  83826. private _loader;
  83827. /** @hidden */
  83828. constructor(loader: GLTFLoader);
  83829. /** @hidden */
  83830. dispose(): void;
  83831. /**
  83832. * Called after the loader state changes to LOADING.
  83833. */
  83834. onLoading(): void;
  83835. }
  83836. }
  83837. declare module BABYLON.GLTF2.Loader.Extensions {
  83838. /**
  83839. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  83840. */
  83841. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  83842. /**
  83843. * The name of this extension.
  83844. */
  83845. readonly name: string;
  83846. /**
  83847. * Defines whether this extension is enabled.
  83848. */
  83849. enabled: boolean;
  83850. private _loader;
  83851. private _clips;
  83852. private _emitters;
  83853. /** @hidden */
  83854. constructor(loader: GLTFLoader);
  83855. /** @hidden */
  83856. dispose(): void;
  83857. /** @hidden */
  83858. onLoading(): void;
  83859. /** @hidden */
  83860. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  83861. /** @hidden */
  83862. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83863. /** @hidden */
  83864. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  83865. private _loadClipAsync;
  83866. private _loadEmitterAsync;
  83867. private _getEventAction;
  83868. private _loadAnimationEventAsync;
  83869. }
  83870. }
  83871. declare module BABYLON.GLTF2.Loader.Extensions {
  83872. /**
  83873. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  83874. */
  83875. export class MSFT_lod implements IGLTFLoaderExtension {
  83876. /**
  83877. * The name of this extension.
  83878. */
  83879. readonly name: string;
  83880. /**
  83881. * Defines whether this extension is enabled.
  83882. */
  83883. enabled: boolean;
  83884. /**
  83885. * Defines a number that determines the order the extensions are applied.
  83886. */
  83887. order: number;
  83888. /**
  83889. * Maximum number of LODs to load, starting from the lowest LOD.
  83890. */
  83891. maxLODsToLoad: number;
  83892. /**
  83893. * Observable raised when all node LODs of one level are loaded.
  83894. * The event data is the index of the loaded LOD starting from zero.
  83895. * Dispose the loader to cancel the loading of the next level of LODs.
  83896. */
  83897. onNodeLODsLoadedObservable: Observable<number>;
  83898. /**
  83899. * Observable raised when all material LODs of one level are loaded.
  83900. * The event data is the index of the loaded LOD starting from zero.
  83901. * Dispose the loader to cancel the loading of the next level of LODs.
  83902. */
  83903. onMaterialLODsLoadedObservable: Observable<number>;
  83904. private _loader;
  83905. private _bufferLODs;
  83906. private _nodeIndexLOD;
  83907. private _nodeSignalLODs;
  83908. private _nodePromiseLODs;
  83909. private _nodeBufferLODs;
  83910. private _materialIndexLOD;
  83911. private _materialSignalLODs;
  83912. private _materialPromiseLODs;
  83913. private _materialBufferLODs;
  83914. /** @hidden */
  83915. constructor(loader: GLTFLoader);
  83916. /** @hidden */
  83917. dispose(): void;
  83918. /** @hidden */
  83919. onReady(): void;
  83920. /** @hidden */
  83921. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  83922. /** @hidden */
  83923. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83924. /** @hidden */
  83925. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  83926. /** @hidden */
  83927. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  83928. /** @hidden */
  83929. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  83930. private _loadBufferLOD;
  83931. /**
  83932. * Gets an array of LOD properties from lowest to highest.
  83933. */
  83934. private _getLODs;
  83935. private _disposeTransformNode;
  83936. private _disposeMaterials;
  83937. }
  83938. }
  83939. declare module BABYLON.GLTF2.Loader.Extensions {
  83940. /** @hidden */
  83941. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  83942. readonly name: string;
  83943. enabled: boolean;
  83944. private _loader;
  83945. constructor(loader: GLTFLoader);
  83946. dispose(): void;
  83947. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83948. }
  83949. }
  83950. declare module BABYLON.GLTF2.Loader.Extensions {
  83951. /** @hidden */
  83952. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  83953. readonly name: string;
  83954. enabled: boolean;
  83955. private _loader;
  83956. constructor(loader: GLTFLoader);
  83957. dispose(): void;
  83958. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83959. }
  83960. }
  83961. declare module BABYLON.GLTF2.Loader.Extensions {
  83962. /**
  83963. * Store glTF extras (if present) in BJS objects' metadata
  83964. */
  83965. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  83966. /**
  83967. * The name of this extension.
  83968. */
  83969. readonly name: string;
  83970. /**
  83971. * Defines whether this extension is enabled.
  83972. */
  83973. enabled: boolean;
  83974. private _loader;
  83975. private _assignExtras;
  83976. /** @hidden */
  83977. constructor(loader: GLTFLoader);
  83978. /** @hidden */
  83979. dispose(): void;
  83980. /** @hidden */
  83981. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83982. /** @hidden */
  83983. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  83984. /** @hidden */
  83985. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  83986. }
  83987. }
  83988. declare module BABYLON {
  83989. /**
  83990. * Class reading and parsing the MTL file bundled with the obj file.
  83991. */
  83992. export class MTLFileLoader {
  83993. /**
  83994. * Invert Y-Axis of referenced textures on load
  83995. */
  83996. static INVERT_TEXTURE_Y: boolean;
  83997. /**
  83998. * All material loaded from the mtl will be set here
  83999. */
  84000. materials: StandardMaterial[];
  84001. /**
  84002. * This function will read the mtl file and create each material described inside
  84003. * This function could be improve by adding :
  84004. * -some component missing (Ni, Tf...)
  84005. * -including the specific options available
  84006. *
  84007. * @param scene defines the scene the material will be created in
  84008. * @param data defines the mtl data to parse
  84009. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  84010. * @param forAssetContainer defines if the material should be registered in the scene
  84011. */
  84012. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  84013. /**
  84014. * Gets the texture for the material.
  84015. *
  84016. * If the material is imported from input file,
  84017. * We sanitize the url to ensure it takes the textre from aside the material.
  84018. *
  84019. * @param rootUrl The root url to load from
  84020. * @param value The value stored in the mtl
  84021. * @return The Texture
  84022. */
  84023. private static _getTexture;
  84024. }
  84025. }
  84026. declare module BABYLON {
  84027. /**
  84028. * Options for loading OBJ/MTL files
  84029. */
  84030. type MeshLoadOptions = {
  84031. /**
  84032. * Defines if UVs are optimized by default during load.
  84033. */
  84034. OptimizeWithUV: boolean;
  84035. /**
  84036. * Defines custom scaling of UV coordinates of loaded meshes.
  84037. */
  84038. UVScaling: Vector2;
  84039. /**
  84040. * Invert model on y-axis (does a model scaling inversion)
  84041. */
  84042. InvertY: boolean;
  84043. /**
  84044. * Invert Y-Axis of referenced textures on load
  84045. */
  84046. InvertTextureY: boolean;
  84047. /**
  84048. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  84049. */
  84050. ImportVertexColors: boolean;
  84051. /**
  84052. * Compute the normals for the model, even if normals are present in the file.
  84053. */
  84054. ComputeNormals: boolean;
  84055. /**
  84056. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  84057. */
  84058. SkipMaterials: boolean;
  84059. /**
  84060. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  84061. */
  84062. MaterialLoadingFailsSilently: boolean;
  84063. };
  84064. /**
  84065. * OBJ file type loader.
  84066. * This is a babylon scene loader plugin.
  84067. */
  84068. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  84069. /**
  84070. * Defines if UVs are optimized by default during load.
  84071. */
  84072. static OPTIMIZE_WITH_UV: boolean;
  84073. /**
  84074. * Invert model on y-axis (does a model scaling inversion)
  84075. */
  84076. static INVERT_Y: boolean;
  84077. /**
  84078. * Invert Y-Axis of referenced textures on load
  84079. */
  84080. static get INVERT_TEXTURE_Y(): boolean;
  84081. static set INVERT_TEXTURE_Y(value: boolean);
  84082. /**
  84083. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  84084. */
  84085. static IMPORT_VERTEX_COLORS: boolean;
  84086. /**
  84087. * Compute the normals for the model, even if normals are present in the file.
  84088. */
  84089. static COMPUTE_NORMALS: boolean;
  84090. /**
  84091. * Defines custom scaling of UV coordinates of loaded meshes.
  84092. */
  84093. static UV_SCALING: Vector2;
  84094. /**
  84095. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  84096. */
  84097. static SKIP_MATERIALS: boolean;
  84098. /**
  84099. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  84100. *
  84101. * Defaults to true for backwards compatibility.
  84102. */
  84103. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  84104. /**
  84105. * Defines the name of the plugin.
  84106. */
  84107. name: string;
  84108. /**
  84109. * Defines the extension the plugin is able to load.
  84110. */
  84111. extensions: string;
  84112. /** @hidden */
  84113. obj: RegExp;
  84114. /** @hidden */
  84115. group: RegExp;
  84116. /** @hidden */
  84117. mtllib: RegExp;
  84118. /** @hidden */
  84119. usemtl: RegExp;
  84120. /** @hidden */
  84121. smooth: RegExp;
  84122. /** @hidden */
  84123. vertexPattern: RegExp;
  84124. /** @hidden */
  84125. normalPattern: RegExp;
  84126. /** @hidden */
  84127. uvPattern: RegExp;
  84128. /** @hidden */
  84129. facePattern1: RegExp;
  84130. /** @hidden */
  84131. facePattern2: RegExp;
  84132. /** @hidden */
  84133. facePattern3: RegExp;
  84134. /** @hidden */
  84135. facePattern4: RegExp;
  84136. /** @hidden */
  84137. facePattern5: RegExp;
  84138. private _forAssetContainer;
  84139. private _meshLoadOptions;
  84140. /**
  84141. * Creates loader for .OBJ files
  84142. *
  84143. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  84144. */
  84145. constructor(meshLoadOptions?: MeshLoadOptions);
  84146. private static get currentMeshLoadOptions();
  84147. /**
  84148. * Calls synchronously the MTL file attached to this obj.
  84149. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  84150. * Without this function materials are not displayed in the first frame (but displayed after).
  84151. * In consequence it is impossible to get material information in your HTML file
  84152. *
  84153. * @param url The URL of the MTL file
  84154. * @param rootUrl
  84155. * @param onSuccess Callback function to be called when the MTL file is loaded
  84156. * @private
  84157. */
  84158. private _loadMTL;
  84159. /**
  84160. * Instantiates a OBJ file loader plugin.
  84161. * @returns the created plugin
  84162. */
  84163. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  84164. /**
  84165. * If the data string can be loaded directly.
  84166. *
  84167. * @param data string containing the file data
  84168. * @returns if the data can be loaded directly
  84169. */
  84170. canDirectLoad(data: string): boolean;
  84171. /**
  84172. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  84173. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  84174. * @param scene the scene the meshes should be added to
  84175. * @param data the OBJ data to load
  84176. * @param rootUrl root url to load from
  84177. * @param onProgress event that fires when loading progress has occured
  84178. * @param fileName Defines the name of the file to load
  84179. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  84180. */
  84181. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  84182. meshes: AbstractMesh[];
  84183. particleSystems: IParticleSystem[];
  84184. skeletons: Skeleton[];
  84185. animationGroups: AnimationGroup[];
  84186. }>;
  84187. /**
  84188. * Imports all objects from the loaded OBJ data and adds them to the scene
  84189. * @param scene the scene the objects should be added to
  84190. * @param data the OBJ data to load
  84191. * @param rootUrl root url to load from
  84192. * @param onProgress event that fires when loading progress has occured
  84193. * @param fileName Defines the name of the file to load
  84194. * @returns a promise which completes when objects have been loaded to the scene
  84195. */
  84196. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  84197. /**
  84198. * Load into an asset container.
  84199. * @param scene The scene to load into
  84200. * @param data The data to import
  84201. * @param rootUrl The root url for scene and resources
  84202. * @param onProgress The callback when the load progresses
  84203. * @param fileName Defines the name of the file to load
  84204. * @returns The loaded asset container
  84205. */
  84206. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  84207. /**
  84208. * Read the OBJ file and create an Array of meshes.
  84209. * Each mesh contains all information given by the OBJ and the MTL file.
  84210. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  84211. *
  84212. * @param meshesNames
  84213. * @param scene Scene The scene where are displayed the data
  84214. * @param data String The content of the obj file
  84215. * @param rootUrl String The path to the folder
  84216. * @returns Array<AbstractMesh>
  84217. * @private
  84218. */
  84219. private _parseSolid;
  84220. }
  84221. }
  84222. declare module BABYLON {
  84223. /**
  84224. * STL file type loader.
  84225. * This is a babylon scene loader plugin.
  84226. */
  84227. export class STLFileLoader implements ISceneLoaderPlugin {
  84228. /** @hidden */
  84229. solidPattern: RegExp;
  84230. /** @hidden */
  84231. facetsPattern: RegExp;
  84232. /** @hidden */
  84233. normalPattern: RegExp;
  84234. /** @hidden */
  84235. vertexPattern: RegExp;
  84236. /**
  84237. * Defines the name of the plugin.
  84238. */
  84239. name: string;
  84240. /**
  84241. * Defines the extensions the stl loader is able to load.
  84242. * force data to come in as an ArrayBuffer
  84243. * we'll convert to string if it looks like it's an ASCII .stl
  84244. */
  84245. extensions: ISceneLoaderPluginExtensions;
  84246. /**
  84247. * Import meshes into a scene.
  84248. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  84249. * @param scene The scene to import into
  84250. * @param data The data to import
  84251. * @param rootUrl The root url for scene and resources
  84252. * @param meshes The meshes array to import into
  84253. * @param particleSystems The particle systems array to import into
  84254. * @param skeletons The skeletons array to import into
  84255. * @param onError The callback when import fails
  84256. * @returns True if successful or false otherwise
  84257. */
  84258. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  84259. /**
  84260. * Load into a scene.
  84261. * @param scene The scene to load into
  84262. * @param data The data to import
  84263. * @param rootUrl The root url for scene and resources
  84264. * @param onError The callback when import fails
  84265. * @returns true if successful or false otherwise
  84266. */
  84267. load(scene: Scene, data: any, rootUrl: string): boolean;
  84268. /**
  84269. * Load into an asset container.
  84270. * @param scene The scene to load into
  84271. * @param data The data to import
  84272. * @param rootUrl The root url for scene and resources
  84273. * @param onError The callback when import fails
  84274. * @returns The loaded asset container
  84275. */
  84276. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  84277. private _isBinary;
  84278. private _parseBinary;
  84279. private _parseASCII;
  84280. }
  84281. }
  84282. declare module BABYLON {
  84283. /**
  84284. * Class for generating OBJ data from a Babylon scene.
  84285. */
  84286. export class OBJExport {
  84287. /**
  84288. * Exports the geometry of a Mesh array in .OBJ file format (text)
  84289. * @param mesh defines the list of meshes to serialize
  84290. * @param materials defines if materials should be exported
  84291. * @param matlibname defines the name of the associated mtl file
  84292. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  84293. * @returns the OBJ content
  84294. */
  84295. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  84296. /**
  84297. * Exports the material(s) of a mesh in .MTL file format (text)
  84298. * @param mesh defines the mesh to extract the material from
  84299. * @returns the mtl content
  84300. */
  84301. static MTL(mesh: Mesh): string;
  84302. }
  84303. }
  84304. declare module BABYLON {
  84305. /** @hidden */
  84306. export var __IGLTFExporterExtension: number;
  84307. /**
  84308. * Interface for extending the exporter
  84309. * @hidden
  84310. */
  84311. export interface IGLTFExporterExtension {
  84312. /**
  84313. * The name of this extension
  84314. */
  84315. readonly name: string;
  84316. /**
  84317. * Defines whether this extension is enabled
  84318. */
  84319. enabled: boolean;
  84320. /**
  84321. * Defines whether this extension is required
  84322. */
  84323. required: boolean;
  84324. }
  84325. }
  84326. declare module BABYLON.GLTF2.Exporter {
  84327. /** @hidden */
  84328. export var __IGLTFExporterExtensionV2: number;
  84329. /**
  84330. * Interface for a glTF exporter extension
  84331. * @hidden
  84332. */
  84333. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  84334. /**
  84335. * Define this method to modify the default behavior before exporting a texture
  84336. * @param context The context when loading the asset
  84337. * @param babylonTexture The Babylon.js texture
  84338. * @param mimeType The mime-type of the generated image
  84339. * @returns A promise that resolves with the exported texture
  84340. */
  84341. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  84342. /**
  84343. * Define this method to get notified when a texture info is created
  84344. * @param context The context when loading the asset
  84345. * @param textureInfo The glTF texture info
  84346. * @param babylonTexture The Babylon.js texture
  84347. */
  84348. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  84349. /**
  84350. * Define this method to modify the default behavior when exporting texture info
  84351. * @param context The context when loading the asset
  84352. * @param meshPrimitive glTF mesh primitive
  84353. * @param babylonSubMesh Babylon submesh
  84354. * @param binaryWriter glTF serializer binary writer instance
  84355. * @returns nullable IMeshPrimitive promise
  84356. */
  84357. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  84358. /**
  84359. * Define this method to modify the default behavior when exporting a node
  84360. * @param context The context when exporting the node
  84361. * @param node glTF node
  84362. * @param babylonNode BabylonJS node
  84363. * @returns nullable INode promise
  84364. */
  84365. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  84366. [key: number]: number;
  84367. }): Promise<Nullable<INode>>;
  84368. /**
  84369. * Define this method to modify the default behavior when exporting a material
  84370. * @param material glTF material
  84371. * @param babylonMaterial BabylonJS material
  84372. * @returns nullable IMaterial promise
  84373. */
  84374. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  84375. /**
  84376. * Define this method to return additional textures to export from a material
  84377. * @param material glTF material
  84378. * @param babylonMaterial BabylonJS material
  84379. * @returns List of textures
  84380. */
  84381. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  84382. /** Gets a boolean indicating that this extension was used */
  84383. wasUsed: boolean;
  84384. /** Gets a boolean indicating that this extension is required for the file to work */
  84385. required: boolean;
  84386. /**
  84387. * Called after the exporter state changes to EXPORTING
  84388. */
  84389. onExporting?(): void;
  84390. }
  84391. }
  84392. declare module BABYLON.GLTF2.Exporter {
  84393. /**
  84394. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  84395. * @hidden
  84396. */
  84397. export class _GLTFMaterialExporter {
  84398. /**
  84399. * Represents the dielectric specular values for R, G and B
  84400. */
  84401. private static readonly _DielectricSpecular;
  84402. /**
  84403. * Allows the maximum specular power to be defined for material calculations
  84404. */
  84405. private static readonly _MaxSpecularPower;
  84406. /**
  84407. * Mapping to store textures
  84408. */
  84409. private _textureMap;
  84410. /**
  84411. * Numeric tolerance value
  84412. */
  84413. private static readonly _Epsilon;
  84414. /**
  84415. * Reference to the glTF Exporter
  84416. */
  84417. private _exporter;
  84418. constructor(exporter: _Exporter);
  84419. /**
  84420. * Specifies if two colors are approximately equal in value
  84421. * @param color1 first color to compare to
  84422. * @param color2 second color to compare to
  84423. * @param epsilon threshold value
  84424. */
  84425. private static FuzzyEquals;
  84426. /**
  84427. * Gets the materials from a Babylon scene and converts them to glTF materials
  84428. * @param scene babylonjs scene
  84429. * @param mimeType texture mime type
  84430. * @param images array of images
  84431. * @param textures array of textures
  84432. * @param materials array of materials
  84433. * @param imageData mapping of texture names to base64 textures
  84434. * @param hasTextureCoords specifies if texture coordinates are present on the material
  84435. */
  84436. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  84437. /**
  84438. * Makes a copy of the glTF material without the texture parameters
  84439. * @param originalMaterial original glTF material
  84440. * @returns glTF material without texture parameters
  84441. */
  84442. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  84443. /**
  84444. * Specifies if the material has any texture parameters present
  84445. * @param material glTF Material
  84446. * @returns boolean specifying if texture parameters are present
  84447. */
  84448. _hasTexturesPresent(material: IMaterial): boolean;
  84449. /**
  84450. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  84451. * @param babylonStandardMaterial
  84452. * @returns glTF Metallic Roughness Material representation
  84453. */
  84454. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  84455. /**
  84456. * Computes the metallic factor
  84457. * @param diffuse diffused value
  84458. * @param specular specular value
  84459. * @param oneMinusSpecularStrength one minus the specular strength
  84460. * @returns metallic value
  84461. */
  84462. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  84463. /**
  84464. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  84465. * @param glTFMaterial glTF material
  84466. * @param babylonMaterial Babylon material
  84467. */
  84468. private static _SetAlphaMode;
  84469. /**
  84470. * Converts a Babylon Standard Material to a glTF Material
  84471. * @param babylonStandardMaterial BJS Standard Material
  84472. * @param mimeType mime type to use for the textures
  84473. * @param images array of glTF image interfaces
  84474. * @param textures array of glTF texture interfaces
  84475. * @param materials array of glTF material interfaces
  84476. * @param imageData map of image file name to data
  84477. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84478. */
  84479. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84480. private _finishMaterial;
  84481. /**
  84482. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  84483. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  84484. * @param mimeType mime type to use for the textures
  84485. * @param images array of glTF image interfaces
  84486. * @param textures array of glTF texture interfaces
  84487. * @param materials array of glTF material interfaces
  84488. * @param imageData map of image file name to data
  84489. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84490. */
  84491. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84492. /**
  84493. * Converts an image typed array buffer to a base64 image
  84494. * @param buffer typed array buffer
  84495. * @param width width of the image
  84496. * @param height height of the image
  84497. * @param mimeType mimetype of the image
  84498. * @returns base64 image string
  84499. */
  84500. private _createBase64FromCanvasAsync;
  84501. /**
  84502. * Generates a white texture based on the specified width and height
  84503. * @param width width of the texture in pixels
  84504. * @param height height of the texture in pixels
  84505. * @param scene babylonjs scene
  84506. * @returns white texture
  84507. */
  84508. private _createWhiteTexture;
  84509. /**
  84510. * 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
  84511. * @param texture1 first texture to resize
  84512. * @param texture2 second texture to resize
  84513. * @param scene babylonjs scene
  84514. * @returns resized textures or null
  84515. */
  84516. private _resizeTexturesToSameDimensions;
  84517. /**
  84518. * Converts an array of pixels to a Float32Array
  84519. * Throws an error if the pixel format is not supported
  84520. * @param pixels - array buffer containing pixel values
  84521. * @returns Float32 of pixels
  84522. */
  84523. private _convertPixelArrayToFloat32;
  84524. /**
  84525. * Convert Specular Glossiness Textures to Metallic Roughness
  84526. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  84527. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  84528. * @param diffuseTexture texture used to store diffuse information
  84529. * @param specularGlossinessTexture texture used to store specular and glossiness information
  84530. * @param factors specular glossiness material factors
  84531. * @param mimeType the mime type to use for the texture
  84532. * @returns pbr metallic roughness interface or null
  84533. */
  84534. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  84535. /**
  84536. * Converts specular glossiness material properties to metallic roughness
  84537. * @param specularGlossiness interface with specular glossiness material properties
  84538. * @returns interface with metallic roughness material properties
  84539. */
  84540. private _convertSpecularGlossinessToMetallicRoughness;
  84541. /**
  84542. * Calculates the surface reflectance, independent of lighting conditions
  84543. * @param color Color source to calculate brightness from
  84544. * @returns number representing the perceived brightness, or zero if color is undefined
  84545. */
  84546. private _getPerceivedBrightness;
  84547. /**
  84548. * Returns the maximum color component value
  84549. * @param color
  84550. * @returns maximum color component value, or zero if color is null or undefined
  84551. */
  84552. private _getMaxComponent;
  84553. /**
  84554. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  84555. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84556. * @param mimeType mime type to use for the textures
  84557. * @param images array of glTF image interfaces
  84558. * @param textures array of glTF texture interfaces
  84559. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  84560. * @param imageData map of image file name to data
  84561. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84562. * @returns glTF PBR Metallic Roughness factors
  84563. */
  84564. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  84565. private _getGLTFTextureSampler;
  84566. private _getGLTFTextureWrapMode;
  84567. private _getGLTFTextureWrapModesSampler;
  84568. /**
  84569. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  84570. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84571. * @param mimeType mime type to use for the textures
  84572. * @param images array of glTF image interfaces
  84573. * @param textures array of glTF texture interfaces
  84574. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  84575. * @param imageData map of image file name to data
  84576. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84577. * @returns glTF PBR Metallic Roughness factors
  84578. */
  84579. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  84580. /**
  84581. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  84582. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84583. * @param mimeType mime type to use for the textures
  84584. * @param images array of glTF image interfaces
  84585. * @param textures array of glTF texture interfaces
  84586. * @param materials array of glTF material interfaces
  84587. * @param imageData map of image file name to data
  84588. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84589. */
  84590. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84591. private setMetallicRoughnessPbrMaterial;
  84592. private getPixelsFromTexture;
  84593. /**
  84594. * Extracts a texture from a Babylon texture into file data and glTF data
  84595. * @param babylonTexture Babylon texture to extract
  84596. * @param mimeType Mime Type of the babylonTexture
  84597. * @return glTF texture info, or null if the texture format is not supported
  84598. */
  84599. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  84600. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  84601. /**
  84602. * Builds a texture from base64 string
  84603. * @param base64Texture base64 texture string
  84604. * @param baseTextureName Name to use for the texture
  84605. * @param mimeType image mime type for the texture
  84606. * @param images array of images
  84607. * @param textures array of textures
  84608. * @param imageData map of image data
  84609. * @returns glTF texture info, or null if the texture format is not supported
  84610. */
  84611. private _getTextureInfoFromBase64;
  84612. }
  84613. }
  84614. declare module BABYLON {
  84615. /**
  84616. * Class for holding and downloading glTF file data
  84617. */
  84618. export class GLTFData {
  84619. /**
  84620. * Object which contains the file name as the key and its data as the value
  84621. */
  84622. glTFFiles: {
  84623. [fileName: string]: string | Blob;
  84624. };
  84625. /**
  84626. * Initializes the glTF file object
  84627. */
  84628. constructor();
  84629. /**
  84630. * Downloads the glTF data as files based on their names and data
  84631. */
  84632. downloadFiles(): void;
  84633. }
  84634. }
  84635. declare module BABYLON {
  84636. /**
  84637. * Holds a collection of exporter options and parameters
  84638. */
  84639. export interface IExportOptions {
  84640. /**
  84641. * Function which indicates whether a babylon node should be exported or not
  84642. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  84643. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  84644. */
  84645. shouldExportNode?(node: Node): boolean;
  84646. /**
  84647. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  84648. * @param metadata source metadata to read from
  84649. * @returns the data to store to glTF node extras
  84650. */
  84651. metadataSelector?(metadata: any): any;
  84652. /**
  84653. * The sample rate to bake animation curves
  84654. */
  84655. animationSampleRate?: number;
  84656. /**
  84657. * Begin serialization without waiting for the scene to be ready
  84658. */
  84659. exportWithoutWaitingForScene?: boolean;
  84660. /**
  84661. * Indicates if coordinate system swapping root nodes should be included in export
  84662. */
  84663. includeCoordinateSystemConversionNodes?: boolean;
  84664. }
  84665. /**
  84666. * Class for generating glTF data from a Babylon scene.
  84667. */
  84668. export class GLTF2Export {
  84669. /**
  84670. * Exports the geometry of the scene to .gltf file format asynchronously
  84671. * @param scene Babylon scene with scene hierarchy information
  84672. * @param filePrefix File prefix to use when generating the glTF file
  84673. * @param options Exporter options
  84674. * @returns Returns an object with a .gltf file and associates texture names
  84675. * as keys and their data and paths as values
  84676. */
  84677. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  84678. private static _PreExportAsync;
  84679. private static _PostExportAsync;
  84680. /**
  84681. * Exports the geometry of the scene to .glb file format asychronously
  84682. * @param scene Babylon scene with scene hierarchy information
  84683. * @param filePrefix File prefix to use when generating glb file
  84684. * @param options Exporter options
  84685. * @returns Returns an object with a .glb filename as key and data as value
  84686. */
  84687. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  84688. }
  84689. }
  84690. declare module BABYLON.GLTF2.Exporter {
  84691. /**
  84692. * @hidden
  84693. */
  84694. export class _GLTFUtilities {
  84695. /**
  84696. * Creates a buffer view based on the supplied arguments
  84697. * @param bufferIndex index value of the specified buffer
  84698. * @param byteOffset byte offset value
  84699. * @param byteLength byte length of the bufferView
  84700. * @param byteStride byte distance between conequential elements
  84701. * @param name name of the buffer view
  84702. * @returns bufferView for glTF
  84703. */
  84704. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  84705. /**
  84706. * Creates an accessor based on the supplied arguments
  84707. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  84708. * @param name The name of the accessor
  84709. * @param type The type of the accessor
  84710. * @param componentType The datatype of components in the attribute
  84711. * @param count The number of attributes referenced by this accessor
  84712. * @param byteOffset The offset relative to the start of the bufferView in bytes
  84713. * @param min Minimum value of each component in this attribute
  84714. * @param max Maximum value of each component in this attribute
  84715. * @returns accessor for glTF
  84716. */
  84717. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  84718. /**
  84719. * Calculates the minimum and maximum values of an array of position floats
  84720. * @param positions Positions array of a mesh
  84721. * @param vertexStart Starting vertex offset to calculate min and max values
  84722. * @param vertexCount Number of vertices to check for min and max values
  84723. * @returns min number array and max number array
  84724. */
  84725. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  84726. min: number[];
  84727. max: number[];
  84728. };
  84729. /**
  84730. * Converts a new right-handed Vector3
  84731. * @param vector vector3 array
  84732. * @returns right-handed Vector3
  84733. */
  84734. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  84735. /**
  84736. * Converts a Vector3 to right-handed
  84737. * @param vector Vector3 to convert to right-handed
  84738. */
  84739. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  84740. /**
  84741. * Converts a three element number array to right-handed
  84742. * @param vector number array to convert to right-handed
  84743. */
  84744. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  84745. /**
  84746. * Converts a new right-handed Vector3
  84747. * @param vector vector3 array
  84748. * @returns right-handed Vector3
  84749. */
  84750. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  84751. /**
  84752. * Converts a Vector3 to right-handed
  84753. * @param vector Vector3 to convert to right-handed
  84754. */
  84755. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  84756. /**
  84757. * Converts a three element number array to right-handed
  84758. * @param vector number array to convert to right-handed
  84759. */
  84760. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  84761. /**
  84762. * Converts a Vector4 to right-handed
  84763. * @param vector Vector4 to convert to right-handed
  84764. */
  84765. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  84766. /**
  84767. * Converts a Vector4 to right-handed
  84768. * @param vector Vector4 to convert to right-handed
  84769. */
  84770. static _GetRightHandedArray4FromRef(vector: number[]): void;
  84771. /**
  84772. * Converts a Quaternion to right-handed
  84773. * @param quaternion Source quaternion to convert to right-handed
  84774. */
  84775. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  84776. /**
  84777. * Converts a Quaternion to right-handed
  84778. * @param quaternion Source quaternion to convert to right-handed
  84779. */
  84780. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  84781. static _NormalizeTangentFromRef(tangent: Vector4): void;
  84782. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  84783. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  84784. }
  84785. }
  84786. declare module BABYLON.GLTF2.Exporter {
  84787. /**
  84788. * Converts Babylon Scene into glTF 2.0.
  84789. * @hidden
  84790. */
  84791. export class _Exporter {
  84792. /**
  84793. * Stores the glTF to export
  84794. */
  84795. _glTF: IGLTF;
  84796. /**
  84797. * Stores all generated buffer views, which represents views into the main glTF buffer data
  84798. */
  84799. _bufferViews: IBufferView[];
  84800. /**
  84801. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  84802. */
  84803. _accessors: IAccessor[];
  84804. /**
  84805. * Stores all the generated nodes, which contains transform and/or mesh information per node
  84806. */
  84807. _nodes: INode[];
  84808. /**
  84809. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  84810. */
  84811. private _scenes;
  84812. /**
  84813. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  84814. */
  84815. private _meshes;
  84816. /**
  84817. * Stores all the generated material information, which represents the appearance of each primitive
  84818. */
  84819. _materials: IMaterial[];
  84820. _materialMap: {
  84821. [materialID: number]: number;
  84822. };
  84823. /**
  84824. * Stores all the generated texture information, which is referenced by glTF materials
  84825. */
  84826. _textures: ITexture[];
  84827. /**
  84828. * Stores all the generated image information, which is referenced by glTF textures
  84829. */
  84830. _images: IImage[];
  84831. /**
  84832. * Stores all the texture samplers
  84833. */
  84834. _samplers: ISampler[];
  84835. /**
  84836. * Stores all the generated glTF skins
  84837. */
  84838. _skins: ISkin[];
  84839. /**
  84840. * Stores all the generated animation samplers, which is referenced by glTF animations
  84841. */
  84842. /**
  84843. * Stores the animations for glTF models
  84844. */
  84845. private _animations;
  84846. /**
  84847. * Stores the total amount of bytes stored in the glTF buffer
  84848. */
  84849. private _totalByteLength;
  84850. /**
  84851. * Stores a reference to the Babylon scene containing the source geometry and material information
  84852. */
  84853. _babylonScene: Scene;
  84854. /**
  84855. * Stores a map of the image data, where the key is the file name and the value
  84856. * is the image data
  84857. */
  84858. _imageData: {
  84859. [fileName: string]: {
  84860. data: Uint8Array;
  84861. mimeType: ImageMimeType;
  84862. };
  84863. };
  84864. protected _orderedImageData: Array<{
  84865. data: Uint8Array;
  84866. mimeType: ImageMimeType;
  84867. }>;
  84868. /**
  84869. * Stores a map of the unique id of a node to its index in the node array
  84870. */
  84871. _nodeMap: {
  84872. [key: number]: number;
  84873. };
  84874. /**
  84875. * Specifies if the source Babylon scene was left handed, and needed conversion.
  84876. */
  84877. _convertToRightHandedSystem: boolean;
  84878. /**
  84879. * Specifies if a Babylon node should be converted to right-handed on export
  84880. */
  84881. _convertToRightHandedSystemMap: {
  84882. [nodeId: number]: boolean;
  84883. };
  84884. _includeCoordinateSystemConversionNodes: boolean;
  84885. /**
  84886. * Baked animation sample rate
  84887. */
  84888. private _animationSampleRate;
  84889. private _options;
  84890. private _localEngine;
  84891. _glTFMaterialExporter: _GLTFMaterialExporter;
  84892. private _extensions;
  84893. private static _ExtensionNames;
  84894. private static _ExtensionFactories;
  84895. private _applyExtension;
  84896. private _applyExtensions;
  84897. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  84898. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  84899. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  84900. [key: number]: number;
  84901. }): Promise<Nullable<INode>>;
  84902. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  84903. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  84904. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  84905. private _forEachExtensions;
  84906. private _extensionsOnExporting;
  84907. /**
  84908. * Load glTF serializer extensions
  84909. */
  84910. private _loadExtensions;
  84911. /**
  84912. * Creates a glTF Exporter instance, which can accept optional exporter options
  84913. * @param babylonScene Babylon scene object
  84914. * @param options Options to modify the behavior of the exporter
  84915. */
  84916. constructor(babylonScene: Scene, options?: IExportOptions);
  84917. dispose(): void;
  84918. /**
  84919. * Registers a glTF exporter extension
  84920. * @param name Name of the extension to export
  84921. * @param factory The factory function that creates the exporter extension
  84922. */
  84923. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  84924. /**
  84925. * Un-registers an exporter extension
  84926. * @param name The name fo the exporter extension
  84927. * @returns A boolean indicating whether the extension has been un-registered
  84928. */
  84929. static UnregisterExtension(name: string): boolean;
  84930. /**
  84931. * Lazy load a local engine
  84932. */
  84933. _getLocalEngine(): Engine;
  84934. private reorderIndicesBasedOnPrimitiveMode;
  84935. /**
  84936. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  84937. * clock-wise during export to glTF
  84938. * @param submesh BabylonJS submesh
  84939. * @param primitiveMode Primitive mode of the mesh
  84940. * @param sideOrientation the winding order of the submesh
  84941. * @param vertexBufferKind The type of vertex attribute
  84942. * @param meshAttributeArray The vertex attribute data
  84943. * @param byteOffset The offset to the binary data
  84944. * @param binaryWriter The binary data for the glTF file
  84945. * @param convertToRightHandedSystem Converts the values to right-handed
  84946. */
  84947. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  84948. /**
  84949. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  84950. * clock-wise during export to glTF
  84951. * @param submesh BabylonJS submesh
  84952. * @param primitiveMode Primitive mode of the mesh
  84953. * @param sideOrientation the winding order of the submesh
  84954. * @param vertexBufferKind The type of vertex attribute
  84955. * @param meshAttributeArray The vertex attribute data
  84956. * @param byteOffset The offset to the binary data
  84957. * @param binaryWriter The binary data for the glTF file
  84958. * @param convertToRightHandedSystem Converts the values to right-handed
  84959. */
  84960. private reorderTriangleFillMode;
  84961. /**
  84962. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  84963. * clock-wise during export to glTF
  84964. * @param submesh BabylonJS submesh
  84965. * @param primitiveMode Primitive mode of the mesh
  84966. * @param sideOrientation the winding order of the submesh
  84967. * @param vertexBufferKind The type of vertex attribute
  84968. * @param meshAttributeArray The vertex attribute data
  84969. * @param byteOffset The offset to the binary data
  84970. * @param binaryWriter The binary data for the glTF file
  84971. * @param convertToRightHandedSystem Converts the values to right-handed
  84972. */
  84973. private reorderTriangleStripDrawMode;
  84974. /**
  84975. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  84976. * clock-wise during export to glTF
  84977. * @param submesh BabylonJS submesh
  84978. * @param primitiveMode Primitive mode of the mesh
  84979. * @param sideOrientation the winding order of the submesh
  84980. * @param vertexBufferKind The type of vertex attribute
  84981. * @param meshAttributeArray The vertex attribute data
  84982. * @param byteOffset The offset to the binary data
  84983. * @param binaryWriter The binary data for the glTF file
  84984. * @param convertToRightHandedSystem Converts the values to right-handed
  84985. */
  84986. private reorderTriangleFanMode;
  84987. /**
  84988. * Writes the vertex attribute data to binary
  84989. * @param vertices The vertices to write to the binary writer
  84990. * @param byteOffset The offset into the binary writer to overwrite binary data
  84991. * @param vertexAttributeKind The vertex attribute type
  84992. * @param meshAttributeArray The vertex attribute data
  84993. * @param binaryWriter The writer containing the binary data
  84994. * @param convertToRightHandedSystem Converts the values to right-handed
  84995. */
  84996. private writeVertexAttributeData;
  84997. /**
  84998. * Writes mesh attribute data to a data buffer
  84999. * Returns the bytelength of the data
  85000. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  85001. * @param meshAttributeArray Array containing the attribute data
  85002. * @param byteStride Specifies the space between data
  85003. * @param binaryWriter The buffer to write the binary data to
  85004. * @param convertToRightHandedSystem Converts the values to right-handed
  85005. */
  85006. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  85007. /**
  85008. * Writes mesh attribute data to a data buffer
  85009. * Returns the bytelength of the data
  85010. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  85011. * @param meshAttributeArray Array containing the attribute data
  85012. * @param byteStride Specifies the space between data
  85013. * @param binaryWriter The buffer to write the binary data to
  85014. * @param convertToRightHandedSystem Converts the values to right-handed
  85015. */
  85016. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  85017. /**
  85018. * Generates glTF json data
  85019. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  85020. * @param glTFPrefix Text to use when prefixing a glTF file
  85021. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  85022. * @returns json data as string
  85023. */
  85024. private generateJSON;
  85025. /**
  85026. * Generates data for .gltf and .bin files based on the glTF prefix string
  85027. * @param glTFPrefix Text to use when prefixing a glTF file
  85028. * @param dispose Dispose the exporter
  85029. * @returns GLTFData with glTF file data
  85030. */
  85031. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  85032. /**
  85033. * Creates a binary buffer for glTF
  85034. * @returns array buffer for binary data
  85035. */
  85036. private _generateBinaryAsync;
  85037. /**
  85038. * Pads the number to a multiple of 4
  85039. * @param num number to pad
  85040. * @returns padded number
  85041. */
  85042. private _getPadding;
  85043. /**
  85044. * @hidden
  85045. */
  85046. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  85047. /**
  85048. * Sets the TRS for each node
  85049. * @param node glTF Node for storing the transformation data
  85050. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  85051. * @param convertToRightHandedSystem Converts the values to right-handed
  85052. */
  85053. private setNodeTransformation;
  85054. private getVertexBufferFromMesh;
  85055. /**
  85056. * Creates a bufferview based on the vertices type for the Babylon mesh
  85057. * @param kind Indicates the type of vertices data
  85058. * @param componentType Indicates the numerical type used to store the data
  85059. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  85060. * @param binaryWriter The buffer to write the bufferview data to
  85061. * @param convertToRightHandedSystem Converts the values to right-handed
  85062. */
  85063. private createBufferViewKind;
  85064. /**
  85065. * Creates a bufferview based on the vertices type for the Babylon mesh
  85066. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  85067. * @param babylonMorphTarget the morph target to be exported
  85068. * @param binaryWriter The buffer to write the bufferview data to
  85069. * @param convertToRightHandedSystem Converts the values to right-handed
  85070. */
  85071. private setMorphTargetAttributes;
  85072. /**
  85073. * The primitive mode of the Babylon mesh
  85074. * @param babylonMesh The BabylonJS mesh
  85075. */
  85076. private getMeshPrimitiveMode;
  85077. /**
  85078. * Sets the primitive mode of the glTF mesh primitive
  85079. * @param meshPrimitive glTF mesh primitive
  85080. * @param primitiveMode The primitive mode
  85081. */
  85082. private setPrimitiveMode;
  85083. /**
  85084. * Sets the vertex attribute accessor based of the glTF mesh primitive
  85085. * @param meshPrimitive glTF mesh primitive
  85086. * @param attributeKind vertex attribute
  85087. * @returns boolean specifying if uv coordinates are present
  85088. */
  85089. private setAttributeKind;
  85090. /**
  85091. * Sets data for the primitive attributes of each submesh
  85092. * @param mesh glTF Mesh object to store the primitive attribute information
  85093. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  85094. * @param binaryWriter Buffer to write the attribute data to
  85095. * @param convertToRightHandedSystem Converts the values to right-handed
  85096. */
  85097. private setPrimitiveAttributesAsync;
  85098. /**
  85099. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  85100. * @param node The node to check
  85101. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  85102. */
  85103. private isBabylonCoordinateSystemConvertingNode;
  85104. /**
  85105. * Creates a glTF scene based on the array of meshes
  85106. * Returns the the total byte offset
  85107. * @param babylonScene Babylon scene to get the mesh data from
  85108. * @param binaryWriter Buffer to write binary data to
  85109. */
  85110. private createSceneAsync;
  85111. /**
  85112. * Creates a mapping of Node unique id to node index and handles animations
  85113. * @param babylonScene Babylon Scene
  85114. * @param nodes Babylon transform nodes
  85115. * @param binaryWriter Buffer to write binary data to
  85116. * @returns Node mapping of unique id to index
  85117. */
  85118. private createNodeMapAndAnimationsAsync;
  85119. /**
  85120. * Creates a glTF node from a Babylon mesh
  85121. * @param babylonMesh Source Babylon mesh
  85122. * @param binaryWriter Buffer for storing geometry data
  85123. * @param convertToRightHandedSystem Converts the values to right-handed
  85124. * @param nodeMap Node mapping of unique id to glTF node index
  85125. * @returns glTF node
  85126. */
  85127. private createNodeAsync;
  85128. /**
  85129. * Creates a glTF skin from a Babylon skeleton
  85130. * @param babylonScene Babylon Scene
  85131. * @param nodes Babylon transform nodes
  85132. * @param binaryWriter Buffer to write binary data to
  85133. * @returns Node mapping of unique id to index
  85134. */
  85135. private createSkinsAsync;
  85136. }
  85137. /**
  85138. * @hidden
  85139. *
  85140. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  85141. */
  85142. export class _BinaryWriter {
  85143. /**
  85144. * Array buffer which stores all binary data
  85145. */
  85146. private _arrayBuffer;
  85147. /**
  85148. * View of the array buffer
  85149. */
  85150. private _dataView;
  85151. /**
  85152. * byte offset of data in array buffer
  85153. */
  85154. private _byteOffset;
  85155. /**
  85156. * Initialize binary writer with an initial byte length
  85157. * @param byteLength Initial byte length of the array buffer
  85158. */
  85159. constructor(byteLength: number);
  85160. /**
  85161. * Resize the array buffer to the specified byte length
  85162. * @param byteLength
  85163. */
  85164. private resizeBuffer;
  85165. /**
  85166. * Get an array buffer with the length of the byte offset
  85167. * @returns ArrayBuffer resized to the byte offset
  85168. */
  85169. getArrayBuffer(): ArrayBuffer;
  85170. /**
  85171. * Get the byte offset of the array buffer
  85172. * @returns byte offset
  85173. */
  85174. getByteOffset(): number;
  85175. /**
  85176. * Stores an UInt8 in the array buffer
  85177. * @param entry
  85178. * @param byteOffset If defined, specifies where to set the value as an offset.
  85179. */
  85180. setUInt8(entry: number, byteOffset?: number): void;
  85181. /**
  85182. * Stores an UInt16 in the array buffer
  85183. * @param entry
  85184. * @param byteOffset If defined, specifies where to set the value as an offset.
  85185. */
  85186. setUInt16(entry: number, byteOffset?: number): void;
  85187. /**
  85188. * Gets an UInt32 in the array buffer
  85189. * @param entry
  85190. * @param byteOffset If defined, specifies where to set the value as an offset.
  85191. */
  85192. getUInt32(byteOffset: number): number;
  85193. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  85194. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  85195. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  85196. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  85197. /**
  85198. * Stores a Float32 in the array buffer
  85199. * @param entry
  85200. */
  85201. setFloat32(entry: number, byteOffset?: number): void;
  85202. /**
  85203. * Stores an UInt32 in the array buffer
  85204. * @param entry
  85205. * @param byteOffset If defined, specifies where to set the value as an offset.
  85206. */
  85207. setUInt32(entry: number, byteOffset?: number): void;
  85208. }
  85209. }
  85210. declare module BABYLON.GLTF2.Exporter {
  85211. /**
  85212. * @hidden
  85213. * Interface to store animation data.
  85214. */
  85215. export interface _IAnimationData {
  85216. /**
  85217. * Keyframe data.
  85218. */
  85219. inputs: number[];
  85220. /**
  85221. * Value data.
  85222. */
  85223. outputs: number[][];
  85224. /**
  85225. * Animation interpolation data.
  85226. */
  85227. samplerInterpolation: AnimationSamplerInterpolation;
  85228. /**
  85229. * Minimum keyframe value.
  85230. */
  85231. inputsMin: number;
  85232. /**
  85233. * Maximum keyframe value.
  85234. */
  85235. inputsMax: number;
  85236. }
  85237. /**
  85238. * @hidden
  85239. */
  85240. export interface _IAnimationInfo {
  85241. /**
  85242. * The target channel for the animation
  85243. */
  85244. animationChannelTargetPath: AnimationChannelTargetPath;
  85245. /**
  85246. * The glTF accessor type for the data.
  85247. */
  85248. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  85249. /**
  85250. * Specifies if quaternions should be used.
  85251. */
  85252. useQuaternion: boolean;
  85253. }
  85254. /**
  85255. * @hidden
  85256. * Utility class for generating glTF animation data from BabylonJS.
  85257. */
  85258. export class _GLTFAnimation {
  85259. /**
  85260. * @ignore
  85261. *
  85262. * Creates glTF channel animation from BabylonJS animation.
  85263. * @param babylonTransformNode - BabylonJS mesh.
  85264. * @param animation - animation.
  85265. * @param animationChannelTargetPath - The target animation channel.
  85266. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  85267. * @param useQuaternion - Specifies if quaternions are used.
  85268. * @returns nullable IAnimationData
  85269. */
  85270. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  85271. private static _DeduceAnimationInfo;
  85272. /**
  85273. * @ignore
  85274. * Create node animations from the transform node animations
  85275. * @param babylonNode
  85276. * @param runtimeGLTFAnimation
  85277. * @param idleGLTFAnimations
  85278. * @param nodeMap
  85279. * @param nodes
  85280. * @param binaryWriter
  85281. * @param bufferViews
  85282. * @param accessors
  85283. * @param convertToRightHandedSystem
  85284. * @param animationSampleRate
  85285. */
  85286. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  85287. [key: number]: number;
  85288. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  85289. /**
  85290. * @ignore
  85291. * Create individual morph animations from the mesh's morph target animation tracks
  85292. * @param babylonNode
  85293. * @param runtimeGLTFAnimation
  85294. * @param idleGLTFAnimations
  85295. * @param nodeMap
  85296. * @param nodes
  85297. * @param binaryWriter
  85298. * @param bufferViews
  85299. * @param accessors
  85300. * @param convertToRightHandedSystem
  85301. * @param animationSampleRate
  85302. */
  85303. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  85304. [key: number]: number;
  85305. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  85306. /**
  85307. * @ignore
  85308. * Create node and morph animations from the animation groups
  85309. * @param babylonScene
  85310. * @param glTFAnimations
  85311. * @param nodeMap
  85312. * @param nodes
  85313. * @param binaryWriter
  85314. * @param bufferViews
  85315. * @param accessors
  85316. * @param convertToRightHandedSystemMap
  85317. * @param animationSampleRate
  85318. */
  85319. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  85320. [key: number]: number;
  85321. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  85322. [nodeId: number]: boolean;
  85323. }, animationSampleRate: number): void;
  85324. private static AddAnimation;
  85325. /**
  85326. * Create a baked animation
  85327. * @param babylonTransformNode BabylonJS mesh
  85328. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  85329. * @param animationChannelTargetPath animation target channel
  85330. * @param minFrame minimum animation frame
  85331. * @param maxFrame maximum animation frame
  85332. * @param fps frames per second of the animation
  85333. * @param inputs input key frames of the animation
  85334. * @param outputs output key frame data of the animation
  85335. * @param convertToRightHandedSystem converts the values to right-handed
  85336. * @param useQuaternion specifies if quaternions should be used
  85337. */
  85338. private static _CreateBakedAnimation;
  85339. private static _ConvertFactorToVector3OrQuaternion;
  85340. private static _SetInterpolatedValue;
  85341. /**
  85342. * Creates linear animation from the animation key frames
  85343. * @param babylonTransformNode BabylonJS mesh
  85344. * @param animation BabylonJS animation
  85345. * @param animationChannelTargetPath The target animation channel
  85346. * @param frameDelta The difference between the last and first frame of the animation
  85347. * @param inputs Array to store the key frame times
  85348. * @param outputs Array to store the key frame data
  85349. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  85350. * @param useQuaternion Specifies if quaternions are used in the animation
  85351. */
  85352. private static _CreateLinearOrStepAnimation;
  85353. /**
  85354. * Creates cubic spline animation from the animation key frames
  85355. * @param babylonTransformNode BabylonJS mesh
  85356. * @param animation BabylonJS animation
  85357. * @param animationChannelTargetPath The target animation channel
  85358. * @param frameDelta The difference between the last and first frame of the animation
  85359. * @param inputs Array to store the key frame times
  85360. * @param outputs Array to store the key frame data
  85361. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  85362. * @param useQuaternion Specifies if quaternions are used in the animation
  85363. */
  85364. private static _CreateCubicSplineAnimation;
  85365. private static _GetBasePositionRotationOrScale;
  85366. /**
  85367. * Adds a key frame value
  85368. * @param keyFrame
  85369. * @param animation
  85370. * @param outputs
  85371. * @param animationChannelTargetPath
  85372. * @param basePositionRotationOrScale
  85373. * @param convertToRightHandedSystem
  85374. * @param useQuaternion
  85375. */
  85376. private static _AddKeyframeValue;
  85377. /**
  85378. * Determine the interpolation based on the key frames
  85379. * @param keyFrames
  85380. * @param animationChannelTargetPath
  85381. * @param useQuaternion
  85382. */
  85383. private static _DeduceInterpolation;
  85384. /**
  85385. * Adds an input tangent or output tangent to the output data
  85386. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  85387. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  85388. * @param outputs The animation data by keyframe
  85389. * @param animationChannelTargetPath The target animation channel
  85390. * @param interpolation The interpolation type
  85391. * @param keyFrame The key frame with the animation data
  85392. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  85393. * @param useQuaternion Specifies if quaternions are used
  85394. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  85395. */
  85396. private static AddSplineTangent;
  85397. /**
  85398. * Get the minimum and maximum key frames' frame values
  85399. * @param keyFrames animation key frames
  85400. * @returns the minimum and maximum key frame value
  85401. */
  85402. private static calculateMinMaxKeyFrames;
  85403. }
  85404. }
  85405. declare module BABYLON.GLTF2.Exporter {
  85406. /** @hidden */
  85407. export var textureTransformPixelShader: {
  85408. name: string;
  85409. shader: string;
  85410. };
  85411. }
  85412. declare module BABYLON.GLTF2.Exporter.Extensions {
  85413. /**
  85414. * @hidden
  85415. */
  85416. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  85417. private _recordedTextures;
  85418. /** Name of this extension */
  85419. readonly name: string;
  85420. /** Defines whether this extension is enabled */
  85421. enabled: boolean;
  85422. /** Defines whether this extension is required */
  85423. required: boolean;
  85424. /** Reference to the glTF exporter */
  85425. private _wasUsed;
  85426. constructor(exporter: _Exporter);
  85427. dispose(): void;
  85428. /** @hidden */
  85429. get wasUsed(): boolean;
  85430. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  85431. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  85432. /**
  85433. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  85434. * @param babylonTexture
  85435. * @param offset
  85436. * @param rotation
  85437. * @param scale
  85438. * @param scene
  85439. */
  85440. private _textureTransformTextureAsync;
  85441. }
  85442. }
  85443. declare module BABYLON.GLTF2.Exporter.Extensions {
  85444. /**
  85445. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  85446. */
  85447. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  85448. /** The name of this extension. */
  85449. readonly name: string;
  85450. /** Defines whether this extension is enabled. */
  85451. enabled: boolean;
  85452. /** Defines whether this extension is required */
  85453. required: boolean;
  85454. /** Reference to the glTF exporter */
  85455. private _exporter;
  85456. private _lights;
  85457. /** @hidden */
  85458. constructor(exporter: _Exporter);
  85459. /** @hidden */
  85460. dispose(): void;
  85461. /** @hidden */
  85462. get wasUsed(): boolean;
  85463. /** @hidden */
  85464. onExporting(): void;
  85465. /**
  85466. * Define this method to modify the default behavior when exporting a node
  85467. * @param context The context when exporting the node
  85468. * @param node glTF node
  85469. * @param babylonNode BabylonJS node
  85470. * @param nodeMap Node mapping of unique id to glTF node index
  85471. * @returns nullable INode promise
  85472. */
  85473. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  85474. [key: number]: number;
  85475. }): Promise<Nullable<INode>>;
  85476. }
  85477. }
  85478. declare module BABYLON.GLTF2.Exporter.Extensions {
  85479. /**
  85480. * @hidden
  85481. */
  85482. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  85483. /** Name of this extension */
  85484. readonly name: string;
  85485. /** Defines whether this extension is enabled */
  85486. enabled: boolean;
  85487. /** Defines whether this extension is required */
  85488. required: boolean;
  85489. /** Reference to the glTF exporter */
  85490. private _textureInfos;
  85491. private _exportedTextures;
  85492. private _wasUsed;
  85493. constructor(exporter: _Exporter);
  85494. dispose(): void;
  85495. /** @hidden */
  85496. get wasUsed(): boolean;
  85497. private _getTextureIndex;
  85498. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  85499. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  85500. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  85501. }
  85502. }
  85503. declare module BABYLON.GLTF2.Exporter.Extensions {
  85504. /**
  85505. * @hidden
  85506. */
  85507. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  85508. /** Name of this extension */
  85509. readonly name: string;
  85510. /** Defines whether this extension is enabled */
  85511. enabled: boolean;
  85512. /** Defines whether this extension is required */
  85513. required: boolean;
  85514. private _wasUsed;
  85515. constructor(exporter: _Exporter);
  85516. /** @hidden */
  85517. get wasUsed(): boolean;
  85518. dispose(): void;
  85519. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  85520. }
  85521. }
  85522. declare module BABYLON {
  85523. /**
  85524. * Class for generating STL data from a Babylon scene.
  85525. */
  85526. export class STLExport {
  85527. /**
  85528. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  85529. * @param meshes list defines the mesh to serialize
  85530. * @param download triggers the automatic download of the file.
  85531. * @param fileName changes the downloads fileName.
  85532. * @param binary changes the STL to a binary type.
  85533. * @param isLittleEndian toggle for binary type exporter.
  85534. * @returns the STL as UTF8 string
  85535. */
  85536. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  85537. }
  85538. }
  85539. declare module "babylonjs-gltf2interface" {
  85540. export = BABYLON.GLTF2;
  85541. }
  85542. /**
  85543. * Module for glTF 2.0 Interface
  85544. */
  85545. declare module BABYLON.GLTF2 {
  85546. /**
  85547. * The datatype of the components in the attribute
  85548. */
  85549. const enum AccessorComponentType {
  85550. /**
  85551. * Byte
  85552. */
  85553. BYTE = 5120,
  85554. /**
  85555. * Unsigned Byte
  85556. */
  85557. UNSIGNED_BYTE = 5121,
  85558. /**
  85559. * Short
  85560. */
  85561. SHORT = 5122,
  85562. /**
  85563. * Unsigned Short
  85564. */
  85565. UNSIGNED_SHORT = 5123,
  85566. /**
  85567. * Unsigned Int
  85568. */
  85569. UNSIGNED_INT = 5125,
  85570. /**
  85571. * Float
  85572. */
  85573. FLOAT = 5126,
  85574. }
  85575. /**
  85576. * Specifies if the attirbute is a scalar, vector, or matrix
  85577. */
  85578. const enum AccessorType {
  85579. /**
  85580. * Scalar
  85581. */
  85582. SCALAR = "SCALAR",
  85583. /**
  85584. * Vector2
  85585. */
  85586. VEC2 = "VEC2",
  85587. /**
  85588. * Vector3
  85589. */
  85590. VEC3 = "VEC3",
  85591. /**
  85592. * Vector4
  85593. */
  85594. VEC4 = "VEC4",
  85595. /**
  85596. * Matrix2x2
  85597. */
  85598. MAT2 = "MAT2",
  85599. /**
  85600. * Matrix3x3
  85601. */
  85602. MAT3 = "MAT3",
  85603. /**
  85604. * Matrix4x4
  85605. */
  85606. MAT4 = "MAT4",
  85607. }
  85608. /**
  85609. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  85610. */
  85611. const enum AnimationChannelTargetPath {
  85612. /**
  85613. * Translation
  85614. */
  85615. TRANSLATION = "translation",
  85616. /**
  85617. * Rotation
  85618. */
  85619. ROTATION = "rotation",
  85620. /**
  85621. * Scale
  85622. */
  85623. SCALE = "scale",
  85624. /**
  85625. * Weights
  85626. */
  85627. WEIGHTS = "weights",
  85628. }
  85629. /**
  85630. * Interpolation algorithm
  85631. */
  85632. const enum AnimationSamplerInterpolation {
  85633. /**
  85634. * The animated values are linearly interpolated between keyframes
  85635. */
  85636. LINEAR = "LINEAR",
  85637. /**
  85638. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  85639. */
  85640. STEP = "STEP",
  85641. /**
  85642. * The animation's interpolation is computed using a cubic spline with specified tangents
  85643. */
  85644. CUBICSPLINE = "CUBICSPLINE",
  85645. }
  85646. /**
  85647. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  85648. */
  85649. const enum CameraType {
  85650. /**
  85651. * A perspective camera containing properties to create a perspective projection matrix
  85652. */
  85653. PERSPECTIVE = "perspective",
  85654. /**
  85655. * An orthographic camera containing properties to create an orthographic projection matrix
  85656. */
  85657. ORTHOGRAPHIC = "orthographic",
  85658. }
  85659. /**
  85660. * The mime-type of the image
  85661. */
  85662. const enum ImageMimeType {
  85663. /**
  85664. * JPEG Mime-type
  85665. */
  85666. JPEG = "image/jpeg",
  85667. /**
  85668. * PNG Mime-type
  85669. */
  85670. PNG = "image/png",
  85671. }
  85672. /**
  85673. * The alpha rendering mode of the material
  85674. */
  85675. const enum MaterialAlphaMode {
  85676. /**
  85677. * The alpha value is ignored and the rendered output is fully opaque
  85678. */
  85679. OPAQUE = "OPAQUE",
  85680. /**
  85681. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  85682. */
  85683. MASK = "MASK",
  85684. /**
  85685. * 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)
  85686. */
  85687. BLEND = "BLEND",
  85688. }
  85689. /**
  85690. * The type of the primitives to render
  85691. */
  85692. const enum MeshPrimitiveMode {
  85693. /**
  85694. * Points
  85695. */
  85696. POINTS = 0,
  85697. /**
  85698. * Lines
  85699. */
  85700. LINES = 1,
  85701. /**
  85702. * Line Loop
  85703. */
  85704. LINE_LOOP = 2,
  85705. /**
  85706. * Line Strip
  85707. */
  85708. LINE_STRIP = 3,
  85709. /**
  85710. * Triangles
  85711. */
  85712. TRIANGLES = 4,
  85713. /**
  85714. * Triangle Strip
  85715. */
  85716. TRIANGLE_STRIP = 5,
  85717. /**
  85718. * Triangle Fan
  85719. */
  85720. TRIANGLE_FAN = 6,
  85721. }
  85722. /**
  85723. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  85724. */
  85725. const enum TextureMagFilter {
  85726. /**
  85727. * Nearest
  85728. */
  85729. NEAREST = 9728,
  85730. /**
  85731. * Linear
  85732. */
  85733. LINEAR = 9729,
  85734. }
  85735. /**
  85736. * Minification filter. All valid values correspond to WebGL enums
  85737. */
  85738. const enum TextureMinFilter {
  85739. /**
  85740. * Nearest
  85741. */
  85742. NEAREST = 9728,
  85743. /**
  85744. * Linear
  85745. */
  85746. LINEAR = 9729,
  85747. /**
  85748. * Nearest Mip-Map Nearest
  85749. */
  85750. NEAREST_MIPMAP_NEAREST = 9984,
  85751. /**
  85752. * Linear Mipmap Nearest
  85753. */
  85754. LINEAR_MIPMAP_NEAREST = 9985,
  85755. /**
  85756. * Nearest Mipmap Linear
  85757. */
  85758. NEAREST_MIPMAP_LINEAR = 9986,
  85759. /**
  85760. * Linear Mipmap Linear
  85761. */
  85762. LINEAR_MIPMAP_LINEAR = 9987,
  85763. }
  85764. /**
  85765. * S (U) wrapping mode. All valid values correspond to WebGL enums
  85766. */
  85767. const enum TextureWrapMode {
  85768. /**
  85769. * Clamp to Edge
  85770. */
  85771. CLAMP_TO_EDGE = 33071,
  85772. /**
  85773. * Mirrored Repeat
  85774. */
  85775. MIRRORED_REPEAT = 33648,
  85776. /**
  85777. * Repeat
  85778. */
  85779. REPEAT = 10497,
  85780. }
  85781. /**
  85782. * glTF Property
  85783. */
  85784. interface IProperty {
  85785. /**
  85786. * Dictionary object with extension-specific objects
  85787. */
  85788. extensions?: {
  85789. [key: string]: any;
  85790. };
  85791. /**
  85792. * Application-Specific data
  85793. */
  85794. extras?: any;
  85795. }
  85796. /**
  85797. * glTF Child of Root Property
  85798. */
  85799. interface IChildRootProperty extends IProperty {
  85800. /**
  85801. * The user-defined name of this object
  85802. */
  85803. name?: string;
  85804. }
  85805. /**
  85806. * Indices of those attributes that deviate from their initialization value
  85807. */
  85808. interface IAccessorSparseIndices extends IProperty {
  85809. /**
  85810. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  85811. */
  85812. bufferView: number;
  85813. /**
  85814. * The offset relative to the start of the bufferView in bytes. Must be aligned
  85815. */
  85816. byteOffset?: number;
  85817. /**
  85818. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  85819. */
  85820. componentType: AccessorComponentType;
  85821. }
  85822. /**
  85823. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  85824. */
  85825. interface IAccessorSparseValues extends IProperty {
  85826. /**
  85827. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  85828. */
  85829. bufferView: number;
  85830. /**
  85831. * The offset relative to the start of the bufferView in bytes. Must be aligned
  85832. */
  85833. byteOffset?: number;
  85834. }
  85835. /**
  85836. * Sparse storage of attributes that deviate from their initialization value
  85837. */
  85838. interface IAccessorSparse extends IProperty {
  85839. /**
  85840. * The number of attributes encoded in this sparse accessor
  85841. */
  85842. count: number;
  85843. /**
  85844. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  85845. */
  85846. indices: IAccessorSparseIndices;
  85847. /**
  85848. * 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
  85849. */
  85850. values: IAccessorSparseValues;
  85851. }
  85852. /**
  85853. * 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
  85854. */
  85855. interface IAccessor extends IChildRootProperty {
  85856. /**
  85857. * The index of the bufferview
  85858. */
  85859. bufferView?: number;
  85860. /**
  85861. * The offset relative to the start of the bufferView in bytes
  85862. */
  85863. byteOffset?: number;
  85864. /**
  85865. * The datatype of components in the attribute
  85866. */
  85867. componentType: AccessorComponentType;
  85868. /**
  85869. * Specifies whether integer data values should be normalized
  85870. */
  85871. normalized?: boolean;
  85872. /**
  85873. * The number of attributes referenced by this accessor
  85874. */
  85875. count: number;
  85876. /**
  85877. * Specifies if the attribute is a scalar, vector, or matrix
  85878. */
  85879. type: AccessorType;
  85880. /**
  85881. * Maximum value of each component in this attribute
  85882. */
  85883. max?: number[];
  85884. /**
  85885. * Minimum value of each component in this attribute
  85886. */
  85887. min?: number[];
  85888. /**
  85889. * Sparse storage of attributes that deviate from their initialization value
  85890. */
  85891. sparse?: IAccessorSparse;
  85892. }
  85893. /**
  85894. * Targets an animation's sampler at a node's property
  85895. */
  85896. interface IAnimationChannel extends IProperty {
  85897. /**
  85898. * The index of a sampler in this animation used to compute the value for the target
  85899. */
  85900. sampler: number;
  85901. /**
  85902. * The index of the node and TRS property to target
  85903. */
  85904. target: IAnimationChannelTarget;
  85905. }
  85906. /**
  85907. * The index of the node and TRS property that an animation channel targets
  85908. */
  85909. interface IAnimationChannelTarget extends IProperty {
  85910. /**
  85911. * The index of the node to target
  85912. */
  85913. node: number;
  85914. /**
  85915. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  85916. */
  85917. path: AnimationChannelTargetPath;
  85918. }
  85919. /**
  85920. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  85921. */
  85922. interface IAnimationSampler extends IProperty {
  85923. /**
  85924. * The index of an accessor containing keyframe input values, e.g., time
  85925. */
  85926. input: number;
  85927. /**
  85928. * Interpolation algorithm
  85929. */
  85930. interpolation?: AnimationSamplerInterpolation;
  85931. /**
  85932. * The index of an accessor, containing keyframe output values
  85933. */
  85934. output: number;
  85935. }
  85936. /**
  85937. * A keyframe animation
  85938. */
  85939. interface IAnimation extends IChildRootProperty {
  85940. /**
  85941. * An array of channels, each of which targets an animation's sampler at a node's property
  85942. */
  85943. channels: IAnimationChannel[];
  85944. /**
  85945. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  85946. */
  85947. samplers: IAnimationSampler[];
  85948. }
  85949. /**
  85950. * Metadata about the glTF asset
  85951. */
  85952. interface IAsset extends IChildRootProperty {
  85953. /**
  85954. * A copyright message suitable for display to credit the content creator
  85955. */
  85956. copyright?: string;
  85957. /**
  85958. * Tool that generated this glTF model. Useful for debugging
  85959. */
  85960. generator?: string;
  85961. /**
  85962. * The glTF version that this asset targets
  85963. */
  85964. version: string;
  85965. /**
  85966. * The minimum glTF version that this asset targets
  85967. */
  85968. minVersion?: string;
  85969. }
  85970. /**
  85971. * A buffer points to binary geometry, animation, or skins
  85972. */
  85973. interface IBuffer extends IChildRootProperty {
  85974. /**
  85975. * 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
  85976. */
  85977. uri?: string;
  85978. /**
  85979. * The length of the buffer in bytes
  85980. */
  85981. byteLength: number;
  85982. }
  85983. /**
  85984. * A view into a buffer generally representing a subset of the buffer
  85985. */
  85986. interface IBufferView extends IChildRootProperty {
  85987. /**
  85988. * The index of the buffer
  85989. */
  85990. buffer: number;
  85991. /**
  85992. * The offset into the buffer in bytes
  85993. */
  85994. byteOffset?: number;
  85995. /**
  85996. * The lenth of the bufferView in bytes
  85997. */
  85998. byteLength: number;
  85999. /**
  86000. * The stride, in bytes
  86001. */
  86002. byteStride?: number;
  86003. }
  86004. /**
  86005. * An orthographic camera containing properties to create an orthographic projection matrix
  86006. */
  86007. interface ICameraOrthographic extends IProperty {
  86008. /**
  86009. * The floating-point horizontal magnification of the view. Must not be zero
  86010. */
  86011. xmag: number;
  86012. /**
  86013. * The floating-point vertical magnification of the view. Must not be zero
  86014. */
  86015. ymag: number;
  86016. /**
  86017. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  86018. */
  86019. zfar: number;
  86020. /**
  86021. * The floating-point distance to the near clipping plane
  86022. */
  86023. znear: number;
  86024. }
  86025. /**
  86026. * A perspective camera containing properties to create a perspective projection matrix
  86027. */
  86028. interface ICameraPerspective extends IProperty {
  86029. /**
  86030. * The floating-point aspect ratio of the field of view
  86031. */
  86032. aspectRatio?: number;
  86033. /**
  86034. * The floating-point vertical field of view in radians
  86035. */
  86036. yfov: number;
  86037. /**
  86038. * The floating-point distance to the far clipping plane
  86039. */
  86040. zfar?: number;
  86041. /**
  86042. * The floating-point distance to the near clipping plane
  86043. */
  86044. znear: number;
  86045. }
  86046. /**
  86047. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  86048. */
  86049. interface ICamera extends IChildRootProperty {
  86050. /**
  86051. * An orthographic camera containing properties to create an orthographic projection matrix
  86052. */
  86053. orthographic?: ICameraOrthographic;
  86054. /**
  86055. * A perspective camera containing properties to create a perspective projection matrix
  86056. */
  86057. perspective?: ICameraPerspective;
  86058. /**
  86059. * Specifies if the camera uses a perspective or orthographic projection
  86060. */
  86061. type: CameraType;
  86062. }
  86063. /**
  86064. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  86065. */
  86066. interface IImage extends IChildRootProperty {
  86067. /**
  86068. * 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
  86069. */
  86070. uri?: string;
  86071. /**
  86072. * The image's MIME type
  86073. */
  86074. mimeType?: ImageMimeType;
  86075. /**
  86076. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  86077. */
  86078. bufferView?: number;
  86079. }
  86080. /**
  86081. * Material Normal Texture Info
  86082. */
  86083. interface IMaterialNormalTextureInfo extends ITextureInfo {
  86084. /**
  86085. * The scalar multiplier applied to each normal vector of the normal texture
  86086. */
  86087. scale?: number;
  86088. }
  86089. /**
  86090. * Material Occlusion Texture Info
  86091. */
  86092. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  86093. /**
  86094. * A scalar multiplier controlling the amount of occlusion applied
  86095. */
  86096. strength?: number;
  86097. }
  86098. /**
  86099. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  86100. */
  86101. interface IMaterialPbrMetallicRoughness {
  86102. /**
  86103. * The material's base color factor
  86104. */
  86105. baseColorFactor?: number[];
  86106. /**
  86107. * The base color texture
  86108. */
  86109. baseColorTexture?: ITextureInfo;
  86110. /**
  86111. * The metalness of the material
  86112. */
  86113. metallicFactor?: number;
  86114. /**
  86115. * The roughness of the material
  86116. */
  86117. roughnessFactor?: number;
  86118. /**
  86119. * The metallic-roughness texture
  86120. */
  86121. metallicRoughnessTexture?: ITextureInfo;
  86122. }
  86123. /**
  86124. * The material appearance of a primitive
  86125. */
  86126. interface IMaterial extends IChildRootProperty {
  86127. /**
  86128. * 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
  86129. */
  86130. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  86131. /**
  86132. * The normal map texture
  86133. */
  86134. normalTexture?: IMaterialNormalTextureInfo;
  86135. /**
  86136. * The occlusion map texture
  86137. */
  86138. occlusionTexture?: IMaterialOcclusionTextureInfo;
  86139. /**
  86140. * The emissive map texture
  86141. */
  86142. emissiveTexture?: ITextureInfo;
  86143. /**
  86144. * 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
  86145. */
  86146. emissiveFactor?: number[];
  86147. /**
  86148. * The alpha rendering mode of the material
  86149. */
  86150. alphaMode?: MaterialAlphaMode;
  86151. /**
  86152. * The alpha cutoff value of the material
  86153. */
  86154. alphaCutoff?: number;
  86155. /**
  86156. * Specifies whether the material is double sided
  86157. */
  86158. doubleSided?: boolean;
  86159. }
  86160. /**
  86161. * Geometry to be rendered with the given material
  86162. */
  86163. interface IMeshPrimitive extends IProperty {
  86164. /**
  86165. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  86166. */
  86167. attributes: {
  86168. [name: string]: number;
  86169. };
  86170. /**
  86171. * The index of the accessor that contains the indices
  86172. */
  86173. indices?: number;
  86174. /**
  86175. * The index of the material to apply to this primitive when rendering
  86176. */
  86177. material?: number;
  86178. /**
  86179. * The type of primitives to render. All valid values correspond to WebGL enums
  86180. */
  86181. mode?: MeshPrimitiveMode;
  86182. /**
  86183. * 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
  86184. */
  86185. targets?: {
  86186. [name: string]: number;
  86187. }[];
  86188. }
  86189. /**
  86190. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  86191. */
  86192. interface IMesh extends IChildRootProperty {
  86193. /**
  86194. * An array of primitives, each defining geometry to be rendered with a material
  86195. */
  86196. primitives: IMeshPrimitive[];
  86197. /**
  86198. * Array of weights to be applied to the Morph Targets
  86199. */
  86200. weights?: number[];
  86201. }
  86202. /**
  86203. * A node in the node hierarchy
  86204. */
  86205. interface INode extends IChildRootProperty {
  86206. /**
  86207. * The index of the camera referenced by this node
  86208. */
  86209. camera?: number;
  86210. /**
  86211. * The indices of this node's children
  86212. */
  86213. children?: number[];
  86214. /**
  86215. * The index of the skin referenced by this node
  86216. */
  86217. skin?: number;
  86218. /**
  86219. * A floating-point 4x4 transformation matrix stored in column-major order
  86220. */
  86221. matrix?: number[];
  86222. /**
  86223. * The index of the mesh in this node
  86224. */
  86225. mesh?: number;
  86226. /**
  86227. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  86228. */
  86229. rotation?: number[];
  86230. /**
  86231. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  86232. */
  86233. scale?: number[];
  86234. /**
  86235. * The node's translation along the x, y, and z axes
  86236. */
  86237. translation?: number[];
  86238. /**
  86239. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  86240. */
  86241. weights?: number[];
  86242. }
  86243. /**
  86244. * Texture sampler properties for filtering and wrapping modes
  86245. */
  86246. interface ISampler extends IChildRootProperty {
  86247. /**
  86248. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  86249. */
  86250. magFilter?: TextureMagFilter;
  86251. /**
  86252. * Minification filter. All valid values correspond to WebGL enums
  86253. */
  86254. minFilter?: TextureMinFilter;
  86255. /**
  86256. * S (U) wrapping mode. All valid values correspond to WebGL enums
  86257. */
  86258. wrapS?: TextureWrapMode;
  86259. /**
  86260. * T (V) wrapping mode. All valid values correspond to WebGL enums
  86261. */
  86262. wrapT?: TextureWrapMode;
  86263. }
  86264. /**
  86265. * The root nodes of a scene
  86266. */
  86267. interface IScene extends IChildRootProperty {
  86268. /**
  86269. * The indices of each root node
  86270. */
  86271. nodes: number[];
  86272. }
  86273. /**
  86274. * Joints and matrices defining a skin
  86275. */
  86276. interface ISkin extends IChildRootProperty {
  86277. /**
  86278. * 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
  86279. */
  86280. inverseBindMatrices?: number;
  86281. /**
  86282. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  86283. */
  86284. skeleton?: number;
  86285. /**
  86286. * 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)
  86287. */
  86288. joints: number[];
  86289. }
  86290. /**
  86291. * A texture and its sampler
  86292. */
  86293. interface ITexture extends IChildRootProperty {
  86294. /**
  86295. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  86296. */
  86297. sampler?: number;
  86298. /**
  86299. * The index of the image used by this texture
  86300. */
  86301. source: number;
  86302. }
  86303. /**
  86304. * Reference to a texture
  86305. */
  86306. interface ITextureInfo extends IProperty {
  86307. /**
  86308. * The index of the texture
  86309. */
  86310. index: number;
  86311. /**
  86312. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  86313. */
  86314. texCoord?: number;
  86315. }
  86316. /**
  86317. * The root object for a glTF asset
  86318. */
  86319. interface IGLTF extends IProperty {
  86320. /**
  86321. * An array of accessors. An accessor is a typed view into a bufferView
  86322. */
  86323. accessors?: IAccessor[];
  86324. /**
  86325. * An array of keyframe animations
  86326. */
  86327. animations?: IAnimation[];
  86328. /**
  86329. * Metadata about the glTF asset
  86330. */
  86331. asset: IAsset;
  86332. /**
  86333. * An array of buffers. A buffer points to binary geometry, animation, or skins
  86334. */
  86335. buffers?: IBuffer[];
  86336. /**
  86337. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  86338. */
  86339. bufferViews?: IBufferView[];
  86340. /**
  86341. * An array of cameras
  86342. */
  86343. cameras?: ICamera[];
  86344. /**
  86345. * Names of glTF extensions used somewhere in this asset
  86346. */
  86347. extensionsUsed?: string[];
  86348. /**
  86349. * Names of glTF extensions required to properly load this asset
  86350. */
  86351. extensionsRequired?: string[];
  86352. /**
  86353. * An array of images. An image defines data used to create a texture
  86354. */
  86355. images?: IImage[];
  86356. /**
  86357. * An array of materials. A material defines the appearance of a primitive
  86358. */
  86359. materials?: IMaterial[];
  86360. /**
  86361. * An array of meshes. A mesh is a set of primitives to be rendered
  86362. */
  86363. meshes?: IMesh[];
  86364. /**
  86365. * An array of nodes
  86366. */
  86367. nodes?: INode[];
  86368. /**
  86369. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  86370. */
  86371. samplers?: ISampler[];
  86372. /**
  86373. * The index of the default scene
  86374. */
  86375. scene?: number;
  86376. /**
  86377. * An array of scenes
  86378. */
  86379. scenes?: IScene[];
  86380. /**
  86381. * An array of skins. A skin is defined by joints and matrices
  86382. */
  86383. skins?: ISkin[];
  86384. /**
  86385. * An array of textures
  86386. */
  86387. textures?: ITexture[];
  86388. }
  86389. /**
  86390. * The glTF validation results
  86391. * @ignore
  86392. */
  86393. interface IGLTFValidationResults {
  86394. info: {
  86395. generator: string;
  86396. hasAnimations: boolean;
  86397. hasDefaultScene: boolean;
  86398. hasMaterials: boolean;
  86399. hasMorphTargets: boolean;
  86400. hasSkins: boolean;
  86401. hasTextures: boolean;
  86402. maxAttributesUsed: number;
  86403. primitivesCount: number
  86404. };
  86405. issues: {
  86406. messages: Array<string>;
  86407. numErrors: number;
  86408. numHints: number;
  86409. numInfos: number;
  86410. numWarnings: number;
  86411. truncated: boolean
  86412. };
  86413. mimeType: string;
  86414. uri: string;
  86415. validatedAt: string;
  86416. validatorVersion: string;
  86417. }
  86418. /**
  86419. * The glTF validation options
  86420. */
  86421. interface IGLTFValidationOptions {
  86422. /** Uri to use */
  86423. uri?: string;
  86424. /** Function used to load external resources */
  86425. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  86426. /** Boolean indicating that we need to validate accessor data */
  86427. validateAccessorData?: boolean;
  86428. /** max number of issues allowed */
  86429. maxIssues?: number;
  86430. /** Ignored issues */
  86431. ignoredIssues?: Array<string>;
  86432. /** Value to override severy settings */
  86433. severityOverrides?: Object;
  86434. }
  86435. /**
  86436. * The glTF validator object
  86437. * @ignore
  86438. */
  86439. interface IGLTFValidator {
  86440. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  86441. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  86442. }
  86443. /**
  86444. * Interfaces from the EXT_lights_image_based extension
  86445. */
  86446. /** @hidden */
  86447. interface IEXTLightsImageBased_LightReferenceImageBased {
  86448. light: number;
  86449. }
  86450. /** @hidden */
  86451. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  86452. intensity: number;
  86453. rotation: number[];
  86454. specularImageSize: number;
  86455. specularImages: number[][];
  86456. irradianceCoefficients: number[][];
  86457. }
  86458. /** @hidden */
  86459. interface IEXTLightsImageBased {
  86460. lights: IEXTLightsImageBased_LightImageBased[];
  86461. }
  86462. /**
  86463. * Interfaces from the EXT_mesh_gpu_instancing extension
  86464. * !!! Experimental Extension Subject to Changes !!!
  86465. */
  86466. /** @hidden */
  86467. interface IEXTMeshGpuInstancing {
  86468. mesh?: number;
  86469. attributes: { [name: string]: number };
  86470. }
  86471. /**
  86472. * Interfaces from the KHR_draco_mesh_compression extension
  86473. */
  86474. /** @hidden */
  86475. interface IKHRDracoMeshCompression {
  86476. bufferView: number;
  86477. attributes: { [name: string]: number };
  86478. }
  86479. /**
  86480. * Interfaces from the KHR_lights_punctual extension
  86481. */
  86482. /** @hidden */
  86483. const enum IKHRLightsPunctual_LightType {
  86484. DIRECTIONAL = "directional",
  86485. POINT = "point",
  86486. SPOT = "spot"
  86487. }
  86488. /** @hidden */
  86489. interface IKHRLightsPunctual_LightReference {
  86490. light: number;
  86491. }
  86492. /** @hidden */
  86493. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  86494. type: IKHRLightsPunctual_LightType;
  86495. color?: number[];
  86496. intensity?: number;
  86497. range?: number;
  86498. spot?: {
  86499. innerConeAngle?: number;
  86500. outerConeAngle?: number;
  86501. };
  86502. }
  86503. /** @hidden */
  86504. interface IKHRLightsPunctual {
  86505. lights: IKHRLightsPunctual_Light[];
  86506. }
  86507. /**
  86508. * Interfaces from the KHR_materials_clearcoat extension
  86509. * !!! Experimental Extension Subject to Changes !!!
  86510. */
  86511. /** @hidden */
  86512. interface IKHRMaterialsClearcoat {
  86513. clearcoatFactor: number;
  86514. clearcoatTexture: ITextureInfo;
  86515. clearcoatRoughnessFactor: number;
  86516. clearcoatRoughnessTexture: ITextureInfo;
  86517. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  86518. }
  86519. /**
  86520. * Interfaces from the KHR_materials_ior extension
  86521. * !!! Experimental Extension Subject to Changes !!!
  86522. */
  86523. /** @hidden */
  86524. interface IKHRMaterialsIor {
  86525. ior: number;
  86526. }
  86527. /**
  86528. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  86529. */
  86530. /** @hidden */
  86531. interface IKHRMaterialsPbrSpecularGlossiness {
  86532. diffuseFactor: number[];
  86533. diffuseTexture: ITextureInfo;
  86534. specularFactor: number[];
  86535. glossinessFactor: number;
  86536. specularGlossinessTexture: ITextureInfo;
  86537. }
  86538. /**
  86539. * Interfaces from the KHR_materials_sheen extension
  86540. * !!! Experimental Extension Subject to Changes !!!
  86541. */
  86542. /** @hidden */
  86543. interface IKHRMaterialsSheen {
  86544. sheenColorFactor?: number[];
  86545. sheenColorTexture?: ITextureInfo;
  86546. sheenRoughnessFactor?: number;
  86547. sheenRoughnessTexture?: ITextureInfo;
  86548. }
  86549. /**
  86550. * Interfaces from the KHR_materials_specular extension
  86551. * !!! Experimental Extension Subject to Changes !!!
  86552. */
  86553. /** @hidden */
  86554. interface IKHRMaterialsSpecular {
  86555. specularFactor: number;
  86556. specularColorFactor: number[];
  86557. specularTexture: ITextureInfo;
  86558. }
  86559. /**
  86560. * Interfaces from the KHR_materials_transmission extension
  86561. * !!! Experimental Extension Subject to Changes !!!
  86562. */
  86563. /** @hidden */
  86564. interface IKHRMaterialsTransmission {
  86565. transmissionFactor?: number;
  86566. transmissionTexture?: ITextureInfo;
  86567. }
  86568. /**
  86569. * Interfaces from the KHR_materials_variants extension
  86570. * !!! Experimental Extension Subject to Changes !!!
  86571. */
  86572. /** @hidden */
  86573. interface IKHRMaterialVariants_Mapping extends IProperty {
  86574. mappings: Array<{
  86575. variants: number[];
  86576. material: number;
  86577. }>;
  86578. }
  86579. /** @hidden */
  86580. interface IKHRMaterialVariants_Variant extends IProperty {
  86581. name: string;
  86582. }
  86583. /** @hidden */
  86584. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  86585. variants: Array<IKHRMaterialVariants_Variant>;
  86586. }
  86587. /**
  86588. * Interfaces from the KHR_texture_basisu extension
  86589. * !!! Experimental Extension Subject to Changes !!!
  86590. */
  86591. /** @hidden */
  86592. interface IKHRTextureBasisU {
  86593. source: number;
  86594. }
  86595. /**
  86596. * Interfaces from the EXT_texture_webp extension
  86597. */
  86598. /** @hidden */
  86599. interface IEXTTextureWebP {
  86600. source: number;
  86601. }
  86602. /**
  86603. * Interfaces from the KHR_texture_transform extension
  86604. */
  86605. /** @hidden */
  86606. interface IKHRTextureTransform {
  86607. offset?: number[];
  86608. rotation?: number;
  86609. scale?: number[];
  86610. texCoord?: number;
  86611. }
  86612. /**
  86613. * Interfaces from the KHR_xmp extension
  86614. * !!! Experimental Extension Subject to Changes !!!
  86615. */
  86616. /** @hidden */
  86617. interface IKHRXmp_Data {
  86618. [key: string]: unknown;
  86619. }
  86620. /** @hidden */
  86621. interface IKHRXmp_Gltf {
  86622. packets: IKHRXmp_Data[];
  86623. }
  86624. /** @hidden */
  86625. interface IKHRXmp_Node {
  86626. packet: number;
  86627. }
  86628. /**
  86629. * Interfaces from the MSFT_audio_emitter extension
  86630. */
  86631. /** @hidden */
  86632. interface IMSFTAudioEmitter_ClipReference {
  86633. clip: number;
  86634. weight?: number;
  86635. }
  86636. /** @hidden */
  86637. interface IMSFTAudioEmitter_EmittersReference {
  86638. emitters: number[];
  86639. }
  86640. /** @hidden */
  86641. const enum IMSFTAudioEmitter_DistanceModel {
  86642. linear = "linear",
  86643. inverse = "inverse",
  86644. exponential = "exponential",
  86645. }
  86646. /** @hidden */
  86647. interface IMSFTAudioEmitter_Emitter {
  86648. name?: string;
  86649. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  86650. refDistance?: number;
  86651. maxDistance?: number;
  86652. rolloffFactor?: number;
  86653. innerAngle?: number;
  86654. outerAngle?: number;
  86655. loop?: boolean;
  86656. volume?: number;
  86657. clips: IMSFTAudioEmitter_ClipReference[];
  86658. }
  86659. /** @hidden */
  86660. const enum IMSFTAudioEmitter_AudioMimeType {
  86661. WAV = "audio/wav",
  86662. }
  86663. /** @hidden */
  86664. interface IMSFTAudioEmitter_Clip extends IProperty {
  86665. uri?: string;
  86666. bufferView?: number;
  86667. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  86668. }
  86669. /** @hidden */
  86670. const enum IMSFTAudioEmitter_AnimationEventAction {
  86671. play = "play",
  86672. pause = "pause",
  86673. stop = "stop",
  86674. }
  86675. /** @hidden */
  86676. interface IMSFTAudioEmitter_AnimationEvent {
  86677. action: IMSFTAudioEmitter_AnimationEventAction;
  86678. emitter: number;
  86679. time: number;
  86680. startOffset?: number;
  86681. }
  86682. /**
  86683. * Interfaces from the MSFT_lod extension
  86684. */
  86685. /** @hidden */
  86686. interface IMSFTLOD {
  86687. ids: number[];
  86688. }
  86689. }
  86690. declare module BABYLON {
  86691. /** @hidden */
  86692. export var cellPixelShader: {
  86693. name: string;
  86694. shader: string;
  86695. };
  86696. }
  86697. declare module BABYLON {
  86698. /** @hidden */
  86699. export var cellVertexShader: {
  86700. name: string;
  86701. shader: string;
  86702. };
  86703. }
  86704. declare module BABYLON {
  86705. export class CellMaterial extends BABYLON.PushMaterial {
  86706. private _diffuseTexture;
  86707. diffuseTexture: BABYLON.BaseTexture;
  86708. diffuseColor: BABYLON.Color3;
  86709. _computeHighLevel: boolean;
  86710. computeHighLevel: boolean;
  86711. private _disableLighting;
  86712. disableLighting: boolean;
  86713. private _maxSimultaneousLights;
  86714. maxSimultaneousLights: number;
  86715. constructor(name: string, scene: BABYLON.Scene);
  86716. needAlphaBlending(): boolean;
  86717. needAlphaTesting(): boolean;
  86718. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86719. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86720. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86721. getAnimatables(): BABYLON.IAnimatable[];
  86722. getActiveTextures(): BABYLON.BaseTexture[];
  86723. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86724. dispose(forceDisposeEffect?: boolean): void;
  86725. getClassName(): string;
  86726. clone(name: string): CellMaterial;
  86727. serialize(): any;
  86728. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  86729. }
  86730. }
  86731. declare module BABYLON {
  86732. export class CustomShaderStructure {
  86733. FragmentStore: string;
  86734. VertexStore: string;
  86735. constructor();
  86736. }
  86737. export class ShaderSpecialParts {
  86738. constructor();
  86739. Fragment_Begin: string;
  86740. Fragment_Definitions: string;
  86741. Fragment_MainBegin: string;
  86742. Fragment_Custom_Diffuse: string;
  86743. Fragment_Before_Lights: string;
  86744. Fragment_Before_Fog: string;
  86745. Fragment_Custom_Alpha: string;
  86746. Fragment_Before_FragColor: string;
  86747. Vertex_Begin: string;
  86748. Vertex_Definitions: string;
  86749. Vertex_MainBegin: string;
  86750. Vertex_Before_PositionUpdated: string;
  86751. Vertex_Before_NormalUpdated: string;
  86752. Vertex_After_WorldPosComputed: string;
  86753. Vertex_MainEnd: string;
  86754. }
  86755. export class CustomMaterial extends BABYLON.StandardMaterial {
  86756. static ShaderIndexer: number;
  86757. CustomParts: ShaderSpecialParts;
  86758. _isCreatedShader: boolean;
  86759. _createdShaderName: string;
  86760. _customUniform: string[];
  86761. _newUniforms: string[];
  86762. _newUniformInstances: {
  86763. [name: string]: any;
  86764. };
  86765. _newSamplerInstances: {
  86766. [name: string]: BABYLON.Texture;
  86767. };
  86768. _customAttributes: string[];
  86769. FragmentShader: string;
  86770. VertexShader: string;
  86771. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  86772. ReviewUniform(name: string, arr: string[]): string[];
  86773. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  86774. constructor(name: string, scene: BABYLON.Scene);
  86775. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  86776. AddAttribute(name: string): CustomMaterial;
  86777. Fragment_Begin(shaderPart: string): CustomMaterial;
  86778. Fragment_Definitions(shaderPart: string): CustomMaterial;
  86779. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  86780. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  86781. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  86782. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  86783. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  86784. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  86785. Vertex_Begin(shaderPart: string): CustomMaterial;
  86786. Vertex_Definitions(shaderPart: string): CustomMaterial;
  86787. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  86788. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  86789. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  86790. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  86791. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  86792. }
  86793. }
  86794. declare module BABYLON {
  86795. export class ShaderAlebdoParts {
  86796. constructor();
  86797. Fragment_Begin: string;
  86798. Fragment_Definitions: string;
  86799. Fragment_MainBegin: string;
  86800. Fragment_Custom_Albedo: string;
  86801. Fragment_Before_Lights: string;
  86802. Fragment_Custom_MetallicRoughness: string;
  86803. Fragment_Custom_MicroSurface: string;
  86804. Fragment_Before_Fog: string;
  86805. Fragment_Custom_Alpha: string;
  86806. Fragment_Before_FragColor: string;
  86807. Vertex_Begin: string;
  86808. Vertex_Definitions: string;
  86809. Vertex_MainBegin: string;
  86810. Vertex_Before_PositionUpdated: string;
  86811. Vertex_Before_NormalUpdated: string;
  86812. Vertex_After_WorldPosComputed: string;
  86813. Vertex_MainEnd: string;
  86814. }
  86815. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  86816. static ShaderIndexer: number;
  86817. CustomParts: ShaderAlebdoParts;
  86818. _isCreatedShader: boolean;
  86819. _createdShaderName: string;
  86820. _customUniform: string[];
  86821. _newUniforms: string[];
  86822. _newUniformInstances: {
  86823. [name: string]: any;
  86824. };
  86825. _newSamplerInstances: {
  86826. [name: string]: BABYLON.Texture;
  86827. };
  86828. _customAttributes: string[];
  86829. FragmentShader: string;
  86830. VertexShader: string;
  86831. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  86832. ReviewUniform(name: string, arr: string[]): string[];
  86833. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  86834. constructor(name: string, scene: BABYLON.Scene);
  86835. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  86836. AddAttribute(name: string): PBRCustomMaterial;
  86837. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  86838. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  86839. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  86840. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  86841. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  86842. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  86843. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  86844. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  86845. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  86846. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  86847. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  86848. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  86849. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  86850. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  86851. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  86852. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  86853. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  86854. }
  86855. }
  86856. declare module BABYLON {
  86857. /** @hidden */
  86858. export var firePixelShader: {
  86859. name: string;
  86860. shader: string;
  86861. };
  86862. }
  86863. declare module BABYLON {
  86864. /** @hidden */
  86865. export var fireVertexShader: {
  86866. name: string;
  86867. shader: string;
  86868. };
  86869. }
  86870. declare module BABYLON {
  86871. export class FireMaterial extends BABYLON.PushMaterial {
  86872. private _diffuseTexture;
  86873. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86874. private _distortionTexture;
  86875. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86876. private _opacityTexture;
  86877. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86878. diffuseColor: BABYLON.Color3;
  86879. speed: number;
  86880. private _scaledDiffuse;
  86881. private _lastTime;
  86882. constructor(name: string, scene: BABYLON.Scene);
  86883. needAlphaBlending(): boolean;
  86884. needAlphaTesting(): boolean;
  86885. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86886. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86887. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86888. getAnimatables(): BABYLON.IAnimatable[];
  86889. getActiveTextures(): BABYLON.BaseTexture[];
  86890. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86891. getClassName(): string;
  86892. dispose(forceDisposeEffect?: boolean): void;
  86893. clone(name: string): FireMaterial;
  86894. serialize(): any;
  86895. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  86896. }
  86897. }
  86898. declare module BABYLON {
  86899. /** @hidden */
  86900. export var furPixelShader: {
  86901. name: string;
  86902. shader: string;
  86903. };
  86904. }
  86905. declare module BABYLON {
  86906. /** @hidden */
  86907. export var furVertexShader: {
  86908. name: string;
  86909. shader: string;
  86910. };
  86911. }
  86912. declare module BABYLON {
  86913. export class FurMaterial extends BABYLON.PushMaterial {
  86914. private _diffuseTexture;
  86915. diffuseTexture: BABYLON.BaseTexture;
  86916. private _heightTexture;
  86917. heightTexture: BABYLON.BaseTexture;
  86918. diffuseColor: BABYLON.Color3;
  86919. furLength: number;
  86920. furAngle: number;
  86921. furColor: BABYLON.Color3;
  86922. furOffset: number;
  86923. furSpacing: number;
  86924. furGravity: BABYLON.Vector3;
  86925. furSpeed: number;
  86926. furDensity: number;
  86927. furOcclusion: number;
  86928. furTexture: BABYLON.DynamicTexture;
  86929. private _disableLighting;
  86930. disableLighting: boolean;
  86931. private _maxSimultaneousLights;
  86932. maxSimultaneousLights: number;
  86933. highLevelFur: boolean;
  86934. _meshes: BABYLON.AbstractMesh[];
  86935. private _furTime;
  86936. constructor(name: string, scene: BABYLON.Scene);
  86937. get furTime(): number;
  86938. set furTime(furTime: number);
  86939. needAlphaBlending(): boolean;
  86940. needAlphaTesting(): boolean;
  86941. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86942. updateFur(): void;
  86943. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86944. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86945. getAnimatables(): BABYLON.IAnimatable[];
  86946. getActiveTextures(): BABYLON.BaseTexture[];
  86947. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86948. dispose(forceDisposeEffect?: boolean): void;
  86949. clone(name: string): FurMaterial;
  86950. serialize(): any;
  86951. getClassName(): string;
  86952. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  86953. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  86954. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  86955. }
  86956. }
  86957. declare module BABYLON {
  86958. /** @hidden */
  86959. export var gradientPixelShader: {
  86960. name: string;
  86961. shader: string;
  86962. };
  86963. }
  86964. declare module BABYLON {
  86965. /** @hidden */
  86966. export var gradientVertexShader: {
  86967. name: string;
  86968. shader: string;
  86969. };
  86970. }
  86971. declare module BABYLON {
  86972. export class GradientMaterial extends BABYLON.PushMaterial {
  86973. private _maxSimultaneousLights;
  86974. maxSimultaneousLights: number;
  86975. topColor: BABYLON.Color3;
  86976. topColorAlpha: number;
  86977. bottomColor: BABYLON.Color3;
  86978. bottomColorAlpha: number;
  86979. offset: number;
  86980. scale: number;
  86981. smoothness: number;
  86982. private _disableLighting;
  86983. disableLighting: boolean;
  86984. constructor(name: string, scene: BABYLON.Scene);
  86985. needAlphaBlending(): boolean;
  86986. needAlphaTesting(): boolean;
  86987. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86988. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86989. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86990. getAnimatables(): BABYLON.IAnimatable[];
  86991. dispose(forceDisposeEffect?: boolean): void;
  86992. clone(name: string): GradientMaterial;
  86993. serialize(): any;
  86994. getClassName(): string;
  86995. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  86996. }
  86997. }
  86998. declare module BABYLON {
  86999. /** @hidden */
  87000. export var gridPixelShader: {
  87001. name: string;
  87002. shader: string;
  87003. };
  87004. }
  87005. declare module BABYLON {
  87006. /** @hidden */
  87007. export var gridVertexShader: {
  87008. name: string;
  87009. shader: string;
  87010. };
  87011. }
  87012. declare module BABYLON {
  87013. /**
  87014. * The grid materials allows you to wrap any shape with a grid.
  87015. * Colors are customizable.
  87016. */
  87017. export class GridMaterial extends BABYLON.PushMaterial {
  87018. /**
  87019. * Main color of the grid (e.g. between lines)
  87020. */
  87021. mainColor: BABYLON.Color3;
  87022. /**
  87023. * Color of the grid lines.
  87024. */
  87025. lineColor: BABYLON.Color3;
  87026. /**
  87027. * The scale of the grid compared to unit.
  87028. */
  87029. gridRatio: number;
  87030. /**
  87031. * Allows setting an offset for the grid lines.
  87032. */
  87033. gridOffset: BABYLON.Vector3;
  87034. /**
  87035. * The frequency of thicker lines.
  87036. */
  87037. majorUnitFrequency: number;
  87038. /**
  87039. * The visibility of minor units in the grid.
  87040. */
  87041. minorUnitVisibility: number;
  87042. /**
  87043. * The grid opacity outside of the lines.
  87044. */
  87045. opacity: number;
  87046. /**
  87047. * Determine RBG output is premultiplied by alpha value.
  87048. */
  87049. preMultiplyAlpha: boolean;
  87050. private _opacityTexture;
  87051. opacityTexture: BABYLON.BaseTexture;
  87052. private _gridControl;
  87053. /**
  87054. * constructor
  87055. * @param name The name given to the material in order to identify it afterwards.
  87056. * @param scene The scene the material is used in.
  87057. */
  87058. constructor(name: string, scene: BABYLON.Scene);
  87059. /**
  87060. * Returns wehter or not the grid requires alpha blending.
  87061. */
  87062. needAlphaBlending(): boolean;
  87063. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  87064. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87065. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87066. /**
  87067. * Dispose the material and its associated resources.
  87068. * @param forceDisposeEffect will also dispose the used effect when true
  87069. */
  87070. dispose(forceDisposeEffect?: boolean): void;
  87071. clone(name: string): GridMaterial;
  87072. serialize(): any;
  87073. getClassName(): string;
  87074. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  87075. }
  87076. }
  87077. declare module BABYLON {
  87078. /** @hidden */
  87079. export var lavaPixelShader: {
  87080. name: string;
  87081. shader: string;
  87082. };
  87083. }
  87084. declare module BABYLON {
  87085. /** @hidden */
  87086. export var lavaVertexShader: {
  87087. name: string;
  87088. shader: string;
  87089. };
  87090. }
  87091. declare module BABYLON {
  87092. export class LavaMaterial extends BABYLON.PushMaterial {
  87093. private _diffuseTexture;
  87094. diffuseTexture: BABYLON.BaseTexture;
  87095. noiseTexture: BABYLON.BaseTexture;
  87096. fogColor: BABYLON.Color3;
  87097. speed: number;
  87098. movingSpeed: number;
  87099. lowFrequencySpeed: number;
  87100. fogDensity: number;
  87101. private _lastTime;
  87102. diffuseColor: BABYLON.Color3;
  87103. private _disableLighting;
  87104. disableLighting: boolean;
  87105. private _unlit;
  87106. unlit: boolean;
  87107. private _maxSimultaneousLights;
  87108. maxSimultaneousLights: number;
  87109. private _scaledDiffuse;
  87110. constructor(name: string, scene: BABYLON.Scene);
  87111. needAlphaBlending(): boolean;
  87112. needAlphaTesting(): boolean;
  87113. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87114. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87115. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87116. getAnimatables(): BABYLON.IAnimatable[];
  87117. getActiveTextures(): BABYLON.BaseTexture[];
  87118. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87119. dispose(forceDisposeEffect?: boolean): void;
  87120. clone(name: string): LavaMaterial;
  87121. serialize(): any;
  87122. getClassName(): string;
  87123. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  87124. }
  87125. }
  87126. declare module BABYLON {
  87127. /** @hidden */
  87128. export var mixPixelShader: {
  87129. name: string;
  87130. shader: string;
  87131. };
  87132. }
  87133. declare module BABYLON {
  87134. /** @hidden */
  87135. export var mixVertexShader: {
  87136. name: string;
  87137. shader: string;
  87138. };
  87139. }
  87140. declare module BABYLON {
  87141. export class MixMaterial extends BABYLON.PushMaterial {
  87142. /**
  87143. * Mix textures
  87144. */
  87145. private _mixTexture1;
  87146. mixTexture1: BABYLON.BaseTexture;
  87147. private _mixTexture2;
  87148. mixTexture2: BABYLON.BaseTexture;
  87149. /**
  87150. * Diffuse textures
  87151. */
  87152. private _diffuseTexture1;
  87153. diffuseTexture1: BABYLON.Texture;
  87154. private _diffuseTexture2;
  87155. diffuseTexture2: BABYLON.Texture;
  87156. private _diffuseTexture3;
  87157. diffuseTexture3: BABYLON.Texture;
  87158. private _diffuseTexture4;
  87159. diffuseTexture4: BABYLON.Texture;
  87160. private _diffuseTexture5;
  87161. diffuseTexture5: BABYLON.Texture;
  87162. private _diffuseTexture6;
  87163. diffuseTexture6: BABYLON.Texture;
  87164. private _diffuseTexture7;
  87165. diffuseTexture7: BABYLON.Texture;
  87166. private _diffuseTexture8;
  87167. diffuseTexture8: BABYLON.Texture;
  87168. /**
  87169. * Uniforms
  87170. */
  87171. diffuseColor: BABYLON.Color3;
  87172. specularColor: BABYLON.Color3;
  87173. specularPower: number;
  87174. private _disableLighting;
  87175. disableLighting: boolean;
  87176. private _maxSimultaneousLights;
  87177. maxSimultaneousLights: number;
  87178. constructor(name: string, scene: BABYLON.Scene);
  87179. needAlphaBlending(): boolean;
  87180. needAlphaTesting(): boolean;
  87181. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87182. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87183. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87184. getAnimatables(): BABYLON.IAnimatable[];
  87185. getActiveTextures(): BABYLON.BaseTexture[];
  87186. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87187. dispose(forceDisposeEffect?: boolean): void;
  87188. clone(name: string): MixMaterial;
  87189. serialize(): any;
  87190. getClassName(): string;
  87191. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  87192. }
  87193. }
  87194. declare module BABYLON {
  87195. /** @hidden */
  87196. export var normalPixelShader: {
  87197. name: string;
  87198. shader: string;
  87199. };
  87200. }
  87201. declare module BABYLON {
  87202. /** @hidden */
  87203. export var normalVertexShader: {
  87204. name: string;
  87205. shader: string;
  87206. };
  87207. }
  87208. declare module BABYLON {
  87209. export class NormalMaterial extends BABYLON.PushMaterial {
  87210. private _diffuseTexture;
  87211. diffuseTexture: BABYLON.BaseTexture;
  87212. diffuseColor: BABYLON.Color3;
  87213. private _disableLighting;
  87214. disableLighting: boolean;
  87215. private _maxSimultaneousLights;
  87216. maxSimultaneousLights: number;
  87217. constructor(name: string, scene: BABYLON.Scene);
  87218. needAlphaBlending(): boolean;
  87219. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  87220. needAlphaTesting(): boolean;
  87221. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87222. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87223. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87224. getAnimatables(): BABYLON.IAnimatable[];
  87225. getActiveTextures(): BABYLON.BaseTexture[];
  87226. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87227. dispose(forceDisposeEffect?: boolean): void;
  87228. clone(name: string): NormalMaterial;
  87229. serialize(): any;
  87230. getClassName(): string;
  87231. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  87232. }
  87233. }
  87234. declare module BABYLON {
  87235. /** @hidden */
  87236. export var shadowOnlyPixelShader: {
  87237. name: string;
  87238. shader: string;
  87239. };
  87240. }
  87241. declare module BABYLON {
  87242. /** @hidden */
  87243. export var shadowOnlyVertexShader: {
  87244. name: string;
  87245. shader: string;
  87246. };
  87247. }
  87248. declare module BABYLON {
  87249. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  87250. private _activeLight;
  87251. private _needAlphaBlending;
  87252. constructor(name: string, scene: BABYLON.Scene);
  87253. shadowColor: BABYLON.Color3;
  87254. needAlphaBlending(): boolean;
  87255. needAlphaTesting(): boolean;
  87256. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87257. get activeLight(): BABYLON.IShadowLight;
  87258. set activeLight(light: BABYLON.IShadowLight);
  87259. private _getFirstShadowLightForMesh;
  87260. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87261. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87262. clone(name: string): ShadowOnlyMaterial;
  87263. serialize(): any;
  87264. getClassName(): string;
  87265. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  87266. }
  87267. }
  87268. declare module BABYLON {
  87269. /** @hidden */
  87270. export var simplePixelShader: {
  87271. name: string;
  87272. shader: string;
  87273. };
  87274. }
  87275. declare module BABYLON {
  87276. /** @hidden */
  87277. export var simpleVertexShader: {
  87278. name: string;
  87279. shader: string;
  87280. };
  87281. }
  87282. declare module BABYLON {
  87283. export class SimpleMaterial extends BABYLON.PushMaterial {
  87284. private _diffuseTexture;
  87285. diffuseTexture: BABYLON.BaseTexture;
  87286. diffuseColor: BABYLON.Color3;
  87287. private _disableLighting;
  87288. disableLighting: boolean;
  87289. private _maxSimultaneousLights;
  87290. maxSimultaneousLights: number;
  87291. constructor(name: string, scene: BABYLON.Scene);
  87292. needAlphaBlending(): boolean;
  87293. needAlphaTesting(): boolean;
  87294. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87295. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87296. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87297. getAnimatables(): BABYLON.IAnimatable[];
  87298. getActiveTextures(): BABYLON.BaseTexture[];
  87299. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87300. dispose(forceDisposeEffect?: boolean): void;
  87301. clone(name: string): SimpleMaterial;
  87302. serialize(): any;
  87303. getClassName(): string;
  87304. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  87305. }
  87306. }
  87307. declare module BABYLON {
  87308. /** @hidden */
  87309. export var skyPixelShader: {
  87310. name: string;
  87311. shader: string;
  87312. };
  87313. }
  87314. declare module BABYLON {
  87315. /** @hidden */
  87316. export var skyVertexShader: {
  87317. name: string;
  87318. shader: string;
  87319. };
  87320. }
  87321. declare module BABYLON {
  87322. /**
  87323. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  87324. * @see https://doc.babylonjs.com/extensions/sky
  87325. */
  87326. export class SkyMaterial extends BABYLON.PushMaterial {
  87327. /**
  87328. * Defines the overall luminance of sky in interval ]0, 1[.
  87329. */
  87330. luminance: number;
  87331. /**
  87332. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  87333. */
  87334. turbidity: number;
  87335. /**
  87336. * Defines the sky appearance (light intensity).
  87337. */
  87338. rayleigh: number;
  87339. /**
  87340. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  87341. */
  87342. mieCoefficient: number;
  87343. /**
  87344. * Defines the amount of haze particles following the Mie scattering theory.
  87345. */
  87346. mieDirectionalG: number;
  87347. /**
  87348. * Defines the distance of the sun according to the active scene camera.
  87349. */
  87350. distance: number;
  87351. /**
  87352. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  87353. * "inclined".
  87354. */
  87355. inclination: number;
  87356. /**
  87357. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  87358. * an object direction and a reference direction.
  87359. */
  87360. azimuth: number;
  87361. /**
  87362. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  87363. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  87364. */
  87365. sunPosition: BABYLON.Vector3;
  87366. /**
  87367. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  87368. * .sunPosition property.
  87369. */
  87370. useSunPosition: boolean;
  87371. /**
  87372. * Defines an offset vector used to get a horizon offset.
  87373. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  87374. */
  87375. cameraOffset: BABYLON.Vector3;
  87376. private _cameraPosition;
  87377. /**
  87378. * Instantiates a new sky material.
  87379. * This material allows to create dynamic and texture free
  87380. * effects for skyboxes by taking care of the atmosphere state.
  87381. * @see https://doc.babylonjs.com/extensions/sky
  87382. * @param name Define the name of the material in the scene
  87383. * @param scene Define the scene the material belong to
  87384. */
  87385. constructor(name: string, scene: BABYLON.Scene);
  87386. /**
  87387. * Specifies if the material will require alpha blending
  87388. * @returns a boolean specifying if alpha blending is needed
  87389. */
  87390. needAlphaBlending(): boolean;
  87391. /**
  87392. * Specifies if this material should be rendered in alpha test mode
  87393. * @returns false as the sky material doesn't need alpha testing.
  87394. */
  87395. needAlphaTesting(): boolean;
  87396. /**
  87397. * Get the texture used for alpha test purpose.
  87398. * @returns null as the sky material has no texture.
  87399. */
  87400. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87401. /**
  87402. * Get if the submesh is ready to be used and all its information available.
  87403. * Child classes can use it to update shaders
  87404. * @param mesh defines the mesh to check
  87405. * @param subMesh defines which submesh to check
  87406. * @param useInstances specifies that instances should be used
  87407. * @returns a boolean indicating that the submesh is ready or not
  87408. */
  87409. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87410. /**
  87411. * Binds the submesh to this material by preparing the effect and shader to draw
  87412. * @param world defines the world transformation matrix
  87413. * @param mesh defines the mesh containing the submesh
  87414. * @param subMesh defines the submesh to bind the material to
  87415. */
  87416. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87417. /**
  87418. * Get the list of animatables in the material.
  87419. * @returns the list of animatables object used in the material
  87420. */
  87421. getAnimatables(): BABYLON.IAnimatable[];
  87422. /**
  87423. * Disposes the material
  87424. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  87425. */
  87426. dispose(forceDisposeEffect?: boolean): void;
  87427. /**
  87428. * Makes a duplicate of the material, and gives it a new name
  87429. * @param name defines the new name for the duplicated material
  87430. * @returns the cloned material
  87431. */
  87432. clone(name: string): SkyMaterial;
  87433. /**
  87434. * Serializes this material in a JSON representation
  87435. * @returns the serialized material object
  87436. */
  87437. serialize(): any;
  87438. /**
  87439. * Gets the current class name of the material e.g. "SkyMaterial"
  87440. * Mainly use in serialization.
  87441. * @returns the class name
  87442. */
  87443. getClassName(): string;
  87444. /**
  87445. * Creates a sky material from parsed material data
  87446. * @param source defines the JSON representation of the material
  87447. * @param scene defines the hosting scene
  87448. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  87449. * @returns a new sky material
  87450. */
  87451. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  87452. }
  87453. }
  87454. declare module BABYLON {
  87455. /** @hidden */
  87456. export var terrainPixelShader: {
  87457. name: string;
  87458. shader: string;
  87459. };
  87460. }
  87461. declare module BABYLON {
  87462. /** @hidden */
  87463. export var terrainVertexShader: {
  87464. name: string;
  87465. shader: string;
  87466. };
  87467. }
  87468. declare module BABYLON {
  87469. export class TerrainMaterial extends BABYLON.PushMaterial {
  87470. private _mixTexture;
  87471. mixTexture: BABYLON.BaseTexture;
  87472. private _diffuseTexture1;
  87473. diffuseTexture1: BABYLON.Texture;
  87474. private _diffuseTexture2;
  87475. diffuseTexture2: BABYLON.Texture;
  87476. private _diffuseTexture3;
  87477. diffuseTexture3: BABYLON.Texture;
  87478. private _bumpTexture1;
  87479. bumpTexture1: BABYLON.Texture;
  87480. private _bumpTexture2;
  87481. bumpTexture2: BABYLON.Texture;
  87482. private _bumpTexture3;
  87483. bumpTexture3: BABYLON.Texture;
  87484. diffuseColor: BABYLON.Color3;
  87485. specularColor: BABYLON.Color3;
  87486. specularPower: number;
  87487. private _disableLighting;
  87488. disableLighting: boolean;
  87489. private _maxSimultaneousLights;
  87490. maxSimultaneousLights: number;
  87491. constructor(name: string, scene: BABYLON.Scene);
  87492. needAlphaBlending(): boolean;
  87493. needAlphaTesting(): boolean;
  87494. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87495. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87496. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87497. getAnimatables(): BABYLON.IAnimatable[];
  87498. getActiveTextures(): BABYLON.BaseTexture[];
  87499. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87500. dispose(forceDisposeEffect?: boolean): void;
  87501. clone(name: string): TerrainMaterial;
  87502. serialize(): any;
  87503. getClassName(): string;
  87504. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  87505. }
  87506. }
  87507. declare module BABYLON {
  87508. /** @hidden */
  87509. export var triplanarPixelShader: {
  87510. name: string;
  87511. shader: string;
  87512. };
  87513. }
  87514. declare module BABYLON {
  87515. /** @hidden */
  87516. export var triplanarVertexShader: {
  87517. name: string;
  87518. shader: string;
  87519. };
  87520. }
  87521. declare module BABYLON {
  87522. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  87523. mixTexture: BABYLON.BaseTexture;
  87524. private _diffuseTextureX;
  87525. diffuseTextureX: BABYLON.BaseTexture;
  87526. private _diffuseTextureY;
  87527. diffuseTextureY: BABYLON.BaseTexture;
  87528. private _diffuseTextureZ;
  87529. diffuseTextureZ: BABYLON.BaseTexture;
  87530. private _normalTextureX;
  87531. normalTextureX: BABYLON.BaseTexture;
  87532. private _normalTextureY;
  87533. normalTextureY: BABYLON.BaseTexture;
  87534. private _normalTextureZ;
  87535. normalTextureZ: BABYLON.BaseTexture;
  87536. tileSize: number;
  87537. diffuseColor: BABYLON.Color3;
  87538. specularColor: BABYLON.Color3;
  87539. specularPower: number;
  87540. private _disableLighting;
  87541. disableLighting: boolean;
  87542. private _maxSimultaneousLights;
  87543. maxSimultaneousLights: number;
  87544. constructor(name: string, scene: BABYLON.Scene);
  87545. needAlphaBlending(): boolean;
  87546. needAlphaTesting(): boolean;
  87547. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87548. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87549. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87550. getAnimatables(): BABYLON.IAnimatable[];
  87551. getActiveTextures(): BABYLON.BaseTexture[];
  87552. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87553. dispose(forceDisposeEffect?: boolean): void;
  87554. clone(name: string): TriPlanarMaterial;
  87555. serialize(): any;
  87556. getClassName(): string;
  87557. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  87558. }
  87559. }
  87560. declare module BABYLON {
  87561. /** @hidden */
  87562. export var waterPixelShader: {
  87563. name: string;
  87564. shader: string;
  87565. };
  87566. }
  87567. declare module BABYLON {
  87568. /** @hidden */
  87569. export var waterVertexShader: {
  87570. name: string;
  87571. shader: string;
  87572. };
  87573. }
  87574. declare module BABYLON {
  87575. export class WaterMaterial extends BABYLON.PushMaterial {
  87576. renderTargetSize: BABYLON.Vector2;
  87577. private _bumpTexture;
  87578. bumpTexture: BABYLON.BaseTexture;
  87579. diffuseColor: BABYLON.Color3;
  87580. specularColor: BABYLON.Color3;
  87581. specularPower: number;
  87582. private _disableLighting;
  87583. disableLighting: boolean;
  87584. private _maxSimultaneousLights;
  87585. maxSimultaneousLights: number;
  87586. /**
  87587. * Defines the wind force.
  87588. */
  87589. windForce: number;
  87590. /**
  87591. * Defines the direction of the wind in the plane (X, Z).
  87592. */
  87593. windDirection: BABYLON.Vector2;
  87594. /**
  87595. * Defines the height of the waves.
  87596. */
  87597. waveHeight: number;
  87598. /**
  87599. * Defines the bump height related to the bump map.
  87600. */
  87601. bumpHeight: number;
  87602. /**
  87603. * Defines wether or not: to add a smaller moving bump to less steady waves.
  87604. */
  87605. private _bumpSuperimpose;
  87606. bumpSuperimpose: boolean;
  87607. /**
  87608. * Defines wether or not color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  87609. */
  87610. private _fresnelSeparate;
  87611. fresnelSeparate: boolean;
  87612. /**
  87613. * Defines wether or not bump Wwves modify the reflection.
  87614. */
  87615. private _bumpAffectsReflection;
  87616. bumpAffectsReflection: boolean;
  87617. /**
  87618. * Defines the water color blended with the refraction (near).
  87619. */
  87620. waterColor: BABYLON.Color3;
  87621. /**
  87622. * Defines the blend factor related to the water color.
  87623. */
  87624. colorBlendFactor: number;
  87625. /**
  87626. * Defines the water color blended with the reflection (far).
  87627. */
  87628. waterColor2: BABYLON.Color3;
  87629. /**
  87630. * Defines the blend factor related to the water color (reflection, far).
  87631. */
  87632. colorBlendFactor2: number;
  87633. /**
  87634. * Defines the maximum length of a wave.
  87635. */
  87636. waveLength: number;
  87637. /**
  87638. * Defines the waves speed.
  87639. */
  87640. waveSpeed: number;
  87641. /**
  87642. * Defines the number of times waves are repeated. This is typically used to adjust waves count according to the ground's size where the material is applied on.
  87643. */
  87644. waveCount: number;
  87645. /**
  87646. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  87647. * will avoid calculating useless pixels in the pixel shader of the water material.
  87648. */
  87649. disableClipPlane: boolean;
  87650. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  87651. private _mesh;
  87652. private _refractionRTT;
  87653. private _reflectionRTT;
  87654. private _reflectionTransform;
  87655. private _lastTime;
  87656. private _lastDeltaTime;
  87657. private _useLogarithmicDepth;
  87658. private _waitingRenderList;
  87659. private _imageProcessingConfiguration;
  87660. private _imageProcessingObserver;
  87661. /**
  87662. * Gets a boolean indicating that current material needs to register RTT
  87663. */
  87664. get hasRenderTargetTextures(): boolean;
  87665. /**
  87666. * Constructor
  87667. */
  87668. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  87669. get useLogarithmicDepth(): boolean;
  87670. set useLogarithmicDepth(value: boolean);
  87671. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  87672. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  87673. addToRenderList(node: any): void;
  87674. enableRenderTargets(enable: boolean): void;
  87675. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  87676. get renderTargetsEnabled(): boolean;
  87677. needAlphaBlending(): boolean;
  87678. needAlphaTesting(): boolean;
  87679. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87680. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87681. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87682. private _createRenderTargets;
  87683. getAnimatables(): BABYLON.IAnimatable[];
  87684. getActiveTextures(): BABYLON.BaseTexture[];
  87685. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87686. dispose(forceDisposeEffect?: boolean): void;
  87687. clone(name: string): WaterMaterial;
  87688. serialize(): any;
  87689. getClassName(): string;
  87690. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  87691. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  87692. }
  87693. }
  87694. declare module BABYLON {
  87695. /** @hidden */
  87696. export var asciiartPixelShader: {
  87697. name: string;
  87698. shader: string;
  87699. };
  87700. }
  87701. declare module BABYLON {
  87702. /**
  87703. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  87704. *
  87705. * It basically takes care rendering the font front the given font size to a texture.
  87706. * This is used later on in the postprocess.
  87707. */
  87708. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  87709. private _font;
  87710. private _text;
  87711. private _charSize;
  87712. /**
  87713. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  87714. */
  87715. get charSize(): number;
  87716. /**
  87717. * Create a new instance of the Ascii Art FontTexture class
  87718. * @param name the name of the texture
  87719. * @param font the font to use, use the W3C CSS notation
  87720. * @param text the caracter set to use in the rendering.
  87721. * @param scene the scene that owns the texture
  87722. */
  87723. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  87724. /**
  87725. * Gets the max char width of a font.
  87726. * @param font the font to use, use the W3C CSS notation
  87727. * @return the max char width
  87728. */
  87729. private getFontWidth;
  87730. /**
  87731. * Gets the max char height of a font.
  87732. * @param font the font to use, use the W3C CSS notation
  87733. * @return the max char height
  87734. */
  87735. private getFontHeight;
  87736. /**
  87737. * Clones the current AsciiArtTexture.
  87738. * @return the clone of the texture.
  87739. */
  87740. clone(): AsciiArtFontTexture;
  87741. /**
  87742. * Parses a json object representing the texture and returns an instance of it.
  87743. * @param source the source JSON representation
  87744. * @param scene the scene to create the texture for
  87745. * @return the parsed texture
  87746. */
  87747. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  87748. }
  87749. /**
  87750. * Option available in the Ascii Art Post Process.
  87751. */
  87752. export interface IAsciiArtPostProcessOptions {
  87753. /**
  87754. * The font to use following the w3c font definition.
  87755. */
  87756. font?: string;
  87757. /**
  87758. * The character set to use in the postprocess.
  87759. */
  87760. characterSet?: string;
  87761. /**
  87762. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  87763. * This number is defined between 0 and 1;
  87764. */
  87765. mixToTile?: number;
  87766. /**
  87767. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  87768. * This number is defined between 0 and 1;
  87769. */
  87770. mixToNormal?: number;
  87771. }
  87772. /**
  87773. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  87774. *
  87775. * Simmply add it to your scene and let the nerd that lives in you have fun.
  87776. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  87777. */
  87778. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  87779. /**
  87780. * The font texture used to render the char in the post process.
  87781. */
  87782. private _asciiArtFontTexture;
  87783. /**
  87784. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  87785. * This number is defined between 0 and 1;
  87786. */
  87787. mixToTile: number;
  87788. /**
  87789. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  87790. * This number is defined between 0 and 1;
  87791. */
  87792. mixToNormal: number;
  87793. /**
  87794. * Instantiates a new Ascii Art Post Process.
  87795. * @param name the name to give to the postprocess
  87796. * @camera the camera to apply the post process to.
  87797. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  87798. */
  87799. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  87800. }
  87801. }
  87802. declare module BABYLON {
  87803. /** @hidden */
  87804. export var digitalrainPixelShader: {
  87805. name: string;
  87806. shader: string;
  87807. };
  87808. }
  87809. declare module BABYLON {
  87810. /**
  87811. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  87812. *
  87813. * It basically takes care rendering the font front the given font size to a texture.
  87814. * This is used later on in the postprocess.
  87815. */
  87816. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  87817. private _font;
  87818. private _text;
  87819. private _charSize;
  87820. /**
  87821. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  87822. */
  87823. get charSize(): number;
  87824. /**
  87825. * Create a new instance of the Digital Rain FontTexture class
  87826. * @param name the name of the texture
  87827. * @param font the font to use, use the W3C CSS notation
  87828. * @param text the caracter set to use in the rendering.
  87829. * @param scene the scene that owns the texture
  87830. */
  87831. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  87832. /**
  87833. * Gets the max char width of a font.
  87834. * @param font the font to use, use the W3C CSS notation
  87835. * @return the max char width
  87836. */
  87837. private getFontWidth;
  87838. /**
  87839. * Gets the max char height of a font.
  87840. * @param font the font to use, use the W3C CSS notation
  87841. * @return the max char height
  87842. */
  87843. private getFontHeight;
  87844. /**
  87845. * Clones the current DigitalRainFontTexture.
  87846. * @return the clone of the texture.
  87847. */
  87848. clone(): DigitalRainFontTexture;
  87849. /**
  87850. * Parses a json object representing the texture and returns an instance of it.
  87851. * @param source the source JSON representation
  87852. * @param scene the scene to create the texture for
  87853. * @return the parsed texture
  87854. */
  87855. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  87856. }
  87857. /**
  87858. * Option available in the Digital Rain Post Process.
  87859. */
  87860. export interface IDigitalRainPostProcessOptions {
  87861. /**
  87862. * The font to use following the w3c font definition.
  87863. */
  87864. font?: string;
  87865. /**
  87866. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  87867. * This number is defined between 0 and 1;
  87868. */
  87869. mixToTile?: number;
  87870. /**
  87871. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  87872. * This number is defined between 0 and 1;
  87873. */
  87874. mixToNormal?: number;
  87875. }
  87876. /**
  87877. * DigitalRainPostProcess helps rendering everithing in digital rain.
  87878. *
  87879. * Simmply add it to your scene and let the nerd that lives in you have fun.
  87880. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  87881. */
  87882. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  87883. /**
  87884. * The font texture used to render the char in the post process.
  87885. */
  87886. private _digitalRainFontTexture;
  87887. /**
  87888. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  87889. * This number is defined between 0 and 1;
  87890. */
  87891. mixToTile: number;
  87892. /**
  87893. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  87894. * This number is defined between 0 and 1;
  87895. */
  87896. mixToNormal: number;
  87897. /**
  87898. * Instantiates a new Digital Rain Post Process.
  87899. * @param name the name to give to the postprocess
  87900. * @camera the camera to apply the post process to.
  87901. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  87902. */
  87903. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  87904. }
  87905. }
  87906. declare module BABYLON {
  87907. /** @hidden */
  87908. export var brickProceduralTexturePixelShader: {
  87909. name: string;
  87910. shader: string;
  87911. };
  87912. }
  87913. declare module BABYLON {
  87914. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  87915. private _numberOfBricksHeight;
  87916. private _numberOfBricksWidth;
  87917. private _jointColor;
  87918. private _brickColor;
  87919. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87920. updateShaderUniforms(): void;
  87921. get numberOfBricksHeight(): number;
  87922. set numberOfBricksHeight(value: number);
  87923. get numberOfBricksWidth(): number;
  87924. set numberOfBricksWidth(value: number);
  87925. get jointColor(): BABYLON.Color3;
  87926. set jointColor(value: BABYLON.Color3);
  87927. get brickColor(): BABYLON.Color3;
  87928. set brickColor(value: BABYLON.Color3);
  87929. /**
  87930. * Serializes this brick procedural texture
  87931. * @returns a serialized brick procedural texture object
  87932. */
  87933. serialize(): any;
  87934. /**
  87935. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  87936. * @param parsedTexture defines parsed texture data
  87937. * @param scene defines the current scene
  87938. * @param rootUrl defines the root URL containing brick procedural texture information
  87939. * @returns a parsed Brick Procedural BABYLON.Texture
  87940. */
  87941. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  87942. }
  87943. }
  87944. declare module BABYLON {
  87945. /** @hidden */
  87946. export var cloudProceduralTexturePixelShader: {
  87947. name: string;
  87948. shader: string;
  87949. };
  87950. }
  87951. declare module BABYLON {
  87952. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  87953. private _skyColor;
  87954. private _cloudColor;
  87955. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87956. updateShaderUniforms(): void;
  87957. get skyColor(): BABYLON.Color4;
  87958. set skyColor(value: BABYLON.Color4);
  87959. get cloudColor(): BABYLON.Color4;
  87960. set cloudColor(value: BABYLON.Color4);
  87961. /**
  87962. * Serializes this cloud procedural texture
  87963. * @returns a serialized cloud procedural texture object
  87964. */
  87965. serialize(): any;
  87966. /**
  87967. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  87968. * @param parsedTexture defines parsed texture data
  87969. * @param scene defines the current scene
  87970. * @param rootUrl defines the root URL containing cloud procedural texture information
  87971. * @returns a parsed Cloud Procedural BABYLON.Texture
  87972. */
  87973. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  87974. }
  87975. }
  87976. declare module BABYLON {
  87977. /** @hidden */
  87978. export var fireProceduralTexturePixelShader: {
  87979. name: string;
  87980. shader: string;
  87981. };
  87982. }
  87983. declare module BABYLON {
  87984. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  87985. private _time;
  87986. private _speed;
  87987. private _autoGenerateTime;
  87988. private _fireColors;
  87989. private _alphaThreshold;
  87990. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87991. updateShaderUniforms(): void;
  87992. render(useCameraPostProcess?: boolean): void;
  87993. static get PurpleFireColors(): BABYLON.Color3[];
  87994. static get GreenFireColors(): BABYLON.Color3[];
  87995. static get RedFireColors(): BABYLON.Color3[];
  87996. static get BlueFireColors(): BABYLON.Color3[];
  87997. get autoGenerateTime(): boolean;
  87998. set autoGenerateTime(value: boolean);
  87999. get fireColors(): BABYLON.Color3[];
  88000. set fireColors(value: BABYLON.Color3[]);
  88001. get time(): number;
  88002. set time(value: number);
  88003. get speed(): BABYLON.Vector2;
  88004. set speed(value: BABYLON.Vector2);
  88005. get alphaThreshold(): number;
  88006. set alphaThreshold(value: number);
  88007. /**
  88008. * Serializes this fire procedural texture
  88009. * @returns a serialized fire procedural texture object
  88010. */
  88011. serialize(): any;
  88012. /**
  88013. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  88014. * @param parsedTexture defines parsed texture data
  88015. * @param scene defines the current scene
  88016. * @param rootUrl defines the root URL containing fire procedural texture information
  88017. * @returns a parsed Fire Procedural BABYLON.Texture
  88018. */
  88019. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  88020. }
  88021. }
  88022. declare module BABYLON {
  88023. /** @hidden */
  88024. export var grassProceduralTexturePixelShader: {
  88025. name: string;
  88026. shader: string;
  88027. };
  88028. }
  88029. declare module BABYLON {
  88030. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  88031. private _grassColors;
  88032. private _groundColor;
  88033. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88034. updateShaderUniforms(): void;
  88035. get grassColors(): BABYLON.Color3[];
  88036. set grassColors(value: BABYLON.Color3[]);
  88037. get groundColor(): BABYLON.Color3;
  88038. set groundColor(value: BABYLON.Color3);
  88039. /**
  88040. * Serializes this grass procedural texture
  88041. * @returns a serialized grass procedural texture object
  88042. */
  88043. serialize(): any;
  88044. /**
  88045. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  88046. * @param parsedTexture defines parsed texture data
  88047. * @param scene defines the current scene
  88048. * @param rootUrl defines the root URL containing grass procedural texture information
  88049. * @returns a parsed Grass Procedural BABYLON.Texture
  88050. */
  88051. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  88052. }
  88053. }
  88054. declare module BABYLON {
  88055. /** @hidden */
  88056. export var marbleProceduralTexturePixelShader: {
  88057. name: string;
  88058. shader: string;
  88059. };
  88060. }
  88061. declare module BABYLON {
  88062. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  88063. private _numberOfTilesHeight;
  88064. private _numberOfTilesWidth;
  88065. private _amplitude;
  88066. private _jointColor;
  88067. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88068. updateShaderUniforms(): void;
  88069. get numberOfTilesHeight(): number;
  88070. set numberOfTilesHeight(value: number);
  88071. get amplitude(): number;
  88072. set amplitude(value: number);
  88073. get numberOfTilesWidth(): number;
  88074. set numberOfTilesWidth(value: number);
  88075. get jointColor(): BABYLON.Color3;
  88076. set jointColor(value: BABYLON.Color3);
  88077. /**
  88078. * Serializes this marble procedural texture
  88079. * @returns a serialized marble procedural texture object
  88080. */
  88081. serialize(): any;
  88082. /**
  88083. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  88084. * @param parsedTexture defines parsed texture data
  88085. * @param scene defines the current scene
  88086. * @param rootUrl defines the root URL containing marble procedural texture information
  88087. * @returns a parsed Marble Procedural BABYLON.Texture
  88088. */
  88089. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  88090. }
  88091. }
  88092. declare module BABYLON {
  88093. /** @hidden */
  88094. export var normalMapProceduralTexturePixelShader: {
  88095. name: string;
  88096. shader: string;
  88097. };
  88098. }
  88099. declare module BABYLON {
  88100. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  88101. private _baseTexture;
  88102. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88103. updateShaderUniforms(): void;
  88104. render(useCameraPostProcess?: boolean): void;
  88105. resize(size: any, generateMipMaps: any): void;
  88106. get baseTexture(): BABYLON.Texture;
  88107. set baseTexture(texture: BABYLON.Texture);
  88108. /**
  88109. * Serializes this normal map procedural texture
  88110. * @returns a serialized normal map procedural texture object
  88111. */
  88112. serialize(): any;
  88113. /**
  88114. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  88115. * @param parsedTexture defines parsed texture data
  88116. * @param scene defines the current scene
  88117. * @param rootUrl defines the root URL containing normal map procedural texture information
  88118. * @returns a parsed Normal Map Procedural BABYLON.Texture
  88119. */
  88120. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  88121. }
  88122. }
  88123. declare module BABYLON {
  88124. /** @hidden */
  88125. export var perlinNoiseProceduralTexturePixelShader: {
  88126. name: string;
  88127. shader: string;
  88128. };
  88129. }
  88130. declare module BABYLON {
  88131. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  88132. time: number;
  88133. timeScale: number;
  88134. translationSpeed: number;
  88135. private _currentTranslation;
  88136. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88137. updateShaderUniforms(): void;
  88138. render(useCameraPostProcess?: boolean): void;
  88139. resize(size: any, generateMipMaps: any): void;
  88140. /**
  88141. * Serializes this perlin noise procedural texture
  88142. * @returns a serialized perlin noise procedural texture object
  88143. */
  88144. serialize(): any;
  88145. /**
  88146. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  88147. * @param parsedTexture defines parsed texture data
  88148. * @param scene defines the current scene
  88149. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  88150. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  88151. */
  88152. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  88153. }
  88154. }
  88155. declare module BABYLON {
  88156. /** @hidden */
  88157. export var roadProceduralTexturePixelShader: {
  88158. name: string;
  88159. shader: string;
  88160. };
  88161. }
  88162. declare module BABYLON {
  88163. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  88164. private _roadColor;
  88165. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88166. updateShaderUniforms(): void;
  88167. get roadColor(): BABYLON.Color3;
  88168. set roadColor(value: BABYLON.Color3);
  88169. /**
  88170. * Serializes this road procedural texture
  88171. * @returns a serialized road procedural texture object
  88172. */
  88173. serialize(): any;
  88174. /**
  88175. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  88176. * @param parsedTexture defines parsed texture data
  88177. * @param scene defines the current scene
  88178. * @param rootUrl defines the root URL containing road procedural texture information
  88179. * @returns a parsed Road Procedural BABYLON.Texture
  88180. */
  88181. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  88182. }
  88183. }
  88184. declare module BABYLON {
  88185. /** @hidden */
  88186. export var starfieldProceduralTexturePixelShader: {
  88187. name: string;
  88188. shader: string;
  88189. };
  88190. }
  88191. declare module BABYLON {
  88192. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  88193. private _time;
  88194. private _alpha;
  88195. private _beta;
  88196. private _zoom;
  88197. private _formuparam;
  88198. private _stepsize;
  88199. private _tile;
  88200. private _brightness;
  88201. private _darkmatter;
  88202. private _distfading;
  88203. private _saturation;
  88204. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88205. updateShaderUniforms(): void;
  88206. get time(): number;
  88207. set time(value: number);
  88208. get alpha(): number;
  88209. set alpha(value: number);
  88210. get beta(): number;
  88211. set beta(value: number);
  88212. get formuparam(): number;
  88213. set formuparam(value: number);
  88214. get stepsize(): number;
  88215. set stepsize(value: number);
  88216. get zoom(): number;
  88217. set zoom(value: number);
  88218. get tile(): number;
  88219. set tile(value: number);
  88220. get brightness(): number;
  88221. set brightness(value: number);
  88222. get darkmatter(): number;
  88223. set darkmatter(value: number);
  88224. get distfading(): number;
  88225. set distfading(value: number);
  88226. get saturation(): number;
  88227. set saturation(value: number);
  88228. /**
  88229. * Serializes this starfield procedural texture
  88230. * @returns a serialized starfield procedural texture object
  88231. */
  88232. serialize(): any;
  88233. /**
  88234. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  88235. * @param parsedTexture defines parsed texture data
  88236. * @param scene defines the current scene
  88237. * @param rootUrl defines the root URL containing startfield procedural texture information
  88238. * @returns a parsed Starfield Procedural BABYLON.Texture
  88239. */
  88240. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  88241. }
  88242. }
  88243. declare module BABYLON {
  88244. /** @hidden */
  88245. export var woodProceduralTexturePixelShader: {
  88246. name: string;
  88247. shader: string;
  88248. };
  88249. }
  88250. declare module BABYLON {
  88251. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  88252. private _ampScale;
  88253. private _woodColor;
  88254. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88255. updateShaderUniforms(): void;
  88256. get ampScale(): number;
  88257. set ampScale(value: number);
  88258. get woodColor(): BABYLON.Color3;
  88259. set woodColor(value: BABYLON.Color3);
  88260. /**
  88261. * Serializes this wood procedural texture
  88262. * @returns a serialized wood procedural texture object
  88263. */
  88264. serialize(): any;
  88265. /**
  88266. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  88267. * @param parsedTexture defines parsed texture data
  88268. * @param scene defines the current scene
  88269. * @param rootUrl defines the root URL containing wood procedural texture information
  88270. * @returns a parsed Wood Procedural BABYLON.Texture
  88271. */
  88272. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  88273. }
  88274. }