documentation.d.ts 3.7 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276742777427874279742807428174282742837428474285742867428774288742897429074291742927429374294742957429674297742987429974300743017430274303743047430574306743077430874309743107431174312743137431474315743167431774318743197432074321743227432374324743257432674327743287432974330743317433274333743347433574336743377433874339743407434174342743437434474345743467434774348743497435074351743527435374354743557435674357743587435974360743617436274363743647436574366743677436874369743707437174372743737437474375743767437774378743797438074381743827438374384743857438674387743887438974390743917439274393743947439574396743977439874399744007440174402744037440474405744067440774408744097441074411744127441374414744157441674417744187441974420744217442274423744247442574426744277442874429744307443174432744337443474435744367443774438744397444074441744427444374444744457444674447744487444974450744517445274453744547445574456744577445874459744607446174462744637446474465744667446774468744697447074471744727447374474744757447674477744787447974480744817448274483744847448574486744877448874489744907449174492744937449474495744967449774498744997450074501745027450374504745057450674507745087450974510745117451274513745147451574516745177451874519745207452174522745237452474525745267452774528745297453074531745327453374534745357453674537745387453974540745417454274543745447454574546745477454874549745507455174552745537455474555745567455774558745597456074561745627456374564745657456674567745687456974570745717457274573745747457574576745777457874579745807458174582745837458474585745867458774588745897459074591745927459374594745957459674597745987459974600746017460274603746047460574606746077460874609746107461174612746137461474615746167461774618746197462074621746227462374624746257462674627746287462974630746317463274633746347463574636746377463874639746407464174642746437464474645746467464774648746497465074651746527465374654746557465674657746587465974660746617466274663746647466574666746677466874669746707467174672746737467474675746767467774678746797468074681746827468374684746857468674687746887468974690746917469274693746947469574696746977469874699747007470174702747037470474705747067470774708747097471074711747127471374714747157471674717747187471974720747217472274723747247472574726747277472874729747307473174732747337473474735747367473774738747397474074741747427474374744747457474674747747487474974750747517475274753747547475574756747577475874759747607476174762747637476474765747667476774768747697477074771747727477374774747757477674777747787477974780747817478274783747847478574786747877478874789747907479174792747937479474795747967479774798747997480074801748027480374804748057480674807748087480974810748117481274813748147481574816748177481874819748207482174822748237482474825748267482774828748297483074831748327483374834748357483674837748387483974840748417484274843748447484574846748477484874849748507485174852748537485474855748567485774858748597486074861748627486374864748657486674867748687486974870748717487274873748747487574876748777487874879748807488174882748837488474885748867488774888748897489074891748927489374894748957489674897748987489974900749017490274903749047490574906749077490874909749107491174912749137491474915749167491774918749197492074921749227492374924749257492674927749287492974930749317493274933749347493574936749377493874939749407494174942749437494474945749467494774948749497495074951749527495374954749557495674957749587495974960749617496274963749647496574966749677496874969749707497174972749737497474975749767497774978749797498074981749827498374984749857498674987749887498974990749917499274993749947499574996749977499874999750007500175002750037500475005750067500775008750097501075011750127501375014750157501675017750187501975020750217502275023750247502575026750277502875029750307503175032750337503475035750367503775038750397504075041750427504375044750457504675047750487504975050750517505275053750547505575056750577505875059750607506175062750637506475065750667506775068750697507075071750727507375074750757507675077750787507975080750817508275083750847508575086750877508875089750907509175092750937509475095750967509775098750997510075101751027510375104751057510675107751087510975110751117511275113751147511575116751177511875119751207512175122751237512475125751267512775128751297513075131751327513375134751357513675137751387513975140751417514275143751447514575146751477514875149751507515175152751537515475155751567515775158751597516075161751627516375164751657516675167751687516975170751717517275173751747517575176751777517875179751807518175182751837518475185751867518775188751897519075191751927519375194751957519675197751987519975200752017520275203752047520575206752077520875209752107521175212752137521475215752167521775218752197522075221752227522375224752257522675227752287522975230752317523275233752347523575236752377523875239752407524175242752437524475245752467524775248752497525075251752527525375254752557525675257752587525975260752617526275263752647526575266752677526875269752707527175272752737527475275752767527775278752797528075281752827528375284752857528675287752887528975290752917529275293752947529575296752977529875299753007530175302753037530475305753067530775308753097531075311753127531375314753157531675317753187531975320753217532275323753247532575326753277532875329753307533175332753337533475335753367533775338753397534075341753427534375344753457534675347753487534975350753517535275353753547535575356753577535875359753607536175362753637536475365753667536775368753697537075371753727537375374753757537675377753787537975380753817538275383753847538575386753877538875389753907539175392753937539475395753967539775398753997540075401754027540375404754057540675407754087540975410754117541275413754147541575416754177541875419754207542175422754237542475425754267542775428754297543075431754327543375434754357543675437754387543975440754417544275443754447544575446754477544875449754507545175452754537545475455754567545775458754597546075461754627546375464754657546675467754687546975470754717547275473754747547575476754777547875479754807548175482754837548475485754867548775488754897549075491754927549375494754957549675497754987549975500755017550275503755047550575506755077550875509755107551175512755137551475515755167551775518755197552075521755227552375524755257552675527755287552975530755317553275533755347553575536755377553875539755407554175542755437554475545755467554775548755497555075551755527555375554755557555675557755587555975560755617556275563755647556575566755677556875569755707557175572755737557475575755767557775578755797558075581755827558375584755857558675587755887558975590755917559275593755947559575596755977559875599756007560175602756037560475605756067560775608756097561075611756127561375614756157561675617756187561975620756217562275623756247562575626756277562875629756307563175632756337563475635756367563775638756397564075641756427564375644756457564675647756487564975650756517565275653756547565575656756577565875659756607566175662756637566475665756667566775668756697567075671756727567375674756757567675677756787567975680756817568275683756847568575686756877568875689756907569175692756937569475695756967569775698756997570075701757027570375704757057570675707757087570975710757117571275713757147571575716757177571875719757207572175722757237572475725757267572775728757297573075731757327573375734757357573675737757387573975740757417574275743757447574575746757477574875749757507575175752757537575475755757567575775758757597576075761757627576375764757657576675767757687576975770757717577275773757747577575776757777577875779757807578175782757837578475785757867578775788757897579075791757927579375794757957579675797757987579975800758017580275803758047580575806758077580875809758107581175812758137581475815758167581775818758197582075821758227582375824758257582675827758287582975830758317583275833758347583575836758377583875839758407584175842758437584475845758467584775848758497585075851758527585375854758557585675857758587585975860758617586275863758647586575866758677586875869758707587175872758737587475875758767587775878758797588075881758827588375884758857588675887758887588975890758917589275893758947589575896758977589875899759007590175902759037590475905759067590775908759097591075911759127591375914759157591675917759187591975920759217592275923759247592575926759277592875929759307593175932759337593475935759367593775938759397594075941759427594375944759457594675947759487594975950759517595275953759547595575956759577595875959759607596175962759637596475965759667596775968759697597075971759727597375974759757597675977759787597975980759817598275983759847598575986759877598875989759907599175992759937599475995759967599775998759997600076001760027600376004760057600676007760087600976010760117601276013760147601576016760177601876019760207602176022760237602476025760267602776028760297603076031760327603376034760357603676037760387603976040760417604276043760447604576046760477604876049760507605176052760537605476055760567605776058760597606076061760627606376064760657606676067760687606976070760717607276073760747607576076760777607876079760807608176082760837608476085760867608776088760897609076091760927609376094760957609676097760987609976100761017610276103761047610576106761077610876109761107611176112761137611476115761167611776118761197612076121761227612376124761257612676127761287612976130761317613276133761347613576136761377613876139761407614176142761437614476145761467614776148761497615076151761527615376154761557615676157761587615976160761617616276163761647616576166761677616876169761707617176172761737617476175761767617776178761797618076181761827618376184761857618676187761887618976190761917619276193761947619576196761977619876199762007620176202762037620476205762067620776208762097621076211762127621376214762157621676217762187621976220762217622276223762247622576226762277622876229762307623176232762337623476235762367623776238762397624076241762427624376244762457624676247762487624976250762517625276253762547625576256762577625876259762607626176262762637626476265762667626776268762697627076271762727627376274762757627676277762787627976280762817628276283762847628576286762877628876289762907629176292762937629476295762967629776298762997630076301763027630376304763057630676307763087630976310763117631276313763147631576316763177631876319763207632176322763237632476325763267632776328763297633076331763327633376334763357633676337763387633976340763417634276343763447634576346763477634876349763507635176352763537635476355763567635776358763597636076361763627636376364763657636676367763687636976370763717637276373763747637576376763777637876379763807638176382763837638476385763867638776388763897639076391763927639376394763957639676397763987639976400764017640276403764047640576406764077640876409764107641176412764137641476415764167641776418764197642076421764227642376424764257642676427764287642976430764317643276433764347643576436764377643876439764407644176442764437644476445764467644776448764497645076451764527645376454764557645676457764587645976460764617646276463764647646576466764677646876469764707647176472764737647476475764767647776478764797648076481764827648376484764857648676487764887648976490764917649276493764947649576496764977649876499765007650176502765037650476505765067650776508765097651076511765127651376514765157651676517765187651976520765217652276523765247652576526765277652876529765307653176532765337653476535765367653776538765397654076541765427654376544765457654676547765487654976550765517655276553765547655576556765577655876559765607656176562765637656476565765667656776568765697657076571765727657376574765757657676577765787657976580765817658276583765847658576586765877658876589765907659176592765937659476595765967659776598765997660076601766027660376604766057660676607766087660976610766117661276613766147661576616766177661876619766207662176622766237662476625766267662776628766297663076631766327663376634766357663676637766387663976640766417664276643766447664576646766477664876649766507665176652766537665476655766567665776658766597666076661766627666376664766657666676667766687666976670766717667276673766747667576676766777667876679766807668176682766837668476685766867668776688766897669076691766927669376694766957669676697766987669976700767017670276703767047670576706767077670876709767107671176712767137671476715767167671776718767197672076721767227672376724767257672676727767287672976730767317673276733767347673576736767377673876739767407674176742767437674476745767467674776748767497675076751767527675376754767557675676757767587675976760767617676276763767647676576766767677676876769767707677176772767737677476775767767677776778767797678076781767827678376784767857678676787767887678976790767917679276793767947679576796767977679876799768007680176802768037680476805768067680776808768097681076811768127681376814768157681676817768187681976820768217682276823768247682576826768277682876829768307683176832768337683476835768367683776838768397684076841768427684376844768457684676847768487684976850768517685276853768547685576856768577685876859768607686176862768637686476865768667686776868768697687076871768727687376874768757687676877768787687976880768817688276883768847688576886768877688876889768907689176892768937689476895768967689776898768997690076901769027690376904769057690676907769087690976910769117691276913769147691576916769177691876919769207692176922769237692476925769267692776928769297693076931769327693376934769357693676937769387693976940769417694276943769447694576946769477694876949769507695176952769537695476955769567695776958769597696076961769627696376964769657696676967769687696976970769717697276973769747697576976769777697876979769807698176982769837698476985769867698776988769897699076991769927699376994769957699676997769987699977000770017700277003770047700577006770077700877009770107701177012770137701477015770167701777018770197702077021770227702377024770257702677027770287702977030770317703277033770347703577036770377703877039770407704177042770437704477045770467704777048770497705077051770527705377054770557705677057770587705977060770617706277063770647706577066770677706877069770707707177072770737707477075770767707777078770797708077081770827708377084770857708677087770887708977090770917709277093770947709577096770977709877099771007710177102771037710477105771067710777108771097711077111771127711377114771157711677117771187711977120771217712277123771247712577126771277712877129771307713177132771337713477135771367713777138771397714077141771427714377144771457714677147771487714977150771517715277153771547715577156771577715877159771607716177162771637716477165771667716777168771697717077171771727717377174771757717677177771787717977180771817718277183771847718577186771877718877189771907719177192771937719477195771967719777198771997720077201772027720377204772057720677207772087720977210772117721277213772147721577216772177721877219772207722177222772237722477225772267722777228772297723077231772327723377234772357723677237772387723977240772417724277243772447724577246772477724877249772507725177252772537725477255772567725777258772597726077261772627726377264772657726677267772687726977270772717727277273772747727577276772777727877279772807728177282772837728477285772867728777288772897729077291772927729377294772957729677297772987729977300773017730277303773047730577306773077730877309773107731177312773137731477315773167731777318773197732077321773227732377324773257732677327773287732977330773317733277333773347733577336773377733877339773407734177342773437734477345773467734777348773497735077351773527735377354773557735677357773587735977360773617736277363773647736577366773677736877369773707737177372773737737477375773767737777378773797738077381773827738377384773857738677387773887738977390773917739277393773947739577396773977739877399774007740177402774037740477405774067740777408774097741077411774127741377414774157741677417774187741977420774217742277423774247742577426774277742877429774307743177432774337743477435774367743777438774397744077441774427744377444774457744677447774487744977450774517745277453774547745577456774577745877459774607746177462774637746477465774667746777468774697747077471774727747377474774757747677477774787747977480774817748277483774847748577486774877748877489774907749177492774937749477495774967749777498774997750077501775027750377504775057750677507775087750977510775117751277513775147751577516775177751877519775207752177522775237752477525775267752777528775297753077531775327753377534775357753677537775387753977540775417754277543775447754577546775477754877549775507755177552775537755477555775567755777558775597756077561775627756377564775657756677567775687756977570775717757277573775747757577576775777757877579775807758177582775837758477585775867758777588775897759077591775927759377594775957759677597775987759977600776017760277603776047760577606776077760877609776107761177612776137761477615776167761777618776197762077621776227762377624776257762677627776287762977630776317763277633776347763577636776377763877639776407764177642776437764477645776467764777648776497765077651776527765377654776557765677657776587765977660776617766277663776647766577666776677766877669776707767177672776737767477675776767767777678776797768077681776827768377684776857768677687776887768977690776917769277693776947769577696776977769877699777007770177702777037770477705777067770777708777097771077711777127771377714777157771677717777187771977720777217772277723777247772577726777277772877729777307773177732777337773477735777367773777738777397774077741777427774377744777457774677747777487774977750777517775277753777547775577756777577775877759777607776177762777637776477765777667776777768777697777077771777727777377774777757777677777777787777977780777817778277783777847778577786777877778877789777907779177792777937779477795777967779777798777997780077801778027780377804778057780677807778087780977810778117781277813778147781577816778177781877819778207782177822778237782477825778267782777828778297783077831778327783377834778357783677837778387783977840778417784277843778447784577846778477784877849778507785177852778537785477855778567785777858778597786077861778627786377864778657786677867778687786977870778717787277873778747787577876778777787877879778807788177882778837788477885778867788777888778897789077891778927789377894778957789677897778987789977900779017790277903779047790577906779077790877909779107791177912779137791477915779167791777918779197792077921779227792377924779257792677927779287792977930779317793277933779347793577936779377793877939779407794177942779437794477945779467794777948779497795077951779527795377954779557795677957779587795977960779617796277963779647796577966779677796877969779707797177972779737797477975779767797777978779797798077981779827798377984779857798677987779887798977990779917799277993779947799577996779977799877999780007800178002780037800478005780067800778008780097801078011780127801378014780157801678017780187801978020780217802278023780247802578026780277802878029780307803178032780337803478035780367803778038780397804078041780427804378044780457804678047780487804978050780517805278053780547805578056780577805878059780607806178062780637806478065780667806778068780697807078071780727807378074780757807678077780787807978080780817808278083780847808578086780877808878089780907809178092780937809478095780967809778098780997810078101781027810378104781057810678107781087810978110781117811278113781147811578116781177811878119781207812178122781237812478125781267812778128781297813078131781327813378134781357813678137781387813978140781417814278143781447814578146781477814878149781507815178152781537815478155781567815778158781597816078161781627816378164781657816678167781687816978170781717817278173781747817578176781777817878179781807818178182781837818478185781867818778188781897819078191781927819378194781957819678197781987819978200782017820278203782047820578206782077820878209782107821178212782137821478215782167821778218782197822078221782227822378224782257822678227782287822978230782317823278233782347823578236782377823878239782407824178242782437824478245782467824778248782497825078251782527825378254782557825678257782587825978260782617826278263782647826578266782677826878269782707827178272782737827478275782767827778278782797828078281782827828378284782857828678287782887828978290782917829278293782947829578296782977829878299783007830178302783037830478305783067830778308783097831078311783127831378314783157831678317783187831978320783217832278323783247832578326783277832878329783307833178332783337833478335783367833778338783397834078341783427834378344783457834678347783487834978350783517835278353783547835578356783577835878359783607836178362783637836478365783667836778368783697837078371783727837378374783757837678377783787837978380783817838278383783847838578386783877838878389783907839178392783937839478395783967839778398783997840078401784027840378404784057840678407784087840978410784117841278413784147841578416784177841878419784207842178422784237842478425784267842778428784297843078431784327843378434784357843678437784387843978440784417844278443784447844578446784477844878449784507845178452784537845478455784567845778458784597846078461784627846378464784657846678467784687846978470784717847278473784747847578476784777847878479784807848178482784837848478485784867848778488784897849078491784927849378494784957849678497784987849978500785017850278503785047850578506785077850878509785107851178512785137851478515785167851778518785197852078521785227852378524785257852678527785287852978530785317853278533785347853578536785377853878539785407854178542785437854478545785467854778548785497855078551785527855378554785557855678557785587855978560785617856278563785647856578566785677856878569785707857178572785737857478575785767857778578785797858078581785827858378584785857858678587785887858978590785917859278593785947859578596785977859878599786007860178602786037860478605786067860778608786097861078611786127861378614786157861678617786187861978620786217862278623786247862578626786277862878629786307863178632786337863478635786367863778638786397864078641786427864378644786457864678647786487864978650786517865278653786547865578656786577865878659786607866178662786637866478665786667866778668786697867078671786727867378674786757867678677786787867978680786817868278683786847868578686786877868878689786907869178692786937869478695786967869778698786997870078701787027870378704787057870678707787087870978710787117871278713787147871578716787177871878719787207872178722787237872478725787267872778728787297873078731787327873378734787357873678737787387873978740787417874278743787447874578746787477874878749787507875178752787537875478755787567875778758787597876078761787627876378764787657876678767787687876978770787717877278773787747877578776787777877878779787807878178782787837878478785787867878778788787897879078791787927879378794787957879678797787987879978800788017880278803788047880578806788077880878809788107881178812788137881478815788167881778818788197882078821788227882378824788257882678827788287882978830788317883278833788347883578836788377883878839788407884178842788437884478845788467884778848788497885078851788527885378854788557885678857788587885978860788617886278863788647886578866788677886878869788707887178872788737887478875788767887778878788797888078881788827888378884788857888678887788887888978890788917889278893788947889578896788977889878899789007890178902789037890478905789067890778908789097891078911789127891378914789157891678917789187891978920789217892278923789247892578926789277892878929789307893178932789337893478935789367893778938789397894078941789427894378944789457894678947789487894978950789517895278953789547895578956789577895878959789607896178962789637896478965789667896778968789697897078971789727897378974789757897678977789787897978980789817898278983789847898578986789877898878989789907899178992789937899478995789967899778998789997900079001790027900379004790057900679007790087900979010790117901279013790147901579016790177901879019790207902179022790237902479025790267902779028790297903079031790327903379034790357903679037790387903979040790417904279043790447904579046790477904879049790507905179052790537905479055790567905779058790597906079061790627906379064790657906679067790687906979070790717907279073790747907579076790777907879079790807908179082790837908479085790867908779088790897909079091790927909379094790957909679097790987909979100791017910279103791047910579106791077910879109791107911179112791137911479115791167911779118791197912079121791227912379124791257912679127791287912979130791317913279133791347913579136791377913879139791407914179142791437914479145791467914779148791497915079151791527915379154791557915679157791587915979160791617916279163791647916579166791677916879169791707917179172791737917479175791767917779178791797918079181791827918379184791857918679187791887918979190791917919279193791947919579196791977919879199792007920179202792037920479205792067920779208792097921079211792127921379214792157921679217792187921979220792217922279223792247922579226792277922879229792307923179232792337923479235792367923779238792397924079241792427924379244792457924679247792487924979250792517925279253792547925579256792577925879259792607926179262792637926479265792667926779268792697927079271792727927379274792757927679277792787927979280792817928279283792847928579286792877928879289792907929179292792937929479295792967929779298792997930079301793027930379304793057930679307793087930979310793117931279313793147931579316793177931879319793207932179322793237932479325793267932779328793297933079331793327933379334793357933679337793387933979340793417934279343793447934579346793477934879349793507935179352793537935479355793567935779358793597936079361793627936379364793657936679367793687936979370793717937279373793747937579376793777937879379793807938179382793837938479385793867938779388793897939079391793927939379394793957939679397793987939979400794017940279403794047940579406794077940879409794107941179412794137941479415794167941779418794197942079421794227942379424794257942679427794287942979430794317943279433794347943579436794377943879439794407944179442794437944479445794467944779448794497945079451794527945379454794557945679457794587945979460794617946279463794647946579466794677946879469794707947179472794737947479475794767947779478794797948079481794827948379484794857948679487794887948979490794917949279493794947949579496794977949879499795007950179502795037950479505795067950779508795097951079511795127951379514795157951679517795187951979520795217952279523795247952579526795277952879529795307953179532795337953479535795367953779538795397954079541795427954379544795457954679547795487954979550795517955279553795547955579556795577955879559795607956179562795637956479565795667956779568795697957079571795727957379574795757957679577795787957979580795817958279583795847958579586795877958879589795907959179592795937959479595795967959779598795997960079601796027960379604796057960679607796087960979610796117961279613796147961579616796177961879619796207962179622796237962479625796267962779628796297963079631796327963379634796357963679637796387963979640796417964279643796447964579646796477964879649796507965179652796537965479655796567965779658796597966079661796627966379664796657966679667796687966979670796717967279673796747967579676796777967879679796807968179682796837968479685796867968779688796897969079691796927969379694796957969679697796987969979700797017970279703797047970579706797077970879709797107971179712797137971479715797167971779718797197972079721797227972379724797257972679727797287972979730797317973279733797347973579736797377973879739797407974179742797437974479745797467974779748797497975079751797527975379754797557975679757797587975979760797617976279763797647976579766797677976879769797707977179772797737977479775797767977779778797797978079781797827978379784797857978679787797887978979790797917979279793797947979579796797977979879799798007980179802798037980479805798067980779808798097981079811798127981379814798157981679817798187981979820798217982279823798247982579826798277982879829798307983179832798337983479835798367983779838798397984079841798427984379844798457984679847798487984979850798517985279853798547985579856798577985879859798607986179862798637986479865798667986779868798697987079871798727987379874798757987679877798787987979880798817988279883798847988579886798877988879889798907989179892798937989479895798967989779898798997990079901799027990379904799057990679907799087990979910799117991279913799147991579916799177991879919799207992179922799237992479925799267992779928799297993079931799327993379934799357993679937799387993979940799417994279943799447994579946799477994879949799507995179952799537995479955799567995779958799597996079961799627996379964799657996679967799687996979970799717997279973799747997579976799777997879979799807998179982799837998479985799867998779988799897999079991799927999379994799957999679997799987999980000800018000280003800048000580006800078000880009800108001180012800138001480015800168001780018800198002080021800228002380024800258002680027800288002980030800318003280033800348003580036800378003880039800408004180042800438004480045800468004780048800498005080051800528005380054800558005680057800588005980060800618006280063800648006580066800678006880069800708007180072800738007480075800768007780078800798008080081800828008380084800858008680087800888008980090800918009280093800948009580096800978009880099801008010180102801038010480105801068010780108801098011080111801128011380114801158011680117801188011980120801218012280123801248012580126801278012880129801308013180132801338013480135801368013780138801398014080141801428014380144801458014680147801488014980150801518015280153801548015580156801578015880159801608016180162801638016480165801668016780168801698017080171801728017380174801758017680177801788017980180801818018280183801848018580186801878018880189801908019180192801938019480195801968019780198801998020080201802028020380204802058020680207802088020980210802118021280213802148021580216802178021880219802208022180222802238022480225802268022780228802298023080231802328023380234802358023680237802388023980240802418024280243802448024580246802478024880249802508025180252802538025480255802568025780258802598026080261802628026380264802658026680267802688026980270802718027280273802748027580276802778027880279802808028180282802838028480285802868028780288802898029080291802928029380294802958029680297802988029980300803018030280303803048030580306803078030880309803108031180312803138031480315803168031780318803198032080321803228032380324803258032680327803288032980330803318033280333803348033580336803378033880339803408034180342803438034480345803468034780348803498035080351803528035380354803558035680357803588035980360803618036280363803648036580366803678036880369803708037180372803738037480375803768037780378803798038080381803828038380384803858038680387803888038980390803918039280393803948039580396803978039880399804008040180402804038040480405804068040780408804098041080411804128041380414804158041680417804188041980420804218042280423804248042580426804278042880429804308043180432804338043480435804368043780438804398044080441804428044380444804458044680447804488044980450804518045280453804548045580456804578045880459804608046180462804638046480465804668046780468804698047080471804728047380474804758047680477804788047980480804818048280483804848048580486804878048880489804908049180492804938049480495804968049780498804998050080501805028050380504805058050680507805088050980510805118051280513805148051580516805178051880519805208052180522805238052480525805268052780528805298053080531805328053380534805358053680537805388053980540805418054280543805448054580546805478054880549805508055180552805538055480555805568055780558805598056080561805628056380564805658056680567805688056980570805718057280573805748057580576805778057880579805808058180582805838058480585805868058780588805898059080591805928059380594805958059680597805988059980600806018060280603806048060580606806078060880609806108061180612806138061480615806168061780618806198062080621806228062380624806258062680627806288062980630806318063280633806348063580636806378063880639806408064180642806438064480645806468064780648806498065080651806528065380654806558065680657806588065980660806618066280663806648066580666806678066880669806708067180672806738067480675806768067780678806798068080681806828068380684806858068680687806888068980690806918069280693806948069580696806978069880699807008070180702807038070480705807068070780708807098071080711807128071380714807158071680717807188071980720807218072280723807248072580726807278072880729807308073180732807338073480735807368073780738807398074080741807428074380744807458074680747807488074980750807518075280753807548075580756807578075880759807608076180762807638076480765807668076780768807698077080771807728077380774807758077680777807788077980780807818078280783807848078580786807878078880789807908079180792807938079480795807968079780798807998080080801808028080380804808058080680807808088080980810808118081280813808148081580816808178081880819808208082180822808238082480825808268082780828808298083080831808328083380834808358083680837808388083980840808418084280843808448084580846808478084880849808508085180852808538085480855808568085780858808598086080861808628086380864808658086680867808688086980870808718087280873808748087580876808778087880879808808088180882808838088480885808868088780888808898089080891808928089380894808958089680897808988089980900809018090280903809048090580906809078090880909809108091180912809138091480915809168091780918809198092080921809228092380924809258092680927809288092980930809318093280933809348093580936809378093880939809408094180942809438094480945809468094780948809498095080951809528095380954809558095680957809588095980960809618096280963809648096580966809678096880969809708097180972809738097480975809768097780978809798098080981809828098380984809858098680987809888098980990809918099280993809948099580996809978099880999810008100181002810038100481005810068100781008810098101081011810128101381014810158101681017810188101981020810218102281023810248102581026810278102881029810308103181032810338103481035810368103781038810398104081041810428104381044810458104681047810488104981050810518105281053810548105581056810578105881059810608106181062810638106481065810668106781068810698107081071810728107381074810758107681077810788107981080810818108281083810848108581086810878108881089810908109181092810938109481095810968109781098810998110081101811028110381104811058110681107811088110981110811118111281113811148111581116811178111881119811208112181122811238112481125811268112781128811298113081131811328113381134811358113681137811388113981140811418114281143811448114581146811478114881149811508115181152811538115481155811568115781158811598116081161811628116381164811658116681167811688116981170811718117281173811748117581176811778117881179811808118181182811838118481185811868118781188811898119081191811928119381194811958119681197811988119981200812018120281203812048120581206812078120881209812108121181212812138121481215812168121781218812198122081221812228122381224812258122681227812288122981230812318123281233812348123581236812378123881239812408124181242812438124481245812468124781248812498125081251812528125381254812558125681257812588125981260812618126281263812648126581266812678126881269812708127181272812738127481275812768127781278812798128081281812828128381284812858128681287812888128981290812918129281293812948129581296812978129881299813008130181302813038130481305813068130781308813098131081311813128131381314813158131681317813188131981320813218132281323813248132581326813278132881329813308133181332813338133481335813368133781338813398134081341813428134381344813458134681347813488134981350813518135281353813548135581356813578135881359813608136181362813638136481365813668136781368813698137081371813728137381374813758137681377813788137981380813818138281383813848138581386813878138881389813908139181392813938139481395813968139781398813998140081401814028140381404814058140681407814088140981410814118141281413814148141581416814178141881419814208142181422814238142481425814268142781428814298143081431814328143381434814358143681437814388143981440814418144281443814448144581446814478144881449814508145181452814538145481455814568145781458814598146081461814628146381464814658146681467814688146981470814718147281473814748147581476814778147881479814808148181482814838148481485814868148781488814898149081491814928149381494814958149681497814988149981500815018150281503815048150581506815078150881509815108151181512815138151481515815168151781518815198152081521815228152381524815258152681527815288152981530815318153281533815348153581536815378153881539815408154181542815438154481545815468154781548815498155081551815528155381554815558155681557815588155981560815618156281563815648156581566815678156881569815708157181572815738157481575815768157781578815798158081581815828158381584815858158681587815888158981590815918159281593815948159581596815978159881599816008160181602816038160481605816068160781608816098161081611816128161381614816158161681617816188161981620816218162281623816248162581626816278162881629816308163181632816338163481635816368163781638816398164081641816428164381644816458164681647816488164981650816518165281653816548165581656816578165881659816608166181662816638166481665816668166781668816698167081671816728167381674816758167681677816788167981680816818168281683816848168581686816878168881689816908169181692816938169481695816968169781698816998170081701817028170381704817058170681707817088170981710817118171281713817148171581716817178171881719817208172181722817238172481725817268172781728817298173081731817328173381734817358173681737817388173981740817418174281743817448174581746817478174881749817508175181752817538175481755817568175781758817598176081761817628176381764817658176681767817688176981770817718177281773817748177581776817778177881779817808178181782817838178481785817868178781788817898179081791817928179381794817958179681797817988179981800818018180281803818048180581806818078180881809818108181181812818138181481815818168181781818818198182081821818228182381824818258182681827818288182981830818318183281833818348183581836818378183881839818408184181842818438184481845818468184781848818498185081851818528185381854818558185681857818588185981860818618186281863818648186581866818678186881869818708187181872818738187481875818768187781878818798188081881818828188381884818858188681887818888188981890818918189281893818948189581896818978189881899819008190181902819038190481905819068190781908819098191081911819128191381914819158191681917819188191981920819218192281923819248192581926819278192881929819308193181932819338193481935819368193781938819398194081941819428194381944819458194681947819488194981950819518195281953819548195581956819578195881959819608196181962819638196481965819668196781968819698197081971819728197381974819758197681977819788197981980819818198281983819848198581986819878198881989819908199181992819938199481995819968199781998819998200082001820028200382004820058200682007820088200982010820118201282013820148201582016820178201882019820208202182022820238202482025820268202782028820298203082031820328203382034820358203682037820388203982040820418204282043820448204582046820478204882049820508205182052820538205482055820568205782058820598206082061820628206382064820658206682067820688206982070820718207282073820748207582076820778207882079820808208182082820838208482085820868208782088820898209082091820928209382094820958209682097820988209982100821018210282103821048210582106821078210882109821108211182112821138211482115821168211782118821198212082121821228212382124821258212682127821288212982130821318213282133821348213582136821378213882139821408214182142821438214482145821468214782148821498215082151821528215382154821558215682157821588215982160821618216282163821648216582166821678216882169821708217182172821738217482175821768217782178821798218082181821828218382184821858218682187821888218982190821918219282193821948219582196821978219882199822008220182202822038220482205822068220782208822098221082211822128221382214822158221682217822188221982220822218222282223822248222582226822278222882229822308223182232822338223482235822368223782238822398224082241822428224382244822458224682247822488224982250822518225282253822548225582256822578225882259822608226182262822638226482265822668226782268822698227082271822728227382274822758227682277822788227982280822818228282283822848228582286822878228882289822908229182292822938229482295822968229782298822998230082301823028230382304823058230682307823088230982310823118231282313823148231582316823178231882319823208232182322823238232482325823268232782328823298233082331823328233382334823358233682337823388233982340823418234282343823448234582346823478234882349823508235182352823538235482355823568235782358823598236082361823628236382364823658236682367823688236982370823718237282373823748237582376823778237882379823808238182382823838238482385823868238782388823898239082391823928239382394823958239682397823988239982400824018240282403824048240582406824078240882409824108241182412824138241482415824168241782418824198242082421824228242382424824258242682427824288242982430824318243282433824348243582436824378243882439824408244182442824438244482445824468244782448824498245082451824528245382454824558245682457824588245982460824618246282463824648246582466824678246882469824708247182472824738247482475824768247782478824798248082481824828248382484824858248682487824888248982490824918249282493824948249582496824978249882499825008250182502825038250482505825068250782508825098251082511825128251382514825158251682517825188251982520825218252282523825248252582526825278252882529825308253182532825338253482535825368253782538825398254082541825428254382544825458254682547825488254982550825518255282553825548255582556825578255882559825608256182562825638256482565825668256782568825698257082571825728257382574825758257682577825788257982580825818258282583825848258582586825878258882589825908259182592825938259482595825968259782598825998260082601826028260382604826058260682607826088260982610826118261282613826148261582616826178261882619826208262182622826238262482625826268262782628826298263082631826328263382634826358263682637826388263982640826418264282643826448264582646826478264882649826508265182652826538265482655826568265782658826598266082661826628266382664826658266682667826688266982670826718267282673826748267582676826778267882679826808268182682826838268482685826868268782688826898269082691826928269382694826958269682697826988269982700827018270282703827048270582706827078270882709827108271182712827138271482715827168271782718827198272082721827228272382724827258272682727827288272982730827318273282733827348273582736827378273882739827408274182742827438274482745827468274782748827498275082751827528275382754827558275682757827588275982760827618276282763827648276582766827678276882769827708277182772827738277482775827768277782778827798278082781827828278382784827858278682787827888278982790827918279282793827948279582796827978279882799828008280182802828038280482805828068280782808828098281082811828128281382814828158281682817828188281982820828218282282823828248282582826828278282882829828308283182832828338283482835828368283782838828398284082841828428284382844828458284682847828488284982850828518285282853828548285582856828578285882859828608286182862828638286482865828668286782868828698287082871828728287382874828758287682877828788287982880828818288282883828848288582886828878288882889828908289182892828938289482895828968289782898828998290082901829028290382904829058290682907829088290982910829118291282913829148291582916829178291882919829208292182922829238292482925829268292782928829298293082931829328293382934829358293682937829388293982940829418294282943829448294582946829478294882949829508295182952829538295482955829568295782958829598296082961829628296382964829658296682967829688296982970829718297282973829748297582976829778297882979829808298182982829838298482985829868298782988829898299082991829928299382994829958299682997829988299983000830018300283003830048300583006830078300883009830108301183012830138301483015830168301783018830198302083021830228302383024830258302683027830288302983030830318303283033830348303583036830378303883039830408304183042830438304483045830468304783048830498305083051830528305383054830558305683057830588305983060830618306283063830648306583066830678306883069830708307183072830738307483075830768307783078830798308083081830828308383084830858308683087830888308983090830918309283093830948309583096830978309883099831008310183102831038310483105831068310783108831098311083111831128311383114831158311683117831188311983120831218312283123831248312583126831278312883129831308313183132831338313483135831368313783138831398314083141831428314383144831458314683147831488314983150831518315283153831548315583156831578315883159831608316183162831638316483165831668316783168831698317083171831728317383174831758317683177831788317983180831818318283183831848318583186831878318883189831908319183192831938319483195831968319783198831998320083201832028320383204832058320683207832088320983210832118321283213832148321583216832178321883219832208322183222832238322483225832268322783228832298323083231832328323383234832358323683237832388323983240832418324283243832448324583246832478324883249832508325183252832538325483255832568325783258832598326083261832628326383264832658326683267832688326983270832718327283273832748327583276832778327883279832808328183282832838328483285832868328783288832898329083291832928329383294832958329683297832988329983300833018330283303833048330583306833078330883309833108331183312833138331483315833168331783318833198332083321833228332383324833258332683327833288332983330833318333283333833348333583336833378333883339833408334183342833438334483345833468334783348833498335083351833528335383354833558335683357833588335983360833618336283363833648336583366833678336883369833708337183372833738337483375833768337783378833798338083381833828338383384833858338683387833888338983390833918339283393833948339583396833978339883399834008340183402834038340483405834068340783408834098341083411834128341383414834158341683417834188341983420834218342283423834248342583426834278342883429834308343183432834338343483435834368343783438834398344083441834428344383444834458344683447834488344983450834518345283453834548345583456834578345883459834608346183462834638346483465834668346783468834698347083471834728347383474834758347683477834788347983480834818348283483834848348583486834878348883489834908349183492834938349483495834968349783498834998350083501835028350383504835058350683507835088350983510835118351283513835148351583516835178351883519835208352183522835238352483525835268352783528835298353083531835328353383534835358353683537835388353983540835418354283543835448354583546835478354883549835508355183552835538355483555835568355783558835598356083561835628356383564835658356683567835688356983570835718357283573835748357583576835778357883579835808358183582835838358483585835868358783588835898359083591835928359383594835958359683597835988359983600836018360283603836048360583606836078360883609836108361183612836138361483615836168361783618836198362083621836228362383624836258362683627836288362983630836318363283633836348363583636836378363883639836408364183642836438364483645836468364783648836498365083651836528365383654836558365683657836588365983660836618366283663836648366583666836678366883669836708367183672836738367483675836768367783678836798368083681836828368383684836858368683687836888368983690836918369283693836948369583696836978369883699837008370183702837038370483705837068370783708837098371083711837128371383714837158371683717837188371983720837218372283723837248372583726837278372883729837308373183732837338373483735837368373783738837398374083741837428374383744837458374683747837488374983750837518375283753837548375583756837578375883759837608376183762837638376483765837668376783768837698377083771837728377383774837758377683777837788377983780837818378283783837848378583786837878378883789837908379183792837938379483795837968379783798837998380083801838028380383804838058380683807838088380983810838118381283813838148381583816838178381883819838208382183822838238382483825838268382783828838298383083831838328383383834838358383683837838388383983840838418384283843838448384583846838478384883849838508385183852838538385483855838568385783858838598386083861838628386383864838658386683867838688386983870838718387283873838748387583876838778387883879838808388183882838838388483885838868388783888838898389083891838928389383894838958389683897838988389983900839018390283903839048390583906839078390883909839108391183912839138391483915839168391783918839198392083921839228392383924839258392683927839288392983930839318393283933839348393583936839378393883939839408394183942839438394483945839468394783948839498395083951839528395383954839558395683957839588395983960839618396283963839648396583966839678396883969839708397183972839738397483975839768397783978839798398083981839828398383984839858398683987839888398983990839918399283993839948399583996839978399883999840008400184002840038400484005840068400784008840098401084011840128401384014840158401684017840188401984020840218402284023840248402584026840278402884029840308403184032840338403484035840368403784038840398404084041840428404384044840458404684047840488404984050840518405284053840548405584056840578405884059840608406184062840638406484065840668406784068840698407084071840728407384074840758407684077840788407984080840818408284083840848408584086840878408884089840908409184092840938409484095840968409784098840998410084101841028410384104841058410684107841088410984110841118411284113841148411584116841178411884119841208412184122841238412484125841268412784128841298413084131841328413384134841358413684137841388413984140841418414284143841448414584146841478414884149841508415184152841538415484155841568415784158841598416084161841628416384164841658416684167841688416984170841718417284173841748417584176841778417884179841808418184182841838418484185841868418784188841898419084191841928419384194841958419684197841988419984200842018420284203842048420584206842078420884209842108421184212842138421484215842168421784218842198422084221842228422384224842258422684227842288422984230842318423284233842348423584236842378423884239842408424184242842438424484245842468424784248842498425084251842528425384254842558425684257842588425984260842618426284263842648426584266842678426884269842708427184272842738427484275842768427784278842798428084281842828428384284842858428684287842888428984290842918429284293842948429584296842978429884299843008430184302843038430484305843068430784308843098431084311843128431384314843158431684317843188431984320843218432284323843248432584326843278432884329843308433184332843338433484335843368433784338843398434084341843428434384344843458434684347843488434984350843518435284353843548435584356843578435884359843608436184362843638436484365843668436784368843698437084371843728437384374843758437684377843788437984380843818438284383843848438584386843878438884389843908439184392843938439484395843968439784398843998440084401844028440384404844058440684407844088440984410844118441284413844148441584416844178441884419844208442184422844238442484425844268442784428844298443084431844328443384434844358443684437844388443984440844418444284443844448444584446844478444884449844508445184452844538445484455844568445784458844598446084461844628446384464844658446684467844688446984470844718447284473844748447584476844778447884479844808448184482844838448484485844868448784488844898449084491844928449384494844958449684497844988449984500845018450284503845048450584506845078450884509845108451184512845138451484515845168451784518845198452084521845228452384524845258452684527845288452984530845318453284533845348453584536845378453884539845408454184542845438454484545845468454784548845498455084551845528455384554845558455684557845588455984560845618456284563845648456584566845678456884569845708457184572845738457484575845768457784578845798458084581845828458384584845858458684587845888458984590845918459284593845948459584596845978459884599846008460184602846038460484605846068460784608846098461084611846128461384614846158461684617846188461984620846218462284623846248462584626846278462884629846308463184632846338463484635846368463784638846398464084641846428464384644846458464684647846488464984650846518465284653846548465584656846578465884659846608466184662846638466484665846668466784668846698467084671846728467384674846758467684677846788467984680846818468284683846848468584686846878468884689846908469184692846938469484695846968469784698846998470084701847028470384704847058470684707847088470984710847118471284713847148471584716847178471884719847208472184722847238472484725847268472784728847298473084731847328473384734847358473684737847388473984740847418474284743847448474584746847478474884749847508475184752847538475484755847568475784758847598476084761847628476384764847658476684767847688476984770847718477284773847748477584776847778477884779847808478184782847838478484785847868478784788847898479084791847928479384794847958479684797847988479984800848018480284803848048480584806848078480884809848108481184812848138481484815848168481784818848198482084821848228482384824848258482684827848288482984830848318483284833848348483584836848378483884839848408484184842848438484484845848468484784848848498485084851848528485384854848558485684857848588485984860848618486284863848648486584866848678486884869848708487184872848738487484875848768487784878848798488084881848828488384884848858488684887848888488984890848918489284893848948489584896848978489884899849008490184902849038490484905849068490784908849098491084911849128491384914849158491684917849188491984920849218492284923849248492584926849278492884929849308493184932849338493484935849368493784938849398494084941849428494384944849458494684947849488494984950849518495284953849548495584956849578495884959849608496184962849638496484965849668496784968849698497084971849728497384974849758497684977849788497984980849818498284983849848498584986849878498884989849908499184992849938499484995849968499784998849998500085001850028500385004850058500685007850088500985010850118501285013850148501585016850178501885019850208502185022850238502485025850268502785028850298503085031850328503385034850358503685037850388503985040850418504285043850448504585046850478504885049850508505185052850538505485055850568505785058850598506085061850628506385064850658506685067850688506985070850718507285073850748507585076850778507885079850808508185082850838508485085850868508785088850898509085091850928509385094850958509685097850988509985100851018510285103851048510585106851078510885109851108511185112851138511485115851168511785118851198512085121851228512385124851258512685127851288512985130851318513285133851348513585136851378513885139851408514185142851438514485145851468514785148851498515085151851528515385154851558515685157851588515985160851618516285163851648516585166851678516885169851708517185172851738517485175851768517785178851798518085181851828518385184851858518685187851888518985190851918519285193851948519585196851978519885199852008520185202852038520485205852068520785208852098521085211852128521385214852158521685217852188521985220852218522285223852248522585226852278522885229852308523185232852338523485235852368523785238852398524085241852428524385244852458524685247852488524985250852518525285253852548525585256852578525885259852608526185262852638526485265852668526785268852698527085271852728527385274852758527685277852788527985280852818528285283852848528585286852878528885289852908529185292852938529485295852968529785298852998530085301853028530385304853058530685307853088530985310853118531285313853148531585316853178531885319853208532185322853238532485325853268532785328853298533085331853328533385334853358533685337853388533985340853418534285343853448534585346853478534885349853508535185352853538535485355853568535785358853598536085361853628536385364853658536685367853688536985370853718537285373853748537585376853778537885379853808538185382853838538485385853868538785388853898539085391853928539385394853958539685397853988539985400854018540285403854048540585406854078540885409854108541185412854138541485415854168541785418854198542085421854228542385424854258542685427854288542985430854318543285433854348543585436854378543885439854408544185442854438544485445854468544785448854498545085451854528545385454854558545685457854588545985460854618546285463854648546585466854678546885469854708547185472854738547485475854768547785478854798548085481854828548385484854858548685487854888548985490854918549285493854948549585496854978549885499855008550185502855038550485505855068550785508855098551085511855128551385514855158551685517855188551985520855218552285523855248552585526855278552885529855308553185532855338553485535855368553785538855398554085541855428554385544855458554685547855488554985550855518555285553855548555585556855578555885559855608556185562855638556485565855668556785568855698557085571855728557385574855758557685577855788557985580855818558285583855848558585586855878558885589855908559185592855938559485595855968559785598855998560085601856028560385604856058560685607856088560985610856118561285613856148561585616856178561885619856208562185622856238562485625856268562785628856298563085631856328563385634856358563685637856388563985640856418564285643856448564585646856478564885649856508565185652856538565485655856568565785658856598566085661856628566385664856658566685667856688566985670856718567285673856748567585676856778567885679856808568185682856838568485685856868568785688856898569085691856928569385694856958569685697856988569985700857018570285703857048570585706857078570885709857108571185712857138571485715857168571785718857198572085721857228572385724857258572685727857288572985730857318573285733857348573585736857378573885739857408574185742857438574485745857468574785748857498575085751857528575385754857558575685757857588575985760857618576285763857648576585766857678576885769857708577185772857738577485775857768577785778857798578085781857828578385784857858578685787857888578985790857918579285793857948579585796857978579885799858008580185802858038580485805858068580785808858098581085811858128581385814858158581685817858188581985820858218582285823858248582585826858278582885829858308583185832858338583485835858368583785838858398584085841858428584385844858458584685847858488584985850858518585285853858548585585856858578585885859858608586185862858638586485865858668586785868858698587085871858728587385874858758587685877858788587985880858818588285883858848588585886858878588885889858908589185892858938589485895858968589785898858998590085901859028590385904859058590685907859088590985910859118591285913859148591585916859178591885919859208592185922859238592485925859268592785928859298593085931859328593385934859358593685937859388593985940859418594285943859448594585946859478594885949859508595185952859538595485955859568595785958859598596085961859628596385964859658596685967859688596985970859718597285973859748597585976859778597885979859808598185982859838598485985859868598785988859898599085991859928599385994859958599685997859988599986000860018600286003860048600586006860078600886009860108601186012860138601486015860168601786018860198602086021860228602386024860258602686027860288602986030860318603286033860348603586036860378603886039860408604186042860438604486045860468604786048860498605086051860528605386054860558605686057860588605986060860618606286063860648606586066860678606886069860708607186072860738607486075860768607786078860798608086081860828608386084860858608686087860888608986090860918609286093860948609586096860978609886099861008610186102861038610486105861068610786108861098611086111861128611386114861158611686117861188611986120861218612286123861248612586126861278612886129861308613186132861338613486135861368613786138861398614086141861428614386144861458614686147861488614986150861518615286153861548615586156861578615886159861608616186162861638616486165861668616786168861698617086171861728617386174861758617686177861788617986180861818618286183861848618586186861878618886189861908619186192861938619486195861968619786198861998620086201862028620386204862058620686207862088620986210862118621286213862148621586216862178621886219862208622186222862238622486225862268622786228862298623086231862328623386234862358623686237862388623986240862418624286243862448624586246862478624886249862508625186252862538625486255862568625786258862598626086261862628626386264862658626686267862688626986270862718627286273862748627586276862778627886279862808628186282862838628486285862868628786288862898629086291862928629386294862958629686297862988629986300863018630286303863048630586306863078630886309863108631186312863138631486315863168631786318863198632086321863228632386324863258632686327863288632986330863318633286333863348633586336863378633886339863408634186342863438634486345863468634786348863498635086351863528635386354863558635686357863588635986360863618636286363863648636586366863678636886369863708637186372863738637486375863768637786378863798638086381863828638386384863858638686387863888638986390863918639286393863948639586396863978639886399864008640186402864038640486405864068640786408864098641086411864128641386414864158641686417864188641986420864218642286423864248642586426864278642886429864308643186432864338643486435864368643786438864398644086441864428644386444864458644686447864488644986450864518645286453864548645586456864578645886459864608646186462864638646486465864668646786468864698647086471864728647386474864758647686477864788647986480864818648286483864848648586486864878648886489864908649186492864938649486495864968649786498864998650086501865028650386504865058650686507865088650986510865118651286513865148651586516865178651886519865208652186522865238652486525865268652786528865298653086531865328653386534865358653686537865388653986540865418654286543865448654586546865478654886549865508655186552865538655486555865568655786558865598656086561865628656386564865658656686567865688656986570865718657286573865748657586576865778657886579865808658186582865838658486585865868658786588865898659086591865928659386594865958659686597865988659986600866018660286603866048660586606866078660886609866108661186612866138661486615866168661786618866198662086621866228662386624866258662686627866288662986630866318663286633866348663586636866378663886639866408664186642866438664486645866468664786648866498665086651866528665386654866558665686657866588665986660866618666286663866648666586666866678666886669866708667186672866738667486675866768667786678866798668086681866828668386684866858668686687866888668986690866918669286693866948669586696866978669886699867008670186702867038670486705867068670786708867098671086711867128671386714867158671686717867188671986720867218672286723867248672586726867278672886729867308673186732867338673486735867368673786738867398674086741867428674386744867458674686747867488674986750867518675286753867548675586756867578675886759867608676186762867638676486765867668676786768867698677086771867728677386774867758677686777867788677986780867818678286783867848678586786867878678886789867908679186792867938679486795867968679786798867998680086801868028680386804868058680686807868088680986810868118681286813868148681586816868178681886819868208682186822868238682486825868268682786828868298683086831868328683386834868358683686837868388683986840868418684286843868448684586846868478684886849868508685186852868538685486855868568685786858868598686086861868628686386864868658686686867868688686986870868718687286873868748687586876868778687886879868808688186882868838688486885868868688786888868898689086891868928689386894868958689686897868988689986900869018690286903869048690586906869078690886909869108691186912869138691486915869168691786918869198692086921869228692386924869258692686927869288692986930869318693286933869348693586936869378693886939869408694186942869438694486945869468694786948869498695086951869528695386954869558695686957869588695986960869618696286963869648696586966869678696886969869708697186972869738697486975869768697786978869798698086981869828698386984869858698686987869888698986990869918699286993869948699586996869978699886999870008700187002870038700487005870068700787008870098701087011870128701387014870158701687017870188701987020870218702287023870248702587026870278702887029870308703187032870338703487035870368703787038870398704087041870428704387044870458704687047870488704987050870518705287053870548705587056870578705887059870608706187062870638706487065870668706787068870698707087071870728707387074870758707687077870788707987080870818708287083870848708587086870878708887089870908709187092870938709487095870968709787098870998710087101871028710387104871058710687107871088710987110871118711287113871148711587116871178711887119871208712187122871238712487125871268712787128871298713087131871328713387134871358713687137871388713987140871418714287143871448714587146871478714887149871508715187152871538715487155871568715787158871598716087161871628716387164871658716687167871688716987170871718717287173871748717587176871778717887179871808718187182871838718487185871868718787188871898719087191871928719387194871958719687197871988719987200872018720287203872048720587206872078720887209872108721187212872138721487215872168721787218872198722087221872228722387224872258722687227872288722987230872318723287233872348723587236872378723887239872408724187242872438724487245872468724787248872498725087251872528725387254872558725687257872588725987260872618726287263872648726587266872678726887269872708727187272872738727487275872768727787278872798728087281872828728387284872858728687287872888728987290872918729287293872948729587296872978729887299873008730187302873038730487305873068730787308873098731087311873128731387314873158731687317873188731987320873218732287323873248732587326873278732887329873308733187332873338733487335873368733787338873398734087341873428734387344873458734687347873488734987350873518735287353873548735587356873578735887359873608736187362873638736487365873668736787368873698737087371873728737387374873758737687377873788737987380873818738287383873848738587386873878738887389873908739187392873938739487395873968739787398873998740087401874028740387404874058740687407874088740987410874118741287413874148741587416874178741887419874208742187422874238742487425874268742787428874298743087431874328743387434874358743687437874388743987440874418744287443874448744587446874478744887449874508745187452874538745487455874568745787458874598746087461874628746387464874658746687467874688746987470874718747287473874748747587476874778747887479874808748187482874838748487485874868748787488874898749087491874928749387494874958749687497874988749987500875018750287503875048750587506875078750887509875108751187512875138751487515875168751787518875198752087521875228752387524875258752687527875288752987530875318753287533875348753587536875378753887539875408754187542875438754487545875468754787548875498755087551875528755387554875558755687557875588755987560875618756287563875648756587566875678756887569875708757187572875738757487575875768757787578875798758087581875828758387584875858758687587875888758987590875918759287593875948759587596875978759887599876008760187602876038760487605876068760787608876098761087611876128761387614876158761687617876188761987620876218762287623876248762587626876278762887629876308763187632876338763487635876368763787638876398764087641876428764387644876458764687647876488764987650876518765287653876548765587656876578765887659876608766187662876638766487665876668766787668876698767087671876728767387674876758767687677876788767987680876818768287683876848768587686876878768887689876908769187692876938769487695876968769787698876998770087701877028770387704877058770687707877088770987710877118771287713877148771587716877178771887719877208772187722877238772487725877268772787728877298773087731877328773387734877358773687737877388773987740877418774287743877448774587746877478774887749877508775187752877538775487755877568775787758877598776087761877628776387764877658776687767877688776987770877718777287773877748777587776877778777887779877808778187782877838778487785877868778787788877898779087791877928779387794877958779687797877988779987800878018780287803878048780587806878078780887809878108781187812878138781487815878168781787818878198782087821878228782387824878258782687827878288782987830878318783287833878348783587836878378783887839878408784187842878438784487845878468784787848878498785087851878528785387854878558785687857878588785987860878618786287863878648786587866878678786887869878708787187872878738787487875878768787787878878798788087881878828788387884878858788687887878888788987890878918789287893878948789587896878978789887899879008790187902879038790487905879068790787908879098791087911879128791387914879158791687917879188791987920879218792287923879248792587926879278792887929879308793187932879338793487935879368793787938879398794087941879428794387944879458794687947879488794987950879518795287953879548795587956879578795887959879608796187962879638796487965879668796787968879698797087971879728797387974879758797687977879788797987980879818798287983879848798587986879878798887989879908799187992879938799487995879968799787998879998800088001880028800388004880058800688007880088800988010880118801288013880148801588016880178801888019880208802188022880238802488025880268802788028880298803088031880328803388034880358803688037880388803988040880418804288043880448804588046880478804888049880508805188052880538805488055880568805788058880598806088061880628806388064880658806688067880688806988070880718807288073880748807588076880778807888079880808808188082880838808488085880868808788088880898809088091880928809388094880958809688097880988809988100881018810288103881048810588106881078810888109881108811188112881138811488115881168811788118881198812088121881228812388124881258812688127881288812988130881318813288133881348813588136881378813888139881408814188142881438814488145881468814788148881498815088151881528815388154881558815688157881588815988160881618816288163881648816588166881678816888169881708817188172881738817488175881768817788178881798818088181881828818388184881858818688187881888818988190881918819288193881948819588196881978819888199882008820188202882038820488205882068820788208882098821088211882128821388214882158821688217882188821988220882218822288223882248822588226882278822888229882308823188232882338823488235882368823788238882398824088241882428824388244882458824688247882488824988250882518825288253882548825588256882578825888259882608826188262882638826488265882668826788268882698827088271882728827388274882758827688277882788827988280882818828288283882848828588286882878828888289882908829188292882938829488295882968829788298882998830088301883028830388304883058830688307883088830988310883118831288313883148831588316883178831888319883208832188322883238832488325883268832788328883298833088331883328833388334883358833688337883388833988340883418834288343883448834588346883478834888349883508835188352883538835488355883568835788358883598836088361883628836388364883658836688367883688836988370883718837288373883748837588376883778837888379883808838188382883838838488385883868838788388883898839088391883928839388394883958839688397883988839988400884018840288403884048840588406884078840888409884108841188412884138841488415884168841788418884198842088421884228842388424884258842688427884288842988430
  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. * Define options used to create a depth texture
  7783. */
  7784. export class DepthTextureCreationOptions {
  7785. /** Specifies whether or not a stencil should be allocated in the texture */
  7786. generateStencil?: boolean;
  7787. /** Specifies whether or not bilinear filtering is enable on the texture */
  7788. bilinearFiltering?: boolean;
  7789. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7790. comparisonFunction?: number;
  7791. /** Specifies if the created texture is a cube texture */
  7792. isCube?: boolean;
  7793. }
  7794. }
  7795. declare module BABYLON {
  7796. interface ThinEngine {
  7797. /**
  7798. * Creates a depth stencil cube texture.
  7799. * This is only available in WebGL 2.
  7800. * @param size The size of face edge in the cube texture.
  7801. * @param options The options defining the cube texture.
  7802. * @returns The cube texture
  7803. */
  7804. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7805. /**
  7806. * Creates a cube texture
  7807. * @param rootUrl defines the url where the files to load is located
  7808. * @param scene defines the current scene
  7809. * @param files defines the list of files to load (1 per face)
  7810. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7811. * @param onLoad defines an optional callback raised when the texture is loaded
  7812. * @param onError defines an optional callback raised if there is an issue to load the texture
  7813. * @param format defines the format of the data
  7814. * @param forcedExtension defines the extension to use to pick the right loader
  7815. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7816. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7817. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7818. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7819. * @param loaderOptions options to be passed to the loader
  7820. * @returns the cube texture as an InternalTexture
  7821. */
  7822. 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;
  7823. /**
  7824. * Creates a cube texture
  7825. * @param rootUrl defines the url where the files to load is located
  7826. * @param scene defines the current scene
  7827. * @param files defines the list of files to load (1 per face)
  7828. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7829. * @param onLoad defines an optional callback raised when the texture is loaded
  7830. * @param onError defines an optional callback raised if there is an issue to load the texture
  7831. * @param format defines the format of the data
  7832. * @param forcedExtension defines the extension to use to pick the right loader
  7833. * @returns the cube texture as an InternalTexture
  7834. */
  7835. 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;
  7836. /**
  7837. * Creates a cube texture
  7838. * @param rootUrl defines the url where the files to load is located
  7839. * @param scene defines the current scene
  7840. * @param files defines the list of files to load (1 per face)
  7841. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7842. * @param onLoad defines an optional callback raised when the texture is loaded
  7843. * @param onError defines an optional callback raised if there is an issue to load the texture
  7844. * @param format defines the format of the data
  7845. * @param forcedExtension defines the extension to use to pick the right loader
  7846. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7847. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7848. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7849. * @returns the cube texture as an InternalTexture
  7850. */
  7851. 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;
  7852. /** @hidden */
  7853. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7854. /** @hidden */
  7855. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7856. /** @hidden */
  7857. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7858. /** @hidden */
  7859. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7860. /**
  7861. * @hidden
  7862. */
  7863. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  7864. }
  7865. }
  7866. declare module BABYLON {
  7867. /**
  7868. * Class for creating a cube texture
  7869. */
  7870. export class CubeTexture extends BaseTexture {
  7871. private _delayedOnLoad;
  7872. /**
  7873. * Observable triggered once the texture has been loaded.
  7874. */
  7875. onLoadObservable: Observable<CubeTexture>;
  7876. /**
  7877. * The url of the texture
  7878. */
  7879. url: string;
  7880. /**
  7881. * Gets or sets the center of the bounding box associated with the cube texture.
  7882. * It must define where the camera used to render the texture was set
  7883. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7884. */
  7885. boundingBoxPosition: Vector3;
  7886. private _boundingBoxSize;
  7887. /**
  7888. * Gets or sets the size of the bounding box associated with the cube texture
  7889. * When defined, the cubemap will switch to local mode
  7890. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7891. * @example https://www.babylonjs-playground.com/#RNASML
  7892. */
  7893. set boundingBoxSize(value: Vector3);
  7894. /**
  7895. * Returns the bounding box size
  7896. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7897. */
  7898. get boundingBoxSize(): Vector3;
  7899. protected _rotationY: number;
  7900. /**
  7901. * Sets texture matrix rotation angle around Y axis in radians.
  7902. */
  7903. set rotationY(value: number);
  7904. /**
  7905. * Gets texture matrix rotation angle around Y axis radians.
  7906. */
  7907. get rotationY(): number;
  7908. /**
  7909. * Are mip maps generated for this texture or not.
  7910. */
  7911. get noMipmap(): boolean;
  7912. private _noMipmap;
  7913. private _files;
  7914. protected _forcedExtension: Nullable<string>;
  7915. private _extensions;
  7916. private _textureMatrix;
  7917. private _format;
  7918. private _createPolynomials;
  7919. private _loaderOptions;
  7920. /**
  7921. * Creates a cube texture from an array of image urls
  7922. * @param files defines an array of image urls
  7923. * @param scene defines the hosting scene
  7924. * @param noMipmap specifies if mip maps are not used
  7925. * @returns a cube texture
  7926. */
  7927. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7928. /**
  7929. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7930. * @param url defines the url of the prefiltered texture
  7931. * @param scene defines the scene the texture is attached to
  7932. * @param forcedExtension defines the extension of the file if different from the url
  7933. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7934. * @return the prefiltered texture
  7935. */
  7936. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7937. /**
  7938. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7939. * as prefiltered data.
  7940. * @param rootUrl defines the url of the texture or the root name of the six images
  7941. * @param null defines the scene or engine the texture is attached to
  7942. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7943. * @param noMipmap defines if mipmaps should be created or not
  7944. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7945. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7946. * @param onError defines a callback triggered in case of error during load
  7947. * @param format defines the internal format to use for the texture once loaded
  7948. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7949. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7950. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7951. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7952. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7953. * @param loaderOptions options to be passed to the loader
  7954. * @return the cube texture
  7955. */
  7956. 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);
  7957. /**
  7958. * Get the current class name of the texture useful for serialization or dynamic coding.
  7959. * @returns "CubeTexture"
  7960. */
  7961. getClassName(): string;
  7962. /**
  7963. * Update the url (and optional buffer) of this texture if url was null during construction.
  7964. * @param url the url of the texture
  7965. * @param forcedExtension defines the extension to use
  7966. * @param onLoad callback called when the texture is loaded (defaults to null)
  7967. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7968. */
  7969. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7970. /**
  7971. * Delays loading of the cube texture
  7972. * @param forcedExtension defines the extension to use
  7973. */
  7974. delayLoad(forcedExtension?: string): void;
  7975. /**
  7976. * Returns the reflection texture matrix
  7977. * @returns the reflection texture matrix
  7978. */
  7979. getReflectionTextureMatrix(): Matrix;
  7980. /**
  7981. * Sets the reflection texture matrix
  7982. * @param value Reflection texture matrix
  7983. */
  7984. setReflectionTextureMatrix(value: Matrix): void;
  7985. /**
  7986. * Parses text to create a cube texture
  7987. * @param parsedTexture define the serialized text to read from
  7988. * @param scene defines the hosting scene
  7989. * @param rootUrl defines the root url of the cube texture
  7990. * @returns a cube texture
  7991. */
  7992. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7993. /**
  7994. * Makes a clone, or deep copy, of the cube texture
  7995. * @returns a new cube texture
  7996. */
  7997. clone(): CubeTexture;
  7998. }
  7999. }
  8000. declare module BABYLON {
  8001. /**
  8002. * Manages the defines for the Material
  8003. */
  8004. export class MaterialDefines {
  8005. /** @hidden */
  8006. protected _keys: string[];
  8007. private _isDirty;
  8008. /** @hidden */
  8009. _renderId: number;
  8010. /** @hidden */
  8011. _areLightsDirty: boolean;
  8012. /** @hidden */
  8013. _areLightsDisposed: boolean;
  8014. /** @hidden */
  8015. _areAttributesDirty: boolean;
  8016. /** @hidden */
  8017. _areTexturesDirty: boolean;
  8018. /** @hidden */
  8019. _areFresnelDirty: boolean;
  8020. /** @hidden */
  8021. _areMiscDirty: boolean;
  8022. /** @hidden */
  8023. _arePrePassDirty: boolean;
  8024. /** @hidden */
  8025. _areImageProcessingDirty: boolean;
  8026. /** @hidden */
  8027. _normals: boolean;
  8028. /** @hidden */
  8029. _uvs: boolean;
  8030. /** @hidden */
  8031. _needNormals: boolean;
  8032. /** @hidden */
  8033. _needUVs: boolean;
  8034. [id: string]: any;
  8035. /**
  8036. * Specifies if the material needs to be re-calculated
  8037. */
  8038. get isDirty(): boolean;
  8039. /**
  8040. * Marks the material to indicate that it has been re-calculated
  8041. */
  8042. markAsProcessed(): void;
  8043. /**
  8044. * Marks the material to indicate that it needs to be re-calculated
  8045. */
  8046. markAsUnprocessed(): void;
  8047. /**
  8048. * Marks the material to indicate all of its defines need to be re-calculated
  8049. */
  8050. markAllAsDirty(): void;
  8051. /**
  8052. * Marks the material to indicate that image processing needs to be re-calculated
  8053. */
  8054. markAsImageProcessingDirty(): void;
  8055. /**
  8056. * Marks the material to indicate the lights need to be re-calculated
  8057. * @param disposed Defines whether the light is dirty due to dispose or not
  8058. */
  8059. markAsLightDirty(disposed?: boolean): void;
  8060. /**
  8061. * Marks the attribute state as changed
  8062. */
  8063. markAsAttributesDirty(): void;
  8064. /**
  8065. * Marks the texture state as changed
  8066. */
  8067. markAsTexturesDirty(): void;
  8068. /**
  8069. * Marks the fresnel state as changed
  8070. */
  8071. markAsFresnelDirty(): void;
  8072. /**
  8073. * Marks the misc state as changed
  8074. */
  8075. markAsMiscDirty(): void;
  8076. /**
  8077. * Marks the prepass state as changed
  8078. */
  8079. markAsPrePassDirty(): void;
  8080. /**
  8081. * Rebuilds the material defines
  8082. */
  8083. rebuild(): void;
  8084. /**
  8085. * Specifies if two material defines are equal
  8086. * @param other - A material define instance to compare to
  8087. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8088. */
  8089. isEqual(other: MaterialDefines): boolean;
  8090. /**
  8091. * Clones this instance's defines to another instance
  8092. * @param other - material defines to clone values to
  8093. */
  8094. cloneTo(other: MaterialDefines): void;
  8095. /**
  8096. * Resets the material define values
  8097. */
  8098. reset(): void;
  8099. /**
  8100. * Converts the material define values to a string
  8101. * @returns - String of material define information
  8102. */
  8103. toString(): string;
  8104. }
  8105. }
  8106. declare module BABYLON {
  8107. /**
  8108. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8109. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8110. * 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;
  8111. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8112. */
  8113. export class ColorCurves {
  8114. private _dirty;
  8115. private _tempColor;
  8116. private _globalCurve;
  8117. private _highlightsCurve;
  8118. private _midtonesCurve;
  8119. private _shadowsCurve;
  8120. private _positiveCurve;
  8121. private _negativeCurve;
  8122. private _globalHue;
  8123. private _globalDensity;
  8124. private _globalSaturation;
  8125. private _globalExposure;
  8126. /**
  8127. * Gets the global Hue value.
  8128. * 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).
  8129. */
  8130. get globalHue(): number;
  8131. /**
  8132. * Sets the global Hue value.
  8133. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8134. */
  8135. set globalHue(value: number);
  8136. /**
  8137. * Gets the global Density value.
  8138. * 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.
  8139. * Values less than zero provide a filter of opposite hue.
  8140. */
  8141. get globalDensity(): number;
  8142. /**
  8143. * Sets the global Density value.
  8144. * 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.
  8145. * Values less than zero provide a filter of opposite hue.
  8146. */
  8147. set globalDensity(value: number);
  8148. /**
  8149. * Gets the global Saturation value.
  8150. * 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.
  8151. */
  8152. get globalSaturation(): number;
  8153. /**
  8154. * Sets the global Saturation value.
  8155. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8156. */
  8157. set globalSaturation(value: number);
  8158. /**
  8159. * Gets the global Exposure value.
  8160. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8161. */
  8162. get globalExposure(): number;
  8163. /**
  8164. * Sets the global Exposure value.
  8165. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8166. */
  8167. set globalExposure(value: number);
  8168. private _highlightsHue;
  8169. private _highlightsDensity;
  8170. private _highlightsSaturation;
  8171. private _highlightsExposure;
  8172. /**
  8173. * Gets the highlights Hue value.
  8174. * 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).
  8175. */
  8176. get highlightsHue(): number;
  8177. /**
  8178. * Sets the highlights Hue value.
  8179. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8180. */
  8181. set highlightsHue(value: number);
  8182. /**
  8183. * Gets the highlights Density value.
  8184. * 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.
  8185. * Values less than zero provide a filter of opposite hue.
  8186. */
  8187. get highlightsDensity(): number;
  8188. /**
  8189. * Sets the highlights Density value.
  8190. * 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.
  8191. * Values less than zero provide a filter of opposite hue.
  8192. */
  8193. set highlightsDensity(value: number);
  8194. /**
  8195. * Gets the highlights Saturation value.
  8196. * 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.
  8197. */
  8198. get highlightsSaturation(): number;
  8199. /**
  8200. * Sets the highlights Saturation value.
  8201. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8202. */
  8203. set highlightsSaturation(value: number);
  8204. /**
  8205. * Gets the highlights Exposure value.
  8206. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8207. */
  8208. get highlightsExposure(): number;
  8209. /**
  8210. * Sets the highlights Exposure value.
  8211. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8212. */
  8213. set highlightsExposure(value: number);
  8214. private _midtonesHue;
  8215. private _midtonesDensity;
  8216. private _midtonesSaturation;
  8217. private _midtonesExposure;
  8218. /**
  8219. * Gets the midtones Hue value.
  8220. * 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).
  8221. */
  8222. get midtonesHue(): number;
  8223. /**
  8224. * Sets the midtones Hue value.
  8225. * 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).
  8226. */
  8227. set midtonesHue(value: number);
  8228. /**
  8229. * Gets the midtones Density value.
  8230. * 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.
  8231. * Values less than zero provide a filter of opposite hue.
  8232. */
  8233. get midtonesDensity(): number;
  8234. /**
  8235. * Sets the midtones Density value.
  8236. * 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.
  8237. * Values less than zero provide a filter of opposite hue.
  8238. */
  8239. set midtonesDensity(value: number);
  8240. /**
  8241. * Gets the midtones Saturation value.
  8242. * 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.
  8243. */
  8244. get midtonesSaturation(): number;
  8245. /**
  8246. * Sets the midtones Saturation value.
  8247. * 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.
  8248. */
  8249. set midtonesSaturation(value: number);
  8250. /**
  8251. * Gets the midtones Exposure value.
  8252. * 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.
  8253. */
  8254. get midtonesExposure(): number;
  8255. /**
  8256. * Sets the midtones Exposure 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 exposure and negative values decrease exposure.
  8258. */
  8259. set midtonesExposure(value: number);
  8260. private _shadowsHue;
  8261. private _shadowsDensity;
  8262. private _shadowsSaturation;
  8263. private _shadowsExposure;
  8264. /**
  8265. * Gets the shadows Hue value.
  8266. * 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).
  8267. */
  8268. get shadowsHue(): number;
  8269. /**
  8270. * Sets the shadows Hue value.
  8271. * 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).
  8272. */
  8273. set shadowsHue(value: number);
  8274. /**
  8275. * Gets the shadows Density value.
  8276. * 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.
  8277. * Values less than zero provide a filter of opposite hue.
  8278. */
  8279. get shadowsDensity(): number;
  8280. /**
  8281. * Sets the shadows Density value.
  8282. * 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.
  8283. * Values less than zero provide a filter of opposite hue.
  8284. */
  8285. set shadowsDensity(value: number);
  8286. /**
  8287. * Gets the shadows Saturation value.
  8288. * 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.
  8289. */
  8290. get shadowsSaturation(): number;
  8291. /**
  8292. * Sets the shadows Saturation value.
  8293. * 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.
  8294. */
  8295. set shadowsSaturation(value: number);
  8296. /**
  8297. * Gets the shadows Exposure value.
  8298. * 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.
  8299. */
  8300. get shadowsExposure(): number;
  8301. /**
  8302. * Sets the shadows Exposure 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 exposure and negative values decrease exposure.
  8304. */
  8305. set shadowsExposure(value: number);
  8306. /**
  8307. * Returns the class name
  8308. * @returns The class name
  8309. */
  8310. getClassName(): string;
  8311. /**
  8312. * Binds the color curves to the shader.
  8313. * @param colorCurves The color curve to bind
  8314. * @param effect The effect to bind to
  8315. * @param positiveUniform The positive uniform shader parameter
  8316. * @param neutralUniform The neutral uniform shader parameter
  8317. * @param negativeUniform The negative uniform shader parameter
  8318. */
  8319. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8320. /**
  8321. * Prepare the list of uniforms associated with the ColorCurves effects.
  8322. * @param uniformsList The list of uniforms used in the effect
  8323. */
  8324. static PrepareUniforms(uniformsList: string[]): void;
  8325. /**
  8326. * Returns color grading data based on a hue, density, saturation and exposure value.
  8327. * @param filterHue The hue of the color filter.
  8328. * @param filterDensity The density of the color filter.
  8329. * @param saturation The saturation.
  8330. * @param exposure The exposure.
  8331. * @param result The result data container.
  8332. */
  8333. private getColorGradingDataToRef;
  8334. /**
  8335. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8336. * @param value The input slider value in range [-100,100].
  8337. * @returns Adjusted value.
  8338. */
  8339. private static applyColorGradingSliderNonlinear;
  8340. /**
  8341. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8342. * @param hue The hue (H) input.
  8343. * @param saturation The saturation (S) input.
  8344. * @param brightness The brightness (B) input.
  8345. * @result An RGBA color represented as Vector4.
  8346. */
  8347. private static fromHSBToRef;
  8348. /**
  8349. * Returns a value clamped between min and max
  8350. * @param value The value to clamp
  8351. * @param min The minimum of value
  8352. * @param max The maximum of value
  8353. * @returns The clamped value.
  8354. */
  8355. private static clamp;
  8356. /**
  8357. * Clones the current color curve instance.
  8358. * @return The cloned curves
  8359. */
  8360. clone(): ColorCurves;
  8361. /**
  8362. * Serializes the current color curve instance to a json representation.
  8363. * @return a JSON representation
  8364. */
  8365. serialize(): any;
  8366. /**
  8367. * Parses the color curve from a json representation.
  8368. * @param source the JSON source to parse
  8369. * @return The parsed curves
  8370. */
  8371. static Parse(source: any): ColorCurves;
  8372. }
  8373. }
  8374. declare module BABYLON {
  8375. /**
  8376. * Interface to follow in your material defines to integrate easily the
  8377. * Image proccessing functions.
  8378. * @hidden
  8379. */
  8380. export interface IImageProcessingConfigurationDefines {
  8381. IMAGEPROCESSING: boolean;
  8382. VIGNETTE: boolean;
  8383. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8384. VIGNETTEBLENDMODEOPAQUE: boolean;
  8385. TONEMAPPING: boolean;
  8386. TONEMAPPING_ACES: boolean;
  8387. CONTRAST: boolean;
  8388. EXPOSURE: boolean;
  8389. COLORCURVES: boolean;
  8390. COLORGRADING: boolean;
  8391. COLORGRADING3D: boolean;
  8392. SAMPLER3DGREENDEPTH: boolean;
  8393. SAMPLER3DBGRMAP: boolean;
  8394. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8395. }
  8396. /**
  8397. * @hidden
  8398. */
  8399. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8400. IMAGEPROCESSING: boolean;
  8401. VIGNETTE: boolean;
  8402. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8403. VIGNETTEBLENDMODEOPAQUE: boolean;
  8404. TONEMAPPING: boolean;
  8405. TONEMAPPING_ACES: boolean;
  8406. CONTRAST: boolean;
  8407. COLORCURVES: boolean;
  8408. COLORGRADING: boolean;
  8409. COLORGRADING3D: boolean;
  8410. SAMPLER3DGREENDEPTH: boolean;
  8411. SAMPLER3DBGRMAP: boolean;
  8412. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8413. EXPOSURE: boolean;
  8414. constructor();
  8415. }
  8416. /**
  8417. * This groups together the common properties used for image processing either in direct forward pass
  8418. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8419. * or not.
  8420. */
  8421. export class ImageProcessingConfiguration {
  8422. /**
  8423. * Default tone mapping applied in BabylonJS.
  8424. */
  8425. static readonly TONEMAPPING_STANDARD: number;
  8426. /**
  8427. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8428. * to other engines rendering to increase portability.
  8429. */
  8430. static readonly TONEMAPPING_ACES: number;
  8431. /**
  8432. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8433. */
  8434. colorCurves: Nullable<ColorCurves>;
  8435. private _colorCurvesEnabled;
  8436. /**
  8437. * Gets wether the color curves effect is enabled.
  8438. */
  8439. get colorCurvesEnabled(): boolean;
  8440. /**
  8441. * Sets wether the color curves effect is enabled.
  8442. */
  8443. set colorCurvesEnabled(value: boolean);
  8444. private _colorGradingTexture;
  8445. /**
  8446. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8447. */
  8448. get colorGradingTexture(): Nullable<BaseTexture>;
  8449. /**
  8450. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8451. */
  8452. set colorGradingTexture(value: Nullable<BaseTexture>);
  8453. private _colorGradingEnabled;
  8454. /**
  8455. * Gets wether the color grading effect is enabled.
  8456. */
  8457. get colorGradingEnabled(): boolean;
  8458. /**
  8459. * Sets wether the color grading effect is enabled.
  8460. */
  8461. set colorGradingEnabled(value: boolean);
  8462. private _colorGradingWithGreenDepth;
  8463. /**
  8464. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8465. */
  8466. get colorGradingWithGreenDepth(): boolean;
  8467. /**
  8468. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8469. */
  8470. set colorGradingWithGreenDepth(value: boolean);
  8471. private _colorGradingBGR;
  8472. /**
  8473. * Gets wether the color grading texture contains BGR values.
  8474. */
  8475. get colorGradingBGR(): boolean;
  8476. /**
  8477. * Sets wether the color grading texture contains BGR values.
  8478. */
  8479. set colorGradingBGR(value: boolean);
  8480. /** @hidden */
  8481. _exposure: number;
  8482. /**
  8483. * Gets the Exposure used in the effect.
  8484. */
  8485. get exposure(): number;
  8486. /**
  8487. * Sets the Exposure used in the effect.
  8488. */
  8489. set exposure(value: number);
  8490. private _toneMappingEnabled;
  8491. /**
  8492. * Gets wether the tone mapping effect is enabled.
  8493. */
  8494. get toneMappingEnabled(): boolean;
  8495. /**
  8496. * Sets wether the tone mapping effect is enabled.
  8497. */
  8498. set toneMappingEnabled(value: boolean);
  8499. private _toneMappingType;
  8500. /**
  8501. * Gets the type of tone mapping effect.
  8502. */
  8503. get toneMappingType(): number;
  8504. /**
  8505. * Sets the type of tone mapping effect used in BabylonJS.
  8506. */
  8507. set toneMappingType(value: number);
  8508. protected _contrast: number;
  8509. /**
  8510. * Gets the contrast used in the effect.
  8511. */
  8512. get contrast(): number;
  8513. /**
  8514. * Sets the contrast used in the effect.
  8515. */
  8516. set contrast(value: number);
  8517. /**
  8518. * Vignette stretch size.
  8519. */
  8520. vignetteStretch: number;
  8521. /**
  8522. * Vignette centre X Offset.
  8523. */
  8524. vignetteCentreX: number;
  8525. /**
  8526. * Vignette centre Y Offset.
  8527. */
  8528. vignetteCentreY: number;
  8529. /**
  8530. * Vignette weight or intensity of the vignette effect.
  8531. */
  8532. vignetteWeight: number;
  8533. /**
  8534. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8535. * if vignetteEnabled is set to true.
  8536. */
  8537. vignetteColor: Color4;
  8538. /**
  8539. * Camera field of view used by the Vignette effect.
  8540. */
  8541. vignetteCameraFov: number;
  8542. private _vignetteBlendMode;
  8543. /**
  8544. * Gets the vignette blend mode allowing different kind of effect.
  8545. */
  8546. get vignetteBlendMode(): number;
  8547. /**
  8548. * Sets the vignette blend mode allowing different kind of effect.
  8549. */
  8550. set vignetteBlendMode(value: number);
  8551. private _vignetteEnabled;
  8552. /**
  8553. * Gets wether the vignette effect is enabled.
  8554. */
  8555. get vignetteEnabled(): boolean;
  8556. /**
  8557. * Sets wether the vignette effect is enabled.
  8558. */
  8559. set vignetteEnabled(value: boolean);
  8560. private _applyByPostProcess;
  8561. /**
  8562. * Gets wether the image processing is applied through a post process or not.
  8563. */
  8564. get applyByPostProcess(): boolean;
  8565. /**
  8566. * Sets wether the image processing is applied through a post process or not.
  8567. */
  8568. set applyByPostProcess(value: boolean);
  8569. private _isEnabled;
  8570. /**
  8571. * Gets wether the image processing is enabled or not.
  8572. */
  8573. get isEnabled(): boolean;
  8574. /**
  8575. * Sets wether the image processing is enabled or not.
  8576. */
  8577. set isEnabled(value: boolean);
  8578. /**
  8579. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8580. */
  8581. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8582. /**
  8583. * Method called each time the image processing information changes requires to recompile the effect.
  8584. */
  8585. protected _updateParameters(): void;
  8586. /**
  8587. * Gets the current class name.
  8588. * @return "ImageProcessingConfiguration"
  8589. */
  8590. getClassName(): string;
  8591. /**
  8592. * Prepare the list of uniforms associated with the Image Processing effects.
  8593. * @param uniforms The list of uniforms used in the effect
  8594. * @param defines the list of defines currently in use
  8595. */
  8596. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8597. /**
  8598. * Prepare the list of samplers associated with the Image Processing effects.
  8599. * @param samplersList The list of uniforms used in the effect
  8600. * @param defines the list of defines currently in use
  8601. */
  8602. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8603. /**
  8604. * Prepare the list of defines associated to the shader.
  8605. * @param defines the list of defines to complete
  8606. * @param forPostProcess Define if we are currently in post process mode or not
  8607. */
  8608. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8609. /**
  8610. * Returns true if all the image processing information are ready.
  8611. * @returns True if ready, otherwise, false
  8612. */
  8613. isReady(): boolean;
  8614. /**
  8615. * Binds the image processing to the shader.
  8616. * @param effect The effect to bind to
  8617. * @param overrideAspectRatio Override the aspect ratio of the effect
  8618. */
  8619. bind(effect: Effect, overrideAspectRatio?: number): void;
  8620. /**
  8621. * Clones the current image processing instance.
  8622. * @return The cloned image processing
  8623. */
  8624. clone(): ImageProcessingConfiguration;
  8625. /**
  8626. * Serializes the current image processing instance to a json representation.
  8627. * @return a JSON representation
  8628. */
  8629. serialize(): any;
  8630. /**
  8631. * Parses the image processing from a json representation.
  8632. * @param source the JSON source to parse
  8633. * @return The parsed image processing
  8634. */
  8635. static Parse(source: any): ImageProcessingConfiguration;
  8636. private static _VIGNETTEMODE_MULTIPLY;
  8637. private static _VIGNETTEMODE_OPAQUE;
  8638. /**
  8639. * Used to apply the vignette as a mix with the pixel color.
  8640. */
  8641. static get VIGNETTEMODE_MULTIPLY(): number;
  8642. /**
  8643. * Used to apply the vignette as a replacement of the pixel color.
  8644. */
  8645. static get VIGNETTEMODE_OPAQUE(): number;
  8646. }
  8647. }
  8648. declare module BABYLON {
  8649. /** @hidden */
  8650. export var postprocessVertexShader: {
  8651. name: string;
  8652. shader: string;
  8653. };
  8654. }
  8655. declare module BABYLON {
  8656. /**
  8657. * Type used to define a render target texture size (either with a number or with a rect width and height)
  8658. */
  8659. export type RenderTargetTextureSize = number | {
  8660. width: number;
  8661. height: number;
  8662. layers?: number;
  8663. };
  8664. interface ThinEngine {
  8665. /**
  8666. * Creates a new render target texture
  8667. * @param size defines the size of the texture
  8668. * @param options defines the options used to create the texture
  8669. * @returns a new render target texture stored in an InternalTexture
  8670. */
  8671. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8672. /**
  8673. * Creates a depth stencil texture.
  8674. * This is only available in WebGL 2 or with the depth texture extension available.
  8675. * @param size The size of face edge in the texture.
  8676. * @param options The options defining the texture.
  8677. * @returns The texture
  8678. */
  8679. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8680. /** @hidden */
  8681. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8682. }
  8683. }
  8684. declare module BABYLON {
  8685. /**
  8686. * Defines the kind of connection point for node based material
  8687. */
  8688. export enum NodeMaterialBlockConnectionPointTypes {
  8689. /** Float */
  8690. Float = 1,
  8691. /** Int */
  8692. Int = 2,
  8693. /** Vector2 */
  8694. Vector2 = 4,
  8695. /** Vector3 */
  8696. Vector3 = 8,
  8697. /** Vector4 */
  8698. Vector4 = 16,
  8699. /** Color3 */
  8700. Color3 = 32,
  8701. /** Color4 */
  8702. Color4 = 64,
  8703. /** Matrix */
  8704. Matrix = 128,
  8705. /** Custom object */
  8706. Object = 256,
  8707. /** Detect type based on connection */
  8708. AutoDetect = 1024,
  8709. /** Output type that will be defined by input type */
  8710. BasedOnInput = 2048
  8711. }
  8712. }
  8713. declare module BABYLON {
  8714. /**
  8715. * Enum used to define the target of a block
  8716. */
  8717. export enum NodeMaterialBlockTargets {
  8718. /** Vertex shader */
  8719. Vertex = 1,
  8720. /** Fragment shader */
  8721. Fragment = 2,
  8722. /** Neutral */
  8723. Neutral = 4,
  8724. /** Vertex and Fragment */
  8725. VertexAndFragment = 3
  8726. }
  8727. }
  8728. declare module BABYLON {
  8729. /**
  8730. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8731. */
  8732. export enum NodeMaterialBlockConnectionPointMode {
  8733. /** Value is an uniform */
  8734. Uniform = 0,
  8735. /** Value is a mesh attribute */
  8736. Attribute = 1,
  8737. /** Value is a varying between vertex and fragment shaders */
  8738. Varying = 2,
  8739. /** Mode is undefined */
  8740. Undefined = 3
  8741. }
  8742. }
  8743. declare module BABYLON {
  8744. /**
  8745. * Enum used to define system values e.g. values automatically provided by the system
  8746. */
  8747. export enum NodeMaterialSystemValues {
  8748. /** World */
  8749. World = 1,
  8750. /** View */
  8751. View = 2,
  8752. /** Projection */
  8753. Projection = 3,
  8754. /** ViewProjection */
  8755. ViewProjection = 4,
  8756. /** WorldView */
  8757. WorldView = 5,
  8758. /** WorldViewProjection */
  8759. WorldViewProjection = 6,
  8760. /** CameraPosition */
  8761. CameraPosition = 7,
  8762. /** Fog Color */
  8763. FogColor = 8,
  8764. /** Delta time */
  8765. DeltaTime = 9
  8766. }
  8767. }
  8768. declare module BABYLON {
  8769. /** Defines supported spaces */
  8770. export enum Space {
  8771. /** Local (object) space */
  8772. LOCAL = 0,
  8773. /** World space */
  8774. WORLD = 1,
  8775. /** Bone space */
  8776. BONE = 2
  8777. }
  8778. /** Defines the 3 main axes */
  8779. export class Axis {
  8780. /** X axis */
  8781. static X: Vector3;
  8782. /** Y axis */
  8783. static Y: Vector3;
  8784. /** Z axis */
  8785. static Z: Vector3;
  8786. }
  8787. /**
  8788. * Defines cartesian components.
  8789. */
  8790. export enum Coordinate {
  8791. /** X axis */
  8792. X = 0,
  8793. /** Y axis */
  8794. Y = 1,
  8795. /** Z axis */
  8796. Z = 2
  8797. }
  8798. }
  8799. declare module BABYLON {
  8800. /**
  8801. * Represents a camera frustum
  8802. */
  8803. export class Frustum {
  8804. /**
  8805. * Gets the planes representing the frustum
  8806. * @param transform matrix to be applied to the returned planes
  8807. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8808. */
  8809. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8810. /**
  8811. * Gets the near frustum plane transformed by the transform matrix
  8812. * @param transform transformation matrix to be applied to the resulting frustum plane
  8813. * @param frustumPlane the resuling frustum plane
  8814. */
  8815. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8816. /**
  8817. * Gets the far frustum plane transformed by the transform matrix
  8818. * @param transform transformation matrix to be applied to the resulting frustum plane
  8819. * @param frustumPlane the resuling frustum plane
  8820. */
  8821. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8822. /**
  8823. * Gets the left frustum plane transformed by the transform matrix
  8824. * @param transform transformation matrix to be applied to the resulting frustum plane
  8825. * @param frustumPlane the resuling frustum plane
  8826. */
  8827. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8828. /**
  8829. * Gets the right frustum plane transformed by the transform matrix
  8830. * @param transform transformation matrix to be applied to the resulting frustum plane
  8831. * @param frustumPlane the resuling frustum plane
  8832. */
  8833. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8834. /**
  8835. * Gets the top frustum plane transformed by the transform matrix
  8836. * @param transform transformation matrix to be applied to the resulting frustum plane
  8837. * @param frustumPlane the resuling frustum plane
  8838. */
  8839. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8840. /**
  8841. * Gets the bottom frustum plane transformed by the transform matrix
  8842. * @param transform transformation matrix to be applied to the resulting frustum plane
  8843. * @param frustumPlane the resuling frustum plane
  8844. */
  8845. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8846. /**
  8847. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8848. * @param transform transformation matrix to be applied to the resulting frustum planes
  8849. * @param frustumPlanes the resuling frustum planes
  8850. */
  8851. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8852. }
  8853. }
  8854. declare module BABYLON {
  8855. /**
  8856. * Interface for the size containing width and height
  8857. */
  8858. export interface ISize {
  8859. /**
  8860. * Width
  8861. */
  8862. width: number;
  8863. /**
  8864. * Heighht
  8865. */
  8866. height: number;
  8867. }
  8868. /**
  8869. * Size containing widht and height
  8870. */
  8871. export class Size implements ISize {
  8872. /**
  8873. * Width
  8874. */
  8875. width: number;
  8876. /**
  8877. * Height
  8878. */
  8879. height: number;
  8880. /**
  8881. * Creates a Size object from the given width and height (floats).
  8882. * @param width width of the new size
  8883. * @param height height of the new size
  8884. */
  8885. constructor(width: number, height: number);
  8886. /**
  8887. * Returns a string with the Size width and height
  8888. * @returns a string with the Size width and height
  8889. */
  8890. toString(): string;
  8891. /**
  8892. * "Size"
  8893. * @returns the string "Size"
  8894. */
  8895. getClassName(): string;
  8896. /**
  8897. * Returns the Size hash code.
  8898. * @returns a hash code for a unique width and height
  8899. */
  8900. getHashCode(): number;
  8901. /**
  8902. * Updates the current size from the given one.
  8903. * @param src the given size
  8904. */
  8905. copyFrom(src: Size): void;
  8906. /**
  8907. * Updates in place the current Size from the given floats.
  8908. * @param width width of the new size
  8909. * @param height height of the new size
  8910. * @returns the updated Size.
  8911. */
  8912. copyFromFloats(width: number, height: number): Size;
  8913. /**
  8914. * Updates in place the current Size from the given floats.
  8915. * @param width width to set
  8916. * @param height height to set
  8917. * @returns the updated Size.
  8918. */
  8919. set(width: number, height: number): Size;
  8920. /**
  8921. * Multiplies the width and height by numbers
  8922. * @param w factor to multiple the width by
  8923. * @param h factor to multiple the height by
  8924. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8925. */
  8926. multiplyByFloats(w: number, h: number): Size;
  8927. /**
  8928. * Clones the size
  8929. * @returns a new Size copied from the given one.
  8930. */
  8931. clone(): Size;
  8932. /**
  8933. * True if the current Size and the given one width and height are strictly equal.
  8934. * @param other the other size to compare against
  8935. * @returns True if the current Size and the given one width and height are strictly equal.
  8936. */
  8937. equals(other: Size): boolean;
  8938. /**
  8939. * The surface of the Size : width * height (float).
  8940. */
  8941. get surface(): number;
  8942. /**
  8943. * Create a new size of zero
  8944. * @returns a new Size set to (0.0, 0.0)
  8945. */
  8946. static Zero(): Size;
  8947. /**
  8948. * Sums the width and height of two sizes
  8949. * @param otherSize size to add to this size
  8950. * @returns a new Size set as the addition result of the current Size and the given one.
  8951. */
  8952. add(otherSize: Size): Size;
  8953. /**
  8954. * Subtracts the width and height of two
  8955. * @param otherSize size to subtract to this size
  8956. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8957. */
  8958. subtract(otherSize: Size): Size;
  8959. /**
  8960. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8961. * @param start starting size to lerp between
  8962. * @param end end size to lerp between
  8963. * @param amount amount to lerp between the start and end values
  8964. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8965. */
  8966. static Lerp(start: Size, end: Size, amount: number): Size;
  8967. }
  8968. }
  8969. declare module BABYLON {
  8970. /**
  8971. * Contains position and normal vectors for a vertex
  8972. */
  8973. export class PositionNormalVertex {
  8974. /** the position of the vertex (defaut: 0,0,0) */
  8975. position: Vector3;
  8976. /** the normal of the vertex (defaut: 0,1,0) */
  8977. normal: Vector3;
  8978. /**
  8979. * Creates a PositionNormalVertex
  8980. * @param position the position of the vertex (defaut: 0,0,0)
  8981. * @param normal the normal of the vertex (defaut: 0,1,0)
  8982. */
  8983. constructor(
  8984. /** the position of the vertex (defaut: 0,0,0) */
  8985. position?: Vector3,
  8986. /** the normal of the vertex (defaut: 0,1,0) */
  8987. normal?: Vector3);
  8988. /**
  8989. * Clones the PositionNormalVertex
  8990. * @returns the cloned PositionNormalVertex
  8991. */
  8992. clone(): PositionNormalVertex;
  8993. }
  8994. /**
  8995. * Contains position, normal and uv vectors for a vertex
  8996. */
  8997. export class PositionNormalTextureVertex {
  8998. /** the position of the vertex (defaut: 0,0,0) */
  8999. position: Vector3;
  9000. /** the normal of the vertex (defaut: 0,1,0) */
  9001. normal: Vector3;
  9002. /** the uv of the vertex (default: 0,0) */
  9003. uv: Vector2;
  9004. /**
  9005. * Creates a PositionNormalTextureVertex
  9006. * @param position the position of the vertex (defaut: 0,0,0)
  9007. * @param normal the normal of the vertex (defaut: 0,1,0)
  9008. * @param uv the uv of the vertex (default: 0,0)
  9009. */
  9010. constructor(
  9011. /** the position of the vertex (defaut: 0,0,0) */
  9012. position?: Vector3,
  9013. /** the normal of the vertex (defaut: 0,1,0) */
  9014. normal?: Vector3,
  9015. /** the uv of the vertex (default: 0,0) */
  9016. uv?: Vector2);
  9017. /**
  9018. * Clones the PositionNormalTextureVertex
  9019. * @returns the cloned PositionNormalTextureVertex
  9020. */
  9021. clone(): PositionNormalTextureVertex;
  9022. }
  9023. }
  9024. declare module BABYLON {
  9025. /**
  9026. * Enum defining the type of animations supported by InputBlock
  9027. */
  9028. export enum AnimatedInputBlockTypes {
  9029. /** No animation */
  9030. None = 0,
  9031. /** Time based animation. Will only work for floats */
  9032. Time = 1
  9033. }
  9034. }
  9035. declare module BABYLON {
  9036. /**
  9037. * Interface describing all the common properties and methods a shadow light needs to implement.
  9038. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9039. * as well as binding the different shadow properties to the effects.
  9040. */
  9041. export interface IShadowLight extends Light {
  9042. /**
  9043. * The light id in the scene (used in scene.findLighById for instance)
  9044. */
  9045. id: string;
  9046. /**
  9047. * The position the shdow will be casted from.
  9048. */
  9049. position: Vector3;
  9050. /**
  9051. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9052. */
  9053. direction: Vector3;
  9054. /**
  9055. * The transformed position. Position of the light in world space taking parenting in account.
  9056. */
  9057. transformedPosition: Vector3;
  9058. /**
  9059. * The transformed direction. Direction of the light in world space taking parenting in account.
  9060. */
  9061. transformedDirection: Vector3;
  9062. /**
  9063. * The friendly name of the light in the scene.
  9064. */
  9065. name: string;
  9066. /**
  9067. * Defines the shadow projection clipping minimum z value.
  9068. */
  9069. shadowMinZ: number;
  9070. /**
  9071. * Defines the shadow projection clipping maximum z value.
  9072. */
  9073. shadowMaxZ: number;
  9074. /**
  9075. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9076. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9077. */
  9078. computeTransformedInformation(): boolean;
  9079. /**
  9080. * Gets the scene the light belongs to.
  9081. * @returns The scene
  9082. */
  9083. getScene(): Scene;
  9084. /**
  9085. * Callback defining a custom Projection Matrix Builder.
  9086. * This can be used to override the default projection matrix computation.
  9087. */
  9088. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9089. /**
  9090. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9091. * @param matrix The materix to updated with the projection information
  9092. * @param viewMatrix The transform matrix of the light
  9093. * @param renderList The list of mesh to render in the map
  9094. * @returns The current light
  9095. */
  9096. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9097. /**
  9098. * Gets the current depth scale used in ESM.
  9099. * @returns The scale
  9100. */
  9101. getDepthScale(): number;
  9102. /**
  9103. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9104. * @returns true if a cube texture needs to be use
  9105. */
  9106. needCube(): boolean;
  9107. /**
  9108. * Detects if the projection matrix requires to be recomputed this frame.
  9109. * @returns true if it requires to be recomputed otherwise, false.
  9110. */
  9111. needProjectionMatrixCompute(): boolean;
  9112. /**
  9113. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9114. */
  9115. forceProjectionMatrixCompute(): void;
  9116. /**
  9117. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9118. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9119. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9120. */
  9121. getShadowDirection(faceIndex?: number): Vector3;
  9122. /**
  9123. * Gets the minZ used for shadow according to both the scene and the light.
  9124. * @param activeCamera The camera we are returning the min for
  9125. * @returns the depth min z
  9126. */
  9127. getDepthMinZ(activeCamera: Camera): number;
  9128. /**
  9129. * Gets the maxZ used for shadow according to both the scene and the light.
  9130. * @param activeCamera The camera we are returning the max for
  9131. * @returns the depth max z
  9132. */
  9133. getDepthMaxZ(activeCamera: Camera): number;
  9134. }
  9135. /**
  9136. * Base implementation IShadowLight
  9137. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9138. */
  9139. export abstract class ShadowLight extends Light implements IShadowLight {
  9140. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9141. protected _position: Vector3;
  9142. protected _setPosition(value: Vector3): void;
  9143. /**
  9144. * Sets the position the shadow will be casted from. Also use as the light position for both
  9145. * point and spot lights.
  9146. */
  9147. get position(): Vector3;
  9148. /**
  9149. * Sets the position the shadow will be casted from. Also use as the light position for both
  9150. * point and spot lights.
  9151. */
  9152. set position(value: Vector3);
  9153. protected _direction: Vector3;
  9154. protected _setDirection(value: Vector3): void;
  9155. /**
  9156. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9157. * Also use as the light direction on spot and directional lights.
  9158. */
  9159. get direction(): Vector3;
  9160. /**
  9161. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9162. * Also use as the light direction on spot and directional lights.
  9163. */
  9164. set direction(value: Vector3);
  9165. protected _shadowMinZ: number;
  9166. /**
  9167. * Gets the shadow projection clipping minimum z value.
  9168. */
  9169. get shadowMinZ(): number;
  9170. /**
  9171. * Sets the shadow projection clipping minimum z value.
  9172. */
  9173. set shadowMinZ(value: number);
  9174. protected _shadowMaxZ: number;
  9175. /**
  9176. * Sets the shadow projection clipping maximum z value.
  9177. */
  9178. get shadowMaxZ(): number;
  9179. /**
  9180. * Gets the shadow projection clipping maximum z value.
  9181. */
  9182. set shadowMaxZ(value: number);
  9183. /**
  9184. * Callback defining a custom Projection Matrix Builder.
  9185. * This can be used to override the default projection matrix computation.
  9186. */
  9187. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9188. /**
  9189. * The transformed position. Position of the light in world space taking parenting in account.
  9190. */
  9191. transformedPosition: Vector3;
  9192. /**
  9193. * The transformed direction. Direction of the light in world space taking parenting in account.
  9194. */
  9195. transformedDirection: Vector3;
  9196. private _needProjectionMatrixCompute;
  9197. /**
  9198. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9199. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9200. */
  9201. computeTransformedInformation(): boolean;
  9202. /**
  9203. * Return the depth scale used for the shadow map.
  9204. * @returns the depth scale.
  9205. */
  9206. getDepthScale(): number;
  9207. /**
  9208. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9209. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9210. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9211. */
  9212. getShadowDirection(faceIndex?: number): Vector3;
  9213. /**
  9214. * Returns the ShadowLight absolute position in the World.
  9215. * @returns the position vector in world space
  9216. */
  9217. getAbsolutePosition(): Vector3;
  9218. /**
  9219. * Sets the ShadowLight direction toward the passed target.
  9220. * @param target The point to target in local space
  9221. * @returns the updated ShadowLight direction
  9222. */
  9223. setDirectionToTarget(target: Vector3): Vector3;
  9224. /**
  9225. * Returns the light rotation in euler definition.
  9226. * @returns the x y z rotation in local space.
  9227. */
  9228. getRotation(): Vector3;
  9229. /**
  9230. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9231. * @returns true if a cube texture needs to be use
  9232. */
  9233. needCube(): boolean;
  9234. /**
  9235. * Detects if the projection matrix requires to be recomputed this frame.
  9236. * @returns true if it requires to be recomputed otherwise, false.
  9237. */
  9238. needProjectionMatrixCompute(): boolean;
  9239. /**
  9240. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9241. */
  9242. forceProjectionMatrixCompute(): void;
  9243. /** @hidden */
  9244. _initCache(): void;
  9245. /** @hidden */
  9246. _isSynchronized(): boolean;
  9247. /**
  9248. * Computes the world matrix of the node
  9249. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9250. * @returns the world matrix
  9251. */
  9252. computeWorldMatrix(force?: boolean): Matrix;
  9253. /**
  9254. * Gets the minZ used for shadow according to both the scene and the light.
  9255. * @param activeCamera The camera we are returning the min for
  9256. * @returns the depth min z
  9257. */
  9258. getDepthMinZ(activeCamera: Camera): number;
  9259. /**
  9260. * Gets the maxZ used for shadow according to both the scene and the light.
  9261. * @param activeCamera The camera we are returning the max for
  9262. * @returns the depth max z
  9263. */
  9264. getDepthMaxZ(activeCamera: Camera): number;
  9265. /**
  9266. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9267. * @param matrix The materix to updated with the projection information
  9268. * @param viewMatrix The transform matrix of the light
  9269. * @param renderList The list of mesh to render in the map
  9270. * @returns The current light
  9271. */
  9272. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9273. }
  9274. }
  9275. declare module BABYLON {
  9276. /** @hidden */
  9277. export var packingFunctions: {
  9278. name: string;
  9279. shader: string;
  9280. };
  9281. }
  9282. declare module BABYLON {
  9283. /** @hidden */
  9284. export var bayerDitherFunctions: {
  9285. name: string;
  9286. shader: string;
  9287. };
  9288. }
  9289. declare module BABYLON {
  9290. /** @hidden */
  9291. export var shadowMapFragmentDeclaration: {
  9292. name: string;
  9293. shader: string;
  9294. };
  9295. }
  9296. declare module BABYLON {
  9297. /** @hidden */
  9298. export var clipPlaneFragmentDeclaration: {
  9299. name: string;
  9300. shader: string;
  9301. };
  9302. }
  9303. declare module BABYLON {
  9304. /** @hidden */
  9305. export var clipPlaneFragment: {
  9306. name: string;
  9307. shader: string;
  9308. };
  9309. }
  9310. declare module BABYLON {
  9311. /** @hidden */
  9312. export var shadowMapFragment: {
  9313. name: string;
  9314. shader: string;
  9315. };
  9316. }
  9317. declare module BABYLON {
  9318. /** @hidden */
  9319. export var shadowMapPixelShader: {
  9320. name: string;
  9321. shader: string;
  9322. };
  9323. }
  9324. declare module BABYLON {
  9325. /** @hidden */
  9326. export var bonesDeclaration: {
  9327. name: string;
  9328. shader: string;
  9329. };
  9330. }
  9331. declare module BABYLON {
  9332. /** @hidden */
  9333. export var morphTargetsVertexGlobalDeclaration: {
  9334. name: string;
  9335. shader: string;
  9336. };
  9337. }
  9338. declare module BABYLON {
  9339. /** @hidden */
  9340. export var morphTargetsVertexDeclaration: {
  9341. name: string;
  9342. shader: string;
  9343. };
  9344. }
  9345. declare module BABYLON {
  9346. /** @hidden */
  9347. export var instancesDeclaration: {
  9348. name: string;
  9349. shader: string;
  9350. };
  9351. }
  9352. declare module BABYLON {
  9353. /** @hidden */
  9354. export var helperFunctions: {
  9355. name: string;
  9356. shader: string;
  9357. };
  9358. }
  9359. declare module BABYLON {
  9360. /** @hidden */
  9361. export var shadowMapVertexDeclaration: {
  9362. name: string;
  9363. shader: string;
  9364. };
  9365. }
  9366. declare module BABYLON {
  9367. /** @hidden */
  9368. export var clipPlaneVertexDeclaration: {
  9369. name: string;
  9370. shader: string;
  9371. };
  9372. }
  9373. declare module BABYLON {
  9374. /** @hidden */
  9375. export var morphTargetsVertex: {
  9376. name: string;
  9377. shader: string;
  9378. };
  9379. }
  9380. declare module BABYLON {
  9381. /** @hidden */
  9382. export var instancesVertex: {
  9383. name: string;
  9384. shader: string;
  9385. };
  9386. }
  9387. declare module BABYLON {
  9388. /** @hidden */
  9389. export var bonesVertex: {
  9390. name: string;
  9391. shader: string;
  9392. };
  9393. }
  9394. declare module BABYLON {
  9395. /** @hidden */
  9396. export var shadowMapVertexNormalBias: {
  9397. name: string;
  9398. shader: string;
  9399. };
  9400. }
  9401. declare module BABYLON {
  9402. /** @hidden */
  9403. export var shadowMapVertexMetric: {
  9404. name: string;
  9405. shader: string;
  9406. };
  9407. }
  9408. declare module BABYLON {
  9409. /** @hidden */
  9410. export var clipPlaneVertex: {
  9411. name: string;
  9412. shader: string;
  9413. };
  9414. }
  9415. declare module BABYLON {
  9416. /** @hidden */
  9417. export var shadowMapVertexShader: {
  9418. name: string;
  9419. shader: string;
  9420. };
  9421. }
  9422. declare module BABYLON {
  9423. /** @hidden */
  9424. export var depthBoxBlurPixelShader: {
  9425. name: string;
  9426. shader: string;
  9427. };
  9428. }
  9429. declare module BABYLON {
  9430. /** @hidden */
  9431. export var shadowMapFragmentSoftTransparentShadow: {
  9432. name: string;
  9433. shader: string;
  9434. };
  9435. }
  9436. declare module BABYLON {
  9437. /**
  9438. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9439. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9440. */
  9441. export class EffectFallbacks implements IEffectFallbacks {
  9442. private _defines;
  9443. private _currentRank;
  9444. private _maxRank;
  9445. private _mesh;
  9446. /**
  9447. * Removes the fallback from the bound mesh.
  9448. */
  9449. unBindMesh(): void;
  9450. /**
  9451. * Adds a fallback on the specified property.
  9452. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9453. * @param define The name of the define in the shader
  9454. */
  9455. addFallback(rank: number, define: string): void;
  9456. /**
  9457. * Sets the mesh to use CPU skinning when needing to fallback.
  9458. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9459. * @param mesh The mesh to use the fallbacks.
  9460. */
  9461. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9462. /**
  9463. * Checks to see if more fallbacks are still availible.
  9464. */
  9465. get hasMoreFallbacks(): boolean;
  9466. /**
  9467. * Removes the defines that should be removed when falling back.
  9468. * @param currentDefines defines the current define statements for the shader.
  9469. * @param effect defines the current effect we try to compile
  9470. * @returns The resulting defines with defines of the current rank removed.
  9471. */
  9472. reduce(currentDefines: string, effect: Effect): string;
  9473. }
  9474. }
  9475. declare module BABYLON {
  9476. /**
  9477. * Interface used to define Action
  9478. */
  9479. export interface IAction {
  9480. /**
  9481. * Trigger for the action
  9482. */
  9483. trigger: number;
  9484. /** Options of the trigger */
  9485. triggerOptions: any;
  9486. /**
  9487. * Gets the trigger parameters
  9488. * @returns the trigger parameters
  9489. */
  9490. getTriggerParameter(): any;
  9491. /**
  9492. * Internal only - executes current action event
  9493. * @hidden
  9494. */
  9495. _executeCurrent(evt?: ActionEvent): void;
  9496. /**
  9497. * Serialize placeholder for child classes
  9498. * @param parent of child
  9499. * @returns the serialized object
  9500. */
  9501. serialize(parent: any): any;
  9502. /**
  9503. * Internal only
  9504. * @hidden
  9505. */
  9506. _prepare(): void;
  9507. /**
  9508. * Internal only - manager for action
  9509. * @hidden
  9510. */
  9511. _actionManager: Nullable<AbstractActionManager>;
  9512. /**
  9513. * Adds action to chain of actions, may be a DoNothingAction
  9514. * @param action defines the next action to execute
  9515. * @returns The action passed in
  9516. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9517. */
  9518. then(action: IAction): IAction;
  9519. }
  9520. /**
  9521. * The action to be carried out following a trigger
  9522. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9523. */
  9524. export class Action implements IAction {
  9525. /** the trigger, with or without parameters, for the action */
  9526. triggerOptions: any;
  9527. /**
  9528. * Trigger for the action
  9529. */
  9530. trigger: number;
  9531. /**
  9532. * Internal only - manager for action
  9533. * @hidden
  9534. */
  9535. _actionManager: ActionManager;
  9536. private _nextActiveAction;
  9537. private _child;
  9538. private _condition?;
  9539. private _triggerParameter;
  9540. /**
  9541. * An event triggered prior to action being executed.
  9542. */
  9543. onBeforeExecuteObservable: Observable<Action>;
  9544. /**
  9545. * Creates a new Action
  9546. * @param triggerOptions the trigger, with or without parameters, for the action
  9547. * @param condition an optional determinant of action
  9548. */
  9549. constructor(
  9550. /** the trigger, with or without parameters, for the action */
  9551. triggerOptions: any, condition?: Condition);
  9552. /**
  9553. * Internal only
  9554. * @hidden
  9555. */
  9556. _prepare(): void;
  9557. /**
  9558. * Gets the trigger parameters
  9559. * @returns the trigger parameters
  9560. */
  9561. getTriggerParameter(): any;
  9562. /**
  9563. * Internal only - executes current action event
  9564. * @hidden
  9565. */
  9566. _executeCurrent(evt?: ActionEvent): void;
  9567. /**
  9568. * Execute placeholder for child classes
  9569. * @param evt optional action event
  9570. */
  9571. execute(evt?: ActionEvent): void;
  9572. /**
  9573. * Skips to next active action
  9574. */
  9575. skipToNextActiveAction(): void;
  9576. /**
  9577. * Adds action to chain of actions, may be a DoNothingAction
  9578. * @param action defines the next action to execute
  9579. * @returns The action passed in
  9580. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9581. */
  9582. then(action: Action): Action;
  9583. /**
  9584. * Internal only
  9585. * @hidden
  9586. */
  9587. _getProperty(propertyPath: string): string;
  9588. /**
  9589. * Internal only
  9590. * @hidden
  9591. */
  9592. _getEffectiveTarget(target: any, propertyPath: string): any;
  9593. /**
  9594. * Serialize placeholder for child classes
  9595. * @param parent of child
  9596. * @returns the serialized object
  9597. */
  9598. serialize(parent: any): any;
  9599. /**
  9600. * Internal only called by serialize
  9601. * @hidden
  9602. */
  9603. protected _serialize(serializedAction: any, parent?: any): any;
  9604. /**
  9605. * Internal only
  9606. * @hidden
  9607. */
  9608. static _SerializeValueAsString: (value: any) => string;
  9609. /**
  9610. * Internal only
  9611. * @hidden
  9612. */
  9613. static _GetTargetProperty: (target: Scene | Node) => {
  9614. name: string;
  9615. targetType: string;
  9616. value: string;
  9617. };
  9618. }
  9619. }
  9620. declare module BABYLON {
  9621. /**
  9622. * A Condition applied to an Action
  9623. */
  9624. export class Condition {
  9625. /**
  9626. * Internal only - manager for action
  9627. * @hidden
  9628. */
  9629. _actionManager: ActionManager;
  9630. /**
  9631. * Internal only
  9632. * @hidden
  9633. */
  9634. _evaluationId: number;
  9635. /**
  9636. * Internal only
  9637. * @hidden
  9638. */
  9639. _currentResult: boolean;
  9640. /**
  9641. * Creates a new Condition
  9642. * @param actionManager the manager of the action the condition is applied to
  9643. */
  9644. constructor(actionManager: ActionManager);
  9645. /**
  9646. * Check if the current condition is valid
  9647. * @returns a boolean
  9648. */
  9649. isValid(): boolean;
  9650. /**
  9651. * Internal only
  9652. * @hidden
  9653. */
  9654. _getProperty(propertyPath: string): string;
  9655. /**
  9656. * Internal only
  9657. * @hidden
  9658. */
  9659. _getEffectiveTarget(target: any, propertyPath: string): any;
  9660. /**
  9661. * Serialize placeholder for child classes
  9662. * @returns the serialized object
  9663. */
  9664. serialize(): any;
  9665. /**
  9666. * Internal only
  9667. * @hidden
  9668. */
  9669. protected _serialize(serializedCondition: any): any;
  9670. }
  9671. /**
  9672. * Defines specific conditional operators as extensions of Condition
  9673. */
  9674. export class ValueCondition extends Condition {
  9675. /** path to specify the property of the target the conditional operator uses */
  9676. propertyPath: string;
  9677. /** the value compared by the conditional operator against the current value of the property */
  9678. value: any;
  9679. /** the conditional operator, default ValueCondition.IsEqual */
  9680. operator: number;
  9681. /**
  9682. * Internal only
  9683. * @hidden
  9684. */
  9685. private static _IsEqual;
  9686. /**
  9687. * Internal only
  9688. * @hidden
  9689. */
  9690. private static _IsDifferent;
  9691. /**
  9692. * Internal only
  9693. * @hidden
  9694. */
  9695. private static _IsGreater;
  9696. /**
  9697. * Internal only
  9698. * @hidden
  9699. */
  9700. private static _IsLesser;
  9701. /**
  9702. * returns the number for IsEqual
  9703. */
  9704. static get IsEqual(): number;
  9705. /**
  9706. * Returns the number for IsDifferent
  9707. */
  9708. static get IsDifferent(): number;
  9709. /**
  9710. * Returns the number for IsGreater
  9711. */
  9712. static get IsGreater(): number;
  9713. /**
  9714. * Returns the number for IsLesser
  9715. */
  9716. static get IsLesser(): number;
  9717. /**
  9718. * Internal only The action manager for the condition
  9719. * @hidden
  9720. */
  9721. _actionManager: ActionManager;
  9722. /**
  9723. * Internal only
  9724. * @hidden
  9725. */
  9726. private _target;
  9727. /**
  9728. * Internal only
  9729. * @hidden
  9730. */
  9731. private _effectiveTarget;
  9732. /**
  9733. * Internal only
  9734. * @hidden
  9735. */
  9736. private _property;
  9737. /**
  9738. * Creates a new ValueCondition
  9739. * @param actionManager manager for the action the condition applies to
  9740. * @param target for the action
  9741. * @param propertyPath path to specify the property of the target the conditional operator uses
  9742. * @param value the value compared by the conditional operator against the current value of the property
  9743. * @param operator the conditional operator, default ValueCondition.IsEqual
  9744. */
  9745. constructor(actionManager: ActionManager, target: any,
  9746. /** path to specify the property of the target the conditional operator uses */
  9747. propertyPath: string,
  9748. /** the value compared by the conditional operator against the current value of the property */
  9749. value: any,
  9750. /** the conditional operator, default ValueCondition.IsEqual */
  9751. operator?: number);
  9752. /**
  9753. * Compares the given value with the property value for the specified conditional operator
  9754. * @returns the result of the comparison
  9755. */
  9756. isValid(): boolean;
  9757. /**
  9758. * Serialize the ValueCondition into a JSON compatible object
  9759. * @returns serialization object
  9760. */
  9761. serialize(): any;
  9762. /**
  9763. * Gets the name of the conditional operator for the ValueCondition
  9764. * @param operator the conditional operator
  9765. * @returns the name
  9766. */
  9767. static GetOperatorName(operator: number): string;
  9768. }
  9769. /**
  9770. * Defines a predicate condition as an extension of Condition
  9771. */
  9772. export class PredicateCondition extends Condition {
  9773. /** defines the predicate function used to validate the condition */
  9774. predicate: () => boolean;
  9775. /**
  9776. * Internal only - manager for action
  9777. * @hidden
  9778. */
  9779. _actionManager: ActionManager;
  9780. /**
  9781. * Creates a new PredicateCondition
  9782. * @param actionManager manager for the action the condition applies to
  9783. * @param predicate defines the predicate function used to validate the condition
  9784. */
  9785. constructor(actionManager: ActionManager,
  9786. /** defines the predicate function used to validate the condition */
  9787. predicate: () => boolean);
  9788. /**
  9789. * @returns the validity of the predicate condition
  9790. */
  9791. isValid(): boolean;
  9792. }
  9793. /**
  9794. * Defines a state condition as an extension of Condition
  9795. */
  9796. export class StateCondition extends Condition {
  9797. /** Value to compare with target state */
  9798. value: string;
  9799. /**
  9800. * Internal only - manager for action
  9801. * @hidden
  9802. */
  9803. _actionManager: ActionManager;
  9804. /**
  9805. * Internal only
  9806. * @hidden
  9807. */
  9808. private _target;
  9809. /**
  9810. * Creates a new StateCondition
  9811. * @param actionManager manager for the action the condition applies to
  9812. * @param target of the condition
  9813. * @param value to compare with target state
  9814. */
  9815. constructor(actionManager: ActionManager, target: any,
  9816. /** Value to compare with target state */
  9817. value: string);
  9818. /**
  9819. * Gets a boolean indicating if the current condition is met
  9820. * @returns the validity of the state
  9821. */
  9822. isValid(): boolean;
  9823. /**
  9824. * Serialize the StateCondition into a JSON compatible object
  9825. * @returns serialization object
  9826. */
  9827. serialize(): any;
  9828. }
  9829. }
  9830. declare module BABYLON {
  9831. /**
  9832. * This defines an action responsible to toggle a boolean once triggered.
  9833. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9834. */
  9835. export class SwitchBooleanAction extends Action {
  9836. /**
  9837. * The path to the boolean property in the target object
  9838. */
  9839. propertyPath: string;
  9840. private _target;
  9841. private _effectiveTarget;
  9842. private _property;
  9843. /**
  9844. * Instantiate the action
  9845. * @param triggerOptions defines the trigger options
  9846. * @param target defines the object containing the boolean
  9847. * @param propertyPath defines the path to the boolean property in the target object
  9848. * @param condition defines the trigger related conditions
  9849. */
  9850. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9851. /** @hidden */
  9852. _prepare(): void;
  9853. /**
  9854. * Execute the action toggle the boolean value.
  9855. */
  9856. execute(): void;
  9857. /**
  9858. * Serializes the actions and its related information.
  9859. * @param parent defines the object to serialize in
  9860. * @returns the serialized object
  9861. */
  9862. serialize(parent: any): any;
  9863. }
  9864. /**
  9865. * This defines an action responsible to set a the state field of the target
  9866. * to a desired value once triggered.
  9867. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9868. */
  9869. export class SetStateAction extends Action {
  9870. /**
  9871. * The value to store in the state field.
  9872. */
  9873. value: string;
  9874. private _target;
  9875. /**
  9876. * Instantiate the action
  9877. * @param triggerOptions defines the trigger options
  9878. * @param target defines the object containing the state property
  9879. * @param value defines the value to store in the state field
  9880. * @param condition defines the trigger related conditions
  9881. */
  9882. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9883. /**
  9884. * Execute the action and store the value on the target state property.
  9885. */
  9886. execute(): void;
  9887. /**
  9888. * Serializes the actions and its related information.
  9889. * @param parent defines the object to serialize in
  9890. * @returns the serialized object
  9891. */
  9892. serialize(parent: any): any;
  9893. }
  9894. /**
  9895. * This defines an action responsible to set a property of the target
  9896. * to a desired value once triggered.
  9897. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9898. */
  9899. export class SetValueAction extends Action {
  9900. /**
  9901. * The path of the property to set in the target.
  9902. */
  9903. propertyPath: string;
  9904. /**
  9905. * The value to set in the property
  9906. */
  9907. value: any;
  9908. private _target;
  9909. private _effectiveTarget;
  9910. private _property;
  9911. /**
  9912. * Instantiate the action
  9913. * @param triggerOptions defines the trigger options
  9914. * @param target defines the object containing the property
  9915. * @param propertyPath defines the path of the property to set in the target
  9916. * @param value defines the value to set in the property
  9917. * @param condition defines the trigger related conditions
  9918. */
  9919. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9920. /** @hidden */
  9921. _prepare(): void;
  9922. /**
  9923. * Execute the action and set the targetted property to the desired value.
  9924. */
  9925. execute(): void;
  9926. /**
  9927. * Serializes the actions and its related information.
  9928. * @param parent defines the object to serialize in
  9929. * @returns the serialized object
  9930. */
  9931. serialize(parent: any): any;
  9932. }
  9933. /**
  9934. * This defines an action responsible to increment the target value
  9935. * to a desired value once triggered.
  9936. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9937. */
  9938. export class IncrementValueAction extends Action {
  9939. /**
  9940. * The path of the property to increment in the target.
  9941. */
  9942. propertyPath: string;
  9943. /**
  9944. * The value we should increment the property by.
  9945. */
  9946. value: any;
  9947. private _target;
  9948. private _effectiveTarget;
  9949. private _property;
  9950. /**
  9951. * Instantiate the action
  9952. * @param triggerOptions defines the trigger options
  9953. * @param target defines the object containing the property
  9954. * @param propertyPath defines the path of the property to increment in the target
  9955. * @param value defines the value value we should increment the property by
  9956. * @param condition defines the trigger related conditions
  9957. */
  9958. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9959. /** @hidden */
  9960. _prepare(): void;
  9961. /**
  9962. * Execute the action and increment the target of the value amount.
  9963. */
  9964. execute(): void;
  9965. /**
  9966. * Serializes the actions and its related information.
  9967. * @param parent defines the object to serialize in
  9968. * @returns the serialized object
  9969. */
  9970. serialize(parent: any): any;
  9971. }
  9972. /**
  9973. * This defines an action responsible to start an animation once triggered.
  9974. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9975. */
  9976. export class PlayAnimationAction extends Action {
  9977. /**
  9978. * Where the animation should start (animation frame)
  9979. */
  9980. from: number;
  9981. /**
  9982. * Where the animation should stop (animation frame)
  9983. */
  9984. to: number;
  9985. /**
  9986. * Define if the animation should loop or stop after the first play.
  9987. */
  9988. loop?: boolean;
  9989. private _target;
  9990. /**
  9991. * Instantiate the action
  9992. * @param triggerOptions defines the trigger options
  9993. * @param target defines the target animation or animation name
  9994. * @param from defines from where the animation should start (animation frame)
  9995. * @param end defines where the animation should stop (animation frame)
  9996. * @param loop defines if the animation should loop or stop after the first play
  9997. * @param condition defines the trigger related conditions
  9998. */
  9999. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10000. /** @hidden */
  10001. _prepare(): void;
  10002. /**
  10003. * Execute the action and play the animation.
  10004. */
  10005. execute(): void;
  10006. /**
  10007. * Serializes the actions and its related information.
  10008. * @param parent defines the object to serialize in
  10009. * @returns the serialized object
  10010. */
  10011. serialize(parent: any): any;
  10012. }
  10013. /**
  10014. * This defines an action responsible to stop an animation once triggered.
  10015. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10016. */
  10017. export class StopAnimationAction extends Action {
  10018. private _target;
  10019. /**
  10020. * Instantiate the action
  10021. * @param triggerOptions defines the trigger options
  10022. * @param target defines the target animation or animation name
  10023. * @param condition defines the trigger related conditions
  10024. */
  10025. constructor(triggerOptions: any, target: any, condition?: Condition);
  10026. /** @hidden */
  10027. _prepare(): void;
  10028. /**
  10029. * Execute the action and stop the animation.
  10030. */
  10031. execute(): void;
  10032. /**
  10033. * Serializes the actions and its related information.
  10034. * @param parent defines the object to serialize in
  10035. * @returns the serialized object
  10036. */
  10037. serialize(parent: any): any;
  10038. }
  10039. /**
  10040. * This defines an action responsible that does nothing once triggered.
  10041. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10042. */
  10043. export class DoNothingAction extends Action {
  10044. /**
  10045. * Instantiate the action
  10046. * @param triggerOptions defines the trigger options
  10047. * @param condition defines the trigger related conditions
  10048. */
  10049. constructor(triggerOptions?: any, condition?: Condition);
  10050. /**
  10051. * Execute the action and do nothing.
  10052. */
  10053. execute(): void;
  10054. /**
  10055. * Serializes the actions and its related information.
  10056. * @param parent defines the object to serialize in
  10057. * @returns the serialized object
  10058. */
  10059. serialize(parent: any): any;
  10060. }
  10061. /**
  10062. * This defines an action responsible to trigger several actions once triggered.
  10063. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10064. */
  10065. export class CombineAction extends Action {
  10066. /**
  10067. * The list of aggregated animations to run.
  10068. */
  10069. children: Action[];
  10070. /**
  10071. * Instantiate the action
  10072. * @param triggerOptions defines the trigger options
  10073. * @param children defines the list of aggregated animations to run
  10074. * @param condition defines the trigger related conditions
  10075. */
  10076. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10077. /** @hidden */
  10078. _prepare(): void;
  10079. /**
  10080. * Execute the action and executes all the aggregated actions.
  10081. */
  10082. execute(evt: ActionEvent): void;
  10083. /**
  10084. * Serializes the actions and its related information.
  10085. * @param parent defines the object to serialize in
  10086. * @returns the serialized object
  10087. */
  10088. serialize(parent: any): any;
  10089. }
  10090. /**
  10091. * This defines an action responsible to run code (external event) once triggered.
  10092. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10093. */
  10094. export class ExecuteCodeAction extends Action {
  10095. /**
  10096. * The callback function to run.
  10097. */
  10098. func: (evt: ActionEvent) => void;
  10099. /**
  10100. * Instantiate the action
  10101. * @param triggerOptions defines the trigger options
  10102. * @param func defines the callback function to run
  10103. * @param condition defines the trigger related conditions
  10104. */
  10105. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10106. /**
  10107. * Execute the action and run the attached code.
  10108. */
  10109. execute(evt: ActionEvent): void;
  10110. }
  10111. /**
  10112. * This defines an action responsible to set the parent property of the target once triggered.
  10113. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10114. */
  10115. export class SetParentAction extends Action {
  10116. private _parent;
  10117. private _target;
  10118. /**
  10119. * Instantiate the action
  10120. * @param triggerOptions defines the trigger options
  10121. * @param target defines the target containing the parent property
  10122. * @param parent defines from where the animation should start (animation frame)
  10123. * @param condition defines the trigger related conditions
  10124. */
  10125. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10126. /** @hidden */
  10127. _prepare(): void;
  10128. /**
  10129. * Execute the action and set the parent property.
  10130. */
  10131. execute(): void;
  10132. /**
  10133. * Serializes the actions and its related information.
  10134. * @param parent defines the object to serialize in
  10135. * @returns the serialized object
  10136. */
  10137. serialize(parent: any): any;
  10138. }
  10139. }
  10140. declare module BABYLON {
  10141. /**
  10142. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10143. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10144. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10145. */
  10146. export class ActionManager extends AbstractActionManager {
  10147. /**
  10148. * Nothing
  10149. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10150. */
  10151. static readonly NothingTrigger: number;
  10152. /**
  10153. * On pick
  10154. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10155. */
  10156. static readonly OnPickTrigger: number;
  10157. /**
  10158. * On left pick
  10159. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10160. */
  10161. static readonly OnLeftPickTrigger: number;
  10162. /**
  10163. * On right pick
  10164. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10165. */
  10166. static readonly OnRightPickTrigger: number;
  10167. /**
  10168. * On center pick
  10169. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10170. */
  10171. static readonly OnCenterPickTrigger: number;
  10172. /**
  10173. * On pick down
  10174. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10175. */
  10176. static readonly OnPickDownTrigger: number;
  10177. /**
  10178. * On double pick
  10179. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10180. */
  10181. static readonly OnDoublePickTrigger: number;
  10182. /**
  10183. * On pick up
  10184. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10185. */
  10186. static readonly OnPickUpTrigger: number;
  10187. /**
  10188. * On pick out.
  10189. * This trigger will only be raised if you also declared a OnPickDown
  10190. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10191. */
  10192. static readonly OnPickOutTrigger: number;
  10193. /**
  10194. * On long press
  10195. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10196. */
  10197. static readonly OnLongPressTrigger: number;
  10198. /**
  10199. * On pointer over
  10200. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10201. */
  10202. static readonly OnPointerOverTrigger: number;
  10203. /**
  10204. * On pointer out
  10205. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10206. */
  10207. static readonly OnPointerOutTrigger: number;
  10208. /**
  10209. * On every frame
  10210. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10211. */
  10212. static readonly OnEveryFrameTrigger: number;
  10213. /**
  10214. * On intersection enter
  10215. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10216. */
  10217. static readonly OnIntersectionEnterTrigger: number;
  10218. /**
  10219. * On intersection exit
  10220. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10221. */
  10222. static readonly OnIntersectionExitTrigger: number;
  10223. /**
  10224. * On key down
  10225. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10226. */
  10227. static readonly OnKeyDownTrigger: number;
  10228. /**
  10229. * On key up
  10230. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10231. */
  10232. static readonly OnKeyUpTrigger: number;
  10233. private _scene;
  10234. /**
  10235. * Creates a new action manager
  10236. * @param scene defines the hosting scene
  10237. */
  10238. constructor(scene: Scene);
  10239. /**
  10240. * Releases all associated resources
  10241. */
  10242. dispose(): void;
  10243. /**
  10244. * Gets hosting scene
  10245. * @returns the hosting scene
  10246. */
  10247. getScene(): Scene;
  10248. /**
  10249. * Does this action manager handles actions of any of the given triggers
  10250. * @param triggers defines the triggers to be tested
  10251. * @return a boolean indicating whether one (or more) of the triggers is handled
  10252. */
  10253. hasSpecificTriggers(triggers: number[]): boolean;
  10254. /**
  10255. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10256. * speed.
  10257. * @param triggerA defines the trigger to be tested
  10258. * @param triggerB defines the trigger to be tested
  10259. * @return a boolean indicating whether one (or more) of the triggers is handled
  10260. */
  10261. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10262. /**
  10263. * Does this action manager handles actions of a given trigger
  10264. * @param trigger defines the trigger to be tested
  10265. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10266. * @return whether the trigger is handled
  10267. */
  10268. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10269. /**
  10270. * Does this action manager has pointer triggers
  10271. */
  10272. get hasPointerTriggers(): boolean;
  10273. /**
  10274. * Does this action manager has pick triggers
  10275. */
  10276. get hasPickTriggers(): boolean;
  10277. /**
  10278. * Registers an action to this action manager
  10279. * @param action defines the action to be registered
  10280. * @return the action amended (prepared) after registration
  10281. */
  10282. registerAction(action: IAction): Nullable<IAction>;
  10283. /**
  10284. * Unregisters an action to this action manager
  10285. * @param action defines the action to be unregistered
  10286. * @return a boolean indicating whether the action has been unregistered
  10287. */
  10288. unregisterAction(action: IAction): Boolean;
  10289. /**
  10290. * Process a specific trigger
  10291. * @param trigger defines the trigger to process
  10292. * @param evt defines the event details to be processed
  10293. */
  10294. processTrigger(trigger: number, evt?: IActionEvent): void;
  10295. /** @hidden */
  10296. _getEffectiveTarget(target: any, propertyPath: string): any;
  10297. /** @hidden */
  10298. _getProperty(propertyPath: string): string;
  10299. /**
  10300. * Serialize this manager to a JSON object
  10301. * @param name defines the property name to store this manager
  10302. * @returns a JSON representation of this manager
  10303. */
  10304. serialize(name: string): any;
  10305. /**
  10306. * Creates a new ActionManager from a JSON data
  10307. * @param parsedActions defines the JSON data to read from
  10308. * @param object defines the hosting mesh
  10309. * @param scene defines the hosting scene
  10310. */
  10311. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10312. /**
  10313. * Get a trigger name by index
  10314. * @param trigger defines the trigger index
  10315. * @returns a trigger name
  10316. */
  10317. static GetTriggerName(trigger: number): string;
  10318. }
  10319. }
  10320. declare module BABYLON {
  10321. /**
  10322. * Class used to represent a sprite
  10323. * @see https://doc.babylonjs.com/babylon101/sprites
  10324. */
  10325. export class Sprite implements IAnimatable {
  10326. /** defines the name */
  10327. name: string;
  10328. /** Gets or sets the current world position */
  10329. position: Vector3;
  10330. /** Gets or sets the main color */
  10331. color: Color4;
  10332. /** Gets or sets the width */
  10333. width: number;
  10334. /** Gets or sets the height */
  10335. height: number;
  10336. /** Gets or sets rotation angle */
  10337. angle: number;
  10338. /** Gets or sets the cell index in the sprite sheet */
  10339. cellIndex: number;
  10340. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10341. cellRef: string;
  10342. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10343. invertU: boolean;
  10344. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10345. invertV: boolean;
  10346. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10347. disposeWhenFinishedAnimating: boolean;
  10348. /** Gets the list of attached animations */
  10349. animations: Nullable<Array<Animation>>;
  10350. /** Gets or sets a boolean indicating if the sprite can be picked */
  10351. isPickable: boolean;
  10352. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10353. useAlphaForPicking: boolean;
  10354. /** @hidden */
  10355. _xOffset: number;
  10356. /** @hidden */
  10357. _yOffset: number;
  10358. /** @hidden */
  10359. _xSize: number;
  10360. /** @hidden */
  10361. _ySize: number;
  10362. /**
  10363. * Gets or sets the associated action manager
  10364. */
  10365. actionManager: Nullable<ActionManager>;
  10366. /**
  10367. * An event triggered when the control has been disposed
  10368. */
  10369. onDisposeObservable: Observable<Sprite>;
  10370. private _animationStarted;
  10371. private _loopAnimation;
  10372. private _fromIndex;
  10373. private _toIndex;
  10374. private _delay;
  10375. private _direction;
  10376. private _manager;
  10377. private _time;
  10378. private _onAnimationEnd;
  10379. /**
  10380. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10381. */
  10382. isVisible: boolean;
  10383. /**
  10384. * Gets or sets the sprite size
  10385. */
  10386. get size(): number;
  10387. set size(value: number);
  10388. /**
  10389. * Returns a boolean indicating if the animation is started
  10390. */
  10391. get animationStarted(): boolean;
  10392. /**
  10393. * Gets or sets the unique id of the sprite
  10394. */
  10395. uniqueId: number;
  10396. /**
  10397. * Gets the manager of this sprite
  10398. */
  10399. get manager(): ISpriteManager;
  10400. /**
  10401. * Creates a new Sprite
  10402. * @param name defines the name
  10403. * @param manager defines the manager
  10404. */
  10405. constructor(
  10406. /** defines the name */
  10407. name: string, manager: ISpriteManager);
  10408. /**
  10409. * Returns the string "Sprite"
  10410. * @returns "Sprite"
  10411. */
  10412. getClassName(): string;
  10413. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10414. get fromIndex(): number;
  10415. set fromIndex(value: number);
  10416. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10417. get toIndex(): number;
  10418. set toIndex(value: number);
  10419. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10420. get loopAnimation(): boolean;
  10421. set loopAnimation(value: boolean);
  10422. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10423. get delay(): number;
  10424. set delay(value: number);
  10425. /**
  10426. * Starts an animation
  10427. * @param from defines the initial key
  10428. * @param to defines the end key
  10429. * @param loop defines if the animation must loop
  10430. * @param delay defines the start delay (in ms)
  10431. * @param onAnimationEnd defines a callback to call when animation ends
  10432. */
  10433. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10434. /** Stops current animation (if any) */
  10435. stopAnimation(): void;
  10436. /** @hidden */
  10437. _animate(deltaTime: number): void;
  10438. /** Release associated resources */
  10439. dispose(): void;
  10440. /**
  10441. * Serializes the sprite to a JSON object
  10442. * @returns the JSON object
  10443. */
  10444. serialize(): any;
  10445. /**
  10446. * Parses a JSON object to create a new sprite
  10447. * @param parsedSprite The JSON object to parse
  10448. * @param manager defines the hosting manager
  10449. * @returns the new sprite
  10450. */
  10451. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10452. }
  10453. }
  10454. declare module BABYLON {
  10455. /**
  10456. * Information about the result of picking within a scene
  10457. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10458. */
  10459. export class PickingInfo {
  10460. /** @hidden */
  10461. _pickingUnavailable: boolean;
  10462. /**
  10463. * If the pick collided with an object
  10464. */
  10465. hit: boolean;
  10466. /**
  10467. * Distance away where the pick collided
  10468. */
  10469. distance: number;
  10470. /**
  10471. * The location of pick collision
  10472. */
  10473. pickedPoint: Nullable<Vector3>;
  10474. /**
  10475. * The mesh corresponding the the pick collision
  10476. */
  10477. pickedMesh: Nullable<AbstractMesh>;
  10478. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10479. bu: number;
  10480. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10481. bv: number;
  10482. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10483. faceId: number;
  10484. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10485. subMeshFaceId: number;
  10486. /** Id of the the submesh that was picked */
  10487. subMeshId: number;
  10488. /** If a sprite was picked, this will be the sprite the pick collided with */
  10489. pickedSprite: Nullable<Sprite>;
  10490. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10491. thinInstanceIndex: number;
  10492. /**
  10493. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10494. */
  10495. originMesh: Nullable<AbstractMesh>;
  10496. /**
  10497. * The ray that was used to perform the picking.
  10498. */
  10499. ray: Nullable<Ray>;
  10500. /**
  10501. * Gets the normal correspodning to the face the pick collided with
  10502. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10503. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10504. * @returns The normal correspodning to the face the pick collided with
  10505. */
  10506. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10507. /**
  10508. * Gets the texture coordinates of where the pick occured
  10509. * @returns the vector containing the coordnates of the texture
  10510. */
  10511. getTextureCoordinates(): Nullable<Vector2>;
  10512. }
  10513. }
  10514. declare module BABYLON {
  10515. /**
  10516. * Class representing a ray with position and direction
  10517. */
  10518. export class Ray {
  10519. /** origin point */
  10520. origin: Vector3;
  10521. /** direction */
  10522. direction: Vector3;
  10523. /** length of the ray */
  10524. length: number;
  10525. private static readonly _TmpVector3;
  10526. private _tmpRay;
  10527. /**
  10528. * Creates a new ray
  10529. * @param origin origin point
  10530. * @param direction direction
  10531. * @param length length of the ray
  10532. */
  10533. constructor(
  10534. /** origin point */
  10535. origin: Vector3,
  10536. /** direction */
  10537. direction: Vector3,
  10538. /** length of the ray */
  10539. length?: number);
  10540. /**
  10541. * Checks if the ray intersects a box
  10542. * This does not account for the ray lenght by design to improve perfs.
  10543. * @param minimum bound of the box
  10544. * @param maximum bound of the box
  10545. * @param intersectionTreshold extra extend to be added to the box in all direction
  10546. * @returns if the box was hit
  10547. */
  10548. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10549. /**
  10550. * Checks if the ray intersects a box
  10551. * This does not account for the ray lenght by design to improve perfs.
  10552. * @param box the bounding box to check
  10553. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10554. * @returns if the box was hit
  10555. */
  10556. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10557. /**
  10558. * If the ray hits a sphere
  10559. * @param sphere the bounding sphere to check
  10560. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10561. * @returns true if it hits the sphere
  10562. */
  10563. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10564. /**
  10565. * If the ray hits a triange
  10566. * @param vertex0 triangle vertex
  10567. * @param vertex1 triangle vertex
  10568. * @param vertex2 triangle vertex
  10569. * @returns intersection information if hit
  10570. */
  10571. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10572. /**
  10573. * Checks if ray intersects a plane
  10574. * @param plane the plane to check
  10575. * @returns the distance away it was hit
  10576. */
  10577. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10578. /**
  10579. * Calculate the intercept of a ray on a given axis
  10580. * @param axis to check 'x' | 'y' | 'z'
  10581. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10582. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10583. */
  10584. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10585. /**
  10586. * Checks if ray intersects a mesh
  10587. * @param mesh the mesh to check
  10588. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10589. * @returns picking info of the intersecton
  10590. */
  10591. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10592. /**
  10593. * Checks if ray intersects a mesh
  10594. * @param meshes the meshes to check
  10595. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10596. * @param results array to store result in
  10597. * @returns Array of picking infos
  10598. */
  10599. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10600. private _comparePickingInfo;
  10601. private static smallnum;
  10602. private static rayl;
  10603. /**
  10604. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10605. * @param sega the first point of the segment to test the intersection against
  10606. * @param segb the second point of the segment to test the intersection against
  10607. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10608. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10609. */
  10610. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10611. /**
  10612. * Update the ray from viewport position
  10613. * @param x position
  10614. * @param y y position
  10615. * @param viewportWidth viewport width
  10616. * @param viewportHeight viewport height
  10617. * @param world world matrix
  10618. * @param view view matrix
  10619. * @param projection projection matrix
  10620. * @returns this ray updated
  10621. */
  10622. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10623. /**
  10624. * Creates a ray with origin and direction of 0,0,0
  10625. * @returns the new ray
  10626. */
  10627. static Zero(): Ray;
  10628. /**
  10629. * Creates a new ray from screen space and viewport
  10630. * @param x position
  10631. * @param y y position
  10632. * @param viewportWidth viewport width
  10633. * @param viewportHeight viewport height
  10634. * @param world world matrix
  10635. * @param view view matrix
  10636. * @param projection projection matrix
  10637. * @returns new ray
  10638. */
  10639. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10640. /**
  10641. * 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
  10642. * transformed to the given world matrix.
  10643. * @param origin The origin point
  10644. * @param end The end point
  10645. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10646. * @returns the new ray
  10647. */
  10648. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10649. /**
  10650. * Transforms a ray by a matrix
  10651. * @param ray ray to transform
  10652. * @param matrix matrix to apply
  10653. * @returns the resulting new ray
  10654. */
  10655. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10656. /**
  10657. * Transforms a ray by a matrix
  10658. * @param ray ray to transform
  10659. * @param matrix matrix to apply
  10660. * @param result ray to store result in
  10661. */
  10662. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10663. /**
  10664. * Unproject a ray from screen space to object space
  10665. * @param sourceX defines the screen space x coordinate to use
  10666. * @param sourceY defines the screen space y coordinate to use
  10667. * @param viewportWidth defines the current width of the viewport
  10668. * @param viewportHeight defines the current height of the viewport
  10669. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10670. * @param view defines the view matrix to use
  10671. * @param projection defines the projection matrix to use
  10672. */
  10673. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10674. }
  10675. /**
  10676. * Type used to define predicate used to select faces when a mesh intersection is detected
  10677. */
  10678. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10679. interface Scene {
  10680. /** @hidden */
  10681. _tempPickingRay: Nullable<Ray>;
  10682. /** @hidden */
  10683. _cachedRayForTransform: Ray;
  10684. /** @hidden */
  10685. _pickWithRayInverseMatrix: Matrix;
  10686. /** @hidden */
  10687. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10688. /** @hidden */
  10689. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10690. /** @hidden */
  10691. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  10692. }
  10693. }
  10694. declare module BABYLON {
  10695. /**
  10696. * Groups all the scene component constants in one place to ease maintenance.
  10697. * @hidden
  10698. */
  10699. export class SceneComponentConstants {
  10700. static readonly NAME_EFFECTLAYER: string;
  10701. static readonly NAME_LAYER: string;
  10702. static readonly NAME_LENSFLARESYSTEM: string;
  10703. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10704. static readonly NAME_PARTICLESYSTEM: string;
  10705. static readonly NAME_GAMEPAD: string;
  10706. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10707. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10708. static readonly NAME_PREPASSRENDERER: string;
  10709. static readonly NAME_DEPTHRENDERER: string;
  10710. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10711. static readonly NAME_SPRITE: string;
  10712. static readonly NAME_SUBSURFACE: string;
  10713. static readonly NAME_OUTLINERENDERER: string;
  10714. static readonly NAME_PROCEDURALTEXTURE: string;
  10715. static readonly NAME_SHADOWGENERATOR: string;
  10716. static readonly NAME_OCTREE: string;
  10717. static readonly NAME_PHYSICSENGINE: string;
  10718. static readonly NAME_AUDIO: string;
  10719. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10720. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10721. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10722. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10723. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10724. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10725. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10726. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10727. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10728. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10729. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10730. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10731. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10732. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10733. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10734. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10735. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10736. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10737. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10738. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10739. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10740. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10741. static readonly STEP_AFTERRENDER_AUDIO: number;
  10742. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10743. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10744. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10745. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10746. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10747. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10748. static readonly STEP_POINTERMOVE_SPRITE: number;
  10749. static readonly STEP_POINTERDOWN_SPRITE: number;
  10750. static readonly STEP_POINTERUP_SPRITE: number;
  10751. }
  10752. /**
  10753. * This represents a scene component.
  10754. *
  10755. * This is used to decouple the dependency the scene is having on the different workloads like
  10756. * layers, post processes...
  10757. */
  10758. export interface ISceneComponent {
  10759. /**
  10760. * The name of the component. Each component must have a unique name.
  10761. */
  10762. name: string;
  10763. /**
  10764. * The scene the component belongs to.
  10765. */
  10766. scene: Scene;
  10767. /**
  10768. * Register the component to one instance of a scene.
  10769. */
  10770. register(): void;
  10771. /**
  10772. * Rebuilds the elements related to this component in case of
  10773. * context lost for instance.
  10774. */
  10775. rebuild(): void;
  10776. /**
  10777. * Disposes the component and the associated ressources.
  10778. */
  10779. dispose(): void;
  10780. }
  10781. /**
  10782. * This represents a SERIALIZABLE scene component.
  10783. *
  10784. * This extends Scene Component to add Serialization methods on top.
  10785. */
  10786. export interface ISceneSerializableComponent extends ISceneComponent {
  10787. /**
  10788. * Adds all the elements from the container to the scene
  10789. * @param container the container holding the elements
  10790. */
  10791. addFromContainer(container: AbstractScene): void;
  10792. /**
  10793. * Removes all the elements in the container from the scene
  10794. * @param container contains the elements to remove
  10795. * @param dispose if the removed element should be disposed (default: false)
  10796. */
  10797. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10798. /**
  10799. * Serializes the component data to the specified json object
  10800. * @param serializationObject The object to serialize to
  10801. */
  10802. serialize(serializationObject: any): void;
  10803. }
  10804. /**
  10805. * Strong typing of a Mesh related stage step action
  10806. */
  10807. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10808. /**
  10809. * Strong typing of a Evaluate Sub Mesh related stage step action
  10810. */
  10811. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10812. /**
  10813. * Strong typing of a pre active Mesh related stage step action
  10814. */
  10815. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  10816. /**
  10817. * Strong typing of a Camera related stage step action
  10818. */
  10819. export type CameraStageAction = (camera: Camera) => void;
  10820. /**
  10821. * Strong typing of a Camera Frame buffer related stage step action
  10822. */
  10823. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10824. /**
  10825. * Strong typing of a Render Target related stage step action
  10826. */
  10827. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10828. /**
  10829. * Strong typing of a RenderingGroup related stage step action
  10830. */
  10831. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10832. /**
  10833. * Strong typing of a Mesh Render related stage step action
  10834. */
  10835. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10836. /**
  10837. * Strong typing of a simple stage step action
  10838. */
  10839. export type SimpleStageAction = () => void;
  10840. /**
  10841. * Strong typing of a render target action.
  10842. */
  10843. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10844. /**
  10845. * Strong typing of a pointer move action.
  10846. */
  10847. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10848. /**
  10849. * Strong typing of a pointer up/down action.
  10850. */
  10851. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10852. /**
  10853. * Representation of a stage in the scene (Basically a list of ordered steps)
  10854. * @hidden
  10855. */
  10856. export class Stage<T extends Function> extends Array<{
  10857. index: number;
  10858. component: ISceneComponent;
  10859. action: T;
  10860. }> {
  10861. /**
  10862. * Hide ctor from the rest of the world.
  10863. * @param items The items to add.
  10864. */
  10865. private constructor();
  10866. /**
  10867. * Creates a new Stage.
  10868. * @returns A new instance of a Stage
  10869. */
  10870. static Create<T extends Function>(): Stage<T>;
  10871. /**
  10872. * Registers a step in an ordered way in the targeted stage.
  10873. * @param index Defines the position to register the step in
  10874. * @param component Defines the component attached to the step
  10875. * @param action Defines the action to launch during the step
  10876. */
  10877. registerStep(index: number, component: ISceneComponent, action: T): void;
  10878. /**
  10879. * Clears all the steps from the stage.
  10880. */
  10881. clear(): void;
  10882. }
  10883. }
  10884. declare module BABYLON {
  10885. interface Scene {
  10886. /** @hidden */
  10887. _pointerOverSprite: Nullable<Sprite>;
  10888. /** @hidden */
  10889. _pickedDownSprite: Nullable<Sprite>;
  10890. /** @hidden */
  10891. _tempSpritePickingRay: Nullable<Ray>;
  10892. /**
  10893. * All of the sprite managers added to this scene
  10894. * @see https://doc.babylonjs.com/babylon101/sprites
  10895. */
  10896. spriteManagers: Array<ISpriteManager>;
  10897. /**
  10898. * An event triggered when sprites rendering is about to start
  10899. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10900. */
  10901. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10902. /**
  10903. * An event triggered when sprites rendering is done
  10904. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10905. */
  10906. onAfterSpritesRenderingObservable: Observable<Scene>;
  10907. /** @hidden */
  10908. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10909. /** Launch a ray to try to pick a sprite in the scene
  10910. * @param x position on screen
  10911. * @param y position on screen
  10912. * @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
  10913. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10914. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10915. * @returns a PickingInfo
  10916. */
  10917. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10918. /** Use the given ray to pick a sprite in the scene
  10919. * @param ray The ray (in world space) to use to pick meshes
  10920. * @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
  10921. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10922. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10923. * @returns a PickingInfo
  10924. */
  10925. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10926. /** @hidden */
  10927. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10928. /** Launch a ray to try to pick sprites in the scene
  10929. * @param x position on screen
  10930. * @param y position on screen
  10931. * @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
  10932. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10933. * @returns a PickingInfo array
  10934. */
  10935. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10936. /** Use the given ray to pick sprites in the scene
  10937. * @param ray The ray (in world space) to use to pick meshes
  10938. * @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
  10939. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10940. * @returns a PickingInfo array
  10941. */
  10942. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10943. /**
  10944. * Force the sprite under the pointer
  10945. * @param sprite defines the sprite to use
  10946. */
  10947. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10948. /**
  10949. * Gets the sprite under the pointer
  10950. * @returns a Sprite or null if no sprite is under the pointer
  10951. */
  10952. getPointerOverSprite(): Nullable<Sprite>;
  10953. }
  10954. /**
  10955. * Defines the sprite scene component responsible to manage sprites
  10956. * in a given scene.
  10957. */
  10958. export class SpriteSceneComponent implements ISceneComponent {
  10959. /**
  10960. * The component name helpfull to identify the component in the list of scene components.
  10961. */
  10962. readonly name: string;
  10963. /**
  10964. * The scene the component belongs to.
  10965. */
  10966. scene: Scene;
  10967. /** @hidden */
  10968. private _spritePredicate;
  10969. /**
  10970. * Creates a new instance of the component for the given scene
  10971. * @param scene Defines the scene to register the component in
  10972. */
  10973. constructor(scene: Scene);
  10974. /**
  10975. * Registers the component in a given scene
  10976. */
  10977. register(): void;
  10978. /**
  10979. * Rebuilds the elements related to this component in case of
  10980. * context lost for instance.
  10981. */
  10982. rebuild(): void;
  10983. /**
  10984. * Disposes the component and the associated ressources.
  10985. */
  10986. dispose(): void;
  10987. private _pickSpriteButKeepRay;
  10988. private _pointerMove;
  10989. private _pointerDown;
  10990. private _pointerUp;
  10991. }
  10992. }
  10993. declare module BABYLON {
  10994. /** @hidden */
  10995. export var fogFragmentDeclaration: {
  10996. name: string;
  10997. shader: string;
  10998. };
  10999. }
  11000. declare module BABYLON {
  11001. /** @hidden */
  11002. export var fogFragment: {
  11003. name: string;
  11004. shader: string;
  11005. };
  11006. }
  11007. declare module BABYLON {
  11008. /** @hidden */
  11009. export var imageProcessingCompatibility: {
  11010. name: string;
  11011. shader: string;
  11012. };
  11013. }
  11014. declare module BABYLON {
  11015. /** @hidden */
  11016. export var spritesPixelShader: {
  11017. name: string;
  11018. shader: string;
  11019. };
  11020. }
  11021. declare module BABYLON {
  11022. /** @hidden */
  11023. export var fogVertexDeclaration: {
  11024. name: string;
  11025. shader: string;
  11026. };
  11027. }
  11028. declare module BABYLON {
  11029. /** @hidden */
  11030. export var spritesVertexShader: {
  11031. name: string;
  11032. shader: string;
  11033. };
  11034. }
  11035. declare module BABYLON {
  11036. /**
  11037. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11038. */
  11039. export interface ISpriteManager extends IDisposable {
  11040. /**
  11041. * Gets manager's name
  11042. */
  11043. name: string;
  11044. /**
  11045. * Restricts the camera to viewing objects with the same layerMask.
  11046. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11047. */
  11048. layerMask: number;
  11049. /**
  11050. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11051. */
  11052. isPickable: boolean;
  11053. /**
  11054. * Gets the hosting scene
  11055. */
  11056. scene: Scene;
  11057. /**
  11058. * Specifies the rendering group id for this mesh (0 by default)
  11059. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11060. */
  11061. renderingGroupId: number;
  11062. /**
  11063. * Defines the list of sprites managed by the manager.
  11064. */
  11065. sprites: Array<Sprite>;
  11066. /**
  11067. * Gets or sets the spritesheet texture
  11068. */
  11069. texture: Texture;
  11070. /** Defines the default width of a cell in the spritesheet */
  11071. cellWidth: number;
  11072. /** Defines the default height of a cell in the spritesheet */
  11073. cellHeight: number;
  11074. /**
  11075. * Tests the intersection of a sprite with a specific ray.
  11076. * @param ray The ray we are sending to test the collision
  11077. * @param camera The camera space we are sending rays in
  11078. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11079. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11080. * @returns picking info or null.
  11081. */
  11082. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11083. /**
  11084. * Intersects the sprites with a ray
  11085. * @param ray defines the ray to intersect with
  11086. * @param camera defines the current active camera
  11087. * @param predicate defines a predicate used to select candidate sprites
  11088. * @returns null if no hit or a PickingInfo array
  11089. */
  11090. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11091. /**
  11092. * Renders the list of sprites on screen.
  11093. */
  11094. render(): void;
  11095. }
  11096. /**
  11097. * Class used to manage multiple sprites on the same spritesheet
  11098. * @see https://doc.babylonjs.com/babylon101/sprites
  11099. */
  11100. export class SpriteManager implements ISpriteManager {
  11101. /** defines the manager's name */
  11102. name: string;
  11103. /** Define the Url to load snippets */
  11104. static SnippetUrl: string;
  11105. /** Snippet ID if the manager was created from the snippet server */
  11106. snippetId: string;
  11107. /** Gets the list of sprites */
  11108. sprites: Sprite[];
  11109. /** Gets or sets the rendering group id (0 by default) */
  11110. renderingGroupId: number;
  11111. /** Gets or sets camera layer mask */
  11112. layerMask: number;
  11113. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11114. fogEnabled: boolean;
  11115. /** Gets or sets a boolean indicating if the sprites are pickable */
  11116. isPickable: boolean;
  11117. /** Defines the default width of a cell in the spritesheet */
  11118. cellWidth: number;
  11119. /** Defines the default height of a cell in the spritesheet */
  11120. cellHeight: number;
  11121. /** Associative array from JSON sprite data file */
  11122. private _cellData;
  11123. /** Array of sprite names from JSON sprite data file */
  11124. private _spriteMap;
  11125. /** True when packed cell data from JSON file is ready*/
  11126. private _packedAndReady;
  11127. private _textureContent;
  11128. private _useInstancing;
  11129. /**
  11130. * An event triggered when the manager is disposed.
  11131. */
  11132. onDisposeObservable: Observable<SpriteManager>;
  11133. private _onDisposeObserver;
  11134. /**
  11135. * Callback called when the manager is disposed
  11136. */
  11137. set onDispose(callback: () => void);
  11138. private _capacity;
  11139. private _fromPacked;
  11140. private _spriteTexture;
  11141. private _epsilon;
  11142. private _scene;
  11143. private _vertexData;
  11144. private _buffer;
  11145. private _vertexBuffers;
  11146. private _spriteBuffer;
  11147. private _indexBuffer;
  11148. private _effectBase;
  11149. private _effectFog;
  11150. private _vertexBufferSize;
  11151. /**
  11152. * Gets or sets the unique id of the sprite
  11153. */
  11154. uniqueId: number;
  11155. /**
  11156. * Gets the array of sprites
  11157. */
  11158. get children(): Sprite[];
  11159. /**
  11160. * Gets the hosting scene
  11161. */
  11162. get scene(): Scene;
  11163. /**
  11164. * Gets the capacity of the manager
  11165. */
  11166. get capacity(): number;
  11167. /**
  11168. * Gets or sets the spritesheet texture
  11169. */
  11170. get texture(): Texture;
  11171. set texture(value: Texture);
  11172. private _blendMode;
  11173. /**
  11174. * Blend mode use to render the particle, it can be any of
  11175. * the static Constants.ALPHA_x properties provided in this class.
  11176. * Default value is Constants.ALPHA_COMBINE
  11177. */
  11178. get blendMode(): number;
  11179. set blendMode(blendMode: number);
  11180. /** Disables writing to the depth buffer when rendering the sprites.
  11181. * It can be handy to disable depth writing when using textures without alpha channel
  11182. * and setting some specific blend modes.
  11183. */
  11184. disableDepthWrite: boolean;
  11185. /**
  11186. * Creates a new sprite manager
  11187. * @param name defines the manager's name
  11188. * @param imgUrl defines the sprite sheet url
  11189. * @param capacity defines the maximum allowed number of sprites
  11190. * @param cellSize defines the size of a sprite cell
  11191. * @param scene defines the hosting scene
  11192. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11193. * @param samplingMode defines the smapling mode to use with spritesheet
  11194. * @param fromPacked set to false; do not alter
  11195. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11196. */
  11197. constructor(
  11198. /** defines the manager's name */
  11199. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11200. /**
  11201. * Returns the string "SpriteManager"
  11202. * @returns "SpriteManager"
  11203. */
  11204. getClassName(): string;
  11205. private _makePacked;
  11206. private _appendSpriteVertex;
  11207. private _checkTextureAlpha;
  11208. /**
  11209. * Intersects the sprites with a ray
  11210. * @param ray defines the ray to intersect with
  11211. * @param camera defines the current active camera
  11212. * @param predicate defines a predicate used to select candidate sprites
  11213. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11214. * @returns null if no hit or a PickingInfo
  11215. */
  11216. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11217. /**
  11218. * Intersects the sprites with a ray
  11219. * @param ray defines the ray to intersect with
  11220. * @param camera defines the current active camera
  11221. * @param predicate defines a predicate used to select candidate sprites
  11222. * @returns null if no hit or a PickingInfo array
  11223. */
  11224. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11225. /**
  11226. * Render all child sprites
  11227. */
  11228. render(): void;
  11229. /**
  11230. * Release associated resources
  11231. */
  11232. dispose(): void;
  11233. /**
  11234. * Serializes the sprite manager to a JSON object
  11235. * @param serializeTexture defines if the texture must be serialized as well
  11236. * @returns the JSON object
  11237. */
  11238. serialize(serializeTexture?: boolean): any;
  11239. /**
  11240. * Parses a JSON object to create a new sprite manager.
  11241. * @param parsedManager The JSON object to parse
  11242. * @param scene The scene to create the sprite managerin
  11243. * @param rootUrl The root url to use to load external dependencies like texture
  11244. * @returns the new sprite manager
  11245. */
  11246. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11247. /**
  11248. * Creates a sprite manager from a snippet saved in a remote file
  11249. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11250. * @param url defines the url to load from
  11251. * @param scene defines the hosting scene
  11252. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11253. * @returns a promise that will resolve to the new sprite manager
  11254. */
  11255. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11256. /**
  11257. * Creates a sprite manager from a snippet saved by the sprite editor
  11258. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11259. * @param scene defines the hosting scene
  11260. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11261. * @returns a promise that will resolve to the new sprite manager
  11262. */
  11263. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11264. }
  11265. }
  11266. declare module BABYLON {
  11267. /** Interface used by value gradients (color, factor, ...) */
  11268. export interface IValueGradient {
  11269. /**
  11270. * Gets or sets the gradient value (between 0 and 1)
  11271. */
  11272. gradient: number;
  11273. }
  11274. /** Class used to store color4 gradient */
  11275. export class ColorGradient implements IValueGradient {
  11276. /**
  11277. * Gets or sets the gradient value (between 0 and 1)
  11278. */
  11279. gradient: number;
  11280. /**
  11281. * Gets or sets first associated color
  11282. */
  11283. color1: Color4;
  11284. /**
  11285. * Gets or sets second associated color
  11286. */
  11287. color2?: Color4 | undefined;
  11288. /**
  11289. * Creates a new color4 gradient
  11290. * @param gradient gets or sets the gradient value (between 0 and 1)
  11291. * @param color1 gets or sets first associated color
  11292. * @param color2 gets or sets first second color
  11293. */
  11294. constructor(
  11295. /**
  11296. * Gets or sets the gradient value (between 0 and 1)
  11297. */
  11298. gradient: number,
  11299. /**
  11300. * Gets or sets first associated color
  11301. */
  11302. color1: Color4,
  11303. /**
  11304. * Gets or sets second associated color
  11305. */
  11306. color2?: Color4 | undefined);
  11307. /**
  11308. * Will get a color picked randomly between color1 and color2.
  11309. * If color2 is undefined then color1 will be used
  11310. * @param result defines the target Color4 to store the result in
  11311. */
  11312. getColorToRef(result: Color4): void;
  11313. }
  11314. /** Class used to store color 3 gradient */
  11315. export class Color3Gradient implements IValueGradient {
  11316. /**
  11317. * Gets or sets the gradient value (between 0 and 1)
  11318. */
  11319. gradient: number;
  11320. /**
  11321. * Gets or sets the associated color
  11322. */
  11323. color: Color3;
  11324. /**
  11325. * Creates a new color3 gradient
  11326. * @param gradient gets or sets the gradient value (between 0 and 1)
  11327. * @param color gets or sets associated color
  11328. */
  11329. constructor(
  11330. /**
  11331. * Gets or sets the gradient value (between 0 and 1)
  11332. */
  11333. gradient: number,
  11334. /**
  11335. * Gets or sets the associated color
  11336. */
  11337. color: Color3);
  11338. }
  11339. /** Class used to store factor gradient */
  11340. export class FactorGradient implements IValueGradient {
  11341. /**
  11342. * Gets or sets the gradient value (between 0 and 1)
  11343. */
  11344. gradient: number;
  11345. /**
  11346. * Gets or sets first associated factor
  11347. */
  11348. factor1: number;
  11349. /**
  11350. * Gets or sets second associated factor
  11351. */
  11352. factor2?: number | undefined;
  11353. /**
  11354. * Creates a new factor gradient
  11355. * @param gradient gets or sets the gradient value (between 0 and 1)
  11356. * @param factor1 gets or sets first associated factor
  11357. * @param factor2 gets or sets second associated factor
  11358. */
  11359. constructor(
  11360. /**
  11361. * Gets or sets the gradient value (between 0 and 1)
  11362. */
  11363. gradient: number,
  11364. /**
  11365. * Gets or sets first associated factor
  11366. */
  11367. factor1: number,
  11368. /**
  11369. * Gets or sets second associated factor
  11370. */
  11371. factor2?: number | undefined);
  11372. /**
  11373. * Will get a number picked randomly between factor1 and factor2.
  11374. * If factor2 is undefined then factor1 will be used
  11375. * @returns the picked number
  11376. */
  11377. getFactor(): number;
  11378. }
  11379. /**
  11380. * Helper used to simplify some generic gradient tasks
  11381. */
  11382. export class GradientHelper {
  11383. /**
  11384. * Gets the current gradient from an array of IValueGradient
  11385. * @param ratio defines the current ratio to get
  11386. * @param gradients defines the array of IValueGradient
  11387. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11388. */
  11389. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11390. }
  11391. }
  11392. declare module BABYLON {
  11393. interface ThinEngine {
  11394. /**
  11395. * Creates a raw texture
  11396. * @param data defines the data to store in the texture
  11397. * @param width defines the width of the texture
  11398. * @param height defines the height of the texture
  11399. * @param format defines the format of the data
  11400. * @param generateMipMaps defines if the engine should generate the mip levels
  11401. * @param invertY defines if data must be stored with Y axis inverted
  11402. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11403. * @param compression defines the compression used (null by default)
  11404. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11405. * @returns the raw texture inside an InternalTexture
  11406. */
  11407. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11408. /**
  11409. * Update a raw texture
  11410. * @param texture defines the texture to update
  11411. * @param data defines the data to store in the texture
  11412. * @param format defines the format of the data
  11413. * @param invertY defines if data must be stored with Y axis inverted
  11414. */
  11415. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11416. /**
  11417. * Update a raw texture
  11418. * @param texture defines the texture to update
  11419. * @param data defines the data to store in the texture
  11420. * @param format defines the format of the data
  11421. * @param invertY defines if data must be stored with Y axis inverted
  11422. * @param compression defines the compression used (null by default)
  11423. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11424. */
  11425. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11426. /**
  11427. * Creates a new raw cube texture
  11428. * @param data defines the array of data to use to create each face
  11429. * @param size defines the size of the textures
  11430. * @param format defines the format of the data
  11431. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11432. * @param generateMipMaps defines if the engine should generate the mip levels
  11433. * @param invertY defines if data must be stored with Y axis inverted
  11434. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11435. * @param compression defines the compression used (null by default)
  11436. * @returns the cube texture as an InternalTexture
  11437. */
  11438. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11439. /**
  11440. * Update a raw cube texture
  11441. * @param texture defines the texture to udpdate
  11442. * @param data defines the data to store
  11443. * @param format defines the data format
  11444. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11445. * @param invertY defines if data must be stored with Y axis inverted
  11446. */
  11447. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11448. /**
  11449. * Update a raw cube texture
  11450. * @param texture defines the texture to udpdate
  11451. * @param data defines the data to store
  11452. * @param format defines the data format
  11453. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11454. * @param invertY defines if data must be stored with Y axis inverted
  11455. * @param compression defines the compression used (null by default)
  11456. */
  11457. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11458. /**
  11459. * Update a raw cube texture
  11460. * @param texture defines the texture to udpdate
  11461. * @param data defines the data to store
  11462. * @param format defines the data format
  11463. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11464. * @param invertY defines if data must be stored with Y axis inverted
  11465. * @param compression defines the compression used (null by default)
  11466. * @param level defines which level of the texture to update
  11467. */
  11468. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11469. /**
  11470. * Creates a new raw cube texture from a specified url
  11471. * @param url defines the url where the data is located
  11472. * @param scene defines the current scene
  11473. * @param size defines the size of the textures
  11474. * @param format defines the format of the data
  11475. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11476. * @param noMipmap defines if the engine should avoid generating the mip levels
  11477. * @param callback defines a callback used to extract texture data from loaded data
  11478. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11479. * @param onLoad defines a callback called when texture is loaded
  11480. * @param onError defines a callback called if there is an error
  11481. * @returns the cube texture as an InternalTexture
  11482. */
  11483. 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;
  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. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11497. * @param invertY defines if data must be stored with Y axis inverted
  11498. * @returns the cube texture as an InternalTexture
  11499. */
  11500. 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;
  11501. /**
  11502. * Creates a new raw 3D texture
  11503. * @param data defines the data used to create the texture
  11504. * @param width defines the width of the texture
  11505. * @param height defines the height of the texture
  11506. * @param depth defines the depth of the texture
  11507. * @param format defines the format of the texture
  11508. * @param generateMipMaps defines if the engine must generate mip levels
  11509. * @param invertY defines if data must be stored with Y axis inverted
  11510. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11511. * @param compression defines the compressed used (can be null)
  11512. * @param textureType defines the compressed used (can be null)
  11513. * @returns a new raw 3D texture (stored in an InternalTexture)
  11514. */
  11515. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11516. /**
  11517. * Update a raw 3D texture
  11518. * @param texture defines the texture to update
  11519. * @param data defines the data to store
  11520. * @param format defines the data format
  11521. * @param invertY defines if data must be stored with Y axis inverted
  11522. */
  11523. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11524. /**
  11525. * Update a raw 3D texture
  11526. * @param texture defines the texture to update
  11527. * @param data defines the data to store
  11528. * @param format defines the data format
  11529. * @param invertY defines if data must be stored with Y axis inverted
  11530. * @param compression defines the used compression (can be null)
  11531. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11532. */
  11533. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11534. /**
  11535. * Creates a new raw 2D array texture
  11536. * @param data defines the data used to create the texture
  11537. * @param width defines the width of the texture
  11538. * @param height defines the height of the texture
  11539. * @param depth defines the number of layers of the texture
  11540. * @param format defines the format of the texture
  11541. * @param generateMipMaps defines if the engine must generate mip levels
  11542. * @param invertY defines if data must be stored with Y axis inverted
  11543. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11544. * @param compression defines the compressed used (can be null)
  11545. * @param textureType defines the compressed used (can be null)
  11546. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11547. */
  11548. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11549. /**
  11550. * Update a raw 2D array texture
  11551. * @param texture defines the texture to update
  11552. * @param data defines the data to store
  11553. * @param format defines the data format
  11554. * @param invertY defines if data must be stored with Y axis inverted
  11555. */
  11556. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11557. /**
  11558. * Update a raw 2D array texture
  11559. * @param texture defines the texture to update
  11560. * @param data defines the data to store
  11561. * @param format defines the data format
  11562. * @param invertY defines if data must be stored with Y axis inverted
  11563. * @param compression defines the used compression (can be null)
  11564. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11565. */
  11566. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11567. }
  11568. }
  11569. declare module BABYLON {
  11570. /**
  11571. * Raw texture can help creating a texture directly from an array of data.
  11572. * This can be super useful if you either get the data from an uncompressed source or
  11573. * if you wish to create your texture pixel by pixel.
  11574. */
  11575. export class RawTexture extends Texture {
  11576. /**
  11577. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11578. */
  11579. format: number;
  11580. /**
  11581. * Instantiates a new RawTexture.
  11582. * Raw texture can help creating a texture directly from an array of data.
  11583. * This can be super useful if you either get the data from an uncompressed source or
  11584. * if you wish to create your texture pixel by pixel.
  11585. * @param data define the array of data to use to create the texture
  11586. * @param width define the width of the texture
  11587. * @param height define the height of the texture
  11588. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11589. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11590. * @param generateMipMaps define whether mip maps should be generated or not
  11591. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11592. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11593. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11594. */
  11595. constructor(data: ArrayBufferView, width: number, height: number,
  11596. /**
  11597. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11598. */
  11599. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11600. /**
  11601. * Updates the texture underlying data.
  11602. * @param data Define the new data of the texture
  11603. */
  11604. update(data: ArrayBufferView): void;
  11605. /**
  11606. * Creates a luminance texture from some data.
  11607. * @param data Define the texture data
  11608. * @param width Define the width of the texture
  11609. * @param height Define the height of the texture
  11610. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11611. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11612. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11613. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11614. * @returns the luminance texture
  11615. */
  11616. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11617. /**
  11618. * Creates a luminance alpha texture from some data.
  11619. * @param data Define the texture data
  11620. * @param width Define the width of the texture
  11621. * @param height Define the height of the texture
  11622. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11623. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11624. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11625. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11626. * @returns the luminance alpha texture
  11627. */
  11628. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11629. /**
  11630. * Creates an alpha texture from some data.
  11631. * @param data Define the texture data
  11632. * @param width Define the width of the texture
  11633. * @param height Define the height of the texture
  11634. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11635. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11636. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11637. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11638. * @returns the alpha texture
  11639. */
  11640. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11641. /**
  11642. * Creates a RGB texture from some data.
  11643. * @param data Define the texture data
  11644. * @param width Define the width of the texture
  11645. * @param height Define the height of the texture
  11646. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11647. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11648. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11649. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11650. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11651. * @returns the RGB alpha texture
  11652. */
  11653. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11654. /**
  11655. * Creates a RGBA texture from some data.
  11656. * @param data Define the texture data
  11657. * @param width Define the width of the texture
  11658. * @param height Define the height of the texture
  11659. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11660. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11661. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11662. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11663. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11664. * @returns the RGBA texture
  11665. */
  11666. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11667. /**
  11668. * Creates a R texture from some data.
  11669. * @param data Define the texture data
  11670. * @param width Define the width of the texture
  11671. * @param height Define the height of the texture
  11672. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11673. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11674. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11675. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11676. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11677. * @returns the R texture
  11678. */
  11679. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11680. }
  11681. }
  11682. declare module BABYLON {
  11683. interface ThinEngine {
  11684. /**
  11685. * Update a dynamic index buffer
  11686. * @param indexBuffer defines the target index buffer
  11687. * @param indices defines the data to update
  11688. * @param offset defines the offset in the target index buffer where update should start
  11689. */
  11690. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11691. /**
  11692. * Updates a dynamic vertex buffer.
  11693. * @param vertexBuffer the vertex buffer to update
  11694. * @param data the data used to update the vertex buffer
  11695. * @param byteOffset the byte offset of the data
  11696. * @param byteLength the byte length of the data
  11697. */
  11698. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11699. }
  11700. }
  11701. declare module BABYLON {
  11702. interface AbstractScene {
  11703. /**
  11704. * The list of procedural textures added to the scene
  11705. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11706. */
  11707. proceduralTextures: Array<ProceduralTexture>;
  11708. }
  11709. /**
  11710. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11711. * in a given scene.
  11712. */
  11713. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11714. /**
  11715. * The component name helpfull to identify the component in the list of scene components.
  11716. */
  11717. readonly name: string;
  11718. /**
  11719. * The scene the component belongs to.
  11720. */
  11721. scene: Scene;
  11722. /**
  11723. * Creates a new instance of the component for the given scene
  11724. * @param scene Defines the scene to register the component in
  11725. */
  11726. constructor(scene: Scene);
  11727. /**
  11728. * Registers the component in a given scene
  11729. */
  11730. register(): void;
  11731. /**
  11732. * Rebuilds the elements related to this component in case of
  11733. * context lost for instance.
  11734. */
  11735. rebuild(): void;
  11736. /**
  11737. * Disposes the component and the associated ressources.
  11738. */
  11739. dispose(): void;
  11740. private _beforeClear;
  11741. }
  11742. }
  11743. declare module BABYLON {
  11744. interface ThinEngine {
  11745. /**
  11746. * Creates a new render target cube texture
  11747. * @param size defines the size of the texture
  11748. * @param options defines the options used to create the texture
  11749. * @returns a new render target cube texture stored in an InternalTexture
  11750. */
  11751. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11752. }
  11753. }
  11754. declare module BABYLON {
  11755. /** @hidden */
  11756. export var proceduralVertexShader: {
  11757. name: string;
  11758. shader: string;
  11759. };
  11760. }
  11761. declare module BABYLON {
  11762. /**
  11763. * 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.
  11764. * This is the base class of any Procedural texture and contains most of the shareable code.
  11765. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11766. */
  11767. export class ProceduralTexture extends Texture {
  11768. /**
  11769. * Define if the texture is enabled or not (disabled texture will not render)
  11770. */
  11771. isEnabled: boolean;
  11772. /**
  11773. * Define if the texture must be cleared before rendering (default is true)
  11774. */
  11775. autoClear: boolean;
  11776. /**
  11777. * Callback called when the texture is generated
  11778. */
  11779. onGenerated: () => void;
  11780. /**
  11781. * Event raised when the texture is generated
  11782. */
  11783. onGeneratedObservable: Observable<ProceduralTexture>;
  11784. /**
  11785. * Event raised before the texture is generated
  11786. */
  11787. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  11788. /**
  11789. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  11790. */
  11791. nodeMaterialSource: Nullable<NodeMaterial>;
  11792. /** @hidden */
  11793. _generateMipMaps: boolean;
  11794. /** @hidden **/
  11795. _effect: Effect;
  11796. /** @hidden */
  11797. _textures: {
  11798. [key: string]: Texture;
  11799. };
  11800. /** @hidden */
  11801. protected _fallbackTexture: Nullable<Texture>;
  11802. private _size;
  11803. private _currentRefreshId;
  11804. private _frameId;
  11805. private _refreshRate;
  11806. private _vertexBuffers;
  11807. private _indexBuffer;
  11808. private _uniforms;
  11809. private _samplers;
  11810. private _fragment;
  11811. private _floats;
  11812. private _ints;
  11813. private _floatsArrays;
  11814. private _colors3;
  11815. private _colors4;
  11816. private _vectors2;
  11817. private _vectors3;
  11818. private _matrices;
  11819. private _fallbackTextureUsed;
  11820. private _fullEngine;
  11821. private _cachedDefines;
  11822. private _contentUpdateId;
  11823. private _contentData;
  11824. /**
  11825. * Instantiates a new procedural texture.
  11826. * 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.
  11827. * This is the base class of any Procedural texture and contains most of the shareable code.
  11828. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11829. * @param name Define the name of the texture
  11830. * @param size Define the size of the texture to create
  11831. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11832. * @param scene Define the scene the texture belongs to
  11833. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11834. * @param generateMipMaps Define if the texture should creates mip maps or not
  11835. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11836. * @param textureType The FBO internal texture type
  11837. */
  11838. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  11839. /**
  11840. * The effect that is created when initializing the post process.
  11841. * @returns The created effect corresponding the the postprocess.
  11842. */
  11843. getEffect(): Effect;
  11844. /**
  11845. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11846. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11847. */
  11848. getContent(): Nullable<ArrayBufferView>;
  11849. private _createIndexBuffer;
  11850. /** @hidden */
  11851. _rebuild(): void;
  11852. /**
  11853. * Resets the texture in order to recreate its associated resources.
  11854. * This can be called in case of context loss
  11855. */
  11856. reset(): void;
  11857. protected _getDefines(): string;
  11858. /**
  11859. * Is the texture ready to be used ? (rendered at least once)
  11860. * @returns true if ready, otherwise, false.
  11861. */
  11862. isReady(): boolean;
  11863. /**
  11864. * Resets the refresh counter of the texture and start bak from scratch.
  11865. * Could be useful to regenerate the texture if it is setup to render only once.
  11866. */
  11867. resetRefreshCounter(): void;
  11868. /**
  11869. * Set the fragment shader to use in order to render the texture.
  11870. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11871. */
  11872. setFragment(fragment: any): void;
  11873. /**
  11874. * Define the refresh rate of the texture or the rendering frequency.
  11875. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11876. */
  11877. get refreshRate(): number;
  11878. set refreshRate(value: number);
  11879. /** @hidden */
  11880. _shouldRender(): boolean;
  11881. /**
  11882. * Get the size the texture is rendering at.
  11883. * @returns the size (on cube texture it is always squared)
  11884. */
  11885. getRenderSize(): RenderTargetTextureSize;
  11886. /**
  11887. * Resize the texture to new value.
  11888. * @param size Define the new size the texture should have
  11889. * @param generateMipMaps Define whether the new texture should create mip maps
  11890. */
  11891. resize(size: number, generateMipMaps: boolean): void;
  11892. private _checkUniform;
  11893. /**
  11894. * Set a texture in the shader program used to render.
  11895. * @param name Define the name of the uniform samplers as defined in the shader
  11896. * @param texture Define the texture to bind to this sampler
  11897. * @return the texture itself allowing "fluent" like uniform updates
  11898. */
  11899. setTexture(name: string, texture: Texture): ProceduralTexture;
  11900. /**
  11901. * Set a float in the shader.
  11902. * @param name Define the name of the uniform as defined in the shader
  11903. * @param value Define the value to give to the uniform
  11904. * @return the texture itself allowing "fluent" like uniform updates
  11905. */
  11906. setFloat(name: string, value: number): ProceduralTexture;
  11907. /**
  11908. * Set a int in the shader.
  11909. * @param name Define the name of the uniform as defined in the shader
  11910. * @param value Define the value to give to the uniform
  11911. * @return the texture itself allowing "fluent" like uniform updates
  11912. */
  11913. setInt(name: string, value: number): ProceduralTexture;
  11914. /**
  11915. * Set an array of floats in the shader.
  11916. * @param name Define the name of the uniform as defined in the shader
  11917. * @param value Define the value to give to the uniform
  11918. * @return the texture itself allowing "fluent" like uniform updates
  11919. */
  11920. setFloats(name: string, value: number[]): ProceduralTexture;
  11921. /**
  11922. * Set a vec3 in the shader from a Color3.
  11923. * @param name Define the name of the uniform as defined in the shader
  11924. * @param value Define the value to give to the uniform
  11925. * @return the texture itself allowing "fluent" like uniform updates
  11926. */
  11927. setColor3(name: string, value: Color3): ProceduralTexture;
  11928. /**
  11929. * Set a vec4 in the shader from a Color4.
  11930. * @param name Define the name of the uniform as defined in the shader
  11931. * @param value Define the value to give to the uniform
  11932. * @return the texture itself allowing "fluent" like uniform updates
  11933. */
  11934. setColor4(name: string, value: Color4): ProceduralTexture;
  11935. /**
  11936. * Set a vec2 in the shader from a Vector2.
  11937. * @param name Define the name of the uniform as defined in the shader
  11938. * @param value Define the value to give to the uniform
  11939. * @return the texture itself allowing "fluent" like uniform updates
  11940. */
  11941. setVector2(name: string, value: Vector2): ProceduralTexture;
  11942. /**
  11943. * Set a vec3 in the shader from a Vector3.
  11944. * @param name Define the name of the uniform as defined in the shader
  11945. * @param value Define the value to give to the uniform
  11946. * @return the texture itself allowing "fluent" like uniform updates
  11947. */
  11948. setVector3(name: string, value: Vector3): ProceduralTexture;
  11949. /**
  11950. * Set a mat4 in the shader from a MAtrix.
  11951. * @param name Define the name of the uniform as defined in the shader
  11952. * @param value Define the value to give to the uniform
  11953. * @return the texture itself allowing "fluent" like uniform updates
  11954. */
  11955. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11956. /**
  11957. * Render the texture to its associated render target.
  11958. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11959. */
  11960. render(useCameraPostProcess?: boolean): void;
  11961. /**
  11962. * Clone the texture.
  11963. * @returns the cloned texture
  11964. */
  11965. clone(): ProceduralTexture;
  11966. /**
  11967. * Dispose the texture and release its asoociated resources.
  11968. */
  11969. dispose(): void;
  11970. }
  11971. }
  11972. declare module BABYLON {
  11973. /**
  11974. * This represents the base class for particle system in Babylon.
  11975. * 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.
  11976. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11977. * @example https://doc.babylonjs.com/babylon101/particles
  11978. */
  11979. export class BaseParticleSystem {
  11980. /**
  11981. * Source color is added to the destination color without alpha affecting the result
  11982. */
  11983. static BLENDMODE_ONEONE: number;
  11984. /**
  11985. * Blend current color and particle color using particle’s alpha
  11986. */
  11987. static BLENDMODE_STANDARD: number;
  11988. /**
  11989. * Add current color and particle color multiplied by particle’s alpha
  11990. */
  11991. static BLENDMODE_ADD: number;
  11992. /**
  11993. * Multiply current color with particle color
  11994. */
  11995. static BLENDMODE_MULTIPLY: number;
  11996. /**
  11997. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11998. */
  11999. static BLENDMODE_MULTIPLYADD: number;
  12000. /**
  12001. * List of animations used by the particle system.
  12002. */
  12003. animations: Animation[];
  12004. /**
  12005. * Gets or sets the unique id of the particle system
  12006. */
  12007. uniqueId: number;
  12008. /**
  12009. * The id of the Particle system.
  12010. */
  12011. id: string;
  12012. /**
  12013. * The friendly name of the Particle system.
  12014. */
  12015. name: string;
  12016. /**
  12017. * Snippet ID if the particle system was created from the snippet server
  12018. */
  12019. snippetId: string;
  12020. /**
  12021. * The rendering group used by the Particle system to chose when to render.
  12022. */
  12023. renderingGroupId: number;
  12024. /**
  12025. * The emitter represents the Mesh or position we are attaching the particle system to.
  12026. */
  12027. emitter: Nullable<AbstractMesh | Vector3>;
  12028. /**
  12029. * The maximum number of particles to emit per frame
  12030. */
  12031. emitRate: number;
  12032. /**
  12033. * If you want to launch only a few particles at once, that can be done, as well.
  12034. */
  12035. manualEmitCount: number;
  12036. /**
  12037. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12038. */
  12039. updateSpeed: number;
  12040. /**
  12041. * The amount of time the particle system is running (depends of the overall update speed).
  12042. */
  12043. targetStopDuration: number;
  12044. /**
  12045. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12046. */
  12047. disposeOnStop: boolean;
  12048. /**
  12049. * Minimum power of emitting particles.
  12050. */
  12051. minEmitPower: number;
  12052. /**
  12053. * Maximum power of emitting particles.
  12054. */
  12055. maxEmitPower: number;
  12056. /**
  12057. * Minimum life time of emitting particles.
  12058. */
  12059. minLifeTime: number;
  12060. /**
  12061. * Maximum life time of emitting particles.
  12062. */
  12063. maxLifeTime: number;
  12064. /**
  12065. * Minimum Size of emitting particles.
  12066. */
  12067. minSize: number;
  12068. /**
  12069. * Maximum Size of emitting particles.
  12070. */
  12071. maxSize: number;
  12072. /**
  12073. * Minimum scale of emitting particles on X axis.
  12074. */
  12075. minScaleX: number;
  12076. /**
  12077. * Maximum scale of emitting particles on X axis.
  12078. */
  12079. maxScaleX: number;
  12080. /**
  12081. * Minimum scale of emitting particles on Y axis.
  12082. */
  12083. minScaleY: number;
  12084. /**
  12085. * Maximum scale of emitting particles on Y axis.
  12086. */
  12087. maxScaleY: number;
  12088. /**
  12089. * Gets or sets the minimal initial rotation in radians.
  12090. */
  12091. minInitialRotation: number;
  12092. /**
  12093. * Gets or sets the maximal initial rotation in radians.
  12094. */
  12095. maxInitialRotation: number;
  12096. /**
  12097. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12098. */
  12099. minAngularSpeed: number;
  12100. /**
  12101. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12102. */
  12103. maxAngularSpeed: number;
  12104. /**
  12105. * The texture used to render each particle. (this can be a spritesheet)
  12106. */
  12107. particleTexture: Nullable<BaseTexture>;
  12108. /**
  12109. * The layer mask we are rendering the particles through.
  12110. */
  12111. layerMask: number;
  12112. /**
  12113. * This can help using your own shader to render the particle system.
  12114. * The according effect will be created
  12115. */
  12116. customShader: any;
  12117. /**
  12118. * By default particle system starts as soon as they are created. This prevents the
  12119. * automatic start to happen and let you decide when to start emitting particles.
  12120. */
  12121. preventAutoStart: boolean;
  12122. private _noiseTexture;
  12123. /**
  12124. * Gets or sets a texture used to add random noise to particle positions
  12125. */
  12126. get noiseTexture(): Nullable<ProceduralTexture>;
  12127. set noiseTexture(value: Nullable<ProceduralTexture>);
  12128. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12129. noiseStrength: Vector3;
  12130. /**
  12131. * Callback triggered when the particle animation is ending.
  12132. */
  12133. onAnimationEnd: Nullable<() => void>;
  12134. /**
  12135. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12136. */
  12137. blendMode: number;
  12138. /**
  12139. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12140. * to override the particles.
  12141. */
  12142. forceDepthWrite: boolean;
  12143. /** 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 */
  12144. preWarmCycles: number;
  12145. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12146. preWarmStepOffset: number;
  12147. /**
  12148. * 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)
  12149. */
  12150. spriteCellChangeSpeed: number;
  12151. /**
  12152. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12153. */
  12154. startSpriteCellID: number;
  12155. /**
  12156. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12157. */
  12158. endSpriteCellID: number;
  12159. /**
  12160. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12161. */
  12162. spriteCellWidth: number;
  12163. /**
  12164. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12165. */
  12166. spriteCellHeight: number;
  12167. /**
  12168. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12169. */
  12170. spriteRandomStartCell: boolean;
  12171. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12172. translationPivot: Vector2;
  12173. /** @hidden */
  12174. protected _isAnimationSheetEnabled: boolean;
  12175. /**
  12176. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12177. */
  12178. beginAnimationOnStart: boolean;
  12179. /**
  12180. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12181. */
  12182. beginAnimationFrom: number;
  12183. /**
  12184. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12185. */
  12186. beginAnimationTo: number;
  12187. /**
  12188. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12189. */
  12190. beginAnimationLoop: boolean;
  12191. /**
  12192. * Gets or sets a world offset applied to all particles
  12193. */
  12194. worldOffset: Vector3;
  12195. /**
  12196. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12197. */
  12198. get isAnimationSheetEnabled(): boolean;
  12199. set isAnimationSheetEnabled(value: boolean);
  12200. /**
  12201. * Get hosting scene
  12202. * @returns the scene
  12203. */
  12204. getScene(): Nullable<Scene>;
  12205. /**
  12206. * You can use gravity if you want to give an orientation to your particles.
  12207. */
  12208. gravity: Vector3;
  12209. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12210. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12211. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12212. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12213. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12214. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12215. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12216. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12217. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12218. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12219. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12220. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12221. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12222. /**
  12223. * Defines the delay in milliseconds before starting the system (0 by default)
  12224. */
  12225. startDelay: number;
  12226. /**
  12227. * Gets the current list of drag gradients.
  12228. * You must use addDragGradient and removeDragGradient to udpate this list
  12229. * @returns the list of drag gradients
  12230. */
  12231. getDragGradients(): Nullable<Array<FactorGradient>>;
  12232. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12233. limitVelocityDamping: number;
  12234. /**
  12235. * Gets the current list of limit velocity gradients.
  12236. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12237. * @returns the list of limit velocity gradients
  12238. */
  12239. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12240. /**
  12241. * Gets the current list of color gradients.
  12242. * You must use addColorGradient and removeColorGradient to udpate this list
  12243. * @returns the list of color gradients
  12244. */
  12245. getColorGradients(): Nullable<Array<ColorGradient>>;
  12246. /**
  12247. * Gets the current list of size gradients.
  12248. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12249. * @returns the list of size gradients
  12250. */
  12251. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12252. /**
  12253. * Gets the current list of color remap gradients.
  12254. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12255. * @returns the list of color remap gradients
  12256. */
  12257. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12258. /**
  12259. * Gets the current list of alpha remap gradients.
  12260. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12261. * @returns the list of alpha remap gradients
  12262. */
  12263. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12264. /**
  12265. * Gets the current list of life time gradients.
  12266. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12267. * @returns the list of life time gradients
  12268. */
  12269. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12270. /**
  12271. * Gets the current list of angular speed gradients.
  12272. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12273. * @returns the list of angular speed gradients
  12274. */
  12275. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12276. /**
  12277. * Gets the current list of velocity gradients.
  12278. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12279. * @returns the list of velocity gradients
  12280. */
  12281. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12282. /**
  12283. * Gets the current list of start size gradients.
  12284. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12285. * @returns the list of start size gradients
  12286. */
  12287. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12288. /**
  12289. * Gets the current list of emit rate gradients.
  12290. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12291. * @returns the list of emit rate gradients
  12292. */
  12293. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12294. /**
  12295. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12296. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12297. */
  12298. get direction1(): Vector3;
  12299. set direction1(value: Vector3);
  12300. /**
  12301. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12302. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12303. */
  12304. get direction2(): Vector3;
  12305. set direction2(value: Vector3);
  12306. /**
  12307. * 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.
  12308. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12309. */
  12310. get minEmitBox(): Vector3;
  12311. set minEmitBox(value: Vector3);
  12312. /**
  12313. * 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.
  12314. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12315. */
  12316. get maxEmitBox(): Vector3;
  12317. set maxEmitBox(value: Vector3);
  12318. /**
  12319. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12320. */
  12321. color1: Color4;
  12322. /**
  12323. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12324. */
  12325. color2: Color4;
  12326. /**
  12327. * Color the particle will have at the end of its lifetime
  12328. */
  12329. colorDead: Color4;
  12330. /**
  12331. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12332. */
  12333. textureMask: Color4;
  12334. /**
  12335. * The particle emitter type defines the emitter used by the particle system.
  12336. * It can be for example box, sphere, or cone...
  12337. */
  12338. particleEmitterType: IParticleEmitterType;
  12339. /** @hidden */
  12340. _isSubEmitter: boolean;
  12341. /**
  12342. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12343. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12344. */
  12345. billboardMode: number;
  12346. protected _isBillboardBased: boolean;
  12347. /**
  12348. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12349. */
  12350. get isBillboardBased(): boolean;
  12351. set isBillboardBased(value: boolean);
  12352. /**
  12353. * The scene the particle system belongs to.
  12354. */
  12355. protected _scene: Nullable<Scene>;
  12356. /**
  12357. * The engine the particle system belongs to.
  12358. */
  12359. protected _engine: ThinEngine;
  12360. /**
  12361. * Local cache of defines for image processing.
  12362. */
  12363. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12364. /**
  12365. * Default configuration related to image processing available in the standard Material.
  12366. */
  12367. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12368. /**
  12369. * Gets the image processing configuration used either in this material.
  12370. */
  12371. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12372. /**
  12373. * Sets the Default image processing configuration used either in the this material.
  12374. *
  12375. * If sets to null, the scene one is in use.
  12376. */
  12377. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12378. /**
  12379. * Attaches a new image processing configuration to the Standard Material.
  12380. * @param configuration
  12381. */
  12382. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12383. /** @hidden */
  12384. protected _reset(): void;
  12385. /** @hidden */
  12386. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12387. /**
  12388. * Instantiates a particle system.
  12389. * 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.
  12390. * @param name The name of the particle system
  12391. */
  12392. constructor(name: string);
  12393. /**
  12394. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12395. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12396. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12397. * @returns the emitter
  12398. */
  12399. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12400. /**
  12401. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12402. * @param radius The radius of the hemisphere to emit from
  12403. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12404. * @returns the emitter
  12405. */
  12406. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12407. /**
  12408. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12409. * @param radius The radius of the sphere to emit from
  12410. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12411. * @returns the emitter
  12412. */
  12413. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12414. /**
  12415. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12416. * @param radius The radius of the sphere to emit from
  12417. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12418. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12419. * @returns the emitter
  12420. */
  12421. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12422. /**
  12423. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12424. * @param radius The radius of the emission cylinder
  12425. * @param height The height of the emission cylinder
  12426. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12427. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12428. * @returns the emitter
  12429. */
  12430. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12431. /**
  12432. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12433. * @param radius The radius of the cylinder to emit from
  12434. * @param height The height of the emission cylinder
  12435. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12436. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12437. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12438. * @returns the emitter
  12439. */
  12440. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12441. /**
  12442. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12443. * @param radius The radius of the cone to emit from
  12444. * @param angle The base angle of the cone
  12445. * @returns the emitter
  12446. */
  12447. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12448. /**
  12449. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12450. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12451. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12452. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12453. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12454. * @returns the emitter
  12455. */
  12456. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12457. }
  12458. }
  12459. declare module BABYLON {
  12460. /**
  12461. * Type of sub emitter
  12462. */
  12463. export enum SubEmitterType {
  12464. /**
  12465. * Attached to the particle over it's lifetime
  12466. */
  12467. ATTACHED = 0,
  12468. /**
  12469. * Created when the particle dies
  12470. */
  12471. END = 1
  12472. }
  12473. /**
  12474. * Sub emitter class used to emit particles from an existing particle
  12475. */
  12476. export class SubEmitter {
  12477. /**
  12478. * the particle system to be used by the sub emitter
  12479. */
  12480. particleSystem: ParticleSystem;
  12481. /**
  12482. * Type of the submitter (Default: END)
  12483. */
  12484. type: SubEmitterType;
  12485. /**
  12486. * 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)
  12487. * Note: This only is supported when using an emitter of type Mesh
  12488. */
  12489. inheritDirection: boolean;
  12490. /**
  12491. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12492. */
  12493. inheritedVelocityAmount: number;
  12494. /**
  12495. * Creates a sub emitter
  12496. * @param particleSystem the particle system to be used by the sub emitter
  12497. */
  12498. constructor(
  12499. /**
  12500. * the particle system to be used by the sub emitter
  12501. */
  12502. particleSystem: ParticleSystem);
  12503. /**
  12504. * Clones the sub emitter
  12505. * @returns the cloned sub emitter
  12506. */
  12507. clone(): SubEmitter;
  12508. /**
  12509. * Serialize current object to a JSON object
  12510. * @returns the serialized object
  12511. */
  12512. serialize(): any;
  12513. /** @hidden */
  12514. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12515. /**
  12516. * Creates a new SubEmitter from a serialized JSON version
  12517. * @param serializationObject defines the JSON object to read from
  12518. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12519. * @param rootUrl defines the rootUrl for data loading
  12520. * @returns a new SubEmitter
  12521. */
  12522. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12523. /** Release associated resources */
  12524. dispose(): void;
  12525. }
  12526. }
  12527. declare module BABYLON {
  12528. /** @hidden */
  12529. export var imageProcessingDeclaration: {
  12530. name: string;
  12531. shader: string;
  12532. };
  12533. }
  12534. declare module BABYLON {
  12535. /** @hidden */
  12536. export var imageProcessingFunctions: {
  12537. name: string;
  12538. shader: string;
  12539. };
  12540. }
  12541. declare module BABYLON {
  12542. /** @hidden */
  12543. export var particlesPixelShader: {
  12544. name: string;
  12545. shader: string;
  12546. };
  12547. }
  12548. declare module BABYLON {
  12549. /** @hidden */
  12550. export var particlesVertexShader: {
  12551. name: string;
  12552. shader: string;
  12553. };
  12554. }
  12555. declare module BABYLON {
  12556. /**
  12557. * Interface used to define entities containing multiple clip planes
  12558. */
  12559. export interface IClipPlanesHolder {
  12560. /**
  12561. * Gets or sets the active clipplane 1
  12562. */
  12563. clipPlane: Nullable<Plane>;
  12564. /**
  12565. * Gets or sets the active clipplane 2
  12566. */
  12567. clipPlane2: Nullable<Plane>;
  12568. /**
  12569. * Gets or sets the active clipplane 3
  12570. */
  12571. clipPlane3: Nullable<Plane>;
  12572. /**
  12573. * Gets or sets the active clipplane 4
  12574. */
  12575. clipPlane4: Nullable<Plane>;
  12576. /**
  12577. * Gets or sets the active clipplane 5
  12578. */
  12579. clipPlane5: Nullable<Plane>;
  12580. /**
  12581. * Gets or sets the active clipplane 6
  12582. */
  12583. clipPlane6: Nullable<Plane>;
  12584. }
  12585. }
  12586. declare module BABYLON {
  12587. /**
  12588. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12589. *
  12590. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12591. *
  12592. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12593. */
  12594. export class ThinMaterialHelper {
  12595. /**
  12596. * Binds the clip plane information from the holder to the effect.
  12597. * @param effect The effect we are binding the data to
  12598. * @param holder The entity containing the clip plane information
  12599. */
  12600. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12601. }
  12602. }
  12603. declare module BABYLON {
  12604. interface ThinEngine {
  12605. /**
  12606. * Sets alpha constants used by some alpha blending modes
  12607. * @param r defines the red component
  12608. * @param g defines the green component
  12609. * @param b defines the blue component
  12610. * @param a defines the alpha component
  12611. */
  12612. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12613. /**
  12614. * Sets the current alpha mode
  12615. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12616. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12617. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12618. */
  12619. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12620. /**
  12621. * Gets the current alpha mode
  12622. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12623. * @returns the current alpha mode
  12624. */
  12625. getAlphaMode(): number;
  12626. /**
  12627. * Sets the current alpha equation
  12628. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12629. */
  12630. setAlphaEquation(equation: number): void;
  12631. /**
  12632. * Gets the current alpha equation.
  12633. * @returns the current alpha equation
  12634. */
  12635. getAlphaEquation(): number;
  12636. }
  12637. }
  12638. declare module BABYLON {
  12639. /**
  12640. * This represents a particle system in Babylon.
  12641. * 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.
  12642. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12643. * @example https://doc.babylonjs.com/babylon101/particles
  12644. */
  12645. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12646. /**
  12647. * Billboard mode will only apply to Y axis
  12648. */
  12649. static readonly BILLBOARDMODE_Y: number;
  12650. /**
  12651. * Billboard mode will apply to all axes
  12652. */
  12653. static readonly BILLBOARDMODE_ALL: number;
  12654. /**
  12655. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12656. */
  12657. static readonly BILLBOARDMODE_STRETCHED: number;
  12658. /**
  12659. * This function can be defined to provide custom update for active particles.
  12660. * This function will be called instead of regular update (age, position, color, etc.).
  12661. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12662. */
  12663. updateFunction: (particles: Particle[]) => void;
  12664. private _emitterWorldMatrix;
  12665. /**
  12666. * This function can be defined to specify initial direction for every new particle.
  12667. * It by default use the emitterType defined function
  12668. */
  12669. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12670. /**
  12671. * This function can be defined to specify initial position for every new particle.
  12672. * It by default use the emitterType defined function
  12673. */
  12674. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12675. /**
  12676. * @hidden
  12677. */
  12678. _inheritedVelocityOffset: Vector3;
  12679. /**
  12680. * An event triggered when the system is disposed
  12681. */
  12682. onDisposeObservable: Observable<IParticleSystem>;
  12683. /**
  12684. * An event triggered when the system is stopped
  12685. */
  12686. onStoppedObservable: Observable<IParticleSystem>;
  12687. private _onDisposeObserver;
  12688. /**
  12689. * Sets a callback that will be triggered when the system is disposed
  12690. */
  12691. set onDispose(callback: () => void);
  12692. private _particles;
  12693. private _epsilon;
  12694. private _capacity;
  12695. private _stockParticles;
  12696. private _newPartsExcess;
  12697. private _vertexData;
  12698. private _vertexBuffer;
  12699. private _vertexBuffers;
  12700. private _spriteBuffer;
  12701. private _indexBuffer;
  12702. private _effect;
  12703. private _customEffect;
  12704. private _cachedDefines;
  12705. private _scaledColorStep;
  12706. private _colorDiff;
  12707. private _scaledDirection;
  12708. private _scaledGravity;
  12709. private _currentRenderId;
  12710. private _alive;
  12711. private _useInstancing;
  12712. private _vertexArrayObject;
  12713. private _started;
  12714. private _stopped;
  12715. private _actualFrame;
  12716. private _scaledUpdateSpeed;
  12717. private _vertexBufferSize;
  12718. /** @hidden */
  12719. _currentEmitRateGradient: Nullable<FactorGradient>;
  12720. /** @hidden */
  12721. _currentEmitRate1: number;
  12722. /** @hidden */
  12723. _currentEmitRate2: number;
  12724. /** @hidden */
  12725. _currentStartSizeGradient: Nullable<FactorGradient>;
  12726. /** @hidden */
  12727. _currentStartSize1: number;
  12728. /** @hidden */
  12729. _currentStartSize2: number;
  12730. private readonly _rawTextureWidth;
  12731. private _rampGradientsTexture;
  12732. private _useRampGradients;
  12733. /** Gets or sets a matrix to use to compute projection */
  12734. defaultProjectionMatrix: Matrix;
  12735. /** Gets or sets a matrix to use to compute view */
  12736. defaultViewMatrix: Matrix;
  12737. /** Gets or sets a boolean indicating that ramp gradients must be used
  12738. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12739. */
  12740. get useRampGradients(): boolean;
  12741. set useRampGradients(value: boolean);
  12742. /**
  12743. * 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.
  12744. * 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: [])
  12745. */
  12746. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12747. private _subEmitters;
  12748. /**
  12749. * @hidden
  12750. * If the particle systems emitter should be disposed when the particle system is disposed
  12751. */
  12752. _disposeEmitterOnDispose: boolean;
  12753. /**
  12754. * The current active Sub-systems, this property is used by the root particle system only.
  12755. */
  12756. activeSubSystems: Array<ParticleSystem>;
  12757. /**
  12758. * Specifies if the particles are updated in emitter local space or world space
  12759. */
  12760. isLocal: boolean;
  12761. private _rootParticleSystem;
  12762. /**
  12763. * Gets the current list of active particles
  12764. */
  12765. get particles(): Particle[];
  12766. /**
  12767. * Gets the number of particles active at the same time.
  12768. * @returns The number of active particles.
  12769. */
  12770. getActiveCount(): number;
  12771. /**
  12772. * Returns the string "ParticleSystem"
  12773. * @returns a string containing the class name
  12774. */
  12775. getClassName(): string;
  12776. /**
  12777. * Gets a boolean indicating that the system is stopping
  12778. * @returns true if the system is currently stopping
  12779. */
  12780. isStopping(): boolean;
  12781. /**
  12782. * Gets the custom effect used to render the particles
  12783. * @param blendMode Blend mode for which the effect should be retrieved
  12784. * @returns The effect
  12785. */
  12786. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12787. /**
  12788. * Sets the custom effect used to render the particles
  12789. * @param effect The effect to set
  12790. * @param blendMode Blend mode for which the effect should be set
  12791. */
  12792. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12793. /** @hidden */
  12794. private _onBeforeDrawParticlesObservable;
  12795. /**
  12796. * Observable that will be called just before the particles are drawn
  12797. */
  12798. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12799. /**
  12800. * Gets the name of the particle vertex shader
  12801. */
  12802. get vertexShaderName(): string;
  12803. /**
  12804. * Instantiates a particle system.
  12805. * 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.
  12806. * @param name The name of the particle system
  12807. * @param capacity The max number of particles alive at the same time
  12808. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  12809. * @param customEffect a custom effect used to change the way particles are rendered by default
  12810. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12811. * @param epsilon Offset used to render the particles
  12812. */
  12813. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12814. private _addFactorGradient;
  12815. private _removeFactorGradient;
  12816. /**
  12817. * Adds a new life time gradient
  12818. * @param gradient defines the gradient to use (between 0 and 1)
  12819. * @param factor defines the life time factor to affect to the specified gradient
  12820. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12821. * @returns the current particle system
  12822. */
  12823. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12824. /**
  12825. * Remove a specific life time gradient
  12826. * @param gradient defines the gradient to remove
  12827. * @returns the current particle system
  12828. */
  12829. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12830. /**
  12831. * Adds a new size gradient
  12832. * @param gradient defines the gradient to use (between 0 and 1)
  12833. * @param factor defines the size factor to affect to the specified gradient
  12834. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12835. * @returns the current particle system
  12836. */
  12837. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12838. /**
  12839. * Remove a specific size gradient
  12840. * @param gradient defines the gradient to remove
  12841. * @returns the current particle system
  12842. */
  12843. removeSizeGradient(gradient: number): IParticleSystem;
  12844. /**
  12845. * Adds a new color remap gradient
  12846. * @param gradient defines the gradient to use (between 0 and 1)
  12847. * @param min defines the color remap minimal range
  12848. * @param max defines the color remap maximal range
  12849. * @returns the current particle system
  12850. */
  12851. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12852. /**
  12853. * Remove a specific color remap gradient
  12854. * @param gradient defines the gradient to remove
  12855. * @returns the current particle system
  12856. */
  12857. removeColorRemapGradient(gradient: number): IParticleSystem;
  12858. /**
  12859. * Adds a new alpha remap gradient
  12860. * @param gradient defines the gradient to use (between 0 and 1)
  12861. * @param min defines the alpha remap minimal range
  12862. * @param max defines the alpha remap maximal range
  12863. * @returns the current particle system
  12864. */
  12865. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12866. /**
  12867. * Remove a specific alpha remap gradient
  12868. * @param gradient defines the gradient to remove
  12869. * @returns the current particle system
  12870. */
  12871. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12872. /**
  12873. * Adds a new angular speed gradient
  12874. * @param gradient defines the gradient to use (between 0 and 1)
  12875. * @param factor defines the angular speed to affect to the specified gradient
  12876. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12877. * @returns the current particle system
  12878. */
  12879. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12880. /**
  12881. * Remove a specific angular speed gradient
  12882. * @param gradient defines the gradient to remove
  12883. * @returns the current particle system
  12884. */
  12885. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12886. /**
  12887. * Adds a new velocity gradient
  12888. * @param gradient defines the gradient to use (between 0 and 1)
  12889. * @param factor defines the velocity to affect to the specified gradient
  12890. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12891. * @returns the current particle system
  12892. */
  12893. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12894. /**
  12895. * Remove a specific velocity gradient
  12896. * @param gradient defines the gradient to remove
  12897. * @returns the current particle system
  12898. */
  12899. removeVelocityGradient(gradient: number): IParticleSystem;
  12900. /**
  12901. * Adds a new limit velocity gradient
  12902. * @param gradient defines the gradient to use (between 0 and 1)
  12903. * @param factor defines the limit velocity value to affect to the specified gradient
  12904. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12905. * @returns the current particle system
  12906. */
  12907. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12908. /**
  12909. * Remove a specific limit velocity gradient
  12910. * @param gradient defines the gradient to remove
  12911. * @returns the current particle system
  12912. */
  12913. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12914. /**
  12915. * Adds a new drag gradient
  12916. * @param gradient defines the gradient to use (between 0 and 1)
  12917. * @param factor defines the drag value to affect to the specified gradient
  12918. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12919. * @returns the current particle system
  12920. */
  12921. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12922. /**
  12923. * Remove a specific drag gradient
  12924. * @param gradient defines the gradient to remove
  12925. * @returns the current particle system
  12926. */
  12927. removeDragGradient(gradient: number): IParticleSystem;
  12928. /**
  12929. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12930. * @param gradient defines the gradient to use (between 0 and 1)
  12931. * @param factor defines the emit rate value to affect to the specified gradient
  12932. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12933. * @returns the current particle system
  12934. */
  12935. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12936. /**
  12937. * Remove a specific emit rate gradient
  12938. * @param gradient defines the gradient to remove
  12939. * @returns the current particle system
  12940. */
  12941. removeEmitRateGradient(gradient: number): IParticleSystem;
  12942. /**
  12943. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12944. * @param gradient defines the gradient to use (between 0 and 1)
  12945. * @param factor defines the start size value to affect to the specified gradient
  12946. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12947. * @returns the current particle system
  12948. */
  12949. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12950. /**
  12951. * Remove a specific start size gradient
  12952. * @param gradient defines the gradient to remove
  12953. * @returns the current particle system
  12954. */
  12955. removeStartSizeGradient(gradient: number): IParticleSystem;
  12956. private _createRampGradientTexture;
  12957. /**
  12958. * Gets the current list of ramp gradients.
  12959. * You must use addRampGradient and removeRampGradient to udpate this list
  12960. * @returns the list of ramp gradients
  12961. */
  12962. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12963. /** Force the system to rebuild all gradients that need to be resync */
  12964. forceRefreshGradients(): void;
  12965. private _syncRampGradientTexture;
  12966. /**
  12967. * Adds a new ramp gradient used to remap particle colors
  12968. * @param gradient defines the gradient to use (between 0 and 1)
  12969. * @param color defines the color to affect to the specified gradient
  12970. * @returns the current particle system
  12971. */
  12972. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12973. /**
  12974. * Remove a specific ramp gradient
  12975. * @param gradient defines the gradient to remove
  12976. * @returns the current particle system
  12977. */
  12978. removeRampGradient(gradient: number): ParticleSystem;
  12979. /**
  12980. * Adds a new color gradient
  12981. * @param gradient defines the gradient to use (between 0 and 1)
  12982. * @param color1 defines the color to affect to the specified gradient
  12983. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12984. * @returns this particle system
  12985. */
  12986. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12987. /**
  12988. * Remove a specific color gradient
  12989. * @param gradient defines the gradient to remove
  12990. * @returns this particle system
  12991. */
  12992. removeColorGradient(gradient: number): IParticleSystem;
  12993. private _fetchR;
  12994. protected _reset(): void;
  12995. private _resetEffect;
  12996. private _createVertexBuffers;
  12997. private _createIndexBuffer;
  12998. /**
  12999. * Gets the maximum number of particles active at the same time.
  13000. * @returns The max number of active particles.
  13001. */
  13002. getCapacity(): number;
  13003. /**
  13004. * Gets whether there are still active particles in the system.
  13005. * @returns True if it is alive, otherwise false.
  13006. */
  13007. isAlive(): boolean;
  13008. /**
  13009. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13010. * @returns True if it has been started, otherwise false.
  13011. */
  13012. isStarted(): boolean;
  13013. private _prepareSubEmitterInternalArray;
  13014. /**
  13015. * Starts the particle system and begins to emit
  13016. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13017. */
  13018. start(delay?: number): void;
  13019. /**
  13020. * Stops the particle system.
  13021. * @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.
  13022. */
  13023. stop(stopSubEmitters?: boolean): void;
  13024. /**
  13025. * Remove all active particles
  13026. */
  13027. reset(): void;
  13028. /**
  13029. * @hidden (for internal use only)
  13030. */
  13031. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13032. /**
  13033. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13034. * Its lifetime will start back at 0.
  13035. */
  13036. recycleParticle: (particle: Particle) => void;
  13037. private _stopSubEmitters;
  13038. private _createParticle;
  13039. private _removeFromRoot;
  13040. private _emitFromParticle;
  13041. private _update;
  13042. /** @hidden */
  13043. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13044. /** @hidden */
  13045. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13046. /**
  13047. * Fill the defines array according to the current settings of the particle system
  13048. * @param defines Array to be updated
  13049. * @param blendMode blend mode to take into account when updating the array
  13050. */
  13051. fillDefines(defines: Array<string>, blendMode: number): void;
  13052. /**
  13053. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13054. * @param uniforms Uniforms array to fill
  13055. * @param attributes Attributes array to fill
  13056. * @param samplers Samplers array to fill
  13057. */
  13058. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13059. /** @hidden */
  13060. private _getEffect;
  13061. /**
  13062. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13063. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13064. */
  13065. animate(preWarmOnly?: boolean): void;
  13066. private _appendParticleVertices;
  13067. /**
  13068. * Rebuilds the particle system.
  13069. */
  13070. rebuild(): void;
  13071. /**
  13072. * Is this system ready to be used/rendered
  13073. * @return true if the system is ready
  13074. */
  13075. isReady(): boolean;
  13076. private _render;
  13077. /**
  13078. * Renders the particle system in its current state.
  13079. * @returns the current number of particles
  13080. */
  13081. render(): number;
  13082. /**
  13083. * Disposes the particle system and free the associated resources
  13084. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13085. */
  13086. dispose(disposeTexture?: boolean): void;
  13087. /**
  13088. * Clones the particle system.
  13089. * @param name The name of the cloned object
  13090. * @param newEmitter The new emitter to use
  13091. * @returns the cloned particle system
  13092. */
  13093. clone(name: string, newEmitter: any): ParticleSystem;
  13094. /**
  13095. * Serializes the particle system to a JSON object
  13096. * @param serializeTexture defines if the texture must be serialized as well
  13097. * @returns the JSON object
  13098. */
  13099. serialize(serializeTexture?: boolean): any;
  13100. /** @hidden */
  13101. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13102. /** @hidden */
  13103. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13104. /**
  13105. * Parses a JSON object to create a particle system.
  13106. * @param parsedParticleSystem The JSON object to parse
  13107. * @param sceneOrEngine The scene or the engine to create the particle system in
  13108. * @param rootUrl The root url to use to load external dependencies like texture
  13109. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13110. * @returns the Parsed particle system
  13111. */
  13112. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13113. }
  13114. }
  13115. declare module BABYLON {
  13116. /**
  13117. * A particle represents one of the element emitted by a particle system.
  13118. * This is mainly define by its coordinates, direction, velocity and age.
  13119. */
  13120. export class Particle {
  13121. /**
  13122. * The particle system the particle belongs to.
  13123. */
  13124. particleSystem: ParticleSystem;
  13125. private static _Count;
  13126. /**
  13127. * Unique ID of the particle
  13128. */
  13129. id: number;
  13130. /**
  13131. * The world position of the particle in the scene.
  13132. */
  13133. position: Vector3;
  13134. /**
  13135. * The world direction of the particle in the scene.
  13136. */
  13137. direction: Vector3;
  13138. /**
  13139. * The color of the particle.
  13140. */
  13141. color: Color4;
  13142. /**
  13143. * The color change of the particle per step.
  13144. */
  13145. colorStep: Color4;
  13146. /**
  13147. * Defines how long will the life of the particle be.
  13148. */
  13149. lifeTime: number;
  13150. /**
  13151. * The current age of the particle.
  13152. */
  13153. age: number;
  13154. /**
  13155. * The current size of the particle.
  13156. */
  13157. size: number;
  13158. /**
  13159. * The current scale of the particle.
  13160. */
  13161. scale: Vector2;
  13162. /**
  13163. * The current angle of the particle.
  13164. */
  13165. angle: number;
  13166. /**
  13167. * Defines how fast is the angle changing.
  13168. */
  13169. angularSpeed: number;
  13170. /**
  13171. * Defines the cell index used by the particle to be rendered from a sprite.
  13172. */
  13173. cellIndex: number;
  13174. /**
  13175. * The information required to support color remapping
  13176. */
  13177. remapData: Vector4;
  13178. /** @hidden */
  13179. _randomCellOffset?: number;
  13180. /** @hidden */
  13181. _initialDirection: Nullable<Vector3>;
  13182. /** @hidden */
  13183. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13184. /** @hidden */
  13185. _initialStartSpriteCellID: number;
  13186. /** @hidden */
  13187. _initialEndSpriteCellID: number;
  13188. /** @hidden */
  13189. _currentColorGradient: Nullable<ColorGradient>;
  13190. /** @hidden */
  13191. _currentColor1: Color4;
  13192. /** @hidden */
  13193. _currentColor2: Color4;
  13194. /** @hidden */
  13195. _currentSizeGradient: Nullable<FactorGradient>;
  13196. /** @hidden */
  13197. _currentSize1: number;
  13198. /** @hidden */
  13199. _currentSize2: number;
  13200. /** @hidden */
  13201. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13202. /** @hidden */
  13203. _currentAngularSpeed1: number;
  13204. /** @hidden */
  13205. _currentAngularSpeed2: number;
  13206. /** @hidden */
  13207. _currentVelocityGradient: Nullable<FactorGradient>;
  13208. /** @hidden */
  13209. _currentVelocity1: number;
  13210. /** @hidden */
  13211. _currentVelocity2: number;
  13212. /** @hidden */
  13213. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13214. /** @hidden */
  13215. _currentLimitVelocity1: number;
  13216. /** @hidden */
  13217. _currentLimitVelocity2: number;
  13218. /** @hidden */
  13219. _currentDragGradient: Nullable<FactorGradient>;
  13220. /** @hidden */
  13221. _currentDrag1: number;
  13222. /** @hidden */
  13223. _currentDrag2: number;
  13224. /** @hidden */
  13225. _randomNoiseCoordinates1: Vector3;
  13226. /** @hidden */
  13227. _randomNoiseCoordinates2: Vector3;
  13228. /** @hidden */
  13229. _localPosition?: Vector3;
  13230. /**
  13231. * Creates a new instance Particle
  13232. * @param particleSystem the particle system the particle belongs to
  13233. */
  13234. constructor(
  13235. /**
  13236. * The particle system the particle belongs to.
  13237. */
  13238. particleSystem: ParticleSystem);
  13239. private updateCellInfoFromSystem;
  13240. /**
  13241. * Defines how the sprite cell index is updated for the particle
  13242. */
  13243. updateCellIndex(): void;
  13244. /** @hidden */
  13245. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13246. /** @hidden */
  13247. _inheritParticleInfoToSubEmitters(): void;
  13248. /** @hidden */
  13249. _reset(): void;
  13250. /**
  13251. * Copy the properties of particle to another one.
  13252. * @param other the particle to copy the information to.
  13253. */
  13254. copyTo(other: Particle): void;
  13255. }
  13256. }
  13257. declare module BABYLON {
  13258. /**
  13259. * Particle emitter represents a volume emitting particles.
  13260. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13261. */
  13262. export interface IParticleEmitterType {
  13263. /**
  13264. * Called by the particle System when the direction is computed for the created particle.
  13265. * @param worldMatrix is the world matrix of the particle system
  13266. * @param directionToUpdate is the direction vector to update with the result
  13267. * @param particle is the particle we are computed the direction for
  13268. * @param isLocal defines if the direction should be set in local space
  13269. */
  13270. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13271. /**
  13272. * Called by the particle System when the position is computed for the created particle.
  13273. * @param worldMatrix is the world matrix of the particle system
  13274. * @param positionToUpdate is the position vector to update with the result
  13275. * @param particle is the particle we are computed the position for
  13276. * @param isLocal defines if the position should be set in local space
  13277. */
  13278. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13279. /**
  13280. * Clones the current emitter and returns a copy of it
  13281. * @returns the new emitter
  13282. */
  13283. clone(): IParticleEmitterType;
  13284. /**
  13285. * Called by the GPUParticleSystem to setup the update shader
  13286. * @param effect defines the update shader
  13287. */
  13288. applyToShader(effect: Effect): void;
  13289. /**
  13290. * Returns a string to use to update the GPU particles update shader
  13291. * @returns the effect defines string
  13292. */
  13293. getEffectDefines(): string;
  13294. /**
  13295. * Returns a string representing the class name
  13296. * @returns a string containing the class name
  13297. */
  13298. getClassName(): string;
  13299. /**
  13300. * Serializes the particle system to a JSON object.
  13301. * @returns the JSON object
  13302. */
  13303. serialize(): any;
  13304. /**
  13305. * Parse properties from a JSON object
  13306. * @param serializationObject defines the JSON object
  13307. * @param scene defines the hosting scene
  13308. */
  13309. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13310. }
  13311. }
  13312. declare module BABYLON {
  13313. /**
  13314. * Particle emitter emitting particles from the inside of a box.
  13315. * It emits the particles randomly between 2 given directions.
  13316. */
  13317. export class BoxParticleEmitter implements IParticleEmitterType {
  13318. /**
  13319. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13320. */
  13321. direction1: Vector3;
  13322. /**
  13323. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13324. */
  13325. direction2: Vector3;
  13326. /**
  13327. * 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.
  13328. */
  13329. minEmitBox: Vector3;
  13330. /**
  13331. * 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.
  13332. */
  13333. maxEmitBox: Vector3;
  13334. /**
  13335. * Creates a new instance BoxParticleEmitter
  13336. */
  13337. constructor();
  13338. /**
  13339. * Called by the particle System when the direction is computed for the created particle.
  13340. * @param worldMatrix is the world matrix of the particle system
  13341. * @param directionToUpdate is the direction vector to update with the result
  13342. * @param particle is the particle we are computed the direction for
  13343. * @param isLocal defines if the direction should be set in local space
  13344. */
  13345. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13346. /**
  13347. * Called by the particle System when the position is computed for the created particle.
  13348. * @param worldMatrix is the world matrix of the particle system
  13349. * @param positionToUpdate is the position vector to update with the result
  13350. * @param particle is the particle we are computed the position for
  13351. * @param isLocal defines if the position should be set in local space
  13352. */
  13353. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13354. /**
  13355. * Clones the current emitter and returns a copy of it
  13356. * @returns the new emitter
  13357. */
  13358. clone(): BoxParticleEmitter;
  13359. /**
  13360. * Called by the GPUParticleSystem to setup the update shader
  13361. * @param effect defines the update shader
  13362. */
  13363. applyToShader(effect: Effect): void;
  13364. /**
  13365. * Returns a string to use to update the GPU particles update shader
  13366. * @returns a string containng the defines string
  13367. */
  13368. getEffectDefines(): string;
  13369. /**
  13370. * Returns the string "BoxParticleEmitter"
  13371. * @returns a string containing the class name
  13372. */
  13373. getClassName(): string;
  13374. /**
  13375. * Serializes the particle system to a JSON object.
  13376. * @returns the JSON object
  13377. */
  13378. serialize(): any;
  13379. /**
  13380. * Parse properties from a JSON object
  13381. * @param serializationObject defines the JSON object
  13382. */
  13383. parse(serializationObject: any): void;
  13384. }
  13385. }
  13386. declare module BABYLON {
  13387. /**
  13388. * Particle emitter emitting particles from the inside of a cone.
  13389. * It emits the particles alongside the cone volume from the base to the particle.
  13390. * The emission direction might be randomized.
  13391. */
  13392. export class ConeParticleEmitter implements IParticleEmitterType {
  13393. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13394. directionRandomizer: number;
  13395. private _radius;
  13396. private _angle;
  13397. private _height;
  13398. /**
  13399. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13400. */
  13401. radiusRange: number;
  13402. /**
  13403. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13404. */
  13405. heightRange: number;
  13406. /**
  13407. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13408. */
  13409. emitFromSpawnPointOnly: boolean;
  13410. /**
  13411. * Gets or sets the radius of the emission cone
  13412. */
  13413. get radius(): number;
  13414. set radius(value: number);
  13415. /**
  13416. * Gets or sets the angle of the emission cone
  13417. */
  13418. get angle(): number;
  13419. set angle(value: number);
  13420. private _buildHeight;
  13421. /**
  13422. * Creates a new instance ConeParticleEmitter
  13423. * @param radius the radius of the emission cone (1 by default)
  13424. * @param angle the cone base angle (PI by default)
  13425. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13426. */
  13427. constructor(radius?: number, angle?: number,
  13428. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13429. directionRandomizer?: number);
  13430. /**
  13431. * Called by the particle System when the direction is computed for the created particle.
  13432. * @param worldMatrix is the world matrix of the particle system
  13433. * @param directionToUpdate is the direction vector to update with the result
  13434. * @param particle is the particle we are computed the direction for
  13435. * @param isLocal defines if the direction should be set in local space
  13436. */
  13437. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13438. /**
  13439. * Called by the particle System when the position is computed for the created particle.
  13440. * @param worldMatrix is the world matrix of the particle system
  13441. * @param positionToUpdate is the position vector to update with the result
  13442. * @param particle is the particle we are computed the position for
  13443. * @param isLocal defines if the position should be set in local space
  13444. */
  13445. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13446. /**
  13447. * Clones the current emitter and returns a copy of it
  13448. * @returns the new emitter
  13449. */
  13450. clone(): ConeParticleEmitter;
  13451. /**
  13452. * Called by the GPUParticleSystem to setup the update shader
  13453. * @param effect defines the update shader
  13454. */
  13455. applyToShader(effect: Effect): void;
  13456. /**
  13457. * Returns a string to use to update the GPU particles update shader
  13458. * @returns a string containng the defines string
  13459. */
  13460. getEffectDefines(): string;
  13461. /**
  13462. * Returns the string "ConeParticleEmitter"
  13463. * @returns a string containing the class name
  13464. */
  13465. getClassName(): string;
  13466. /**
  13467. * Serializes the particle system to a JSON object.
  13468. * @returns the JSON object
  13469. */
  13470. serialize(): any;
  13471. /**
  13472. * Parse properties from a JSON object
  13473. * @param serializationObject defines the JSON object
  13474. */
  13475. parse(serializationObject: any): void;
  13476. }
  13477. }
  13478. declare module BABYLON {
  13479. /**
  13480. * Particle emitter emitting particles from the inside of a cylinder.
  13481. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13482. */
  13483. export class CylinderParticleEmitter implements IParticleEmitterType {
  13484. /**
  13485. * The radius of the emission cylinder.
  13486. */
  13487. radius: number;
  13488. /**
  13489. * The height of the emission cylinder.
  13490. */
  13491. height: number;
  13492. /**
  13493. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13494. */
  13495. radiusRange: number;
  13496. /**
  13497. * How much to randomize the particle direction [0-1].
  13498. */
  13499. directionRandomizer: number;
  13500. /**
  13501. * Creates a new instance CylinderParticleEmitter
  13502. * @param radius the radius of the emission cylinder (1 by default)
  13503. * @param height the height of the emission cylinder (1 by default)
  13504. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13505. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13506. */
  13507. constructor(
  13508. /**
  13509. * The radius of the emission cylinder.
  13510. */
  13511. radius?: number,
  13512. /**
  13513. * The height of the emission cylinder.
  13514. */
  13515. height?: number,
  13516. /**
  13517. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13518. */
  13519. radiusRange?: number,
  13520. /**
  13521. * How much to randomize the particle direction [0-1].
  13522. */
  13523. directionRandomizer?: number);
  13524. /**
  13525. * Called by the particle System when the direction is computed for the created particle.
  13526. * @param worldMatrix is the world matrix of the particle system
  13527. * @param directionToUpdate is the direction vector to update with the result
  13528. * @param particle is the particle we are computed the direction for
  13529. * @param isLocal defines if the direction should be set in local space
  13530. */
  13531. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13532. /**
  13533. * Called by the particle System when the position is computed for the created particle.
  13534. * @param worldMatrix is the world matrix of the particle system
  13535. * @param positionToUpdate is the position vector to update with the result
  13536. * @param particle is the particle we are computed the position for
  13537. * @param isLocal defines if the position should be set in local space
  13538. */
  13539. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13540. /**
  13541. * Clones the current emitter and returns a copy of it
  13542. * @returns the new emitter
  13543. */
  13544. clone(): CylinderParticleEmitter;
  13545. /**
  13546. * Called by the GPUParticleSystem to setup the update shader
  13547. * @param effect defines the update shader
  13548. */
  13549. applyToShader(effect: Effect): void;
  13550. /**
  13551. * Returns a string to use to update the GPU particles update shader
  13552. * @returns a string containng the defines string
  13553. */
  13554. getEffectDefines(): string;
  13555. /**
  13556. * Returns the string "CylinderParticleEmitter"
  13557. * @returns a string containing the class name
  13558. */
  13559. getClassName(): string;
  13560. /**
  13561. * Serializes the particle system to a JSON object.
  13562. * @returns the JSON object
  13563. */
  13564. serialize(): any;
  13565. /**
  13566. * Parse properties from a JSON object
  13567. * @param serializationObject defines the JSON object
  13568. */
  13569. parse(serializationObject: any): void;
  13570. }
  13571. /**
  13572. * Particle emitter emitting particles from the inside of a cylinder.
  13573. * It emits the particles randomly between two vectors.
  13574. */
  13575. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13576. /**
  13577. * The min limit of the emission direction.
  13578. */
  13579. direction1: Vector3;
  13580. /**
  13581. * The max limit of the emission direction.
  13582. */
  13583. direction2: Vector3;
  13584. /**
  13585. * Creates a new instance CylinderDirectedParticleEmitter
  13586. * @param radius the radius of the emission cylinder (1 by default)
  13587. * @param height the height of the emission cylinder (1 by default)
  13588. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13589. * @param direction1 the min limit of the emission direction (up vector by default)
  13590. * @param direction2 the max limit of the emission direction (up vector by default)
  13591. */
  13592. constructor(radius?: number, height?: number, radiusRange?: number,
  13593. /**
  13594. * The min limit of the emission direction.
  13595. */
  13596. direction1?: Vector3,
  13597. /**
  13598. * The max limit of the emission direction.
  13599. */
  13600. direction2?: Vector3);
  13601. /**
  13602. * Called by the particle System when the direction is computed for the created particle.
  13603. * @param worldMatrix is the world matrix of the particle system
  13604. * @param directionToUpdate is the direction vector to update with the result
  13605. * @param particle is the particle we are computed the direction for
  13606. */
  13607. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13608. /**
  13609. * Clones the current emitter and returns a copy of it
  13610. * @returns the new emitter
  13611. */
  13612. clone(): CylinderDirectedParticleEmitter;
  13613. /**
  13614. * Called by the GPUParticleSystem to setup the update shader
  13615. * @param effect defines the update shader
  13616. */
  13617. applyToShader(effect: Effect): void;
  13618. /**
  13619. * Returns a string to use to update the GPU particles update shader
  13620. * @returns a string containng the defines string
  13621. */
  13622. getEffectDefines(): string;
  13623. /**
  13624. * Returns the string "CylinderDirectedParticleEmitter"
  13625. * @returns a string containing the class name
  13626. */
  13627. getClassName(): string;
  13628. /**
  13629. * Serializes the particle system to a JSON object.
  13630. * @returns the JSON object
  13631. */
  13632. serialize(): any;
  13633. /**
  13634. * Parse properties from a JSON object
  13635. * @param serializationObject defines the JSON object
  13636. */
  13637. parse(serializationObject: any): void;
  13638. }
  13639. }
  13640. declare module BABYLON {
  13641. /**
  13642. * Particle emitter emitting particles from the inside of a hemisphere.
  13643. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13644. */
  13645. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13646. /**
  13647. * The radius of the emission hemisphere.
  13648. */
  13649. radius: number;
  13650. /**
  13651. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13652. */
  13653. radiusRange: number;
  13654. /**
  13655. * How much to randomize the particle direction [0-1].
  13656. */
  13657. directionRandomizer: number;
  13658. /**
  13659. * Creates a new instance HemisphericParticleEmitter
  13660. * @param radius the radius of the emission hemisphere (1 by default)
  13661. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13662. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13663. */
  13664. constructor(
  13665. /**
  13666. * The radius of the emission hemisphere.
  13667. */
  13668. radius?: number,
  13669. /**
  13670. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13671. */
  13672. radiusRange?: number,
  13673. /**
  13674. * How much to randomize the particle direction [0-1].
  13675. */
  13676. directionRandomizer?: number);
  13677. /**
  13678. * Called by the particle System when the direction is computed for the created particle.
  13679. * @param worldMatrix is the world matrix of the particle system
  13680. * @param directionToUpdate is the direction vector to update with the result
  13681. * @param particle is the particle we are computed the direction for
  13682. * @param isLocal defines if the direction should be set in local space
  13683. */
  13684. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13685. /**
  13686. * Called by the particle System when the position is computed for the created particle.
  13687. * @param worldMatrix is the world matrix of the particle system
  13688. * @param positionToUpdate is the position vector to update with the result
  13689. * @param particle is the particle we are computed the position for
  13690. * @param isLocal defines if the position should be set in local space
  13691. */
  13692. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13693. /**
  13694. * Clones the current emitter and returns a copy of it
  13695. * @returns the new emitter
  13696. */
  13697. clone(): HemisphericParticleEmitter;
  13698. /**
  13699. * Called by the GPUParticleSystem to setup the update shader
  13700. * @param effect defines the update shader
  13701. */
  13702. applyToShader(effect: Effect): void;
  13703. /**
  13704. * Returns a string to use to update the GPU particles update shader
  13705. * @returns a string containng the defines string
  13706. */
  13707. getEffectDefines(): string;
  13708. /**
  13709. * Returns the string "HemisphericParticleEmitter"
  13710. * @returns a string containing the class name
  13711. */
  13712. getClassName(): string;
  13713. /**
  13714. * Serializes the particle system to a JSON object.
  13715. * @returns the JSON object
  13716. */
  13717. serialize(): any;
  13718. /**
  13719. * Parse properties from a JSON object
  13720. * @param serializationObject defines the JSON object
  13721. */
  13722. parse(serializationObject: any): void;
  13723. }
  13724. }
  13725. declare module BABYLON {
  13726. /**
  13727. * Particle emitter emitting particles from a point.
  13728. * It emits the particles randomly between 2 given directions.
  13729. */
  13730. export class PointParticleEmitter implements IParticleEmitterType {
  13731. /**
  13732. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13733. */
  13734. direction1: Vector3;
  13735. /**
  13736. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13737. */
  13738. direction2: Vector3;
  13739. /**
  13740. * Creates a new instance PointParticleEmitter
  13741. */
  13742. constructor();
  13743. /**
  13744. * Called by the particle System when the direction is computed for the created particle.
  13745. * @param worldMatrix is the world matrix of the particle system
  13746. * @param directionToUpdate is the direction vector to update with the result
  13747. * @param particle is the particle we are computed the direction for
  13748. * @param isLocal defines if the direction should be set in local space
  13749. */
  13750. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13751. /**
  13752. * Called by the particle System when the position is computed for the created particle.
  13753. * @param worldMatrix is the world matrix of the particle system
  13754. * @param positionToUpdate is the position vector to update with the result
  13755. * @param particle is the particle we are computed the position for
  13756. * @param isLocal defines if the position should be set in local space
  13757. */
  13758. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13759. /**
  13760. * Clones the current emitter and returns a copy of it
  13761. * @returns the new emitter
  13762. */
  13763. clone(): PointParticleEmitter;
  13764. /**
  13765. * Called by the GPUParticleSystem to setup the update shader
  13766. * @param effect defines the update shader
  13767. */
  13768. applyToShader(effect: Effect): void;
  13769. /**
  13770. * Returns a string to use to update the GPU particles update shader
  13771. * @returns a string containng the defines string
  13772. */
  13773. getEffectDefines(): string;
  13774. /**
  13775. * Returns the string "PointParticleEmitter"
  13776. * @returns a string containing the class name
  13777. */
  13778. getClassName(): string;
  13779. /**
  13780. * Serializes the particle system to a JSON object.
  13781. * @returns the JSON object
  13782. */
  13783. serialize(): any;
  13784. /**
  13785. * Parse properties from a JSON object
  13786. * @param serializationObject defines the JSON object
  13787. */
  13788. parse(serializationObject: any): void;
  13789. }
  13790. }
  13791. declare module BABYLON {
  13792. /**
  13793. * Particle emitter emitting particles from the inside of a sphere.
  13794. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13795. */
  13796. export class SphereParticleEmitter implements IParticleEmitterType {
  13797. /**
  13798. * The radius of the emission sphere.
  13799. */
  13800. radius: number;
  13801. /**
  13802. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13803. */
  13804. radiusRange: number;
  13805. /**
  13806. * How much to randomize the particle direction [0-1].
  13807. */
  13808. directionRandomizer: number;
  13809. /**
  13810. * Creates a new instance SphereParticleEmitter
  13811. * @param radius the radius of the emission sphere (1 by default)
  13812. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13813. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13814. */
  13815. constructor(
  13816. /**
  13817. * The radius of the emission sphere.
  13818. */
  13819. radius?: number,
  13820. /**
  13821. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13822. */
  13823. radiusRange?: number,
  13824. /**
  13825. * How much to randomize the particle direction [0-1].
  13826. */
  13827. directionRandomizer?: number);
  13828. /**
  13829. * Called by the particle System when the direction is computed for the created particle.
  13830. * @param worldMatrix is the world matrix of the particle system
  13831. * @param directionToUpdate is the direction vector to update with the result
  13832. * @param particle is the particle we are computed the direction for
  13833. * @param isLocal defines if the direction should be set in local space
  13834. */
  13835. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13836. /**
  13837. * Called by the particle System when the position is computed for the created particle.
  13838. * @param worldMatrix is the world matrix of the particle system
  13839. * @param positionToUpdate is the position vector to update with the result
  13840. * @param particle is the particle we are computed the position for
  13841. * @param isLocal defines if the position should be set in local space
  13842. */
  13843. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13844. /**
  13845. * Clones the current emitter and returns a copy of it
  13846. * @returns the new emitter
  13847. */
  13848. clone(): SphereParticleEmitter;
  13849. /**
  13850. * Called by the GPUParticleSystem to setup the update shader
  13851. * @param effect defines the update shader
  13852. */
  13853. applyToShader(effect: Effect): void;
  13854. /**
  13855. * Returns a string to use to update the GPU particles update shader
  13856. * @returns a string containng the defines string
  13857. */
  13858. getEffectDefines(): string;
  13859. /**
  13860. * Returns the string "SphereParticleEmitter"
  13861. * @returns a string containing the class name
  13862. */
  13863. getClassName(): string;
  13864. /**
  13865. * Serializes the particle system to a JSON object.
  13866. * @returns the JSON object
  13867. */
  13868. serialize(): any;
  13869. /**
  13870. * Parse properties from a JSON object
  13871. * @param serializationObject defines the JSON object
  13872. */
  13873. parse(serializationObject: any): void;
  13874. }
  13875. /**
  13876. * Particle emitter emitting particles from the inside of a sphere.
  13877. * It emits the particles randomly between two vectors.
  13878. */
  13879. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13880. /**
  13881. * The min limit of the emission direction.
  13882. */
  13883. direction1: Vector3;
  13884. /**
  13885. * The max limit of the emission direction.
  13886. */
  13887. direction2: Vector3;
  13888. /**
  13889. * Creates a new instance SphereDirectedParticleEmitter
  13890. * @param radius the radius of the emission sphere (1 by default)
  13891. * @param direction1 the min limit of the emission direction (up vector by default)
  13892. * @param direction2 the max limit of the emission direction (up vector by default)
  13893. */
  13894. constructor(radius?: number,
  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. * Called by the particle System when the direction is computed for the created particle.
  13905. * @param worldMatrix is the world matrix of the particle system
  13906. * @param directionToUpdate is the direction vector to update with the result
  13907. * @param particle is the particle we are computed the direction for
  13908. */
  13909. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13910. /**
  13911. * Clones the current emitter and returns a copy of it
  13912. * @returns the new emitter
  13913. */
  13914. clone(): SphereDirectedParticleEmitter;
  13915. /**
  13916. * Called by the GPUParticleSystem to setup the update shader
  13917. * @param effect defines the update shader
  13918. */
  13919. applyToShader(effect: Effect): void;
  13920. /**
  13921. * Returns a string to use to update the GPU particles update shader
  13922. * @returns a string containng the defines string
  13923. */
  13924. getEffectDefines(): string;
  13925. /**
  13926. * Returns the string "SphereDirectedParticleEmitter"
  13927. * @returns a string containing the class name
  13928. */
  13929. getClassName(): string;
  13930. /**
  13931. * Serializes the particle system to a JSON object.
  13932. * @returns the JSON object
  13933. */
  13934. serialize(): any;
  13935. /**
  13936. * Parse properties from a JSON object
  13937. * @param serializationObject defines the JSON object
  13938. */
  13939. parse(serializationObject: any): void;
  13940. }
  13941. }
  13942. declare module BABYLON {
  13943. /**
  13944. * Particle emitter emitting particles from a custom list of positions.
  13945. */
  13946. export class CustomParticleEmitter implements IParticleEmitterType {
  13947. /**
  13948. * Gets or sets the position generator that will create the inital position of each particle.
  13949. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13950. */
  13951. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13952. /**
  13953. * Gets or sets the destination generator that will create the final destination of each particle.
  13954. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13955. */
  13956. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13957. /**
  13958. * Creates a new instance CustomParticleEmitter
  13959. */
  13960. constructor();
  13961. /**
  13962. * Called by the particle System when the direction is computed for the created particle.
  13963. * @param worldMatrix is the world matrix of the particle system
  13964. * @param directionToUpdate is the direction vector to update with the result
  13965. * @param particle is the particle we are computed the direction for
  13966. * @param isLocal defines if the direction should be set in local space
  13967. */
  13968. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13969. /**
  13970. * Called by the particle System when the position is computed for the created particle.
  13971. * @param worldMatrix is the world matrix of the particle system
  13972. * @param positionToUpdate is the position vector to update with the result
  13973. * @param particle is the particle we are computed the position for
  13974. * @param isLocal defines if the position should be set in local space
  13975. */
  13976. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13977. /**
  13978. * Clones the current emitter and returns a copy of it
  13979. * @returns the new emitter
  13980. */
  13981. clone(): CustomParticleEmitter;
  13982. /**
  13983. * Called by the GPUParticleSystem to setup the update shader
  13984. * @param effect defines the update shader
  13985. */
  13986. applyToShader(effect: Effect): void;
  13987. /**
  13988. * Returns a string to use to update the GPU particles update shader
  13989. * @returns a string containng the defines string
  13990. */
  13991. getEffectDefines(): string;
  13992. /**
  13993. * Returns the string "PointParticleEmitter"
  13994. * @returns a string containing the class name
  13995. */
  13996. getClassName(): string;
  13997. /**
  13998. * Serializes the particle system to a JSON object.
  13999. * @returns the JSON object
  14000. */
  14001. serialize(): any;
  14002. /**
  14003. * Parse properties from a JSON object
  14004. * @param serializationObject defines the JSON object
  14005. */
  14006. parse(serializationObject: any): void;
  14007. }
  14008. }
  14009. declare module BABYLON {
  14010. /**
  14011. * Particle emitter emitting particles from the inside of a box.
  14012. * It emits the particles randomly between 2 given directions.
  14013. */
  14014. export class MeshParticleEmitter implements IParticleEmitterType {
  14015. private _indices;
  14016. private _positions;
  14017. private _normals;
  14018. private _storedNormal;
  14019. private _mesh;
  14020. /**
  14021. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14022. */
  14023. direction1: Vector3;
  14024. /**
  14025. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14026. */
  14027. direction2: Vector3;
  14028. /**
  14029. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14030. */
  14031. useMeshNormalsForDirection: boolean;
  14032. /** Defines the mesh to use as source */
  14033. get mesh(): Nullable<AbstractMesh>;
  14034. set mesh(value: Nullable<AbstractMesh>);
  14035. /**
  14036. * Creates a new instance MeshParticleEmitter
  14037. * @param mesh defines the mesh to use as source
  14038. */
  14039. constructor(mesh?: Nullable<AbstractMesh>);
  14040. /**
  14041. * Called by the particle System when the direction is computed for the created particle.
  14042. * @param worldMatrix is the world matrix of the particle system
  14043. * @param directionToUpdate is the direction vector to update with the result
  14044. * @param particle is the particle we are computed the direction for
  14045. * @param isLocal defines if the direction should be set in local space
  14046. */
  14047. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14048. /**
  14049. * Called by the particle System when the position is computed for the created particle.
  14050. * @param worldMatrix is the world matrix of the particle system
  14051. * @param positionToUpdate is the position vector to update with the result
  14052. * @param particle is the particle we are computed the position for
  14053. * @param isLocal defines if the position should be set in local space
  14054. */
  14055. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14056. /**
  14057. * Clones the current emitter and returns a copy of it
  14058. * @returns the new emitter
  14059. */
  14060. clone(): MeshParticleEmitter;
  14061. /**
  14062. * Called by the GPUParticleSystem to setup the update shader
  14063. * @param effect defines the update shader
  14064. */
  14065. applyToShader(effect: Effect): void;
  14066. /**
  14067. * Returns a string to use to update the GPU particles update shader
  14068. * @returns a string containng the defines string
  14069. */
  14070. getEffectDefines(): string;
  14071. /**
  14072. * Returns the string "BoxParticleEmitter"
  14073. * @returns a string containing the class name
  14074. */
  14075. getClassName(): string;
  14076. /**
  14077. * Serializes the particle system to a JSON object.
  14078. * @returns the JSON object
  14079. */
  14080. serialize(): any;
  14081. /**
  14082. * Parse properties from a JSON object
  14083. * @param serializationObject defines the JSON object
  14084. * @param scene defines the hosting scene
  14085. */
  14086. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14087. }
  14088. }
  14089. declare module BABYLON {
  14090. /**
  14091. * Interface representing a particle system in Babylon.js.
  14092. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14093. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14094. */
  14095. export interface IParticleSystem {
  14096. /**
  14097. * List of animations used by the particle system.
  14098. */
  14099. animations: Animation[];
  14100. /**
  14101. * The id of the Particle system.
  14102. */
  14103. id: string;
  14104. /**
  14105. * The name of the Particle system.
  14106. */
  14107. name: string;
  14108. /**
  14109. * The emitter represents the Mesh or position we are attaching the particle system to.
  14110. */
  14111. emitter: Nullable<AbstractMesh | Vector3>;
  14112. /**
  14113. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14114. */
  14115. isBillboardBased: boolean;
  14116. /**
  14117. * The rendering group used by the Particle system to chose when to render.
  14118. */
  14119. renderingGroupId: number;
  14120. /**
  14121. * The layer mask we are rendering the particles through.
  14122. */
  14123. layerMask: number;
  14124. /**
  14125. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14126. */
  14127. updateSpeed: number;
  14128. /**
  14129. * The amount of time the particle system is running (depends of the overall update speed).
  14130. */
  14131. targetStopDuration: number;
  14132. /**
  14133. * The texture used to render each particle. (this can be a spritesheet)
  14134. */
  14135. particleTexture: Nullable<BaseTexture>;
  14136. /**
  14137. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14138. */
  14139. blendMode: number;
  14140. /**
  14141. * Minimum life time of emitting particles.
  14142. */
  14143. minLifeTime: number;
  14144. /**
  14145. * Maximum life time of emitting particles.
  14146. */
  14147. maxLifeTime: number;
  14148. /**
  14149. * Minimum Size of emitting particles.
  14150. */
  14151. minSize: number;
  14152. /**
  14153. * Maximum Size of emitting particles.
  14154. */
  14155. maxSize: number;
  14156. /**
  14157. * Minimum scale of emitting particles on X axis.
  14158. */
  14159. minScaleX: number;
  14160. /**
  14161. * Maximum scale of emitting particles on X axis.
  14162. */
  14163. maxScaleX: number;
  14164. /**
  14165. * Minimum scale of emitting particles on Y axis.
  14166. */
  14167. minScaleY: number;
  14168. /**
  14169. * Maximum scale of emitting particles on Y axis.
  14170. */
  14171. maxScaleY: number;
  14172. /**
  14173. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14174. */
  14175. color1: Color4;
  14176. /**
  14177. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14178. */
  14179. color2: Color4;
  14180. /**
  14181. * Color the particle will have at the end of its lifetime.
  14182. */
  14183. colorDead: Color4;
  14184. /**
  14185. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14186. */
  14187. emitRate: number;
  14188. /**
  14189. * You can use gravity if you want to give an orientation to your particles.
  14190. */
  14191. gravity: Vector3;
  14192. /**
  14193. * Minimum power of emitting particles.
  14194. */
  14195. minEmitPower: number;
  14196. /**
  14197. * Maximum power of emitting particles.
  14198. */
  14199. maxEmitPower: number;
  14200. /**
  14201. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14202. */
  14203. minAngularSpeed: number;
  14204. /**
  14205. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14206. */
  14207. maxAngularSpeed: number;
  14208. /**
  14209. * Gets or sets the minimal initial rotation in radians.
  14210. */
  14211. minInitialRotation: number;
  14212. /**
  14213. * Gets or sets the maximal initial rotation in radians.
  14214. */
  14215. maxInitialRotation: number;
  14216. /**
  14217. * The particle emitter type defines the emitter used by the particle system.
  14218. * It can be for example box, sphere, or cone...
  14219. */
  14220. particleEmitterType: Nullable<IParticleEmitterType>;
  14221. /**
  14222. * Defines the delay in milliseconds before starting the system (0 by default)
  14223. */
  14224. startDelay: number;
  14225. /**
  14226. * 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
  14227. */
  14228. preWarmCycles: number;
  14229. /**
  14230. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14231. */
  14232. preWarmStepOffset: number;
  14233. /**
  14234. * 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)
  14235. */
  14236. spriteCellChangeSpeed: number;
  14237. /**
  14238. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14239. */
  14240. startSpriteCellID: number;
  14241. /**
  14242. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14243. */
  14244. endSpriteCellID: number;
  14245. /**
  14246. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14247. */
  14248. spriteCellWidth: number;
  14249. /**
  14250. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14251. */
  14252. spriteCellHeight: number;
  14253. /**
  14254. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14255. */
  14256. spriteRandomStartCell: boolean;
  14257. /**
  14258. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14259. */
  14260. isAnimationSheetEnabled: boolean;
  14261. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14262. translationPivot: Vector2;
  14263. /**
  14264. * Gets or sets a texture used to add random noise to particle positions
  14265. */
  14266. noiseTexture: Nullable<BaseTexture>;
  14267. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14268. noiseStrength: Vector3;
  14269. /**
  14270. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14271. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14272. */
  14273. billboardMode: number;
  14274. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14275. limitVelocityDamping: number;
  14276. /**
  14277. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14278. */
  14279. beginAnimationOnStart: boolean;
  14280. /**
  14281. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14282. */
  14283. beginAnimationFrom: number;
  14284. /**
  14285. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14286. */
  14287. beginAnimationTo: number;
  14288. /**
  14289. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14290. */
  14291. beginAnimationLoop: boolean;
  14292. /**
  14293. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14294. */
  14295. disposeOnStop: boolean;
  14296. /**
  14297. * Specifies if the particles are updated in emitter local space or world space
  14298. */
  14299. isLocal: boolean;
  14300. /** Snippet ID if the particle system was created from the snippet server */
  14301. snippetId: string;
  14302. /** Gets or sets a matrix to use to compute projection */
  14303. defaultProjectionMatrix: Matrix;
  14304. /**
  14305. * Gets the maximum number of particles active at the same time.
  14306. * @returns The max number of active particles.
  14307. */
  14308. getCapacity(): number;
  14309. /**
  14310. * Gets the number of particles active at the same time.
  14311. * @returns The number of active particles.
  14312. */
  14313. getActiveCount(): number;
  14314. /**
  14315. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14316. * @returns True if it has been started, otherwise false.
  14317. */
  14318. isStarted(): boolean;
  14319. /**
  14320. * Animates the particle system for this frame.
  14321. */
  14322. animate(): void;
  14323. /**
  14324. * Renders the particle system in its current state.
  14325. * @returns the current number of particles
  14326. */
  14327. render(): number;
  14328. /**
  14329. * Dispose the particle system and frees its associated resources.
  14330. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14331. */
  14332. dispose(disposeTexture?: boolean): void;
  14333. /**
  14334. * An event triggered when the system is disposed
  14335. */
  14336. onDisposeObservable: Observable<IParticleSystem>;
  14337. /**
  14338. * An event triggered when the system is stopped
  14339. */
  14340. onStoppedObservable: Observable<IParticleSystem>;
  14341. /**
  14342. * Clones the particle system.
  14343. * @param name The name of the cloned object
  14344. * @param newEmitter The new emitter to use
  14345. * @returns the cloned particle system
  14346. */
  14347. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14348. /**
  14349. * Serializes the particle system to a JSON object
  14350. * @param serializeTexture defines if the texture must be serialized as well
  14351. * @returns the JSON object
  14352. */
  14353. serialize(serializeTexture: boolean): any;
  14354. /**
  14355. * Rebuild the particle system
  14356. */
  14357. rebuild(): void;
  14358. /** Force the system to rebuild all gradients that need to be resync */
  14359. forceRefreshGradients(): void;
  14360. /**
  14361. * Starts the particle system and begins to emit
  14362. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14363. */
  14364. start(delay?: number): void;
  14365. /**
  14366. * Stops the particle system.
  14367. */
  14368. stop(): void;
  14369. /**
  14370. * Remove all active particles
  14371. */
  14372. reset(): void;
  14373. /**
  14374. * Gets a boolean indicating that the system is stopping
  14375. * @returns true if the system is currently stopping
  14376. */
  14377. isStopping(): boolean;
  14378. /**
  14379. * Is this system ready to be used/rendered
  14380. * @return true if the system is ready
  14381. */
  14382. isReady(): boolean;
  14383. /**
  14384. * Returns the string "ParticleSystem"
  14385. * @returns a string containing the class name
  14386. */
  14387. getClassName(): string;
  14388. /**
  14389. * Gets the custom effect used to render the particles
  14390. * @param blendMode Blend mode for which the effect should be retrieved
  14391. * @returns The effect
  14392. */
  14393. getCustomEffect(blendMode: number): Nullable<Effect>;
  14394. /**
  14395. * Sets the custom effect used to render the particles
  14396. * @param effect The effect to set
  14397. * @param blendMode Blend mode for which the effect should be set
  14398. */
  14399. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14400. /**
  14401. * Fill the defines array according to the current settings of the particle system
  14402. * @param defines Array to be updated
  14403. * @param blendMode blend mode to take into account when updating the array
  14404. */
  14405. fillDefines(defines: Array<string>, blendMode: number): void;
  14406. /**
  14407. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14408. * @param uniforms Uniforms array to fill
  14409. * @param attributes Attributes array to fill
  14410. * @param samplers Samplers array to fill
  14411. */
  14412. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14413. /**
  14414. * Observable that will be called just before the particles are drawn
  14415. */
  14416. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14417. /**
  14418. * Gets the name of the particle vertex shader
  14419. */
  14420. vertexShaderName: string;
  14421. /**
  14422. * Adds a new color gradient
  14423. * @param gradient defines the gradient to use (between 0 and 1)
  14424. * @param color1 defines the color to affect to the specified gradient
  14425. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14426. * @returns the current particle system
  14427. */
  14428. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14429. /**
  14430. * Remove a specific color gradient
  14431. * @param gradient defines the gradient to remove
  14432. * @returns the current particle system
  14433. */
  14434. removeColorGradient(gradient: number): IParticleSystem;
  14435. /**
  14436. * Adds a new size gradient
  14437. * @param gradient defines the gradient to use (between 0 and 1)
  14438. * @param factor defines the size factor to affect to the specified gradient
  14439. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14440. * @returns the current particle system
  14441. */
  14442. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14443. /**
  14444. * Remove a specific size gradient
  14445. * @param gradient defines the gradient to remove
  14446. * @returns the current particle system
  14447. */
  14448. removeSizeGradient(gradient: number): IParticleSystem;
  14449. /**
  14450. * Gets the current list of color gradients.
  14451. * You must use addColorGradient and removeColorGradient to udpate this list
  14452. * @returns the list of color gradients
  14453. */
  14454. getColorGradients(): Nullable<Array<ColorGradient>>;
  14455. /**
  14456. * Gets the current list of size gradients.
  14457. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14458. * @returns the list of size gradients
  14459. */
  14460. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14461. /**
  14462. * Gets the current list of angular speed gradients.
  14463. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14464. * @returns the list of angular speed gradients
  14465. */
  14466. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14467. /**
  14468. * Adds a new angular speed gradient
  14469. * @param gradient defines the gradient to use (between 0 and 1)
  14470. * @param factor defines the angular speed to affect to the specified gradient
  14471. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14472. * @returns the current particle system
  14473. */
  14474. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14475. /**
  14476. * Remove a specific angular speed gradient
  14477. * @param gradient defines the gradient to remove
  14478. * @returns the current particle system
  14479. */
  14480. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14481. /**
  14482. * Gets the current list of velocity gradients.
  14483. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14484. * @returns the list of velocity gradients
  14485. */
  14486. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14487. /**
  14488. * Adds a new velocity gradient
  14489. * @param gradient defines the gradient to use (between 0 and 1)
  14490. * @param factor defines the velocity to affect to the specified gradient
  14491. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14492. * @returns the current particle system
  14493. */
  14494. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14495. /**
  14496. * Remove a specific velocity gradient
  14497. * @param gradient defines the gradient to remove
  14498. * @returns the current particle system
  14499. */
  14500. removeVelocityGradient(gradient: number): IParticleSystem;
  14501. /**
  14502. * Gets the current list of limit velocity gradients.
  14503. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14504. * @returns the list of limit velocity gradients
  14505. */
  14506. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14507. /**
  14508. * Adds a new limit velocity gradient
  14509. * @param gradient defines the gradient to use (between 0 and 1)
  14510. * @param factor defines the limit velocity to affect to the specified gradient
  14511. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14512. * @returns the current particle system
  14513. */
  14514. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14515. /**
  14516. * Remove a specific limit velocity gradient
  14517. * @param gradient defines the gradient to remove
  14518. * @returns the current particle system
  14519. */
  14520. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14521. /**
  14522. * Adds a new drag gradient
  14523. * @param gradient defines the gradient to use (between 0 and 1)
  14524. * @param factor defines the drag to affect to the specified gradient
  14525. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14526. * @returns the current particle system
  14527. */
  14528. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14529. /**
  14530. * Remove a specific drag gradient
  14531. * @param gradient defines the gradient to remove
  14532. * @returns the current particle system
  14533. */
  14534. removeDragGradient(gradient: number): IParticleSystem;
  14535. /**
  14536. * Gets the current list of drag gradients.
  14537. * You must use addDragGradient and removeDragGradient to udpate this list
  14538. * @returns the list of drag gradients
  14539. */
  14540. getDragGradients(): Nullable<Array<FactorGradient>>;
  14541. /**
  14542. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14543. * @param gradient defines the gradient to use (between 0 and 1)
  14544. * @param factor defines the emit rate to affect to the specified gradient
  14545. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14546. * @returns the current particle system
  14547. */
  14548. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14549. /**
  14550. * Remove a specific emit rate gradient
  14551. * @param gradient defines the gradient to remove
  14552. * @returns the current particle system
  14553. */
  14554. removeEmitRateGradient(gradient: number): IParticleSystem;
  14555. /**
  14556. * Gets the current list of emit rate gradients.
  14557. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14558. * @returns the list of emit rate gradients
  14559. */
  14560. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14561. /**
  14562. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14563. * @param gradient defines the gradient to use (between 0 and 1)
  14564. * @param factor defines the start size to affect to the specified gradient
  14565. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14566. * @returns the current particle system
  14567. */
  14568. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14569. /**
  14570. * Remove a specific start size gradient
  14571. * @param gradient defines the gradient to remove
  14572. * @returns the current particle system
  14573. */
  14574. removeStartSizeGradient(gradient: number): IParticleSystem;
  14575. /**
  14576. * Gets the current list of start size gradients.
  14577. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14578. * @returns the list of start size gradients
  14579. */
  14580. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14581. /**
  14582. * Adds a new life time gradient
  14583. * @param gradient defines the gradient to use (between 0 and 1)
  14584. * @param factor defines the life time factor to affect to the specified gradient
  14585. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14586. * @returns the current particle system
  14587. */
  14588. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14589. /**
  14590. * Remove a specific life time gradient
  14591. * @param gradient defines the gradient to remove
  14592. * @returns the current particle system
  14593. */
  14594. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14595. /**
  14596. * Gets the current list of life time gradients.
  14597. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14598. * @returns the list of life time gradients
  14599. */
  14600. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14601. /**
  14602. * Gets the current list of color gradients.
  14603. * You must use addColorGradient and removeColorGradient to udpate this list
  14604. * @returns the list of color gradients
  14605. */
  14606. getColorGradients(): Nullable<Array<ColorGradient>>;
  14607. /**
  14608. * Adds a new ramp gradient used to remap particle colors
  14609. * @param gradient defines the gradient to use (between 0 and 1)
  14610. * @param color defines the color to affect to the specified gradient
  14611. * @returns the current particle system
  14612. */
  14613. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14614. /**
  14615. * Gets the current list of ramp gradients.
  14616. * You must use addRampGradient and removeRampGradient to udpate this list
  14617. * @returns the list of ramp gradients
  14618. */
  14619. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14620. /** Gets or sets a boolean indicating that ramp gradients must be used
  14621. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14622. */
  14623. useRampGradients: boolean;
  14624. /**
  14625. * Adds a new color remap gradient
  14626. * @param gradient defines the gradient to use (between 0 and 1)
  14627. * @param min defines the color remap minimal range
  14628. * @param max defines the color remap maximal range
  14629. * @returns the current particle system
  14630. */
  14631. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14632. /**
  14633. * Gets the current list of color remap gradients.
  14634. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14635. * @returns the list of color remap gradients
  14636. */
  14637. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14638. /**
  14639. * Adds a new alpha remap gradient
  14640. * @param gradient defines the gradient to use (between 0 and 1)
  14641. * @param min defines the alpha remap minimal range
  14642. * @param max defines the alpha remap maximal range
  14643. * @returns the current particle system
  14644. */
  14645. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14646. /**
  14647. * Gets the current list of alpha remap gradients.
  14648. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14649. * @returns the list of alpha remap gradients
  14650. */
  14651. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14652. /**
  14653. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14654. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14655. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14656. * @returns the emitter
  14657. */
  14658. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14659. /**
  14660. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14661. * @param radius The radius of the hemisphere to emit from
  14662. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14663. * @returns the emitter
  14664. */
  14665. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14666. /**
  14667. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14668. * @param radius The radius of the sphere to emit from
  14669. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14670. * @returns the emitter
  14671. */
  14672. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14673. /**
  14674. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14675. * @param radius The radius of the sphere to emit from
  14676. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14677. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14678. * @returns the emitter
  14679. */
  14680. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14681. /**
  14682. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14683. * @param radius The radius of the emission cylinder
  14684. * @param height The height of the emission cylinder
  14685. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14686. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14687. * @returns the emitter
  14688. */
  14689. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14690. /**
  14691. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14692. * @param radius The radius of the cylinder to emit from
  14693. * @param height The height of the emission cylinder
  14694. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14695. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14696. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14697. * @returns the emitter
  14698. */
  14699. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14700. /**
  14701. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14702. * @param radius The radius of the cone to emit from
  14703. * @param angle The base angle of the cone
  14704. * @returns the emitter
  14705. */
  14706. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14707. /**
  14708. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14709. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14710. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14711. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14712. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14713. * @returns the emitter
  14714. */
  14715. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14716. /**
  14717. * Get hosting scene
  14718. * @returns the scene
  14719. */
  14720. getScene(): Nullable<Scene>;
  14721. }
  14722. }
  14723. declare module BABYLON {
  14724. /**
  14725. * 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.
  14726. * @see https://doc.babylonjs.com/how_to/transformnode
  14727. */
  14728. export class TransformNode extends Node {
  14729. /**
  14730. * Object will not rotate to face the camera
  14731. */
  14732. static BILLBOARDMODE_NONE: number;
  14733. /**
  14734. * Object will rotate to face the camera but only on the x axis
  14735. */
  14736. static BILLBOARDMODE_X: number;
  14737. /**
  14738. * Object will rotate to face the camera but only on the y axis
  14739. */
  14740. static BILLBOARDMODE_Y: number;
  14741. /**
  14742. * Object will rotate to face the camera but only on the z axis
  14743. */
  14744. static BILLBOARDMODE_Z: number;
  14745. /**
  14746. * Object will rotate to face the camera
  14747. */
  14748. static BILLBOARDMODE_ALL: number;
  14749. /**
  14750. * Object will rotate to face the camera's position instead of orientation
  14751. */
  14752. static BILLBOARDMODE_USE_POSITION: number;
  14753. private static _TmpRotation;
  14754. private static _TmpScaling;
  14755. private static _TmpTranslation;
  14756. private _forward;
  14757. private _forwardInverted;
  14758. private _up;
  14759. private _right;
  14760. private _rightInverted;
  14761. private _position;
  14762. private _rotation;
  14763. private _rotationQuaternion;
  14764. protected _scaling: Vector3;
  14765. protected _isDirty: boolean;
  14766. private _transformToBoneReferal;
  14767. private _isAbsoluteSynced;
  14768. private _billboardMode;
  14769. /**
  14770. * Gets or sets the billboard mode. Default is 0.
  14771. *
  14772. * | Value | Type | Description |
  14773. * | --- | --- | --- |
  14774. * | 0 | BILLBOARDMODE_NONE | |
  14775. * | 1 | BILLBOARDMODE_X | |
  14776. * | 2 | BILLBOARDMODE_Y | |
  14777. * | 4 | BILLBOARDMODE_Z | |
  14778. * | 7 | BILLBOARDMODE_ALL | |
  14779. *
  14780. */
  14781. get billboardMode(): number;
  14782. set billboardMode(value: number);
  14783. private _preserveParentRotationForBillboard;
  14784. /**
  14785. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14786. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14787. */
  14788. get preserveParentRotationForBillboard(): boolean;
  14789. set preserveParentRotationForBillboard(value: boolean);
  14790. /**
  14791. * 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
  14792. */
  14793. scalingDeterminant: number;
  14794. private _infiniteDistance;
  14795. /**
  14796. * Gets or sets the distance of the object to max, often used by skybox
  14797. */
  14798. get infiniteDistance(): boolean;
  14799. set infiniteDistance(value: boolean);
  14800. /**
  14801. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14802. * By default the system will update normals to compensate
  14803. */
  14804. ignoreNonUniformScaling: boolean;
  14805. /**
  14806. * 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
  14807. */
  14808. reIntegrateRotationIntoRotationQuaternion: boolean;
  14809. /** @hidden */
  14810. _poseMatrix: Nullable<Matrix>;
  14811. /** @hidden */
  14812. _localMatrix: Matrix;
  14813. private _usePivotMatrix;
  14814. private _absolutePosition;
  14815. private _absoluteScaling;
  14816. private _absoluteRotationQuaternion;
  14817. private _pivotMatrix;
  14818. private _pivotMatrixInverse;
  14819. /** @hidden */
  14820. _postMultiplyPivotMatrix: boolean;
  14821. protected _isWorldMatrixFrozen: boolean;
  14822. /** @hidden */
  14823. _indexInSceneTransformNodesArray: number;
  14824. /**
  14825. * An event triggered after the world matrix is updated
  14826. */
  14827. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14828. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14829. /**
  14830. * Gets a string identifying the name of the class
  14831. * @returns "TransformNode" string
  14832. */
  14833. getClassName(): string;
  14834. /**
  14835. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14836. */
  14837. get position(): Vector3;
  14838. set position(newPosition: Vector3);
  14839. /**
  14840. * 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)).
  14841. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14842. */
  14843. get rotation(): Vector3;
  14844. set rotation(newRotation: Vector3);
  14845. /**
  14846. * 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)).
  14847. */
  14848. get scaling(): Vector3;
  14849. set scaling(newScaling: Vector3);
  14850. /**
  14851. * 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).
  14852. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14853. */
  14854. get rotationQuaternion(): Nullable<Quaternion>;
  14855. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14856. /**
  14857. * The forward direction of that transform in world space.
  14858. */
  14859. get forward(): Vector3;
  14860. /**
  14861. * The up direction of that transform in world space.
  14862. */
  14863. get up(): Vector3;
  14864. /**
  14865. * The right direction of that transform in world space.
  14866. */
  14867. get right(): Vector3;
  14868. /**
  14869. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14870. * @param matrix the matrix to copy the pose from
  14871. * @returns this TransformNode.
  14872. */
  14873. updatePoseMatrix(matrix: Matrix): TransformNode;
  14874. /**
  14875. * Returns the mesh Pose matrix.
  14876. * @returns the pose matrix
  14877. */
  14878. getPoseMatrix(): Matrix;
  14879. /** @hidden */
  14880. _isSynchronized(): boolean;
  14881. /** @hidden */
  14882. _initCache(): void;
  14883. /**
  14884. * Flag the transform node as dirty (Forcing it to update everything)
  14885. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14886. * @returns this transform node
  14887. */
  14888. markAsDirty(property: string): TransformNode;
  14889. /**
  14890. * Returns the current mesh absolute position.
  14891. * Returns a Vector3.
  14892. */
  14893. get absolutePosition(): Vector3;
  14894. /**
  14895. * Returns the current mesh absolute scaling.
  14896. * Returns a Vector3.
  14897. */
  14898. get absoluteScaling(): Vector3;
  14899. /**
  14900. * Returns the current mesh absolute rotation.
  14901. * Returns a Quaternion.
  14902. */
  14903. get absoluteRotationQuaternion(): Quaternion;
  14904. /**
  14905. * Sets a new matrix to apply before all other transformation
  14906. * @param matrix defines the transform matrix
  14907. * @returns the current TransformNode
  14908. */
  14909. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14910. /**
  14911. * Sets a new pivot matrix to the current node
  14912. * @param matrix defines the new pivot matrix to use
  14913. * @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
  14914. * @returns the current TransformNode
  14915. */
  14916. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14917. /**
  14918. * Returns the mesh pivot matrix.
  14919. * Default : Identity.
  14920. * @returns the matrix
  14921. */
  14922. getPivotMatrix(): Matrix;
  14923. /**
  14924. * Instantiate (when possible) or clone that node with its hierarchy
  14925. * @param newParent defines the new parent to use for the instance (or clone)
  14926. * @param options defines options to configure how copy is done
  14927. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14928. * @returns an instance (or a clone) of the current node with its hiearchy
  14929. */
  14930. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14931. doNotInstantiate: boolean;
  14932. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14933. /**
  14934. * Prevents the World matrix to be computed any longer
  14935. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14936. * @returns the TransformNode.
  14937. */
  14938. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14939. /**
  14940. * Allows back the World matrix computation.
  14941. * @returns the TransformNode.
  14942. */
  14943. unfreezeWorldMatrix(): this;
  14944. /**
  14945. * True if the World matrix has been frozen.
  14946. */
  14947. get isWorldMatrixFrozen(): boolean;
  14948. /**
  14949. * Retuns the mesh absolute position in the World.
  14950. * @returns a Vector3.
  14951. */
  14952. getAbsolutePosition(): Vector3;
  14953. /**
  14954. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14955. * @param absolutePosition the absolute position to set
  14956. * @returns the TransformNode.
  14957. */
  14958. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14959. /**
  14960. * Sets the mesh position in its local space.
  14961. * @param vector3 the position to set in localspace
  14962. * @returns the TransformNode.
  14963. */
  14964. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14965. /**
  14966. * Returns the mesh position in the local space from the current World matrix values.
  14967. * @returns a new Vector3.
  14968. */
  14969. getPositionExpressedInLocalSpace(): Vector3;
  14970. /**
  14971. * Translates the mesh along the passed Vector3 in its local space.
  14972. * @param vector3 the distance to translate in localspace
  14973. * @returns the TransformNode.
  14974. */
  14975. locallyTranslate(vector3: Vector3): TransformNode;
  14976. private static _lookAtVectorCache;
  14977. /**
  14978. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14979. * @param targetPoint the position (must be in same space as current mesh) to look at
  14980. * @param yawCor optional yaw (y-axis) correction in radians
  14981. * @param pitchCor optional pitch (x-axis) correction in radians
  14982. * @param rollCor optional roll (z-axis) correction in radians
  14983. * @param space the choosen space of the target
  14984. * @returns the TransformNode.
  14985. */
  14986. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14987. /**
  14988. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14989. * This Vector3 is expressed in the World space.
  14990. * @param localAxis axis to rotate
  14991. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14992. */
  14993. getDirection(localAxis: Vector3): Vector3;
  14994. /**
  14995. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14996. * localAxis is expressed in the mesh local space.
  14997. * result is computed in the Wordl space from the mesh World matrix.
  14998. * @param localAxis axis to rotate
  14999. * @param result the resulting transformnode
  15000. * @returns this TransformNode.
  15001. */
  15002. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15003. /**
  15004. * Sets this transform node rotation to the given local axis.
  15005. * @param localAxis the axis in local space
  15006. * @param yawCor optional yaw (y-axis) correction in radians
  15007. * @param pitchCor optional pitch (x-axis) correction in radians
  15008. * @param rollCor optional roll (z-axis) correction in radians
  15009. * @returns this TransformNode
  15010. */
  15011. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15012. /**
  15013. * Sets a new pivot point to the current node
  15014. * @param point defines the new pivot point to use
  15015. * @param space defines if the point is in world or local space (local by default)
  15016. * @returns the current TransformNode
  15017. */
  15018. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15019. /**
  15020. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15021. * @returns the pivot point
  15022. */
  15023. getPivotPoint(): Vector3;
  15024. /**
  15025. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15026. * @param result the vector3 to store the result
  15027. * @returns this TransformNode.
  15028. */
  15029. getPivotPointToRef(result: Vector3): TransformNode;
  15030. /**
  15031. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15032. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15033. */
  15034. getAbsolutePivotPoint(): Vector3;
  15035. /**
  15036. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15037. * @param result vector3 to store the result
  15038. * @returns this TransformNode.
  15039. */
  15040. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15041. /**
  15042. * Defines the passed node as the parent of the current node.
  15043. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15044. * @see https://doc.babylonjs.com/how_to/parenting
  15045. * @param node the node ot set as the parent
  15046. * @returns this TransformNode.
  15047. */
  15048. setParent(node: Nullable<Node>): TransformNode;
  15049. private _nonUniformScaling;
  15050. /**
  15051. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15052. */
  15053. get nonUniformScaling(): boolean;
  15054. /** @hidden */
  15055. _updateNonUniformScalingState(value: boolean): boolean;
  15056. /**
  15057. * Attach the current TransformNode to another TransformNode associated with a bone
  15058. * @param bone Bone affecting the TransformNode
  15059. * @param affectedTransformNode TransformNode associated with the bone
  15060. * @returns this object
  15061. */
  15062. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15063. /**
  15064. * Detach the transform node if its associated with a bone
  15065. * @returns this object
  15066. */
  15067. detachFromBone(): TransformNode;
  15068. private static _rotationAxisCache;
  15069. /**
  15070. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15071. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15072. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15073. * The passed axis is also normalized.
  15074. * @param axis the axis to rotate around
  15075. * @param amount the amount to rotate in radians
  15076. * @param space Space to rotate in (Default: local)
  15077. * @returns the TransformNode.
  15078. */
  15079. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15080. /**
  15081. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15082. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15083. * The passed axis is also normalized. .
  15084. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15085. * @param point the point to rotate around
  15086. * @param axis the axis to rotate around
  15087. * @param amount the amount to rotate in radians
  15088. * @returns the TransformNode
  15089. */
  15090. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15091. /**
  15092. * Translates the mesh along the axis vector for the passed distance in the given space.
  15093. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15094. * @param axis the axis to translate in
  15095. * @param distance the distance to translate
  15096. * @param space Space to rotate in (Default: local)
  15097. * @returns the TransformNode.
  15098. */
  15099. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15100. /**
  15101. * Adds a rotation step to the mesh current rotation.
  15102. * x, y, z are Euler angles expressed in radians.
  15103. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15104. * This means this rotation is made in the mesh local space only.
  15105. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15106. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15107. * ```javascript
  15108. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15109. * ```
  15110. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15111. * 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.
  15112. * @param x Rotation to add
  15113. * @param y Rotation to add
  15114. * @param z Rotation to add
  15115. * @returns the TransformNode.
  15116. */
  15117. addRotation(x: number, y: number, z: number): TransformNode;
  15118. /**
  15119. * @hidden
  15120. */
  15121. protected _getEffectiveParent(): Nullable<Node>;
  15122. /**
  15123. * Computes the world matrix of the node
  15124. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15125. * @returns the world matrix
  15126. */
  15127. computeWorldMatrix(force?: boolean): Matrix;
  15128. /**
  15129. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15130. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15131. */
  15132. resetLocalMatrix(independentOfChildren?: boolean): void;
  15133. protected _afterComputeWorldMatrix(): void;
  15134. /**
  15135. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15136. * @param func callback function to add
  15137. *
  15138. * @returns the TransformNode.
  15139. */
  15140. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15141. /**
  15142. * Removes a registered callback function.
  15143. * @param func callback function to remove
  15144. * @returns the TransformNode.
  15145. */
  15146. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15147. /**
  15148. * Gets the position of the current mesh in camera space
  15149. * @param camera defines the camera to use
  15150. * @returns a position
  15151. */
  15152. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15153. /**
  15154. * Returns the distance from the mesh to the active camera
  15155. * @param camera defines the camera to use
  15156. * @returns the distance
  15157. */
  15158. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15159. /**
  15160. * Clone the current transform node
  15161. * @param name Name of the new clone
  15162. * @param newParent New parent for the clone
  15163. * @param doNotCloneChildren Do not clone children hierarchy
  15164. * @returns the new transform node
  15165. */
  15166. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15167. /**
  15168. * Serializes the objects information.
  15169. * @param currentSerializationObject defines the object to serialize in
  15170. * @returns the serialized object
  15171. */
  15172. serialize(currentSerializationObject?: any): any;
  15173. /**
  15174. * Returns a new TransformNode object parsed from the source provided.
  15175. * @param parsedTransformNode is the source.
  15176. * @param scene the scne the object belongs to
  15177. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15178. * @returns a new TransformNode object parsed from the source provided.
  15179. */
  15180. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15181. /**
  15182. * Get all child-transformNodes of this node
  15183. * @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
  15184. * @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
  15185. * @returns an array of TransformNode
  15186. */
  15187. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15188. /**
  15189. * Releases resources associated with this transform node.
  15190. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15191. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15192. */
  15193. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15194. /**
  15195. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15196. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15197. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15198. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15199. * @returns the current mesh
  15200. */
  15201. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15202. private _syncAbsoluteScalingAndRotation;
  15203. }
  15204. }
  15205. declare module BABYLON {
  15206. /**
  15207. * Class used to override all child animations of a given target
  15208. */
  15209. export class AnimationPropertiesOverride {
  15210. /**
  15211. * Gets or sets a value indicating if animation blending must be used
  15212. */
  15213. enableBlending: boolean;
  15214. /**
  15215. * Gets or sets the blending speed to use when enableBlending is true
  15216. */
  15217. blendingSpeed: number;
  15218. /**
  15219. * Gets or sets the default loop mode to use
  15220. */
  15221. loopMode: number;
  15222. }
  15223. }
  15224. declare module BABYLON {
  15225. /**
  15226. * Class used to store bone information
  15227. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15228. */
  15229. export class Bone extends Node {
  15230. /**
  15231. * defines the bone name
  15232. */
  15233. name: string;
  15234. private static _tmpVecs;
  15235. private static _tmpQuat;
  15236. private static _tmpMats;
  15237. /**
  15238. * Gets the list of child bones
  15239. */
  15240. children: Bone[];
  15241. /** Gets the animations associated with this bone */
  15242. animations: Animation[];
  15243. /**
  15244. * Gets or sets bone length
  15245. */
  15246. length: number;
  15247. /**
  15248. * @hidden Internal only
  15249. * Set this value to map this bone to a different index in the transform matrices
  15250. * Set this value to -1 to exclude the bone from the transform matrices
  15251. */
  15252. _index: Nullable<number>;
  15253. private _skeleton;
  15254. private _localMatrix;
  15255. private _restPose;
  15256. private _bindPose;
  15257. private _baseMatrix;
  15258. private _absoluteTransform;
  15259. private _invertedAbsoluteTransform;
  15260. private _parent;
  15261. private _scalingDeterminant;
  15262. private _worldTransform;
  15263. private _localScaling;
  15264. private _localRotation;
  15265. private _localPosition;
  15266. private _needToDecompose;
  15267. private _needToCompose;
  15268. /** @hidden */
  15269. _linkedTransformNode: Nullable<TransformNode>;
  15270. /** @hidden */
  15271. _waitingTransformNodeId: Nullable<string>;
  15272. /** @hidden */
  15273. get _matrix(): Matrix;
  15274. /** @hidden */
  15275. set _matrix(value: Matrix);
  15276. /**
  15277. * Create a new bone
  15278. * @param name defines the bone name
  15279. * @param skeleton defines the parent skeleton
  15280. * @param parentBone defines the parent (can be null if the bone is the root)
  15281. * @param localMatrix defines the local matrix
  15282. * @param restPose defines the rest pose matrix
  15283. * @param baseMatrix defines the base matrix
  15284. * @param index defines index of the bone in the hiearchy
  15285. */
  15286. constructor(
  15287. /**
  15288. * defines the bone name
  15289. */
  15290. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15291. /**
  15292. * Gets the current object class name.
  15293. * @return the class name
  15294. */
  15295. getClassName(): string;
  15296. /**
  15297. * Gets the parent skeleton
  15298. * @returns a skeleton
  15299. */
  15300. getSkeleton(): Skeleton;
  15301. /**
  15302. * Gets parent bone
  15303. * @returns a bone or null if the bone is the root of the bone hierarchy
  15304. */
  15305. getParent(): Nullable<Bone>;
  15306. /**
  15307. * Returns an array containing the root bones
  15308. * @returns an array containing the root bones
  15309. */
  15310. getChildren(): Array<Bone>;
  15311. /**
  15312. * Gets the node index in matrix array generated for rendering
  15313. * @returns the node index
  15314. */
  15315. getIndex(): number;
  15316. /**
  15317. * Sets the parent bone
  15318. * @param parent defines the parent (can be null if the bone is the root)
  15319. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15320. */
  15321. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15322. /**
  15323. * Gets the local matrix
  15324. * @returns a matrix
  15325. */
  15326. getLocalMatrix(): Matrix;
  15327. /**
  15328. * Gets the base matrix (initial matrix which remains unchanged)
  15329. * @returns a matrix
  15330. */
  15331. getBaseMatrix(): Matrix;
  15332. /**
  15333. * Gets the rest pose matrix
  15334. * @returns a matrix
  15335. */
  15336. getRestPose(): Matrix;
  15337. /**
  15338. * Sets the rest pose matrix
  15339. * @param matrix the local-space rest pose to set for this bone
  15340. */
  15341. setRestPose(matrix: Matrix): void;
  15342. /**
  15343. * Gets the bind pose matrix
  15344. * @returns the bind pose matrix
  15345. */
  15346. getBindPose(): Matrix;
  15347. /**
  15348. * Sets the bind pose matrix
  15349. * @param matrix the local-space bind pose to set for this bone
  15350. */
  15351. setBindPose(matrix: Matrix): void;
  15352. /**
  15353. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15354. */
  15355. getWorldMatrix(): Matrix;
  15356. /**
  15357. * Sets the local matrix to rest pose matrix
  15358. */
  15359. returnToRest(): void;
  15360. /**
  15361. * Gets the inverse of the absolute transform matrix.
  15362. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15363. * @returns a matrix
  15364. */
  15365. getInvertedAbsoluteTransform(): Matrix;
  15366. /**
  15367. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15368. * @returns a matrix
  15369. */
  15370. getAbsoluteTransform(): Matrix;
  15371. /**
  15372. * Links with the given transform node.
  15373. * The local matrix of this bone is copied from the transform node every frame.
  15374. * @param transformNode defines the transform node to link to
  15375. */
  15376. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15377. /**
  15378. * Gets the node used to drive the bone's transformation
  15379. * @returns a transform node or null
  15380. */
  15381. getTransformNode(): Nullable<TransformNode>;
  15382. /** Gets or sets current position (in local space) */
  15383. get position(): Vector3;
  15384. set position(newPosition: Vector3);
  15385. /** Gets or sets current rotation (in local space) */
  15386. get rotation(): Vector3;
  15387. set rotation(newRotation: Vector3);
  15388. /** Gets or sets current rotation quaternion (in local space) */
  15389. get rotationQuaternion(): Quaternion;
  15390. set rotationQuaternion(newRotation: Quaternion);
  15391. /** Gets or sets current scaling (in local space) */
  15392. get scaling(): Vector3;
  15393. set scaling(newScaling: Vector3);
  15394. /**
  15395. * Gets the animation properties override
  15396. */
  15397. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15398. private _decompose;
  15399. private _compose;
  15400. /**
  15401. * Update the base and local matrices
  15402. * @param matrix defines the new base or local matrix
  15403. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15404. * @param updateLocalMatrix defines if the local matrix should be updated
  15405. */
  15406. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15407. /** @hidden */
  15408. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15409. /**
  15410. * Flag the bone as dirty (Forcing it to update everything)
  15411. */
  15412. markAsDirty(): void;
  15413. /** @hidden */
  15414. _markAsDirtyAndCompose(): void;
  15415. private _markAsDirtyAndDecompose;
  15416. /**
  15417. * Translate the bone in local or world space
  15418. * @param vec The amount to translate the bone
  15419. * @param space The space that the translation is in
  15420. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15421. */
  15422. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15423. /**
  15424. * Set the postion of the bone in local or world space
  15425. * @param position The position to set the bone
  15426. * @param space The space that the position is in
  15427. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15428. */
  15429. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15430. /**
  15431. * Set the absolute position of the bone (world space)
  15432. * @param position The position to set the bone
  15433. * @param mesh The mesh that this bone is attached to
  15434. */
  15435. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15436. /**
  15437. * Scale the bone on the x, y and z axes (in local space)
  15438. * @param x The amount to scale the bone on the x axis
  15439. * @param y The amount to scale the bone on the y axis
  15440. * @param z The amount to scale the bone on the z axis
  15441. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15442. */
  15443. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15444. /**
  15445. * Set the bone scaling in local space
  15446. * @param scale defines the scaling vector
  15447. */
  15448. setScale(scale: Vector3): void;
  15449. /**
  15450. * Gets the current scaling in local space
  15451. * @returns the current scaling vector
  15452. */
  15453. getScale(): Vector3;
  15454. /**
  15455. * Gets the current scaling in local space and stores it in a target vector
  15456. * @param result defines the target vector
  15457. */
  15458. getScaleToRef(result: Vector3): void;
  15459. /**
  15460. * Set the yaw, pitch, and roll of the bone in local or world space
  15461. * @param yaw The rotation of the bone on the y axis
  15462. * @param pitch The rotation of the bone on the x axis
  15463. * @param roll The rotation of the bone on the z axis
  15464. * @param space The space that the axes of rotation are in
  15465. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15466. */
  15467. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15468. /**
  15469. * Add a rotation to the bone on an axis in local or world space
  15470. * @param axis The axis to rotate the bone on
  15471. * @param amount The amount to rotate the bone
  15472. * @param space The space that the axis is in
  15473. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15474. */
  15475. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15476. /**
  15477. * Set the rotation of the bone to a particular axis angle in local or world space
  15478. * @param axis The axis to rotate the bone on
  15479. * @param angle The angle that the bone should be rotated to
  15480. * @param space The space that the axis is in
  15481. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15482. */
  15483. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15484. /**
  15485. * Set the euler rotation of the bone in local or world space
  15486. * @param rotation The euler rotation that the bone should be set to
  15487. * @param space The space that the rotation is in
  15488. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15489. */
  15490. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15491. /**
  15492. * Set the quaternion rotation of the bone in local or world space
  15493. * @param quat The quaternion rotation that the bone should be set to
  15494. * @param space The space that the rotation is in
  15495. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15496. */
  15497. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15498. /**
  15499. * Set the rotation matrix of the bone in local or world space
  15500. * @param rotMat The rotation matrix that the bone should be set to
  15501. * @param space The space that the rotation is in
  15502. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15503. */
  15504. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15505. private _rotateWithMatrix;
  15506. private _getNegativeRotationToRef;
  15507. /**
  15508. * Get the position of the bone in local or world space
  15509. * @param space The space that the returned position is in
  15510. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15511. * @returns The position of the bone
  15512. */
  15513. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15514. /**
  15515. * Copy the position of the bone to a vector3 in local or world space
  15516. * @param space The space that the returned position is in
  15517. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15518. * @param result The vector3 to copy the position to
  15519. */
  15520. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15521. /**
  15522. * Get the absolute position of the bone (world space)
  15523. * @param mesh The mesh that this bone is attached to
  15524. * @returns The absolute position of the bone
  15525. */
  15526. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15527. /**
  15528. * Copy the absolute position of the bone (world space) to the result param
  15529. * @param mesh The mesh that this bone is attached to
  15530. * @param result The vector3 to copy the absolute position to
  15531. */
  15532. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15533. /**
  15534. * Compute the absolute transforms of this bone and its children
  15535. */
  15536. computeAbsoluteTransforms(): void;
  15537. /**
  15538. * Get the world direction from an axis that is in the local space of the bone
  15539. * @param localAxis The local direction that is used to compute the world direction
  15540. * @param mesh The mesh that this bone is attached to
  15541. * @returns The world direction
  15542. */
  15543. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15544. /**
  15545. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15546. * @param localAxis The local direction that is used to compute the world direction
  15547. * @param mesh The mesh that this bone is attached to
  15548. * @param result The vector3 that the world direction will be copied to
  15549. */
  15550. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15551. /**
  15552. * Get the euler rotation of the bone in local or world space
  15553. * @param space The space that the rotation should be in
  15554. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15555. * @returns The euler rotation
  15556. */
  15557. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15558. /**
  15559. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15560. * @param space The space that the rotation should be in
  15561. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15562. * @param result The vector3 that the rotation should be copied to
  15563. */
  15564. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15565. /**
  15566. * Get the quaternion rotation of the bone in either local or world space
  15567. * @param space The space that the rotation should be in
  15568. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15569. * @returns The quaternion rotation
  15570. */
  15571. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15572. /**
  15573. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15574. * @param space The space that the rotation should be in
  15575. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15576. * @param result The quaternion that the rotation should be copied to
  15577. */
  15578. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15579. /**
  15580. * Get the rotation matrix of the bone in local or world space
  15581. * @param space The space that the rotation should be in
  15582. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15583. * @returns The rotation matrix
  15584. */
  15585. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15586. /**
  15587. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15588. * @param space The space that the rotation should be in
  15589. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15590. * @param result The quaternion that the rotation should be copied to
  15591. */
  15592. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15593. /**
  15594. * Get the world position of a point that is in the local space of the bone
  15595. * @param position The local position
  15596. * @param mesh The mesh that this bone is attached to
  15597. * @returns The world position
  15598. */
  15599. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15600. /**
  15601. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15602. * @param position The local position
  15603. * @param mesh The mesh that this bone is attached to
  15604. * @param result The vector3 that the world position should be copied to
  15605. */
  15606. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15607. /**
  15608. * Get the local position of a point that is in world space
  15609. * @param position The world position
  15610. * @param mesh The mesh that this bone is attached to
  15611. * @returns The local position
  15612. */
  15613. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15614. /**
  15615. * Get the local position of a point that is in world space and copy it to the result param
  15616. * @param position The world position
  15617. * @param mesh The mesh that this bone is attached to
  15618. * @param result The vector3 that the local position should be copied to
  15619. */
  15620. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15621. /**
  15622. * Set the current local matrix as the restPose for this bone.
  15623. */
  15624. setCurrentPoseAsRest(): void;
  15625. }
  15626. }
  15627. declare module BABYLON {
  15628. /**
  15629. * Defines a runtime animation
  15630. */
  15631. export class RuntimeAnimation {
  15632. private _events;
  15633. /**
  15634. * The current frame of the runtime animation
  15635. */
  15636. private _currentFrame;
  15637. /**
  15638. * The animation used by the runtime animation
  15639. */
  15640. private _animation;
  15641. /**
  15642. * The target of the runtime animation
  15643. */
  15644. private _target;
  15645. /**
  15646. * The initiating animatable
  15647. */
  15648. private _host;
  15649. /**
  15650. * The original value of the runtime animation
  15651. */
  15652. private _originalValue;
  15653. /**
  15654. * The original blend value of the runtime animation
  15655. */
  15656. private _originalBlendValue;
  15657. /**
  15658. * The offsets cache of the runtime animation
  15659. */
  15660. private _offsetsCache;
  15661. /**
  15662. * The high limits cache of the runtime animation
  15663. */
  15664. private _highLimitsCache;
  15665. /**
  15666. * Specifies if the runtime animation has been stopped
  15667. */
  15668. private _stopped;
  15669. /**
  15670. * The blending factor of the runtime animation
  15671. */
  15672. private _blendingFactor;
  15673. /**
  15674. * The BabylonJS scene
  15675. */
  15676. private _scene;
  15677. /**
  15678. * The current value of the runtime animation
  15679. */
  15680. private _currentValue;
  15681. /** @hidden */
  15682. _animationState: _IAnimationState;
  15683. /**
  15684. * The active target of the runtime animation
  15685. */
  15686. private _activeTargets;
  15687. private _currentActiveTarget;
  15688. private _directTarget;
  15689. /**
  15690. * The target path of the runtime animation
  15691. */
  15692. private _targetPath;
  15693. /**
  15694. * The weight of the runtime animation
  15695. */
  15696. private _weight;
  15697. /**
  15698. * The ratio offset of the runtime animation
  15699. */
  15700. private _ratioOffset;
  15701. /**
  15702. * The previous delay of the runtime animation
  15703. */
  15704. private _previousDelay;
  15705. /**
  15706. * The previous ratio of the runtime animation
  15707. */
  15708. private _previousRatio;
  15709. private _enableBlending;
  15710. private _keys;
  15711. private _minFrame;
  15712. private _maxFrame;
  15713. private _minValue;
  15714. private _maxValue;
  15715. private _targetIsArray;
  15716. /**
  15717. * Gets the current frame of the runtime animation
  15718. */
  15719. get currentFrame(): number;
  15720. /**
  15721. * Gets the weight of the runtime animation
  15722. */
  15723. get weight(): number;
  15724. /**
  15725. * Gets the current value of the runtime animation
  15726. */
  15727. get currentValue(): any;
  15728. /**
  15729. * Gets the target path of the runtime animation
  15730. */
  15731. get targetPath(): string;
  15732. /**
  15733. * Gets the actual target of the runtime animation
  15734. */
  15735. get target(): any;
  15736. /**
  15737. * Gets the additive state of the runtime animation
  15738. */
  15739. get isAdditive(): boolean;
  15740. /** @hidden */
  15741. _onLoop: () => void;
  15742. /**
  15743. * Create a new RuntimeAnimation object
  15744. * @param target defines the target of the animation
  15745. * @param animation defines the source animation object
  15746. * @param scene defines the hosting scene
  15747. * @param host defines the initiating Animatable
  15748. */
  15749. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15750. private _preparePath;
  15751. /**
  15752. * Gets the animation from the runtime animation
  15753. */
  15754. get animation(): Animation;
  15755. /**
  15756. * Resets the runtime animation to the beginning
  15757. * @param restoreOriginal defines whether to restore the target property to the original value
  15758. */
  15759. reset(restoreOriginal?: boolean): void;
  15760. /**
  15761. * Specifies if the runtime animation is stopped
  15762. * @returns Boolean specifying if the runtime animation is stopped
  15763. */
  15764. isStopped(): boolean;
  15765. /**
  15766. * Disposes of the runtime animation
  15767. */
  15768. dispose(): void;
  15769. /**
  15770. * Apply the interpolated value to the target
  15771. * @param currentValue defines the value computed by the animation
  15772. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15773. */
  15774. setValue(currentValue: any, weight: number): void;
  15775. private _getOriginalValues;
  15776. private _setValue;
  15777. /**
  15778. * Gets the loop pmode of the runtime animation
  15779. * @returns Loop Mode
  15780. */
  15781. private _getCorrectLoopMode;
  15782. /**
  15783. * Move the current animation to a given frame
  15784. * @param frame defines the frame to move to
  15785. */
  15786. goToFrame(frame: number): void;
  15787. /**
  15788. * @hidden Internal use only
  15789. */
  15790. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15791. /**
  15792. * Execute the current animation
  15793. * @param delay defines the delay to add to the current frame
  15794. * @param from defines the lower bound of the animation range
  15795. * @param to defines the upper bound of the animation range
  15796. * @param loop defines if the current animation must loop
  15797. * @param speedRatio defines the current speed ratio
  15798. * @param weight defines the weight of the animation (default is -1 so no weight)
  15799. * @param onLoop optional callback called when animation loops
  15800. * @returns a boolean indicating if the animation is running
  15801. */
  15802. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15803. }
  15804. }
  15805. declare module BABYLON {
  15806. /**
  15807. * Class used to store an actual running animation
  15808. */
  15809. export class Animatable {
  15810. /** defines the target object */
  15811. target: any;
  15812. /** defines the starting frame number (default is 0) */
  15813. fromFrame: number;
  15814. /** defines the ending frame number (default is 100) */
  15815. toFrame: number;
  15816. /** defines if the animation must loop (default is false) */
  15817. loopAnimation: boolean;
  15818. /** defines a callback to call when animation ends if it is not looping */
  15819. onAnimationEnd?: (() => void) | null | undefined;
  15820. /** defines a callback to call when animation loops */
  15821. onAnimationLoop?: (() => void) | null | undefined;
  15822. /** defines whether the animation should be evaluated additively */
  15823. isAdditive: boolean;
  15824. private _localDelayOffset;
  15825. private _pausedDelay;
  15826. private _runtimeAnimations;
  15827. private _paused;
  15828. private _scene;
  15829. private _speedRatio;
  15830. private _weight;
  15831. private _syncRoot;
  15832. /**
  15833. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15834. * This will only apply for non looping animation (default is true)
  15835. */
  15836. disposeOnEnd: boolean;
  15837. /**
  15838. * Gets a boolean indicating if the animation has started
  15839. */
  15840. animationStarted: boolean;
  15841. /**
  15842. * Observer raised when the animation ends
  15843. */
  15844. onAnimationEndObservable: Observable<Animatable>;
  15845. /**
  15846. * Observer raised when the animation loops
  15847. */
  15848. onAnimationLoopObservable: Observable<Animatable>;
  15849. /**
  15850. * Gets the root Animatable used to synchronize and normalize animations
  15851. */
  15852. get syncRoot(): Nullable<Animatable>;
  15853. /**
  15854. * Gets the current frame of the first RuntimeAnimation
  15855. * Used to synchronize Animatables
  15856. */
  15857. get masterFrame(): number;
  15858. /**
  15859. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15860. */
  15861. get weight(): number;
  15862. set weight(value: number);
  15863. /**
  15864. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15865. */
  15866. get speedRatio(): number;
  15867. set speedRatio(value: number);
  15868. /**
  15869. * Creates a new Animatable
  15870. * @param scene defines the hosting scene
  15871. * @param target defines the target object
  15872. * @param fromFrame defines the starting frame number (default is 0)
  15873. * @param toFrame defines the ending frame number (default is 100)
  15874. * @param loopAnimation defines if the animation must loop (default is false)
  15875. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15876. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15877. * @param animations defines a group of animation to add to the new Animatable
  15878. * @param onAnimationLoop defines a callback to call when animation loops
  15879. * @param isAdditive defines whether the animation should be evaluated additively
  15880. */
  15881. constructor(scene: Scene,
  15882. /** defines the target object */
  15883. target: any,
  15884. /** defines the starting frame number (default is 0) */
  15885. fromFrame?: number,
  15886. /** defines the ending frame number (default is 100) */
  15887. toFrame?: number,
  15888. /** defines if the animation must loop (default is false) */
  15889. loopAnimation?: boolean, speedRatio?: number,
  15890. /** defines a callback to call when animation ends if it is not looping */
  15891. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15892. /** defines a callback to call when animation loops */
  15893. onAnimationLoop?: (() => void) | null | undefined,
  15894. /** defines whether the animation should be evaluated additively */
  15895. isAdditive?: boolean);
  15896. /**
  15897. * Synchronize and normalize current Animatable with a source Animatable
  15898. * This is useful when using animation weights and when animations are not of the same length
  15899. * @param root defines the root Animatable to synchronize with
  15900. * @returns the current Animatable
  15901. */
  15902. syncWith(root: Animatable): Animatable;
  15903. /**
  15904. * Gets the list of runtime animations
  15905. * @returns an array of RuntimeAnimation
  15906. */
  15907. getAnimations(): RuntimeAnimation[];
  15908. /**
  15909. * Adds more animations to the current animatable
  15910. * @param target defines the target of the animations
  15911. * @param animations defines the new animations to add
  15912. */
  15913. appendAnimations(target: any, animations: Animation[]): void;
  15914. /**
  15915. * Gets the source animation for a specific property
  15916. * @param property defines the propertyu to look for
  15917. * @returns null or the source animation for the given property
  15918. */
  15919. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15920. /**
  15921. * Gets the runtime animation for a specific property
  15922. * @param property defines the propertyu to look for
  15923. * @returns null or the runtime animation for the given property
  15924. */
  15925. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15926. /**
  15927. * Resets the animatable to its original state
  15928. */
  15929. reset(): void;
  15930. /**
  15931. * Allows the animatable to blend with current running animations
  15932. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15933. * @param blendingSpeed defines the blending speed to use
  15934. */
  15935. enableBlending(blendingSpeed: number): void;
  15936. /**
  15937. * Disable animation blending
  15938. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15939. */
  15940. disableBlending(): void;
  15941. /**
  15942. * Jump directly to a given frame
  15943. * @param frame defines the frame to jump to
  15944. */
  15945. goToFrame(frame: number): void;
  15946. /**
  15947. * Pause the animation
  15948. */
  15949. pause(): void;
  15950. /**
  15951. * Restart the animation
  15952. */
  15953. restart(): void;
  15954. private _raiseOnAnimationEnd;
  15955. /**
  15956. * Stop and delete the current animation
  15957. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15958. * @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)
  15959. */
  15960. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15961. /**
  15962. * Wait asynchronously for the animation to end
  15963. * @returns a promise which will be fullfilled when the animation ends
  15964. */
  15965. waitAsync(): Promise<Animatable>;
  15966. /** @hidden */
  15967. _animate(delay: number): boolean;
  15968. }
  15969. interface Scene {
  15970. /** @hidden */
  15971. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15972. /** @hidden */
  15973. _processLateAnimationBindingsForMatrices(holder: {
  15974. totalWeight: number;
  15975. totalAdditiveWeight: number;
  15976. animations: RuntimeAnimation[];
  15977. additiveAnimations: RuntimeAnimation[];
  15978. originalValue: Matrix;
  15979. }): any;
  15980. /** @hidden */
  15981. _processLateAnimationBindingsForQuaternions(holder: {
  15982. totalWeight: number;
  15983. totalAdditiveWeight: number;
  15984. animations: RuntimeAnimation[];
  15985. additiveAnimations: RuntimeAnimation[];
  15986. originalValue: Quaternion;
  15987. }, refQuaternion: Quaternion): Quaternion;
  15988. /** @hidden */
  15989. _processLateAnimationBindings(): void;
  15990. /**
  15991. * Will start the animation sequence of a given target
  15992. * @param target defines the target
  15993. * @param from defines from which frame should animation start
  15994. * @param to defines until which frame should animation run.
  15995. * @param weight defines the weight to apply to the animation (1.0 by default)
  15996. * @param loop defines if the animation loops
  15997. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15998. * @param onAnimationEnd defines the function to be executed when the animation ends
  15999. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16000. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16001. * @param onAnimationLoop defines the callback to call when an animation loops
  16002. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16003. * @returns the animatable object created for this animation
  16004. */
  16005. 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;
  16006. /**
  16007. * Will start the animation sequence of a given target
  16008. * @param target defines the target
  16009. * @param from defines from which frame should animation start
  16010. * @param to defines until which frame should animation run.
  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 stopCurrent defines if the current animations must be stopped first (true by default)
  16016. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16017. * @param onAnimationLoop defines the callback to call when an animation loops
  16018. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16019. * @returns the animatable object created for this animation
  16020. */
  16021. 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;
  16022. /**
  16023. * Will start the animation sequence of a given target and its hierarchy
  16024. * @param target defines the target
  16025. * @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.
  16026. * @param from defines from which frame should animation start
  16027. * @param to defines until which frame should animation run.
  16028. * @param loop defines if the animation loops
  16029. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16030. * @param onAnimationEnd defines the function to be executed when the animation ends
  16031. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16032. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16033. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16034. * @param onAnimationLoop defines the callback to call when an animation loops
  16035. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16036. * @returns the list of created animatables
  16037. */
  16038. 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[];
  16039. /**
  16040. * Begin a new animation on a given node
  16041. * @param target defines the target where the animation will take place
  16042. * @param animations defines the list of animations to start
  16043. * @param from defines the initial value
  16044. * @param to defines the final value
  16045. * @param loop defines if you want animation to loop (off by default)
  16046. * @param speedRatio defines the speed ratio to apply to all animations
  16047. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16048. * @param onAnimationLoop defines the callback to call when an animation loops
  16049. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16050. * @returns the list of created animatables
  16051. */
  16052. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16053. /**
  16054. * Begin a new animation on a given node and its hierarchy
  16055. * @param target defines the root node where the animation will take place
  16056. * @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.
  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 animatables created for all nodes
  16066. */
  16067. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16068. /**
  16069. * Gets the animatable associated with a specific target
  16070. * @param target defines the target of the animatable
  16071. * @returns the required animatable if found
  16072. */
  16073. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16074. /**
  16075. * Gets all animatables associated with a given target
  16076. * @param target defines the target to look animatables for
  16077. * @returns an array of Animatables
  16078. */
  16079. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16080. /**
  16081. * Stops and removes all animations that have been applied to the scene
  16082. */
  16083. stopAllAnimations(): void;
  16084. /**
  16085. * Gets the current delta time used by animation engine
  16086. */
  16087. deltaTime: number;
  16088. }
  16089. interface Bone {
  16090. /**
  16091. * Copy an animation range from another bone
  16092. * @param source defines the source bone
  16093. * @param rangeName defines the range name to copy
  16094. * @param frameOffset defines the frame offset
  16095. * @param rescaleAsRequired defines if rescaling must be applied if required
  16096. * @param skelDimensionsRatio defines the scaling ratio
  16097. * @returns true if operation was successful
  16098. */
  16099. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16100. }
  16101. }
  16102. declare module BABYLON {
  16103. /**
  16104. * Class used to handle skinning animations
  16105. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16106. */
  16107. export class Skeleton implements IAnimatable {
  16108. /** defines the skeleton name */
  16109. name: string;
  16110. /** defines the skeleton Id */
  16111. id: string;
  16112. /**
  16113. * Defines the list of child bones
  16114. */
  16115. bones: Bone[];
  16116. /**
  16117. * Defines an estimate of the dimension of the skeleton at rest
  16118. */
  16119. dimensionsAtRest: Vector3;
  16120. /**
  16121. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16122. */
  16123. needInitialSkinMatrix: boolean;
  16124. /**
  16125. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16126. */
  16127. overrideMesh: Nullable<AbstractMesh>;
  16128. /**
  16129. * Gets the list of animations attached to this skeleton
  16130. */
  16131. animations: Array<Animation>;
  16132. private _scene;
  16133. private _isDirty;
  16134. private _transformMatrices;
  16135. private _transformMatrixTexture;
  16136. private _meshesWithPoseMatrix;
  16137. private _animatables;
  16138. private _identity;
  16139. private _synchronizedWithMesh;
  16140. private _ranges;
  16141. private _lastAbsoluteTransformsUpdateId;
  16142. private _canUseTextureForBones;
  16143. private _uniqueId;
  16144. /** @hidden */
  16145. _numBonesWithLinkedTransformNode: number;
  16146. /** @hidden */
  16147. _hasWaitingData: Nullable<boolean>;
  16148. /** @hidden */
  16149. _waitingOverrideMeshId: Nullable<string>;
  16150. /**
  16151. * Specifies if the skeleton should be serialized
  16152. */
  16153. doNotSerialize: boolean;
  16154. private _useTextureToStoreBoneMatrices;
  16155. /**
  16156. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16157. * Please note that this option is not available if the hardware does not support it
  16158. */
  16159. get useTextureToStoreBoneMatrices(): boolean;
  16160. set useTextureToStoreBoneMatrices(value: boolean);
  16161. private _animationPropertiesOverride;
  16162. /**
  16163. * Gets or sets the animation properties override
  16164. */
  16165. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16166. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16167. /**
  16168. * List of inspectable custom properties (used by the Inspector)
  16169. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16170. */
  16171. inspectableCustomProperties: IInspectable[];
  16172. /**
  16173. * An observable triggered before computing the skeleton's matrices
  16174. */
  16175. onBeforeComputeObservable: Observable<Skeleton>;
  16176. /**
  16177. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16178. */
  16179. get isUsingTextureForMatrices(): boolean;
  16180. /**
  16181. * Gets the unique ID of this skeleton
  16182. */
  16183. get uniqueId(): number;
  16184. /**
  16185. * Creates a new skeleton
  16186. * @param name defines the skeleton name
  16187. * @param id defines the skeleton Id
  16188. * @param scene defines the hosting scene
  16189. */
  16190. constructor(
  16191. /** defines the skeleton name */
  16192. name: string,
  16193. /** defines the skeleton Id */
  16194. id: string, scene: Scene);
  16195. /**
  16196. * Gets the current object class name.
  16197. * @return the class name
  16198. */
  16199. getClassName(): string;
  16200. /**
  16201. * Returns an array containing the root bones
  16202. * @returns an array containing the root bones
  16203. */
  16204. getChildren(): Array<Bone>;
  16205. /**
  16206. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16207. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16208. * @returns a Float32Array containing matrices data
  16209. */
  16210. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16211. /**
  16212. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16213. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16214. * @returns a raw texture containing the data
  16215. */
  16216. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16217. /**
  16218. * Gets the current hosting scene
  16219. * @returns a scene object
  16220. */
  16221. getScene(): Scene;
  16222. /**
  16223. * Gets a string representing the current skeleton data
  16224. * @param fullDetails defines a boolean indicating if we want a verbose version
  16225. * @returns a string representing the current skeleton data
  16226. */
  16227. toString(fullDetails?: boolean): string;
  16228. /**
  16229. * Get bone's index searching by name
  16230. * @param name defines bone's name to search for
  16231. * @return the indice of the bone. Returns -1 if not found
  16232. */
  16233. getBoneIndexByName(name: string): number;
  16234. /**
  16235. * Creater a new animation range
  16236. * @param name defines the name of the range
  16237. * @param from defines the start key
  16238. * @param to defines the end key
  16239. */
  16240. createAnimationRange(name: string, from: number, to: number): void;
  16241. /**
  16242. * Delete a specific animation range
  16243. * @param name defines the name of the range
  16244. * @param deleteFrames defines if frames must be removed as well
  16245. */
  16246. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16247. /**
  16248. * Gets a specific animation range
  16249. * @param name defines the name of the range to look for
  16250. * @returns the requested animation range or null if not found
  16251. */
  16252. getAnimationRange(name: string): Nullable<AnimationRange>;
  16253. /**
  16254. * Gets the list of all animation ranges defined on this skeleton
  16255. * @returns an array
  16256. */
  16257. getAnimationRanges(): Nullable<AnimationRange>[];
  16258. /**
  16259. * Copy animation range from a source skeleton.
  16260. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16261. * @param source defines the source skeleton
  16262. * @param name defines the name of the range to copy
  16263. * @param rescaleAsRequired defines if rescaling must be applied if required
  16264. * @returns true if operation was successful
  16265. */
  16266. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16267. /**
  16268. * Forces the skeleton to go to rest pose
  16269. */
  16270. returnToRest(): void;
  16271. private _getHighestAnimationFrame;
  16272. /**
  16273. * Begin a specific animation range
  16274. * @param name defines the name of the range to start
  16275. * @param loop defines if looping must be turned on (false by default)
  16276. * @param speedRatio defines the speed ratio to apply (1 by default)
  16277. * @param onAnimationEnd defines a callback which will be called when animation will end
  16278. * @returns a new animatable
  16279. */
  16280. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16281. /**
  16282. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16283. * @param skeleton defines the Skeleton containing the animation range to convert
  16284. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16285. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16286. * @returns the original skeleton
  16287. */
  16288. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16289. /** @hidden */
  16290. _markAsDirty(): void;
  16291. /** @hidden */
  16292. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16293. /** @hidden */
  16294. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16295. private _computeTransformMatrices;
  16296. /**
  16297. * Build all resources required to render a skeleton
  16298. */
  16299. prepare(): void;
  16300. /**
  16301. * Gets the list of animatables currently running for this skeleton
  16302. * @returns an array of animatables
  16303. */
  16304. getAnimatables(): IAnimatable[];
  16305. /**
  16306. * Clone the current skeleton
  16307. * @param name defines the name of the new skeleton
  16308. * @param id defines the id of the new skeleton
  16309. * @returns the new skeleton
  16310. */
  16311. clone(name: string, id?: string): Skeleton;
  16312. /**
  16313. * Enable animation blending for this skeleton
  16314. * @param blendingSpeed defines the blending speed to apply
  16315. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16316. */
  16317. enableBlending(blendingSpeed?: number): void;
  16318. /**
  16319. * Releases all resources associated with the current skeleton
  16320. */
  16321. dispose(): void;
  16322. /**
  16323. * Serialize the skeleton in a JSON object
  16324. * @returns a JSON object
  16325. */
  16326. serialize(): any;
  16327. /**
  16328. * Creates a new skeleton from serialized data
  16329. * @param parsedSkeleton defines the serialized data
  16330. * @param scene defines the hosting scene
  16331. * @returns a new skeleton
  16332. */
  16333. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16334. /**
  16335. * Compute all node absolute transforms
  16336. * @param forceUpdate defines if computation must be done even if cache is up to date
  16337. */
  16338. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16339. /**
  16340. * Gets the root pose matrix
  16341. * @returns a matrix
  16342. */
  16343. getPoseMatrix(): Nullable<Matrix>;
  16344. /**
  16345. * Sorts bones per internal index
  16346. */
  16347. sortBones(): void;
  16348. private _sortBones;
  16349. /**
  16350. * Set the current local matrix as the restPose for all bones in the skeleton.
  16351. */
  16352. setCurrentPoseAsRest(): void;
  16353. }
  16354. }
  16355. declare module BABYLON {
  16356. /**
  16357. * Creates an instance based on a source mesh.
  16358. */
  16359. export class InstancedMesh extends AbstractMesh {
  16360. private _sourceMesh;
  16361. private _currentLOD;
  16362. /** @hidden */
  16363. _indexInSourceMeshInstanceArray: number;
  16364. constructor(name: string, source: Mesh);
  16365. /**
  16366. * Returns the string "InstancedMesh".
  16367. */
  16368. getClassName(): string;
  16369. /** Gets the list of lights affecting that mesh */
  16370. get lightSources(): Light[];
  16371. _resyncLightSources(): void;
  16372. _resyncLightSource(light: Light): void;
  16373. _removeLightSource(light: Light, dispose: boolean): void;
  16374. /**
  16375. * If the source mesh receives shadows
  16376. */
  16377. get receiveShadows(): boolean;
  16378. /**
  16379. * The material of the source mesh
  16380. */
  16381. get material(): Nullable<Material>;
  16382. /**
  16383. * Visibility of the source mesh
  16384. */
  16385. get visibility(): number;
  16386. /**
  16387. * Skeleton of the source mesh
  16388. */
  16389. get skeleton(): Nullable<Skeleton>;
  16390. /**
  16391. * Rendering ground id of the source mesh
  16392. */
  16393. get renderingGroupId(): number;
  16394. set renderingGroupId(value: number);
  16395. /**
  16396. * Returns the total number of vertices (integer).
  16397. */
  16398. getTotalVertices(): number;
  16399. /**
  16400. * Returns a positive integer : the total number of indices in this mesh geometry.
  16401. * @returns the numner of indices or zero if the mesh has no geometry.
  16402. */
  16403. getTotalIndices(): number;
  16404. /**
  16405. * The source mesh of the instance
  16406. */
  16407. get sourceMesh(): Mesh;
  16408. /**
  16409. * Creates a new InstancedMesh object from the mesh model.
  16410. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16411. * @param name defines the name of the new instance
  16412. * @returns a new InstancedMesh
  16413. */
  16414. createInstance(name: string): InstancedMesh;
  16415. /**
  16416. * Is this node ready to be used/rendered
  16417. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16418. * @return {boolean} is it ready
  16419. */
  16420. isReady(completeCheck?: boolean): boolean;
  16421. /**
  16422. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16423. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16424. * @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.
  16425. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16426. */
  16427. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16428. /**
  16429. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16430. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16431. * The `data` are either a numeric array either a Float32Array.
  16432. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16433. * 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).
  16434. * Note that a new underlying VertexBuffer object is created each call.
  16435. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16436. *
  16437. * Possible `kind` values :
  16438. * - VertexBuffer.PositionKind
  16439. * - VertexBuffer.UVKind
  16440. * - VertexBuffer.UV2Kind
  16441. * - VertexBuffer.UV3Kind
  16442. * - VertexBuffer.UV4Kind
  16443. * - VertexBuffer.UV5Kind
  16444. * - VertexBuffer.UV6Kind
  16445. * - VertexBuffer.ColorKind
  16446. * - VertexBuffer.MatricesIndicesKind
  16447. * - VertexBuffer.MatricesIndicesExtraKind
  16448. * - VertexBuffer.MatricesWeightsKind
  16449. * - VertexBuffer.MatricesWeightsExtraKind
  16450. *
  16451. * Returns the Mesh.
  16452. */
  16453. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16454. /**
  16455. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16456. * If the mesh has no geometry, it is simply returned as it is.
  16457. * The `data` are either a numeric array either a Float32Array.
  16458. * No new underlying VertexBuffer object is created.
  16459. * 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.
  16460. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16461. *
  16462. * Possible `kind` values :
  16463. * - VertexBuffer.PositionKind
  16464. * - VertexBuffer.UVKind
  16465. * - VertexBuffer.UV2Kind
  16466. * - VertexBuffer.UV3Kind
  16467. * - VertexBuffer.UV4Kind
  16468. * - VertexBuffer.UV5Kind
  16469. * - VertexBuffer.UV6Kind
  16470. * - VertexBuffer.ColorKind
  16471. * - VertexBuffer.MatricesIndicesKind
  16472. * - VertexBuffer.MatricesIndicesExtraKind
  16473. * - VertexBuffer.MatricesWeightsKind
  16474. * - VertexBuffer.MatricesWeightsExtraKind
  16475. *
  16476. * Returns the Mesh.
  16477. */
  16478. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16479. /**
  16480. * Sets the mesh indices.
  16481. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16482. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16483. * This method creates a new index buffer each call.
  16484. * Returns the Mesh.
  16485. */
  16486. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16487. /**
  16488. * Boolean : True if the mesh owns the requested kind of data.
  16489. */
  16490. isVerticesDataPresent(kind: string): boolean;
  16491. /**
  16492. * Returns an array of indices (IndicesArray).
  16493. */
  16494. getIndices(): Nullable<IndicesArray>;
  16495. get _positions(): Nullable<Vector3[]>;
  16496. /**
  16497. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16498. * This means the mesh underlying bounding box and sphere are recomputed.
  16499. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16500. * @returns the current mesh
  16501. */
  16502. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16503. /** @hidden */
  16504. _preActivate(): InstancedMesh;
  16505. /** @hidden */
  16506. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16507. /** @hidden */
  16508. _postActivate(): void;
  16509. getWorldMatrix(): Matrix;
  16510. get isAnInstance(): boolean;
  16511. /**
  16512. * Returns the current associated LOD AbstractMesh.
  16513. */
  16514. getLOD(camera: Camera): AbstractMesh;
  16515. /** @hidden */
  16516. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16517. /** @hidden */
  16518. _syncSubMeshes(): InstancedMesh;
  16519. /** @hidden */
  16520. _generatePointsArray(): boolean;
  16521. /** @hidden */
  16522. _updateBoundingInfo(): AbstractMesh;
  16523. /**
  16524. * Creates a new InstancedMesh from the current mesh.
  16525. * - name (string) : the cloned mesh name
  16526. * - newParent (optional Node) : the optional Node to parent the clone to.
  16527. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16528. *
  16529. * Returns the clone.
  16530. */
  16531. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16532. /**
  16533. * Disposes the InstancedMesh.
  16534. * Returns nothing.
  16535. */
  16536. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16537. }
  16538. interface Mesh {
  16539. /**
  16540. * Register a custom buffer that will be instanced
  16541. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16542. * @param kind defines the buffer kind
  16543. * @param stride defines the stride in floats
  16544. */
  16545. registerInstancedBuffer(kind: string, stride: number): void;
  16546. /**
  16547. * true to use the edge renderer for all instances of this mesh
  16548. */
  16549. edgesShareWithInstances: boolean;
  16550. /** @hidden */
  16551. _userInstancedBuffersStorage: {
  16552. data: {
  16553. [key: string]: Float32Array;
  16554. };
  16555. sizes: {
  16556. [key: string]: number;
  16557. };
  16558. vertexBuffers: {
  16559. [key: string]: Nullable<VertexBuffer>;
  16560. };
  16561. strides: {
  16562. [key: string]: number;
  16563. };
  16564. };
  16565. }
  16566. interface AbstractMesh {
  16567. /**
  16568. * Object used to store instanced buffers defined by user
  16569. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16570. */
  16571. instancedBuffers: {
  16572. [key: string]: any;
  16573. };
  16574. }
  16575. }
  16576. declare module BABYLON {
  16577. /**
  16578. * Defines the options associated with the creation of a shader material.
  16579. */
  16580. export interface IShaderMaterialOptions {
  16581. /**
  16582. * Does the material work in alpha blend mode
  16583. */
  16584. needAlphaBlending: boolean;
  16585. /**
  16586. * Does the material work in alpha test mode
  16587. */
  16588. needAlphaTesting: boolean;
  16589. /**
  16590. * The list of attribute names used in the shader
  16591. */
  16592. attributes: string[];
  16593. /**
  16594. * The list of unifrom names used in the shader
  16595. */
  16596. uniforms: string[];
  16597. /**
  16598. * The list of UBO names used in the shader
  16599. */
  16600. uniformBuffers: string[];
  16601. /**
  16602. * The list of sampler names used in the shader
  16603. */
  16604. samplers: string[];
  16605. /**
  16606. * The list of defines used in the shader
  16607. */
  16608. defines: string[];
  16609. }
  16610. /**
  16611. * 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.
  16612. *
  16613. * This returned material effects how the mesh will look based on the code in the shaders.
  16614. *
  16615. * @see https://doc.babylonjs.com/how_to/shader_material
  16616. */
  16617. export class ShaderMaterial extends Material {
  16618. private _shaderPath;
  16619. private _options;
  16620. private _textures;
  16621. private _textureArrays;
  16622. private _floats;
  16623. private _ints;
  16624. private _floatsArrays;
  16625. private _colors3;
  16626. private _colors3Arrays;
  16627. private _colors4;
  16628. private _colors4Arrays;
  16629. private _vectors2;
  16630. private _vectors3;
  16631. private _vectors4;
  16632. private _matrices;
  16633. private _matrixArrays;
  16634. private _matrices3x3;
  16635. private _matrices2x2;
  16636. private _vectors2Arrays;
  16637. private _vectors3Arrays;
  16638. private _vectors4Arrays;
  16639. private _cachedWorldViewMatrix;
  16640. private _cachedWorldViewProjectionMatrix;
  16641. private _renderId;
  16642. private _multiview;
  16643. private _cachedDefines;
  16644. /** Define the Url to load snippets */
  16645. static SnippetUrl: string;
  16646. /** Snippet ID if the material was created from the snippet server */
  16647. snippetId: string;
  16648. /**
  16649. * Instantiate a new shader material.
  16650. * 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.
  16651. * This returned material effects how the mesh will look based on the code in the shaders.
  16652. * @see https://doc.babylonjs.com/how_to/shader_material
  16653. * @param name Define the name of the material in the scene
  16654. * @param scene Define the scene the material belongs to
  16655. * @param shaderPath Defines the route to the shader code in one of three ways:
  16656. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16657. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16658. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16659. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16660. * @param options Define the options used to create the shader
  16661. */
  16662. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16663. /**
  16664. * Gets the shader path used to define the shader code
  16665. * It can be modified to trigger a new compilation
  16666. */
  16667. get shaderPath(): any;
  16668. /**
  16669. * Sets the shader path used to define the shader code
  16670. * It can be modified to trigger a new compilation
  16671. */
  16672. set shaderPath(shaderPath: any);
  16673. /**
  16674. * Gets the options used to compile the shader.
  16675. * They can be modified to trigger a new compilation
  16676. */
  16677. get options(): IShaderMaterialOptions;
  16678. /**
  16679. * Gets the current class name of the material e.g. "ShaderMaterial"
  16680. * Mainly use in serialization.
  16681. * @returns the class name
  16682. */
  16683. getClassName(): string;
  16684. /**
  16685. * Specifies if the material will require alpha blending
  16686. * @returns a boolean specifying if alpha blending is needed
  16687. */
  16688. needAlphaBlending(): boolean;
  16689. /**
  16690. * Specifies if this material should be rendered in alpha test mode
  16691. * @returns a boolean specifying if an alpha test is needed.
  16692. */
  16693. needAlphaTesting(): boolean;
  16694. private _checkUniform;
  16695. /**
  16696. * Set a texture in the shader.
  16697. * @param name Define the name of the uniform samplers as defined in the shader
  16698. * @param texture Define the texture to bind to this sampler
  16699. * @return the material itself allowing "fluent" like uniform updates
  16700. */
  16701. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16702. /**
  16703. * Set a texture array in the shader.
  16704. * @param name Define the name of the uniform sampler array as defined in the shader
  16705. * @param textures Define the list of textures to bind to this sampler
  16706. * @return the material itself allowing "fluent" like uniform updates
  16707. */
  16708. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16709. /**
  16710. * Set a float in the shader.
  16711. * @param name Define the name of the uniform as defined in the shader
  16712. * @param value Define the value to give to the uniform
  16713. * @return the material itself allowing "fluent" like uniform updates
  16714. */
  16715. setFloat(name: string, value: number): ShaderMaterial;
  16716. /**
  16717. * Set a int in the shader.
  16718. * @param name Define the name of the uniform as defined in the shader
  16719. * @param value Define the value to give to the uniform
  16720. * @return the material itself allowing "fluent" like uniform updates
  16721. */
  16722. setInt(name: string, value: number): ShaderMaterial;
  16723. /**
  16724. * Set an array of floats in the shader.
  16725. * @param name Define the name of the uniform as defined in the shader
  16726. * @param value Define the value to give to the uniform
  16727. * @return the material itself allowing "fluent" like uniform updates
  16728. */
  16729. setFloats(name: string, value: number[]): ShaderMaterial;
  16730. /**
  16731. * Set a vec3 in the shader from a Color3.
  16732. * @param name Define the name of the uniform as defined in the shader
  16733. * @param value Define the value to give to the uniform
  16734. * @return the material itself allowing "fluent" like uniform updates
  16735. */
  16736. setColor3(name: string, value: Color3): ShaderMaterial;
  16737. /**
  16738. * Set a vec3 array in the shader from a Color3 array.
  16739. * @param name Define the name of the uniform as defined in the shader
  16740. * @param value Define the value to give to the uniform
  16741. * @return the material itself allowing "fluent" like uniform updates
  16742. */
  16743. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16744. /**
  16745. * Set a vec4 in the shader from a Color4.
  16746. * @param name Define the name of the uniform as defined in the shader
  16747. * @param value Define the value to give to the uniform
  16748. * @return the material itself allowing "fluent" like uniform updates
  16749. */
  16750. setColor4(name: string, value: Color4): ShaderMaterial;
  16751. /**
  16752. * Set a vec4 array in the shader from a Color4 array.
  16753. * @param name Define the name of the uniform as defined in the shader
  16754. * @param value Define the value to give to the uniform
  16755. * @return the material itself allowing "fluent" like uniform updates
  16756. */
  16757. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16758. /**
  16759. * Set a vec2 in the shader from a Vector2.
  16760. * @param name Define the name of the uniform as defined in the shader
  16761. * @param value Define the value to give to the uniform
  16762. * @return the material itself allowing "fluent" like uniform updates
  16763. */
  16764. setVector2(name: string, value: Vector2): ShaderMaterial;
  16765. /**
  16766. * Set a vec3 in the shader from a Vector3.
  16767. * @param name Define the name of the uniform as defined in the shader
  16768. * @param value Define the value to give to the uniform
  16769. * @return the material itself allowing "fluent" like uniform updates
  16770. */
  16771. setVector3(name: string, value: Vector3): ShaderMaterial;
  16772. /**
  16773. * Set a vec4 in the shader from a Vector4.
  16774. * @param name Define the name of the uniform as defined in the shader
  16775. * @param value Define the value to give to the uniform
  16776. * @return the material itself allowing "fluent" like uniform updates
  16777. */
  16778. setVector4(name: string, value: Vector4): ShaderMaterial;
  16779. /**
  16780. * Set a mat4 in the shader from a Matrix.
  16781. * @param name Define the name of the uniform as defined in the shader
  16782. * @param value Define the value to give to the uniform
  16783. * @return the material itself allowing "fluent" like uniform updates
  16784. */
  16785. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16786. /**
  16787. * Set a float32Array in the shader from a matrix array.
  16788. * @param name Define the name of the uniform as defined in the shader
  16789. * @param value Define the value to give to the uniform
  16790. * @return the material itself allowing "fluent" like uniform updates
  16791. */
  16792. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16793. /**
  16794. * Set a mat3 in the shader from a Float32Array.
  16795. * @param name Define the name of the uniform as defined in the shader
  16796. * @param value Define the value to give to the uniform
  16797. * @return the material itself allowing "fluent" like uniform updates
  16798. */
  16799. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16800. /**
  16801. * Set a mat2 in the shader from a Float32Array.
  16802. * @param name Define the name of the uniform as defined in the shader
  16803. * @param value Define the value to give to the uniform
  16804. * @return the material itself allowing "fluent" like uniform updates
  16805. */
  16806. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16807. /**
  16808. * Set a vec2 array in the shader from a number array.
  16809. * @param name Define the name of the uniform as defined in the shader
  16810. * @param value Define the value to give to the uniform
  16811. * @return the material itself allowing "fluent" like uniform updates
  16812. */
  16813. setArray2(name: string, value: number[]): ShaderMaterial;
  16814. /**
  16815. * Set a vec3 array in the shader from a number array.
  16816. * @param name Define the name of the uniform as defined in the shader
  16817. * @param value Define the value to give to the uniform
  16818. * @return the material itself allowing "fluent" like uniform updates
  16819. */
  16820. setArray3(name: string, value: number[]): ShaderMaterial;
  16821. /**
  16822. * Set a vec4 array in the shader from a number array.
  16823. * @param name Define the name of the uniform as defined in the shader
  16824. * @param value Define the value to give to the uniform
  16825. * @return the material itself allowing "fluent" like uniform updates
  16826. */
  16827. setArray4(name: string, value: number[]): ShaderMaterial;
  16828. private _checkCache;
  16829. /**
  16830. * Specifies that the submesh is ready to be used
  16831. * @param mesh defines the mesh to check
  16832. * @param subMesh defines which submesh to check
  16833. * @param useInstances specifies that instances should be used
  16834. * @returns a boolean indicating that the submesh is ready or not
  16835. */
  16836. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16837. /**
  16838. * Checks if the material is ready to render the requested mesh
  16839. * @param mesh Define the mesh to render
  16840. * @param useInstances Define whether or not the material is used with instances
  16841. * @returns true if ready, otherwise false
  16842. */
  16843. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16844. /**
  16845. * Binds the world matrix to the material
  16846. * @param world defines the world transformation matrix
  16847. * @param effectOverride - If provided, use this effect instead of internal effect
  16848. */
  16849. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16850. /**
  16851. * Binds the submesh to this material by preparing the effect and shader to draw
  16852. * @param world defines the world transformation matrix
  16853. * @param mesh defines the mesh containing the submesh
  16854. * @param subMesh defines the submesh to bind the material to
  16855. */
  16856. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16857. /**
  16858. * Binds the material to the mesh
  16859. * @param world defines the world transformation matrix
  16860. * @param mesh defines the mesh to bind the material to
  16861. * @param effectOverride - If provided, use this effect instead of internal effect
  16862. */
  16863. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16864. protected _afterBind(mesh?: Mesh): void;
  16865. /**
  16866. * Gets the active textures from the material
  16867. * @returns an array of textures
  16868. */
  16869. getActiveTextures(): BaseTexture[];
  16870. /**
  16871. * Specifies if the material uses a texture
  16872. * @param texture defines the texture to check against the material
  16873. * @returns a boolean specifying if the material uses the texture
  16874. */
  16875. hasTexture(texture: BaseTexture): boolean;
  16876. /**
  16877. * Makes a duplicate of the material, and gives it a new name
  16878. * @param name defines the new name for the duplicated material
  16879. * @returns the cloned material
  16880. */
  16881. clone(name: string): ShaderMaterial;
  16882. /**
  16883. * Disposes the material
  16884. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16885. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16886. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16887. */
  16888. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16889. /**
  16890. * Serializes this material in a JSON representation
  16891. * @returns the serialized material object
  16892. */
  16893. serialize(): any;
  16894. /**
  16895. * Creates a shader material from parsed shader material data
  16896. * @param source defines the JSON represnetation of the material
  16897. * @param scene defines the hosting scene
  16898. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16899. * @returns a new material
  16900. */
  16901. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16902. /**
  16903. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16904. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16905. * @param url defines the url to load from
  16906. * @param scene defines the hosting scene
  16907. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16908. * @returns a promise that will resolve to the new ShaderMaterial
  16909. */
  16910. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16911. /**
  16912. * Creates a ShaderMaterial from a snippet saved by the Inspector
  16913. * @param snippetId defines the snippet to load
  16914. * @param scene defines the hosting scene
  16915. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16916. * @returns a promise that will resolve to the new ShaderMaterial
  16917. */
  16918. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16919. }
  16920. }
  16921. declare module BABYLON {
  16922. /** @hidden */
  16923. export var colorPixelShader: {
  16924. name: string;
  16925. shader: string;
  16926. };
  16927. }
  16928. declare module BABYLON {
  16929. /** @hidden */
  16930. export var colorVertexShader: {
  16931. name: string;
  16932. shader: string;
  16933. };
  16934. }
  16935. declare module BABYLON {
  16936. /**
  16937. * Line mesh
  16938. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16939. */
  16940. export class LinesMesh extends Mesh {
  16941. /**
  16942. * If vertex color should be applied to the mesh
  16943. */
  16944. readonly useVertexColor?: boolean | undefined;
  16945. /**
  16946. * If vertex alpha should be applied to the mesh
  16947. */
  16948. readonly useVertexAlpha?: boolean | undefined;
  16949. /**
  16950. * Color of the line (Default: White)
  16951. */
  16952. color: Color3;
  16953. /**
  16954. * Alpha of the line (Default: 1)
  16955. */
  16956. alpha: number;
  16957. /**
  16958. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16959. * This margin is expressed in world space coordinates, so its value may vary.
  16960. * Default value is 0.1
  16961. */
  16962. intersectionThreshold: number;
  16963. private _colorShader;
  16964. private color4;
  16965. /**
  16966. * Creates a new LinesMesh
  16967. * @param name defines the name
  16968. * @param scene defines the hosting scene
  16969. * @param parent defines the parent mesh if any
  16970. * @param source defines the optional source LinesMesh used to clone data from
  16971. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16972. * When false, achieved by calling a clone(), also passing False.
  16973. * This will make creation of children, recursive.
  16974. * @param useVertexColor defines if this LinesMesh supports vertex color
  16975. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16976. */
  16977. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16978. /**
  16979. * If vertex color should be applied to the mesh
  16980. */
  16981. useVertexColor?: boolean | undefined,
  16982. /**
  16983. * If vertex alpha should be applied to the mesh
  16984. */
  16985. useVertexAlpha?: boolean | undefined);
  16986. private _addClipPlaneDefine;
  16987. private _removeClipPlaneDefine;
  16988. isReady(): boolean;
  16989. /**
  16990. * Returns the string "LineMesh"
  16991. */
  16992. getClassName(): string;
  16993. /**
  16994. * @hidden
  16995. */
  16996. get material(): Material;
  16997. /**
  16998. * @hidden
  16999. */
  17000. set material(value: Material);
  17001. /**
  17002. * @hidden
  17003. */
  17004. get checkCollisions(): boolean;
  17005. /** @hidden */
  17006. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17007. /** @hidden */
  17008. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17009. /**
  17010. * Disposes of the line mesh
  17011. * @param doNotRecurse If children should be disposed
  17012. */
  17013. dispose(doNotRecurse?: boolean): void;
  17014. /**
  17015. * Returns a new LineMesh object cloned from the current one.
  17016. */
  17017. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17018. /**
  17019. * Creates a new InstancedLinesMesh object from the mesh model.
  17020. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17021. * @param name defines the name of the new instance
  17022. * @returns a new InstancedLinesMesh
  17023. */
  17024. createInstance(name: string): InstancedLinesMesh;
  17025. }
  17026. /**
  17027. * Creates an instance based on a source LinesMesh
  17028. */
  17029. export class InstancedLinesMesh extends InstancedMesh {
  17030. /**
  17031. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17032. * This margin is expressed in world space coordinates, so its value may vary.
  17033. * Initilized with the intersectionThreshold value of the source LinesMesh
  17034. */
  17035. intersectionThreshold: number;
  17036. constructor(name: string, source: LinesMesh);
  17037. /**
  17038. * Returns the string "InstancedLinesMesh".
  17039. */
  17040. getClassName(): string;
  17041. }
  17042. }
  17043. declare module BABYLON {
  17044. /** @hidden */
  17045. export var linePixelShader: {
  17046. name: string;
  17047. shader: string;
  17048. };
  17049. }
  17050. declare module BABYLON {
  17051. /** @hidden */
  17052. export var lineVertexShader: {
  17053. name: string;
  17054. shader: string;
  17055. };
  17056. }
  17057. declare module BABYLON {
  17058. interface Scene {
  17059. /** @hidden */
  17060. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17061. }
  17062. interface AbstractMesh {
  17063. /**
  17064. * Gets the edgesRenderer associated with the mesh
  17065. */
  17066. edgesRenderer: Nullable<EdgesRenderer>;
  17067. }
  17068. interface LinesMesh {
  17069. /**
  17070. * Enables the edge rendering mode on the mesh.
  17071. * This mode makes the mesh edges visible
  17072. * @param epsilon defines the maximal distance between two angles to detect a face
  17073. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17074. * @returns the currentAbstractMesh
  17075. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17076. */
  17077. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17078. }
  17079. interface InstancedLinesMesh {
  17080. /**
  17081. * Enables the edge rendering mode on the mesh.
  17082. * This mode makes the mesh edges visible
  17083. * @param epsilon defines the maximal distance between two angles to detect a face
  17084. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17085. * @returns the current InstancedLinesMesh
  17086. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17087. */
  17088. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17089. }
  17090. /**
  17091. * Defines the minimum contract an Edges renderer should follow.
  17092. */
  17093. export interface IEdgesRenderer extends IDisposable {
  17094. /**
  17095. * Gets or sets a boolean indicating if the edgesRenderer is active
  17096. */
  17097. isEnabled: boolean;
  17098. /**
  17099. * Renders the edges of the attached mesh,
  17100. */
  17101. render(): void;
  17102. /**
  17103. * Checks wether or not the edges renderer is ready to render.
  17104. * @return true if ready, otherwise false.
  17105. */
  17106. isReady(): boolean;
  17107. /**
  17108. * List of instances to render in case the source mesh has instances
  17109. */
  17110. customInstances: SmartArray<Matrix>;
  17111. }
  17112. /**
  17113. * Defines the additional options of the edges renderer
  17114. */
  17115. export interface IEdgesRendererOptions {
  17116. /**
  17117. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17118. * If not defined, the default value is true
  17119. */
  17120. useAlternateEdgeFinder?: boolean;
  17121. /**
  17122. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17123. * If not defined, the default value is true.
  17124. * 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)
  17125. * This option is used only if useAlternateEdgeFinder = true
  17126. */
  17127. useFastVertexMerger?: boolean;
  17128. /**
  17129. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17130. * The default value is 1e-6
  17131. * This option is used only if useAlternateEdgeFinder = true
  17132. */
  17133. epsilonVertexMerge?: number;
  17134. /**
  17135. * 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
  17136. * 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.
  17137. * This option is used only if useAlternateEdgeFinder = true
  17138. */
  17139. applyTessellation?: boolean;
  17140. /**
  17141. * 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
  17142. * The default value is 1e-6
  17143. * This option is used only if useAlternateEdgeFinder = true
  17144. */
  17145. epsilonVertexAligned?: number;
  17146. }
  17147. /**
  17148. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17149. */
  17150. export class EdgesRenderer implements IEdgesRenderer {
  17151. /**
  17152. * Define the size of the edges with an orthographic camera
  17153. */
  17154. edgesWidthScalerForOrthographic: number;
  17155. /**
  17156. * Define the size of the edges with a perspective camera
  17157. */
  17158. edgesWidthScalerForPerspective: number;
  17159. protected _source: AbstractMesh;
  17160. protected _linesPositions: number[];
  17161. protected _linesNormals: number[];
  17162. protected _linesIndices: number[];
  17163. protected _epsilon: number;
  17164. protected _indicesCount: number;
  17165. protected _lineShader: ShaderMaterial;
  17166. protected _ib: DataBuffer;
  17167. protected _buffers: {
  17168. [key: string]: Nullable<VertexBuffer>;
  17169. };
  17170. protected _buffersForInstances: {
  17171. [key: string]: Nullable<VertexBuffer>;
  17172. };
  17173. protected _checkVerticesInsteadOfIndices: boolean;
  17174. protected _options: Nullable<IEdgesRendererOptions>;
  17175. private _meshRebuildObserver;
  17176. private _meshDisposeObserver;
  17177. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17178. isEnabled: boolean;
  17179. /**
  17180. * List of instances to render in case the source mesh has instances
  17181. */
  17182. customInstances: SmartArray<Matrix>;
  17183. private static GetShader;
  17184. /**
  17185. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17186. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17187. * @param source Mesh used to create edges
  17188. * @param epsilon sum of angles in adjacency to check for edge
  17189. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17190. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17191. * @param options The options to apply when generating the edges
  17192. */
  17193. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17194. protected _prepareRessources(): void;
  17195. /** @hidden */
  17196. _rebuild(): void;
  17197. /**
  17198. * Releases the required resources for the edges renderer
  17199. */
  17200. dispose(): void;
  17201. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17202. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17203. /**
  17204. * Checks if the pair of p0 and p1 is en edge
  17205. * @param faceIndex
  17206. * @param edge
  17207. * @param faceNormals
  17208. * @param p0
  17209. * @param p1
  17210. * @private
  17211. */
  17212. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17213. /**
  17214. * push line into the position, normal and index buffer
  17215. * @protected
  17216. */
  17217. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17218. /**
  17219. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17220. */
  17221. private _tessellateTriangle;
  17222. private _generateEdgesLinesAlternate;
  17223. /**
  17224. * Generates lines edges from adjacencjes
  17225. * @private
  17226. */
  17227. _generateEdgesLines(): void;
  17228. /**
  17229. * Checks wether or not the edges renderer is ready to render.
  17230. * @return true if ready, otherwise false.
  17231. */
  17232. isReady(): boolean;
  17233. /**
  17234. * Renders the edges of the attached mesh,
  17235. */
  17236. render(): void;
  17237. }
  17238. /**
  17239. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17240. */
  17241. export class LineEdgesRenderer extends EdgesRenderer {
  17242. /**
  17243. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17244. * @param source LineMesh used to generate edges
  17245. * @param epsilon not important (specified angle for edge detection)
  17246. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17247. */
  17248. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17249. /**
  17250. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17251. */
  17252. _generateEdgesLines(): void;
  17253. }
  17254. }
  17255. declare module BABYLON {
  17256. /**
  17257. * This represents the object necessary to create a rendering group.
  17258. * This is exclusively used and created by the rendering manager.
  17259. * To modify the behavior, you use the available helpers in your scene or meshes.
  17260. * @hidden
  17261. */
  17262. export class RenderingGroup {
  17263. index: number;
  17264. private static _zeroVector;
  17265. private _scene;
  17266. private _opaqueSubMeshes;
  17267. private _transparentSubMeshes;
  17268. private _alphaTestSubMeshes;
  17269. private _depthOnlySubMeshes;
  17270. private _particleSystems;
  17271. private _spriteManagers;
  17272. private _opaqueSortCompareFn;
  17273. private _alphaTestSortCompareFn;
  17274. private _transparentSortCompareFn;
  17275. private _renderOpaque;
  17276. private _renderAlphaTest;
  17277. private _renderTransparent;
  17278. /** @hidden */
  17279. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17280. onBeforeTransparentRendering: () => void;
  17281. /**
  17282. * Set the opaque sort comparison function.
  17283. * If null the sub meshes will be render in the order they were created
  17284. */
  17285. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17286. /**
  17287. * Set the alpha test sort comparison function.
  17288. * If null the sub meshes will be render in the order they were created
  17289. */
  17290. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17291. /**
  17292. * Set the transparent sort comparison function.
  17293. * If null the sub meshes will be render in the order they were created
  17294. */
  17295. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17296. /**
  17297. * Creates a new rendering group.
  17298. * @param index The rendering group index
  17299. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17300. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17301. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17302. */
  17303. 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>);
  17304. /**
  17305. * Render all the sub meshes contained in the group.
  17306. * @param customRenderFunction Used to override the default render behaviour of the group.
  17307. * @returns true if rendered some submeshes.
  17308. */
  17309. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17310. /**
  17311. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17312. * @param subMeshes The submeshes to render
  17313. */
  17314. private renderOpaqueSorted;
  17315. /**
  17316. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17317. * @param subMeshes The submeshes to render
  17318. */
  17319. private renderAlphaTestSorted;
  17320. /**
  17321. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17322. * @param subMeshes The submeshes to render
  17323. */
  17324. private renderTransparentSorted;
  17325. /**
  17326. * Renders the submeshes in a specified order.
  17327. * @param subMeshes The submeshes to sort before render
  17328. * @param sortCompareFn The comparison function use to sort
  17329. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17330. * @param transparent Specifies to activate blending if true
  17331. */
  17332. private static renderSorted;
  17333. /**
  17334. * Renders the submeshes in the order they were dispatched (no sort applied).
  17335. * @param subMeshes The submeshes to render
  17336. */
  17337. private static renderUnsorted;
  17338. /**
  17339. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17340. * are rendered back to front if in the same alpha index.
  17341. *
  17342. * @param a The first submesh
  17343. * @param b The second submesh
  17344. * @returns The result of the comparison
  17345. */
  17346. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17347. /**
  17348. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17349. * are rendered back to front.
  17350. *
  17351. * @param a The first submesh
  17352. * @param b The second submesh
  17353. * @returns The result of the comparison
  17354. */
  17355. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17356. /**
  17357. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17358. * are rendered front to back (prevent overdraw).
  17359. *
  17360. * @param a The first submesh
  17361. * @param b The second submesh
  17362. * @returns The result of the comparison
  17363. */
  17364. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17365. /**
  17366. * Resets the different lists of submeshes to prepare a new frame.
  17367. */
  17368. prepare(): void;
  17369. dispose(): void;
  17370. /**
  17371. * Inserts the submesh in its correct queue depending on its material.
  17372. * @param subMesh The submesh to dispatch
  17373. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17374. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17375. */
  17376. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17377. dispatchSprites(spriteManager: ISpriteManager): void;
  17378. dispatchParticles(particleSystem: IParticleSystem): void;
  17379. private _renderParticles;
  17380. private _renderSprites;
  17381. }
  17382. }
  17383. declare module BABYLON {
  17384. /**
  17385. * Interface describing the different options available in the rendering manager
  17386. * regarding Auto Clear between groups.
  17387. */
  17388. export interface IRenderingManagerAutoClearSetup {
  17389. /**
  17390. * Defines whether or not autoclear is enable.
  17391. */
  17392. autoClear: boolean;
  17393. /**
  17394. * Defines whether or not to autoclear the depth buffer.
  17395. */
  17396. depth: boolean;
  17397. /**
  17398. * Defines whether or not to autoclear the stencil buffer.
  17399. */
  17400. stencil: boolean;
  17401. }
  17402. /**
  17403. * This class is used by the onRenderingGroupObservable
  17404. */
  17405. export class RenderingGroupInfo {
  17406. /**
  17407. * The Scene that being rendered
  17408. */
  17409. scene: Scene;
  17410. /**
  17411. * The camera currently used for the rendering pass
  17412. */
  17413. camera: Nullable<Camera>;
  17414. /**
  17415. * The ID of the renderingGroup being processed
  17416. */
  17417. renderingGroupId: number;
  17418. }
  17419. /**
  17420. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17421. * It is enable to manage the different groups as well as the different necessary sort functions.
  17422. * This should not be used directly aside of the few static configurations
  17423. */
  17424. export class RenderingManager {
  17425. /**
  17426. * The max id used for rendering groups (not included)
  17427. */
  17428. static MAX_RENDERINGGROUPS: number;
  17429. /**
  17430. * The min id used for rendering groups (included)
  17431. */
  17432. static MIN_RENDERINGGROUPS: number;
  17433. /**
  17434. * Used to globally prevent autoclearing scenes.
  17435. */
  17436. static AUTOCLEAR: boolean;
  17437. /**
  17438. * @hidden
  17439. */
  17440. _useSceneAutoClearSetup: boolean;
  17441. private _scene;
  17442. private _renderingGroups;
  17443. private _depthStencilBufferAlreadyCleaned;
  17444. private _autoClearDepthStencil;
  17445. private _customOpaqueSortCompareFn;
  17446. private _customAlphaTestSortCompareFn;
  17447. private _customTransparentSortCompareFn;
  17448. private _renderingGroupInfo;
  17449. /**
  17450. * Instantiates a new rendering group for a particular scene
  17451. * @param scene Defines the scene the groups belongs to
  17452. */
  17453. constructor(scene: Scene);
  17454. private _clearDepthStencilBuffer;
  17455. /**
  17456. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17457. * @hidden
  17458. */
  17459. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17460. /**
  17461. * Resets the different information of the group to prepare a new frame
  17462. * @hidden
  17463. */
  17464. reset(): void;
  17465. /**
  17466. * Dispose and release the group and its associated resources.
  17467. * @hidden
  17468. */
  17469. dispose(): void;
  17470. /**
  17471. * Clear the info related to rendering groups preventing retention points during dispose.
  17472. */
  17473. freeRenderingGroups(): void;
  17474. private _prepareRenderingGroup;
  17475. /**
  17476. * Add a sprite manager to the rendering manager in order to render it this frame.
  17477. * @param spriteManager Define the sprite manager to render
  17478. */
  17479. dispatchSprites(spriteManager: ISpriteManager): void;
  17480. /**
  17481. * Add a particle system to the rendering manager in order to render it this frame.
  17482. * @param particleSystem Define the particle system to render
  17483. */
  17484. dispatchParticles(particleSystem: IParticleSystem): void;
  17485. /**
  17486. * Add a submesh to the manager in order to render it this frame
  17487. * @param subMesh The submesh to dispatch
  17488. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17489. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17490. */
  17491. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17492. /**
  17493. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17494. * This allowed control for front to back rendering or reversly depending of the special needs.
  17495. *
  17496. * @param renderingGroupId The rendering group id corresponding to its index
  17497. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17498. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17499. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17500. */
  17501. 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;
  17502. /**
  17503. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17504. *
  17505. * @param renderingGroupId The rendering group id corresponding to its index
  17506. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17507. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17508. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17509. */
  17510. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17511. /**
  17512. * Gets the current auto clear configuration for one rendering group of the rendering
  17513. * manager.
  17514. * @param index the rendering group index to get the information for
  17515. * @returns The auto clear setup for the requested rendering group
  17516. */
  17517. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17518. }
  17519. }
  17520. declare module BABYLON {
  17521. /**
  17522. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17523. */
  17524. export interface ICustomShaderOptions {
  17525. /**
  17526. * Gets or sets the custom shader name to use
  17527. */
  17528. shaderName: string;
  17529. /**
  17530. * The list of attribute names used in the shader
  17531. */
  17532. attributes?: string[];
  17533. /**
  17534. * The list of unifrom names used in the shader
  17535. */
  17536. uniforms?: string[];
  17537. /**
  17538. * The list of sampler names used in the shader
  17539. */
  17540. samplers?: string[];
  17541. /**
  17542. * The list of defines used in the shader
  17543. */
  17544. defines?: string[];
  17545. }
  17546. /**
  17547. * Interface to implement to create a shadow generator compatible with BJS.
  17548. */
  17549. export interface IShadowGenerator {
  17550. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17551. id: string;
  17552. /**
  17553. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17554. * @returns The render target texture if present otherwise, null
  17555. */
  17556. getShadowMap(): Nullable<RenderTargetTexture>;
  17557. /**
  17558. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17559. * @param subMesh The submesh we want to render in the shadow map
  17560. * @param useInstances Defines wether will draw in the map using instances
  17561. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17562. * @returns true if ready otherwise, false
  17563. */
  17564. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17565. /**
  17566. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17567. * @param defines Defines of the material we want to update
  17568. * @param lightIndex Index of the light in the enabled light list of the material
  17569. */
  17570. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17571. /**
  17572. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17573. * defined in the generator but impacting the effect).
  17574. * It implies the unifroms available on the materials are the standard BJS ones.
  17575. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17576. * @param effect The effect we are binfing the information for
  17577. */
  17578. bindShadowLight(lightIndex: string, effect: Effect): void;
  17579. /**
  17580. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17581. * (eq to shadow prjection matrix * light transform matrix)
  17582. * @returns The transform matrix used to create the shadow map
  17583. */
  17584. getTransformMatrix(): Matrix;
  17585. /**
  17586. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17587. * Cube and 2D textures for instance.
  17588. */
  17589. recreateShadowMap(): void;
  17590. /**
  17591. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17592. * @param onCompiled Callback triggered at the and of the effects compilation
  17593. * @param options Sets of optional options forcing the compilation with different modes
  17594. */
  17595. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17596. useInstances: boolean;
  17597. }>): void;
  17598. /**
  17599. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17600. * @param options Sets of optional options forcing the compilation with different modes
  17601. * @returns A promise that resolves when the compilation completes
  17602. */
  17603. forceCompilationAsync(options?: Partial<{
  17604. useInstances: boolean;
  17605. }>): Promise<void>;
  17606. /**
  17607. * Serializes the shadow generator setup to a json object.
  17608. * @returns The serialized JSON object
  17609. */
  17610. serialize(): any;
  17611. /**
  17612. * Disposes the Shadow map and related Textures and effects.
  17613. */
  17614. dispose(): void;
  17615. }
  17616. /**
  17617. * Default implementation IShadowGenerator.
  17618. * This is the main object responsible of generating shadows in the framework.
  17619. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17620. */
  17621. export class ShadowGenerator implements IShadowGenerator {
  17622. /**
  17623. * Name of the shadow generator class
  17624. */
  17625. static CLASSNAME: string;
  17626. /**
  17627. * Shadow generator mode None: no filtering applied.
  17628. */
  17629. static readonly FILTER_NONE: number;
  17630. /**
  17631. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17632. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17633. */
  17634. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17635. /**
  17636. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17637. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17638. */
  17639. static readonly FILTER_POISSONSAMPLING: number;
  17640. /**
  17641. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17642. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17643. */
  17644. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17645. /**
  17646. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17647. * edge artifacts on steep falloff.
  17648. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17649. */
  17650. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17651. /**
  17652. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17653. * edge artifacts on steep falloff.
  17654. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17655. */
  17656. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17657. /**
  17658. * Shadow generator mode PCF: Percentage Closer Filtering
  17659. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17660. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17661. */
  17662. static readonly FILTER_PCF: number;
  17663. /**
  17664. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17665. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17666. * Contact Hardening
  17667. */
  17668. static readonly FILTER_PCSS: number;
  17669. /**
  17670. * Reserved for PCF and PCSS
  17671. * Highest Quality.
  17672. *
  17673. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17674. *
  17675. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17676. */
  17677. static readonly QUALITY_HIGH: number;
  17678. /**
  17679. * Reserved for PCF and PCSS
  17680. * Good tradeoff for quality/perf cross devices
  17681. *
  17682. * Execute PCF on a 3*3 kernel.
  17683. *
  17684. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17685. */
  17686. static readonly QUALITY_MEDIUM: number;
  17687. /**
  17688. * Reserved for PCF and PCSS
  17689. * The lowest quality but the fastest.
  17690. *
  17691. * Execute PCF on a 1*1 kernel.
  17692. *
  17693. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17694. */
  17695. static readonly QUALITY_LOW: number;
  17696. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17697. id: string;
  17698. /** Gets or sets the custom shader name to use */
  17699. customShaderOptions: ICustomShaderOptions;
  17700. /**
  17701. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17702. */
  17703. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17704. /**
  17705. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17706. */
  17707. onAfterShadowMapRenderObservable: Observable<Effect>;
  17708. /**
  17709. * Observable triggered before a mesh is rendered in the shadow map.
  17710. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17711. */
  17712. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17713. /**
  17714. * Observable triggered after a mesh is rendered in the shadow map.
  17715. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17716. */
  17717. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17718. protected _bias: number;
  17719. /**
  17720. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17721. */
  17722. get bias(): number;
  17723. /**
  17724. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17725. */
  17726. set bias(bias: number);
  17727. protected _normalBias: number;
  17728. /**
  17729. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17730. */
  17731. get normalBias(): number;
  17732. /**
  17733. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17734. */
  17735. set normalBias(normalBias: number);
  17736. protected _blurBoxOffset: number;
  17737. /**
  17738. * Gets the blur box offset: offset applied during the blur pass.
  17739. * Only useful if useKernelBlur = false
  17740. */
  17741. get blurBoxOffset(): number;
  17742. /**
  17743. * Sets the blur box offset: offset applied during the blur pass.
  17744. * Only useful if useKernelBlur = false
  17745. */
  17746. set blurBoxOffset(value: number);
  17747. protected _blurScale: number;
  17748. /**
  17749. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17750. * 2 means half of the size.
  17751. */
  17752. get blurScale(): number;
  17753. /**
  17754. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17755. * 2 means half of the size.
  17756. */
  17757. set blurScale(value: number);
  17758. protected _blurKernel: number;
  17759. /**
  17760. * Gets the blur kernel: kernel size of the blur pass.
  17761. * Only useful if useKernelBlur = true
  17762. */
  17763. get blurKernel(): number;
  17764. /**
  17765. * Sets the blur kernel: kernel size of the blur pass.
  17766. * Only useful if useKernelBlur = true
  17767. */
  17768. set blurKernel(value: number);
  17769. protected _useKernelBlur: boolean;
  17770. /**
  17771. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17772. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17773. */
  17774. get useKernelBlur(): boolean;
  17775. /**
  17776. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17777. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17778. */
  17779. set useKernelBlur(value: boolean);
  17780. protected _depthScale: number;
  17781. /**
  17782. * Gets the depth scale used in ESM mode.
  17783. */
  17784. get depthScale(): number;
  17785. /**
  17786. * Sets the depth scale used in ESM mode.
  17787. * This can override the scale stored on the light.
  17788. */
  17789. set depthScale(value: number);
  17790. protected _validateFilter(filter: number): number;
  17791. protected _filter: number;
  17792. /**
  17793. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17794. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17795. */
  17796. get filter(): number;
  17797. /**
  17798. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17799. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17800. */
  17801. set filter(value: number);
  17802. /**
  17803. * Gets if the current filter is set to Poisson Sampling.
  17804. */
  17805. get usePoissonSampling(): boolean;
  17806. /**
  17807. * Sets the current filter to Poisson Sampling.
  17808. */
  17809. set usePoissonSampling(value: boolean);
  17810. /**
  17811. * Gets if the current filter is set to ESM.
  17812. */
  17813. get useExponentialShadowMap(): boolean;
  17814. /**
  17815. * Sets the current filter is to ESM.
  17816. */
  17817. set useExponentialShadowMap(value: boolean);
  17818. /**
  17819. * Gets if the current filter is set to filtered ESM.
  17820. */
  17821. get useBlurExponentialShadowMap(): boolean;
  17822. /**
  17823. * Gets if the current filter is set to filtered ESM.
  17824. */
  17825. set useBlurExponentialShadowMap(value: boolean);
  17826. /**
  17827. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17828. * exponential to prevent steep falloff artifacts).
  17829. */
  17830. get useCloseExponentialShadowMap(): boolean;
  17831. /**
  17832. * Sets the current filter to "close ESM" (using the inverse of the
  17833. * exponential to prevent steep falloff artifacts).
  17834. */
  17835. set useCloseExponentialShadowMap(value: boolean);
  17836. /**
  17837. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17838. * exponential to prevent steep falloff artifacts).
  17839. */
  17840. get useBlurCloseExponentialShadowMap(): boolean;
  17841. /**
  17842. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17843. * exponential to prevent steep falloff artifacts).
  17844. */
  17845. set useBlurCloseExponentialShadowMap(value: boolean);
  17846. /**
  17847. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17848. */
  17849. get usePercentageCloserFiltering(): boolean;
  17850. /**
  17851. * Sets the current filter to "PCF" (percentage closer filtering).
  17852. */
  17853. set usePercentageCloserFiltering(value: boolean);
  17854. protected _filteringQuality: number;
  17855. /**
  17856. * Gets the PCF or PCSS Quality.
  17857. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17858. */
  17859. get filteringQuality(): number;
  17860. /**
  17861. * Sets the PCF or PCSS Quality.
  17862. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17863. */
  17864. set filteringQuality(filteringQuality: number);
  17865. /**
  17866. * Gets if the current filter is set to "PCSS" (contact hardening).
  17867. */
  17868. get useContactHardeningShadow(): boolean;
  17869. /**
  17870. * Sets the current filter to "PCSS" (contact hardening).
  17871. */
  17872. set useContactHardeningShadow(value: boolean);
  17873. protected _contactHardeningLightSizeUVRatio: number;
  17874. /**
  17875. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17876. * Using a ratio helps keeping shape stability independently of the map size.
  17877. *
  17878. * It does not account for the light projection as it was having too much
  17879. * instability during the light setup or during light position changes.
  17880. *
  17881. * Only valid if useContactHardeningShadow is true.
  17882. */
  17883. get contactHardeningLightSizeUVRatio(): number;
  17884. /**
  17885. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17886. * Using a ratio helps keeping shape stability independently of the map size.
  17887. *
  17888. * It does not account for the light projection as it was having too much
  17889. * instability during the light setup or during light position changes.
  17890. *
  17891. * Only valid if useContactHardeningShadow is true.
  17892. */
  17893. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17894. protected _darkness: number;
  17895. /** Gets or sets the actual darkness of a shadow */
  17896. get darkness(): number;
  17897. set darkness(value: number);
  17898. /**
  17899. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17900. * 0 means strongest and 1 would means no shadow.
  17901. * @returns the darkness.
  17902. */
  17903. getDarkness(): number;
  17904. /**
  17905. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17906. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17907. * @returns the shadow generator allowing fluent coding.
  17908. */
  17909. setDarkness(darkness: number): ShadowGenerator;
  17910. protected _transparencyShadow: boolean;
  17911. /** Gets or sets the ability to have transparent shadow */
  17912. get transparencyShadow(): boolean;
  17913. set transparencyShadow(value: boolean);
  17914. /**
  17915. * Sets the ability to have transparent shadow (boolean).
  17916. * @param transparent True if transparent else False
  17917. * @returns the shadow generator allowing fluent coding
  17918. */
  17919. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17920. /**
  17921. * Enables or disables shadows with varying strength based on the transparency
  17922. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17923. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17924. * mesh.visibility * alphaTexture.a
  17925. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17926. */
  17927. enableSoftTransparentShadow: boolean;
  17928. protected _shadowMap: Nullable<RenderTargetTexture>;
  17929. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17930. /**
  17931. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17932. * @returns The render target texture if present otherwise, null
  17933. */
  17934. getShadowMap(): Nullable<RenderTargetTexture>;
  17935. /**
  17936. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17937. * @returns The render target texture if the shadow map is present otherwise, null
  17938. */
  17939. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17940. /**
  17941. * Gets the class name of that object
  17942. * @returns "ShadowGenerator"
  17943. */
  17944. getClassName(): string;
  17945. /**
  17946. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17947. * @param mesh Mesh to add
  17948. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17949. * @returns the Shadow Generator itself
  17950. */
  17951. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17952. /**
  17953. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17954. * @param mesh Mesh to remove
  17955. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17956. * @returns the Shadow Generator itself
  17957. */
  17958. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17959. /**
  17960. * Controls the extent to which the shadows fade out at the edge of the frustum
  17961. */
  17962. frustumEdgeFalloff: number;
  17963. protected _light: IShadowLight;
  17964. /**
  17965. * Returns the associated light object.
  17966. * @returns the light generating the shadow
  17967. */
  17968. getLight(): IShadowLight;
  17969. /**
  17970. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17971. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17972. * It might on the other hand introduce peter panning.
  17973. */
  17974. forceBackFacesOnly: boolean;
  17975. protected _scene: Scene;
  17976. protected _lightDirection: Vector3;
  17977. protected _effect: Effect;
  17978. protected _viewMatrix: Matrix;
  17979. protected _projectionMatrix: Matrix;
  17980. protected _transformMatrix: Matrix;
  17981. protected _cachedPosition: Vector3;
  17982. protected _cachedDirection: Vector3;
  17983. protected _cachedDefines: string;
  17984. protected _currentRenderID: number;
  17985. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17986. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17987. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17988. protected _blurPostProcesses: PostProcess[];
  17989. protected _mapSize: number;
  17990. protected _currentFaceIndex: number;
  17991. protected _currentFaceIndexCache: number;
  17992. protected _textureType: number;
  17993. protected _defaultTextureMatrix: Matrix;
  17994. protected _storedUniqueId: Nullable<number>;
  17995. /** @hidden */
  17996. static _SceneComponentInitialization: (scene: Scene) => void;
  17997. /**
  17998. * Gets or sets the size of the texture what stores the shadows
  17999. */
  18000. get mapSize(): number;
  18001. set mapSize(size: number);
  18002. /**
  18003. * Creates a ShadowGenerator object.
  18004. * A ShadowGenerator is the required tool to use the shadows.
  18005. * Each light casting shadows needs to use its own ShadowGenerator.
  18006. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18007. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18008. * @param light The light object generating the shadows.
  18009. * @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.
  18010. */
  18011. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18012. protected _initializeGenerator(): void;
  18013. protected _createTargetRenderTexture(): void;
  18014. protected _initializeShadowMap(): void;
  18015. protected _initializeBlurRTTAndPostProcesses(): void;
  18016. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18017. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18018. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18019. protected _applyFilterValues(): void;
  18020. /**
  18021. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18022. * @param onCompiled Callback triggered at the and of the effects compilation
  18023. * @param options Sets of optional options forcing the compilation with different modes
  18024. */
  18025. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18026. useInstances: boolean;
  18027. }>): void;
  18028. /**
  18029. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18030. * @param options Sets of optional options forcing the compilation with different modes
  18031. * @returns A promise that resolves when the compilation completes
  18032. */
  18033. forceCompilationAsync(options?: Partial<{
  18034. useInstances: boolean;
  18035. }>): Promise<void>;
  18036. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18037. private _prepareShadowDefines;
  18038. /**
  18039. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18040. * @param subMesh The submesh we want to render in the shadow map
  18041. * @param useInstances Defines wether will draw in the map using instances
  18042. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18043. * @returns true if ready otherwise, false
  18044. */
  18045. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18046. /**
  18047. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18048. * @param defines Defines of the material we want to update
  18049. * @param lightIndex Index of the light in the enabled light list of the material
  18050. */
  18051. prepareDefines(defines: any, lightIndex: number): void;
  18052. /**
  18053. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18054. * defined in the generator but impacting the effect).
  18055. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18056. * @param effect The effect we are binfing the information for
  18057. */
  18058. bindShadowLight(lightIndex: string, effect: Effect): void;
  18059. /**
  18060. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18061. * (eq to shadow prjection matrix * light transform matrix)
  18062. * @returns The transform matrix used to create the shadow map
  18063. */
  18064. getTransformMatrix(): Matrix;
  18065. /**
  18066. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18067. * Cube and 2D textures for instance.
  18068. */
  18069. recreateShadowMap(): void;
  18070. protected _disposeBlurPostProcesses(): void;
  18071. protected _disposeRTTandPostProcesses(): void;
  18072. /**
  18073. * Disposes the ShadowGenerator.
  18074. * Returns nothing.
  18075. */
  18076. dispose(): void;
  18077. /**
  18078. * Serializes the shadow generator setup to a json object.
  18079. * @returns The serialized JSON object
  18080. */
  18081. serialize(): any;
  18082. /**
  18083. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18084. * @param parsedShadowGenerator The JSON object to parse
  18085. * @param scene The scene to create the shadow map for
  18086. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18087. * @returns The parsed shadow generator
  18088. */
  18089. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18090. }
  18091. }
  18092. declare module BABYLON {
  18093. /**
  18094. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18095. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18096. * 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.
  18097. */
  18098. export abstract class Light extends Node {
  18099. /**
  18100. * Falloff Default: light is falling off following the material specification:
  18101. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18102. */
  18103. static readonly FALLOFF_DEFAULT: number;
  18104. /**
  18105. * Falloff Physical: light is falling off following the inverse squared distance law.
  18106. */
  18107. static readonly FALLOFF_PHYSICAL: number;
  18108. /**
  18109. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18110. * to enhance interoperability with other engines.
  18111. */
  18112. static readonly FALLOFF_GLTF: number;
  18113. /**
  18114. * Falloff Standard: light is falling off like in the standard material
  18115. * to enhance interoperability with other materials.
  18116. */
  18117. static readonly FALLOFF_STANDARD: number;
  18118. /**
  18119. * If every light affecting the material is in this lightmapMode,
  18120. * material.lightmapTexture adds or multiplies
  18121. * (depends on material.useLightmapAsShadowmap)
  18122. * after every other light calculations.
  18123. */
  18124. static readonly LIGHTMAP_DEFAULT: number;
  18125. /**
  18126. * material.lightmapTexture as only diffuse lighting from this light
  18127. * adds only specular lighting from this light
  18128. * adds dynamic shadows
  18129. */
  18130. static readonly LIGHTMAP_SPECULAR: number;
  18131. /**
  18132. * material.lightmapTexture as only lighting
  18133. * no light calculation from this light
  18134. * only adds dynamic shadows from this light
  18135. */
  18136. static readonly LIGHTMAP_SHADOWSONLY: number;
  18137. /**
  18138. * Each light type uses the default quantity according to its type:
  18139. * point/spot lights use luminous intensity
  18140. * directional lights use illuminance
  18141. */
  18142. static readonly INTENSITYMODE_AUTOMATIC: number;
  18143. /**
  18144. * lumen (lm)
  18145. */
  18146. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18147. /**
  18148. * candela (lm/sr)
  18149. */
  18150. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18151. /**
  18152. * lux (lm/m^2)
  18153. */
  18154. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18155. /**
  18156. * nit (cd/m^2)
  18157. */
  18158. static readonly INTENSITYMODE_LUMINANCE: number;
  18159. /**
  18160. * Light type const id of the point light.
  18161. */
  18162. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18163. /**
  18164. * Light type const id of the directional light.
  18165. */
  18166. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18167. /**
  18168. * Light type const id of the spot light.
  18169. */
  18170. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18171. /**
  18172. * Light type const id of the hemispheric light.
  18173. */
  18174. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18175. /**
  18176. * Diffuse gives the basic color to an object.
  18177. */
  18178. diffuse: Color3;
  18179. /**
  18180. * Specular produces a highlight color on an object.
  18181. * Note: This is note affecting PBR materials.
  18182. */
  18183. specular: Color3;
  18184. /**
  18185. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18186. * falling off base on range or angle.
  18187. * This can be set to any values in Light.FALLOFF_x.
  18188. *
  18189. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18190. * other types of materials.
  18191. */
  18192. falloffType: number;
  18193. /**
  18194. * Strength of the light.
  18195. * Note: By default it is define in the framework own unit.
  18196. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18197. */
  18198. intensity: number;
  18199. private _range;
  18200. protected _inverseSquaredRange: number;
  18201. /**
  18202. * Defines how far from the source the light is impacting in scene units.
  18203. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18204. */
  18205. get range(): number;
  18206. /**
  18207. * Defines how far from the source the light is impacting in scene units.
  18208. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18209. */
  18210. set range(value: number);
  18211. /**
  18212. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18213. * of light.
  18214. */
  18215. private _photometricScale;
  18216. private _intensityMode;
  18217. /**
  18218. * Gets the photometric scale used to interpret the intensity.
  18219. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18220. */
  18221. get intensityMode(): number;
  18222. /**
  18223. * Sets the photometric scale used to interpret the intensity.
  18224. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18225. */
  18226. set intensityMode(value: number);
  18227. private _radius;
  18228. /**
  18229. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18230. */
  18231. get radius(): number;
  18232. /**
  18233. * sets the light radius used by PBR Materials to simulate soft area lights.
  18234. */
  18235. set radius(value: number);
  18236. private _renderPriority;
  18237. /**
  18238. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18239. * exceeding the number allowed of the materials.
  18240. */
  18241. renderPriority: number;
  18242. private _shadowEnabled;
  18243. /**
  18244. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18245. * the current shadow generator.
  18246. */
  18247. get shadowEnabled(): boolean;
  18248. /**
  18249. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18250. * the current shadow generator.
  18251. */
  18252. set shadowEnabled(value: boolean);
  18253. private _includedOnlyMeshes;
  18254. /**
  18255. * Gets the only meshes impacted by this light.
  18256. */
  18257. get includedOnlyMeshes(): AbstractMesh[];
  18258. /**
  18259. * Sets the only meshes impacted by this light.
  18260. */
  18261. set includedOnlyMeshes(value: AbstractMesh[]);
  18262. private _excludedMeshes;
  18263. /**
  18264. * Gets the meshes not impacted by this light.
  18265. */
  18266. get excludedMeshes(): AbstractMesh[];
  18267. /**
  18268. * Sets the meshes not impacted by this light.
  18269. */
  18270. set excludedMeshes(value: AbstractMesh[]);
  18271. private _excludeWithLayerMask;
  18272. /**
  18273. * Gets the layer id use to find what meshes are not impacted by the light.
  18274. * Inactive if 0
  18275. */
  18276. get excludeWithLayerMask(): number;
  18277. /**
  18278. * Sets the layer id use to find what meshes are not impacted by the light.
  18279. * Inactive if 0
  18280. */
  18281. set excludeWithLayerMask(value: number);
  18282. private _includeOnlyWithLayerMask;
  18283. /**
  18284. * Gets the layer id use to find what meshes are impacted by the light.
  18285. * Inactive if 0
  18286. */
  18287. get includeOnlyWithLayerMask(): number;
  18288. /**
  18289. * Sets the layer id use to find what meshes are impacted by the light.
  18290. * Inactive if 0
  18291. */
  18292. set includeOnlyWithLayerMask(value: number);
  18293. private _lightmapMode;
  18294. /**
  18295. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18296. */
  18297. get lightmapMode(): number;
  18298. /**
  18299. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18300. */
  18301. set lightmapMode(value: number);
  18302. /**
  18303. * Shadow generator associted to the light.
  18304. * @hidden Internal use only.
  18305. */
  18306. _shadowGenerator: Nullable<IShadowGenerator>;
  18307. /**
  18308. * @hidden Internal use only.
  18309. */
  18310. _excludedMeshesIds: string[];
  18311. /**
  18312. * @hidden Internal use only.
  18313. */
  18314. _includedOnlyMeshesIds: string[];
  18315. /**
  18316. * The current light unifom buffer.
  18317. * @hidden Internal use only.
  18318. */
  18319. _uniformBuffer: UniformBuffer;
  18320. /** @hidden */
  18321. _renderId: number;
  18322. /**
  18323. * Creates a Light object in the scene.
  18324. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18325. * @param name The firendly name of the light
  18326. * @param scene The scene the light belongs too
  18327. */
  18328. constructor(name: string, scene: Scene);
  18329. protected abstract _buildUniformLayout(): void;
  18330. /**
  18331. * Sets the passed Effect "effect" with the Light information.
  18332. * @param effect The effect to update
  18333. * @param lightIndex The index of the light in the effect to update
  18334. * @returns The light
  18335. */
  18336. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18337. /**
  18338. * Sets the passed Effect "effect" with the Light textures.
  18339. * @param effect The effect to update
  18340. * @param lightIndex The index of the light in the effect to update
  18341. * @returns The light
  18342. */
  18343. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18344. /**
  18345. * Binds the lights information from the scene to the effect for the given mesh.
  18346. * @param lightIndex Light index
  18347. * @param scene The scene where the light belongs to
  18348. * @param effect The effect we are binding the data to
  18349. * @param useSpecular Defines if specular is supported
  18350. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18351. */
  18352. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18353. /**
  18354. * Sets the passed Effect "effect" with the Light information.
  18355. * @param effect The effect to update
  18356. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18357. * @returns The light
  18358. */
  18359. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18360. /**
  18361. * Returns the string "Light".
  18362. * @returns the class name
  18363. */
  18364. getClassName(): string;
  18365. /** @hidden */
  18366. readonly _isLight: boolean;
  18367. /**
  18368. * Converts the light information to a readable string for debug purpose.
  18369. * @param fullDetails Supports for multiple levels of logging within scene loading
  18370. * @returns the human readable light info
  18371. */
  18372. toString(fullDetails?: boolean): string;
  18373. /** @hidden */
  18374. protected _syncParentEnabledState(): void;
  18375. /**
  18376. * Set the enabled state of this node.
  18377. * @param value - the new enabled state
  18378. */
  18379. setEnabled(value: boolean): void;
  18380. /**
  18381. * Returns the Light associated shadow generator if any.
  18382. * @return the associated shadow generator.
  18383. */
  18384. getShadowGenerator(): Nullable<IShadowGenerator>;
  18385. /**
  18386. * Returns a Vector3, the absolute light position in the World.
  18387. * @returns the world space position of the light
  18388. */
  18389. getAbsolutePosition(): Vector3;
  18390. /**
  18391. * Specifies if the light will affect the passed mesh.
  18392. * @param mesh The mesh to test against the light
  18393. * @return true the mesh is affected otherwise, false.
  18394. */
  18395. canAffectMesh(mesh: AbstractMesh): boolean;
  18396. /**
  18397. * Sort function to order lights for rendering.
  18398. * @param a First Light object to compare to second.
  18399. * @param b Second Light object to compare first.
  18400. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18401. */
  18402. static CompareLightsPriority(a: Light, b: Light): number;
  18403. /**
  18404. * Releases resources associated with this node.
  18405. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18406. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18407. */
  18408. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18409. /**
  18410. * Returns the light type ID (integer).
  18411. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18412. */
  18413. getTypeID(): number;
  18414. /**
  18415. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18416. * @returns the scaled intensity in intensity mode unit
  18417. */
  18418. getScaledIntensity(): number;
  18419. /**
  18420. * Returns a new Light object, named "name", from the current one.
  18421. * @param name The name of the cloned light
  18422. * @param newParent The parent of this light, if it has one
  18423. * @returns the new created light
  18424. */
  18425. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18426. /**
  18427. * Serializes the current light into a Serialization object.
  18428. * @returns the serialized object.
  18429. */
  18430. serialize(): any;
  18431. /**
  18432. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18433. * This new light is named "name" and added to the passed scene.
  18434. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18435. * @param name The friendly name of the light
  18436. * @param scene The scene the new light will belong to
  18437. * @returns the constructor function
  18438. */
  18439. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18440. /**
  18441. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18442. * @param parsedLight The JSON representation of the light
  18443. * @param scene The scene to create the parsed light in
  18444. * @returns the created light after parsing
  18445. */
  18446. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18447. private _hookArrayForExcluded;
  18448. private _hookArrayForIncludedOnly;
  18449. private _resyncMeshes;
  18450. /**
  18451. * Forces the meshes to update their light related information in their rendering used effects
  18452. * @hidden Internal Use Only
  18453. */
  18454. _markMeshesAsLightDirty(): void;
  18455. /**
  18456. * Recomputes the cached photometric scale if needed.
  18457. */
  18458. private _computePhotometricScale;
  18459. /**
  18460. * Returns the Photometric Scale according to the light type and intensity mode.
  18461. */
  18462. private _getPhotometricScale;
  18463. /**
  18464. * Reorder the light in the scene according to their defined priority.
  18465. * @hidden Internal Use Only
  18466. */
  18467. _reorderLightsInScene(): void;
  18468. /**
  18469. * Prepares the list of defines specific to the light type.
  18470. * @param defines the list of defines
  18471. * @param lightIndex defines the index of the light for the effect
  18472. */
  18473. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18474. }
  18475. }
  18476. declare module BABYLON {
  18477. /**
  18478. * Configuration needed for prepass-capable materials
  18479. */
  18480. export class PrePassConfiguration {
  18481. /**
  18482. * Previous world matrices of meshes carrying this material
  18483. * Used for computing velocity
  18484. */
  18485. previousWorldMatrices: {
  18486. [index: number]: Matrix;
  18487. };
  18488. /**
  18489. * Previous view project matrix
  18490. * Used for computing velocity
  18491. */
  18492. previousViewProjection: Matrix;
  18493. /**
  18494. * Previous bones of meshes carrying this material
  18495. * Used for computing velocity
  18496. */
  18497. previousBones: {
  18498. [index: number]: Float32Array;
  18499. };
  18500. /**
  18501. * Add the required uniforms to the current list.
  18502. * @param uniforms defines the current uniform list.
  18503. */
  18504. static AddUniforms(uniforms: string[]): void;
  18505. /**
  18506. * Add the required samplers to the current list.
  18507. * @param samplers defines the current sampler list.
  18508. */
  18509. static AddSamplers(samplers: string[]): void;
  18510. /**
  18511. * Binds the material data.
  18512. * @param effect defines the effect to update
  18513. * @param scene defines the scene the material belongs to.
  18514. * @param mesh The mesh
  18515. * @param world World matrix of this mesh
  18516. * @param isFrozen Is the material frozen
  18517. */
  18518. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  18519. }
  18520. }
  18521. declare module BABYLON {
  18522. /**
  18523. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18524. * This is the base of the follow, arc rotate cameras and Free camera
  18525. * @see https://doc.babylonjs.com/features/cameras
  18526. */
  18527. export class TargetCamera extends Camera {
  18528. private static _RigCamTransformMatrix;
  18529. private static _TargetTransformMatrix;
  18530. private static _TargetFocalPoint;
  18531. private _tmpUpVector;
  18532. private _tmpTargetVector;
  18533. /**
  18534. * Define the current direction the camera is moving to
  18535. */
  18536. cameraDirection: Vector3;
  18537. /**
  18538. * Define the current rotation the camera is rotating to
  18539. */
  18540. cameraRotation: Vector2;
  18541. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18542. ignoreParentScaling: boolean;
  18543. /**
  18544. * When set, the up vector of the camera will be updated by the rotation of the camera
  18545. */
  18546. updateUpVectorFromRotation: boolean;
  18547. private _tmpQuaternion;
  18548. /**
  18549. * Define the current rotation of the camera
  18550. */
  18551. rotation: Vector3;
  18552. /**
  18553. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18554. */
  18555. rotationQuaternion: Quaternion;
  18556. /**
  18557. * Define the current speed of the camera
  18558. */
  18559. speed: number;
  18560. /**
  18561. * Add constraint to the camera to prevent it to move freely in all directions and
  18562. * around all axis.
  18563. */
  18564. noRotationConstraint: boolean;
  18565. /**
  18566. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18567. * panning
  18568. */
  18569. invertRotation: boolean;
  18570. /**
  18571. * Speed multiplier for inverse camera panning
  18572. */
  18573. inverseRotationSpeed: number;
  18574. /**
  18575. * Define the current target of the camera as an object or a position.
  18576. */
  18577. lockedTarget: any;
  18578. /** @hidden */
  18579. _currentTarget: Vector3;
  18580. /** @hidden */
  18581. _initialFocalDistance: number;
  18582. /** @hidden */
  18583. _viewMatrix: Matrix;
  18584. /** @hidden */
  18585. _camMatrix: Matrix;
  18586. /** @hidden */
  18587. _cameraTransformMatrix: Matrix;
  18588. /** @hidden */
  18589. _cameraRotationMatrix: Matrix;
  18590. /** @hidden */
  18591. _referencePoint: Vector3;
  18592. /** @hidden */
  18593. _transformedReferencePoint: Vector3;
  18594. /** @hidden */
  18595. _reset: () => void;
  18596. private _defaultUp;
  18597. /**
  18598. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18599. * This is the base of the follow, arc rotate cameras and Free camera
  18600. * @see https://doc.babylonjs.com/features/cameras
  18601. * @param name Defines the name of the camera in the scene
  18602. * @param position Defines the start position of the camera in the scene
  18603. * @param scene Defines the scene the camera belongs to
  18604. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18605. */
  18606. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18607. /**
  18608. * Gets the position in front of the camera at a given distance.
  18609. * @param distance The distance from the camera we want the position to be
  18610. * @returns the position
  18611. */
  18612. getFrontPosition(distance: number): Vector3;
  18613. /** @hidden */
  18614. _getLockedTargetPosition(): Nullable<Vector3>;
  18615. private _storedPosition;
  18616. private _storedRotation;
  18617. private _storedRotationQuaternion;
  18618. /**
  18619. * Store current camera state of the camera (fov, position, rotation, etc..)
  18620. * @returns the camera
  18621. */
  18622. storeState(): Camera;
  18623. /**
  18624. * Restored camera state. You must call storeState() first
  18625. * @returns whether it was successful or not
  18626. * @hidden
  18627. */
  18628. _restoreStateValues(): boolean;
  18629. /** @hidden */
  18630. _initCache(): void;
  18631. /** @hidden */
  18632. _updateCache(ignoreParentClass?: boolean): void;
  18633. /** @hidden */
  18634. _isSynchronizedViewMatrix(): boolean;
  18635. /** @hidden */
  18636. _computeLocalCameraSpeed(): number;
  18637. /**
  18638. * Defines the target the camera should look at.
  18639. * @param target Defines the new target as a Vector or a mesh
  18640. */
  18641. setTarget(target: Vector3): void;
  18642. /**
  18643. * Defines the target point of the camera.
  18644. * The camera looks towards it form the radius distance.
  18645. */
  18646. get target(): Vector3;
  18647. set target(value: Vector3);
  18648. /**
  18649. * Return the current target position of the camera. This value is expressed in local space.
  18650. * @returns the target position
  18651. */
  18652. getTarget(): Vector3;
  18653. /** @hidden */
  18654. _decideIfNeedsToMove(): boolean;
  18655. /** @hidden */
  18656. _updatePosition(): void;
  18657. /** @hidden */
  18658. _checkInputs(): void;
  18659. protected _updateCameraRotationMatrix(): void;
  18660. /**
  18661. * 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)
  18662. * @returns the current camera
  18663. */
  18664. private _rotateUpVectorWithCameraRotationMatrix;
  18665. private _cachedRotationZ;
  18666. private _cachedQuaternionRotationZ;
  18667. /** @hidden */
  18668. _getViewMatrix(): Matrix;
  18669. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18670. /**
  18671. * @hidden
  18672. */
  18673. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18674. /**
  18675. * @hidden
  18676. */
  18677. _updateRigCameras(): void;
  18678. private _getRigCamPositionAndTarget;
  18679. /**
  18680. * Gets the current object class name.
  18681. * @return the class name
  18682. */
  18683. getClassName(): string;
  18684. }
  18685. }
  18686. declare module BABYLON {
  18687. /**
  18688. * Gather the list of keyboard event types as constants.
  18689. */
  18690. export class KeyboardEventTypes {
  18691. /**
  18692. * The keydown event is fired when a key becomes active (pressed).
  18693. */
  18694. static readonly KEYDOWN: number;
  18695. /**
  18696. * The keyup event is fired when a key has been released.
  18697. */
  18698. static readonly KEYUP: number;
  18699. }
  18700. /**
  18701. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18702. */
  18703. export class KeyboardInfo {
  18704. /**
  18705. * Defines the type of event (KeyboardEventTypes)
  18706. */
  18707. type: number;
  18708. /**
  18709. * Defines the related dom event
  18710. */
  18711. event: KeyboardEvent;
  18712. /**
  18713. * Instantiates a new keyboard info.
  18714. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18715. * @param type Defines the type of event (KeyboardEventTypes)
  18716. * @param event Defines the related dom event
  18717. */
  18718. constructor(
  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. /**
  18729. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18730. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18731. */
  18732. export class KeyboardInfoPre extends KeyboardInfo {
  18733. /**
  18734. * Defines the type of event (KeyboardEventTypes)
  18735. */
  18736. type: number;
  18737. /**
  18738. * Defines the related dom event
  18739. */
  18740. event: KeyboardEvent;
  18741. /**
  18742. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18743. */
  18744. skipOnPointerObservable: boolean;
  18745. /**
  18746. * Instantiates a new keyboard pre info.
  18747. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18748. * @param type Defines the type of event (KeyboardEventTypes)
  18749. * @param event Defines the related dom event
  18750. */
  18751. constructor(
  18752. /**
  18753. * Defines the type of event (KeyboardEventTypes)
  18754. */
  18755. type: number,
  18756. /**
  18757. * Defines the related dom event
  18758. */
  18759. event: KeyboardEvent);
  18760. }
  18761. }
  18762. declare module BABYLON {
  18763. /**
  18764. * Manage the keyboard inputs to control the movement of a free camera.
  18765. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18766. */
  18767. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18768. /**
  18769. * Defines the camera the input is attached to.
  18770. */
  18771. camera: FreeCamera;
  18772. /**
  18773. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18774. */
  18775. keysUp: number[];
  18776. /**
  18777. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18778. */
  18779. keysUpward: number[];
  18780. /**
  18781. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18782. */
  18783. keysDown: number[];
  18784. /**
  18785. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18786. */
  18787. keysDownward: number[];
  18788. /**
  18789. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18790. */
  18791. keysLeft: number[];
  18792. /**
  18793. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18794. */
  18795. keysRight: number[];
  18796. private _keys;
  18797. private _onCanvasBlurObserver;
  18798. private _onKeyboardObserver;
  18799. private _engine;
  18800. private _scene;
  18801. /**
  18802. * Attach the input controls to a specific dom element to get the input from.
  18803. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18804. */
  18805. attachControl(noPreventDefault?: boolean): void;
  18806. /**
  18807. * Detach the current controls from the specified dom element.
  18808. */
  18809. detachControl(): void;
  18810. /**
  18811. * Update the current camera state depending on the inputs that have been used this frame.
  18812. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18813. */
  18814. checkInputs(): void;
  18815. /**
  18816. * Gets the class name of the current intput.
  18817. * @returns the class name
  18818. */
  18819. getClassName(): string;
  18820. /** @hidden */
  18821. _onLostFocus(): void;
  18822. /**
  18823. * Get the friendly name associated with the input class.
  18824. * @returns the input friendly name
  18825. */
  18826. getSimpleName(): string;
  18827. }
  18828. }
  18829. declare module BABYLON {
  18830. /**
  18831. * Gather the list of pointer event types as constants.
  18832. */
  18833. export class PointerEventTypes {
  18834. /**
  18835. * 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.
  18836. */
  18837. static readonly POINTERDOWN: number;
  18838. /**
  18839. * The pointerup event is fired when a pointer is no longer active.
  18840. */
  18841. static readonly POINTERUP: number;
  18842. /**
  18843. * The pointermove event is fired when a pointer changes coordinates.
  18844. */
  18845. static readonly POINTERMOVE: number;
  18846. /**
  18847. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18848. */
  18849. static readonly POINTERWHEEL: number;
  18850. /**
  18851. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18852. */
  18853. static readonly POINTERPICK: number;
  18854. /**
  18855. * The pointertap event is fired when a the object has been touched and released without drag.
  18856. */
  18857. static readonly POINTERTAP: number;
  18858. /**
  18859. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18860. */
  18861. static readonly POINTERDOUBLETAP: number;
  18862. }
  18863. /**
  18864. * Base class of pointer info types.
  18865. */
  18866. export class PointerInfoBase {
  18867. /**
  18868. * Defines the type of event (PointerEventTypes)
  18869. */
  18870. type: number;
  18871. /**
  18872. * Defines the related dom event
  18873. */
  18874. event: PointerEvent | MouseWheelEvent;
  18875. /**
  18876. * Instantiates the base class of pointers info.
  18877. * @param type Defines the type of event (PointerEventTypes)
  18878. * @param event Defines the related dom event
  18879. */
  18880. constructor(
  18881. /**
  18882. * Defines the type of event (PointerEventTypes)
  18883. */
  18884. type: number,
  18885. /**
  18886. * Defines the related dom event
  18887. */
  18888. event: PointerEvent | MouseWheelEvent);
  18889. }
  18890. /**
  18891. * This class is used to store pointer related info for the onPrePointerObservable event.
  18892. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18893. */
  18894. export class PointerInfoPre extends PointerInfoBase {
  18895. /**
  18896. * Ray from a pointer if availible (eg. 6dof controller)
  18897. */
  18898. ray: Nullable<Ray>;
  18899. /**
  18900. * Defines the local position of the pointer on the canvas.
  18901. */
  18902. localPosition: Vector2;
  18903. /**
  18904. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18905. */
  18906. skipOnPointerObservable: boolean;
  18907. /**
  18908. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18909. * @param type Defines the type of event (PointerEventTypes)
  18910. * @param event Defines the related dom event
  18911. * @param localX Defines the local x coordinates of the pointer when the event occured
  18912. * @param localY Defines the local y coordinates of the pointer when the event occured
  18913. */
  18914. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18915. }
  18916. /**
  18917. * This type contains all the data related to a pointer event in Babylon.js.
  18918. * 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.
  18919. */
  18920. export class PointerInfo extends PointerInfoBase {
  18921. /**
  18922. * Defines the picking info associated to the info (if any)\
  18923. */
  18924. pickInfo: Nullable<PickingInfo>;
  18925. /**
  18926. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18927. * @param type Defines the type of event (PointerEventTypes)
  18928. * @param event Defines the related dom event
  18929. * @param pickInfo Defines the picking info associated to the info (if any)\
  18930. */
  18931. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18932. /**
  18933. * Defines the picking info associated to the info (if any)\
  18934. */
  18935. pickInfo: Nullable<PickingInfo>);
  18936. }
  18937. /**
  18938. * Data relating to a touch event on the screen.
  18939. */
  18940. export interface PointerTouch {
  18941. /**
  18942. * X coordinate of touch.
  18943. */
  18944. x: number;
  18945. /**
  18946. * Y coordinate of touch.
  18947. */
  18948. y: number;
  18949. /**
  18950. * Id of touch. Unique for each finger.
  18951. */
  18952. pointerId: number;
  18953. /**
  18954. * Event type passed from DOM.
  18955. */
  18956. type: any;
  18957. }
  18958. }
  18959. declare module BABYLON {
  18960. /**
  18961. * Manage the mouse inputs to control the movement of a free camera.
  18962. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18963. */
  18964. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18965. /**
  18966. * Define if touch is enabled in the mouse input
  18967. */
  18968. touchEnabled: boolean;
  18969. /**
  18970. * Defines the camera the input is attached to.
  18971. */
  18972. camera: FreeCamera;
  18973. /**
  18974. * Defines the buttons associated with the input to handle camera move.
  18975. */
  18976. buttons: number[];
  18977. /**
  18978. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18979. */
  18980. angularSensibility: number;
  18981. private _pointerInput;
  18982. private _onMouseMove;
  18983. private _observer;
  18984. private previousPosition;
  18985. /**
  18986. * Observable for when a pointer move event occurs containing the move offset
  18987. */
  18988. onPointerMovedObservable: Observable<{
  18989. offsetX: number;
  18990. offsetY: number;
  18991. }>;
  18992. /**
  18993. * @hidden
  18994. * If the camera should be rotated automatically based on pointer movement
  18995. */
  18996. _allowCameraRotation: boolean;
  18997. /**
  18998. * Manage the mouse inputs to control the movement of a free camera.
  18999. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19000. * @param touchEnabled Defines if touch is enabled or not
  19001. */
  19002. constructor(
  19003. /**
  19004. * Define if touch is enabled in the mouse input
  19005. */
  19006. touchEnabled?: boolean);
  19007. /**
  19008. * Attach the input controls to a specific dom element to get the input from.
  19009. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19010. */
  19011. attachControl(noPreventDefault?: boolean): void;
  19012. /**
  19013. * Called on JS contextmenu event.
  19014. * Override this method to provide functionality.
  19015. */
  19016. protected onContextMenu(evt: PointerEvent): void;
  19017. /**
  19018. * Detach the current controls from the specified dom element.
  19019. */
  19020. detachControl(): void;
  19021. /**
  19022. * Gets the class name of the current intput.
  19023. * @returns the class name
  19024. */
  19025. getClassName(): string;
  19026. /**
  19027. * Get the friendly name associated with the input class.
  19028. * @returns the input friendly name
  19029. */
  19030. getSimpleName(): string;
  19031. }
  19032. }
  19033. declare module BABYLON {
  19034. /**
  19035. * Base class for mouse wheel input..
  19036. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  19037. * for example usage.
  19038. */
  19039. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  19040. /**
  19041. * Defines the camera the input is attached to.
  19042. */
  19043. abstract camera: Camera;
  19044. /**
  19045. * How fast is the camera moves in relation to X axis mouseWheel events.
  19046. * Use negative value to reverse direction.
  19047. */
  19048. wheelPrecisionX: number;
  19049. /**
  19050. * How fast is the camera moves in relation to Y axis mouseWheel events.
  19051. * Use negative value to reverse direction.
  19052. */
  19053. wheelPrecisionY: number;
  19054. /**
  19055. * How fast is the camera moves in relation to Z axis mouseWheel events.
  19056. * Use negative value to reverse direction.
  19057. */
  19058. wheelPrecisionZ: number;
  19059. /**
  19060. * Observable for when a mouse wheel move event occurs.
  19061. */
  19062. onChangedObservable: Observable<{
  19063. wheelDeltaX: number;
  19064. wheelDeltaY: number;
  19065. wheelDeltaZ: number;
  19066. }>;
  19067. private _wheel;
  19068. private _observer;
  19069. /**
  19070. * Attach the input controls to a specific dom element to get the input from.
  19071. * @param noPreventDefault Defines whether event caught by the controls
  19072. * should call preventdefault().
  19073. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19074. */
  19075. attachControl(noPreventDefault?: boolean): void;
  19076. /**
  19077. * Detach the current controls from the specified dom element.
  19078. */
  19079. detachControl(): void;
  19080. /**
  19081. * Called for each rendered frame.
  19082. */
  19083. checkInputs(): void;
  19084. /**
  19085. * Gets the class name of the current intput.
  19086. * @returns the class name
  19087. */
  19088. getClassName(): string;
  19089. /**
  19090. * Get the friendly name associated with the input class.
  19091. * @returns the input friendly name
  19092. */
  19093. getSimpleName(): string;
  19094. /**
  19095. * Incremental value of multiple mouse wheel movements of the X axis.
  19096. * Should be zero-ed when read.
  19097. */
  19098. protected _wheelDeltaX: number;
  19099. /**
  19100. * Incremental value of multiple mouse wheel movements of the Y axis.
  19101. * Should be zero-ed when read.
  19102. */
  19103. protected _wheelDeltaY: number;
  19104. /**
  19105. * Incremental value of multiple mouse wheel movements of the Z axis.
  19106. * Should be zero-ed when read.
  19107. */
  19108. protected _wheelDeltaZ: number;
  19109. /**
  19110. * Firefox uses a different scheme to report scroll distances to other
  19111. * browsers. Rather than use complicated methods to calculate the exact
  19112. * multiple we need to apply, let's just cheat and use a constant.
  19113. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  19114. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  19115. */
  19116. private readonly _ffMultiplier;
  19117. /**
  19118. * Different event attributes for wheel data fall into a few set ranges.
  19119. * Some relevant but dated date here:
  19120. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  19121. */
  19122. private readonly _normalize;
  19123. }
  19124. }
  19125. declare module BABYLON {
  19126. /**
  19127. * Manage the mouse wheel inputs to control a free camera.
  19128. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19129. */
  19130. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  19131. /**
  19132. * Defines the camera the input is attached to.
  19133. */
  19134. camera: FreeCamera;
  19135. /**
  19136. * Gets the class name of the current input.
  19137. * @returns the class name
  19138. */
  19139. getClassName(): string;
  19140. /**
  19141. * Set which movement axis (relative to camera's orientation) the mouse
  19142. * wheel's X axis controls.
  19143. * @param axis The axis to be moved. Set null to clear.
  19144. */
  19145. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  19146. /**
  19147. * Get the configured movement axis (relative to camera's orientation) the
  19148. * mouse wheel's X axis controls.
  19149. * @returns The configured axis or null if none.
  19150. */
  19151. get wheelXMoveRelative(): Nullable<Coordinate>;
  19152. /**
  19153. * Set which movement axis (relative to camera's orientation) the mouse
  19154. * wheel's Y axis controls.
  19155. * @param axis The axis to be moved. Set null to clear.
  19156. */
  19157. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  19158. /**
  19159. * Get the configured movement axis (relative to camera's orientation) the
  19160. * mouse wheel's Y axis controls.
  19161. * @returns The configured axis or null if none.
  19162. */
  19163. get wheelYMoveRelative(): Nullable<Coordinate>;
  19164. /**
  19165. * Set which movement axis (relative to camera's orientation) the mouse
  19166. * wheel's Z axis controls.
  19167. * @param axis The axis to be moved. Set null to clear.
  19168. */
  19169. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  19170. /**
  19171. * Get the configured movement axis (relative to camera's orientation) the
  19172. * mouse wheel's Z axis controls.
  19173. * @returns The configured axis or null if none.
  19174. */
  19175. get wheelZMoveRelative(): Nullable<Coordinate>;
  19176. /**
  19177. * Set which rotation axis (relative to camera's orientation) the mouse
  19178. * wheel's X axis controls.
  19179. * @param axis The axis to be moved. Set null to clear.
  19180. */
  19181. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  19182. /**
  19183. * Get the configured rotation axis (relative to camera's orientation) the
  19184. * mouse wheel's X axis controls.
  19185. * @returns The configured axis or null if none.
  19186. */
  19187. get wheelXRotateRelative(): Nullable<Coordinate>;
  19188. /**
  19189. * Set which rotation axis (relative to camera's orientation) the mouse
  19190. * wheel's Y axis controls.
  19191. * @param axis The axis to be moved. Set null to clear.
  19192. */
  19193. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  19194. /**
  19195. * Get the configured rotation axis (relative to camera's orientation) the
  19196. * mouse wheel's Y axis controls.
  19197. * @returns The configured axis or null if none.
  19198. */
  19199. get wheelYRotateRelative(): Nullable<Coordinate>;
  19200. /**
  19201. * Set which rotation axis (relative to camera's orientation) the mouse
  19202. * wheel's Z axis controls.
  19203. * @param axis The axis to be moved. Set null to clear.
  19204. */
  19205. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  19206. /**
  19207. * Get the configured rotation axis (relative to camera's orientation) the
  19208. * mouse wheel's Z axis controls.
  19209. * @returns The configured axis or null if none.
  19210. */
  19211. get wheelZRotateRelative(): Nullable<Coordinate>;
  19212. /**
  19213. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  19214. * controls.
  19215. * @param axis The axis to be moved. Set null to clear.
  19216. */
  19217. set wheelXMoveScene(axis: Nullable<Coordinate>);
  19218. /**
  19219. * Get the configured movement axis (relative to the scene) the mouse wheel's
  19220. * X axis controls.
  19221. * @returns The configured axis or null if none.
  19222. */
  19223. get wheelXMoveScene(): Nullable<Coordinate>;
  19224. /**
  19225. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  19226. * controls.
  19227. * @param axis The axis to be moved. Set null to clear.
  19228. */
  19229. set wheelYMoveScene(axis: Nullable<Coordinate>);
  19230. /**
  19231. * Get the configured movement axis (relative to the scene) the mouse wheel's
  19232. * Y axis controls.
  19233. * @returns The configured axis or null if none.
  19234. */
  19235. get wheelYMoveScene(): Nullable<Coordinate>;
  19236. /**
  19237. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  19238. * controls.
  19239. * @param axis The axis to be moved. Set null to clear.
  19240. */
  19241. set wheelZMoveScene(axis: Nullable<Coordinate>);
  19242. /**
  19243. * Get the configured movement axis (relative to the scene) the mouse wheel's
  19244. * Z axis controls.
  19245. * @returns The configured axis or null if none.
  19246. */
  19247. get wheelZMoveScene(): Nullable<Coordinate>;
  19248. /**
  19249. * Called for each rendered frame.
  19250. */
  19251. checkInputs(): void;
  19252. private _moveRelative;
  19253. private _rotateRelative;
  19254. private _moveScene;
  19255. /**
  19256. * These are set to the desired default behaviour.
  19257. */
  19258. private _wheelXAction;
  19259. private _wheelXActionCoordinate;
  19260. private _wheelYAction;
  19261. private _wheelYActionCoordinate;
  19262. private _wheelZAction;
  19263. private _wheelZActionCoordinate;
  19264. /**
  19265. * Update the camera according to any configured properties for the 3
  19266. * mouse-wheel axis.
  19267. */
  19268. private _updateCamera;
  19269. }
  19270. }
  19271. declare module BABYLON {
  19272. /**
  19273. * Manage the touch inputs to control the movement of a free camera.
  19274. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19275. */
  19276. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19277. /**
  19278. * Define if mouse events can be treated as touch events
  19279. */
  19280. allowMouse: boolean;
  19281. /**
  19282. * Defines the camera the input is attached to.
  19283. */
  19284. camera: FreeCamera;
  19285. /**
  19286. * Defines the touch sensibility for rotation.
  19287. * The higher the faster.
  19288. */
  19289. touchAngularSensibility: number;
  19290. /**
  19291. * Defines the touch sensibility for move.
  19292. * The higher the faster.
  19293. */
  19294. touchMoveSensibility: number;
  19295. private _offsetX;
  19296. private _offsetY;
  19297. private _pointerPressed;
  19298. private _pointerInput?;
  19299. private _observer;
  19300. private _onLostFocus;
  19301. /**
  19302. * Manage the touch inputs to control the movement of a free camera.
  19303. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19304. * @param allowMouse Defines if mouse events can be treated as touch events
  19305. */
  19306. constructor(
  19307. /**
  19308. * Define if mouse events can be treated as touch events
  19309. */
  19310. allowMouse?: boolean);
  19311. /**
  19312. * Attach the input controls to a specific dom element to get the input from.
  19313. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19314. */
  19315. attachControl(noPreventDefault?: boolean): void;
  19316. /**
  19317. * Detach the current controls from the specified dom element.
  19318. * @param element Defines the element to stop listening the inputs from
  19319. */
  19320. detachControl(): void;
  19321. /**
  19322. * Update the current camera state depending on the inputs that have been used this frame.
  19323. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19324. */
  19325. checkInputs(): void;
  19326. /**
  19327. * Gets the class name of the current intput.
  19328. * @returns the class name
  19329. */
  19330. getClassName(): string;
  19331. /**
  19332. * Get the friendly name associated with the input class.
  19333. * @returns the input friendly name
  19334. */
  19335. getSimpleName(): string;
  19336. }
  19337. }
  19338. declare module BABYLON {
  19339. /**
  19340. * Default Inputs manager for the FreeCamera.
  19341. * It groups all the default supported inputs for ease of use.
  19342. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19343. */
  19344. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19345. /**
  19346. * @hidden
  19347. */
  19348. _mouseInput: Nullable<FreeCameraMouseInput>;
  19349. /**
  19350. * @hidden
  19351. */
  19352. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  19353. /**
  19354. * Instantiates a new FreeCameraInputsManager.
  19355. * @param camera Defines the camera the inputs belong to
  19356. */
  19357. constructor(camera: FreeCamera);
  19358. /**
  19359. * Add keyboard input support to the input manager.
  19360. * @returns the current input manager
  19361. */
  19362. addKeyboard(): FreeCameraInputsManager;
  19363. /**
  19364. * Add mouse input support to the input manager.
  19365. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19366. * @returns the current input manager
  19367. */
  19368. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19369. /**
  19370. * Removes the mouse input support from the manager
  19371. * @returns the current input manager
  19372. */
  19373. removeMouse(): FreeCameraInputsManager;
  19374. /**
  19375. * Add mouse wheel input support to the input manager.
  19376. * @returns the current input manager
  19377. */
  19378. addMouseWheel(): FreeCameraInputsManager;
  19379. /**
  19380. * Removes the mouse wheel input support from the manager
  19381. * @returns the current input manager
  19382. */
  19383. removeMouseWheel(): FreeCameraInputsManager;
  19384. /**
  19385. * Add touch input support to the input manager.
  19386. * @returns the current input manager
  19387. */
  19388. addTouch(): FreeCameraInputsManager;
  19389. /**
  19390. * Remove all attached input methods from a camera
  19391. */
  19392. clear(): void;
  19393. }
  19394. }
  19395. declare module BABYLON {
  19396. /**
  19397. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19398. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19399. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19400. */
  19401. export class FreeCamera extends TargetCamera {
  19402. /**
  19403. * Define the collision ellipsoid of the camera.
  19404. * This is helpful to simulate a camera body like the player body around the camera
  19405. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19406. */
  19407. ellipsoid: Vector3;
  19408. /**
  19409. * Define an offset for the position of the ellipsoid around the camera.
  19410. * This can be helpful to determine the center of the body near the gravity center of the body
  19411. * instead of its head.
  19412. */
  19413. ellipsoidOffset: Vector3;
  19414. /**
  19415. * Enable or disable collisions of the camera with the rest of the scene objects.
  19416. */
  19417. checkCollisions: boolean;
  19418. /**
  19419. * Enable or disable gravity on the camera.
  19420. */
  19421. applyGravity: boolean;
  19422. /**
  19423. * Define the input manager associated to the camera.
  19424. */
  19425. inputs: FreeCameraInputsManager;
  19426. /**
  19427. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19428. * Higher values reduce sensitivity.
  19429. */
  19430. get angularSensibility(): number;
  19431. /**
  19432. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19433. * Higher values reduce sensitivity.
  19434. */
  19435. set angularSensibility(value: number);
  19436. /**
  19437. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19438. */
  19439. get keysUp(): number[];
  19440. set keysUp(value: number[]);
  19441. /**
  19442. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19443. */
  19444. get keysUpward(): number[];
  19445. set keysUpward(value: number[]);
  19446. /**
  19447. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19448. */
  19449. get keysDown(): number[];
  19450. set keysDown(value: number[]);
  19451. /**
  19452. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19453. */
  19454. get keysDownward(): number[];
  19455. set keysDownward(value: number[]);
  19456. /**
  19457. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19458. */
  19459. get keysLeft(): number[];
  19460. set keysLeft(value: number[]);
  19461. /**
  19462. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19463. */
  19464. get keysRight(): number[];
  19465. set keysRight(value: number[]);
  19466. /**
  19467. * Event raised when the camera collide with a mesh in the scene.
  19468. */
  19469. onCollide: (collidedMesh: AbstractMesh) => void;
  19470. private _collider;
  19471. private _needMoveForGravity;
  19472. private _oldPosition;
  19473. private _diffPosition;
  19474. private _newPosition;
  19475. /** @hidden */
  19476. _localDirection: Vector3;
  19477. /** @hidden */
  19478. _transformedDirection: Vector3;
  19479. /**
  19480. * Instantiates a Free Camera.
  19481. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19482. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19483. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19484. * @param name Define the name of the camera in the scene
  19485. * @param position Define the start position of the camera in the scene
  19486. * @param scene Define the scene the camera belongs to
  19487. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19488. */
  19489. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19490. /**
  19491. * Attached controls to the current camera.
  19492. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19493. */
  19494. attachControl(noPreventDefault?: boolean): void;
  19495. /**
  19496. * Detach the current controls from the camera.
  19497. * The camera will stop reacting to inputs.
  19498. */
  19499. detachControl(): void;
  19500. private _collisionMask;
  19501. /**
  19502. * Define a collision mask to limit the list of object the camera can collide with
  19503. */
  19504. get collisionMask(): number;
  19505. set collisionMask(mask: number);
  19506. /** @hidden */
  19507. _collideWithWorld(displacement: Vector3): void;
  19508. private _onCollisionPositionChange;
  19509. /** @hidden */
  19510. _checkInputs(): void;
  19511. /** @hidden */
  19512. _decideIfNeedsToMove(): boolean;
  19513. /** @hidden */
  19514. _updatePosition(): void;
  19515. /**
  19516. * Destroy the camera and release the current resources hold by it.
  19517. */
  19518. dispose(): void;
  19519. /**
  19520. * Gets the current object class name.
  19521. * @return the class name
  19522. */
  19523. getClassName(): string;
  19524. }
  19525. }
  19526. declare module BABYLON {
  19527. /**
  19528. * Represents a gamepad control stick position
  19529. */
  19530. export class StickValues {
  19531. /**
  19532. * The x component of the control stick
  19533. */
  19534. x: number;
  19535. /**
  19536. * The y component of the control stick
  19537. */
  19538. y: number;
  19539. /**
  19540. * Initializes the gamepad x and y control stick values
  19541. * @param x The x component of the gamepad control stick value
  19542. * @param y The y component of the gamepad control stick value
  19543. */
  19544. constructor(
  19545. /**
  19546. * The x component of the control stick
  19547. */
  19548. x: number,
  19549. /**
  19550. * The y component of the control stick
  19551. */
  19552. y: number);
  19553. }
  19554. /**
  19555. * An interface which manages callbacks for gamepad button changes
  19556. */
  19557. export interface GamepadButtonChanges {
  19558. /**
  19559. * Called when a gamepad has been changed
  19560. */
  19561. changed: boolean;
  19562. /**
  19563. * Called when a gamepad press event has been triggered
  19564. */
  19565. pressChanged: boolean;
  19566. /**
  19567. * Called when a touch event has been triggered
  19568. */
  19569. touchChanged: boolean;
  19570. /**
  19571. * Called when a value has changed
  19572. */
  19573. valueChanged: boolean;
  19574. }
  19575. /**
  19576. * Represents a gamepad
  19577. */
  19578. export class Gamepad {
  19579. /**
  19580. * The id of the gamepad
  19581. */
  19582. id: string;
  19583. /**
  19584. * The index of the gamepad
  19585. */
  19586. index: number;
  19587. /**
  19588. * The browser gamepad
  19589. */
  19590. browserGamepad: any;
  19591. /**
  19592. * Specifies what type of gamepad this represents
  19593. */
  19594. type: number;
  19595. private _leftStick;
  19596. private _rightStick;
  19597. /** @hidden */
  19598. _isConnected: boolean;
  19599. private _leftStickAxisX;
  19600. private _leftStickAxisY;
  19601. private _rightStickAxisX;
  19602. private _rightStickAxisY;
  19603. /**
  19604. * Triggered when the left control stick has been changed
  19605. */
  19606. private _onleftstickchanged;
  19607. /**
  19608. * Triggered when the right control stick has been changed
  19609. */
  19610. private _onrightstickchanged;
  19611. /**
  19612. * Represents a gamepad controller
  19613. */
  19614. static GAMEPAD: number;
  19615. /**
  19616. * Represents a generic controller
  19617. */
  19618. static GENERIC: number;
  19619. /**
  19620. * Represents an XBox controller
  19621. */
  19622. static XBOX: number;
  19623. /**
  19624. * Represents a pose-enabled controller
  19625. */
  19626. static POSE_ENABLED: number;
  19627. /**
  19628. * Represents an Dual Shock controller
  19629. */
  19630. static DUALSHOCK: number;
  19631. /**
  19632. * Specifies whether the left control stick should be Y-inverted
  19633. */
  19634. protected _invertLeftStickY: boolean;
  19635. /**
  19636. * Specifies if the gamepad has been connected
  19637. */
  19638. get isConnected(): boolean;
  19639. /**
  19640. * Initializes the gamepad
  19641. * @param id The id of the gamepad
  19642. * @param index The index of the gamepad
  19643. * @param browserGamepad The browser gamepad
  19644. * @param leftStickX The x component of the left joystick
  19645. * @param leftStickY The y component of the left joystick
  19646. * @param rightStickX The x component of the right joystick
  19647. * @param rightStickY The y component of the right joystick
  19648. */
  19649. constructor(
  19650. /**
  19651. * The id of the gamepad
  19652. */
  19653. id: string,
  19654. /**
  19655. * The index of the gamepad
  19656. */
  19657. index: number,
  19658. /**
  19659. * The browser gamepad
  19660. */
  19661. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19662. /**
  19663. * Callback triggered when the left joystick has changed
  19664. * @param callback
  19665. */
  19666. onleftstickchanged(callback: (values: StickValues) => void): void;
  19667. /**
  19668. * Callback triggered when the right joystick has changed
  19669. * @param callback
  19670. */
  19671. onrightstickchanged(callback: (values: StickValues) => void): void;
  19672. /**
  19673. * Gets the left joystick
  19674. */
  19675. get leftStick(): StickValues;
  19676. /**
  19677. * Sets the left joystick values
  19678. */
  19679. set leftStick(newValues: StickValues);
  19680. /**
  19681. * Gets the right joystick
  19682. */
  19683. get rightStick(): StickValues;
  19684. /**
  19685. * Sets the right joystick value
  19686. */
  19687. set rightStick(newValues: StickValues);
  19688. /**
  19689. * Updates the gamepad joystick positions
  19690. */
  19691. update(): void;
  19692. /**
  19693. * Disposes the gamepad
  19694. */
  19695. dispose(): void;
  19696. }
  19697. /**
  19698. * Represents a generic gamepad
  19699. */
  19700. export class GenericPad extends Gamepad {
  19701. private _buttons;
  19702. private _onbuttondown;
  19703. private _onbuttonup;
  19704. /**
  19705. * Observable triggered when a button has been pressed
  19706. */
  19707. onButtonDownObservable: Observable<number>;
  19708. /**
  19709. * Observable triggered when a button has been released
  19710. */
  19711. onButtonUpObservable: Observable<number>;
  19712. /**
  19713. * Callback triggered when a button has been pressed
  19714. * @param callback Called when a button has been pressed
  19715. */
  19716. onbuttondown(callback: (buttonPressed: number) => void): void;
  19717. /**
  19718. * Callback triggered when a button has been released
  19719. * @param callback Called when a button has been released
  19720. */
  19721. onbuttonup(callback: (buttonReleased: number) => void): void;
  19722. /**
  19723. * Initializes the generic gamepad
  19724. * @param id The id of the generic gamepad
  19725. * @param index The index of the generic gamepad
  19726. * @param browserGamepad The browser gamepad
  19727. */
  19728. constructor(id: string, index: number, browserGamepad: any);
  19729. private _setButtonValue;
  19730. /**
  19731. * Updates the generic gamepad
  19732. */
  19733. update(): void;
  19734. /**
  19735. * Disposes the generic gamepad
  19736. */
  19737. dispose(): void;
  19738. }
  19739. }
  19740. declare module BABYLON {
  19741. /**
  19742. * Defines the types of pose enabled controllers that are supported
  19743. */
  19744. export enum PoseEnabledControllerType {
  19745. /**
  19746. * HTC Vive
  19747. */
  19748. VIVE = 0,
  19749. /**
  19750. * Oculus Rift
  19751. */
  19752. OCULUS = 1,
  19753. /**
  19754. * Windows mixed reality
  19755. */
  19756. WINDOWS = 2,
  19757. /**
  19758. * Samsung gear VR
  19759. */
  19760. GEAR_VR = 3,
  19761. /**
  19762. * Google Daydream
  19763. */
  19764. DAYDREAM = 4,
  19765. /**
  19766. * Generic
  19767. */
  19768. GENERIC = 5
  19769. }
  19770. /**
  19771. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19772. */
  19773. export interface MutableGamepadButton {
  19774. /**
  19775. * Value of the button/trigger
  19776. */
  19777. value: number;
  19778. /**
  19779. * If the button/trigger is currently touched
  19780. */
  19781. touched: boolean;
  19782. /**
  19783. * If the button/trigger is currently pressed
  19784. */
  19785. pressed: boolean;
  19786. }
  19787. /**
  19788. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19789. * @hidden
  19790. */
  19791. export interface ExtendedGamepadButton extends GamepadButton {
  19792. /**
  19793. * If the button/trigger is currently pressed
  19794. */
  19795. readonly pressed: boolean;
  19796. /**
  19797. * If the button/trigger is currently touched
  19798. */
  19799. readonly touched: boolean;
  19800. /**
  19801. * Value of the button/trigger
  19802. */
  19803. readonly value: number;
  19804. }
  19805. /** @hidden */
  19806. export interface _GamePadFactory {
  19807. /**
  19808. * Returns whether or not the current gamepad can be created for this type of controller.
  19809. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19810. * @returns true if it can be created, otherwise false
  19811. */
  19812. canCreate(gamepadInfo: any): boolean;
  19813. /**
  19814. * Creates a new instance of the Gamepad.
  19815. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19816. * @returns the new gamepad instance
  19817. */
  19818. create(gamepadInfo: any): Gamepad;
  19819. }
  19820. /**
  19821. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19822. */
  19823. export class PoseEnabledControllerHelper {
  19824. /** @hidden */
  19825. static _ControllerFactories: _GamePadFactory[];
  19826. /** @hidden */
  19827. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19828. /**
  19829. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19830. * @param vrGamepad the gamepad to initialized
  19831. * @returns a vr controller of the type the gamepad identified as
  19832. */
  19833. static InitiateController(vrGamepad: any): Gamepad;
  19834. }
  19835. /**
  19836. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19837. */
  19838. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19839. /**
  19840. * If the controller is used in a webXR session
  19841. */
  19842. isXR: boolean;
  19843. private _deviceRoomPosition;
  19844. private _deviceRoomRotationQuaternion;
  19845. /**
  19846. * The device position in babylon space
  19847. */
  19848. devicePosition: Vector3;
  19849. /**
  19850. * The device rotation in babylon space
  19851. */
  19852. deviceRotationQuaternion: Quaternion;
  19853. /**
  19854. * The scale factor of the device in babylon space
  19855. */
  19856. deviceScaleFactor: number;
  19857. /**
  19858. * (Likely devicePosition should be used instead) The device position in its room space
  19859. */
  19860. position: Vector3;
  19861. /**
  19862. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19863. */
  19864. rotationQuaternion: Quaternion;
  19865. /**
  19866. * The type of controller (Eg. Windows mixed reality)
  19867. */
  19868. controllerType: PoseEnabledControllerType;
  19869. protected _calculatedPosition: Vector3;
  19870. private _calculatedRotation;
  19871. /**
  19872. * The raw pose from the device
  19873. */
  19874. rawPose: DevicePose;
  19875. private _trackPosition;
  19876. private _maxRotationDistFromHeadset;
  19877. private _draggedRoomRotation;
  19878. /**
  19879. * @hidden
  19880. */
  19881. _disableTrackPosition(fixedPosition: Vector3): void;
  19882. /**
  19883. * Internal, the mesh attached to the controller
  19884. * @hidden
  19885. */
  19886. _mesh: Nullable<AbstractMesh>;
  19887. private _poseControlledCamera;
  19888. private _leftHandSystemQuaternion;
  19889. /**
  19890. * Internal, matrix used to convert room space to babylon space
  19891. * @hidden
  19892. */
  19893. _deviceToWorld: Matrix;
  19894. /**
  19895. * Node to be used when casting a ray from the controller
  19896. * @hidden
  19897. */
  19898. _pointingPoseNode: Nullable<TransformNode>;
  19899. /**
  19900. * Name of the child mesh that can be used to cast a ray from the controller
  19901. */
  19902. static readonly POINTING_POSE: string;
  19903. /**
  19904. * Creates a new PoseEnabledController from a gamepad
  19905. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19906. */
  19907. constructor(browserGamepad: any);
  19908. private _workingMatrix;
  19909. /**
  19910. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19911. */
  19912. update(): void;
  19913. /**
  19914. * Updates only the pose device and mesh without doing any button event checking
  19915. */
  19916. protected _updatePoseAndMesh(): void;
  19917. /**
  19918. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19919. * @param poseData raw pose fromthe device
  19920. */
  19921. updateFromDevice(poseData: DevicePose): void;
  19922. /**
  19923. * @hidden
  19924. */
  19925. _meshAttachedObservable: Observable<AbstractMesh>;
  19926. /**
  19927. * Attaches a mesh to the controller
  19928. * @param mesh the mesh to be attached
  19929. */
  19930. attachToMesh(mesh: AbstractMesh): void;
  19931. /**
  19932. * Attaches the controllers mesh to a camera
  19933. * @param camera the camera the mesh should be attached to
  19934. */
  19935. attachToPoseControlledCamera(camera: TargetCamera): void;
  19936. /**
  19937. * Disposes of the controller
  19938. */
  19939. dispose(): void;
  19940. /**
  19941. * The mesh that is attached to the controller
  19942. */
  19943. get mesh(): Nullable<AbstractMesh>;
  19944. /**
  19945. * Gets the ray of the controller in the direction the controller is pointing
  19946. * @param length the length the resulting ray should be
  19947. * @returns a ray in the direction the controller is pointing
  19948. */
  19949. getForwardRay(length?: number): Ray;
  19950. }
  19951. }
  19952. declare module BABYLON {
  19953. /**
  19954. * Defines the WebVRController object that represents controllers tracked in 3D space
  19955. */
  19956. export abstract class WebVRController extends PoseEnabledController {
  19957. /**
  19958. * Internal, the default controller model for the controller
  19959. */
  19960. protected _defaultModel: Nullable<AbstractMesh>;
  19961. /**
  19962. * Fired when the trigger state has changed
  19963. */
  19964. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19965. /**
  19966. * Fired when the main button state has changed
  19967. */
  19968. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19969. /**
  19970. * Fired when the secondary button state has changed
  19971. */
  19972. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19973. /**
  19974. * Fired when the pad state has changed
  19975. */
  19976. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19977. /**
  19978. * Fired when controllers stick values have changed
  19979. */
  19980. onPadValuesChangedObservable: Observable<StickValues>;
  19981. /**
  19982. * Array of button availible on the controller
  19983. */
  19984. protected _buttons: Array<MutableGamepadButton>;
  19985. private _onButtonStateChange;
  19986. /**
  19987. * Fired when a controller button's state has changed
  19988. * @param callback the callback containing the button that was modified
  19989. */
  19990. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19991. /**
  19992. * X and Y axis corresponding to the controllers joystick
  19993. */
  19994. pad: StickValues;
  19995. /**
  19996. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19997. */
  19998. hand: string;
  19999. /**
  20000. * The default controller model for the controller
  20001. */
  20002. get defaultModel(): Nullable<AbstractMesh>;
  20003. /**
  20004. * Creates a new WebVRController from a gamepad
  20005. * @param vrGamepad the gamepad that the WebVRController should be created from
  20006. */
  20007. constructor(vrGamepad: any);
  20008. /**
  20009. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  20010. */
  20011. update(): void;
  20012. /**
  20013. * Function to be called when a button is modified
  20014. */
  20015. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  20016. /**
  20017. * Loads a mesh and attaches it to the controller
  20018. * @param scene the scene the mesh should be added to
  20019. * @param meshLoaded callback for when the mesh has been loaded
  20020. */
  20021. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  20022. private _setButtonValue;
  20023. private _changes;
  20024. private _checkChanges;
  20025. /**
  20026. * Disposes of th webVRCOntroller
  20027. */
  20028. dispose(): void;
  20029. }
  20030. }
  20031. declare module BABYLON {
  20032. /**
  20033. * The HemisphericLight simulates the ambient environment light,
  20034. * so the passed direction is the light reflection direction, not the incoming direction.
  20035. */
  20036. export class HemisphericLight extends Light {
  20037. /**
  20038. * The groundColor is the light in the opposite direction to the one specified during creation.
  20039. * 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.
  20040. */
  20041. groundColor: Color3;
  20042. /**
  20043. * The light reflection direction, not the incoming direction.
  20044. */
  20045. direction: Vector3;
  20046. /**
  20047. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  20048. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  20049. * The HemisphericLight can't cast shadows.
  20050. * Documentation : https://doc.babylonjs.com/babylon101/lights
  20051. * @param name The friendly name of the light
  20052. * @param direction The direction of the light reflection
  20053. * @param scene The scene the light belongs to
  20054. */
  20055. constructor(name: string, direction: Vector3, scene: Scene);
  20056. protected _buildUniformLayout(): void;
  20057. /**
  20058. * Returns the string "HemisphericLight".
  20059. * @return The class name
  20060. */
  20061. getClassName(): string;
  20062. /**
  20063. * Sets the HemisphericLight direction towards the passed target (Vector3).
  20064. * Returns the updated direction.
  20065. * @param target The target the direction should point to
  20066. * @return The computed direction
  20067. */
  20068. setDirectionToTarget(target: Vector3): Vector3;
  20069. /**
  20070. * Returns the shadow generator associated to the light.
  20071. * @returns Always null for hemispheric lights because it does not support shadows.
  20072. */
  20073. getShadowGenerator(): Nullable<IShadowGenerator>;
  20074. /**
  20075. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  20076. * @param effect The effect to update
  20077. * @param lightIndex The index of the light in the effect to update
  20078. * @returns The hemispheric light
  20079. */
  20080. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  20081. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  20082. /**
  20083. * Computes the world matrix of the node
  20084. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20085. * @param useWasUpdatedFlag defines a reserved property
  20086. * @returns the world matrix
  20087. */
  20088. computeWorldMatrix(): Matrix;
  20089. /**
  20090. * Returns the integer 3.
  20091. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20092. */
  20093. getTypeID(): number;
  20094. /**
  20095. * Prepares the list of defines specific to the light type.
  20096. * @param defines the list of defines
  20097. * @param lightIndex defines the index of the light for the effect
  20098. */
  20099. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20100. }
  20101. }
  20102. declare module BABYLON {
  20103. /** @hidden */
  20104. export var vrMultiviewToSingleviewPixelShader: {
  20105. name: string;
  20106. shader: string;
  20107. };
  20108. }
  20109. declare module BABYLON {
  20110. /**
  20111. * Renders to multiple views with a single draw call
  20112. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20113. */
  20114. export class MultiviewRenderTarget extends RenderTargetTexture {
  20115. /**
  20116. * Creates a multiview render target
  20117. * @param scene scene used with the render target
  20118. * @param size the size of the render target (used for each view)
  20119. */
  20120. constructor(scene: Scene, size?: number | {
  20121. width: number;
  20122. height: number;
  20123. } | {
  20124. ratio: number;
  20125. });
  20126. /**
  20127. * @hidden
  20128. * @param faceIndex the face index, if its a cube texture
  20129. */
  20130. _bindFrameBuffer(faceIndex?: number): void;
  20131. /**
  20132. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20133. * @returns the view count
  20134. */
  20135. getViewCount(): number;
  20136. }
  20137. }
  20138. declare module BABYLON {
  20139. interface Engine {
  20140. /**
  20141. * Creates a new multiview render target
  20142. * @param width defines the width of the texture
  20143. * @param height defines the height of the texture
  20144. * @returns the created multiview texture
  20145. */
  20146. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20147. /**
  20148. * Binds a multiview framebuffer to be drawn to
  20149. * @param multiviewTexture texture to bind
  20150. */
  20151. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20152. }
  20153. interface Camera {
  20154. /**
  20155. * @hidden
  20156. * 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)
  20157. */
  20158. _useMultiviewToSingleView: boolean;
  20159. /**
  20160. * @hidden
  20161. * 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)
  20162. */
  20163. _multiviewTexture: Nullable<RenderTargetTexture>;
  20164. /**
  20165. * @hidden
  20166. * ensures the multiview texture of the camera exists and has the specified width/height
  20167. * @param width height to set on the multiview texture
  20168. * @param height width to set on the multiview texture
  20169. */
  20170. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20171. }
  20172. interface Scene {
  20173. /** @hidden */
  20174. _transformMatrixR: Matrix;
  20175. /** @hidden */
  20176. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20177. /** @hidden */
  20178. _createMultiviewUbo(): void;
  20179. /** @hidden */
  20180. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20181. /** @hidden */
  20182. _renderMultiviewToSingleView(camera: Camera): void;
  20183. }
  20184. }
  20185. declare module BABYLON {
  20186. /**
  20187. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20188. * This will not be used for webXR as it supports displaying texture arrays directly
  20189. */
  20190. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20191. /**
  20192. * Gets a string identifying the name of the class
  20193. * @returns "VRMultiviewToSingleviewPostProcess" string
  20194. */
  20195. getClassName(): string;
  20196. /**
  20197. * Initializes a VRMultiviewToSingleview
  20198. * @param name name of the post process
  20199. * @param camera camera to be applied to
  20200. * @param scaleFactor scaling factor to the size of the output texture
  20201. */
  20202. constructor(name: string, camera: Camera, scaleFactor: number);
  20203. }
  20204. }
  20205. declare module BABYLON {
  20206. /**
  20207. * Interface used to define additional presentation attributes
  20208. */
  20209. export interface IVRPresentationAttributes {
  20210. /**
  20211. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20212. */
  20213. highRefreshRate: boolean;
  20214. /**
  20215. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20216. */
  20217. foveationLevel: number;
  20218. }
  20219. interface Engine {
  20220. /** @hidden */
  20221. _vrDisplay: any;
  20222. /** @hidden */
  20223. _vrSupported: boolean;
  20224. /** @hidden */
  20225. _oldSize: Size;
  20226. /** @hidden */
  20227. _oldHardwareScaleFactor: number;
  20228. /** @hidden */
  20229. _vrExclusivePointerMode: boolean;
  20230. /** @hidden */
  20231. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20232. /** @hidden */
  20233. _onVRDisplayPointerRestricted: () => void;
  20234. /** @hidden */
  20235. _onVRDisplayPointerUnrestricted: () => void;
  20236. /** @hidden */
  20237. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20238. /** @hidden */
  20239. _onVrDisplayDisconnect: Nullable<() => void>;
  20240. /** @hidden */
  20241. _onVrDisplayPresentChange: Nullable<() => void>;
  20242. /**
  20243. * Observable signaled when VR display mode changes
  20244. */
  20245. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20246. /**
  20247. * Observable signaled when VR request present is complete
  20248. */
  20249. onVRRequestPresentComplete: Observable<boolean>;
  20250. /**
  20251. * Observable signaled when VR request present starts
  20252. */
  20253. onVRRequestPresentStart: Observable<Engine>;
  20254. /**
  20255. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20256. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20257. */
  20258. isInVRExclusivePointerMode: boolean;
  20259. /**
  20260. * Gets a boolean indicating if a webVR device was detected
  20261. * @returns true if a webVR device was detected
  20262. */
  20263. isVRDevicePresent(): boolean;
  20264. /**
  20265. * Gets the current webVR device
  20266. * @returns the current webVR device (or null)
  20267. */
  20268. getVRDevice(): any;
  20269. /**
  20270. * Initializes a webVR display and starts listening to display change events
  20271. * The onVRDisplayChangedObservable will be notified upon these changes
  20272. * @returns A promise containing a VRDisplay and if vr is supported
  20273. */
  20274. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20275. /** @hidden */
  20276. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20277. /**
  20278. * Gets or sets the presentation attributes used to configure VR rendering
  20279. */
  20280. vrPresentationAttributes?: IVRPresentationAttributes;
  20281. /**
  20282. * Call this function to switch to webVR mode
  20283. * Will do nothing if webVR is not supported or if there is no webVR device
  20284. * @param options the webvr options provided to the camera. mainly used for multiview
  20285. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20286. */
  20287. enableVR(options: WebVROptions): void;
  20288. /** @hidden */
  20289. _onVRFullScreenTriggered(): void;
  20290. }
  20291. }
  20292. declare module BABYLON {
  20293. /**
  20294. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20295. * IMPORTANT!! The data is right-hand data.
  20296. * @export
  20297. * @interface DevicePose
  20298. */
  20299. export interface DevicePose {
  20300. /**
  20301. * The position of the device, values in array are [x,y,z].
  20302. */
  20303. readonly position: Nullable<Float32Array>;
  20304. /**
  20305. * The linearVelocity of the device, values in array are [x,y,z].
  20306. */
  20307. readonly linearVelocity: Nullable<Float32Array>;
  20308. /**
  20309. * The linearAcceleration of the device, values in array are [x,y,z].
  20310. */
  20311. readonly linearAcceleration: Nullable<Float32Array>;
  20312. /**
  20313. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20314. */
  20315. readonly orientation: Nullable<Float32Array>;
  20316. /**
  20317. * The angularVelocity of the device, values in array are [x,y,z].
  20318. */
  20319. readonly angularVelocity: Nullable<Float32Array>;
  20320. /**
  20321. * The angularAcceleration of the device, values in array are [x,y,z].
  20322. */
  20323. readonly angularAcceleration: Nullable<Float32Array>;
  20324. }
  20325. /**
  20326. * Interface representing a pose controlled object in Babylon.
  20327. * A pose controlled object has both regular pose values as well as pose values
  20328. * from an external device such as a VR head mounted display
  20329. */
  20330. export interface PoseControlled {
  20331. /**
  20332. * The position of the object in babylon space.
  20333. */
  20334. position: Vector3;
  20335. /**
  20336. * The rotation quaternion of the object in babylon space.
  20337. */
  20338. rotationQuaternion: Quaternion;
  20339. /**
  20340. * The position of the device in babylon space.
  20341. */
  20342. devicePosition?: Vector3;
  20343. /**
  20344. * The rotation quaternion of the device in babylon space.
  20345. */
  20346. deviceRotationQuaternion: Quaternion;
  20347. /**
  20348. * The raw pose coming from the device.
  20349. */
  20350. rawPose: Nullable<DevicePose>;
  20351. /**
  20352. * The scale of the device to be used when translating from device space to babylon space.
  20353. */
  20354. deviceScaleFactor: number;
  20355. /**
  20356. * Updates the poseControlled values based on the input device pose.
  20357. * @param poseData the pose data to update the object with
  20358. */
  20359. updateFromDevice(poseData: DevicePose): void;
  20360. }
  20361. /**
  20362. * Set of options to customize the webVRCamera
  20363. */
  20364. export interface WebVROptions {
  20365. /**
  20366. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20367. */
  20368. trackPosition?: boolean;
  20369. /**
  20370. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20371. */
  20372. positionScale?: number;
  20373. /**
  20374. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20375. */
  20376. displayName?: string;
  20377. /**
  20378. * Should the native controller meshes be initialized. (default: true)
  20379. */
  20380. controllerMeshes?: boolean;
  20381. /**
  20382. * Creating a default HemiLight only on controllers. (default: true)
  20383. */
  20384. defaultLightingOnControllers?: boolean;
  20385. /**
  20386. * If you don't want to use the default VR button of the helper. (default: false)
  20387. */
  20388. useCustomVRButton?: boolean;
  20389. /**
  20390. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20391. */
  20392. customVRButton?: HTMLButtonElement;
  20393. /**
  20394. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20395. */
  20396. rayLength?: number;
  20397. /**
  20398. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20399. */
  20400. defaultHeight?: number;
  20401. /**
  20402. * If multiview should be used if availible (default: false)
  20403. */
  20404. useMultiview?: boolean;
  20405. }
  20406. /**
  20407. * This represents a WebVR camera.
  20408. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20409. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20410. */
  20411. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20412. private webVROptions;
  20413. /**
  20414. * @hidden
  20415. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20416. */
  20417. _vrDevice: any;
  20418. /**
  20419. * The rawPose of the vrDevice.
  20420. */
  20421. rawPose: Nullable<DevicePose>;
  20422. private _onVREnabled;
  20423. private _specsVersion;
  20424. private _attached;
  20425. private _frameData;
  20426. protected _descendants: Array<Node>;
  20427. private _deviceRoomPosition;
  20428. /** @hidden */
  20429. _deviceRoomRotationQuaternion: Quaternion;
  20430. private _standingMatrix;
  20431. /**
  20432. * Represents device position in babylon space.
  20433. */
  20434. devicePosition: Vector3;
  20435. /**
  20436. * Represents device rotation in babylon space.
  20437. */
  20438. deviceRotationQuaternion: Quaternion;
  20439. /**
  20440. * The scale of the device to be used when translating from device space to babylon space.
  20441. */
  20442. deviceScaleFactor: number;
  20443. private _deviceToWorld;
  20444. private _worldToDevice;
  20445. /**
  20446. * References to the webVR controllers for the vrDevice.
  20447. */
  20448. controllers: Array<WebVRController>;
  20449. /**
  20450. * Emits an event when a controller is attached.
  20451. */
  20452. onControllersAttachedObservable: Observable<WebVRController[]>;
  20453. /**
  20454. * Emits an event when a controller's mesh has been loaded;
  20455. */
  20456. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20457. /**
  20458. * Emits an event when the HMD's pose has been updated.
  20459. */
  20460. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20461. private _poseSet;
  20462. /**
  20463. * If the rig cameras be used as parent instead of this camera.
  20464. */
  20465. rigParenting: boolean;
  20466. private _lightOnControllers;
  20467. private _defaultHeight?;
  20468. /**
  20469. * Instantiates a WebVRFreeCamera.
  20470. * @param name The name of the WebVRFreeCamera
  20471. * @param position The starting anchor position for the camera
  20472. * @param scene The scene the camera belongs to
  20473. * @param webVROptions a set of customizable options for the webVRCamera
  20474. */
  20475. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20476. /**
  20477. * Gets the device distance from the ground in meters.
  20478. * @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.
  20479. */
  20480. deviceDistanceToRoomGround(): number;
  20481. /**
  20482. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20483. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20484. */
  20485. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20486. /**
  20487. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20488. * @returns A promise with a boolean set to if the standing matrix is supported.
  20489. */
  20490. useStandingMatrixAsync(): Promise<boolean>;
  20491. /**
  20492. * Disposes the camera
  20493. */
  20494. dispose(): void;
  20495. /**
  20496. * Gets a vrController by name.
  20497. * @param name The name of the controller to retreive
  20498. * @returns the controller matching the name specified or null if not found
  20499. */
  20500. getControllerByName(name: string): Nullable<WebVRController>;
  20501. private _leftController;
  20502. /**
  20503. * The controller corresponding to the users left hand.
  20504. */
  20505. get leftController(): Nullable<WebVRController>;
  20506. private _rightController;
  20507. /**
  20508. * The controller corresponding to the users right hand.
  20509. */
  20510. get rightController(): Nullable<WebVRController>;
  20511. /**
  20512. * Casts a ray forward from the vrCamera's gaze.
  20513. * @param length Length of the ray (default: 100)
  20514. * @returns the ray corresponding to the gaze
  20515. */
  20516. getForwardRay(length?: number): Ray;
  20517. /**
  20518. * @hidden
  20519. * Updates the camera based on device's frame data
  20520. */
  20521. _checkInputs(): void;
  20522. /**
  20523. * Updates the poseControlled values based on the input device pose.
  20524. * @param poseData Pose coming from the device
  20525. */
  20526. updateFromDevice(poseData: DevicePose): void;
  20527. private _detachIfAttached;
  20528. /**
  20529. * WebVR's attach control will start broadcasting frames to the device.
  20530. * Note that in certain browsers (chrome for example) this function must be called
  20531. * within a user-interaction callback. Example:
  20532. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20533. *
  20534. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20535. */
  20536. attachControl(noPreventDefault?: boolean): void;
  20537. /**
  20538. * Detaches the camera from the html element and disables VR
  20539. */
  20540. detachControl(): void;
  20541. /**
  20542. * @returns the name of this class
  20543. */
  20544. getClassName(): string;
  20545. /**
  20546. * Calls resetPose on the vrDisplay
  20547. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20548. */
  20549. resetToCurrentRotation(): void;
  20550. /**
  20551. * @hidden
  20552. * Updates the rig cameras (left and right eye)
  20553. */
  20554. _updateRigCameras(): void;
  20555. private _workingVector;
  20556. private _oneVector;
  20557. private _workingMatrix;
  20558. private updateCacheCalled;
  20559. private _correctPositionIfNotTrackPosition;
  20560. /**
  20561. * @hidden
  20562. * Updates the cached values of the camera
  20563. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20564. */
  20565. _updateCache(ignoreParentClass?: boolean): void;
  20566. /**
  20567. * @hidden
  20568. * Get current device position in babylon world
  20569. */
  20570. _computeDevicePosition(): void;
  20571. /**
  20572. * Updates the current device position and rotation in the babylon world
  20573. */
  20574. update(): void;
  20575. /**
  20576. * @hidden
  20577. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20578. * @returns an identity matrix
  20579. */
  20580. _getViewMatrix(): Matrix;
  20581. private _tmpMatrix;
  20582. /**
  20583. * This function is called by the two RIG cameras.
  20584. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20585. * @hidden
  20586. */
  20587. _getWebVRViewMatrix(): Matrix;
  20588. /** @hidden */
  20589. _getWebVRProjectionMatrix(): Matrix;
  20590. private _onGamepadConnectedObserver;
  20591. private _onGamepadDisconnectedObserver;
  20592. private _updateCacheWhenTrackingDisabledObserver;
  20593. /**
  20594. * Initializes the controllers and their meshes
  20595. */
  20596. initControllers(): void;
  20597. }
  20598. }
  20599. declare module BABYLON {
  20600. /**
  20601. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20602. *
  20603. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20604. *
  20605. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20606. */
  20607. export class MaterialHelper {
  20608. /**
  20609. * Bind the current view position to an effect.
  20610. * @param effect The effect to be bound
  20611. * @param scene The scene the eyes position is used from
  20612. * @param variableName name of the shader variable that will hold the eye position
  20613. */
  20614. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20615. /**
  20616. * Helps preparing the defines values about the UVs in used in the effect.
  20617. * UVs are shared as much as we can accross channels in the shaders.
  20618. * @param texture The texture we are preparing the UVs for
  20619. * @param defines The defines to update
  20620. * @param key The channel key "diffuse", "specular"... used in the shader
  20621. */
  20622. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20623. /**
  20624. * Binds a texture matrix value to its corrsponding uniform
  20625. * @param texture The texture to bind the matrix for
  20626. * @param uniformBuffer The uniform buffer receivin the data
  20627. * @param key The channel key "diffuse", "specular"... used in the shader
  20628. */
  20629. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20630. /**
  20631. * Gets the current status of the fog (should it be enabled?)
  20632. * @param mesh defines the mesh to evaluate for fog support
  20633. * @param scene defines the hosting scene
  20634. * @returns true if fog must be enabled
  20635. */
  20636. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20637. /**
  20638. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20639. * @param mesh defines the current mesh
  20640. * @param scene defines the current scene
  20641. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20642. * @param pointsCloud defines if point cloud rendering has to be turned on
  20643. * @param fogEnabled defines if fog has to be turned on
  20644. * @param alphaTest defines if alpha testing has to be turned on
  20645. * @param defines defines the current list of defines
  20646. */
  20647. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20648. /**
  20649. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20650. * @param scene defines the current scene
  20651. * @param engine defines the current engine
  20652. * @param defines specifies the list of active defines
  20653. * @param useInstances defines if instances have to be turned on
  20654. * @param useClipPlane defines if clip plane have to be turned on
  20655. * @param useInstances defines if instances have to be turned on
  20656. * @param useThinInstances defines if thin instances have to be turned on
  20657. */
  20658. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20659. /**
  20660. * Prepares the defines for bones
  20661. * @param mesh The mesh containing the geometry data we will draw
  20662. * @param defines The defines to update
  20663. */
  20664. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20665. /**
  20666. * Prepares the defines for morph targets
  20667. * @param mesh The mesh containing the geometry data we will draw
  20668. * @param defines The defines to update
  20669. */
  20670. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20671. /**
  20672. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20673. * @param mesh The mesh containing the geometry data we will draw
  20674. * @param defines The defines to update
  20675. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20676. * @param useBones Precise whether bones should be used or not (override mesh info)
  20677. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20678. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20679. * @returns false if defines are considered not dirty and have not been checked
  20680. */
  20681. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20682. /**
  20683. * Prepares the defines related to multiview
  20684. * @param scene The scene we are intending to draw
  20685. * @param defines The defines to update
  20686. */
  20687. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20688. /**
  20689. * Prepares the defines related to the prepass
  20690. * @param scene The scene we are intending to draw
  20691. * @param defines The defines to update
  20692. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20693. */
  20694. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20695. /**
  20696. * Prepares the defines related to the light information passed in parameter
  20697. * @param scene The scene we are intending to draw
  20698. * @param mesh The mesh the effect is compiling for
  20699. * @param light The light the effect is compiling for
  20700. * @param lightIndex The index of the light
  20701. * @param defines The defines to update
  20702. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20703. * @param state Defines the current state regarding what is needed (normals, etc...)
  20704. */
  20705. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20706. needNormals: boolean;
  20707. needRebuild: boolean;
  20708. shadowEnabled: boolean;
  20709. specularEnabled: boolean;
  20710. lightmapMode: boolean;
  20711. }): void;
  20712. /**
  20713. * Prepares the defines related to the light information passed in parameter
  20714. * @param scene The scene we are intending to draw
  20715. * @param mesh The mesh the effect is compiling for
  20716. * @param defines The defines to update
  20717. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20718. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20719. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20720. * @returns true if normals will be required for the rest of the effect
  20721. */
  20722. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20723. /**
  20724. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20725. * @param lightIndex defines the light index
  20726. * @param uniformsList The uniform list
  20727. * @param samplersList The sampler list
  20728. * @param projectedLightTexture defines if projected texture must be used
  20729. * @param uniformBuffersList defines an optional list of uniform buffers
  20730. */
  20731. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20732. /**
  20733. * Prepares the uniforms and samplers list to be used in the effect
  20734. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20735. * @param samplersList The sampler list
  20736. * @param defines The defines helping in the list generation
  20737. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20738. */
  20739. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20740. /**
  20741. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20742. * @param defines The defines to update while falling back
  20743. * @param fallbacks The authorized effect fallbacks
  20744. * @param maxSimultaneousLights The maximum number of lights allowed
  20745. * @param rank the current rank of the Effect
  20746. * @returns The newly affected rank
  20747. */
  20748. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20749. private static _TmpMorphInfluencers;
  20750. /**
  20751. * Prepares the list of attributes required for morph targets according to the effect defines.
  20752. * @param attribs The current list of supported attribs
  20753. * @param mesh The mesh to prepare the morph targets attributes for
  20754. * @param influencers The number of influencers
  20755. */
  20756. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20757. /**
  20758. * Prepares the list of attributes required for morph targets according to the effect defines.
  20759. * @param attribs The current list of supported attribs
  20760. * @param mesh The mesh to prepare the morph targets attributes for
  20761. * @param defines The current Defines of the effect
  20762. */
  20763. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20764. /**
  20765. * Prepares the list of attributes required for bones according to the effect defines.
  20766. * @param attribs The current list of supported attribs
  20767. * @param mesh The mesh to prepare the bones attributes for
  20768. * @param defines The current Defines of the effect
  20769. * @param fallbacks The current efffect fallback strategy
  20770. */
  20771. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20772. /**
  20773. * Check and prepare the list of attributes required for instances according to the effect defines.
  20774. * @param attribs The current list of supported attribs
  20775. * @param defines The current MaterialDefines of the effect
  20776. */
  20777. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20778. /**
  20779. * Add the list of attributes required for instances to the attribs array.
  20780. * @param attribs The current list of supported attribs
  20781. */
  20782. static PushAttributesForInstances(attribs: string[]): void;
  20783. /**
  20784. * Binds the light information to the effect.
  20785. * @param light The light containing the generator
  20786. * @param effect The effect we are binding the data to
  20787. * @param lightIndex The light index in the effect used to render
  20788. */
  20789. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20790. /**
  20791. * Binds the lights information from the scene to the effect for the given mesh.
  20792. * @param light Light to bind
  20793. * @param lightIndex Light index
  20794. * @param scene The scene where the light belongs to
  20795. * @param effect The effect we are binding the data to
  20796. * @param useSpecular Defines if specular is supported
  20797. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20798. */
  20799. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20800. /**
  20801. * Binds the lights information from the scene to the effect for the given mesh.
  20802. * @param scene The scene the lights belongs to
  20803. * @param mesh The mesh we are binding the information to render
  20804. * @param effect The effect we are binding the data to
  20805. * @param defines The generated defines for the effect
  20806. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20807. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20808. */
  20809. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20810. private static _tempFogColor;
  20811. /**
  20812. * Binds the fog information from the scene to the effect for the given mesh.
  20813. * @param scene The scene the lights belongs to
  20814. * @param mesh The mesh we are binding the information to render
  20815. * @param effect The effect we are binding the data to
  20816. * @param linearSpace Defines if the fog effect is applied in linear space
  20817. */
  20818. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20819. /**
  20820. * Binds the bones information from the mesh to the effect.
  20821. * @param mesh The mesh we are binding the information to render
  20822. * @param effect The effect we are binding the data to
  20823. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  20824. */
  20825. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  20826. private static _CopyBonesTransformationMatrices;
  20827. /**
  20828. * Binds the morph targets information from the mesh to the effect.
  20829. * @param abstractMesh The mesh we are binding the information to render
  20830. * @param effect The effect we are binding the data to
  20831. */
  20832. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20833. /**
  20834. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20835. * @param defines The generated defines used in the effect
  20836. * @param effect The effect we are binding the data to
  20837. * @param scene The scene we are willing to render with logarithmic scale for
  20838. */
  20839. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20840. /**
  20841. * Binds the clip plane information from the scene to the effect.
  20842. * @param scene The scene the clip plane information are extracted from
  20843. * @param effect The effect we are binding the data to
  20844. */
  20845. static BindClipPlane(effect: Effect, scene: Scene): void;
  20846. }
  20847. }
  20848. declare module BABYLON {
  20849. /**
  20850. * Block used to expose an input value
  20851. */
  20852. export class InputBlock extends NodeMaterialBlock {
  20853. private _mode;
  20854. private _associatedVariableName;
  20855. private _storedValue;
  20856. private _valueCallback;
  20857. private _type;
  20858. private _animationType;
  20859. /** Gets or set a value used to limit the range of float values */
  20860. min: number;
  20861. /** Gets or set a value used to limit the range of float values */
  20862. max: number;
  20863. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20864. isBoolean: boolean;
  20865. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20866. matrixMode: number;
  20867. /** @hidden */
  20868. _systemValue: Nullable<NodeMaterialSystemValues>;
  20869. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20870. isConstant: boolean;
  20871. /** Gets or sets the group to use to display this block in the Inspector */
  20872. groupInInspector: string;
  20873. /** Gets an observable raised when the value is changed */
  20874. onValueChangedObservable: Observable<InputBlock>;
  20875. /**
  20876. * Gets or sets the connection point type (default is float)
  20877. */
  20878. get type(): NodeMaterialBlockConnectionPointTypes;
  20879. /**
  20880. * Creates a new InputBlock
  20881. * @param name defines the block name
  20882. * @param target defines the target of that block (Vertex by default)
  20883. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20884. */
  20885. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20886. /**
  20887. * Validates if a name is a reserve word.
  20888. * @param newName the new name to be given to the node.
  20889. * @returns false if the name is a reserve word, else true.
  20890. */
  20891. validateBlockName(newName: string): boolean;
  20892. /**
  20893. * Gets the output component
  20894. */
  20895. get output(): NodeMaterialConnectionPoint;
  20896. /**
  20897. * Set the source of this connection point to a vertex attribute
  20898. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20899. * @returns the current connection point
  20900. */
  20901. setAsAttribute(attributeName?: string): InputBlock;
  20902. /**
  20903. * Set the source of this connection point to a system value
  20904. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20905. * @returns the current connection point
  20906. */
  20907. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20908. /**
  20909. * Gets or sets the value of that point.
  20910. * Please note that this value will be ignored if valueCallback is defined
  20911. */
  20912. get value(): any;
  20913. set value(value: any);
  20914. /**
  20915. * Gets or sets a callback used to get the value of that point.
  20916. * Please note that setting this value will force the connection point to ignore the value property
  20917. */
  20918. get valueCallback(): () => any;
  20919. set valueCallback(value: () => any);
  20920. /**
  20921. * Gets or sets the associated variable name in the shader
  20922. */
  20923. get associatedVariableName(): string;
  20924. set associatedVariableName(value: string);
  20925. /** Gets or sets the type of animation applied to the input */
  20926. get animationType(): AnimatedInputBlockTypes;
  20927. set animationType(value: AnimatedInputBlockTypes);
  20928. /**
  20929. * Gets a boolean indicating that this connection point not defined yet
  20930. */
  20931. get isUndefined(): boolean;
  20932. /**
  20933. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20934. * In this case the connection point name must be the name of the uniform to use.
  20935. * Can only be set on inputs
  20936. */
  20937. get isUniform(): boolean;
  20938. set isUniform(value: boolean);
  20939. /**
  20940. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20941. * In this case the connection point name must be the name of the attribute to use
  20942. * Can only be set on inputs
  20943. */
  20944. get isAttribute(): boolean;
  20945. set isAttribute(value: boolean);
  20946. /**
  20947. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20948. * Can only be set on exit points
  20949. */
  20950. get isVarying(): boolean;
  20951. set isVarying(value: boolean);
  20952. /**
  20953. * Gets a boolean indicating that the current connection point is a system value
  20954. */
  20955. get isSystemValue(): boolean;
  20956. /**
  20957. * Gets or sets the current well known value or null if not defined as a system value
  20958. */
  20959. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20960. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20961. /**
  20962. * Gets the current class name
  20963. * @returns the class name
  20964. */
  20965. getClassName(): string;
  20966. /**
  20967. * Animate the input if animationType !== None
  20968. * @param scene defines the rendering scene
  20969. */
  20970. animate(scene: Scene): void;
  20971. private _emitDefine;
  20972. initialize(state: NodeMaterialBuildState): void;
  20973. /**
  20974. * Set the input block to its default value (based on its type)
  20975. */
  20976. setDefaultValue(): void;
  20977. private _emitConstant;
  20978. /** @hidden */
  20979. get _noContextSwitch(): boolean;
  20980. private _emit;
  20981. /** @hidden */
  20982. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20983. /** @hidden */
  20984. _transmit(effect: Effect, scene: Scene): void;
  20985. protected _buildBlock(state: NodeMaterialBuildState): void;
  20986. protected _dumpPropertiesCode(): string;
  20987. dispose(): void;
  20988. serialize(): any;
  20989. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20990. }
  20991. }
  20992. declare module BABYLON {
  20993. /**
  20994. * Enum used to define the compatibility state between two connection points
  20995. */
  20996. export enum NodeMaterialConnectionPointCompatibilityStates {
  20997. /** Points are compatibles */
  20998. Compatible = 0,
  20999. /** Points are incompatible because of their types */
  21000. TypeIncompatible = 1,
  21001. /** Points are incompatible because of their targets (vertex vs fragment) */
  21002. TargetIncompatible = 2
  21003. }
  21004. /**
  21005. * Defines the direction of a connection point
  21006. */
  21007. export enum NodeMaterialConnectionPointDirection {
  21008. /** Input */
  21009. Input = 0,
  21010. /** Output */
  21011. Output = 1
  21012. }
  21013. /**
  21014. * Defines a connection point for a block
  21015. */
  21016. export class NodeMaterialConnectionPoint {
  21017. /** @hidden */
  21018. _ownerBlock: NodeMaterialBlock;
  21019. /** @hidden */
  21020. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  21021. private _endpoints;
  21022. private _associatedVariableName;
  21023. private _direction;
  21024. /** @hidden */
  21025. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21026. /** @hidden */
  21027. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21028. private _type;
  21029. /** @hidden */
  21030. _enforceAssociatedVariableName: boolean;
  21031. /** Gets the direction of the point */
  21032. get direction(): NodeMaterialConnectionPointDirection;
  21033. /** Indicates that this connection point needs dual validation before being connected to another point */
  21034. needDualDirectionValidation: boolean;
  21035. /**
  21036. * Gets or sets the additional types supported by this connection point
  21037. */
  21038. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21039. /**
  21040. * Gets or sets the additional types excluded by this connection point
  21041. */
  21042. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21043. /**
  21044. * Observable triggered when this point is connected
  21045. */
  21046. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21047. /**
  21048. * Gets or sets the associated variable name in the shader
  21049. */
  21050. get associatedVariableName(): string;
  21051. set associatedVariableName(value: string);
  21052. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21053. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21054. /**
  21055. * Gets or sets the connection point type (default is float)
  21056. */
  21057. get type(): NodeMaterialBlockConnectionPointTypes;
  21058. set type(value: NodeMaterialBlockConnectionPointTypes);
  21059. /**
  21060. * Gets or sets the connection point name
  21061. */
  21062. name: string;
  21063. /**
  21064. * Gets or sets the connection point name
  21065. */
  21066. displayName: string;
  21067. /**
  21068. * Gets or sets a boolean indicating that this connection point can be omitted
  21069. */
  21070. isOptional: boolean;
  21071. /**
  21072. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  21073. */
  21074. isExposedOnFrame: boolean;
  21075. /**
  21076. * Gets or sets number indicating the position that the port is exposed to on a frame
  21077. */
  21078. exposedPortPosition: number;
  21079. /**
  21080. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21081. */
  21082. define: string;
  21083. /** @hidden */
  21084. _prioritizeVertex: boolean;
  21085. private _target;
  21086. /** Gets or sets the target of that connection point */
  21087. get target(): NodeMaterialBlockTargets;
  21088. set target(value: NodeMaterialBlockTargets);
  21089. /**
  21090. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21091. */
  21092. get isConnected(): boolean;
  21093. /**
  21094. * Gets a boolean indicating that the current point is connected to an input block
  21095. */
  21096. get isConnectedToInputBlock(): boolean;
  21097. /**
  21098. * Gets a the connected input block (if any)
  21099. */
  21100. get connectInputBlock(): Nullable<InputBlock>;
  21101. /** Get the other side of the connection (if any) */
  21102. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21103. /** Get the block that owns this connection point */
  21104. get ownerBlock(): NodeMaterialBlock;
  21105. /** Get the block connected on the other side of this connection (if any) */
  21106. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21107. /** Get the block connected on the endpoints of this connection (if any) */
  21108. get connectedBlocks(): Array<NodeMaterialBlock>;
  21109. /** Gets the list of connected endpoints */
  21110. get endpoints(): NodeMaterialConnectionPoint[];
  21111. /** Gets a boolean indicating if that output point is connected to at least one input */
  21112. get hasEndpoints(): boolean;
  21113. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21114. get isConnectedInVertexShader(): boolean;
  21115. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21116. get isConnectedInFragmentShader(): boolean;
  21117. /**
  21118. * Creates a block suitable to be used as an input for this input point.
  21119. * If null is returned, a block based on the point type will be created.
  21120. * @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
  21121. */
  21122. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21123. /**
  21124. * Creates a new connection point
  21125. * @param name defines the connection point name
  21126. * @param ownerBlock defines the block hosting this connection point
  21127. * @param direction defines the direction of the connection point
  21128. */
  21129. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21130. /**
  21131. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21132. * @returns the class name
  21133. */
  21134. getClassName(): string;
  21135. /**
  21136. * Gets a boolean indicating if the current point can be connected to another point
  21137. * @param connectionPoint defines the other connection point
  21138. * @returns a boolean
  21139. */
  21140. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21141. /**
  21142. * Gets a number indicating if the current point can be connected to another point
  21143. * @param connectionPoint defines the other connection point
  21144. * @returns a number defining the compatibility state
  21145. */
  21146. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21147. /**
  21148. * Connect this point to another connection point
  21149. * @param connectionPoint defines the other connection point
  21150. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21151. * @returns the current connection point
  21152. */
  21153. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21154. /**
  21155. * Disconnect this point from one of his endpoint
  21156. * @param endpoint defines the other connection point
  21157. * @returns the current connection point
  21158. */
  21159. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21160. /**
  21161. * Serializes this point in a JSON representation
  21162. * @param isInput defines if the connection point is an input (default is true)
  21163. * @returns the serialized point object
  21164. */
  21165. serialize(isInput?: boolean): any;
  21166. /**
  21167. * Release resources
  21168. */
  21169. dispose(): void;
  21170. }
  21171. }
  21172. declare module BABYLON {
  21173. /**
  21174. * Enum used to define the material modes
  21175. */
  21176. export enum NodeMaterialModes {
  21177. /** Regular material */
  21178. Material = 0,
  21179. /** For post process */
  21180. PostProcess = 1,
  21181. /** For particle system */
  21182. Particle = 2,
  21183. /** For procedural texture */
  21184. ProceduralTexture = 3
  21185. }
  21186. }
  21187. declare module BABYLON {
  21188. /**
  21189. * Block used to read a texture from a sampler
  21190. */
  21191. export class TextureBlock extends NodeMaterialBlock {
  21192. private _defineName;
  21193. private _linearDefineName;
  21194. private _gammaDefineName;
  21195. private _tempTextureRead;
  21196. private _samplerName;
  21197. private _transformedUVName;
  21198. private _textureTransformName;
  21199. private _textureInfoName;
  21200. private _mainUVName;
  21201. private _mainUVDefineName;
  21202. private _fragmentOnly;
  21203. /**
  21204. * Gets or sets the texture associated with the node
  21205. */
  21206. texture: Nullable<Texture>;
  21207. /**
  21208. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21209. */
  21210. convertToGammaSpace: boolean;
  21211. /**
  21212. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21213. */
  21214. convertToLinearSpace: boolean;
  21215. /**
  21216. * Create a new TextureBlock
  21217. * @param name defines the block name
  21218. */
  21219. constructor(name: string, fragmentOnly?: boolean);
  21220. /**
  21221. * Gets the current class name
  21222. * @returns the class name
  21223. */
  21224. getClassName(): string;
  21225. /**
  21226. * Gets the uv input component
  21227. */
  21228. get uv(): NodeMaterialConnectionPoint;
  21229. /**
  21230. * Gets the rgba output component
  21231. */
  21232. get rgba(): NodeMaterialConnectionPoint;
  21233. /**
  21234. * Gets the rgb output component
  21235. */
  21236. get rgb(): NodeMaterialConnectionPoint;
  21237. /**
  21238. * Gets the r output component
  21239. */
  21240. get r(): NodeMaterialConnectionPoint;
  21241. /**
  21242. * Gets the g output component
  21243. */
  21244. get g(): NodeMaterialConnectionPoint;
  21245. /**
  21246. * Gets the b output component
  21247. */
  21248. get b(): NodeMaterialConnectionPoint;
  21249. /**
  21250. * Gets the a output component
  21251. */
  21252. get a(): NodeMaterialConnectionPoint;
  21253. get target(): NodeMaterialBlockTargets;
  21254. autoConfigure(material: NodeMaterial): void;
  21255. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21256. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21257. isReady(): boolean;
  21258. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21259. private get _isMixed();
  21260. private _injectVertexCode;
  21261. private _writeTextureRead;
  21262. private _writeOutput;
  21263. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21264. protected _dumpPropertiesCode(): string;
  21265. serialize(): any;
  21266. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21267. }
  21268. }
  21269. declare module BABYLON {
  21270. /** @hidden */
  21271. export var reflectionFunction: {
  21272. name: string;
  21273. shader: string;
  21274. };
  21275. }
  21276. declare module BABYLON {
  21277. /**
  21278. * Base block used to read a reflection texture from a sampler
  21279. */
  21280. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21281. /** @hidden */
  21282. _define3DName: string;
  21283. /** @hidden */
  21284. _defineCubicName: string;
  21285. /** @hidden */
  21286. _defineExplicitName: string;
  21287. /** @hidden */
  21288. _defineProjectionName: string;
  21289. /** @hidden */
  21290. _defineLocalCubicName: string;
  21291. /** @hidden */
  21292. _defineSphericalName: string;
  21293. /** @hidden */
  21294. _definePlanarName: string;
  21295. /** @hidden */
  21296. _defineEquirectangularName: string;
  21297. /** @hidden */
  21298. _defineMirroredEquirectangularFixedName: string;
  21299. /** @hidden */
  21300. _defineEquirectangularFixedName: string;
  21301. /** @hidden */
  21302. _defineSkyboxName: string;
  21303. /** @hidden */
  21304. _defineOppositeZ: string;
  21305. /** @hidden */
  21306. _cubeSamplerName: string;
  21307. /** @hidden */
  21308. _2DSamplerName: string;
  21309. protected _positionUVWName: string;
  21310. protected _directionWName: string;
  21311. protected _reflectionVectorName: string;
  21312. /** @hidden */
  21313. _reflectionCoordsName: string;
  21314. /** @hidden */
  21315. _reflectionMatrixName: string;
  21316. protected _reflectionColorName: string;
  21317. /**
  21318. * Gets or sets the texture associated with the node
  21319. */
  21320. texture: Nullable<BaseTexture>;
  21321. /**
  21322. * Create a new ReflectionTextureBaseBlock
  21323. * @param name defines the block name
  21324. */
  21325. constructor(name: string);
  21326. /**
  21327. * Gets the current class name
  21328. * @returns the class name
  21329. */
  21330. getClassName(): string;
  21331. /**
  21332. * Gets the world position input component
  21333. */
  21334. abstract get position(): NodeMaterialConnectionPoint;
  21335. /**
  21336. * Gets the world position input component
  21337. */
  21338. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21339. /**
  21340. * Gets the world normal input component
  21341. */
  21342. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21343. /**
  21344. * Gets the world input component
  21345. */
  21346. abstract get world(): NodeMaterialConnectionPoint;
  21347. /**
  21348. * Gets the camera (or eye) position component
  21349. */
  21350. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21351. /**
  21352. * Gets the view input component
  21353. */
  21354. abstract get view(): NodeMaterialConnectionPoint;
  21355. protected _getTexture(): Nullable<BaseTexture>;
  21356. autoConfigure(material: NodeMaterial): void;
  21357. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21358. isReady(): boolean;
  21359. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21360. /**
  21361. * Gets the code to inject in the vertex shader
  21362. * @param state current state of the node material building
  21363. * @returns the shader code
  21364. */
  21365. handleVertexSide(state: NodeMaterialBuildState): string;
  21366. /**
  21367. * Handles the inits for the fragment code path
  21368. * @param state node material build state
  21369. */
  21370. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21371. /**
  21372. * Generates the reflection coords code for the fragment code path
  21373. * @param worldNormalVarName name of the world normal variable
  21374. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21375. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21376. * @returns the shader code
  21377. */
  21378. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21379. /**
  21380. * Generates the reflection color code for the fragment code path
  21381. * @param lodVarName name of the lod variable
  21382. * @param swizzleLookupTexture swizzle to use for the final color variable
  21383. * @returns the shader code
  21384. */
  21385. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21386. /**
  21387. * Generates the code corresponding to the connected output points
  21388. * @param state node material build state
  21389. * @param varName name of the variable to output
  21390. * @returns the shader code
  21391. */
  21392. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21393. protected _buildBlock(state: NodeMaterialBuildState): this;
  21394. protected _dumpPropertiesCode(): string;
  21395. serialize(): any;
  21396. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21397. }
  21398. }
  21399. declare module BABYLON {
  21400. /**
  21401. * Defines a connection point to be used for points with a custom object type
  21402. */
  21403. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21404. private _blockType;
  21405. private _blockName;
  21406. private _nameForCheking?;
  21407. /**
  21408. * Creates a new connection point
  21409. * @param name defines the connection point name
  21410. * @param ownerBlock defines the block hosting this connection point
  21411. * @param direction defines the direction of the connection point
  21412. */
  21413. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21414. /**
  21415. * Gets a number indicating if the current point can be connected to another point
  21416. * @param connectionPoint defines the other connection point
  21417. * @returns a number defining the compatibility state
  21418. */
  21419. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21420. /**
  21421. * Creates a block suitable to be used as an input for this input point.
  21422. * If null is returned, a block based on the point type will be created.
  21423. * @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
  21424. */
  21425. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21426. }
  21427. }
  21428. declare module BABYLON {
  21429. /**
  21430. * Enum defining the type of properties that can be edited in the property pages in the NME
  21431. */
  21432. export enum PropertyTypeForEdition {
  21433. /** property is a boolean */
  21434. Boolean = 0,
  21435. /** property is a float */
  21436. Float = 1,
  21437. /** property is a Vector2 */
  21438. Vector2 = 2,
  21439. /** property is a list of values */
  21440. List = 3
  21441. }
  21442. /**
  21443. * Interface that defines an option in a variable of type list
  21444. */
  21445. export interface IEditablePropertyListOption {
  21446. /** label of the option */
  21447. "label": string;
  21448. /** value of the option */
  21449. "value": number;
  21450. }
  21451. /**
  21452. * Interface that defines the options available for an editable property
  21453. */
  21454. export interface IEditablePropertyOption {
  21455. /** min value */
  21456. "min"?: number;
  21457. /** max value */
  21458. "max"?: number;
  21459. /** notifiers: indicates which actions to take when the property is changed */
  21460. "notifiers"?: {
  21461. /** the material should be rebuilt */
  21462. "rebuild"?: boolean;
  21463. /** the preview should be updated */
  21464. "update"?: boolean;
  21465. };
  21466. /** list of the options for a variable of type list */
  21467. "options"?: IEditablePropertyListOption[];
  21468. }
  21469. /**
  21470. * Interface that describes an editable property
  21471. */
  21472. export interface IPropertyDescriptionForEdition {
  21473. /** name of the property */
  21474. "propertyName": string;
  21475. /** display name of the property */
  21476. "displayName": string;
  21477. /** type of the property */
  21478. "type": PropertyTypeForEdition;
  21479. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21480. "groupName": string;
  21481. /** options for the property */
  21482. "options": IEditablePropertyOption;
  21483. }
  21484. /**
  21485. * Decorator that flags a property in a node material block as being editable
  21486. */
  21487. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21488. }
  21489. declare module BABYLON {
  21490. /**
  21491. * Block used to implement the refraction part of the sub surface module of the PBR material
  21492. */
  21493. export class RefractionBlock extends NodeMaterialBlock {
  21494. /** @hidden */
  21495. _define3DName: string;
  21496. /** @hidden */
  21497. _refractionMatrixName: string;
  21498. /** @hidden */
  21499. _defineLODRefractionAlpha: string;
  21500. /** @hidden */
  21501. _defineLinearSpecularRefraction: string;
  21502. /** @hidden */
  21503. _defineOppositeZ: string;
  21504. /** @hidden */
  21505. _cubeSamplerName: string;
  21506. /** @hidden */
  21507. _2DSamplerName: string;
  21508. /** @hidden */
  21509. _vRefractionMicrosurfaceInfosName: string;
  21510. /** @hidden */
  21511. _vRefractionInfosName: string;
  21512. private _scene;
  21513. /**
  21514. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21515. * Materials half opaque for instance using refraction could benefit from this control.
  21516. */
  21517. linkRefractionWithTransparency: boolean;
  21518. /**
  21519. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21520. */
  21521. invertRefractionY: boolean;
  21522. /**
  21523. * Gets or sets the texture associated with the node
  21524. */
  21525. texture: Nullable<BaseTexture>;
  21526. /**
  21527. * Create a new RefractionBlock
  21528. * @param name defines the block name
  21529. */
  21530. constructor(name: string);
  21531. /**
  21532. * Gets the current class name
  21533. * @returns the class name
  21534. */
  21535. getClassName(): string;
  21536. /**
  21537. * Gets the intensity input component
  21538. */
  21539. get intensity(): NodeMaterialConnectionPoint;
  21540. /**
  21541. * Gets the index of refraction input component
  21542. */
  21543. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21544. /**
  21545. * Gets the tint at distance input component
  21546. */
  21547. get tintAtDistance(): NodeMaterialConnectionPoint;
  21548. /**
  21549. * Gets the view input component
  21550. */
  21551. get view(): NodeMaterialConnectionPoint;
  21552. /**
  21553. * Gets the refraction object output component
  21554. */
  21555. get refraction(): NodeMaterialConnectionPoint;
  21556. /**
  21557. * Returns true if the block has a texture
  21558. */
  21559. get hasTexture(): boolean;
  21560. protected _getTexture(): Nullable<BaseTexture>;
  21561. autoConfigure(material: NodeMaterial): void;
  21562. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21563. isReady(): boolean;
  21564. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21565. /**
  21566. * Gets the main code of the block (fragment side)
  21567. * @param state current state of the node material building
  21568. * @returns the shader code
  21569. */
  21570. getCode(state: NodeMaterialBuildState): string;
  21571. protected _buildBlock(state: NodeMaterialBuildState): this;
  21572. protected _dumpPropertiesCode(): string;
  21573. serialize(): any;
  21574. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21575. }
  21576. }
  21577. declare module BABYLON {
  21578. /**
  21579. * Base block used as input for post process
  21580. */
  21581. export class CurrentScreenBlock extends NodeMaterialBlock {
  21582. private _samplerName;
  21583. private _linearDefineName;
  21584. private _gammaDefineName;
  21585. private _mainUVName;
  21586. private _tempTextureRead;
  21587. /**
  21588. * Gets or sets the texture associated with the node
  21589. */
  21590. texture: Nullable<BaseTexture>;
  21591. /**
  21592. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21593. */
  21594. convertToGammaSpace: boolean;
  21595. /**
  21596. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21597. */
  21598. convertToLinearSpace: boolean;
  21599. /**
  21600. * Create a new CurrentScreenBlock
  21601. * @param name defines the block name
  21602. */
  21603. constructor(name: string);
  21604. /**
  21605. * Gets the current class name
  21606. * @returns the class name
  21607. */
  21608. getClassName(): string;
  21609. /**
  21610. * Gets the uv input component
  21611. */
  21612. get uv(): NodeMaterialConnectionPoint;
  21613. /**
  21614. * Gets the rgba output component
  21615. */
  21616. get rgba(): NodeMaterialConnectionPoint;
  21617. /**
  21618. * Gets the rgb output component
  21619. */
  21620. get rgb(): NodeMaterialConnectionPoint;
  21621. /**
  21622. * Gets the r output component
  21623. */
  21624. get r(): NodeMaterialConnectionPoint;
  21625. /**
  21626. * Gets the g output component
  21627. */
  21628. get g(): NodeMaterialConnectionPoint;
  21629. /**
  21630. * Gets the b output component
  21631. */
  21632. get b(): NodeMaterialConnectionPoint;
  21633. /**
  21634. * Gets the a output component
  21635. */
  21636. get a(): NodeMaterialConnectionPoint;
  21637. /**
  21638. * Initialize the block and prepare the context for build
  21639. * @param state defines the state that will be used for the build
  21640. */
  21641. initialize(state: NodeMaterialBuildState): void;
  21642. get target(): NodeMaterialBlockTargets;
  21643. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21644. isReady(): boolean;
  21645. private _injectVertexCode;
  21646. private _writeTextureRead;
  21647. private _writeOutput;
  21648. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21649. serialize(): any;
  21650. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21651. }
  21652. }
  21653. declare module BABYLON {
  21654. /**
  21655. * Base block used for the particle texture
  21656. */
  21657. export class ParticleTextureBlock extends NodeMaterialBlock {
  21658. private _samplerName;
  21659. private _linearDefineName;
  21660. private _gammaDefineName;
  21661. private _tempTextureRead;
  21662. /**
  21663. * Gets or sets the texture associated with the node
  21664. */
  21665. texture: Nullable<BaseTexture>;
  21666. /**
  21667. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21668. */
  21669. convertToGammaSpace: boolean;
  21670. /**
  21671. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21672. */
  21673. convertToLinearSpace: boolean;
  21674. /**
  21675. * Create a new ParticleTextureBlock
  21676. * @param name defines the block name
  21677. */
  21678. constructor(name: string);
  21679. /**
  21680. * Gets the current class name
  21681. * @returns the class name
  21682. */
  21683. getClassName(): string;
  21684. /**
  21685. * Gets the uv input component
  21686. */
  21687. get uv(): NodeMaterialConnectionPoint;
  21688. /**
  21689. * Gets the rgba output component
  21690. */
  21691. get rgba(): NodeMaterialConnectionPoint;
  21692. /**
  21693. * Gets the rgb output component
  21694. */
  21695. get rgb(): NodeMaterialConnectionPoint;
  21696. /**
  21697. * Gets the r output component
  21698. */
  21699. get r(): NodeMaterialConnectionPoint;
  21700. /**
  21701. * Gets the g output component
  21702. */
  21703. get g(): NodeMaterialConnectionPoint;
  21704. /**
  21705. * Gets the b output component
  21706. */
  21707. get b(): NodeMaterialConnectionPoint;
  21708. /**
  21709. * Gets the a output component
  21710. */
  21711. get a(): NodeMaterialConnectionPoint;
  21712. /**
  21713. * Initialize the block and prepare the context for build
  21714. * @param state defines the state that will be used for the build
  21715. */
  21716. initialize(state: NodeMaterialBuildState): void;
  21717. autoConfigure(material: NodeMaterial): void;
  21718. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21719. isReady(): boolean;
  21720. private _writeOutput;
  21721. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21722. serialize(): any;
  21723. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21724. }
  21725. }
  21726. declare module BABYLON {
  21727. /**
  21728. * Class used to store shared data between 2 NodeMaterialBuildState
  21729. */
  21730. export class NodeMaterialBuildStateSharedData {
  21731. /**
  21732. * Gets the list of emitted varyings
  21733. */
  21734. temps: string[];
  21735. /**
  21736. * Gets the list of emitted varyings
  21737. */
  21738. varyings: string[];
  21739. /**
  21740. * Gets the varying declaration string
  21741. */
  21742. varyingDeclaration: string;
  21743. /**
  21744. * Input blocks
  21745. */
  21746. inputBlocks: InputBlock[];
  21747. /**
  21748. * Input blocks
  21749. */
  21750. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21751. /**
  21752. * Bindable blocks (Blocks that need to set data to the effect)
  21753. */
  21754. bindableBlocks: NodeMaterialBlock[];
  21755. /**
  21756. * List of blocks that can provide a compilation fallback
  21757. */
  21758. blocksWithFallbacks: NodeMaterialBlock[];
  21759. /**
  21760. * List of blocks that can provide a define update
  21761. */
  21762. blocksWithDefines: NodeMaterialBlock[];
  21763. /**
  21764. * List of blocks that can provide a repeatable content
  21765. */
  21766. repeatableContentBlocks: NodeMaterialBlock[];
  21767. /**
  21768. * List of blocks that can provide a dynamic list of uniforms
  21769. */
  21770. dynamicUniformBlocks: NodeMaterialBlock[];
  21771. /**
  21772. * List of blocks that can block the isReady function for the material
  21773. */
  21774. blockingBlocks: NodeMaterialBlock[];
  21775. /**
  21776. * Gets the list of animated inputs
  21777. */
  21778. animatedInputs: InputBlock[];
  21779. /**
  21780. * Build Id used to avoid multiple recompilations
  21781. */
  21782. buildId: number;
  21783. /** List of emitted variables */
  21784. variableNames: {
  21785. [key: string]: number;
  21786. };
  21787. /** List of emitted defines */
  21788. defineNames: {
  21789. [key: string]: number;
  21790. };
  21791. /** Should emit comments? */
  21792. emitComments: boolean;
  21793. /** Emit build activity */
  21794. verbose: boolean;
  21795. /** Gets or sets the hosting scene */
  21796. scene: Scene;
  21797. /**
  21798. * Gets the compilation hints emitted at compilation time
  21799. */
  21800. hints: {
  21801. needWorldViewMatrix: boolean;
  21802. needWorldViewProjectionMatrix: boolean;
  21803. needAlphaBlending: boolean;
  21804. needAlphaTesting: boolean;
  21805. };
  21806. /**
  21807. * List of compilation checks
  21808. */
  21809. checks: {
  21810. emitVertex: boolean;
  21811. emitFragment: boolean;
  21812. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21813. };
  21814. /**
  21815. * Is vertex program allowed to be empty?
  21816. */
  21817. allowEmptyVertexProgram: boolean;
  21818. /** Creates a new shared data */
  21819. constructor();
  21820. /**
  21821. * Emits console errors and exceptions if there is a failing check
  21822. */
  21823. emitErrors(): void;
  21824. }
  21825. }
  21826. declare module BABYLON {
  21827. /**
  21828. * Class used to store node based material build state
  21829. */
  21830. export class NodeMaterialBuildState {
  21831. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21832. supportUniformBuffers: boolean;
  21833. /**
  21834. * Gets the list of emitted attributes
  21835. */
  21836. attributes: string[];
  21837. /**
  21838. * Gets the list of emitted uniforms
  21839. */
  21840. uniforms: string[];
  21841. /**
  21842. * Gets the list of emitted constants
  21843. */
  21844. constants: string[];
  21845. /**
  21846. * Gets the list of emitted samplers
  21847. */
  21848. samplers: string[];
  21849. /**
  21850. * Gets the list of emitted functions
  21851. */
  21852. functions: {
  21853. [key: string]: string;
  21854. };
  21855. /**
  21856. * Gets the list of emitted extensions
  21857. */
  21858. extensions: {
  21859. [key: string]: string;
  21860. };
  21861. /**
  21862. * Gets the target of the compilation state
  21863. */
  21864. target: NodeMaterialBlockTargets;
  21865. /**
  21866. * Gets the list of emitted counters
  21867. */
  21868. counters: {
  21869. [key: string]: number;
  21870. };
  21871. /**
  21872. * Shared data between multiple NodeMaterialBuildState instances
  21873. */
  21874. sharedData: NodeMaterialBuildStateSharedData;
  21875. /** @hidden */
  21876. _vertexState: NodeMaterialBuildState;
  21877. /** @hidden */
  21878. _attributeDeclaration: string;
  21879. /** @hidden */
  21880. _uniformDeclaration: string;
  21881. /** @hidden */
  21882. _constantDeclaration: string;
  21883. /** @hidden */
  21884. _samplerDeclaration: string;
  21885. /** @hidden */
  21886. _varyingTransfer: string;
  21887. /** @hidden */
  21888. _injectAtEnd: string;
  21889. private _repeatableContentAnchorIndex;
  21890. /** @hidden */
  21891. _builtCompilationString: string;
  21892. /**
  21893. * Gets the emitted compilation strings
  21894. */
  21895. compilationString: string;
  21896. /**
  21897. * Finalize the compilation strings
  21898. * @param state defines the current compilation state
  21899. */
  21900. finalize(state: NodeMaterialBuildState): void;
  21901. /** @hidden */
  21902. get _repeatableContentAnchor(): string;
  21903. /** @hidden */
  21904. _getFreeVariableName(prefix: string): string;
  21905. /** @hidden */
  21906. _getFreeDefineName(prefix: string): string;
  21907. /** @hidden */
  21908. _excludeVariableName(name: string): void;
  21909. /** @hidden */
  21910. _emit2DSampler(name: string): void;
  21911. /** @hidden */
  21912. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21913. /** @hidden */
  21914. _emitExtension(name: string, extension: string, define?: string): void;
  21915. /** @hidden */
  21916. _emitFunction(name: string, code: string, comments: string): void;
  21917. /** @hidden */
  21918. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21919. replaceStrings?: {
  21920. search: RegExp;
  21921. replace: string;
  21922. }[];
  21923. repeatKey?: string;
  21924. }): string;
  21925. /** @hidden */
  21926. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21927. repeatKey?: string;
  21928. removeAttributes?: boolean;
  21929. removeUniforms?: boolean;
  21930. removeVaryings?: boolean;
  21931. removeIfDef?: boolean;
  21932. replaceStrings?: {
  21933. search: RegExp;
  21934. replace: string;
  21935. }[];
  21936. }, storeKey?: string): void;
  21937. /** @hidden */
  21938. _registerTempVariable(name: string): boolean;
  21939. /** @hidden */
  21940. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21941. /** @hidden */
  21942. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21943. /** @hidden */
  21944. _emitFloat(value: number): string;
  21945. }
  21946. }
  21947. declare module BABYLON {
  21948. /**
  21949. * Helper class used to generate session unique ID
  21950. */
  21951. export class UniqueIdGenerator {
  21952. private static _UniqueIdCounter;
  21953. /**
  21954. * Gets an unique (relatively to the current scene) Id
  21955. */
  21956. static get UniqueId(): number;
  21957. }
  21958. }
  21959. declare module BABYLON {
  21960. /**
  21961. * Defines a block that can be used inside a node based material
  21962. */
  21963. export class NodeMaterialBlock {
  21964. private _buildId;
  21965. private _buildTarget;
  21966. private _target;
  21967. private _isFinalMerger;
  21968. private _isInput;
  21969. private _name;
  21970. protected _isUnique: boolean;
  21971. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21972. inputsAreExclusive: boolean;
  21973. /** @hidden */
  21974. _codeVariableName: string;
  21975. /** @hidden */
  21976. _inputs: NodeMaterialConnectionPoint[];
  21977. /** @hidden */
  21978. _outputs: NodeMaterialConnectionPoint[];
  21979. /** @hidden */
  21980. _preparationId: number;
  21981. /**
  21982. * Gets the name of the block
  21983. */
  21984. get name(): string;
  21985. /**
  21986. * Sets the name of the block. Will check if the name is valid.
  21987. */
  21988. set name(newName: string);
  21989. /**
  21990. * Gets or sets the unique id of the node
  21991. */
  21992. uniqueId: number;
  21993. /**
  21994. * Gets or sets the comments associated with this block
  21995. */
  21996. comments: string;
  21997. /**
  21998. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21999. */
  22000. get isUnique(): boolean;
  22001. /**
  22002. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22003. */
  22004. get isFinalMerger(): boolean;
  22005. /**
  22006. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22007. */
  22008. get isInput(): boolean;
  22009. /**
  22010. * Gets or sets the build Id
  22011. */
  22012. get buildId(): number;
  22013. set buildId(value: number);
  22014. /**
  22015. * Gets or sets the target of the block
  22016. */
  22017. get target(): NodeMaterialBlockTargets;
  22018. set target(value: NodeMaterialBlockTargets);
  22019. /**
  22020. * Gets the list of input points
  22021. */
  22022. get inputs(): NodeMaterialConnectionPoint[];
  22023. /** Gets the list of output points */
  22024. get outputs(): NodeMaterialConnectionPoint[];
  22025. /**
  22026. * Find an input by its name
  22027. * @param name defines the name of the input to look for
  22028. * @returns the input or null if not found
  22029. */
  22030. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22031. /**
  22032. * Find an output by its name
  22033. * @param name defines the name of the outputto look for
  22034. * @returns the output or null if not found
  22035. */
  22036. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22037. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  22038. visibleInInspector: boolean;
  22039. /**
  22040. * Creates a new NodeMaterialBlock
  22041. * @param name defines the block name
  22042. * @param target defines the target of that block (Vertex by default)
  22043. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22044. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22045. */
  22046. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22047. /**
  22048. * Initialize the block and prepare the context for build
  22049. * @param state defines the state that will be used for the build
  22050. */
  22051. initialize(state: NodeMaterialBuildState): void;
  22052. /**
  22053. * Bind data to effect. Will only be called for blocks with isBindable === true
  22054. * @param effect defines the effect to bind data to
  22055. * @param nodeMaterial defines the hosting NodeMaterial
  22056. * @param mesh defines the mesh that will be rendered
  22057. * @param subMesh defines the submesh that will be rendered
  22058. */
  22059. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22060. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22061. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22062. protected _writeFloat(value: number): string;
  22063. /**
  22064. * Gets the current class name e.g. "NodeMaterialBlock"
  22065. * @returns the class name
  22066. */
  22067. getClassName(): string;
  22068. /**
  22069. * Register a new input. Must be called inside a block constructor
  22070. * @param name defines the connection point name
  22071. * @param type defines the connection point type
  22072. * @param isOptional defines a boolean indicating that this input can be omitted
  22073. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22074. * @param point an already created connection point. If not provided, create a new one
  22075. * @returns the current block
  22076. */
  22077. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22078. /**
  22079. * Register a new output. Must be called inside a block constructor
  22080. * @param name defines the connection point name
  22081. * @param type defines the connection point type
  22082. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22083. * @param point an already created connection point. If not provided, create a new one
  22084. * @returns the current block
  22085. */
  22086. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22087. /**
  22088. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22089. * @param forOutput defines an optional connection point to check compatibility with
  22090. * @returns the first available input or null
  22091. */
  22092. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22093. /**
  22094. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22095. * @param forBlock defines an optional block to check compatibility with
  22096. * @returns the first available input or null
  22097. */
  22098. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22099. /**
  22100. * Gets the sibling of the given output
  22101. * @param current defines the current output
  22102. * @returns the next output in the list or null
  22103. */
  22104. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22105. /**
  22106. * Connect current block with another block
  22107. * @param other defines the block to connect with
  22108. * @param options define the various options to help pick the right connections
  22109. * @returns the current block
  22110. */
  22111. connectTo(other: NodeMaterialBlock, options?: {
  22112. input?: string;
  22113. output?: string;
  22114. outputSwizzle?: string;
  22115. }): this | undefined;
  22116. protected _buildBlock(state: NodeMaterialBuildState): void;
  22117. /**
  22118. * Add uniforms, samplers and uniform buffers at compilation time
  22119. * @param state defines the state to update
  22120. * @param nodeMaterial defines the node material requesting the update
  22121. * @param defines defines the material defines to update
  22122. * @param uniformBuffers defines the list of uniform buffer names
  22123. */
  22124. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22125. /**
  22126. * Add potential fallbacks if shader compilation fails
  22127. * @param mesh defines the mesh to be rendered
  22128. * @param fallbacks defines the current prioritized list of fallbacks
  22129. */
  22130. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22131. /**
  22132. * Initialize defines for shader compilation
  22133. * @param mesh defines the mesh to be rendered
  22134. * @param nodeMaterial defines the node material requesting the update
  22135. * @param defines defines the material defines to update
  22136. * @param useInstances specifies that instances should be used
  22137. */
  22138. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22139. /**
  22140. * Update defines for shader compilation
  22141. * @param mesh defines the mesh to be rendered
  22142. * @param nodeMaterial defines the node material requesting the update
  22143. * @param defines defines the material defines to update
  22144. * @param useInstances specifies that instances should be used
  22145. * @param subMesh defines which submesh to render
  22146. */
  22147. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22148. /**
  22149. * Lets the block try to connect some inputs automatically
  22150. * @param material defines the hosting NodeMaterial
  22151. */
  22152. autoConfigure(material: NodeMaterial): void;
  22153. /**
  22154. * Function called when a block is declared as repeatable content generator
  22155. * @param vertexShaderState defines the current compilation state for the vertex shader
  22156. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22157. * @param mesh defines the mesh to be rendered
  22158. * @param defines defines the material defines to update
  22159. */
  22160. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22161. /**
  22162. * Checks if the block is ready
  22163. * @param mesh defines the mesh to be rendered
  22164. * @param nodeMaterial defines the node material requesting the update
  22165. * @param defines defines the material defines to update
  22166. * @param useInstances specifies that instances should be used
  22167. * @returns true if the block is ready
  22168. */
  22169. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22170. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22171. private _processBuild;
  22172. /**
  22173. * Validates the new name for the block node.
  22174. * @param newName the new name to be given to the node.
  22175. * @returns false if the name is a reserve word, else true.
  22176. */
  22177. validateBlockName(newName: string): boolean;
  22178. /**
  22179. * Compile the current node and generate the shader code
  22180. * @param state defines the current compilation state (uniforms, samplers, current string)
  22181. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22182. * @returns true if already built
  22183. */
  22184. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22185. protected _inputRename(name: string): string;
  22186. protected _outputRename(name: string): string;
  22187. protected _dumpPropertiesCode(): string;
  22188. /** @hidden */
  22189. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22190. /** @hidden */
  22191. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22192. /**
  22193. * Clone the current block to a new identical block
  22194. * @param scene defines the hosting scene
  22195. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22196. * @returns a copy of the current block
  22197. */
  22198. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22199. /**
  22200. * Serializes this block in a JSON representation
  22201. * @returns the serialized block object
  22202. */
  22203. serialize(): any;
  22204. /** @hidden */
  22205. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22206. private _deserializePortDisplayNamesAndExposedOnFrame;
  22207. /**
  22208. * Release resources
  22209. */
  22210. dispose(): void;
  22211. }
  22212. }
  22213. declare module BABYLON {
  22214. /**
  22215. * Base class of materials working in push mode in babylon JS
  22216. * @hidden
  22217. */
  22218. export class PushMaterial extends Material {
  22219. protected _activeEffect: Effect;
  22220. protected _normalMatrix: Matrix;
  22221. constructor(name: string, scene: Scene);
  22222. getEffect(): Effect;
  22223. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22224. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22225. /**
  22226. * Binds the given world matrix to the active effect
  22227. *
  22228. * @param world the matrix to bind
  22229. */
  22230. bindOnlyWorldMatrix(world: Matrix): void;
  22231. /**
  22232. * Binds the given normal matrix to the active effect
  22233. *
  22234. * @param normalMatrix the matrix to bind
  22235. */
  22236. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22237. bind(world: Matrix, mesh?: Mesh): void;
  22238. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22239. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22240. }
  22241. }
  22242. declare module BABYLON {
  22243. /**
  22244. * Root class for all node material optimizers
  22245. */
  22246. export class NodeMaterialOptimizer {
  22247. /**
  22248. * Function used to optimize a NodeMaterial graph
  22249. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22250. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22251. */
  22252. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22253. }
  22254. }
  22255. declare module BABYLON {
  22256. /**
  22257. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22258. */
  22259. export class TransformBlock extends NodeMaterialBlock {
  22260. /**
  22261. * Defines the value to use to complement W value to transform it to a Vector4
  22262. */
  22263. complementW: number;
  22264. /**
  22265. * Defines the value to use to complement z value to transform it to a Vector4
  22266. */
  22267. complementZ: number;
  22268. /**
  22269. * Creates a new TransformBlock
  22270. * @param name defines the block name
  22271. */
  22272. constructor(name: string);
  22273. /**
  22274. * Gets the current class name
  22275. * @returns the class name
  22276. */
  22277. getClassName(): string;
  22278. /**
  22279. * Gets the vector input
  22280. */
  22281. get vector(): NodeMaterialConnectionPoint;
  22282. /**
  22283. * Gets the output component
  22284. */
  22285. get output(): NodeMaterialConnectionPoint;
  22286. /**
  22287. * Gets the xyz output component
  22288. */
  22289. get xyz(): NodeMaterialConnectionPoint;
  22290. /**
  22291. * Gets the matrix transform input
  22292. */
  22293. get transform(): NodeMaterialConnectionPoint;
  22294. protected _buildBlock(state: NodeMaterialBuildState): this;
  22295. /**
  22296. * Update defines for shader compilation
  22297. * @param mesh defines the mesh to be rendered
  22298. * @param nodeMaterial defines the node material requesting the update
  22299. * @param defines defines the material defines to update
  22300. * @param useInstances specifies that instances should be used
  22301. * @param subMesh defines which submesh to render
  22302. */
  22303. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22304. serialize(): any;
  22305. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22306. protected _dumpPropertiesCode(): string;
  22307. }
  22308. }
  22309. declare module BABYLON {
  22310. /**
  22311. * Block used to output the vertex position
  22312. */
  22313. export class VertexOutputBlock extends NodeMaterialBlock {
  22314. /**
  22315. * Creates a new VertexOutputBlock
  22316. * @param name defines the block name
  22317. */
  22318. constructor(name: string);
  22319. /**
  22320. * Gets the current class name
  22321. * @returns the class name
  22322. */
  22323. getClassName(): string;
  22324. /**
  22325. * Gets the vector input component
  22326. */
  22327. get vector(): NodeMaterialConnectionPoint;
  22328. protected _buildBlock(state: NodeMaterialBuildState): this;
  22329. }
  22330. }
  22331. declare module BABYLON {
  22332. /**
  22333. * Block used to output the final color
  22334. */
  22335. export class FragmentOutputBlock extends NodeMaterialBlock {
  22336. /**
  22337. * Create a new FragmentOutputBlock
  22338. * @param name defines the block name
  22339. */
  22340. constructor(name: string);
  22341. /**
  22342. * Gets the current class name
  22343. * @returns the class name
  22344. */
  22345. getClassName(): string;
  22346. /**
  22347. * Gets the rgba input component
  22348. */
  22349. get rgba(): NodeMaterialConnectionPoint;
  22350. /**
  22351. * Gets the rgb input component
  22352. */
  22353. get rgb(): NodeMaterialConnectionPoint;
  22354. /**
  22355. * Gets the a input component
  22356. */
  22357. get a(): NodeMaterialConnectionPoint;
  22358. protected _buildBlock(state: NodeMaterialBuildState): this;
  22359. }
  22360. }
  22361. declare module BABYLON {
  22362. /**
  22363. * Block used for the particle ramp gradient section
  22364. */
  22365. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22366. /**
  22367. * Create a new ParticleRampGradientBlock
  22368. * @param name defines the block name
  22369. */
  22370. constructor(name: string);
  22371. /**
  22372. * Gets the current class name
  22373. * @returns the class name
  22374. */
  22375. getClassName(): string;
  22376. /**
  22377. * Gets the color input component
  22378. */
  22379. get color(): NodeMaterialConnectionPoint;
  22380. /**
  22381. * Gets the rampColor output component
  22382. */
  22383. get rampColor(): NodeMaterialConnectionPoint;
  22384. /**
  22385. * Initialize the block and prepare the context for build
  22386. * @param state defines the state that will be used for the build
  22387. */
  22388. initialize(state: NodeMaterialBuildState): void;
  22389. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22390. }
  22391. }
  22392. declare module BABYLON {
  22393. /**
  22394. * Block used for the particle blend multiply section
  22395. */
  22396. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22397. /**
  22398. * Create a new ParticleBlendMultiplyBlock
  22399. * @param name defines the block name
  22400. */
  22401. constructor(name: string);
  22402. /**
  22403. * Gets the current class name
  22404. * @returns the class name
  22405. */
  22406. getClassName(): string;
  22407. /**
  22408. * Gets the color input component
  22409. */
  22410. get color(): NodeMaterialConnectionPoint;
  22411. /**
  22412. * Gets the alphaTexture input component
  22413. */
  22414. get alphaTexture(): NodeMaterialConnectionPoint;
  22415. /**
  22416. * Gets the alphaColor input component
  22417. */
  22418. get alphaColor(): NodeMaterialConnectionPoint;
  22419. /**
  22420. * Gets the blendColor output component
  22421. */
  22422. get blendColor(): NodeMaterialConnectionPoint;
  22423. /**
  22424. * Initialize the block and prepare the context for build
  22425. * @param state defines the state that will be used for the build
  22426. */
  22427. initialize(state: NodeMaterialBuildState): void;
  22428. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22429. }
  22430. }
  22431. declare module BABYLON {
  22432. /**
  22433. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22434. */
  22435. export class VectorMergerBlock extends NodeMaterialBlock {
  22436. /**
  22437. * Create a new VectorMergerBlock
  22438. * @param name defines the block name
  22439. */
  22440. constructor(name: string);
  22441. /**
  22442. * Gets the current class name
  22443. * @returns the class name
  22444. */
  22445. getClassName(): string;
  22446. /**
  22447. * Gets the xyz component (input)
  22448. */
  22449. get xyzIn(): NodeMaterialConnectionPoint;
  22450. /**
  22451. * Gets the xy component (input)
  22452. */
  22453. get xyIn(): NodeMaterialConnectionPoint;
  22454. /**
  22455. * Gets the x component (input)
  22456. */
  22457. get x(): NodeMaterialConnectionPoint;
  22458. /**
  22459. * Gets the y component (input)
  22460. */
  22461. get y(): NodeMaterialConnectionPoint;
  22462. /**
  22463. * Gets the z component (input)
  22464. */
  22465. get z(): NodeMaterialConnectionPoint;
  22466. /**
  22467. * Gets the w component (input)
  22468. */
  22469. get w(): NodeMaterialConnectionPoint;
  22470. /**
  22471. * Gets the xyzw component (output)
  22472. */
  22473. get xyzw(): NodeMaterialConnectionPoint;
  22474. /**
  22475. * Gets the xyz component (output)
  22476. */
  22477. get xyzOut(): NodeMaterialConnectionPoint;
  22478. /**
  22479. * Gets the xy component (output)
  22480. */
  22481. get xyOut(): NodeMaterialConnectionPoint;
  22482. /**
  22483. * Gets the xy component (output)
  22484. * @deprecated Please use xyOut instead.
  22485. */
  22486. get xy(): NodeMaterialConnectionPoint;
  22487. /**
  22488. * Gets the xyz component (output)
  22489. * @deprecated Please use xyzOut instead.
  22490. */
  22491. get xyz(): NodeMaterialConnectionPoint;
  22492. protected _buildBlock(state: NodeMaterialBuildState): this;
  22493. }
  22494. }
  22495. declare module BABYLON {
  22496. /**
  22497. * Block used to remap a float from a range to a new one
  22498. */
  22499. export class RemapBlock extends NodeMaterialBlock {
  22500. /**
  22501. * Gets or sets the source range
  22502. */
  22503. sourceRange: Vector2;
  22504. /**
  22505. * Gets or sets the target range
  22506. */
  22507. targetRange: Vector2;
  22508. /**
  22509. * Creates a new RemapBlock
  22510. * @param name defines the block name
  22511. */
  22512. constructor(name: string);
  22513. /**
  22514. * Gets the current class name
  22515. * @returns the class name
  22516. */
  22517. getClassName(): string;
  22518. /**
  22519. * Gets the input component
  22520. */
  22521. get input(): NodeMaterialConnectionPoint;
  22522. /**
  22523. * Gets the source min input component
  22524. */
  22525. get sourceMin(): NodeMaterialConnectionPoint;
  22526. /**
  22527. * Gets the source max input component
  22528. */
  22529. get sourceMax(): NodeMaterialConnectionPoint;
  22530. /**
  22531. * Gets the target min input component
  22532. */
  22533. get targetMin(): NodeMaterialConnectionPoint;
  22534. /**
  22535. * Gets the target max input component
  22536. */
  22537. get targetMax(): NodeMaterialConnectionPoint;
  22538. /**
  22539. * Gets the output component
  22540. */
  22541. get output(): NodeMaterialConnectionPoint;
  22542. protected _buildBlock(state: NodeMaterialBuildState): this;
  22543. protected _dumpPropertiesCode(): string;
  22544. serialize(): any;
  22545. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22546. }
  22547. }
  22548. declare module BABYLON {
  22549. /**
  22550. * Block used to multiply 2 values
  22551. */
  22552. export class MultiplyBlock extends NodeMaterialBlock {
  22553. /**
  22554. * Creates a new MultiplyBlock
  22555. * @param name defines the block name
  22556. */
  22557. constructor(name: string);
  22558. /**
  22559. * Gets the current class name
  22560. * @returns the class name
  22561. */
  22562. getClassName(): string;
  22563. /**
  22564. * Gets the left operand input component
  22565. */
  22566. get left(): NodeMaterialConnectionPoint;
  22567. /**
  22568. * Gets the right operand input component
  22569. */
  22570. get right(): NodeMaterialConnectionPoint;
  22571. /**
  22572. * Gets the output component
  22573. */
  22574. get output(): NodeMaterialConnectionPoint;
  22575. protected _buildBlock(state: NodeMaterialBuildState): this;
  22576. }
  22577. }
  22578. declare module BABYLON {
  22579. /**
  22580. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22581. */
  22582. export class ColorSplitterBlock extends NodeMaterialBlock {
  22583. /**
  22584. * Create a new ColorSplitterBlock
  22585. * @param name defines the block name
  22586. */
  22587. constructor(name: string);
  22588. /**
  22589. * Gets the current class name
  22590. * @returns the class name
  22591. */
  22592. getClassName(): string;
  22593. /**
  22594. * Gets the rgba component (input)
  22595. */
  22596. get rgba(): NodeMaterialConnectionPoint;
  22597. /**
  22598. * Gets the rgb component (input)
  22599. */
  22600. get rgbIn(): NodeMaterialConnectionPoint;
  22601. /**
  22602. * Gets the rgb component (output)
  22603. */
  22604. get rgbOut(): NodeMaterialConnectionPoint;
  22605. /**
  22606. * Gets the r component (output)
  22607. */
  22608. get r(): NodeMaterialConnectionPoint;
  22609. /**
  22610. * Gets the g component (output)
  22611. */
  22612. get g(): NodeMaterialConnectionPoint;
  22613. /**
  22614. * Gets the b component (output)
  22615. */
  22616. get b(): NodeMaterialConnectionPoint;
  22617. /**
  22618. * Gets the a component (output)
  22619. */
  22620. get a(): NodeMaterialConnectionPoint;
  22621. protected _inputRename(name: string): string;
  22622. protected _outputRename(name: string): string;
  22623. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22624. }
  22625. }
  22626. declare module BABYLON {
  22627. /**
  22628. * Operations supported by the Trigonometry block
  22629. */
  22630. export enum TrigonometryBlockOperations {
  22631. /** Cos */
  22632. Cos = 0,
  22633. /** Sin */
  22634. Sin = 1,
  22635. /** Abs */
  22636. Abs = 2,
  22637. /** Exp */
  22638. Exp = 3,
  22639. /** Exp2 */
  22640. Exp2 = 4,
  22641. /** Round */
  22642. Round = 5,
  22643. /** Floor */
  22644. Floor = 6,
  22645. /** Ceiling */
  22646. Ceiling = 7,
  22647. /** Square root */
  22648. Sqrt = 8,
  22649. /** Log */
  22650. Log = 9,
  22651. /** Tangent */
  22652. Tan = 10,
  22653. /** Arc tangent */
  22654. ArcTan = 11,
  22655. /** Arc cosinus */
  22656. ArcCos = 12,
  22657. /** Arc sinus */
  22658. ArcSin = 13,
  22659. /** Fraction */
  22660. Fract = 14,
  22661. /** Sign */
  22662. Sign = 15,
  22663. /** To radians (from degrees) */
  22664. Radians = 16,
  22665. /** To degrees (from radians) */
  22666. Degrees = 17
  22667. }
  22668. /**
  22669. * Block used to apply trigonometry operation to floats
  22670. */
  22671. export class TrigonometryBlock extends NodeMaterialBlock {
  22672. /**
  22673. * Gets or sets the operation applied by the block
  22674. */
  22675. operation: TrigonometryBlockOperations;
  22676. /**
  22677. * Creates a new TrigonometryBlock
  22678. * @param name defines the block name
  22679. */
  22680. constructor(name: string);
  22681. /**
  22682. * Gets the current class name
  22683. * @returns the class name
  22684. */
  22685. getClassName(): string;
  22686. /**
  22687. * Gets the input component
  22688. */
  22689. get input(): NodeMaterialConnectionPoint;
  22690. /**
  22691. * Gets the output component
  22692. */
  22693. get output(): NodeMaterialConnectionPoint;
  22694. protected _buildBlock(state: NodeMaterialBuildState): this;
  22695. serialize(): any;
  22696. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22697. protected _dumpPropertiesCode(): string;
  22698. }
  22699. }
  22700. declare module BABYLON {
  22701. /**
  22702. * Interface used to configure the node material editor
  22703. */
  22704. export interface INodeMaterialEditorOptions {
  22705. /** Define the URl to load node editor script */
  22706. editorURL?: string;
  22707. }
  22708. /** @hidden */
  22709. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22710. NORMAL: boolean;
  22711. TANGENT: boolean;
  22712. UV1: boolean;
  22713. /** BONES */
  22714. NUM_BONE_INFLUENCERS: number;
  22715. BonesPerMesh: number;
  22716. BONETEXTURE: boolean;
  22717. /** MORPH TARGETS */
  22718. MORPHTARGETS: boolean;
  22719. MORPHTARGETS_NORMAL: boolean;
  22720. MORPHTARGETS_TANGENT: boolean;
  22721. MORPHTARGETS_UV: boolean;
  22722. NUM_MORPH_INFLUENCERS: number;
  22723. /** IMAGE PROCESSING */
  22724. IMAGEPROCESSING: boolean;
  22725. VIGNETTE: boolean;
  22726. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22727. VIGNETTEBLENDMODEOPAQUE: boolean;
  22728. TONEMAPPING: boolean;
  22729. TONEMAPPING_ACES: boolean;
  22730. CONTRAST: boolean;
  22731. EXPOSURE: boolean;
  22732. COLORCURVES: boolean;
  22733. COLORGRADING: boolean;
  22734. COLORGRADING3D: boolean;
  22735. SAMPLER3DGREENDEPTH: boolean;
  22736. SAMPLER3DBGRMAP: boolean;
  22737. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22738. /** MISC. */
  22739. BUMPDIRECTUV: number;
  22740. constructor();
  22741. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22742. }
  22743. /**
  22744. * Class used to configure NodeMaterial
  22745. */
  22746. export interface INodeMaterialOptions {
  22747. /**
  22748. * Defines if blocks should emit comments
  22749. */
  22750. emitComments: boolean;
  22751. }
  22752. /**
  22753. * Class used to create a node based material built by assembling shader blocks
  22754. */
  22755. export class NodeMaterial extends PushMaterial {
  22756. private static _BuildIdGenerator;
  22757. private _options;
  22758. private _vertexCompilationState;
  22759. private _fragmentCompilationState;
  22760. private _sharedData;
  22761. private _buildId;
  22762. private _buildWasSuccessful;
  22763. private _cachedWorldViewMatrix;
  22764. private _cachedWorldViewProjectionMatrix;
  22765. private _optimizers;
  22766. private _animationFrame;
  22767. /** Define the Url to load node editor script */
  22768. static EditorURL: string;
  22769. /** Define the Url to load snippets */
  22770. static SnippetUrl: string;
  22771. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22772. static IgnoreTexturesAtLoadTime: boolean;
  22773. private BJSNODEMATERIALEDITOR;
  22774. /** Get the inspector from bundle or global */
  22775. private _getGlobalNodeMaterialEditor;
  22776. /**
  22777. * Snippet ID if the material was created from the snippet server
  22778. */
  22779. snippetId: string;
  22780. /**
  22781. * Gets or sets data used by visual editor
  22782. * @see https://nme.babylonjs.com
  22783. */
  22784. editorData: any;
  22785. /**
  22786. * 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)
  22787. */
  22788. ignoreAlpha: boolean;
  22789. /**
  22790. * Defines the maximum number of lights that can be used in the material
  22791. */
  22792. maxSimultaneousLights: number;
  22793. /**
  22794. * Observable raised when the material is built
  22795. */
  22796. onBuildObservable: Observable<NodeMaterial>;
  22797. /**
  22798. * Gets or sets the root nodes of the material vertex shader
  22799. */
  22800. _vertexOutputNodes: NodeMaterialBlock[];
  22801. /**
  22802. * Gets or sets the root nodes of the material fragment (pixel) shader
  22803. */
  22804. _fragmentOutputNodes: NodeMaterialBlock[];
  22805. /** Gets or sets options to control the node material overall behavior */
  22806. get options(): INodeMaterialOptions;
  22807. set options(options: INodeMaterialOptions);
  22808. /**
  22809. * Default configuration related to image processing available in the standard Material.
  22810. */
  22811. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22812. /**
  22813. * Gets the image processing configuration used either in this material.
  22814. */
  22815. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22816. /**
  22817. * Sets the Default image processing configuration used either in the this material.
  22818. *
  22819. * If sets to null, the scene one is in use.
  22820. */
  22821. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22822. /**
  22823. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22824. */
  22825. attachedBlocks: NodeMaterialBlock[];
  22826. /**
  22827. * Specifies the mode of the node material
  22828. * @hidden
  22829. */
  22830. _mode: NodeMaterialModes;
  22831. /**
  22832. * Gets the mode property
  22833. */
  22834. get mode(): NodeMaterialModes;
  22835. /**
  22836. * A free comment about the material
  22837. */
  22838. comment: string;
  22839. /**
  22840. * Create a new node based material
  22841. * @param name defines the material name
  22842. * @param scene defines the hosting scene
  22843. * @param options defines creation option
  22844. */
  22845. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22846. /**
  22847. * Gets the current class name of the material e.g. "NodeMaterial"
  22848. * @returns the class name
  22849. */
  22850. getClassName(): string;
  22851. /**
  22852. * Keep track of the image processing observer to allow dispose and replace.
  22853. */
  22854. private _imageProcessingObserver;
  22855. /**
  22856. * Attaches a new image processing configuration to the Standard Material.
  22857. * @param configuration
  22858. */
  22859. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22860. /**
  22861. * Get a block by its name
  22862. * @param name defines the name of the block to retrieve
  22863. * @returns the required block or null if not found
  22864. */
  22865. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22866. /**
  22867. * Get a block by its name
  22868. * @param predicate defines the predicate used to find the good candidate
  22869. * @returns the required block or null if not found
  22870. */
  22871. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22872. /**
  22873. * Get an input block by its name
  22874. * @param predicate defines the predicate used to find the good candidate
  22875. * @returns the required input block or null if not found
  22876. */
  22877. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22878. /**
  22879. * Gets the list of input blocks attached to this material
  22880. * @returns an array of InputBlocks
  22881. */
  22882. getInputBlocks(): InputBlock[];
  22883. /**
  22884. * Adds a new optimizer to the list of optimizers
  22885. * @param optimizer defines the optimizers to add
  22886. * @returns the current material
  22887. */
  22888. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22889. /**
  22890. * Remove an optimizer from the list of optimizers
  22891. * @param optimizer defines the optimizers to remove
  22892. * @returns the current material
  22893. */
  22894. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22895. /**
  22896. * Add a new block to the list of output nodes
  22897. * @param node defines the node to add
  22898. * @returns the current material
  22899. */
  22900. addOutputNode(node: NodeMaterialBlock): this;
  22901. /**
  22902. * Remove a block from the list of root nodes
  22903. * @param node defines the node to remove
  22904. * @returns the current material
  22905. */
  22906. removeOutputNode(node: NodeMaterialBlock): this;
  22907. private _addVertexOutputNode;
  22908. private _removeVertexOutputNode;
  22909. private _addFragmentOutputNode;
  22910. private _removeFragmentOutputNode;
  22911. /**
  22912. * Specifies if the material will require alpha blending
  22913. * @returns a boolean specifying if alpha blending is needed
  22914. */
  22915. needAlphaBlending(): boolean;
  22916. /**
  22917. * Specifies if this material should be rendered in alpha test mode
  22918. * @returns a boolean specifying if an alpha test is needed.
  22919. */
  22920. needAlphaTesting(): boolean;
  22921. private _initializeBlock;
  22922. private _resetDualBlocks;
  22923. /**
  22924. * Remove a block from the current node material
  22925. * @param block defines the block to remove
  22926. */
  22927. removeBlock(block: NodeMaterialBlock): void;
  22928. /**
  22929. * Build the material and generates the inner effect
  22930. * @param verbose defines if the build should log activity
  22931. */
  22932. build(verbose?: boolean): void;
  22933. /**
  22934. * Runs an otpimization phase to try to improve the shader code
  22935. */
  22936. optimize(): void;
  22937. private _prepareDefinesForAttributes;
  22938. /**
  22939. * Create a post process from the material
  22940. * @param camera The camera to apply the render pass to.
  22941. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22942. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22943. * @param engine The engine which the post process will be applied. (default: current engine)
  22944. * @param reusable If the post process can be reused on the same frame. (default: false)
  22945. * @param textureType Type of textures used when performing the post process. (default: 0)
  22946. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22947. * @returns the post process created
  22948. */
  22949. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  22950. /**
  22951. * Create the post process effect from the material
  22952. * @param postProcess The post process to create the effect for
  22953. */
  22954. createEffectForPostProcess(postProcess: PostProcess): void;
  22955. private _createEffectForPostProcess;
  22956. /**
  22957. * Create a new procedural texture based on this node material
  22958. * @param size defines the size of the texture
  22959. * @param scene defines the hosting scene
  22960. * @returns the new procedural texture attached to this node material
  22961. */
  22962. createProceduralTexture(size: number | {
  22963. width: number;
  22964. height: number;
  22965. layers?: number;
  22966. }, scene: Scene): Nullable<ProceduralTexture>;
  22967. private _createEffectForParticles;
  22968. private _checkInternals;
  22969. /**
  22970. * Create the effect to be used as the custom effect for a particle system
  22971. * @param particleSystem Particle system to create the effect for
  22972. * @param onCompiled defines a function to call when the effect creation is successful
  22973. * @param onError defines a function to call when the effect creation has failed
  22974. */
  22975. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22976. private _processDefines;
  22977. /**
  22978. * Get if the submesh is ready to be used and all its information available.
  22979. * Child classes can use it to update shaders
  22980. * @param mesh defines the mesh to check
  22981. * @param subMesh defines which submesh to check
  22982. * @param useInstances specifies that instances should be used
  22983. * @returns a boolean indicating that the submesh is ready or not
  22984. */
  22985. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22986. /**
  22987. * Get a string representing the shaders built by the current node graph
  22988. */
  22989. get compiledShaders(): string;
  22990. /**
  22991. * Binds the world matrix to the material
  22992. * @param world defines the world transformation matrix
  22993. */
  22994. bindOnlyWorldMatrix(world: Matrix): void;
  22995. /**
  22996. * Binds the submesh to this material by preparing the effect and shader to draw
  22997. * @param world defines the world transformation matrix
  22998. * @param mesh defines the mesh containing the submesh
  22999. * @param subMesh defines the submesh to bind the material to
  23000. */
  23001. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23002. /**
  23003. * Gets the active textures from the material
  23004. * @returns an array of textures
  23005. */
  23006. getActiveTextures(): BaseTexture[];
  23007. /**
  23008. * Gets the list of texture blocks
  23009. * @returns an array of texture blocks
  23010. */
  23011. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23012. /**
  23013. * Specifies if the material uses a texture
  23014. * @param texture defines the texture to check against the material
  23015. * @returns a boolean specifying if the material uses the texture
  23016. */
  23017. hasTexture(texture: BaseTexture): boolean;
  23018. /**
  23019. * Disposes the material
  23020. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23021. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23022. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23023. */
  23024. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23025. /** Creates the node editor window. */
  23026. private _createNodeEditor;
  23027. /**
  23028. * Launch the node material editor
  23029. * @param config Define the configuration of the editor
  23030. * @return a promise fulfilled when the node editor is visible
  23031. */
  23032. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23033. /**
  23034. * Clear the current material
  23035. */
  23036. clear(): void;
  23037. /**
  23038. * Clear the current material and set it to a default state
  23039. */
  23040. setToDefault(): void;
  23041. /**
  23042. * Clear the current material and set it to a default state for post process
  23043. */
  23044. setToDefaultPostProcess(): void;
  23045. /**
  23046. * Clear the current material and set it to a default state for procedural texture
  23047. */
  23048. setToDefaultProceduralTexture(): void;
  23049. /**
  23050. * Clear the current material and set it to a default state for particle
  23051. */
  23052. setToDefaultParticle(): void;
  23053. /**
  23054. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23055. * @param url defines the url to load from
  23056. * @returns a promise that will fullfil when the material is fully loaded
  23057. */
  23058. loadAsync(url: string): Promise<void>;
  23059. private _gatherBlocks;
  23060. /**
  23061. * Generate a string containing the code declaration required to create an equivalent of this material
  23062. * @returns a string
  23063. */
  23064. generateCode(): string;
  23065. /**
  23066. * Serializes this material in a JSON representation
  23067. * @returns the serialized material object
  23068. */
  23069. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23070. private _restoreConnections;
  23071. /**
  23072. * Clear the current graph and load a new one from a serialization object
  23073. * @param source defines the JSON representation of the material
  23074. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23075. * @param merge defines whether or not the source must be merged or replace the current content
  23076. */
  23077. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23078. /**
  23079. * Makes a duplicate of the current material.
  23080. * @param name - name to use for the new material.
  23081. */
  23082. clone(name: string): NodeMaterial;
  23083. /**
  23084. * Creates a node material from parsed material data
  23085. * @param source defines the JSON representation of the material
  23086. * @param scene defines the hosting scene
  23087. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23088. * @returns a new node material
  23089. */
  23090. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23091. /**
  23092. * Creates a node material from a snippet saved in a remote file
  23093. * @param name defines the name of the material to create
  23094. * @param url defines the url to load from
  23095. * @param scene defines the hosting scene
  23096. * @returns a promise that will resolve to the new node material
  23097. */
  23098. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23099. /**
  23100. * Creates a node material from a snippet saved by the node material editor
  23101. * @param snippetId defines the snippet to load
  23102. * @param scene defines the hosting scene
  23103. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23104. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23105. * @returns a promise that will resolve to the new node material
  23106. */
  23107. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23108. /**
  23109. * Creates a new node material set to default basic configuration
  23110. * @param name defines the name of the material
  23111. * @param scene defines the hosting scene
  23112. * @returns a new NodeMaterial
  23113. */
  23114. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23115. }
  23116. }
  23117. declare module BABYLON {
  23118. interface ThinEngine {
  23119. /**
  23120. * Unbind a list of render target textures from the webGL context
  23121. * This is used only when drawBuffer extension or webGL2 are active
  23122. * @param textures defines the render target textures to unbind
  23123. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  23124. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  23125. */
  23126. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  23127. /**
  23128. * Create a multi render target texture
  23129. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  23130. * @param size defines the size of the texture
  23131. * @param options defines the creation options
  23132. * @returns the cube texture as an InternalTexture
  23133. */
  23134. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  23135. /**
  23136. * Update the sample count for a given multiple render target texture
  23137. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  23138. * @param textures defines the textures to update
  23139. * @param samples defines the sample count to set
  23140. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  23141. */
  23142. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  23143. /**
  23144. * Select a subsets of attachments to draw to.
  23145. * @param attachments gl attachments
  23146. */
  23147. bindAttachments(attachments: number[]): void;
  23148. /**
  23149. * Creates a layout object to draw/clear on specific textures in a MRT
  23150. * @param textureStatus textureStatus[i] indicates if the i-th is active
  23151. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  23152. */
  23153. buildTextureLayout(textureStatus: boolean[]): number[];
  23154. /**
  23155. * Restores the webgl state to only draw on the main color attachment
  23156. */
  23157. restoreSingleAttachment(): void;
  23158. }
  23159. }
  23160. declare module BABYLON {
  23161. /**
  23162. * Creation options of the multi render target texture.
  23163. */
  23164. export interface IMultiRenderTargetOptions {
  23165. /**
  23166. * Define if the texture needs to create mip maps after render.
  23167. */
  23168. generateMipMaps?: boolean;
  23169. /**
  23170. * Define the types of all the draw buffers we want to create
  23171. */
  23172. types?: number[];
  23173. /**
  23174. * Define the sampling modes of all the draw buffers we want to create
  23175. */
  23176. samplingModes?: number[];
  23177. /**
  23178. * Define if a depth buffer is required
  23179. */
  23180. generateDepthBuffer?: boolean;
  23181. /**
  23182. * Define if a stencil buffer is required
  23183. */
  23184. generateStencilBuffer?: boolean;
  23185. /**
  23186. * Define if a depth texture is required instead of a depth buffer
  23187. */
  23188. generateDepthTexture?: boolean;
  23189. /**
  23190. * Define the number of desired draw buffers
  23191. */
  23192. textureCount?: number;
  23193. /**
  23194. * Define if aspect ratio should be adapted to the texture or stay the scene one
  23195. */
  23196. doNotChangeAspectRatio?: boolean;
  23197. /**
  23198. * Define the default type of the buffers we are creating
  23199. */
  23200. defaultType?: number;
  23201. }
  23202. /**
  23203. * A multi render target, like a render target provides the ability to render to a texture.
  23204. * Unlike the render target, it can render to several draw buffers in one draw.
  23205. * This is specially interesting in deferred rendering or for any effects requiring more than
  23206. * just one color from a single pass.
  23207. */
  23208. export class MultiRenderTarget extends RenderTargetTexture {
  23209. private _internalTextures;
  23210. private _textures;
  23211. private _multiRenderTargetOptions;
  23212. private _count;
  23213. /**
  23214. * Get if draw buffers are currently supported by the used hardware and browser.
  23215. */
  23216. get isSupported(): boolean;
  23217. /**
  23218. * Get the list of textures generated by the multi render target.
  23219. */
  23220. get textures(): Texture[];
  23221. /**
  23222. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  23223. */
  23224. get count(): number;
  23225. /**
  23226. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  23227. */
  23228. get depthTexture(): Texture;
  23229. /**
  23230. * Set the wrapping mode on U of all the textures we are rendering to.
  23231. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23232. */
  23233. set wrapU(wrap: number);
  23234. /**
  23235. * Set the wrapping mode on V of all the textures we are rendering to.
  23236. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23237. */
  23238. set wrapV(wrap: number);
  23239. /**
  23240. * Instantiate a new multi render target texture.
  23241. * A multi render target, like a render target provides the ability to render to a texture.
  23242. * Unlike the render target, it can render to several draw buffers in one draw.
  23243. * This is specially interesting in deferred rendering or for any effects requiring more than
  23244. * just one color from a single pass.
  23245. * @param name Define the name of the texture
  23246. * @param size Define the size of the buffers to render to
  23247. * @param count Define the number of target we are rendering into
  23248. * @param scene Define the scene the texture belongs to
  23249. * @param options Define the options used to create the multi render target
  23250. */
  23251. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  23252. private _initTypes;
  23253. /** @hidden */
  23254. _rebuild(forceFullRebuild?: boolean): void;
  23255. private _createInternalTextures;
  23256. private _createTextures;
  23257. /**
  23258. * Replaces a texture within the MRT.
  23259. * @param texture The new texture to insert in the MRT
  23260. * @param index The index of the texture to replace
  23261. */
  23262. replaceTexture(texture: Texture, index: number): void;
  23263. /**
  23264. * Define the number of samples used if MSAA is enabled.
  23265. */
  23266. get samples(): number;
  23267. set samples(value: number);
  23268. /**
  23269. * Resize all the textures in the multi render target.
  23270. * Be careful as it will recreate all the data in the new texture.
  23271. * @param size Define the new size
  23272. */
  23273. resize(size: any): void;
  23274. /**
  23275. * Changes the number of render targets in this MRT
  23276. * Be careful as it will recreate all the data in the new texture.
  23277. * @param count new texture count
  23278. * @param options Specifies texture types and sampling modes for new textures
  23279. */
  23280. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  23281. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23282. /**
  23283. * Dispose the render targets and their associated resources
  23284. */
  23285. dispose(): void;
  23286. /**
  23287. * Release all the underlying texture used as draw buffers.
  23288. */
  23289. releaseInternalTextures(): void;
  23290. }
  23291. }
  23292. declare module BABYLON {
  23293. /** @hidden */
  23294. export var imageProcessingPixelShader: {
  23295. name: string;
  23296. shader: string;
  23297. };
  23298. }
  23299. declare module BABYLON {
  23300. /**
  23301. * ImageProcessingPostProcess
  23302. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  23303. */
  23304. export class ImageProcessingPostProcess extends PostProcess {
  23305. /**
  23306. * Default configuration related to image processing available in the PBR Material.
  23307. */
  23308. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23309. /**
  23310. * Gets the image processing configuration used either in this material.
  23311. */
  23312. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23313. /**
  23314. * Sets the Default image processing configuration used either in the this material.
  23315. *
  23316. * If sets to null, the scene one is in use.
  23317. */
  23318. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23319. /**
  23320. * Keep track of the image processing observer to allow dispose and replace.
  23321. */
  23322. private _imageProcessingObserver;
  23323. /**
  23324. * Attaches a new image processing configuration to the PBR Material.
  23325. * @param configuration
  23326. */
  23327. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  23328. /**
  23329. * If the post process is supported.
  23330. */
  23331. get isSupported(): boolean;
  23332. /**
  23333. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23334. */
  23335. get colorCurves(): Nullable<ColorCurves>;
  23336. /**
  23337. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23338. */
  23339. set colorCurves(value: Nullable<ColorCurves>);
  23340. /**
  23341. * Gets wether the color curves effect is enabled.
  23342. */
  23343. get colorCurvesEnabled(): boolean;
  23344. /**
  23345. * Sets wether the color curves effect is enabled.
  23346. */
  23347. set colorCurvesEnabled(value: boolean);
  23348. /**
  23349. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23350. */
  23351. get colorGradingTexture(): Nullable<BaseTexture>;
  23352. /**
  23353. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23354. */
  23355. set colorGradingTexture(value: Nullable<BaseTexture>);
  23356. /**
  23357. * Gets wether the color grading effect is enabled.
  23358. */
  23359. get colorGradingEnabled(): boolean;
  23360. /**
  23361. * Gets wether the color grading effect is enabled.
  23362. */
  23363. set colorGradingEnabled(value: boolean);
  23364. /**
  23365. * Gets exposure used in the effect.
  23366. */
  23367. get exposure(): number;
  23368. /**
  23369. * Sets exposure used in the effect.
  23370. */
  23371. set exposure(value: number);
  23372. /**
  23373. * Gets wether tonemapping is enabled or not.
  23374. */
  23375. get toneMappingEnabled(): boolean;
  23376. /**
  23377. * Sets wether tonemapping is enabled or not
  23378. */
  23379. set toneMappingEnabled(value: boolean);
  23380. /**
  23381. * Gets the type of tone mapping effect.
  23382. */
  23383. get toneMappingType(): number;
  23384. /**
  23385. * Sets the type of tone mapping effect.
  23386. */
  23387. set toneMappingType(value: number);
  23388. /**
  23389. * Gets contrast used in the effect.
  23390. */
  23391. get contrast(): number;
  23392. /**
  23393. * Sets contrast used in the effect.
  23394. */
  23395. set contrast(value: number);
  23396. /**
  23397. * Gets Vignette stretch size.
  23398. */
  23399. get vignetteStretch(): number;
  23400. /**
  23401. * Sets Vignette stretch size.
  23402. */
  23403. set vignetteStretch(value: number);
  23404. /**
  23405. * Gets Vignette centre X Offset.
  23406. */
  23407. get vignetteCentreX(): number;
  23408. /**
  23409. * Sets Vignette centre X Offset.
  23410. */
  23411. set vignetteCentreX(value: number);
  23412. /**
  23413. * Gets Vignette centre Y Offset.
  23414. */
  23415. get vignetteCentreY(): number;
  23416. /**
  23417. * Sets Vignette centre Y Offset.
  23418. */
  23419. set vignetteCentreY(value: number);
  23420. /**
  23421. * Gets Vignette weight or intensity of the vignette effect.
  23422. */
  23423. get vignetteWeight(): number;
  23424. /**
  23425. * Sets Vignette weight or intensity of the vignette effect.
  23426. */
  23427. set vignetteWeight(value: number);
  23428. /**
  23429. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  23430. * if vignetteEnabled is set to true.
  23431. */
  23432. get vignetteColor(): Color4;
  23433. /**
  23434. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  23435. * if vignetteEnabled is set to true.
  23436. */
  23437. set vignetteColor(value: Color4);
  23438. /**
  23439. * Gets Camera field of view used by the Vignette effect.
  23440. */
  23441. get vignetteCameraFov(): number;
  23442. /**
  23443. * Sets Camera field of view used by the Vignette effect.
  23444. */
  23445. set vignetteCameraFov(value: number);
  23446. /**
  23447. * Gets the vignette blend mode allowing different kind of effect.
  23448. */
  23449. get vignetteBlendMode(): number;
  23450. /**
  23451. * Sets the vignette blend mode allowing different kind of effect.
  23452. */
  23453. set vignetteBlendMode(value: number);
  23454. /**
  23455. * Gets wether the vignette effect is enabled.
  23456. */
  23457. get vignetteEnabled(): boolean;
  23458. /**
  23459. * Sets wether the vignette effect is enabled.
  23460. */
  23461. set vignetteEnabled(value: boolean);
  23462. private _fromLinearSpace;
  23463. /**
  23464. * Gets wether the input of the processing is in Gamma or Linear Space.
  23465. */
  23466. get fromLinearSpace(): boolean;
  23467. /**
  23468. * Sets wether the input of the processing is in Gamma or Linear Space.
  23469. */
  23470. set fromLinearSpace(value: boolean);
  23471. /**
  23472. * Defines cache preventing GC.
  23473. */
  23474. private _defines;
  23475. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  23476. /**
  23477. * "ImageProcessingPostProcess"
  23478. * @returns "ImageProcessingPostProcess"
  23479. */
  23480. getClassName(): string;
  23481. /**
  23482. * @hidden
  23483. */
  23484. _updateParameters(): void;
  23485. dispose(camera?: Camera): void;
  23486. }
  23487. }
  23488. declare module BABYLON {
  23489. /**
  23490. * Interface for defining prepass effects in the prepass post-process pipeline
  23491. */
  23492. export interface PrePassEffectConfiguration {
  23493. /**
  23494. * Name of the effect
  23495. */
  23496. name: string;
  23497. /**
  23498. * Post process to attach for this effect
  23499. */
  23500. postProcess?: PostProcess;
  23501. /**
  23502. * Textures required in the MRT
  23503. */
  23504. texturesRequired: number[];
  23505. /**
  23506. * Is the effect enabled
  23507. */
  23508. enabled: boolean;
  23509. /**
  23510. * Disposes the effect configuration
  23511. */
  23512. dispose?: () => void;
  23513. /**
  23514. * Creates the associated post process
  23515. */
  23516. createPostProcess?: () => PostProcess;
  23517. }
  23518. }
  23519. declare module BABYLON {
  23520. /**
  23521. * Options to be used when creating a FresnelParameters.
  23522. */
  23523. export type IFresnelParametersCreationOptions = {
  23524. /**
  23525. * Define the color used on edges (grazing angle)
  23526. */
  23527. leftColor?: Color3;
  23528. /**
  23529. * Define the color used on center
  23530. */
  23531. rightColor?: Color3;
  23532. /**
  23533. * Define bias applied to computed fresnel term
  23534. */
  23535. bias?: number;
  23536. /**
  23537. * Defined the power exponent applied to fresnel term
  23538. */
  23539. power?: number;
  23540. /**
  23541. * Define if the fresnel effect is enable or not.
  23542. */
  23543. isEnabled?: boolean;
  23544. };
  23545. /**
  23546. * Serialized format for FresnelParameters.
  23547. */
  23548. export type IFresnelParametersSerialized = {
  23549. /**
  23550. * Define the color used on edges (grazing angle) [as an array]
  23551. */
  23552. leftColor: number[];
  23553. /**
  23554. * Define the color used on center [as an array]
  23555. */
  23556. rightColor: number[];
  23557. /**
  23558. * Define bias applied to computed fresnel term
  23559. */
  23560. bias: number;
  23561. /**
  23562. * Defined the power exponent applied to fresnel term
  23563. */
  23564. power?: number;
  23565. /**
  23566. * Define if the fresnel effect is enable or not.
  23567. */
  23568. isEnabled: boolean;
  23569. };
  23570. /**
  23571. * This represents all the required information to add a fresnel effect on a material:
  23572. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  23573. */
  23574. export class FresnelParameters {
  23575. private _isEnabled;
  23576. /**
  23577. * Define if the fresnel effect is enable or not.
  23578. */
  23579. get isEnabled(): boolean;
  23580. set isEnabled(value: boolean);
  23581. /**
  23582. * Define the color used on edges (grazing angle)
  23583. */
  23584. leftColor: Color3;
  23585. /**
  23586. * Define the color used on center
  23587. */
  23588. rightColor: Color3;
  23589. /**
  23590. * Define bias applied to computed fresnel term
  23591. */
  23592. bias: number;
  23593. /**
  23594. * Defined the power exponent applied to fresnel term
  23595. */
  23596. power: number;
  23597. /**
  23598. * Creates a new FresnelParameters object.
  23599. *
  23600. * @param options provide your own settings to optionally to override defaults
  23601. */
  23602. constructor(options?: IFresnelParametersCreationOptions);
  23603. /**
  23604. * Clones the current fresnel and its valuues
  23605. * @returns a clone fresnel configuration
  23606. */
  23607. clone(): FresnelParameters;
  23608. /**
  23609. * Determines equality between FresnelParameters objects
  23610. * @param otherFresnelParameters defines the second operand
  23611. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  23612. */
  23613. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  23614. /**
  23615. * Serializes the current fresnel parameters to a JSON representation.
  23616. * @return the JSON serialization
  23617. */
  23618. serialize(): IFresnelParametersSerialized;
  23619. /**
  23620. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  23621. * @param parsedFresnelParameters Define the JSON representation
  23622. * @returns the parsed parameters
  23623. */
  23624. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  23625. }
  23626. }
  23627. declare module BABYLON {
  23628. /**
  23629. * This groups all the flags used to control the materials channel.
  23630. */
  23631. export class MaterialFlags {
  23632. private static _DiffuseTextureEnabled;
  23633. /**
  23634. * Are diffuse textures enabled in the application.
  23635. */
  23636. static get DiffuseTextureEnabled(): boolean;
  23637. static set DiffuseTextureEnabled(value: boolean);
  23638. private static _DetailTextureEnabled;
  23639. /**
  23640. * Are detail textures enabled in the application.
  23641. */
  23642. static get DetailTextureEnabled(): boolean;
  23643. static set DetailTextureEnabled(value: boolean);
  23644. private static _AmbientTextureEnabled;
  23645. /**
  23646. * Are ambient textures enabled in the application.
  23647. */
  23648. static get AmbientTextureEnabled(): boolean;
  23649. static set AmbientTextureEnabled(value: boolean);
  23650. private static _OpacityTextureEnabled;
  23651. /**
  23652. * Are opacity textures enabled in the application.
  23653. */
  23654. static get OpacityTextureEnabled(): boolean;
  23655. static set OpacityTextureEnabled(value: boolean);
  23656. private static _ReflectionTextureEnabled;
  23657. /**
  23658. * Are reflection textures enabled in the application.
  23659. */
  23660. static get ReflectionTextureEnabled(): boolean;
  23661. static set ReflectionTextureEnabled(value: boolean);
  23662. private static _EmissiveTextureEnabled;
  23663. /**
  23664. * Are emissive textures enabled in the application.
  23665. */
  23666. static get EmissiveTextureEnabled(): boolean;
  23667. static set EmissiveTextureEnabled(value: boolean);
  23668. private static _SpecularTextureEnabled;
  23669. /**
  23670. * Are specular textures enabled in the application.
  23671. */
  23672. static get SpecularTextureEnabled(): boolean;
  23673. static set SpecularTextureEnabled(value: boolean);
  23674. private static _BumpTextureEnabled;
  23675. /**
  23676. * Are bump textures enabled in the application.
  23677. */
  23678. static get BumpTextureEnabled(): boolean;
  23679. static set BumpTextureEnabled(value: boolean);
  23680. private static _LightmapTextureEnabled;
  23681. /**
  23682. * Are lightmap textures enabled in the application.
  23683. */
  23684. static get LightmapTextureEnabled(): boolean;
  23685. static set LightmapTextureEnabled(value: boolean);
  23686. private static _RefractionTextureEnabled;
  23687. /**
  23688. * Are refraction textures enabled in the application.
  23689. */
  23690. static get RefractionTextureEnabled(): boolean;
  23691. static set RefractionTextureEnabled(value: boolean);
  23692. private static _ColorGradingTextureEnabled;
  23693. /**
  23694. * Are color grading textures enabled in the application.
  23695. */
  23696. static get ColorGradingTextureEnabled(): boolean;
  23697. static set ColorGradingTextureEnabled(value: boolean);
  23698. private static _FresnelEnabled;
  23699. /**
  23700. * Are fresnels enabled in the application.
  23701. */
  23702. static get FresnelEnabled(): boolean;
  23703. static set FresnelEnabled(value: boolean);
  23704. private static _ClearCoatTextureEnabled;
  23705. /**
  23706. * Are clear coat textures enabled in the application.
  23707. */
  23708. static get ClearCoatTextureEnabled(): boolean;
  23709. static set ClearCoatTextureEnabled(value: boolean);
  23710. private static _ClearCoatBumpTextureEnabled;
  23711. /**
  23712. * Are clear coat bump textures enabled in the application.
  23713. */
  23714. static get ClearCoatBumpTextureEnabled(): boolean;
  23715. static set ClearCoatBumpTextureEnabled(value: boolean);
  23716. private static _ClearCoatTintTextureEnabled;
  23717. /**
  23718. * Are clear coat tint textures enabled in the application.
  23719. */
  23720. static get ClearCoatTintTextureEnabled(): boolean;
  23721. static set ClearCoatTintTextureEnabled(value: boolean);
  23722. private static _SheenTextureEnabled;
  23723. /**
  23724. * Are sheen textures enabled in the application.
  23725. */
  23726. static get SheenTextureEnabled(): boolean;
  23727. static set SheenTextureEnabled(value: boolean);
  23728. private static _AnisotropicTextureEnabled;
  23729. /**
  23730. * Are anisotropic textures enabled in the application.
  23731. */
  23732. static get AnisotropicTextureEnabled(): boolean;
  23733. static set AnisotropicTextureEnabled(value: boolean);
  23734. private static _ThicknessTextureEnabled;
  23735. /**
  23736. * Are thickness textures enabled in the application.
  23737. */
  23738. static get ThicknessTextureEnabled(): boolean;
  23739. static set ThicknessTextureEnabled(value: boolean);
  23740. }
  23741. }
  23742. declare module BABYLON {
  23743. /** @hidden */
  23744. export var defaultFragmentDeclaration: {
  23745. name: string;
  23746. shader: string;
  23747. };
  23748. }
  23749. declare module BABYLON {
  23750. /** @hidden */
  23751. export var defaultUboDeclaration: {
  23752. name: string;
  23753. shader: string;
  23754. };
  23755. }
  23756. declare module BABYLON {
  23757. /** @hidden */
  23758. export var prePassDeclaration: {
  23759. name: string;
  23760. shader: string;
  23761. };
  23762. }
  23763. declare module BABYLON {
  23764. /** @hidden */
  23765. export var lightFragmentDeclaration: {
  23766. name: string;
  23767. shader: string;
  23768. };
  23769. }
  23770. declare module BABYLON {
  23771. /** @hidden */
  23772. export var lightUboDeclaration: {
  23773. name: string;
  23774. shader: string;
  23775. };
  23776. }
  23777. declare module BABYLON {
  23778. /** @hidden */
  23779. export var lightsFragmentFunctions: {
  23780. name: string;
  23781. shader: string;
  23782. };
  23783. }
  23784. declare module BABYLON {
  23785. /** @hidden */
  23786. export var shadowsFragmentFunctions: {
  23787. name: string;
  23788. shader: string;
  23789. };
  23790. }
  23791. declare module BABYLON {
  23792. /** @hidden */
  23793. export var fresnelFunction: {
  23794. name: string;
  23795. shader: string;
  23796. };
  23797. }
  23798. declare module BABYLON {
  23799. /** @hidden */
  23800. export var bumpFragmentMainFunctions: {
  23801. name: string;
  23802. shader: string;
  23803. };
  23804. }
  23805. declare module BABYLON {
  23806. /** @hidden */
  23807. export var bumpFragmentFunctions: {
  23808. name: string;
  23809. shader: string;
  23810. };
  23811. }
  23812. declare module BABYLON {
  23813. /** @hidden */
  23814. export var logDepthDeclaration: {
  23815. name: string;
  23816. shader: string;
  23817. };
  23818. }
  23819. declare module BABYLON {
  23820. /** @hidden */
  23821. export var bumpFragment: {
  23822. name: string;
  23823. shader: string;
  23824. };
  23825. }
  23826. declare module BABYLON {
  23827. /** @hidden */
  23828. export var depthPrePass: {
  23829. name: string;
  23830. shader: string;
  23831. };
  23832. }
  23833. declare module BABYLON {
  23834. /** @hidden */
  23835. export var lightFragment: {
  23836. name: string;
  23837. shader: string;
  23838. };
  23839. }
  23840. declare module BABYLON {
  23841. /** @hidden */
  23842. export var logDepthFragment: {
  23843. name: string;
  23844. shader: string;
  23845. };
  23846. }
  23847. declare module BABYLON {
  23848. /** @hidden */
  23849. export var defaultPixelShader: {
  23850. name: string;
  23851. shader: string;
  23852. };
  23853. }
  23854. declare module BABYLON {
  23855. /** @hidden */
  23856. export var defaultVertexDeclaration: {
  23857. name: string;
  23858. shader: string;
  23859. };
  23860. }
  23861. declare module BABYLON {
  23862. /** @hidden */
  23863. export var prePassVertexDeclaration: {
  23864. name: string;
  23865. shader: string;
  23866. };
  23867. }
  23868. declare module BABYLON {
  23869. /** @hidden */
  23870. export var bumpVertexDeclaration: {
  23871. name: string;
  23872. shader: string;
  23873. };
  23874. }
  23875. declare module BABYLON {
  23876. /** @hidden */
  23877. export var prePassVertex: {
  23878. name: string;
  23879. shader: string;
  23880. };
  23881. }
  23882. declare module BABYLON {
  23883. /** @hidden */
  23884. export var bumpVertex: {
  23885. name: string;
  23886. shader: string;
  23887. };
  23888. }
  23889. declare module BABYLON {
  23890. /** @hidden */
  23891. export var fogVertex: {
  23892. name: string;
  23893. shader: string;
  23894. };
  23895. }
  23896. declare module BABYLON {
  23897. /** @hidden */
  23898. export var shadowsVertex: {
  23899. name: string;
  23900. shader: string;
  23901. };
  23902. }
  23903. declare module BABYLON {
  23904. /** @hidden */
  23905. export var pointCloudVertex: {
  23906. name: string;
  23907. shader: string;
  23908. };
  23909. }
  23910. declare module BABYLON {
  23911. /** @hidden */
  23912. export var logDepthVertex: {
  23913. name: string;
  23914. shader: string;
  23915. };
  23916. }
  23917. declare module BABYLON {
  23918. /** @hidden */
  23919. export var defaultVertexShader: {
  23920. name: string;
  23921. shader: string;
  23922. };
  23923. }
  23924. declare module BABYLON {
  23925. /**
  23926. * @hidden
  23927. */
  23928. export interface IMaterialDetailMapDefines {
  23929. DETAIL: boolean;
  23930. DETAILDIRECTUV: number;
  23931. DETAIL_NORMALBLENDMETHOD: number;
  23932. /** @hidden */
  23933. _areTexturesDirty: boolean;
  23934. }
  23935. /**
  23936. * Define the code related to the detail map parameters of a material
  23937. *
  23938. * Inspired from:
  23939. * 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
  23940. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  23941. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  23942. */
  23943. export class DetailMapConfiguration {
  23944. private _texture;
  23945. /**
  23946. * The detail texture of the material.
  23947. */
  23948. texture: Nullable<BaseTexture>;
  23949. /**
  23950. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  23951. * Bigger values mean stronger blending
  23952. */
  23953. diffuseBlendLevel: number;
  23954. /**
  23955. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  23956. * Bigger values mean stronger blending. Only used with PBR materials
  23957. */
  23958. roughnessBlendLevel: number;
  23959. /**
  23960. * Defines how strong the bump effect from the detail map is
  23961. * Bigger values mean stronger effect
  23962. */
  23963. bumpLevel: number;
  23964. private _normalBlendMethod;
  23965. /**
  23966. * The method used to blend the bump and detail normals together
  23967. */
  23968. normalBlendMethod: number;
  23969. private _isEnabled;
  23970. /**
  23971. * Enable or disable the detail map on this material
  23972. */
  23973. isEnabled: boolean;
  23974. /** @hidden */
  23975. private _internalMarkAllSubMeshesAsTexturesDirty;
  23976. /** @hidden */
  23977. _markAllSubMeshesAsTexturesDirty(): void;
  23978. /**
  23979. * Instantiate a new detail map
  23980. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  23981. */
  23982. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  23983. /**
  23984. * Gets whether the submesh is ready to be used or not.
  23985. * @param defines the list of "defines" to update.
  23986. * @param scene defines the scene the material belongs to.
  23987. * @returns - boolean indicating that the submesh is ready or not.
  23988. */
  23989. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  23990. /**
  23991. * Update the defines for detail map usage
  23992. * @param defines the list of "defines" to update.
  23993. * @param scene defines the scene the material belongs to.
  23994. */
  23995. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  23996. /**
  23997. * Binds the material data.
  23998. * @param uniformBuffer defines the Uniform buffer to fill in.
  23999. * @param scene defines the scene the material belongs to.
  24000. * @param isFrozen defines whether the material is frozen or not.
  24001. */
  24002. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  24003. /**
  24004. * Checks to see if a texture is used in the material.
  24005. * @param texture - Base texture to use.
  24006. * @returns - Boolean specifying if a texture is used in the material.
  24007. */
  24008. hasTexture(texture: BaseTexture): boolean;
  24009. /**
  24010. * Returns an array of the actively used textures.
  24011. * @param activeTextures Array of BaseTextures
  24012. */
  24013. getActiveTextures(activeTextures: BaseTexture[]): void;
  24014. /**
  24015. * Returns the animatable textures.
  24016. * @param animatables Array of animatable textures.
  24017. */
  24018. getAnimatables(animatables: IAnimatable[]): void;
  24019. /**
  24020. * Disposes the resources of the material.
  24021. * @param forceDisposeTextures - Forces the disposal of all textures.
  24022. */
  24023. dispose(forceDisposeTextures?: boolean): void;
  24024. /**
  24025. * Get the current class name useful for serialization or dynamic coding.
  24026. * @returns "DetailMap"
  24027. */
  24028. getClassName(): string;
  24029. /**
  24030. * Add the required uniforms to the current list.
  24031. * @param uniforms defines the current uniform list.
  24032. */
  24033. static AddUniforms(uniforms: string[]): void;
  24034. /**
  24035. * Add the required samplers to the current list.
  24036. * @param samplers defines the current sampler list.
  24037. */
  24038. static AddSamplers(samplers: string[]): void;
  24039. /**
  24040. * Add the required uniforms to the current buffer.
  24041. * @param uniformBuffer defines the current uniform buffer.
  24042. */
  24043. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  24044. /**
  24045. * Makes a duplicate of the current instance into another one.
  24046. * @param detailMap define the instance where to copy the info
  24047. */
  24048. copyTo(detailMap: DetailMapConfiguration): void;
  24049. /**
  24050. * Serializes this detail map instance
  24051. * @returns - An object with the serialized instance.
  24052. */
  24053. serialize(): any;
  24054. /**
  24055. * Parses a detail map setting from a serialized object.
  24056. * @param source - Serialized object.
  24057. * @param scene Defines the scene we are parsing for
  24058. * @param rootUrl Defines the rootUrl to load from
  24059. */
  24060. parse(source: any, scene: Scene, rootUrl: string): void;
  24061. }
  24062. }
  24063. declare module BABYLON {
  24064. /** @hidden */
  24065. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  24066. MAINUV1: boolean;
  24067. MAINUV2: boolean;
  24068. DIFFUSE: boolean;
  24069. DIFFUSEDIRECTUV: number;
  24070. DETAIL: boolean;
  24071. DETAILDIRECTUV: number;
  24072. DETAIL_NORMALBLENDMETHOD: number;
  24073. AMBIENT: boolean;
  24074. AMBIENTDIRECTUV: number;
  24075. OPACITY: boolean;
  24076. OPACITYDIRECTUV: number;
  24077. OPACITYRGB: boolean;
  24078. REFLECTION: boolean;
  24079. EMISSIVE: boolean;
  24080. EMISSIVEDIRECTUV: number;
  24081. SPECULAR: boolean;
  24082. SPECULARDIRECTUV: number;
  24083. BUMP: boolean;
  24084. BUMPDIRECTUV: number;
  24085. PARALLAX: boolean;
  24086. PARALLAXOCCLUSION: boolean;
  24087. SPECULAROVERALPHA: boolean;
  24088. CLIPPLANE: boolean;
  24089. CLIPPLANE2: boolean;
  24090. CLIPPLANE3: boolean;
  24091. CLIPPLANE4: boolean;
  24092. CLIPPLANE5: boolean;
  24093. CLIPPLANE6: boolean;
  24094. ALPHATEST: boolean;
  24095. DEPTHPREPASS: boolean;
  24096. ALPHAFROMDIFFUSE: boolean;
  24097. POINTSIZE: boolean;
  24098. FOG: boolean;
  24099. SPECULARTERM: boolean;
  24100. DIFFUSEFRESNEL: boolean;
  24101. OPACITYFRESNEL: boolean;
  24102. REFLECTIONFRESNEL: boolean;
  24103. REFRACTIONFRESNEL: boolean;
  24104. EMISSIVEFRESNEL: boolean;
  24105. FRESNEL: boolean;
  24106. NORMAL: boolean;
  24107. UV1: boolean;
  24108. UV2: boolean;
  24109. VERTEXCOLOR: boolean;
  24110. VERTEXALPHA: boolean;
  24111. NUM_BONE_INFLUENCERS: number;
  24112. BonesPerMesh: number;
  24113. BONETEXTURE: boolean;
  24114. BONES_VELOCITY_ENABLED: boolean;
  24115. INSTANCES: boolean;
  24116. THIN_INSTANCES: boolean;
  24117. GLOSSINESS: boolean;
  24118. ROUGHNESS: boolean;
  24119. EMISSIVEASILLUMINATION: boolean;
  24120. LINKEMISSIVEWITHDIFFUSE: boolean;
  24121. REFLECTIONFRESNELFROMSPECULAR: boolean;
  24122. LIGHTMAP: boolean;
  24123. LIGHTMAPDIRECTUV: number;
  24124. OBJECTSPACE_NORMALMAP: boolean;
  24125. USELIGHTMAPASSHADOWMAP: boolean;
  24126. REFLECTIONMAP_3D: boolean;
  24127. REFLECTIONMAP_SPHERICAL: boolean;
  24128. REFLECTIONMAP_PLANAR: boolean;
  24129. REFLECTIONMAP_CUBIC: boolean;
  24130. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  24131. REFLECTIONMAP_PROJECTION: boolean;
  24132. REFLECTIONMAP_SKYBOX: boolean;
  24133. REFLECTIONMAP_EXPLICIT: boolean;
  24134. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  24135. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  24136. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  24137. INVERTCUBICMAP: boolean;
  24138. LOGARITHMICDEPTH: boolean;
  24139. REFRACTION: boolean;
  24140. REFRACTIONMAP_3D: boolean;
  24141. REFLECTIONOVERALPHA: boolean;
  24142. TWOSIDEDLIGHTING: boolean;
  24143. SHADOWFLOAT: boolean;
  24144. MORPHTARGETS: boolean;
  24145. MORPHTARGETS_NORMAL: boolean;
  24146. MORPHTARGETS_TANGENT: boolean;
  24147. MORPHTARGETS_UV: boolean;
  24148. NUM_MORPH_INFLUENCERS: number;
  24149. NONUNIFORMSCALING: boolean;
  24150. PREMULTIPLYALPHA: boolean;
  24151. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  24152. ALPHABLEND: boolean;
  24153. PREPASS: boolean;
  24154. PREPASS_IRRADIANCE: boolean;
  24155. PREPASS_IRRADIANCE_INDEX: number;
  24156. PREPASS_ALBEDO: boolean;
  24157. PREPASS_ALBEDO_INDEX: number;
  24158. PREPASS_DEPTHNORMAL: boolean;
  24159. PREPASS_DEPTHNORMAL_INDEX: number;
  24160. PREPASS_POSITION: boolean;
  24161. PREPASS_POSITION_INDEX: number;
  24162. PREPASS_VELOCITY: boolean;
  24163. PREPASS_VELOCITY_INDEX: number;
  24164. PREPASS_REFLECTIVITY: boolean;
  24165. PREPASS_REFLECTIVITY_INDEX: number;
  24166. SCENE_MRT_COUNT: number;
  24167. RGBDLIGHTMAP: boolean;
  24168. RGBDREFLECTION: boolean;
  24169. RGBDREFRACTION: boolean;
  24170. IMAGEPROCESSING: boolean;
  24171. VIGNETTE: boolean;
  24172. VIGNETTEBLENDMODEMULTIPLY: boolean;
  24173. VIGNETTEBLENDMODEOPAQUE: boolean;
  24174. TONEMAPPING: boolean;
  24175. TONEMAPPING_ACES: boolean;
  24176. CONTRAST: boolean;
  24177. COLORCURVES: boolean;
  24178. COLORGRADING: boolean;
  24179. COLORGRADING3D: boolean;
  24180. SAMPLER3DGREENDEPTH: boolean;
  24181. SAMPLER3DBGRMAP: boolean;
  24182. IMAGEPROCESSINGPOSTPROCESS: boolean;
  24183. MULTIVIEW: boolean;
  24184. /**
  24185. * If the reflection texture on this material is in linear color space
  24186. * @hidden
  24187. */
  24188. IS_REFLECTION_LINEAR: boolean;
  24189. /**
  24190. * If the refraction texture on this material is in linear color space
  24191. * @hidden
  24192. */
  24193. IS_REFRACTION_LINEAR: boolean;
  24194. EXPOSURE: boolean;
  24195. constructor();
  24196. setReflectionMode(modeToEnable: string): void;
  24197. }
  24198. /**
  24199. * This is the default material used in Babylon. It is the best trade off between quality
  24200. * and performances.
  24201. * @see https://doc.babylonjs.com/babylon101/materials
  24202. */
  24203. export class StandardMaterial extends PushMaterial {
  24204. private _diffuseTexture;
  24205. /**
  24206. * The basic texture of the material as viewed under a light.
  24207. */
  24208. diffuseTexture: Nullable<BaseTexture>;
  24209. private _ambientTexture;
  24210. /**
  24211. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  24212. */
  24213. ambientTexture: Nullable<BaseTexture>;
  24214. private _opacityTexture;
  24215. /**
  24216. * Define the transparency of the material from a texture.
  24217. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  24218. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  24219. */
  24220. opacityTexture: Nullable<BaseTexture>;
  24221. private _reflectionTexture;
  24222. /**
  24223. * Define the texture used to display the reflection.
  24224. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24225. */
  24226. reflectionTexture: Nullable<BaseTexture>;
  24227. private _emissiveTexture;
  24228. /**
  24229. * Define texture of the material as if self lit.
  24230. * This will be mixed in the final result even in the absence of light.
  24231. */
  24232. emissiveTexture: Nullable<BaseTexture>;
  24233. private _specularTexture;
  24234. /**
  24235. * Define how the color and intensity of the highlight given by the light in the material.
  24236. */
  24237. specularTexture: Nullable<BaseTexture>;
  24238. private _bumpTexture;
  24239. /**
  24240. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  24241. * 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.
  24242. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  24243. */
  24244. bumpTexture: Nullable<BaseTexture>;
  24245. private _lightmapTexture;
  24246. /**
  24247. * Complex lighting can be computationally expensive to compute at runtime.
  24248. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  24249. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  24250. */
  24251. lightmapTexture: Nullable<BaseTexture>;
  24252. private _refractionTexture;
  24253. /**
  24254. * Define the texture used to display the refraction.
  24255. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24256. */
  24257. refractionTexture: Nullable<BaseTexture>;
  24258. /**
  24259. * The color of the material lit by the environmental background lighting.
  24260. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  24261. */
  24262. ambientColor: Color3;
  24263. /**
  24264. * The basic color of the material as viewed under a light.
  24265. */
  24266. diffuseColor: Color3;
  24267. /**
  24268. * Define how the color and intensity of the highlight given by the light in the material.
  24269. */
  24270. specularColor: Color3;
  24271. /**
  24272. * Define the color of the material as if self lit.
  24273. * This will be mixed in the final result even in the absence of light.
  24274. */
  24275. emissiveColor: Color3;
  24276. /**
  24277. * Defines how sharp are the highlights in the material.
  24278. * The bigger the value the sharper giving a more glossy feeling to the result.
  24279. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  24280. */
  24281. specularPower: number;
  24282. private _useAlphaFromDiffuseTexture;
  24283. /**
  24284. * Does the transparency come from the diffuse texture alpha channel.
  24285. */
  24286. useAlphaFromDiffuseTexture: boolean;
  24287. private _useEmissiveAsIllumination;
  24288. /**
  24289. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  24290. */
  24291. useEmissiveAsIllumination: boolean;
  24292. private _linkEmissiveWithDiffuse;
  24293. /**
  24294. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  24295. * the emissive level when the final color is close to one.
  24296. */
  24297. linkEmissiveWithDiffuse: boolean;
  24298. private _useSpecularOverAlpha;
  24299. /**
  24300. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  24301. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  24302. */
  24303. useSpecularOverAlpha: boolean;
  24304. private _useReflectionOverAlpha;
  24305. /**
  24306. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  24307. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  24308. */
  24309. useReflectionOverAlpha: boolean;
  24310. private _disableLighting;
  24311. /**
  24312. * Does lights from the scene impacts this material.
  24313. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  24314. */
  24315. disableLighting: boolean;
  24316. private _useObjectSpaceNormalMap;
  24317. /**
  24318. * Allows using an object space normal map (instead of tangent space).
  24319. */
  24320. useObjectSpaceNormalMap: boolean;
  24321. private _useParallax;
  24322. /**
  24323. * Is parallax enabled or not.
  24324. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  24325. */
  24326. useParallax: boolean;
  24327. private _useParallaxOcclusion;
  24328. /**
  24329. * Is parallax occlusion enabled or not.
  24330. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  24331. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  24332. */
  24333. useParallaxOcclusion: boolean;
  24334. /**
  24335. * 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.
  24336. */
  24337. parallaxScaleBias: number;
  24338. private _roughness;
  24339. /**
  24340. * Helps to define how blurry the reflections should appears in the material.
  24341. */
  24342. roughness: number;
  24343. /**
  24344. * In case of refraction, define the value of the index of refraction.
  24345. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24346. */
  24347. indexOfRefraction: number;
  24348. /**
  24349. * Invert the refraction texture alongside the y axis.
  24350. * It can be useful with procedural textures or probe for instance.
  24351. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24352. */
  24353. invertRefractionY: boolean;
  24354. /**
  24355. * Defines the alpha limits in alpha test mode.
  24356. */
  24357. alphaCutOff: number;
  24358. private _useLightmapAsShadowmap;
  24359. /**
  24360. * In case of light mapping, define whether the map contains light or shadow informations.
  24361. */
  24362. useLightmapAsShadowmap: boolean;
  24363. private _diffuseFresnelParameters;
  24364. /**
  24365. * Define the diffuse fresnel parameters of the material.
  24366. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24367. */
  24368. diffuseFresnelParameters: FresnelParameters;
  24369. private _opacityFresnelParameters;
  24370. /**
  24371. * Define the opacity fresnel parameters of the material.
  24372. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24373. */
  24374. opacityFresnelParameters: FresnelParameters;
  24375. private _reflectionFresnelParameters;
  24376. /**
  24377. * Define the reflection fresnel parameters of the material.
  24378. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24379. */
  24380. reflectionFresnelParameters: FresnelParameters;
  24381. private _refractionFresnelParameters;
  24382. /**
  24383. * Define the refraction fresnel parameters of the material.
  24384. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24385. */
  24386. refractionFresnelParameters: FresnelParameters;
  24387. private _emissiveFresnelParameters;
  24388. /**
  24389. * Define the emissive fresnel parameters of the material.
  24390. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24391. */
  24392. emissiveFresnelParameters: FresnelParameters;
  24393. private _useReflectionFresnelFromSpecular;
  24394. /**
  24395. * If true automatically deducts the fresnels values from the material specularity.
  24396. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24397. */
  24398. useReflectionFresnelFromSpecular: boolean;
  24399. private _useGlossinessFromSpecularMapAlpha;
  24400. /**
  24401. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  24402. */
  24403. useGlossinessFromSpecularMapAlpha: boolean;
  24404. private _maxSimultaneousLights;
  24405. /**
  24406. * Defines the maximum number of lights that can be used in the material
  24407. */
  24408. maxSimultaneousLights: number;
  24409. private _invertNormalMapX;
  24410. /**
  24411. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  24412. */
  24413. invertNormalMapX: boolean;
  24414. private _invertNormalMapY;
  24415. /**
  24416. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  24417. */
  24418. invertNormalMapY: boolean;
  24419. private _twoSidedLighting;
  24420. /**
  24421. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  24422. */
  24423. twoSidedLighting: boolean;
  24424. /**
  24425. * Default configuration related to image processing available in the standard Material.
  24426. */
  24427. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24428. /**
  24429. * Gets the image processing configuration used either in this material.
  24430. */
  24431. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  24432. /**
  24433. * Sets the Default image processing configuration used either in the this material.
  24434. *
  24435. * If sets to null, the scene one is in use.
  24436. */
  24437. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  24438. /**
  24439. * Keep track of the image processing observer to allow dispose and replace.
  24440. */
  24441. private _imageProcessingObserver;
  24442. /**
  24443. * Attaches a new image processing configuration to the Standard Material.
  24444. * @param configuration
  24445. */
  24446. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  24447. /**
  24448. * Defines additionnal PrePass parameters for the material.
  24449. */
  24450. readonly prePassConfiguration: PrePassConfiguration;
  24451. /**
  24452. * Gets wether the color curves effect is enabled.
  24453. */
  24454. get cameraColorCurvesEnabled(): boolean;
  24455. /**
  24456. * Sets wether the color curves effect is enabled.
  24457. */
  24458. set cameraColorCurvesEnabled(value: boolean);
  24459. /**
  24460. * Gets wether the color grading effect is enabled.
  24461. */
  24462. get cameraColorGradingEnabled(): boolean;
  24463. /**
  24464. * Gets wether the color grading effect is enabled.
  24465. */
  24466. set cameraColorGradingEnabled(value: boolean);
  24467. /**
  24468. * Gets wether tonemapping is enabled or not.
  24469. */
  24470. get cameraToneMappingEnabled(): boolean;
  24471. /**
  24472. * Sets wether tonemapping is enabled or not
  24473. */
  24474. set cameraToneMappingEnabled(value: boolean);
  24475. /**
  24476. * The camera exposure used on this material.
  24477. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  24478. * This corresponds to a photographic exposure.
  24479. */
  24480. get cameraExposure(): number;
  24481. /**
  24482. * The camera exposure used on this material.
  24483. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  24484. * This corresponds to a photographic exposure.
  24485. */
  24486. set cameraExposure(value: number);
  24487. /**
  24488. * Gets The camera contrast used on this material.
  24489. */
  24490. get cameraContrast(): number;
  24491. /**
  24492. * Sets The camera contrast used on this material.
  24493. */
  24494. set cameraContrast(value: number);
  24495. /**
  24496. * Gets the Color Grading 2D Lookup Texture.
  24497. */
  24498. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  24499. /**
  24500. * Sets the Color Grading 2D Lookup Texture.
  24501. */
  24502. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  24503. /**
  24504. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  24505. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  24506. * 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;
  24507. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  24508. */
  24509. get cameraColorCurves(): Nullable<ColorCurves>;
  24510. /**
  24511. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  24512. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  24513. * 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;
  24514. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  24515. */
  24516. set cameraColorCurves(value: Nullable<ColorCurves>);
  24517. /**
  24518. * Can this material render to several textures at once
  24519. */
  24520. get canRenderToMRT(): boolean;
  24521. /**
  24522. * Defines the detail map parameters for the material.
  24523. */
  24524. readonly detailMap: DetailMapConfiguration;
  24525. protected _renderTargets: SmartArray<RenderTargetTexture>;
  24526. protected _worldViewProjectionMatrix: Matrix;
  24527. protected _globalAmbientColor: Color3;
  24528. protected _useLogarithmicDepth: boolean;
  24529. protected _rebuildInParallel: boolean;
  24530. /**
  24531. * Instantiates a new standard material.
  24532. * This is the default material used in Babylon. It is the best trade off between quality
  24533. * and performances.
  24534. * @see https://doc.babylonjs.com/babylon101/materials
  24535. * @param name Define the name of the material in the scene
  24536. * @param scene Define the scene the material belong to
  24537. */
  24538. constructor(name: string, scene: Scene);
  24539. /**
  24540. * Gets a boolean indicating that current material needs to register RTT
  24541. */
  24542. get hasRenderTargetTextures(): boolean;
  24543. /**
  24544. * Gets the current class name of the material e.g. "StandardMaterial"
  24545. * Mainly use in serialization.
  24546. * @returns the class name
  24547. */
  24548. getClassName(): string;
  24549. /**
  24550. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  24551. * You can try switching to logarithmic depth.
  24552. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  24553. */
  24554. get useLogarithmicDepth(): boolean;
  24555. set useLogarithmicDepth(value: boolean);
  24556. /**
  24557. * Specifies if the material will require alpha blending
  24558. * @returns a boolean specifying if alpha blending is needed
  24559. */
  24560. needAlphaBlending(): boolean;
  24561. /**
  24562. * Specifies if this material should be rendered in alpha test mode
  24563. * @returns a boolean specifying if an alpha test is needed.
  24564. */
  24565. needAlphaTesting(): boolean;
  24566. /**
  24567. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  24568. */
  24569. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  24570. /**
  24571. * Specifies whether or not there is a usable alpha channel for transparency.
  24572. */
  24573. protected _hasAlphaChannel(): boolean;
  24574. /**
  24575. * Get the texture used for alpha test purpose.
  24576. * @returns the diffuse texture in case of the standard material.
  24577. */
  24578. getAlphaTestTexture(): Nullable<BaseTexture>;
  24579. /**
  24580. * Get if the submesh is ready to be used and all its information available.
  24581. * Child classes can use it to update shaders
  24582. * @param mesh defines the mesh to check
  24583. * @param subMesh defines which submesh to check
  24584. * @param useInstances specifies that instances should be used
  24585. * @returns a boolean indicating that the submesh is ready or not
  24586. */
  24587. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24588. /**
  24589. * Builds the material UBO layouts.
  24590. * Used internally during the effect preparation.
  24591. */
  24592. buildUniformLayout(): void;
  24593. /**
  24594. * Unbinds the material from the mesh
  24595. */
  24596. unbind(): void;
  24597. /**
  24598. * Binds the submesh to this material by preparing the effect and shader to draw
  24599. * @param world defines the world transformation matrix
  24600. * @param mesh defines the mesh containing the submesh
  24601. * @param subMesh defines the submesh to bind the material to
  24602. */
  24603. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24604. /**
  24605. * Get the list of animatables in the material.
  24606. * @returns the list of animatables object used in the material
  24607. */
  24608. getAnimatables(): IAnimatable[];
  24609. /**
  24610. * Gets the active textures from the material
  24611. * @returns an array of textures
  24612. */
  24613. getActiveTextures(): BaseTexture[];
  24614. /**
  24615. * Specifies if the material uses a texture
  24616. * @param texture defines the texture to check against the material
  24617. * @returns a boolean specifying if the material uses the texture
  24618. */
  24619. hasTexture(texture: BaseTexture): boolean;
  24620. /**
  24621. * Disposes the material
  24622. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  24623. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  24624. */
  24625. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  24626. /**
  24627. * Makes a duplicate of the material, and gives it a new name
  24628. * @param name defines the new name for the duplicated material
  24629. * @returns the cloned material
  24630. */
  24631. clone(name: string): StandardMaterial;
  24632. /**
  24633. * Serializes this material in a JSON representation
  24634. * @returns the serialized material object
  24635. */
  24636. serialize(): any;
  24637. /**
  24638. * Creates a standard material from parsed material data
  24639. * @param source defines the JSON representation of the material
  24640. * @param scene defines the hosting scene
  24641. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24642. * @returns a new standard material
  24643. */
  24644. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  24645. /**
  24646. * Are diffuse textures enabled in the application.
  24647. */
  24648. static get DiffuseTextureEnabled(): boolean;
  24649. static set DiffuseTextureEnabled(value: boolean);
  24650. /**
  24651. * Are detail textures enabled in the application.
  24652. */
  24653. static get DetailTextureEnabled(): boolean;
  24654. static set DetailTextureEnabled(value: boolean);
  24655. /**
  24656. * Are ambient textures enabled in the application.
  24657. */
  24658. static get AmbientTextureEnabled(): boolean;
  24659. static set AmbientTextureEnabled(value: boolean);
  24660. /**
  24661. * Are opacity textures enabled in the application.
  24662. */
  24663. static get OpacityTextureEnabled(): boolean;
  24664. static set OpacityTextureEnabled(value: boolean);
  24665. /**
  24666. * Are reflection textures enabled in the application.
  24667. */
  24668. static get ReflectionTextureEnabled(): boolean;
  24669. static set ReflectionTextureEnabled(value: boolean);
  24670. /**
  24671. * Are emissive textures enabled in the application.
  24672. */
  24673. static get EmissiveTextureEnabled(): boolean;
  24674. static set EmissiveTextureEnabled(value: boolean);
  24675. /**
  24676. * Are specular textures enabled in the application.
  24677. */
  24678. static get SpecularTextureEnabled(): boolean;
  24679. static set SpecularTextureEnabled(value: boolean);
  24680. /**
  24681. * Are bump textures enabled in the application.
  24682. */
  24683. static get BumpTextureEnabled(): boolean;
  24684. static set BumpTextureEnabled(value: boolean);
  24685. /**
  24686. * Are lightmap textures enabled in the application.
  24687. */
  24688. static get LightmapTextureEnabled(): boolean;
  24689. static set LightmapTextureEnabled(value: boolean);
  24690. /**
  24691. * Are refraction textures enabled in the application.
  24692. */
  24693. static get RefractionTextureEnabled(): boolean;
  24694. static set RefractionTextureEnabled(value: boolean);
  24695. /**
  24696. * Are color grading textures enabled in the application.
  24697. */
  24698. static get ColorGradingTextureEnabled(): boolean;
  24699. static set ColorGradingTextureEnabled(value: boolean);
  24700. /**
  24701. * Are fresnels enabled in the application.
  24702. */
  24703. static get FresnelEnabled(): boolean;
  24704. static set FresnelEnabled(value: boolean);
  24705. }
  24706. }
  24707. declare module BABYLON {
  24708. /** @hidden */
  24709. export var rgbdDecodePixelShader: {
  24710. name: string;
  24711. shader: string;
  24712. };
  24713. }
  24714. declare module BABYLON {
  24715. /**
  24716. * Class used to host RGBD texture specific utilities
  24717. */
  24718. export class RGBDTextureTools {
  24719. /**
  24720. * Expand the RGBD Texture from RGBD to Half Float if possible.
  24721. * @param texture the texture to expand.
  24722. */
  24723. static ExpandRGBDTexture(texture: Texture): void;
  24724. }
  24725. }
  24726. declare module BABYLON {
  24727. /**
  24728. * Class used to host texture specific utilities
  24729. */
  24730. export class BRDFTextureTools {
  24731. /**
  24732. * Prevents texture cache collision
  24733. */
  24734. private static _instanceNumber;
  24735. /**
  24736. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  24737. * @param scene defines the hosting scene
  24738. * @returns the environment BRDF texture
  24739. */
  24740. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  24741. private static _environmentBRDFBase64Texture;
  24742. }
  24743. }
  24744. declare module BABYLON {
  24745. /**
  24746. * @hidden
  24747. */
  24748. export interface IMaterialClearCoatDefines {
  24749. CLEARCOAT: boolean;
  24750. CLEARCOAT_DEFAULTIOR: boolean;
  24751. CLEARCOAT_TEXTURE: boolean;
  24752. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  24753. CLEARCOAT_TEXTUREDIRECTUV: number;
  24754. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  24755. CLEARCOAT_BUMP: boolean;
  24756. CLEARCOAT_BUMPDIRECTUV: number;
  24757. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  24758. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  24759. CLEARCOAT_REMAP_F0: boolean;
  24760. CLEARCOAT_TINT: boolean;
  24761. CLEARCOAT_TINT_TEXTURE: boolean;
  24762. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  24763. /** @hidden */
  24764. _areTexturesDirty: boolean;
  24765. }
  24766. /**
  24767. * Define the code related to the clear coat parameters of the pbr material.
  24768. */
  24769. export class PBRClearCoatConfiguration {
  24770. /**
  24771. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  24772. * The default fits with a polyurethane material.
  24773. */
  24774. private static readonly _DefaultIndexOfRefraction;
  24775. private _isEnabled;
  24776. /**
  24777. * Defines if the clear coat is enabled in the material.
  24778. */
  24779. isEnabled: boolean;
  24780. /**
  24781. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  24782. */
  24783. intensity: number;
  24784. /**
  24785. * Defines the clear coat layer roughness.
  24786. */
  24787. roughness: number;
  24788. private _indexOfRefraction;
  24789. /**
  24790. * Defines the index of refraction of the clear coat.
  24791. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  24792. * The default fits with a polyurethane material.
  24793. * Changing the default value is more performance intensive.
  24794. */
  24795. indexOfRefraction: number;
  24796. private _texture;
  24797. /**
  24798. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  24799. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  24800. * if textureRoughness is not empty, else no texture roughness is used
  24801. */
  24802. texture: Nullable<BaseTexture>;
  24803. private _useRoughnessFromMainTexture;
  24804. /**
  24805. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  24806. * If false, the green channel from textureRoughness is used for roughness
  24807. */
  24808. useRoughnessFromMainTexture: boolean;
  24809. private _textureRoughness;
  24810. /**
  24811. * Stores the clear coat roughness in a texture (green channel)
  24812. * Not used if useRoughnessFromMainTexture is true
  24813. */
  24814. textureRoughness: Nullable<BaseTexture>;
  24815. private _remapF0OnInterfaceChange;
  24816. /**
  24817. * Defines if the F0 value should be remapped to account for the interface change in the material.
  24818. */
  24819. remapF0OnInterfaceChange: boolean;
  24820. private _bumpTexture;
  24821. /**
  24822. * Define the clear coat specific bump texture.
  24823. */
  24824. bumpTexture: Nullable<BaseTexture>;
  24825. private _isTintEnabled;
  24826. /**
  24827. * Defines if the clear coat tint is enabled in the material.
  24828. */
  24829. isTintEnabled: boolean;
  24830. /**
  24831. * Defines the clear coat tint of the material.
  24832. * This is only use if tint is enabled
  24833. */
  24834. tintColor: Color3;
  24835. /**
  24836. * Defines the distance at which the tint color should be found in the
  24837. * clear coat media.
  24838. * This is only use if tint is enabled
  24839. */
  24840. tintColorAtDistance: number;
  24841. /**
  24842. * Defines the clear coat layer thickness.
  24843. * This is only use if tint is enabled
  24844. */
  24845. tintThickness: number;
  24846. private _tintTexture;
  24847. /**
  24848. * Stores the clear tint values in a texture.
  24849. * rgb is tint
  24850. * a is a thickness factor
  24851. */
  24852. tintTexture: Nullable<BaseTexture>;
  24853. /** @hidden */
  24854. private _internalMarkAllSubMeshesAsTexturesDirty;
  24855. /** @hidden */
  24856. _markAllSubMeshesAsTexturesDirty(): void;
  24857. /**
  24858. * Instantiate a new istance of clear coat configuration.
  24859. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  24860. */
  24861. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  24862. /**
  24863. * Gets wehter the submesh is ready to be used or not.
  24864. * @param defines the list of "defines" to update.
  24865. * @param scene defines the scene the material belongs to.
  24866. * @param engine defines the engine the material belongs to.
  24867. * @param disableBumpMap defines wether the material disables bump or not.
  24868. * @returns - boolean indicating that the submesh is ready or not.
  24869. */
  24870. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  24871. /**
  24872. * Checks to see if a texture is used in the material.
  24873. * @param defines the list of "defines" to update.
  24874. * @param scene defines the scene to the material belongs to.
  24875. */
  24876. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  24877. /**
  24878. * Binds the material data.
  24879. * @param uniformBuffer defines the Uniform buffer to fill in.
  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. * @param isFrozen defines wether the material is frozen or not.
  24884. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  24885. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  24886. * @param subMesh the submesh to bind data for
  24887. */
  24888. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  24889. /**
  24890. * Checks to see if a texture is used in the material.
  24891. * @param texture - Base texture to use.
  24892. * @returns - Boolean specifying if a texture is used in the material.
  24893. */
  24894. hasTexture(texture: BaseTexture): boolean;
  24895. /**
  24896. * Returns an array of the actively used textures.
  24897. * @param activeTextures Array of BaseTextures
  24898. */
  24899. getActiveTextures(activeTextures: BaseTexture[]): void;
  24900. /**
  24901. * Returns the animatable textures.
  24902. * @param animatables Array of animatable textures.
  24903. */
  24904. getAnimatables(animatables: IAnimatable[]): void;
  24905. /**
  24906. * Disposes the resources of the material.
  24907. * @param forceDisposeTextures - Forces the disposal of all textures.
  24908. */
  24909. dispose(forceDisposeTextures?: boolean): void;
  24910. /**
  24911. * Get the current class name of the texture useful for serialization or dynamic coding.
  24912. * @returns "PBRClearCoatConfiguration"
  24913. */
  24914. getClassName(): string;
  24915. /**
  24916. * Add fallbacks to the effect fallbacks list.
  24917. * @param defines defines the Base texture to use.
  24918. * @param fallbacks defines the current fallback list.
  24919. * @param currentRank defines the current fallback rank.
  24920. * @returns the new fallback rank.
  24921. */
  24922. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  24923. /**
  24924. * Add the required uniforms to the current list.
  24925. * @param uniforms defines the current uniform list.
  24926. */
  24927. static AddUniforms(uniforms: string[]): void;
  24928. /**
  24929. * Add the required samplers to the current list.
  24930. * @param samplers defines the current sampler list.
  24931. */
  24932. static AddSamplers(samplers: string[]): void;
  24933. /**
  24934. * Add the required uniforms to the current buffer.
  24935. * @param uniformBuffer defines the current uniform buffer.
  24936. */
  24937. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  24938. /**
  24939. * Makes a duplicate of the current configuration into another one.
  24940. * @param clearCoatConfiguration define the config where to copy the info
  24941. */
  24942. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  24943. /**
  24944. * Serializes this clear coat configuration.
  24945. * @returns - An object with the serialized config.
  24946. */
  24947. serialize(): any;
  24948. /**
  24949. * Parses a anisotropy Configuration from a serialized object.
  24950. * @param source - Serialized object.
  24951. * @param scene Defines the scene we are parsing for
  24952. * @param rootUrl Defines the rootUrl to load from
  24953. */
  24954. parse(source: any, scene: Scene, rootUrl: string): void;
  24955. }
  24956. }
  24957. declare module BABYLON {
  24958. /**
  24959. * @hidden
  24960. */
  24961. export interface IMaterialAnisotropicDefines {
  24962. ANISOTROPIC: boolean;
  24963. ANISOTROPIC_TEXTURE: boolean;
  24964. ANISOTROPIC_TEXTUREDIRECTUV: number;
  24965. MAINUV1: boolean;
  24966. _areTexturesDirty: boolean;
  24967. _needUVs: boolean;
  24968. }
  24969. /**
  24970. * Define the code related to the anisotropic parameters of the pbr material.
  24971. */
  24972. export class PBRAnisotropicConfiguration {
  24973. private _isEnabled;
  24974. /**
  24975. * Defines if the anisotropy is enabled in the material.
  24976. */
  24977. isEnabled: boolean;
  24978. /**
  24979. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  24980. */
  24981. intensity: number;
  24982. /**
  24983. * Defines if the effect is along the tangents, bitangents or in between.
  24984. * By default, the effect is "strectching" the highlights along the tangents.
  24985. */
  24986. direction: Vector2;
  24987. private _texture;
  24988. /**
  24989. * Stores the anisotropy values in a texture.
  24990. * rg is direction (like normal from -1 to 1)
  24991. * b is a intensity
  24992. */
  24993. texture: Nullable<BaseTexture>;
  24994. /** @hidden */
  24995. private _internalMarkAllSubMeshesAsTexturesDirty;
  24996. /** @hidden */
  24997. _markAllSubMeshesAsTexturesDirty(): void;
  24998. /**
  24999. * Instantiate a new istance of anisotropy configuration.
  25000. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25001. */
  25002. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25003. /**
  25004. * Specifies that the submesh is ready to be used.
  25005. * @param defines the list of "defines" to update.
  25006. * @param scene defines the scene the material belongs to.
  25007. * @returns - boolean indicating that the submesh is ready or not.
  25008. */
  25009. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  25010. /**
  25011. * Checks to see if a texture is used in the material.
  25012. * @param defines the list of "defines" to update.
  25013. * @param mesh the mesh we are preparing the defines for.
  25014. * @param scene defines the scene the material belongs to.
  25015. */
  25016. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  25017. /**
  25018. * Binds the material data.
  25019. * @param uniformBuffer defines the Uniform buffer to fill in.
  25020. * @param scene defines the scene the material belongs to.
  25021. * @param isFrozen defines wether the material is frozen or not.
  25022. */
  25023. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  25024. /**
  25025. * Checks to see if a texture is used in the material.
  25026. * @param texture - Base texture to use.
  25027. * @returns - Boolean specifying if a texture is used in the material.
  25028. */
  25029. hasTexture(texture: BaseTexture): boolean;
  25030. /**
  25031. * Returns an array of the actively used textures.
  25032. * @param activeTextures Array of BaseTextures
  25033. */
  25034. getActiveTextures(activeTextures: BaseTexture[]): void;
  25035. /**
  25036. * Returns the animatable textures.
  25037. * @param animatables Array of animatable textures.
  25038. */
  25039. getAnimatables(animatables: IAnimatable[]): void;
  25040. /**
  25041. * Disposes the resources of the material.
  25042. * @param forceDisposeTextures - Forces the disposal of all textures.
  25043. */
  25044. dispose(forceDisposeTextures?: boolean): void;
  25045. /**
  25046. * Get the current class name of the texture useful for serialization or dynamic coding.
  25047. * @returns "PBRAnisotropicConfiguration"
  25048. */
  25049. getClassName(): string;
  25050. /**
  25051. * Add fallbacks to the effect fallbacks list.
  25052. * @param defines defines the Base texture to use.
  25053. * @param fallbacks defines the current fallback list.
  25054. * @param currentRank defines the current fallback rank.
  25055. * @returns the new fallback rank.
  25056. */
  25057. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25058. /**
  25059. * Add the required uniforms to the current list.
  25060. * @param uniforms defines the current uniform list.
  25061. */
  25062. static AddUniforms(uniforms: string[]): void;
  25063. /**
  25064. * Add the required uniforms to the current buffer.
  25065. * @param uniformBuffer defines the current uniform buffer.
  25066. */
  25067. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25068. /**
  25069. * Add the required samplers to the current list.
  25070. * @param samplers defines the current sampler list.
  25071. */
  25072. static AddSamplers(samplers: string[]): void;
  25073. /**
  25074. * Makes a duplicate of the current configuration into another one.
  25075. * @param anisotropicConfiguration define the config where to copy the info
  25076. */
  25077. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  25078. /**
  25079. * Serializes this anisotropy configuration.
  25080. * @returns - An object with the serialized config.
  25081. */
  25082. serialize(): any;
  25083. /**
  25084. * Parses a anisotropy Configuration from a serialized object.
  25085. * @param source - Serialized object.
  25086. * @param scene Defines the scene we are parsing for
  25087. * @param rootUrl Defines the rootUrl to load from
  25088. */
  25089. parse(source: any, scene: Scene, rootUrl: string): void;
  25090. }
  25091. }
  25092. declare module BABYLON {
  25093. /**
  25094. * @hidden
  25095. */
  25096. export interface IMaterialBRDFDefines {
  25097. BRDF_V_HEIGHT_CORRELATED: boolean;
  25098. MS_BRDF_ENERGY_CONSERVATION: boolean;
  25099. SPHERICAL_HARMONICS: boolean;
  25100. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  25101. /** @hidden */
  25102. _areMiscDirty: boolean;
  25103. }
  25104. /**
  25105. * Define the code related to the BRDF parameters of the pbr material.
  25106. */
  25107. export class PBRBRDFConfiguration {
  25108. /**
  25109. * Default value used for the energy conservation.
  25110. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  25111. */
  25112. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  25113. /**
  25114. * Default value used for the Smith Visibility Height Correlated mode.
  25115. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  25116. */
  25117. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  25118. /**
  25119. * Default value used for the IBL diffuse part.
  25120. * This can help switching back to the polynomials mode globally which is a tiny bit
  25121. * less GPU intensive at the drawback of a lower quality.
  25122. */
  25123. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  25124. /**
  25125. * Default value used for activating energy conservation for the specular workflow.
  25126. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  25127. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  25128. */
  25129. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  25130. private _useEnergyConservation;
  25131. /**
  25132. * Defines if the material uses energy conservation.
  25133. */
  25134. useEnergyConservation: boolean;
  25135. private _useSmithVisibilityHeightCorrelated;
  25136. /**
  25137. * LEGACY Mode set to false
  25138. * Defines if the material uses height smith correlated visibility term.
  25139. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  25140. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  25141. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  25142. * Not relying on height correlated will also disable energy conservation.
  25143. */
  25144. useSmithVisibilityHeightCorrelated: boolean;
  25145. private _useSphericalHarmonics;
  25146. /**
  25147. * LEGACY Mode set to false
  25148. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  25149. * diffuse part of the IBL.
  25150. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  25151. * to the ground truth.
  25152. */
  25153. useSphericalHarmonics: boolean;
  25154. private _useSpecularGlossinessInputEnergyConservation;
  25155. /**
  25156. * Defines if the material uses energy conservation, when the specular workflow is active.
  25157. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  25158. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  25159. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  25160. */
  25161. useSpecularGlossinessInputEnergyConservation: boolean;
  25162. /** @hidden */
  25163. private _internalMarkAllSubMeshesAsMiscDirty;
  25164. /** @hidden */
  25165. _markAllSubMeshesAsMiscDirty(): void;
  25166. /**
  25167. * Instantiate a new istance of clear coat configuration.
  25168. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  25169. */
  25170. constructor(markAllSubMeshesAsMiscDirty: () => void);
  25171. /**
  25172. * Checks to see if a texture is used in the material.
  25173. * @param defines the list of "defines" to update.
  25174. */
  25175. prepareDefines(defines: IMaterialBRDFDefines): void;
  25176. /**
  25177. * Get the current class name of the texture useful for serialization or dynamic coding.
  25178. * @returns "PBRClearCoatConfiguration"
  25179. */
  25180. getClassName(): string;
  25181. /**
  25182. * Makes a duplicate of the current configuration into another one.
  25183. * @param brdfConfiguration define the config where to copy the info
  25184. */
  25185. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  25186. /**
  25187. * Serializes this BRDF configuration.
  25188. * @returns - An object with the serialized config.
  25189. */
  25190. serialize(): any;
  25191. /**
  25192. * Parses a anisotropy Configuration from a serialized object.
  25193. * @param source - Serialized object.
  25194. * @param scene Defines the scene we are parsing for
  25195. * @param rootUrl Defines the rootUrl to load from
  25196. */
  25197. parse(source: any, scene: Scene, rootUrl: string): void;
  25198. }
  25199. }
  25200. declare module BABYLON {
  25201. /**
  25202. * @hidden
  25203. */
  25204. export interface IMaterialSheenDefines {
  25205. SHEEN: boolean;
  25206. SHEEN_TEXTURE: boolean;
  25207. SHEEN_TEXTURE_ROUGHNESS: boolean;
  25208. SHEEN_TEXTUREDIRECTUV: number;
  25209. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  25210. SHEEN_LINKWITHALBEDO: boolean;
  25211. SHEEN_ROUGHNESS: boolean;
  25212. SHEEN_ALBEDOSCALING: boolean;
  25213. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  25214. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  25215. /** @hidden */
  25216. _areTexturesDirty: boolean;
  25217. }
  25218. /**
  25219. * Define the code related to the Sheen parameters of the pbr material.
  25220. */
  25221. export class PBRSheenConfiguration {
  25222. private _isEnabled;
  25223. /**
  25224. * Defines if the material uses sheen.
  25225. */
  25226. isEnabled: boolean;
  25227. private _linkSheenWithAlbedo;
  25228. /**
  25229. * Defines if the sheen is linked to the sheen color.
  25230. */
  25231. linkSheenWithAlbedo: boolean;
  25232. /**
  25233. * Defines the sheen intensity.
  25234. */
  25235. intensity: number;
  25236. /**
  25237. * Defines the sheen color.
  25238. */
  25239. color: Color3;
  25240. private _texture;
  25241. /**
  25242. * Stores the sheen tint values in a texture.
  25243. * rgb is tint
  25244. * 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)
  25245. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  25246. */
  25247. texture: Nullable<BaseTexture>;
  25248. private _useRoughnessFromMainTexture;
  25249. /**
  25250. * Indicates that the alpha channel of the texture property will be used for roughness.
  25251. * Has no effect if the roughness (and texture!) property is not defined
  25252. */
  25253. useRoughnessFromMainTexture: boolean;
  25254. private _roughness;
  25255. /**
  25256. * Defines the sheen roughness.
  25257. * It is not taken into account if linkSheenWithAlbedo is true.
  25258. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  25259. */
  25260. roughness: Nullable<number>;
  25261. private _textureRoughness;
  25262. /**
  25263. * Stores the sheen roughness in a texture.
  25264. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  25265. */
  25266. textureRoughness: Nullable<BaseTexture>;
  25267. private _albedoScaling;
  25268. /**
  25269. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  25270. * It allows the strength of the sheen effect to not depend on the base color of the material,
  25271. * making it easier to setup and tweak the effect
  25272. */
  25273. albedoScaling: boolean;
  25274. /** @hidden */
  25275. private _internalMarkAllSubMeshesAsTexturesDirty;
  25276. /** @hidden */
  25277. _markAllSubMeshesAsTexturesDirty(): void;
  25278. /**
  25279. * Instantiate a new istance of clear coat configuration.
  25280. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25281. */
  25282. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25283. /**
  25284. * Specifies that the submesh is ready to be used.
  25285. * @param defines the list of "defines" to update.
  25286. * @param scene defines the scene the material belongs to.
  25287. * @returns - boolean indicating that the submesh is ready or not.
  25288. */
  25289. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  25290. /**
  25291. * Checks to see if a texture is used in the material.
  25292. * @param defines the list of "defines" to update.
  25293. * @param scene defines the scene the material belongs to.
  25294. */
  25295. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  25296. /**
  25297. * Binds the material data.
  25298. * @param uniformBuffer defines the Uniform buffer to fill in.
  25299. * @param scene defines the scene the material belongs to.
  25300. * @param isFrozen defines wether the material is frozen or not.
  25301. * @param subMesh the submesh to bind data for
  25302. */
  25303. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  25304. /**
  25305. * Checks to see if a texture is used in the material.
  25306. * @param texture - Base texture to use.
  25307. * @returns - Boolean specifying if a texture is used in the material.
  25308. */
  25309. hasTexture(texture: BaseTexture): boolean;
  25310. /**
  25311. * Returns an array of the actively used textures.
  25312. * @param activeTextures Array of BaseTextures
  25313. */
  25314. getActiveTextures(activeTextures: BaseTexture[]): void;
  25315. /**
  25316. * Returns the animatable textures.
  25317. * @param animatables Array of animatable textures.
  25318. */
  25319. getAnimatables(animatables: IAnimatable[]): void;
  25320. /**
  25321. * Disposes the resources of the material.
  25322. * @param forceDisposeTextures - Forces the disposal of all textures.
  25323. */
  25324. dispose(forceDisposeTextures?: boolean): void;
  25325. /**
  25326. * Get the current class name of the texture useful for serialization or dynamic coding.
  25327. * @returns "PBRSheenConfiguration"
  25328. */
  25329. getClassName(): string;
  25330. /**
  25331. * Add fallbacks to the effect fallbacks list.
  25332. * @param defines defines the Base texture to use.
  25333. * @param fallbacks defines the current fallback list.
  25334. * @param currentRank defines the current fallback rank.
  25335. * @returns the new fallback rank.
  25336. */
  25337. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25338. /**
  25339. * Add the required uniforms to the current list.
  25340. * @param uniforms defines the current uniform list.
  25341. */
  25342. static AddUniforms(uniforms: string[]): void;
  25343. /**
  25344. * Add the required uniforms to the current buffer.
  25345. * @param uniformBuffer defines the current uniform buffer.
  25346. */
  25347. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25348. /**
  25349. * Add the required samplers to the current list.
  25350. * @param samplers defines the current sampler list.
  25351. */
  25352. static AddSamplers(samplers: string[]): void;
  25353. /**
  25354. * Makes a duplicate of the current configuration into another one.
  25355. * @param sheenConfiguration define the config where to copy the info
  25356. */
  25357. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  25358. /**
  25359. * Serializes this BRDF configuration.
  25360. * @returns - An object with the serialized config.
  25361. */
  25362. serialize(): any;
  25363. /**
  25364. * Parses a anisotropy Configuration from a serialized object.
  25365. * @param source - Serialized object.
  25366. * @param scene Defines the scene we are parsing for
  25367. * @param rootUrl Defines the rootUrl to load from
  25368. */
  25369. parse(source: any, scene: Scene, rootUrl: string): void;
  25370. }
  25371. }
  25372. declare module BABYLON {
  25373. /**
  25374. * @hidden
  25375. */
  25376. export interface IMaterialSubSurfaceDefines {
  25377. SUBSURFACE: boolean;
  25378. SS_REFRACTION: boolean;
  25379. SS_TRANSLUCENCY: boolean;
  25380. SS_SCATTERING: boolean;
  25381. SS_THICKNESSANDMASK_TEXTURE: boolean;
  25382. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  25383. SS_REFRACTIONMAP_3D: boolean;
  25384. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  25385. SS_LODINREFRACTIONALPHA: boolean;
  25386. SS_GAMMAREFRACTION: boolean;
  25387. SS_RGBDREFRACTION: boolean;
  25388. SS_LINEARSPECULARREFRACTION: boolean;
  25389. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  25390. SS_ALBEDOFORREFRACTIONTINT: boolean;
  25391. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  25392. /** @hidden */
  25393. _areTexturesDirty: boolean;
  25394. }
  25395. /**
  25396. * Define the code related to the sub surface parameters of the pbr material.
  25397. */
  25398. export class PBRSubSurfaceConfiguration {
  25399. private _isRefractionEnabled;
  25400. /**
  25401. * Defines if the refraction is enabled in the material.
  25402. */
  25403. isRefractionEnabled: boolean;
  25404. private _isTranslucencyEnabled;
  25405. /**
  25406. * Defines if the translucency is enabled in the material.
  25407. */
  25408. isTranslucencyEnabled: boolean;
  25409. private _isScatteringEnabled;
  25410. /**
  25411. * Defines if the sub surface scattering is enabled in the material.
  25412. */
  25413. isScatteringEnabled: boolean;
  25414. private _scatteringDiffusionProfileIndex;
  25415. /**
  25416. * Diffusion profile for subsurface scattering.
  25417. * Useful for better scattering in the skins or foliages.
  25418. */
  25419. get scatteringDiffusionProfile(): Nullable<Color3>;
  25420. set scatteringDiffusionProfile(c: Nullable<Color3>);
  25421. /**
  25422. * Defines the refraction intensity of the material.
  25423. * The refraction when enabled replaces the Diffuse part of the material.
  25424. * The intensity helps transitionning between diffuse and refraction.
  25425. */
  25426. refractionIntensity: number;
  25427. /**
  25428. * Defines the translucency intensity of the material.
  25429. * When translucency has been enabled, this defines how much of the "translucency"
  25430. * is addded to the diffuse part of the material.
  25431. */
  25432. translucencyIntensity: number;
  25433. /**
  25434. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  25435. */
  25436. useAlbedoToTintRefraction: boolean;
  25437. private _thicknessTexture;
  25438. /**
  25439. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  25440. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  25441. * 0 would mean minimumThickness
  25442. * 1 would mean maximumThickness
  25443. * The other channels might be use as a mask to vary the different effects intensity.
  25444. */
  25445. thicknessTexture: Nullable<BaseTexture>;
  25446. private _refractionTexture;
  25447. /**
  25448. * Defines the texture to use for refraction.
  25449. */
  25450. refractionTexture: Nullable<BaseTexture>;
  25451. private _indexOfRefraction;
  25452. /**
  25453. * Index of refraction of the material base layer.
  25454. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  25455. *
  25456. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  25457. *
  25458. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  25459. */
  25460. indexOfRefraction: number;
  25461. private _volumeIndexOfRefraction;
  25462. /**
  25463. * Index of refraction of the material's volume.
  25464. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  25465. *
  25466. * This ONLY impacts refraction. If not provided or given a non-valid value,
  25467. * the volume will use the same IOR as the surface.
  25468. */
  25469. get volumeIndexOfRefraction(): number;
  25470. set volumeIndexOfRefraction(value: number);
  25471. private _invertRefractionY;
  25472. /**
  25473. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  25474. */
  25475. invertRefractionY: boolean;
  25476. private _linkRefractionWithTransparency;
  25477. /**
  25478. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  25479. * Materials half opaque for instance using refraction could benefit from this control.
  25480. */
  25481. linkRefractionWithTransparency: boolean;
  25482. /**
  25483. * Defines the minimum thickness stored in the thickness map.
  25484. * If no thickness map is defined, this value will be used to simulate thickness.
  25485. */
  25486. minimumThickness: number;
  25487. /**
  25488. * Defines the maximum thickness stored in the thickness map.
  25489. */
  25490. maximumThickness: number;
  25491. /**
  25492. * Defines the volume tint of the material.
  25493. * This is used for both translucency and scattering.
  25494. */
  25495. tintColor: Color3;
  25496. /**
  25497. * Defines the distance at which the tint color should be found in the media.
  25498. * This is used for refraction only.
  25499. */
  25500. tintColorAtDistance: number;
  25501. /**
  25502. * Defines how far each channel transmit through the media.
  25503. * It is defined as a color to simplify it selection.
  25504. */
  25505. diffusionDistance: Color3;
  25506. private _useMaskFromThicknessTexture;
  25507. /**
  25508. * Stores the intensity of the different subsurface effects in the thickness texture.
  25509. * * the green channel is the translucency intensity.
  25510. * * the blue channel is the scattering intensity.
  25511. * * the alpha channel is the refraction intensity.
  25512. */
  25513. useMaskFromThicknessTexture: boolean;
  25514. private _scene;
  25515. /** @hidden */
  25516. private _internalMarkAllSubMeshesAsTexturesDirty;
  25517. private _internalMarkScenePrePassDirty;
  25518. /** @hidden */
  25519. _markAllSubMeshesAsTexturesDirty(): void;
  25520. /** @hidden */
  25521. _markScenePrePassDirty(): void;
  25522. /**
  25523. * Instantiate a new istance of sub surface configuration.
  25524. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25525. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  25526. * @param scene The scene
  25527. */
  25528. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  25529. /**
  25530. * Gets wehter the submesh is ready to be used or not.
  25531. * @param defines the list of "defines" to update.
  25532. * @param scene defines the scene the material belongs to.
  25533. * @returns - boolean indicating that the submesh is ready or not.
  25534. */
  25535. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  25536. /**
  25537. * Checks to see if a texture is used in the material.
  25538. * @param defines the list of "defines" to update.
  25539. * @param scene defines the scene to the material belongs to.
  25540. */
  25541. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  25542. /**
  25543. * Binds the material data.
  25544. * @param uniformBuffer defines the Uniform buffer to fill in.
  25545. * @param scene defines the scene the material belongs to.
  25546. * @param engine defines the engine the material belongs to.
  25547. * @param isFrozen defines whether the material is frozen or not.
  25548. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  25549. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  25550. */
  25551. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  25552. /**
  25553. * Unbinds the material from the mesh.
  25554. * @param activeEffect defines the effect that should be unbound from.
  25555. * @returns true if unbound, otherwise false
  25556. */
  25557. unbind(activeEffect: Effect): boolean;
  25558. /**
  25559. * Returns the texture used for refraction or null if none is used.
  25560. * @param scene defines the scene the material belongs to.
  25561. * @returns - Refraction texture if present. If no refraction texture and refraction
  25562. * is linked with transparency, returns environment texture. Otherwise, returns null.
  25563. */
  25564. private _getRefractionTexture;
  25565. /**
  25566. * Returns true if alpha blending should be disabled.
  25567. */
  25568. get disableAlphaBlending(): boolean;
  25569. /**
  25570. * Fills the list of render target textures.
  25571. * @param renderTargets the list of render targets to update
  25572. */
  25573. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  25574. /**
  25575. * Checks to see if a texture is used in the material.
  25576. * @param texture - Base texture to use.
  25577. * @returns - Boolean specifying if a texture is used in the material.
  25578. */
  25579. hasTexture(texture: BaseTexture): boolean;
  25580. /**
  25581. * Gets a boolean indicating that current material needs to register RTT
  25582. * @returns true if this uses a render target otherwise false.
  25583. */
  25584. hasRenderTargetTextures(): boolean;
  25585. /**
  25586. * Returns an array of the actively used textures.
  25587. * @param activeTextures Array of BaseTextures
  25588. */
  25589. getActiveTextures(activeTextures: BaseTexture[]): void;
  25590. /**
  25591. * Returns the animatable textures.
  25592. * @param animatables Array of animatable textures.
  25593. */
  25594. getAnimatables(animatables: IAnimatable[]): void;
  25595. /**
  25596. * Disposes the resources of the material.
  25597. * @param forceDisposeTextures - Forces the disposal of all textures.
  25598. */
  25599. dispose(forceDisposeTextures?: boolean): void;
  25600. /**
  25601. * Get the current class name of the texture useful for serialization or dynamic coding.
  25602. * @returns "PBRSubSurfaceConfiguration"
  25603. */
  25604. getClassName(): string;
  25605. /**
  25606. * Add fallbacks to the effect fallbacks list.
  25607. * @param defines defines the Base texture to use.
  25608. * @param fallbacks defines the current fallback list.
  25609. * @param currentRank defines the current fallback rank.
  25610. * @returns the new fallback rank.
  25611. */
  25612. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25613. /**
  25614. * Add the required uniforms to the current list.
  25615. * @param uniforms defines the current uniform list.
  25616. */
  25617. static AddUniforms(uniforms: string[]): void;
  25618. /**
  25619. * Add the required samplers to the current list.
  25620. * @param samplers defines the current sampler list.
  25621. */
  25622. static AddSamplers(samplers: string[]): void;
  25623. /**
  25624. * Add the required uniforms to the current buffer.
  25625. * @param uniformBuffer defines the current uniform buffer.
  25626. */
  25627. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25628. /**
  25629. * Makes a duplicate of the current configuration into another one.
  25630. * @param configuration define the config where to copy the info
  25631. */
  25632. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  25633. /**
  25634. * Serializes this Sub Surface configuration.
  25635. * @returns - An object with the serialized config.
  25636. */
  25637. serialize(): any;
  25638. /**
  25639. * Parses a anisotropy Configuration from a serialized object.
  25640. * @param source - Serialized object.
  25641. * @param scene Defines the scene we are parsing for
  25642. * @param rootUrl Defines the rootUrl to load from
  25643. */
  25644. parse(source: any, scene: Scene, rootUrl: string): void;
  25645. }
  25646. }
  25647. declare module BABYLON {
  25648. /**
  25649. * Class representing spherical harmonics coefficients to the 3rd degree
  25650. */
  25651. export class SphericalHarmonics {
  25652. /**
  25653. * Defines whether or not the harmonics have been prescaled for rendering.
  25654. */
  25655. preScaled: boolean;
  25656. /**
  25657. * The l0,0 coefficients of the spherical harmonics
  25658. */
  25659. l00: Vector3;
  25660. /**
  25661. * The l1,-1 coefficients of the spherical harmonics
  25662. */
  25663. l1_1: Vector3;
  25664. /**
  25665. * The l1,0 coefficients of the spherical harmonics
  25666. */
  25667. l10: Vector3;
  25668. /**
  25669. * The l1,1 coefficients of the spherical harmonics
  25670. */
  25671. l11: Vector3;
  25672. /**
  25673. * The l2,-2 coefficients of the spherical harmonics
  25674. */
  25675. l2_2: Vector3;
  25676. /**
  25677. * The l2,-1 coefficients of the spherical harmonics
  25678. */
  25679. l2_1: Vector3;
  25680. /**
  25681. * The l2,0 coefficients of the spherical harmonics
  25682. */
  25683. l20: Vector3;
  25684. /**
  25685. * The l2,1 coefficients of the spherical harmonics
  25686. */
  25687. l21: Vector3;
  25688. /**
  25689. * The l2,2 coefficients of the spherical harmonics
  25690. */
  25691. l22: Vector3;
  25692. /**
  25693. * Adds a light to the spherical harmonics
  25694. * @param direction the direction of the light
  25695. * @param color the color of the light
  25696. * @param deltaSolidAngle the delta solid angle of the light
  25697. */
  25698. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  25699. /**
  25700. * Scales the spherical harmonics by the given amount
  25701. * @param scale the amount to scale
  25702. */
  25703. scaleInPlace(scale: number): void;
  25704. /**
  25705. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  25706. *
  25707. * ```
  25708. * E_lm = A_l * L_lm
  25709. * ```
  25710. *
  25711. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  25712. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  25713. * the scaling factors are given in equation 9.
  25714. */
  25715. convertIncidentRadianceToIrradiance(): void;
  25716. /**
  25717. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  25718. *
  25719. * ```
  25720. * L = (1/pi) * E * rho
  25721. * ```
  25722. *
  25723. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  25724. */
  25725. convertIrradianceToLambertianRadiance(): void;
  25726. /**
  25727. * Integrates the reconstruction coefficients directly in to the SH preventing further
  25728. * required operations at run time.
  25729. *
  25730. * This is simply done by scaling back the SH with Ylm constants parameter.
  25731. * The trigonometric part being applied by the shader at run time.
  25732. */
  25733. preScaleForRendering(): void;
  25734. /**
  25735. * Constructs a spherical harmonics from an array.
  25736. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  25737. * @returns the spherical harmonics
  25738. */
  25739. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  25740. /**
  25741. * Gets the spherical harmonics from polynomial
  25742. * @param polynomial the spherical polynomial
  25743. * @returns the spherical harmonics
  25744. */
  25745. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  25746. }
  25747. /**
  25748. * Class representing spherical polynomial coefficients to the 3rd degree
  25749. */
  25750. export class SphericalPolynomial {
  25751. private _harmonics;
  25752. /**
  25753. * The spherical harmonics used to create the polynomials.
  25754. */
  25755. get preScaledHarmonics(): SphericalHarmonics;
  25756. /**
  25757. * The x coefficients of the spherical polynomial
  25758. */
  25759. x: Vector3;
  25760. /**
  25761. * The y coefficients of the spherical polynomial
  25762. */
  25763. y: Vector3;
  25764. /**
  25765. * The z coefficients of the spherical polynomial
  25766. */
  25767. z: Vector3;
  25768. /**
  25769. * The xx coefficients of the spherical polynomial
  25770. */
  25771. xx: Vector3;
  25772. /**
  25773. * The yy coefficients of the spherical polynomial
  25774. */
  25775. yy: Vector3;
  25776. /**
  25777. * The zz coefficients of the spherical polynomial
  25778. */
  25779. zz: Vector3;
  25780. /**
  25781. * The xy coefficients of the spherical polynomial
  25782. */
  25783. xy: Vector3;
  25784. /**
  25785. * The yz coefficients of the spherical polynomial
  25786. */
  25787. yz: Vector3;
  25788. /**
  25789. * The zx coefficients of the spherical polynomial
  25790. */
  25791. zx: Vector3;
  25792. /**
  25793. * Adds an ambient color to the spherical polynomial
  25794. * @param color the color to add
  25795. */
  25796. addAmbient(color: Color3): void;
  25797. /**
  25798. * Scales the spherical polynomial by the given amount
  25799. * @param scale the amount to scale
  25800. */
  25801. scaleInPlace(scale: number): void;
  25802. /**
  25803. * Gets the spherical polynomial from harmonics
  25804. * @param harmonics the spherical harmonics
  25805. * @returns the spherical polynomial
  25806. */
  25807. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  25808. /**
  25809. * Constructs a spherical polynomial from an array.
  25810. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  25811. * @returns the spherical polynomial
  25812. */
  25813. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  25814. }
  25815. }
  25816. declare module BABYLON {
  25817. /**
  25818. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  25819. */
  25820. export interface CubeMapInfo {
  25821. /**
  25822. * The pixel array for the front face.
  25823. * This is stored in format, left to right, up to down format.
  25824. */
  25825. front: Nullable<ArrayBufferView>;
  25826. /**
  25827. * The pixel array for the back face.
  25828. * This is stored in format, left to right, up to down format.
  25829. */
  25830. back: Nullable<ArrayBufferView>;
  25831. /**
  25832. * The pixel array for the left face.
  25833. * This is stored in format, left to right, up to down format.
  25834. */
  25835. left: Nullable<ArrayBufferView>;
  25836. /**
  25837. * The pixel array for the right face.
  25838. * This is stored in format, left to right, up to down format.
  25839. */
  25840. right: Nullable<ArrayBufferView>;
  25841. /**
  25842. * The pixel array for the up face.
  25843. * This is stored in format, left to right, up to down format.
  25844. */
  25845. up: Nullable<ArrayBufferView>;
  25846. /**
  25847. * The pixel array for the down face.
  25848. * This is stored in format, left to right, up to down format.
  25849. */
  25850. down: Nullable<ArrayBufferView>;
  25851. /**
  25852. * The size of the cubemap stored.
  25853. *
  25854. * Each faces will be size * size pixels.
  25855. */
  25856. size: number;
  25857. /**
  25858. * The format of the texture.
  25859. *
  25860. * RGBA, RGB.
  25861. */
  25862. format: number;
  25863. /**
  25864. * The type of the texture data.
  25865. *
  25866. * UNSIGNED_INT, FLOAT.
  25867. */
  25868. type: number;
  25869. /**
  25870. * Specifies whether the texture is in gamma space.
  25871. */
  25872. gammaSpace: boolean;
  25873. }
  25874. /**
  25875. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  25876. */
  25877. export class PanoramaToCubeMapTools {
  25878. private static FACE_LEFT;
  25879. private static FACE_RIGHT;
  25880. private static FACE_FRONT;
  25881. private static FACE_BACK;
  25882. private static FACE_DOWN;
  25883. private static FACE_UP;
  25884. /**
  25885. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  25886. *
  25887. * @param float32Array The source data.
  25888. * @param inputWidth The width of the input panorama.
  25889. * @param inputHeight The height of the input panorama.
  25890. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  25891. * @return The cubemap data
  25892. */
  25893. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  25894. private static CreateCubemapTexture;
  25895. private static CalcProjectionSpherical;
  25896. }
  25897. }
  25898. declare module BABYLON {
  25899. /**
  25900. * Helper class dealing with the extraction of spherical polynomial dataArray
  25901. * from a cube map.
  25902. */
  25903. export class CubeMapToSphericalPolynomialTools {
  25904. private static FileFaces;
  25905. /**
  25906. * Converts a texture to the according Spherical Polynomial data.
  25907. * This extracts the first 3 orders only as they are the only one used in the lighting.
  25908. *
  25909. * @param texture The texture to extract the information from.
  25910. * @return The Spherical Polynomial data.
  25911. */
  25912. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  25913. /**
  25914. * Converts a cubemap to the according Spherical Polynomial data.
  25915. * This extracts the first 3 orders only as they are the only one used in the lighting.
  25916. *
  25917. * @param cubeInfo The Cube map to extract the information from.
  25918. * @return The Spherical Polynomial data.
  25919. */
  25920. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  25921. }
  25922. }
  25923. declare module BABYLON {
  25924. interface BaseTexture {
  25925. /**
  25926. * Get the polynomial representation of the texture data.
  25927. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25928. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25929. */
  25930. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25931. }
  25932. }
  25933. declare module BABYLON {
  25934. /** @hidden */
  25935. export var pbrFragmentDeclaration: {
  25936. name: string;
  25937. shader: string;
  25938. };
  25939. }
  25940. declare module BABYLON {
  25941. /** @hidden */
  25942. export var pbrUboDeclaration: {
  25943. name: string;
  25944. shader: string;
  25945. };
  25946. }
  25947. declare module BABYLON {
  25948. /** @hidden */
  25949. export var pbrFragmentExtraDeclaration: {
  25950. name: string;
  25951. shader: string;
  25952. };
  25953. }
  25954. declare module BABYLON {
  25955. /** @hidden */
  25956. export var pbrFragmentSamplersDeclaration: {
  25957. name: string;
  25958. shader: string;
  25959. };
  25960. }
  25961. declare module BABYLON {
  25962. /** @hidden */
  25963. export var subSurfaceScatteringFunctions: {
  25964. name: string;
  25965. shader: string;
  25966. };
  25967. }
  25968. declare module BABYLON {
  25969. /** @hidden */
  25970. export var importanceSampling: {
  25971. name: string;
  25972. shader: string;
  25973. };
  25974. }
  25975. declare module BABYLON {
  25976. /** @hidden */
  25977. export var pbrHelperFunctions: {
  25978. name: string;
  25979. shader: string;
  25980. };
  25981. }
  25982. declare module BABYLON {
  25983. /** @hidden */
  25984. export var harmonicsFunctions: {
  25985. name: string;
  25986. shader: string;
  25987. };
  25988. }
  25989. declare module BABYLON {
  25990. /** @hidden */
  25991. export var pbrDirectLightingSetupFunctions: {
  25992. name: string;
  25993. shader: string;
  25994. };
  25995. }
  25996. declare module BABYLON {
  25997. /** @hidden */
  25998. export var pbrDirectLightingFalloffFunctions: {
  25999. name: string;
  26000. shader: string;
  26001. };
  26002. }
  26003. declare module BABYLON {
  26004. /** @hidden */
  26005. export var pbrBRDFFunctions: {
  26006. name: string;
  26007. shader: string;
  26008. };
  26009. }
  26010. declare module BABYLON {
  26011. /** @hidden */
  26012. export var hdrFilteringFunctions: {
  26013. name: string;
  26014. shader: string;
  26015. };
  26016. }
  26017. declare module BABYLON {
  26018. /** @hidden */
  26019. export var pbrDirectLightingFunctions: {
  26020. name: string;
  26021. shader: string;
  26022. };
  26023. }
  26024. declare module BABYLON {
  26025. /** @hidden */
  26026. export var pbrIBLFunctions: {
  26027. name: string;
  26028. shader: string;
  26029. };
  26030. }
  26031. declare module BABYLON {
  26032. /** @hidden */
  26033. export var pbrBlockAlbedoOpacity: {
  26034. name: string;
  26035. shader: string;
  26036. };
  26037. }
  26038. declare module BABYLON {
  26039. /** @hidden */
  26040. export var pbrBlockReflectivity: {
  26041. name: string;
  26042. shader: string;
  26043. };
  26044. }
  26045. declare module BABYLON {
  26046. /** @hidden */
  26047. export var pbrBlockAmbientOcclusion: {
  26048. name: string;
  26049. shader: string;
  26050. };
  26051. }
  26052. declare module BABYLON {
  26053. /** @hidden */
  26054. export var pbrBlockAlphaFresnel: {
  26055. name: string;
  26056. shader: string;
  26057. };
  26058. }
  26059. declare module BABYLON {
  26060. /** @hidden */
  26061. export var pbrBlockAnisotropic: {
  26062. name: string;
  26063. shader: string;
  26064. };
  26065. }
  26066. declare module BABYLON {
  26067. /** @hidden */
  26068. export var pbrBlockReflection: {
  26069. name: string;
  26070. shader: string;
  26071. };
  26072. }
  26073. declare module BABYLON {
  26074. /** @hidden */
  26075. export var pbrBlockSheen: {
  26076. name: string;
  26077. shader: string;
  26078. };
  26079. }
  26080. declare module BABYLON {
  26081. /** @hidden */
  26082. export var pbrBlockClearcoat: {
  26083. name: string;
  26084. shader: string;
  26085. };
  26086. }
  26087. declare module BABYLON {
  26088. /** @hidden */
  26089. export var pbrBlockSubSurface: {
  26090. name: string;
  26091. shader: string;
  26092. };
  26093. }
  26094. declare module BABYLON {
  26095. /** @hidden */
  26096. export var pbrBlockNormalGeometric: {
  26097. name: string;
  26098. shader: string;
  26099. };
  26100. }
  26101. declare module BABYLON {
  26102. /** @hidden */
  26103. export var pbrBlockNormalFinal: {
  26104. name: string;
  26105. shader: string;
  26106. };
  26107. }
  26108. declare module BABYLON {
  26109. /** @hidden */
  26110. export var pbrBlockLightmapInit: {
  26111. name: string;
  26112. shader: string;
  26113. };
  26114. }
  26115. declare module BABYLON {
  26116. /** @hidden */
  26117. export var pbrBlockGeometryInfo: {
  26118. name: string;
  26119. shader: string;
  26120. };
  26121. }
  26122. declare module BABYLON {
  26123. /** @hidden */
  26124. export var pbrBlockReflectance0: {
  26125. name: string;
  26126. shader: string;
  26127. };
  26128. }
  26129. declare module BABYLON {
  26130. /** @hidden */
  26131. export var pbrBlockReflectance: {
  26132. name: string;
  26133. shader: string;
  26134. };
  26135. }
  26136. declare module BABYLON {
  26137. /** @hidden */
  26138. export var pbrBlockDirectLighting: {
  26139. name: string;
  26140. shader: string;
  26141. };
  26142. }
  26143. declare module BABYLON {
  26144. /** @hidden */
  26145. export var pbrBlockFinalLitComponents: {
  26146. name: string;
  26147. shader: string;
  26148. };
  26149. }
  26150. declare module BABYLON {
  26151. /** @hidden */
  26152. export var pbrBlockFinalUnlitComponents: {
  26153. name: string;
  26154. shader: string;
  26155. };
  26156. }
  26157. declare module BABYLON {
  26158. /** @hidden */
  26159. export var pbrBlockFinalColorComposition: {
  26160. name: string;
  26161. shader: string;
  26162. };
  26163. }
  26164. declare module BABYLON {
  26165. /** @hidden */
  26166. export var pbrBlockImageProcessing: {
  26167. name: string;
  26168. shader: string;
  26169. };
  26170. }
  26171. declare module BABYLON {
  26172. /** @hidden */
  26173. export var pbrDebug: {
  26174. name: string;
  26175. shader: string;
  26176. };
  26177. }
  26178. declare module BABYLON {
  26179. /** @hidden */
  26180. export var pbrPixelShader: {
  26181. name: string;
  26182. shader: string;
  26183. };
  26184. }
  26185. declare module BABYLON {
  26186. /** @hidden */
  26187. export var pbrVertexDeclaration: {
  26188. name: string;
  26189. shader: string;
  26190. };
  26191. }
  26192. declare module BABYLON {
  26193. /** @hidden */
  26194. export var pbrVertexShader: {
  26195. name: string;
  26196. shader: string;
  26197. };
  26198. }
  26199. declare module BABYLON {
  26200. /**
  26201. * Manages the defines for the PBR Material.
  26202. * @hidden
  26203. */
  26204. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  26205. PBR: boolean;
  26206. NUM_SAMPLES: string;
  26207. REALTIME_FILTERING: boolean;
  26208. MAINUV1: boolean;
  26209. MAINUV2: boolean;
  26210. UV1: boolean;
  26211. UV2: boolean;
  26212. ALBEDO: boolean;
  26213. GAMMAALBEDO: boolean;
  26214. ALBEDODIRECTUV: number;
  26215. VERTEXCOLOR: boolean;
  26216. DETAIL: boolean;
  26217. DETAILDIRECTUV: number;
  26218. DETAIL_NORMALBLENDMETHOD: number;
  26219. AMBIENT: boolean;
  26220. AMBIENTDIRECTUV: number;
  26221. AMBIENTINGRAYSCALE: boolean;
  26222. OPACITY: boolean;
  26223. VERTEXALPHA: boolean;
  26224. OPACITYDIRECTUV: number;
  26225. OPACITYRGB: boolean;
  26226. ALPHATEST: boolean;
  26227. DEPTHPREPASS: boolean;
  26228. ALPHABLEND: boolean;
  26229. ALPHAFROMALBEDO: boolean;
  26230. ALPHATESTVALUE: string;
  26231. SPECULAROVERALPHA: boolean;
  26232. RADIANCEOVERALPHA: boolean;
  26233. ALPHAFRESNEL: boolean;
  26234. LINEARALPHAFRESNEL: boolean;
  26235. PREMULTIPLYALPHA: boolean;
  26236. EMISSIVE: boolean;
  26237. EMISSIVEDIRECTUV: number;
  26238. REFLECTIVITY: boolean;
  26239. REFLECTIVITYDIRECTUV: number;
  26240. SPECULARTERM: boolean;
  26241. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  26242. MICROSURFACEAUTOMATIC: boolean;
  26243. LODBASEDMICROSFURACE: boolean;
  26244. MICROSURFACEMAP: boolean;
  26245. MICROSURFACEMAPDIRECTUV: number;
  26246. METALLICWORKFLOW: boolean;
  26247. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  26248. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  26249. METALLNESSSTOREINMETALMAPBLUE: boolean;
  26250. AOSTOREINMETALMAPRED: boolean;
  26251. METALLIC_REFLECTANCE: boolean;
  26252. METALLIC_REFLECTANCEDIRECTUV: number;
  26253. ENVIRONMENTBRDF: boolean;
  26254. ENVIRONMENTBRDF_RGBD: boolean;
  26255. NORMAL: boolean;
  26256. TANGENT: boolean;
  26257. BUMP: boolean;
  26258. BUMPDIRECTUV: number;
  26259. OBJECTSPACE_NORMALMAP: boolean;
  26260. PARALLAX: boolean;
  26261. PARALLAXOCCLUSION: boolean;
  26262. NORMALXYSCALE: boolean;
  26263. LIGHTMAP: boolean;
  26264. LIGHTMAPDIRECTUV: number;
  26265. USELIGHTMAPASSHADOWMAP: boolean;
  26266. GAMMALIGHTMAP: boolean;
  26267. RGBDLIGHTMAP: boolean;
  26268. REFLECTION: boolean;
  26269. REFLECTIONMAP_3D: boolean;
  26270. REFLECTIONMAP_SPHERICAL: boolean;
  26271. REFLECTIONMAP_PLANAR: boolean;
  26272. REFLECTIONMAP_CUBIC: boolean;
  26273. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26274. REFLECTIONMAP_PROJECTION: boolean;
  26275. REFLECTIONMAP_SKYBOX: boolean;
  26276. REFLECTIONMAP_EXPLICIT: boolean;
  26277. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26278. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26279. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26280. INVERTCUBICMAP: boolean;
  26281. USESPHERICALFROMREFLECTIONMAP: boolean;
  26282. USEIRRADIANCEMAP: boolean;
  26283. SPHERICAL_HARMONICS: boolean;
  26284. USESPHERICALINVERTEX: boolean;
  26285. REFLECTIONMAP_OPPOSITEZ: boolean;
  26286. LODINREFLECTIONALPHA: boolean;
  26287. GAMMAREFLECTION: boolean;
  26288. RGBDREFLECTION: boolean;
  26289. LINEARSPECULARREFLECTION: boolean;
  26290. RADIANCEOCCLUSION: boolean;
  26291. HORIZONOCCLUSION: boolean;
  26292. INSTANCES: boolean;
  26293. THIN_INSTANCES: boolean;
  26294. PREPASS: boolean;
  26295. PREPASS_IRRADIANCE: boolean;
  26296. PREPASS_IRRADIANCE_INDEX: number;
  26297. PREPASS_ALBEDO: boolean;
  26298. PREPASS_ALBEDO_INDEX: number;
  26299. PREPASS_DEPTHNORMAL: boolean;
  26300. PREPASS_DEPTHNORMAL_INDEX: number;
  26301. PREPASS_POSITION: boolean;
  26302. PREPASS_POSITION_INDEX: number;
  26303. PREPASS_VELOCITY: boolean;
  26304. PREPASS_VELOCITY_INDEX: number;
  26305. PREPASS_REFLECTIVITY: boolean;
  26306. PREPASS_REFLECTIVITY_INDEX: number;
  26307. SCENE_MRT_COUNT: number;
  26308. NUM_BONE_INFLUENCERS: number;
  26309. BonesPerMesh: number;
  26310. BONETEXTURE: boolean;
  26311. BONES_VELOCITY_ENABLED: boolean;
  26312. NONUNIFORMSCALING: boolean;
  26313. MORPHTARGETS: boolean;
  26314. MORPHTARGETS_NORMAL: boolean;
  26315. MORPHTARGETS_TANGENT: boolean;
  26316. MORPHTARGETS_UV: boolean;
  26317. NUM_MORPH_INFLUENCERS: number;
  26318. IMAGEPROCESSING: boolean;
  26319. VIGNETTE: boolean;
  26320. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26321. VIGNETTEBLENDMODEOPAQUE: boolean;
  26322. TONEMAPPING: boolean;
  26323. TONEMAPPING_ACES: boolean;
  26324. CONTRAST: boolean;
  26325. COLORCURVES: boolean;
  26326. COLORGRADING: boolean;
  26327. COLORGRADING3D: boolean;
  26328. SAMPLER3DGREENDEPTH: boolean;
  26329. SAMPLER3DBGRMAP: boolean;
  26330. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26331. EXPOSURE: boolean;
  26332. MULTIVIEW: boolean;
  26333. USEPHYSICALLIGHTFALLOFF: boolean;
  26334. USEGLTFLIGHTFALLOFF: boolean;
  26335. TWOSIDEDLIGHTING: boolean;
  26336. SHADOWFLOAT: boolean;
  26337. CLIPPLANE: boolean;
  26338. CLIPPLANE2: boolean;
  26339. CLIPPLANE3: boolean;
  26340. CLIPPLANE4: boolean;
  26341. CLIPPLANE5: boolean;
  26342. CLIPPLANE6: boolean;
  26343. POINTSIZE: boolean;
  26344. FOG: boolean;
  26345. LOGARITHMICDEPTH: boolean;
  26346. FORCENORMALFORWARD: boolean;
  26347. SPECULARAA: boolean;
  26348. CLEARCOAT: boolean;
  26349. CLEARCOAT_DEFAULTIOR: boolean;
  26350. CLEARCOAT_TEXTURE: boolean;
  26351. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  26352. CLEARCOAT_TEXTUREDIRECTUV: number;
  26353. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  26354. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  26355. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  26356. CLEARCOAT_BUMP: boolean;
  26357. CLEARCOAT_BUMPDIRECTUV: number;
  26358. CLEARCOAT_REMAP_F0: boolean;
  26359. CLEARCOAT_TINT: boolean;
  26360. CLEARCOAT_TINT_TEXTURE: boolean;
  26361. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  26362. ANISOTROPIC: boolean;
  26363. ANISOTROPIC_TEXTURE: boolean;
  26364. ANISOTROPIC_TEXTUREDIRECTUV: number;
  26365. BRDF_V_HEIGHT_CORRELATED: boolean;
  26366. MS_BRDF_ENERGY_CONSERVATION: boolean;
  26367. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  26368. SHEEN: boolean;
  26369. SHEEN_TEXTURE: boolean;
  26370. SHEEN_TEXTURE_ROUGHNESS: boolean;
  26371. SHEEN_TEXTUREDIRECTUV: number;
  26372. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  26373. SHEEN_LINKWITHALBEDO: boolean;
  26374. SHEEN_ROUGHNESS: boolean;
  26375. SHEEN_ALBEDOSCALING: boolean;
  26376. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  26377. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  26378. SUBSURFACE: boolean;
  26379. SS_REFRACTION: boolean;
  26380. SS_TRANSLUCENCY: boolean;
  26381. SS_SCATTERING: boolean;
  26382. SS_THICKNESSANDMASK_TEXTURE: boolean;
  26383. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  26384. SS_REFRACTIONMAP_3D: boolean;
  26385. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  26386. SS_LODINREFRACTIONALPHA: boolean;
  26387. SS_GAMMAREFRACTION: boolean;
  26388. SS_RGBDREFRACTION: boolean;
  26389. SS_LINEARSPECULARREFRACTION: boolean;
  26390. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  26391. SS_ALBEDOFORREFRACTIONTINT: boolean;
  26392. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  26393. UNLIT: boolean;
  26394. DEBUGMODE: number;
  26395. /**
  26396. * Initializes the PBR Material defines.
  26397. */
  26398. constructor();
  26399. /**
  26400. * Resets the PBR Material defines.
  26401. */
  26402. reset(): void;
  26403. }
  26404. /**
  26405. * The Physically based material base class of BJS.
  26406. *
  26407. * This offers the main features of a standard PBR material.
  26408. * For more information, please refer to the documentation :
  26409. * https://doc.babylonjs.com/how_to/physically_based_rendering
  26410. */
  26411. export abstract class PBRBaseMaterial extends PushMaterial {
  26412. /**
  26413. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  26414. */
  26415. static readonly PBRMATERIAL_OPAQUE: number;
  26416. /**
  26417. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  26418. */
  26419. static readonly PBRMATERIAL_ALPHATEST: number;
  26420. /**
  26421. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26422. */
  26423. static readonly PBRMATERIAL_ALPHABLEND: number;
  26424. /**
  26425. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26426. * They are also discarded below the alpha cutoff threshold to improve performances.
  26427. */
  26428. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  26429. /**
  26430. * Defines the default value of how much AO map is occluding the analytical lights
  26431. * (point spot...).
  26432. */
  26433. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  26434. /**
  26435. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  26436. */
  26437. static readonly LIGHTFALLOFF_PHYSICAL: number;
  26438. /**
  26439. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  26440. * to enhance interoperability with other engines.
  26441. */
  26442. static readonly LIGHTFALLOFF_GLTF: number;
  26443. /**
  26444. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  26445. * to enhance interoperability with other materials.
  26446. */
  26447. static readonly LIGHTFALLOFF_STANDARD: number;
  26448. /**
  26449. * Intensity of the direct lights e.g. the four lights available in your scene.
  26450. * This impacts both the direct diffuse and specular highlights.
  26451. */
  26452. protected _directIntensity: number;
  26453. /**
  26454. * Intensity of the emissive part of the material.
  26455. * This helps controlling the emissive effect without modifying the emissive color.
  26456. */
  26457. protected _emissiveIntensity: number;
  26458. /**
  26459. * Intensity of the environment e.g. how much the environment will light the object
  26460. * either through harmonics for rough material or through the refelction for shiny ones.
  26461. */
  26462. protected _environmentIntensity: number;
  26463. /**
  26464. * This is a special control allowing the reduction of the specular highlights coming from the
  26465. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  26466. */
  26467. protected _specularIntensity: number;
  26468. /**
  26469. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  26470. */
  26471. private _lightingInfos;
  26472. /**
  26473. * Debug Control allowing disabling the bump map on this material.
  26474. */
  26475. protected _disableBumpMap: boolean;
  26476. /**
  26477. * AKA Diffuse Texture in standard nomenclature.
  26478. */
  26479. protected _albedoTexture: Nullable<BaseTexture>;
  26480. /**
  26481. * AKA Occlusion Texture in other nomenclature.
  26482. */
  26483. protected _ambientTexture: Nullable<BaseTexture>;
  26484. /**
  26485. * AKA Occlusion Texture Intensity in other nomenclature.
  26486. */
  26487. protected _ambientTextureStrength: number;
  26488. /**
  26489. * Defines how much the AO map is occluding the analytical lights (point spot...).
  26490. * 1 means it completely occludes it
  26491. * 0 mean it has no impact
  26492. */
  26493. protected _ambientTextureImpactOnAnalyticalLights: number;
  26494. /**
  26495. * Stores the alpha values in a texture.
  26496. */
  26497. protected _opacityTexture: Nullable<BaseTexture>;
  26498. /**
  26499. * Stores the reflection values in a texture.
  26500. */
  26501. protected _reflectionTexture: Nullable<BaseTexture>;
  26502. /**
  26503. * Stores the emissive values in a texture.
  26504. */
  26505. protected _emissiveTexture: Nullable<BaseTexture>;
  26506. /**
  26507. * AKA Specular texture in other nomenclature.
  26508. */
  26509. protected _reflectivityTexture: Nullable<BaseTexture>;
  26510. /**
  26511. * Used to switch from specular/glossiness to metallic/roughness workflow.
  26512. */
  26513. protected _metallicTexture: Nullable<BaseTexture>;
  26514. /**
  26515. * Specifies the metallic scalar of the metallic/roughness workflow.
  26516. * Can also be used to scale the metalness values of the metallic texture.
  26517. */
  26518. protected _metallic: Nullable<number>;
  26519. /**
  26520. * Specifies the roughness scalar of the metallic/roughness workflow.
  26521. * Can also be used to scale the roughness values of the metallic texture.
  26522. */
  26523. protected _roughness: Nullable<number>;
  26524. /**
  26525. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  26526. * By default the indexOfrefraction is used to compute F0;
  26527. *
  26528. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  26529. *
  26530. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  26531. * F90 = metallicReflectanceColor;
  26532. */
  26533. protected _metallicF0Factor: number;
  26534. /**
  26535. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  26536. * By default the F90 is always 1;
  26537. *
  26538. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  26539. *
  26540. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  26541. * F90 = metallicReflectanceColor;
  26542. */
  26543. protected _metallicReflectanceColor: Color3;
  26544. /**
  26545. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  26546. * This is multiply against the scalar values defined in the material.
  26547. */
  26548. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  26549. /**
  26550. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  26551. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  26552. */
  26553. protected _microSurfaceTexture: Nullable<BaseTexture>;
  26554. /**
  26555. * Stores surface normal data used to displace a mesh in a texture.
  26556. */
  26557. protected _bumpTexture: Nullable<BaseTexture>;
  26558. /**
  26559. * Stores the pre-calculated light information of a mesh in a texture.
  26560. */
  26561. protected _lightmapTexture: Nullable<BaseTexture>;
  26562. /**
  26563. * The color of a material in ambient lighting.
  26564. */
  26565. protected _ambientColor: Color3;
  26566. /**
  26567. * AKA Diffuse Color in other nomenclature.
  26568. */
  26569. protected _albedoColor: Color3;
  26570. /**
  26571. * AKA Specular Color in other nomenclature.
  26572. */
  26573. protected _reflectivityColor: Color3;
  26574. /**
  26575. * The color applied when light is reflected from a material.
  26576. */
  26577. protected _reflectionColor: Color3;
  26578. /**
  26579. * The color applied when light is emitted from a material.
  26580. */
  26581. protected _emissiveColor: Color3;
  26582. /**
  26583. * AKA Glossiness in other nomenclature.
  26584. */
  26585. protected _microSurface: number;
  26586. /**
  26587. * Specifies that the material will use the light map as a show map.
  26588. */
  26589. protected _useLightmapAsShadowmap: boolean;
  26590. /**
  26591. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  26592. * makes the reflect vector face the model (under horizon).
  26593. */
  26594. protected _useHorizonOcclusion: boolean;
  26595. /**
  26596. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  26597. * too much the area relying on ambient texture to define their ambient occlusion.
  26598. */
  26599. protected _useRadianceOcclusion: boolean;
  26600. /**
  26601. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  26602. */
  26603. protected _useAlphaFromAlbedoTexture: boolean;
  26604. /**
  26605. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  26606. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26607. */
  26608. protected _useSpecularOverAlpha: boolean;
  26609. /**
  26610. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  26611. */
  26612. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  26613. /**
  26614. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  26615. */
  26616. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  26617. /**
  26618. * Specifies if the metallic texture contains the roughness information in its green channel.
  26619. */
  26620. protected _useRoughnessFromMetallicTextureGreen: boolean;
  26621. /**
  26622. * Specifies if the metallic texture contains the metallness information in its blue channel.
  26623. */
  26624. protected _useMetallnessFromMetallicTextureBlue: boolean;
  26625. /**
  26626. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  26627. */
  26628. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  26629. /**
  26630. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  26631. */
  26632. protected _useAmbientInGrayScale: boolean;
  26633. /**
  26634. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  26635. * The material will try to infer what glossiness each pixel should be.
  26636. */
  26637. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  26638. /**
  26639. * Defines the falloff type used in this material.
  26640. * It by default is Physical.
  26641. */
  26642. protected _lightFalloff: number;
  26643. /**
  26644. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26645. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26646. */
  26647. protected _useRadianceOverAlpha: boolean;
  26648. /**
  26649. * Allows using an object space normal map (instead of tangent space).
  26650. */
  26651. protected _useObjectSpaceNormalMap: boolean;
  26652. /**
  26653. * Allows using the bump map in parallax mode.
  26654. */
  26655. protected _useParallax: boolean;
  26656. /**
  26657. * Allows using the bump map in parallax occlusion mode.
  26658. */
  26659. protected _useParallaxOcclusion: boolean;
  26660. /**
  26661. * Controls the scale bias of the parallax mode.
  26662. */
  26663. protected _parallaxScaleBias: number;
  26664. /**
  26665. * If sets to true, disables all the lights affecting the material.
  26666. */
  26667. protected _disableLighting: boolean;
  26668. /**
  26669. * Number of Simultaneous lights allowed on the material.
  26670. */
  26671. protected _maxSimultaneousLights: number;
  26672. /**
  26673. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  26674. */
  26675. protected _invertNormalMapX: boolean;
  26676. /**
  26677. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  26678. */
  26679. protected _invertNormalMapY: boolean;
  26680. /**
  26681. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26682. */
  26683. protected _twoSidedLighting: boolean;
  26684. /**
  26685. * Defines the alpha limits in alpha test mode.
  26686. */
  26687. protected _alphaCutOff: number;
  26688. /**
  26689. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  26690. */
  26691. protected _forceAlphaTest: boolean;
  26692. /**
  26693. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26694. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  26695. */
  26696. protected _useAlphaFresnel: boolean;
  26697. /**
  26698. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26699. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  26700. */
  26701. protected _useLinearAlphaFresnel: boolean;
  26702. /**
  26703. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  26704. * from cos thetav and roughness:
  26705. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  26706. */
  26707. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  26708. /**
  26709. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  26710. */
  26711. protected _forceIrradianceInFragment: boolean;
  26712. private _realTimeFiltering;
  26713. /**
  26714. * Enables realtime filtering on the texture.
  26715. */
  26716. get realTimeFiltering(): boolean;
  26717. set realTimeFiltering(b: boolean);
  26718. private _realTimeFilteringQuality;
  26719. /**
  26720. * Quality switch for realtime filtering
  26721. */
  26722. get realTimeFilteringQuality(): number;
  26723. set realTimeFilteringQuality(n: number);
  26724. /**
  26725. * Can this material render to several textures at once
  26726. */
  26727. get canRenderToMRT(): boolean;
  26728. /**
  26729. * Force normal to face away from face.
  26730. */
  26731. protected _forceNormalForward: boolean;
  26732. /**
  26733. * Enables specular anti aliasing in the PBR shader.
  26734. * It will both interacts on the Geometry for analytical and IBL lighting.
  26735. * It also prefilter the roughness map based on the bump values.
  26736. */
  26737. protected _enableSpecularAntiAliasing: boolean;
  26738. /**
  26739. * Default configuration related to image processing available in the PBR Material.
  26740. */
  26741. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26742. /**
  26743. * Keep track of the image processing observer to allow dispose and replace.
  26744. */
  26745. private _imageProcessingObserver;
  26746. /**
  26747. * Attaches a new image processing configuration to the PBR Material.
  26748. * @param configuration
  26749. */
  26750. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26751. /**
  26752. * Stores the available render targets.
  26753. */
  26754. private _renderTargets;
  26755. /**
  26756. * Sets the global ambient color for the material used in lighting calculations.
  26757. */
  26758. private _globalAmbientColor;
  26759. /**
  26760. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  26761. */
  26762. private _useLogarithmicDepth;
  26763. /**
  26764. * If set to true, no lighting calculations will be applied.
  26765. */
  26766. private _unlit;
  26767. private _debugMode;
  26768. /**
  26769. * @hidden
  26770. * This is reserved for the inspector.
  26771. * Defines the material debug mode.
  26772. * It helps seeing only some components of the material while troubleshooting.
  26773. */
  26774. debugMode: number;
  26775. /**
  26776. * @hidden
  26777. * This is reserved for the inspector.
  26778. * Specify from where on screen the debug mode should start.
  26779. * The value goes from -1 (full screen) to 1 (not visible)
  26780. * It helps with side by side comparison against the final render
  26781. * This defaults to -1
  26782. */
  26783. private debugLimit;
  26784. /**
  26785. * @hidden
  26786. * This is reserved for the inspector.
  26787. * As the default viewing range might not be enough (if the ambient is really small for instance)
  26788. * You can use the factor to better multiply the final value.
  26789. */
  26790. private debugFactor;
  26791. /**
  26792. * Defines the clear coat layer parameters for the material.
  26793. */
  26794. readonly clearCoat: PBRClearCoatConfiguration;
  26795. /**
  26796. * Defines the anisotropic parameters for the material.
  26797. */
  26798. readonly anisotropy: PBRAnisotropicConfiguration;
  26799. /**
  26800. * Defines the BRDF parameters for the material.
  26801. */
  26802. readonly brdf: PBRBRDFConfiguration;
  26803. /**
  26804. * Defines the Sheen parameters for the material.
  26805. */
  26806. readonly sheen: PBRSheenConfiguration;
  26807. /**
  26808. * Defines the SubSurface parameters for the material.
  26809. */
  26810. readonly subSurface: PBRSubSurfaceConfiguration;
  26811. /**
  26812. * Defines additionnal PrePass parameters for the material.
  26813. */
  26814. readonly prePassConfiguration: PrePassConfiguration;
  26815. /**
  26816. * Defines the detail map parameters for the material.
  26817. */
  26818. readonly detailMap: DetailMapConfiguration;
  26819. protected _rebuildInParallel: boolean;
  26820. /**
  26821. * Instantiates a new PBRMaterial instance.
  26822. *
  26823. * @param name The material name
  26824. * @param scene The scene the material will be use in.
  26825. */
  26826. constructor(name: string, scene: Scene);
  26827. /**
  26828. * Gets a boolean indicating that current material needs to register RTT
  26829. */
  26830. get hasRenderTargetTextures(): boolean;
  26831. /**
  26832. * Gets the name of the material class.
  26833. */
  26834. getClassName(): string;
  26835. /**
  26836. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  26837. */
  26838. get useLogarithmicDepth(): boolean;
  26839. /**
  26840. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  26841. */
  26842. set useLogarithmicDepth(value: boolean);
  26843. /**
  26844. * Returns true if alpha blending should be disabled.
  26845. */
  26846. protected get _disableAlphaBlending(): boolean;
  26847. /**
  26848. * Specifies whether or not this material should be rendered in alpha blend mode.
  26849. */
  26850. needAlphaBlending(): boolean;
  26851. /**
  26852. * Specifies whether or not this material should be rendered in alpha test mode.
  26853. */
  26854. needAlphaTesting(): boolean;
  26855. /**
  26856. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  26857. */
  26858. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  26859. /**
  26860. * Specifies whether or not there is a usable alpha channel for transparency.
  26861. */
  26862. protected _hasAlphaChannel(): boolean;
  26863. /**
  26864. * Gets the texture used for the alpha test.
  26865. */
  26866. getAlphaTestTexture(): Nullable<BaseTexture>;
  26867. /**
  26868. * Specifies that the submesh is ready to be used.
  26869. * @param mesh - BJS mesh.
  26870. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  26871. * @param useInstances - Specifies that instances should be used.
  26872. * @returns - boolean indicating that the submesh is ready or not.
  26873. */
  26874. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26875. /**
  26876. * Specifies if the material uses metallic roughness workflow.
  26877. * @returns boolean specifiying if the material uses metallic roughness workflow.
  26878. */
  26879. isMetallicWorkflow(): boolean;
  26880. private _prepareEffect;
  26881. private _prepareDefines;
  26882. /**
  26883. * Force shader compilation
  26884. */
  26885. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  26886. /**
  26887. * Initializes the uniform buffer layout for the shader.
  26888. */
  26889. buildUniformLayout(): void;
  26890. /**
  26891. * Unbinds the material from the mesh
  26892. */
  26893. unbind(): void;
  26894. /**
  26895. * Binds the submesh data.
  26896. * @param world - The world matrix.
  26897. * @param mesh - The BJS mesh.
  26898. * @param subMesh - A submesh of the BJS mesh.
  26899. */
  26900. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26901. /**
  26902. * Returns the animatable textures.
  26903. * @returns - Array of animatable textures.
  26904. */
  26905. getAnimatables(): IAnimatable[];
  26906. /**
  26907. * Returns the texture used for reflections.
  26908. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  26909. */
  26910. private _getReflectionTexture;
  26911. /**
  26912. * Returns an array of the actively used textures.
  26913. * @returns - Array of BaseTextures
  26914. */
  26915. getActiveTextures(): BaseTexture[];
  26916. /**
  26917. * Checks to see if a texture is used in the material.
  26918. * @param texture - Base texture to use.
  26919. * @returns - Boolean specifying if a texture is used in the material.
  26920. */
  26921. hasTexture(texture: BaseTexture): boolean;
  26922. /**
  26923. * Sets the required values to the prepass renderer.
  26924. * @param prePassRenderer defines the prepass renderer to setup
  26925. */
  26926. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  26927. /**
  26928. * Disposes the resources of the material.
  26929. * @param forceDisposeEffect - Forces the disposal of effects.
  26930. * @param forceDisposeTextures - Forces the disposal of all textures.
  26931. */
  26932. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26933. }
  26934. }
  26935. declare module BABYLON {
  26936. /**
  26937. * The Physically based material of BJS.
  26938. *
  26939. * This offers the main features of a standard PBR material.
  26940. * For more information, please refer to the documentation :
  26941. * https://doc.babylonjs.com/how_to/physically_based_rendering
  26942. */
  26943. export class PBRMaterial extends PBRBaseMaterial {
  26944. /**
  26945. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  26946. */
  26947. static readonly PBRMATERIAL_OPAQUE: number;
  26948. /**
  26949. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  26950. */
  26951. static readonly PBRMATERIAL_ALPHATEST: number;
  26952. /**
  26953. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26954. */
  26955. static readonly PBRMATERIAL_ALPHABLEND: number;
  26956. /**
  26957. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26958. * They are also discarded below the alpha cutoff threshold to improve performances.
  26959. */
  26960. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  26961. /**
  26962. * Defines the default value of how much AO map is occluding the analytical lights
  26963. * (point spot...).
  26964. */
  26965. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  26966. /**
  26967. * Intensity of the direct lights e.g. the four lights available in your scene.
  26968. * This impacts both the direct diffuse and specular highlights.
  26969. */
  26970. directIntensity: number;
  26971. /**
  26972. * Intensity of the emissive part of the material.
  26973. * This helps controlling the emissive effect without modifying the emissive color.
  26974. */
  26975. emissiveIntensity: number;
  26976. /**
  26977. * Intensity of the environment e.g. how much the environment will light the object
  26978. * either through harmonics for rough material or through the refelction for shiny ones.
  26979. */
  26980. environmentIntensity: number;
  26981. /**
  26982. * This is a special control allowing the reduction of the specular highlights coming from the
  26983. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  26984. */
  26985. specularIntensity: number;
  26986. /**
  26987. * Debug Control allowing disabling the bump map on this material.
  26988. */
  26989. disableBumpMap: boolean;
  26990. /**
  26991. * AKA Diffuse Texture in standard nomenclature.
  26992. */
  26993. albedoTexture: BaseTexture;
  26994. /**
  26995. * AKA Occlusion Texture in other nomenclature.
  26996. */
  26997. ambientTexture: BaseTexture;
  26998. /**
  26999. * AKA Occlusion Texture Intensity in other nomenclature.
  27000. */
  27001. ambientTextureStrength: number;
  27002. /**
  27003. * Defines how much the AO map is occluding the analytical lights (point spot...).
  27004. * 1 means it completely occludes it
  27005. * 0 mean it has no impact
  27006. */
  27007. ambientTextureImpactOnAnalyticalLights: number;
  27008. /**
  27009. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  27010. */
  27011. opacityTexture: BaseTexture;
  27012. /**
  27013. * Stores the reflection values in a texture.
  27014. */
  27015. reflectionTexture: Nullable<BaseTexture>;
  27016. /**
  27017. * Stores the emissive values in a texture.
  27018. */
  27019. emissiveTexture: BaseTexture;
  27020. /**
  27021. * AKA Specular texture in other nomenclature.
  27022. */
  27023. reflectivityTexture: BaseTexture;
  27024. /**
  27025. * Used to switch from specular/glossiness to metallic/roughness workflow.
  27026. */
  27027. metallicTexture: BaseTexture;
  27028. /**
  27029. * Specifies the metallic scalar of the metallic/roughness workflow.
  27030. * Can also be used to scale the metalness values of the metallic texture.
  27031. */
  27032. metallic: Nullable<number>;
  27033. /**
  27034. * Specifies the roughness scalar of the metallic/roughness workflow.
  27035. * Can also be used to scale the roughness values of the metallic texture.
  27036. */
  27037. roughness: Nullable<number>;
  27038. /**
  27039. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  27040. * By default the indexOfrefraction is used to compute F0;
  27041. *
  27042. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  27043. *
  27044. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  27045. * F90 = metallicReflectanceColor;
  27046. */
  27047. metallicF0Factor: number;
  27048. /**
  27049. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  27050. * By default the F90 is always 1;
  27051. *
  27052. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  27053. *
  27054. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  27055. * F90 = metallicReflectanceColor;
  27056. */
  27057. metallicReflectanceColor: Color3;
  27058. /**
  27059. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  27060. * This is multiply against the scalar values defined in the material.
  27061. */
  27062. metallicReflectanceTexture: Nullable<BaseTexture>;
  27063. /**
  27064. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  27065. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  27066. */
  27067. microSurfaceTexture: BaseTexture;
  27068. /**
  27069. * Stores surface normal data used to displace a mesh in a texture.
  27070. */
  27071. bumpTexture: BaseTexture;
  27072. /**
  27073. * Stores the pre-calculated light information of a mesh in a texture.
  27074. */
  27075. lightmapTexture: BaseTexture;
  27076. /**
  27077. * Stores the refracted light information in a texture.
  27078. */
  27079. get refractionTexture(): Nullable<BaseTexture>;
  27080. set refractionTexture(value: Nullable<BaseTexture>);
  27081. /**
  27082. * The color of a material in ambient lighting.
  27083. */
  27084. ambientColor: Color3;
  27085. /**
  27086. * AKA Diffuse Color in other nomenclature.
  27087. */
  27088. albedoColor: Color3;
  27089. /**
  27090. * AKA Specular Color in other nomenclature.
  27091. */
  27092. reflectivityColor: Color3;
  27093. /**
  27094. * The color reflected from the material.
  27095. */
  27096. reflectionColor: Color3;
  27097. /**
  27098. * The color emitted from the material.
  27099. */
  27100. emissiveColor: Color3;
  27101. /**
  27102. * AKA Glossiness in other nomenclature.
  27103. */
  27104. microSurface: number;
  27105. /**
  27106. * Index of refraction of the material base layer.
  27107. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  27108. *
  27109. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  27110. *
  27111. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  27112. */
  27113. get indexOfRefraction(): number;
  27114. set indexOfRefraction(value: number);
  27115. /**
  27116. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  27117. */
  27118. get invertRefractionY(): boolean;
  27119. set invertRefractionY(value: boolean);
  27120. /**
  27121. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  27122. * Materials half opaque for instance using refraction could benefit from this control.
  27123. */
  27124. get linkRefractionWithTransparency(): boolean;
  27125. set linkRefractionWithTransparency(value: boolean);
  27126. /**
  27127. * If true, the light map contains occlusion information instead of lighting info.
  27128. */
  27129. useLightmapAsShadowmap: boolean;
  27130. /**
  27131. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  27132. */
  27133. useAlphaFromAlbedoTexture: boolean;
  27134. /**
  27135. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  27136. */
  27137. forceAlphaTest: boolean;
  27138. /**
  27139. * Defines the alpha limits in alpha test mode.
  27140. */
  27141. alphaCutOff: number;
  27142. /**
  27143. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27144. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27145. */
  27146. useSpecularOverAlpha: boolean;
  27147. /**
  27148. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  27149. */
  27150. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  27151. /**
  27152. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  27153. */
  27154. useRoughnessFromMetallicTextureAlpha: boolean;
  27155. /**
  27156. * Specifies if the metallic texture contains the roughness information in its green channel.
  27157. */
  27158. useRoughnessFromMetallicTextureGreen: boolean;
  27159. /**
  27160. * Specifies if the metallic texture contains the metallness information in its blue channel.
  27161. */
  27162. useMetallnessFromMetallicTextureBlue: boolean;
  27163. /**
  27164. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  27165. */
  27166. useAmbientOcclusionFromMetallicTextureRed: boolean;
  27167. /**
  27168. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  27169. */
  27170. useAmbientInGrayScale: boolean;
  27171. /**
  27172. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  27173. * The material will try to infer what glossiness each pixel should be.
  27174. */
  27175. useAutoMicroSurfaceFromReflectivityMap: boolean;
  27176. /**
  27177. * BJS is using an harcoded light falloff based on a manually sets up range.
  27178. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  27179. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  27180. */
  27181. get usePhysicalLightFalloff(): boolean;
  27182. /**
  27183. * BJS is using an harcoded light falloff based on a manually sets up range.
  27184. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  27185. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  27186. */
  27187. set usePhysicalLightFalloff(value: boolean);
  27188. /**
  27189. * In order to support the falloff compatibility with gltf, a special mode has been added
  27190. * to reproduce the gltf light falloff.
  27191. */
  27192. get useGLTFLightFalloff(): boolean;
  27193. /**
  27194. * In order to support the falloff compatibility with gltf, a special mode has been added
  27195. * to reproduce the gltf light falloff.
  27196. */
  27197. set useGLTFLightFalloff(value: boolean);
  27198. /**
  27199. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27200. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27201. */
  27202. useRadianceOverAlpha: boolean;
  27203. /**
  27204. * Allows using an object space normal map (instead of tangent space).
  27205. */
  27206. useObjectSpaceNormalMap: boolean;
  27207. /**
  27208. * Allows using the bump map in parallax mode.
  27209. */
  27210. useParallax: boolean;
  27211. /**
  27212. * Allows using the bump map in parallax occlusion mode.
  27213. */
  27214. useParallaxOcclusion: boolean;
  27215. /**
  27216. * Controls the scale bias of the parallax mode.
  27217. */
  27218. parallaxScaleBias: number;
  27219. /**
  27220. * If sets to true, disables all the lights affecting the material.
  27221. */
  27222. disableLighting: boolean;
  27223. /**
  27224. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  27225. */
  27226. forceIrradianceInFragment: boolean;
  27227. /**
  27228. * Number of Simultaneous lights allowed on the material.
  27229. */
  27230. maxSimultaneousLights: number;
  27231. /**
  27232. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27233. */
  27234. invertNormalMapX: boolean;
  27235. /**
  27236. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27237. */
  27238. invertNormalMapY: boolean;
  27239. /**
  27240. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27241. */
  27242. twoSidedLighting: boolean;
  27243. /**
  27244. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  27245. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  27246. */
  27247. useAlphaFresnel: boolean;
  27248. /**
  27249. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  27250. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  27251. */
  27252. useLinearAlphaFresnel: boolean;
  27253. /**
  27254. * Let user defines the brdf lookup texture used for IBL.
  27255. * A default 8bit version is embedded but you could point at :
  27256. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  27257. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  27258. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  27259. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  27260. */
  27261. environmentBRDFTexture: Nullable<BaseTexture>;
  27262. /**
  27263. * Force normal to face away from face.
  27264. */
  27265. forceNormalForward: boolean;
  27266. /**
  27267. * Enables specular anti aliasing in the PBR shader.
  27268. * It will both interacts on the Geometry for analytical and IBL lighting.
  27269. * It also prefilter the roughness map based on the bump values.
  27270. */
  27271. enableSpecularAntiAliasing: boolean;
  27272. /**
  27273. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  27274. * makes the reflect vector face the model (under horizon).
  27275. */
  27276. useHorizonOcclusion: boolean;
  27277. /**
  27278. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  27279. * too much the area relying on ambient texture to define their ambient occlusion.
  27280. */
  27281. useRadianceOcclusion: boolean;
  27282. /**
  27283. * If set to true, no lighting calculations will be applied.
  27284. */
  27285. unlit: boolean;
  27286. /**
  27287. * Gets the image processing configuration used either in this material.
  27288. */
  27289. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27290. /**
  27291. * Sets the Default image processing configuration used either in the this material.
  27292. *
  27293. * If sets to null, the scene one is in use.
  27294. */
  27295. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27296. /**
  27297. * Gets wether the color curves effect is enabled.
  27298. */
  27299. get cameraColorCurvesEnabled(): boolean;
  27300. /**
  27301. * Sets wether the color curves effect is enabled.
  27302. */
  27303. set cameraColorCurvesEnabled(value: boolean);
  27304. /**
  27305. * Gets wether the color grading effect is enabled.
  27306. */
  27307. get cameraColorGradingEnabled(): boolean;
  27308. /**
  27309. * Gets wether the color grading effect is enabled.
  27310. */
  27311. set cameraColorGradingEnabled(value: boolean);
  27312. /**
  27313. * Gets wether tonemapping is enabled or not.
  27314. */
  27315. get cameraToneMappingEnabled(): boolean;
  27316. /**
  27317. * Sets wether tonemapping is enabled or not
  27318. */
  27319. set cameraToneMappingEnabled(value: boolean);
  27320. /**
  27321. * The camera exposure used on this material.
  27322. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27323. * This corresponds to a photographic exposure.
  27324. */
  27325. get cameraExposure(): number;
  27326. /**
  27327. * The camera exposure used on this material.
  27328. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27329. * This corresponds to a photographic exposure.
  27330. */
  27331. set cameraExposure(value: number);
  27332. /**
  27333. * Gets The camera contrast used on this material.
  27334. */
  27335. get cameraContrast(): number;
  27336. /**
  27337. * Sets The camera contrast used on this material.
  27338. */
  27339. set cameraContrast(value: number);
  27340. /**
  27341. * Gets the Color Grading 2D Lookup Texture.
  27342. */
  27343. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27344. /**
  27345. * Sets the Color Grading 2D Lookup Texture.
  27346. */
  27347. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27348. /**
  27349. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27350. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27351. * 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;
  27352. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27353. */
  27354. get cameraColorCurves(): Nullable<ColorCurves>;
  27355. /**
  27356. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27357. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27358. * 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;
  27359. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27360. */
  27361. set cameraColorCurves(value: Nullable<ColorCurves>);
  27362. /**
  27363. * Instantiates a new PBRMaterial instance.
  27364. *
  27365. * @param name The material name
  27366. * @param scene The scene the material will be use in.
  27367. */
  27368. constructor(name: string, scene: Scene);
  27369. /**
  27370. * Returns the name of this material class.
  27371. */
  27372. getClassName(): string;
  27373. /**
  27374. * Makes a duplicate of the current material.
  27375. * @param name - name to use for the new material.
  27376. */
  27377. clone(name: string): PBRMaterial;
  27378. /**
  27379. * Serializes this PBR Material.
  27380. * @returns - An object with the serialized material.
  27381. */
  27382. serialize(): any;
  27383. /**
  27384. * Parses a PBR Material from a serialized object.
  27385. * @param source - Serialized object.
  27386. * @param scene - BJS scene instance.
  27387. * @param rootUrl - url for the scene object
  27388. * @returns - PBRMaterial
  27389. */
  27390. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  27391. }
  27392. }
  27393. declare module BABYLON {
  27394. /** @hidden */
  27395. export var mrtFragmentDeclaration: {
  27396. name: string;
  27397. shader: string;
  27398. };
  27399. }
  27400. declare module BABYLON {
  27401. /** @hidden */
  27402. export var geometryPixelShader: {
  27403. name: string;
  27404. shader: string;
  27405. };
  27406. }
  27407. declare module BABYLON {
  27408. /** @hidden */
  27409. export var geometryVertexShader: {
  27410. name: string;
  27411. shader: string;
  27412. };
  27413. }
  27414. declare module BABYLON {
  27415. /** @hidden */
  27416. interface ISavedTransformationMatrix {
  27417. world: Matrix;
  27418. viewProjection: Matrix;
  27419. }
  27420. /**
  27421. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  27422. */
  27423. export class GeometryBufferRenderer {
  27424. /**
  27425. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  27426. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  27427. */
  27428. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  27429. /**
  27430. * Constant used to retrieve the position texture index in the G-Buffer textures array
  27431. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  27432. */
  27433. static readonly POSITION_TEXTURE_TYPE: number;
  27434. /**
  27435. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  27436. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  27437. */
  27438. static readonly VELOCITY_TEXTURE_TYPE: number;
  27439. /**
  27440. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  27441. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  27442. */
  27443. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  27444. /**
  27445. * Dictionary used to store the previous transformation matrices of each rendered mesh
  27446. * in order to compute objects velocities when enableVelocity is set to "true"
  27447. * @hidden
  27448. */
  27449. _previousTransformationMatrices: {
  27450. [index: number]: ISavedTransformationMatrix;
  27451. };
  27452. /**
  27453. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  27454. * in order to compute objects velocities when enableVelocity is set to "true"
  27455. * @hidden
  27456. */
  27457. _previousBonesTransformationMatrices: {
  27458. [index: number]: Float32Array;
  27459. };
  27460. /**
  27461. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  27462. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  27463. */
  27464. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  27465. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  27466. renderTransparentMeshes: boolean;
  27467. private _scene;
  27468. private _resizeObserver;
  27469. private _multiRenderTarget;
  27470. private _ratio;
  27471. private _enablePosition;
  27472. private _enableVelocity;
  27473. private _enableReflectivity;
  27474. private _positionIndex;
  27475. private _velocityIndex;
  27476. private _reflectivityIndex;
  27477. private _depthNormalIndex;
  27478. private _linkedWithPrePass;
  27479. private _prePassRenderer;
  27480. private _attachments;
  27481. protected _effect: Effect;
  27482. protected _cachedDefines: string;
  27483. /**
  27484. * @hidden
  27485. * Sets up internal structures to share outputs with PrePassRenderer
  27486. * This method should only be called by the PrePassRenderer itself
  27487. */
  27488. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  27489. /**
  27490. * @hidden
  27491. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  27492. * This method should only be called by the PrePassRenderer itself
  27493. */
  27494. _unlinkPrePassRenderer(): void;
  27495. /**
  27496. * @hidden
  27497. * Resets the geometry buffer layout
  27498. */
  27499. _resetLayout(): void;
  27500. /**
  27501. * @hidden
  27502. * Replaces a texture in the geometry buffer renderer
  27503. * Useful when linking textures of the prepass renderer
  27504. */
  27505. _forceTextureType(geometryBufferType: number, index: number): void;
  27506. /**
  27507. * @hidden
  27508. * Sets texture attachments
  27509. * Useful when linking textures of the prepass renderer
  27510. */
  27511. _setAttachments(attachments: number[]): void;
  27512. /**
  27513. * @hidden
  27514. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  27515. * Useful when linking textures of the prepass renderer
  27516. */
  27517. _linkInternalTexture(internalTexture: InternalTexture): void;
  27518. /**
  27519. * Gets the render list (meshes to be rendered) used in the G buffer.
  27520. */
  27521. get renderList(): Nullable<AbstractMesh[]>;
  27522. /**
  27523. * Set the render list (meshes to be rendered) used in the G buffer.
  27524. */
  27525. set renderList(meshes: Nullable<AbstractMesh[]>);
  27526. /**
  27527. * Gets wether or not G buffer are supported by the running hardware.
  27528. * This requires draw buffer supports
  27529. */
  27530. get isSupported(): boolean;
  27531. /**
  27532. * Returns the index of the given texture type in the G-Buffer textures array
  27533. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  27534. * @returns the index of the given texture type in the G-Buffer textures array
  27535. */
  27536. getTextureIndex(textureType: number): number;
  27537. /**
  27538. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  27539. */
  27540. get enablePosition(): boolean;
  27541. /**
  27542. * Sets whether or not objects positions are enabled for the G buffer.
  27543. */
  27544. set enablePosition(enable: boolean);
  27545. /**
  27546. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  27547. */
  27548. get enableVelocity(): boolean;
  27549. /**
  27550. * Sets wether or not objects velocities are enabled for the G buffer.
  27551. */
  27552. set enableVelocity(enable: boolean);
  27553. /**
  27554. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  27555. */
  27556. get enableReflectivity(): boolean;
  27557. /**
  27558. * Sets wether or not objects roughness are enabled for the G buffer.
  27559. */
  27560. set enableReflectivity(enable: boolean);
  27561. /**
  27562. * Gets the scene associated with the buffer.
  27563. */
  27564. get scene(): Scene;
  27565. /**
  27566. * Gets the ratio used by the buffer during its creation.
  27567. * How big is the buffer related to the main canvas.
  27568. */
  27569. get ratio(): number;
  27570. /** @hidden */
  27571. static _SceneComponentInitialization: (scene: Scene) => void;
  27572. /**
  27573. * Creates a new G Buffer for the scene
  27574. * @param scene The scene the buffer belongs to
  27575. * @param ratio How big is the buffer related to the main canvas.
  27576. */
  27577. constructor(scene: Scene, ratio?: number);
  27578. /**
  27579. * Checks wether everything is ready to render a submesh to the G buffer.
  27580. * @param subMesh the submesh to check readiness for
  27581. * @param useInstances is the mesh drawn using instance or not
  27582. * @returns true if ready otherwise false
  27583. */
  27584. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  27585. /**
  27586. * Gets the current underlying G Buffer.
  27587. * @returns the buffer
  27588. */
  27589. getGBuffer(): MultiRenderTarget;
  27590. /**
  27591. * Gets the number of samples used to render the buffer (anti aliasing).
  27592. */
  27593. get samples(): number;
  27594. /**
  27595. * Sets the number of samples used to render the buffer (anti aliasing).
  27596. */
  27597. set samples(value: number);
  27598. /**
  27599. * Disposes the renderer and frees up associated resources.
  27600. */
  27601. dispose(): void;
  27602. private _assignRenderTargetIndices;
  27603. protected _createRenderTargets(): void;
  27604. private _copyBonesTransformationMatrices;
  27605. }
  27606. }
  27607. declare module BABYLON {
  27608. /**
  27609. * Renders a pre pass of the scene
  27610. * This means every mesh in the scene will be rendered to a render target texture
  27611. * And then this texture will be composited to the rendering canvas with post processes
  27612. * It is necessary for effects like subsurface scattering or deferred shading
  27613. */
  27614. export class PrePassRenderer {
  27615. /** @hidden */
  27616. static _SceneComponentInitialization: (scene: Scene) => void;
  27617. private _textureFormats;
  27618. /**
  27619. * To save performance, we can excluded skinned meshes from the prepass
  27620. */
  27621. excludedSkinnedMesh: AbstractMesh[];
  27622. /**
  27623. * Force material to be excluded from the prepass
  27624. * Can be useful when `useGeometryBufferFallback` is set to `true`
  27625. * and you don't want a material to show in the effect.
  27626. */
  27627. excludedMaterials: Material[];
  27628. private _textureIndices;
  27629. private _scene;
  27630. private _engine;
  27631. private _isDirty;
  27632. /**
  27633. * Number of textures in the multi render target texture where the scene is directly rendered
  27634. */
  27635. mrtCount: number;
  27636. /**
  27637. * The render target where the scene is directly rendered
  27638. */
  27639. prePassRT: MultiRenderTarget;
  27640. private _multiRenderAttachments;
  27641. private _defaultAttachments;
  27642. private _clearAttachments;
  27643. private _postProcesses;
  27644. private readonly _clearColor;
  27645. /**
  27646. * Image processing post process for composition
  27647. */
  27648. imageProcessingPostProcess: ImageProcessingPostProcess;
  27649. /**
  27650. * Configuration for prepass effects
  27651. */
  27652. private _effectConfigurations;
  27653. private _mrtFormats;
  27654. private _mrtLayout;
  27655. private _enabled;
  27656. /**
  27657. * Indicates if the prepass is enabled
  27658. */
  27659. get enabled(): boolean;
  27660. /**
  27661. * How many samples are used for MSAA of the scene render target
  27662. */
  27663. get samples(): number;
  27664. set samples(n: number);
  27665. private _geometryBuffer;
  27666. private _useGeometryBufferFallback;
  27667. /**
  27668. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  27669. */
  27670. get useGeometryBufferFallback(): boolean;
  27671. set useGeometryBufferFallback(value: boolean);
  27672. /**
  27673. * Instanciates a prepass renderer
  27674. * @param scene The scene
  27675. */
  27676. constructor(scene: Scene);
  27677. private _initializeAttachments;
  27678. private _createCompositionEffect;
  27679. /**
  27680. * Indicates if rendering a prepass is supported
  27681. */
  27682. get isSupported(): boolean;
  27683. /**
  27684. * Sets the proper output textures to draw in the engine.
  27685. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  27686. * @param subMesh Submesh on which the effect is applied
  27687. */
  27688. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  27689. /**
  27690. * @hidden
  27691. */
  27692. _beforeCameraDraw(): void;
  27693. /**
  27694. * @hidden
  27695. */
  27696. _afterCameraDraw(): void;
  27697. private _checkRTSize;
  27698. private _bindFrameBuffer;
  27699. /**
  27700. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  27701. */
  27702. clear(): void;
  27703. private _setState;
  27704. private _updateGeometryBufferLayout;
  27705. /**
  27706. * Adds an effect configuration to the prepass.
  27707. * If an effect has already been added, it won't add it twice and will return the configuration
  27708. * already present.
  27709. * @param cfg the effect configuration
  27710. * @return the effect configuration now used by the prepass
  27711. */
  27712. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  27713. /**
  27714. * Returns the index of a texture in the multi render target texture array.
  27715. * @param type Texture type
  27716. * @return The index
  27717. */
  27718. getIndex(type: number): number;
  27719. private _enable;
  27720. private _disable;
  27721. private _resetLayout;
  27722. private _resetPostProcessChain;
  27723. private _bindPostProcessChain;
  27724. /**
  27725. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  27726. */
  27727. markAsDirty(): void;
  27728. /**
  27729. * Enables a texture on the MultiRenderTarget for prepass
  27730. */
  27731. private _enableTextures;
  27732. private _update;
  27733. private _markAllMaterialsAsPrePassDirty;
  27734. /**
  27735. * Disposes the prepass renderer.
  27736. */
  27737. dispose(): void;
  27738. }
  27739. }
  27740. declare module BABYLON {
  27741. /**
  27742. * Size options for a post process
  27743. */
  27744. export type PostProcessOptions = {
  27745. width: number;
  27746. height: number;
  27747. };
  27748. /**
  27749. * PostProcess can be used to apply a shader to a texture after it has been rendered
  27750. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  27751. */
  27752. export class PostProcess {
  27753. /**
  27754. * Gets or sets the unique id of the post process
  27755. */
  27756. uniqueId: number;
  27757. /** Name of the PostProcess. */
  27758. name: string;
  27759. /**
  27760. * Width of the texture to apply the post process on
  27761. */
  27762. width: number;
  27763. /**
  27764. * Height of the texture to apply the post process on
  27765. */
  27766. height: number;
  27767. /**
  27768. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  27769. */
  27770. nodeMaterialSource: Nullable<NodeMaterial>;
  27771. /**
  27772. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  27773. * @hidden
  27774. */
  27775. _outputTexture: Nullable<InternalTexture>;
  27776. /**
  27777. * Sampling mode used by the shader
  27778. * See https://doc.babylonjs.com/classes/3.1/texture
  27779. */
  27780. renderTargetSamplingMode: number;
  27781. /**
  27782. * Clear color to use when screen clearing
  27783. */
  27784. clearColor: Color4;
  27785. /**
  27786. * If the buffer needs to be cleared before applying the post process. (default: true)
  27787. * Should be set to false if shader will overwrite all previous pixels.
  27788. */
  27789. autoClear: boolean;
  27790. /**
  27791. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  27792. */
  27793. alphaMode: number;
  27794. /**
  27795. * Sets the setAlphaBlendConstants of the babylon engine
  27796. */
  27797. alphaConstants: Color4;
  27798. /**
  27799. * Animations to be used for the post processing
  27800. */
  27801. animations: Animation[];
  27802. /**
  27803. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  27804. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  27805. */
  27806. enablePixelPerfectMode: boolean;
  27807. /**
  27808. * Force the postprocess to be applied without taking in account viewport
  27809. */
  27810. forceFullscreenViewport: boolean;
  27811. /**
  27812. * List of inspectable custom properties (used by the Inspector)
  27813. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27814. */
  27815. inspectableCustomProperties: IInspectable[];
  27816. /**
  27817. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  27818. *
  27819. * | Value | Type | Description |
  27820. * | ----- | ----------------------------------- | ----------- |
  27821. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  27822. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  27823. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  27824. *
  27825. */
  27826. scaleMode: number;
  27827. /**
  27828. * Force textures to be a power of two (default: false)
  27829. */
  27830. alwaysForcePOT: boolean;
  27831. private _samples;
  27832. /**
  27833. * Number of sample textures (default: 1)
  27834. */
  27835. get samples(): number;
  27836. set samples(n: number);
  27837. /**
  27838. * Modify the scale of the post process to be the same as the viewport (default: false)
  27839. */
  27840. adaptScaleToCurrentViewport: boolean;
  27841. private _camera;
  27842. protected _scene: Scene;
  27843. private _engine;
  27844. private _options;
  27845. private _reusable;
  27846. private _textureType;
  27847. private _textureFormat;
  27848. /**
  27849. * Smart array of input and output textures for the post process.
  27850. * @hidden
  27851. */
  27852. _textures: SmartArray<InternalTexture>;
  27853. /**
  27854. * The index in _textures that corresponds to the output texture.
  27855. * @hidden
  27856. */
  27857. _currentRenderTextureInd: number;
  27858. private _effect;
  27859. private _samplers;
  27860. private _fragmentUrl;
  27861. private _vertexUrl;
  27862. private _parameters;
  27863. private _scaleRatio;
  27864. protected _indexParameters: any;
  27865. private _shareOutputWithPostProcess;
  27866. private _texelSize;
  27867. private _forcedOutputTexture;
  27868. /**
  27869. * Prepass configuration in case this post process needs a texture from prepass
  27870. * @hidden
  27871. */
  27872. _prePassEffectConfiguration: PrePassEffectConfiguration;
  27873. /**
  27874. * Returns the fragment url or shader name used in the post process.
  27875. * @returns the fragment url or name in the shader store.
  27876. */
  27877. getEffectName(): string;
  27878. /**
  27879. * An event triggered when the postprocess is activated.
  27880. */
  27881. onActivateObservable: Observable<Camera>;
  27882. private _onActivateObserver;
  27883. /**
  27884. * A function that is added to the onActivateObservable
  27885. */
  27886. set onActivate(callback: Nullable<(camera: Camera) => void>);
  27887. /**
  27888. * An event triggered when the postprocess changes its size.
  27889. */
  27890. onSizeChangedObservable: Observable<PostProcess>;
  27891. private _onSizeChangedObserver;
  27892. /**
  27893. * A function that is added to the onSizeChangedObservable
  27894. */
  27895. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  27896. /**
  27897. * An event triggered when the postprocess applies its effect.
  27898. */
  27899. onApplyObservable: Observable<Effect>;
  27900. private _onApplyObserver;
  27901. /**
  27902. * A function that is added to the onApplyObservable
  27903. */
  27904. set onApply(callback: (effect: Effect) => void);
  27905. /**
  27906. * An event triggered before rendering the postprocess
  27907. */
  27908. onBeforeRenderObservable: Observable<Effect>;
  27909. private _onBeforeRenderObserver;
  27910. /**
  27911. * A function that is added to the onBeforeRenderObservable
  27912. */
  27913. set onBeforeRender(callback: (effect: Effect) => void);
  27914. /**
  27915. * An event triggered after rendering the postprocess
  27916. */
  27917. onAfterRenderObservable: Observable<Effect>;
  27918. private _onAfterRenderObserver;
  27919. /**
  27920. * A function that is added to the onAfterRenderObservable
  27921. */
  27922. set onAfterRender(callback: (efect: Effect) => void);
  27923. /**
  27924. * 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
  27925. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  27926. */
  27927. get inputTexture(): InternalTexture;
  27928. set inputTexture(value: InternalTexture);
  27929. /**
  27930. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  27931. * the only way to unset it is to use this function to restore its internal state
  27932. */
  27933. restoreDefaultInputTexture(): void;
  27934. /**
  27935. * Gets the camera which post process is applied to.
  27936. * @returns The camera the post process is applied to.
  27937. */
  27938. getCamera(): Camera;
  27939. /**
  27940. * Gets the texel size of the postprocess.
  27941. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  27942. */
  27943. get texelSize(): Vector2;
  27944. /**
  27945. * Creates a new instance PostProcess
  27946. * @param name The name of the PostProcess.
  27947. * @param fragmentUrl The url of the fragment shader to be used.
  27948. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  27949. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  27950. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  27951. * @param camera The camera to apply the render pass to.
  27952. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27953. * @param engine The engine which the post process will be applied. (default: current engine)
  27954. * @param reusable If the post process can be reused on the same frame. (default: false)
  27955. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  27956. * @param textureType Type of textures used when performing the post process. (default: 0)
  27957. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  27958. * @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
  27959. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  27960. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  27961. */
  27962. 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);
  27963. /**
  27964. * Gets a string identifying the name of the class
  27965. * @returns "PostProcess" string
  27966. */
  27967. getClassName(): string;
  27968. /**
  27969. * Gets the engine which this post process belongs to.
  27970. * @returns The engine the post process was enabled with.
  27971. */
  27972. getEngine(): Engine;
  27973. /**
  27974. * The effect that is created when initializing the post process.
  27975. * @returns The created effect corresponding the the postprocess.
  27976. */
  27977. getEffect(): Effect;
  27978. /**
  27979. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  27980. * @param postProcess The post process to share the output with.
  27981. * @returns This post process.
  27982. */
  27983. shareOutputWith(postProcess: PostProcess): PostProcess;
  27984. /**
  27985. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  27986. * This should be called if the post process that shares output with this post process is disabled/disposed.
  27987. */
  27988. useOwnOutput(): void;
  27989. /**
  27990. * Updates the effect with the current post process compile time values and recompiles the shader.
  27991. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  27992. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  27993. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  27994. * @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
  27995. * @param onCompiled Called when the shader has been compiled.
  27996. * @param onError Called if there is an error when compiling a shader.
  27997. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  27998. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  27999. */
  28000. 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;
  28001. /**
  28002. * The post process is reusable if it can be used multiple times within one frame.
  28003. * @returns If the post process is reusable
  28004. */
  28005. isReusable(): boolean;
  28006. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  28007. markTextureDirty(): void;
  28008. /**
  28009. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  28010. * 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.
  28011. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  28012. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  28013. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  28014. * @returns The target texture that was bound to be written to.
  28015. */
  28016. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  28017. /**
  28018. * If the post process is supported.
  28019. */
  28020. get isSupported(): boolean;
  28021. /**
  28022. * The aspect ratio of the output texture.
  28023. */
  28024. get aspectRatio(): number;
  28025. /**
  28026. * Get a value indicating if the post-process is ready to be used
  28027. * @returns true if the post-process is ready (shader is compiled)
  28028. */
  28029. isReady(): boolean;
  28030. /**
  28031. * Binds all textures and uniforms to the shader, this will be run on every pass.
  28032. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  28033. */
  28034. apply(): Nullable<Effect>;
  28035. private _disposeTextures;
  28036. /**
  28037. * Sets the required values to the prepass renderer.
  28038. * @param prePassRenderer defines the prepass renderer to setup.
  28039. * @returns true if the pre pass is needed.
  28040. */
  28041. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  28042. /**
  28043. * Disposes the post process.
  28044. * @param camera The camera to dispose the post process on.
  28045. */
  28046. dispose(camera?: Camera): void;
  28047. /**
  28048. * Serializes the particle system to a JSON object
  28049. * @returns the JSON object
  28050. */
  28051. serialize(): any;
  28052. /**
  28053. * Creates a material from parsed material data
  28054. * @param parsedPostProcess defines parsed post process data
  28055. * @param scene defines the hosting scene
  28056. * @param rootUrl defines the root URL to use to load textures
  28057. * @returns a new post process
  28058. */
  28059. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  28060. }
  28061. }
  28062. declare module BABYLON {
  28063. /** @hidden */
  28064. export var kernelBlurVaryingDeclaration: {
  28065. name: string;
  28066. shader: string;
  28067. };
  28068. }
  28069. declare module BABYLON {
  28070. /** @hidden */
  28071. export var kernelBlurFragment: {
  28072. name: string;
  28073. shader: string;
  28074. };
  28075. }
  28076. declare module BABYLON {
  28077. /** @hidden */
  28078. export var kernelBlurFragment2: {
  28079. name: string;
  28080. shader: string;
  28081. };
  28082. }
  28083. declare module BABYLON {
  28084. /** @hidden */
  28085. export var kernelBlurPixelShader: {
  28086. name: string;
  28087. shader: string;
  28088. };
  28089. }
  28090. declare module BABYLON {
  28091. /** @hidden */
  28092. export var kernelBlurVertex: {
  28093. name: string;
  28094. shader: string;
  28095. };
  28096. }
  28097. declare module BABYLON {
  28098. /** @hidden */
  28099. export var kernelBlurVertexShader: {
  28100. name: string;
  28101. shader: string;
  28102. };
  28103. }
  28104. declare module BABYLON {
  28105. /**
  28106. * The Blur Post Process which blurs an image based on a kernel and direction.
  28107. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  28108. */
  28109. export class BlurPostProcess extends PostProcess {
  28110. private blockCompilation;
  28111. protected _kernel: number;
  28112. protected _idealKernel: number;
  28113. protected _packedFloat: boolean;
  28114. private _staticDefines;
  28115. /** The direction in which to blur the image. */
  28116. direction: Vector2;
  28117. /**
  28118. * Sets the length in pixels of the blur sample region
  28119. */
  28120. set kernel(v: number);
  28121. /**
  28122. * Gets the length in pixels of the blur sample region
  28123. */
  28124. get kernel(): number;
  28125. /**
  28126. * Sets wether or not the blur needs to unpack/repack floats
  28127. */
  28128. set packedFloat(v: boolean);
  28129. /**
  28130. * Gets wether or not the blur is unpacking/repacking floats
  28131. */
  28132. get packedFloat(): boolean;
  28133. /**
  28134. * Gets a string identifying the name of the class
  28135. * @returns "BlurPostProcess" string
  28136. */
  28137. getClassName(): string;
  28138. /**
  28139. * Creates a new instance BlurPostProcess
  28140. * @param name The name of the effect.
  28141. * @param direction The direction in which to blur the image.
  28142. * @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.
  28143. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  28144. * @param camera The camera to apply the render pass to.
  28145. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28146. * @param engine The engine which the post process will be applied. (default: current engine)
  28147. * @param reusable If the post process can be reused on the same frame. (default: false)
  28148. * @param textureType Type of textures used when performing the post process. (default: 0)
  28149. * @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)
  28150. */
  28151. 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);
  28152. /**
  28153. * Updates the effect with the current post process compile time values and recompiles the shader.
  28154. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  28155. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  28156. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  28157. * @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
  28158. * @param onCompiled Called when the shader has been compiled.
  28159. * @param onError Called if there is an error when compiling a shader.
  28160. */
  28161. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  28162. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  28163. /**
  28164. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  28165. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  28166. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  28167. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  28168. * The gaps between physical kernels are compensated for in the weighting of the samples
  28169. * @param idealKernel Ideal blur kernel.
  28170. * @return Nearest best kernel.
  28171. */
  28172. protected _nearestBestKernel(idealKernel: number): number;
  28173. /**
  28174. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  28175. * @param x The point on the Gaussian distribution to sample.
  28176. * @return the value of the Gaussian function at x.
  28177. */
  28178. protected _gaussianWeight(x: number): number;
  28179. /**
  28180. * Generates a string that can be used as a floating point number in GLSL.
  28181. * @param x Value to print.
  28182. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  28183. * @return GLSL float string.
  28184. */
  28185. protected _glslFloat(x: number, decimalFigures?: number): string;
  28186. /** @hidden */
  28187. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  28188. }
  28189. }
  28190. declare module BABYLON {
  28191. /**
  28192. * Mirror texture can be used to simulate the view from a mirror in a scene.
  28193. * It will dynamically be rendered every frame to adapt to the camera point of view.
  28194. * You can then easily use it as a reflectionTexture on a flat surface.
  28195. * In case the surface is not a plane, please consider relying on reflection probes.
  28196. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  28197. */
  28198. export class MirrorTexture extends RenderTargetTexture {
  28199. private scene;
  28200. /**
  28201. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  28202. * 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.
  28203. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  28204. */
  28205. mirrorPlane: Plane;
  28206. /**
  28207. * Define the blur ratio used to blur the reflection if needed.
  28208. */
  28209. set blurRatio(value: number);
  28210. get blurRatio(): number;
  28211. /**
  28212. * Define the adaptive blur kernel used to blur the reflection if needed.
  28213. * This will autocompute the closest best match for the `blurKernel`
  28214. */
  28215. set adaptiveBlurKernel(value: number);
  28216. /**
  28217. * Define the blur kernel used to blur the reflection if needed.
  28218. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  28219. */
  28220. set blurKernel(value: number);
  28221. /**
  28222. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  28223. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  28224. */
  28225. set blurKernelX(value: number);
  28226. get blurKernelX(): number;
  28227. /**
  28228. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  28229. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  28230. */
  28231. set blurKernelY(value: number);
  28232. get blurKernelY(): number;
  28233. private _autoComputeBlurKernel;
  28234. protected _onRatioRescale(): void;
  28235. private _updateGammaSpace;
  28236. private _imageProcessingConfigChangeObserver;
  28237. private _transformMatrix;
  28238. private _mirrorMatrix;
  28239. private _savedViewMatrix;
  28240. private _blurX;
  28241. private _blurY;
  28242. private _adaptiveBlurKernel;
  28243. private _blurKernelX;
  28244. private _blurKernelY;
  28245. private _blurRatio;
  28246. /**
  28247. * Instantiates a Mirror Texture.
  28248. * Mirror texture can be used to simulate the view from a mirror in a scene.
  28249. * It will dynamically be rendered every frame to adapt to the camera point of view.
  28250. * You can then easily use it as a reflectionTexture on a flat surface.
  28251. * In case the surface is not a plane, please consider relying on reflection probes.
  28252. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  28253. * @param name
  28254. * @param size
  28255. * @param scene
  28256. * @param generateMipMaps
  28257. * @param type
  28258. * @param samplingMode
  28259. * @param generateDepthBuffer
  28260. */
  28261. constructor(name: string, size: number | {
  28262. width: number;
  28263. height: number;
  28264. } | {
  28265. ratio: number;
  28266. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  28267. private _preparePostProcesses;
  28268. /**
  28269. * Clone the mirror texture.
  28270. * @returns the cloned texture
  28271. */
  28272. clone(): MirrorTexture;
  28273. /**
  28274. * Serialize the texture to a JSON representation you could use in Parse later on
  28275. * @returns the serialized JSON representation
  28276. */
  28277. serialize(): any;
  28278. /**
  28279. * Dispose the texture and release its associated resources.
  28280. */
  28281. dispose(): void;
  28282. }
  28283. }
  28284. declare module BABYLON {
  28285. /**
  28286. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  28287. * @see https://doc.babylonjs.com/babylon101/materials#texture
  28288. */
  28289. export class Texture extends BaseTexture {
  28290. /**
  28291. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  28292. */
  28293. static SerializeBuffers: boolean;
  28294. /** @hidden */
  28295. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  28296. /** @hidden */
  28297. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  28298. /** @hidden */
  28299. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  28300. /** nearest is mag = nearest and min = nearest and mip = linear */
  28301. static readonly NEAREST_SAMPLINGMODE: number;
  28302. /** nearest is mag = nearest and min = nearest and mip = linear */
  28303. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  28304. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28305. static readonly BILINEAR_SAMPLINGMODE: number;
  28306. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28307. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  28308. /** Trilinear is mag = linear and min = linear and mip = linear */
  28309. static readonly TRILINEAR_SAMPLINGMODE: number;
  28310. /** Trilinear is mag = linear and min = linear and mip = linear */
  28311. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  28312. /** mag = nearest and min = nearest and mip = nearest */
  28313. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  28314. /** mag = nearest and min = linear and mip = nearest */
  28315. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  28316. /** mag = nearest and min = linear and mip = linear */
  28317. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  28318. /** mag = nearest and min = linear and mip = none */
  28319. static readonly NEAREST_LINEAR: number;
  28320. /** mag = nearest and min = nearest and mip = none */
  28321. static readonly NEAREST_NEAREST: number;
  28322. /** mag = linear and min = nearest and mip = nearest */
  28323. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  28324. /** mag = linear and min = nearest and mip = linear */
  28325. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  28326. /** mag = linear and min = linear and mip = none */
  28327. static readonly LINEAR_LINEAR: number;
  28328. /** mag = linear and min = nearest and mip = none */
  28329. static readonly LINEAR_NEAREST: number;
  28330. /** Explicit coordinates mode */
  28331. static readonly EXPLICIT_MODE: number;
  28332. /** Spherical coordinates mode */
  28333. static readonly SPHERICAL_MODE: number;
  28334. /** Planar coordinates mode */
  28335. static readonly PLANAR_MODE: number;
  28336. /** Cubic coordinates mode */
  28337. static readonly CUBIC_MODE: number;
  28338. /** Projection coordinates mode */
  28339. static readonly PROJECTION_MODE: number;
  28340. /** Inverse Cubic coordinates mode */
  28341. static readonly SKYBOX_MODE: number;
  28342. /** Inverse Cubic coordinates mode */
  28343. static readonly INVCUBIC_MODE: number;
  28344. /** Equirectangular coordinates mode */
  28345. static readonly EQUIRECTANGULAR_MODE: number;
  28346. /** Equirectangular Fixed coordinates mode */
  28347. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  28348. /** Equirectangular Fixed Mirrored coordinates mode */
  28349. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  28350. /** Texture is not repeating outside of 0..1 UVs */
  28351. static readonly CLAMP_ADDRESSMODE: number;
  28352. /** Texture is repeating outside of 0..1 UVs */
  28353. static readonly WRAP_ADDRESSMODE: number;
  28354. /** Texture is repeating and mirrored */
  28355. static readonly MIRROR_ADDRESSMODE: number;
  28356. /**
  28357. * 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
  28358. */
  28359. static UseSerializedUrlIfAny: boolean;
  28360. /**
  28361. * Define the url of the texture.
  28362. */
  28363. url: Nullable<string>;
  28364. /**
  28365. * Define an offset on the texture to offset the u coordinates of the UVs
  28366. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  28367. */
  28368. uOffset: number;
  28369. /**
  28370. * Define an offset on the texture to offset the v coordinates of the UVs
  28371. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  28372. */
  28373. vOffset: number;
  28374. /**
  28375. * Define an offset on the texture to scale the u coordinates of the UVs
  28376. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  28377. */
  28378. uScale: number;
  28379. /**
  28380. * Define an offset on the texture to scale the v coordinates of the UVs
  28381. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  28382. */
  28383. vScale: number;
  28384. /**
  28385. * Define an offset on the texture to rotate around the u coordinates of the UVs
  28386. * @see https://doc.babylonjs.com/how_to/more_materials
  28387. */
  28388. uAng: number;
  28389. /**
  28390. * Define an offset on the texture to rotate around the v coordinates of the UVs
  28391. * @see https://doc.babylonjs.com/how_to/more_materials
  28392. */
  28393. vAng: number;
  28394. /**
  28395. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  28396. * @see https://doc.babylonjs.com/how_to/more_materials
  28397. */
  28398. wAng: number;
  28399. /**
  28400. * Defines the center of rotation (U)
  28401. */
  28402. uRotationCenter: number;
  28403. /**
  28404. * Defines the center of rotation (V)
  28405. */
  28406. vRotationCenter: number;
  28407. /**
  28408. * Defines the center of rotation (W)
  28409. */
  28410. wRotationCenter: number;
  28411. /**
  28412. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  28413. */
  28414. homogeneousRotationInUVTransform: boolean;
  28415. /**
  28416. * Are mip maps generated for this texture or not.
  28417. */
  28418. get noMipmap(): boolean;
  28419. /**
  28420. * List of inspectable custom properties (used by the Inspector)
  28421. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28422. */
  28423. inspectableCustomProperties: Nullable<IInspectable[]>;
  28424. private _noMipmap;
  28425. /** @hidden */
  28426. _invertY: boolean;
  28427. private _rowGenerationMatrix;
  28428. private _cachedTextureMatrix;
  28429. private _projectionModeMatrix;
  28430. private _t0;
  28431. private _t1;
  28432. private _t2;
  28433. private _cachedUOffset;
  28434. private _cachedVOffset;
  28435. private _cachedUScale;
  28436. private _cachedVScale;
  28437. private _cachedUAng;
  28438. private _cachedVAng;
  28439. private _cachedWAng;
  28440. private _cachedProjectionMatrixId;
  28441. private _cachedURotationCenter;
  28442. private _cachedVRotationCenter;
  28443. private _cachedWRotationCenter;
  28444. private _cachedHomogeneousRotationInUVTransform;
  28445. private _cachedCoordinatesMode;
  28446. /** @hidden */
  28447. protected _initialSamplingMode: number;
  28448. /** @hidden */
  28449. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  28450. private _deleteBuffer;
  28451. protected _format: Nullable<number>;
  28452. private _delayedOnLoad;
  28453. private _delayedOnError;
  28454. private _mimeType?;
  28455. private _loaderOptions?;
  28456. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  28457. get mimeType(): string | undefined;
  28458. /**
  28459. * Observable triggered once the texture has been loaded.
  28460. */
  28461. onLoadObservable: Observable<Texture>;
  28462. protected _isBlocking: boolean;
  28463. /**
  28464. * Is the texture preventing material to render while loading.
  28465. * If false, a default texture will be used instead of the loading one during the preparation step.
  28466. */
  28467. set isBlocking(value: boolean);
  28468. get isBlocking(): boolean;
  28469. /**
  28470. * Get the current sampling mode associated with the texture.
  28471. */
  28472. get samplingMode(): number;
  28473. /**
  28474. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  28475. */
  28476. get invertY(): boolean;
  28477. /**
  28478. * Instantiates a new texture.
  28479. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  28480. * @see https://doc.babylonjs.com/babylon101/materials#texture
  28481. * @param url defines the url of the picture to load as a texture
  28482. * @param sceneOrEngine defines the scene or engine the texture will belong to
  28483. * @param noMipmap defines if the texture will require mip maps or not
  28484. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  28485. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  28486. * @param onLoad defines a callback triggered when the texture has been loaded
  28487. * @param onError defines a callback triggered when an error occurred during the loading session
  28488. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  28489. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  28490. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  28491. * @param mimeType defines an optional mime type information
  28492. * @param loaderOptions options to be passed to the loader
  28493. */
  28494. 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);
  28495. /**
  28496. * Update the url (and optional buffer) of this texture if url was null during construction.
  28497. * @param url the url of the texture
  28498. * @param buffer the buffer of the texture (defaults to null)
  28499. * @param onLoad callback called when the texture is loaded (defaults to null)
  28500. */
  28501. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  28502. /**
  28503. * Finish the loading sequence of a texture flagged as delayed load.
  28504. * @hidden
  28505. */
  28506. delayLoad(): void;
  28507. private _prepareRowForTextureGeneration;
  28508. /**
  28509. * Checks if the texture has the same transform matrix than another texture
  28510. * @param texture texture to check against
  28511. * @returns true if the transforms are the same, else false
  28512. */
  28513. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  28514. /**
  28515. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  28516. * @returns the transform matrix of the texture.
  28517. */
  28518. getTextureMatrix(uBase?: number): Matrix;
  28519. /**
  28520. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  28521. * @returns The reflection texture transform
  28522. */
  28523. getReflectionTextureMatrix(): Matrix;
  28524. /**
  28525. * Clones the texture.
  28526. * @returns the cloned texture
  28527. */
  28528. clone(): Texture;
  28529. /**
  28530. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  28531. * @returns The JSON representation of the texture
  28532. */
  28533. serialize(): any;
  28534. /**
  28535. * Get the current class name of the texture useful for serialization or dynamic coding.
  28536. * @returns "Texture"
  28537. */
  28538. getClassName(): string;
  28539. /**
  28540. * Dispose the texture and release its associated resources.
  28541. */
  28542. dispose(): void;
  28543. /**
  28544. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  28545. * @param parsedTexture Define the JSON representation of the texture
  28546. * @param scene Define the scene the parsed texture should be instantiated in
  28547. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  28548. * @returns The parsed texture if successful
  28549. */
  28550. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  28551. /**
  28552. * Creates a texture from its base 64 representation.
  28553. * @param data Define the base64 payload without the data: prefix
  28554. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  28555. * @param scene Define the scene the texture should belong to
  28556. * @param noMipmap Forces the texture to not create mip map information if true
  28557. * @param invertY define if the texture needs to be inverted on the y axis during loading
  28558. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  28559. * @param onLoad define a callback triggered when the texture has been loaded
  28560. * @param onError define a callback triggered when an error occurred during the loading session
  28561. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  28562. * @returns the created texture
  28563. */
  28564. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  28565. /**
  28566. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  28567. * @param data Define the base64 payload without the data: prefix
  28568. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  28569. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  28570. * @param scene Define the scene the texture should belong to
  28571. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  28572. * @param noMipmap Forces the texture to not create mip map information if true
  28573. * @param invertY define if the texture needs to be inverted on the y axis during loading
  28574. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  28575. * @param onLoad define a callback triggered when the texture has been loaded
  28576. * @param onError define a callback triggered when an error occurred during the loading session
  28577. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  28578. * @returns the created texture
  28579. */
  28580. 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;
  28581. }
  28582. }
  28583. declare module BABYLON {
  28584. /**
  28585. * PostProcessManager is used to manage one or more post processes or post process pipelines
  28586. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  28587. */
  28588. export class PostProcessManager {
  28589. private _scene;
  28590. private _indexBuffer;
  28591. private _vertexBuffers;
  28592. /**
  28593. * Creates a new instance PostProcess
  28594. * @param scene The scene that the post process is associated with.
  28595. */
  28596. constructor(scene: Scene);
  28597. private _prepareBuffers;
  28598. private _buildIndexBuffer;
  28599. /**
  28600. * Rebuilds the vertex buffers of the manager.
  28601. * @hidden
  28602. */
  28603. _rebuild(): void;
  28604. /**
  28605. * Prepares a frame to be run through a post process.
  28606. * @param sourceTexture The input texture to the post procesess. (default: null)
  28607. * @param postProcesses An array of post processes to be run. (default: null)
  28608. * @returns True if the post processes were able to be run.
  28609. * @hidden
  28610. */
  28611. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  28612. /**
  28613. * Manually render a set of post processes to a texture.
  28614. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  28615. * @param postProcesses An array of post processes to be run.
  28616. * @param targetTexture The target texture to render to.
  28617. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  28618. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  28619. * @param lodLevel defines which lod of the texture to render to
  28620. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  28621. */
  28622. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  28623. /**
  28624. * Finalize the result of the output of the postprocesses.
  28625. * @param doNotPresent If true the result will not be displayed to the screen.
  28626. * @param targetTexture The target texture to render to.
  28627. * @param faceIndex The index of the face to bind the target texture to.
  28628. * @param postProcesses The array of post processes to render.
  28629. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  28630. * @hidden
  28631. */
  28632. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  28633. /**
  28634. * Disposes of the post process manager.
  28635. */
  28636. dispose(): void;
  28637. }
  28638. }
  28639. declare module BABYLON {
  28640. /**
  28641. * This Helps creating a texture that will be created from a camera in your scene.
  28642. * It is basically a dynamic texture that could be used to create special effects for instance.
  28643. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  28644. */
  28645. export class RenderTargetTexture extends Texture {
  28646. /**
  28647. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  28648. */
  28649. static readonly REFRESHRATE_RENDER_ONCE: number;
  28650. /**
  28651. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  28652. */
  28653. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  28654. /**
  28655. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  28656. * the central point of your effect and can save a lot of performances.
  28657. */
  28658. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  28659. /**
  28660. * Use this predicate to dynamically define the list of mesh you want to render.
  28661. * If set, the renderList property will be overwritten.
  28662. */
  28663. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  28664. private _renderList;
  28665. /**
  28666. * Use this list to define the list of mesh you want to render.
  28667. */
  28668. get renderList(): Nullable<Array<AbstractMesh>>;
  28669. set renderList(value: Nullable<Array<AbstractMesh>>);
  28670. /**
  28671. * Use this function to overload the renderList array at rendering time.
  28672. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  28673. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  28674. * the cube (if the RTT is a cube, else layerOrFace=0).
  28675. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  28676. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  28677. * hold dummy elements!
  28678. */
  28679. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  28680. private _hookArray;
  28681. /**
  28682. * Define if particles should be rendered in your texture.
  28683. */
  28684. renderParticles: boolean;
  28685. /**
  28686. * Define if sprites should be rendered in your texture.
  28687. */
  28688. renderSprites: boolean;
  28689. /**
  28690. * Define the camera used to render the texture.
  28691. */
  28692. activeCamera: Nullable<Camera>;
  28693. /**
  28694. * Override the mesh isReady function with your own one.
  28695. */
  28696. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  28697. /**
  28698. * Override the render function of the texture with your own one.
  28699. */
  28700. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  28701. /**
  28702. * Define if camera post processes should be use while rendering the texture.
  28703. */
  28704. useCameraPostProcesses: boolean;
  28705. /**
  28706. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  28707. */
  28708. ignoreCameraViewport: boolean;
  28709. private _postProcessManager;
  28710. private _postProcesses;
  28711. private _resizeObserver;
  28712. /**
  28713. * An event triggered when the texture is unbind.
  28714. */
  28715. onBeforeBindObservable: Observable<RenderTargetTexture>;
  28716. /**
  28717. * An event triggered when the texture is unbind.
  28718. */
  28719. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  28720. private _onAfterUnbindObserver;
  28721. /**
  28722. * Set a after unbind callback in the texture.
  28723. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  28724. */
  28725. set onAfterUnbind(callback: () => void);
  28726. /**
  28727. * An event triggered before rendering the texture
  28728. */
  28729. onBeforeRenderObservable: Observable<number>;
  28730. private _onBeforeRenderObserver;
  28731. /**
  28732. * Set a before render callback in the texture.
  28733. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  28734. */
  28735. set onBeforeRender(callback: (faceIndex: number) => void);
  28736. /**
  28737. * An event triggered after rendering the texture
  28738. */
  28739. onAfterRenderObservable: Observable<number>;
  28740. private _onAfterRenderObserver;
  28741. /**
  28742. * Set a after render callback in the texture.
  28743. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  28744. */
  28745. set onAfterRender(callback: (faceIndex: number) => void);
  28746. /**
  28747. * An event triggered after the texture clear
  28748. */
  28749. onClearObservable: Observable<Engine>;
  28750. private _onClearObserver;
  28751. /**
  28752. * Set a clear callback in the texture.
  28753. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  28754. */
  28755. set onClear(callback: (Engine: Engine) => void);
  28756. /**
  28757. * An event triggered when the texture is resized.
  28758. */
  28759. onResizeObservable: Observable<RenderTargetTexture>;
  28760. /**
  28761. * Define the clear color of the Render Target if it should be different from the scene.
  28762. */
  28763. clearColor: Color4;
  28764. protected _size: number | {
  28765. width: number;
  28766. height: number;
  28767. layers?: number;
  28768. };
  28769. protected _initialSizeParameter: number | {
  28770. width: number;
  28771. height: number;
  28772. } | {
  28773. ratio: number;
  28774. };
  28775. protected _sizeRatio: Nullable<number>;
  28776. /** @hidden */
  28777. _generateMipMaps: boolean;
  28778. protected _renderingManager: RenderingManager;
  28779. /** @hidden */
  28780. _waitingRenderList?: string[];
  28781. protected _doNotChangeAspectRatio: boolean;
  28782. protected _currentRefreshId: number;
  28783. protected _refreshRate: number;
  28784. protected _textureMatrix: Matrix;
  28785. protected _samples: number;
  28786. protected _renderTargetOptions: RenderTargetCreationOptions;
  28787. /**
  28788. * Gets render target creation options that were used.
  28789. */
  28790. get renderTargetOptions(): RenderTargetCreationOptions;
  28791. protected _onRatioRescale(): void;
  28792. /**
  28793. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  28794. * It must define where the camera used to render the texture is set
  28795. */
  28796. boundingBoxPosition: Vector3;
  28797. private _boundingBoxSize;
  28798. /**
  28799. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  28800. * When defined, the cubemap will switch to local mode
  28801. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  28802. * @example https://www.babylonjs-playground.com/#RNASML
  28803. */
  28804. set boundingBoxSize(value: Vector3);
  28805. get boundingBoxSize(): Vector3;
  28806. /**
  28807. * In case the RTT has been created with a depth texture, get the associated
  28808. * depth texture.
  28809. * Otherwise, return null.
  28810. */
  28811. get depthStencilTexture(): Nullable<InternalTexture>;
  28812. /**
  28813. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  28814. * or used a shadow, depth texture...
  28815. * @param name The friendly name of the texture
  28816. * @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)
  28817. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  28818. * @param generateMipMaps True if mip maps need to be generated after render.
  28819. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  28820. * @param type The type of the buffer in the RTT (int, half float, float...)
  28821. * @param isCube True if a cube texture needs to be created
  28822. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  28823. * @param generateDepthBuffer True to generate a depth buffer
  28824. * @param generateStencilBuffer True to generate a stencil buffer
  28825. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  28826. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  28827. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28828. */
  28829. constructor(name: string, size: number | {
  28830. width: number;
  28831. height: number;
  28832. layers?: number;
  28833. } | {
  28834. ratio: number;
  28835. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  28836. /**
  28837. * Creates a depth stencil texture.
  28838. * This is only available in WebGL 2 or with the depth texture extension available.
  28839. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  28840. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  28841. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  28842. */
  28843. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  28844. private _processSizeParameter;
  28845. /**
  28846. * Define the number of samples to use in case of MSAA.
  28847. * It defaults to one meaning no MSAA has been enabled.
  28848. */
  28849. get samples(): number;
  28850. set samples(value: number);
  28851. /**
  28852. * Resets the refresh counter of the texture and start bak from scratch.
  28853. * Could be useful to regenerate the texture if it is setup to render only once.
  28854. */
  28855. resetRefreshCounter(): void;
  28856. /**
  28857. * Define the refresh rate of the texture or the rendering frequency.
  28858. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  28859. */
  28860. get refreshRate(): number;
  28861. set refreshRate(value: number);
  28862. /**
  28863. * Adds a post process to the render target rendering passes.
  28864. * @param postProcess define the post process to add
  28865. */
  28866. addPostProcess(postProcess: PostProcess): void;
  28867. /**
  28868. * Clear all the post processes attached to the render target
  28869. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  28870. */
  28871. clearPostProcesses(dispose?: boolean): void;
  28872. /**
  28873. * Remove one of the post process from the list of attached post processes to the texture
  28874. * @param postProcess define the post process to remove from the list
  28875. */
  28876. removePostProcess(postProcess: PostProcess): void;
  28877. /** @hidden */
  28878. _shouldRender(): boolean;
  28879. /**
  28880. * Gets the actual render size of the texture.
  28881. * @returns the width of the render size
  28882. */
  28883. getRenderSize(): number;
  28884. /**
  28885. * Gets the actual render width of the texture.
  28886. * @returns the width of the render size
  28887. */
  28888. getRenderWidth(): number;
  28889. /**
  28890. * Gets the actual render height of the texture.
  28891. * @returns the height of the render size
  28892. */
  28893. getRenderHeight(): number;
  28894. /**
  28895. * Gets the actual number of layers of the texture.
  28896. * @returns the number of layers
  28897. */
  28898. getRenderLayers(): number;
  28899. /**
  28900. * Get if the texture can be rescaled or not.
  28901. */
  28902. get canRescale(): boolean;
  28903. /**
  28904. * Resize the texture using a ratio.
  28905. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  28906. */
  28907. scale(ratio: number): void;
  28908. /**
  28909. * Get the texture reflection matrix used to rotate/transform the reflection.
  28910. * @returns the reflection matrix
  28911. */
  28912. getReflectionTextureMatrix(): Matrix;
  28913. /**
  28914. * Resize the texture to a new desired size.
  28915. * Be carrefull as it will recreate all the data in the new texture.
  28916. * @param size Define the new size. It can be:
  28917. * - a number for squared texture,
  28918. * - an object containing { width: number, height: number }
  28919. * - or an object containing a ratio { ratio: number }
  28920. */
  28921. resize(size: number | {
  28922. width: number;
  28923. height: number;
  28924. } | {
  28925. ratio: number;
  28926. }): void;
  28927. private _defaultRenderListPrepared;
  28928. /**
  28929. * Renders all the objects from the render list into the texture.
  28930. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  28931. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  28932. */
  28933. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  28934. private _bestReflectionRenderTargetDimension;
  28935. private _prepareRenderingManager;
  28936. /**
  28937. * @hidden
  28938. * @param faceIndex face index to bind to if this is a cubetexture
  28939. * @param layer defines the index of the texture to bind in the array
  28940. */
  28941. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  28942. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  28943. private renderToTarget;
  28944. /**
  28945. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  28946. * This allowed control for front to back rendering or reversly depending of the special needs.
  28947. *
  28948. * @param renderingGroupId The rendering group id corresponding to its index
  28949. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  28950. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  28951. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  28952. */
  28953. 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;
  28954. /**
  28955. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  28956. *
  28957. * @param renderingGroupId The rendering group id corresponding to its index
  28958. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  28959. */
  28960. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  28961. /**
  28962. * Clones the texture.
  28963. * @returns the cloned texture
  28964. */
  28965. clone(): RenderTargetTexture;
  28966. /**
  28967. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  28968. * @returns The JSON representation of the texture
  28969. */
  28970. serialize(): any;
  28971. /**
  28972. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  28973. */
  28974. disposeFramebufferObjects(): void;
  28975. /**
  28976. * Dispose the texture and release its associated resources.
  28977. */
  28978. dispose(): void;
  28979. /** @hidden */
  28980. _rebuild(): void;
  28981. /**
  28982. * Clear the info related to rendering groups preventing retention point in material dispose.
  28983. */
  28984. freeRenderingGroups(): void;
  28985. /**
  28986. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  28987. * @returns the view count
  28988. */
  28989. getViewCount(): number;
  28990. }
  28991. }
  28992. declare module BABYLON {
  28993. /**
  28994. * Class used to manipulate GUIDs
  28995. */
  28996. export class GUID {
  28997. /**
  28998. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28999. * Be aware Math.random() could cause collisions, but:
  29000. * "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"
  29001. * @returns a pseudo random id
  29002. */
  29003. static RandomId(): string;
  29004. }
  29005. }
  29006. declare module BABYLON {
  29007. /**
  29008. * Options to be used when creating a shadow depth material
  29009. */
  29010. export interface IIOptionShadowDepthMaterial {
  29011. /** Variables in the vertex shader code that need to have their names remapped.
  29012. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  29013. * "var_name" should be either: worldPos or vNormalW
  29014. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  29015. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  29016. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  29017. */
  29018. remappedVariables?: string[];
  29019. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  29020. standalone?: boolean;
  29021. }
  29022. /**
  29023. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  29024. */
  29025. export class ShadowDepthWrapper {
  29026. private _scene;
  29027. private _options?;
  29028. private _baseMaterial;
  29029. private _onEffectCreatedObserver;
  29030. private _subMeshToEffect;
  29031. private _subMeshToDepthEffect;
  29032. private _meshes;
  29033. /** @hidden */
  29034. _matriceNames: any;
  29035. /** Gets the standalone status of the wrapper */
  29036. get standalone(): boolean;
  29037. /** Gets the base material the wrapper is built upon */
  29038. get baseMaterial(): Material;
  29039. /**
  29040. * Instantiate a new shadow depth wrapper.
  29041. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  29042. * generate the shadow depth map. For more information, please refer to the documentation:
  29043. * https://doc.babylonjs.com/babylon101/shadows
  29044. * @param baseMaterial Material to wrap
  29045. * @param scene Define the scene the material belongs to
  29046. * @param options Options used to create the wrapper
  29047. */
  29048. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  29049. /**
  29050. * Gets the effect to use to generate the depth map
  29051. * @param subMesh subMesh to get the effect for
  29052. * @param shadowGenerator shadow generator to get the effect for
  29053. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  29054. */
  29055. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  29056. /**
  29057. * Specifies that the submesh is ready to be used for depth rendering
  29058. * @param subMesh submesh to check
  29059. * @param defines the list of defines to take into account when checking the effect
  29060. * @param shadowGenerator combined with subMesh, it defines the effect to check
  29061. * @param useInstances specifies that instances should be used
  29062. * @returns a boolean indicating that the submesh is ready or not
  29063. */
  29064. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  29065. /**
  29066. * Disposes the resources
  29067. */
  29068. dispose(): void;
  29069. private _makeEffect;
  29070. }
  29071. }
  29072. declare module BABYLON {
  29073. /**
  29074. * Options for compiling materials.
  29075. */
  29076. export interface IMaterialCompilationOptions {
  29077. /**
  29078. * Defines whether clip planes are enabled.
  29079. */
  29080. clipPlane: boolean;
  29081. /**
  29082. * Defines whether instances are enabled.
  29083. */
  29084. useInstances: boolean;
  29085. }
  29086. /**
  29087. * Options passed when calling customShaderNameResolve
  29088. */
  29089. export interface ICustomShaderNameResolveOptions {
  29090. /**
  29091. * 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
  29092. */
  29093. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  29094. }
  29095. /**
  29096. * Base class for the main features of a material in Babylon.js
  29097. */
  29098. export class Material implements IAnimatable {
  29099. /**
  29100. * Returns the triangle fill mode
  29101. */
  29102. static readonly TriangleFillMode: number;
  29103. /**
  29104. * Returns the wireframe mode
  29105. */
  29106. static readonly WireFrameFillMode: number;
  29107. /**
  29108. * Returns the point fill mode
  29109. */
  29110. static readonly PointFillMode: number;
  29111. /**
  29112. * Returns the point list draw mode
  29113. */
  29114. static readonly PointListDrawMode: number;
  29115. /**
  29116. * Returns the line list draw mode
  29117. */
  29118. static readonly LineListDrawMode: number;
  29119. /**
  29120. * Returns the line loop draw mode
  29121. */
  29122. static readonly LineLoopDrawMode: number;
  29123. /**
  29124. * Returns the line strip draw mode
  29125. */
  29126. static readonly LineStripDrawMode: number;
  29127. /**
  29128. * Returns the triangle strip draw mode
  29129. */
  29130. static readonly TriangleStripDrawMode: number;
  29131. /**
  29132. * Returns the triangle fan draw mode
  29133. */
  29134. static readonly TriangleFanDrawMode: number;
  29135. /**
  29136. * Stores the clock-wise side orientation
  29137. */
  29138. static readonly ClockWiseSideOrientation: number;
  29139. /**
  29140. * Stores the counter clock-wise side orientation
  29141. */
  29142. static readonly CounterClockWiseSideOrientation: number;
  29143. /**
  29144. * The dirty texture flag value
  29145. */
  29146. static readonly TextureDirtyFlag: number;
  29147. /**
  29148. * The dirty light flag value
  29149. */
  29150. static readonly LightDirtyFlag: number;
  29151. /**
  29152. * The dirty fresnel flag value
  29153. */
  29154. static readonly FresnelDirtyFlag: number;
  29155. /**
  29156. * The dirty attribute flag value
  29157. */
  29158. static readonly AttributesDirtyFlag: number;
  29159. /**
  29160. * The dirty misc flag value
  29161. */
  29162. static readonly MiscDirtyFlag: number;
  29163. /**
  29164. * The dirty prepass flag value
  29165. */
  29166. static readonly PrePassDirtyFlag: number;
  29167. /**
  29168. * The all dirty flag value
  29169. */
  29170. static readonly AllDirtyFlag: number;
  29171. /**
  29172. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  29173. */
  29174. static readonly MATERIAL_OPAQUE: number;
  29175. /**
  29176. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  29177. */
  29178. static readonly MATERIAL_ALPHATEST: number;
  29179. /**
  29180. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  29181. */
  29182. static readonly MATERIAL_ALPHABLEND: number;
  29183. /**
  29184. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  29185. * They are also discarded below the alpha cutoff threshold to improve performances.
  29186. */
  29187. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  29188. /**
  29189. * The Whiteout method is used to blend normals.
  29190. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  29191. */
  29192. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  29193. /**
  29194. * The Reoriented Normal Mapping method is used to blend normals.
  29195. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  29196. */
  29197. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  29198. /**
  29199. * Custom callback helping to override the default shader used in the material.
  29200. */
  29201. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  29202. /**
  29203. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  29204. */
  29205. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  29206. /**
  29207. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  29208. * This means that the material can keep using a previous shader while a new one is being compiled.
  29209. * This is mostly used when shader parallel compilation is supported (true by default)
  29210. */
  29211. allowShaderHotSwapping: boolean;
  29212. /**
  29213. * The ID of the material
  29214. */
  29215. id: string;
  29216. /**
  29217. * Gets or sets the unique id of the material
  29218. */
  29219. uniqueId: number;
  29220. /**
  29221. * The name of the material
  29222. */
  29223. name: string;
  29224. /**
  29225. * Gets or sets user defined metadata
  29226. */
  29227. metadata: any;
  29228. /**
  29229. * For internal use only. Please do not use.
  29230. */
  29231. reservedDataStore: any;
  29232. /**
  29233. * Specifies if the ready state should be checked on each call
  29234. */
  29235. checkReadyOnEveryCall: boolean;
  29236. /**
  29237. * Specifies if the ready state should be checked once
  29238. */
  29239. checkReadyOnlyOnce: boolean;
  29240. /**
  29241. * The state of the material
  29242. */
  29243. state: string;
  29244. /**
  29245. * If the material can be rendered to several textures with MRT extension
  29246. */
  29247. get canRenderToMRT(): boolean;
  29248. /**
  29249. * The alpha value of the material
  29250. */
  29251. protected _alpha: number;
  29252. /**
  29253. * List of inspectable custom properties (used by the Inspector)
  29254. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29255. */
  29256. inspectableCustomProperties: IInspectable[];
  29257. /**
  29258. * Sets the alpha value of the material
  29259. */
  29260. set alpha(value: number);
  29261. /**
  29262. * Gets the alpha value of the material
  29263. */
  29264. get alpha(): number;
  29265. /**
  29266. * Specifies if back face culling is enabled
  29267. */
  29268. protected _backFaceCulling: boolean;
  29269. /**
  29270. * Sets the back-face culling state
  29271. */
  29272. set backFaceCulling(value: boolean);
  29273. /**
  29274. * Gets the back-face culling state
  29275. */
  29276. get backFaceCulling(): boolean;
  29277. /**
  29278. * Stores the value for side orientation
  29279. */
  29280. sideOrientation: number;
  29281. /**
  29282. * Callback triggered when the material is compiled
  29283. */
  29284. onCompiled: Nullable<(effect: Effect) => void>;
  29285. /**
  29286. * Callback triggered when an error occurs
  29287. */
  29288. onError: Nullable<(effect: Effect, errors: string) => void>;
  29289. /**
  29290. * Callback triggered to get the render target textures
  29291. */
  29292. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  29293. /**
  29294. * Gets a boolean indicating that current material needs to register RTT
  29295. */
  29296. get hasRenderTargetTextures(): boolean;
  29297. /**
  29298. * Specifies if the material should be serialized
  29299. */
  29300. doNotSerialize: boolean;
  29301. /**
  29302. * @hidden
  29303. */
  29304. _storeEffectOnSubMeshes: boolean;
  29305. /**
  29306. * Stores the animations for the material
  29307. */
  29308. animations: Nullable<Array<Animation>>;
  29309. /**
  29310. * An event triggered when the material is disposed
  29311. */
  29312. onDisposeObservable: Observable<Material>;
  29313. /**
  29314. * An observer which watches for dispose events
  29315. */
  29316. private _onDisposeObserver;
  29317. private _onUnBindObservable;
  29318. /**
  29319. * Called during a dispose event
  29320. */
  29321. set onDispose(callback: () => void);
  29322. private _onBindObservable;
  29323. /**
  29324. * An event triggered when the material is bound
  29325. */
  29326. get onBindObservable(): Observable<AbstractMesh>;
  29327. /**
  29328. * An observer which watches for bind events
  29329. */
  29330. private _onBindObserver;
  29331. /**
  29332. * Called during a bind event
  29333. */
  29334. set onBind(callback: (Mesh: AbstractMesh) => void);
  29335. /**
  29336. * An event triggered when the material is unbound
  29337. */
  29338. get onUnBindObservable(): Observable<Material>;
  29339. protected _onEffectCreatedObservable: Nullable<Observable<{
  29340. effect: Effect;
  29341. subMesh: Nullable<SubMesh>;
  29342. }>>;
  29343. /**
  29344. * An event triggered when the effect is (re)created
  29345. */
  29346. get onEffectCreatedObservable(): Observable<{
  29347. effect: Effect;
  29348. subMesh: Nullable<SubMesh>;
  29349. }>;
  29350. /**
  29351. * Stores the value of the alpha mode
  29352. */
  29353. private _alphaMode;
  29354. /**
  29355. * Sets the value of the alpha mode.
  29356. *
  29357. * | Value | Type | Description |
  29358. * | --- | --- | --- |
  29359. * | 0 | ALPHA_DISABLE | |
  29360. * | 1 | ALPHA_ADD | |
  29361. * | 2 | ALPHA_COMBINE | |
  29362. * | 3 | ALPHA_SUBTRACT | |
  29363. * | 4 | ALPHA_MULTIPLY | |
  29364. * | 5 | ALPHA_MAXIMIZED | |
  29365. * | 6 | ALPHA_ONEONE | |
  29366. * | 7 | ALPHA_PREMULTIPLIED | |
  29367. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  29368. * | 9 | ALPHA_INTERPOLATE | |
  29369. * | 10 | ALPHA_SCREENMODE | |
  29370. *
  29371. */
  29372. set alphaMode(value: number);
  29373. /**
  29374. * Gets the value of the alpha mode
  29375. */
  29376. get alphaMode(): number;
  29377. /**
  29378. * Stores the state of the need depth pre-pass value
  29379. */
  29380. private _needDepthPrePass;
  29381. /**
  29382. * Sets the need depth pre-pass value
  29383. */
  29384. set needDepthPrePass(value: boolean);
  29385. /**
  29386. * Gets the depth pre-pass value
  29387. */
  29388. get needDepthPrePass(): boolean;
  29389. /**
  29390. * Specifies if depth writing should be disabled
  29391. */
  29392. disableDepthWrite: boolean;
  29393. /**
  29394. * Specifies if color writing should be disabled
  29395. */
  29396. disableColorWrite: boolean;
  29397. /**
  29398. * Specifies if depth writing should be forced
  29399. */
  29400. forceDepthWrite: boolean;
  29401. /**
  29402. * Specifies the depth function that should be used. 0 means the default engine function
  29403. */
  29404. depthFunction: number;
  29405. /**
  29406. * Specifies if there should be a separate pass for culling
  29407. */
  29408. separateCullingPass: boolean;
  29409. /**
  29410. * Stores the state specifing if fog should be enabled
  29411. */
  29412. private _fogEnabled;
  29413. /**
  29414. * Sets the state for enabling fog
  29415. */
  29416. set fogEnabled(value: boolean);
  29417. /**
  29418. * Gets the value of the fog enabled state
  29419. */
  29420. get fogEnabled(): boolean;
  29421. /**
  29422. * Stores the size of points
  29423. */
  29424. pointSize: number;
  29425. /**
  29426. * Stores the z offset value
  29427. */
  29428. zOffset: number;
  29429. get wireframe(): boolean;
  29430. /**
  29431. * Sets the state of wireframe mode
  29432. */
  29433. set wireframe(value: boolean);
  29434. /**
  29435. * Gets the value specifying if point clouds are enabled
  29436. */
  29437. get pointsCloud(): boolean;
  29438. /**
  29439. * Sets the state of point cloud mode
  29440. */
  29441. set pointsCloud(value: boolean);
  29442. /**
  29443. * Gets the material fill mode
  29444. */
  29445. get fillMode(): number;
  29446. /**
  29447. * Sets the material fill mode
  29448. */
  29449. set fillMode(value: number);
  29450. /**
  29451. * @hidden
  29452. * Stores the effects for the material
  29453. */
  29454. _effect: Nullable<Effect>;
  29455. /**
  29456. * Specifies if uniform buffers should be used
  29457. */
  29458. private _useUBO;
  29459. /**
  29460. * Stores a reference to the scene
  29461. */
  29462. private _scene;
  29463. /**
  29464. * Stores the fill mode state
  29465. */
  29466. private _fillMode;
  29467. /**
  29468. * Specifies if the depth write state should be cached
  29469. */
  29470. private _cachedDepthWriteState;
  29471. /**
  29472. * Specifies if the color write state should be cached
  29473. */
  29474. private _cachedColorWriteState;
  29475. /**
  29476. * Specifies if the depth function state should be cached
  29477. */
  29478. private _cachedDepthFunctionState;
  29479. /**
  29480. * Stores the uniform buffer
  29481. */
  29482. protected _uniformBuffer: UniformBuffer;
  29483. /** @hidden */
  29484. _indexInSceneMaterialArray: number;
  29485. /** @hidden */
  29486. meshMap: Nullable<{
  29487. [id: string]: AbstractMesh | undefined;
  29488. }>;
  29489. /**
  29490. * Creates a material instance
  29491. * @param name defines the name of the material
  29492. * @param scene defines the scene to reference
  29493. * @param doNotAdd specifies if the material should be added to the scene
  29494. */
  29495. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  29496. /**
  29497. * Returns a string representation of the current material
  29498. * @param fullDetails defines a boolean indicating which levels of logging is desired
  29499. * @returns a string with material information
  29500. */
  29501. toString(fullDetails?: boolean): string;
  29502. /**
  29503. * Gets the class name of the material
  29504. * @returns a string with the class name of the material
  29505. */
  29506. getClassName(): string;
  29507. /**
  29508. * Specifies if updates for the material been locked
  29509. */
  29510. get isFrozen(): boolean;
  29511. /**
  29512. * Locks updates for the material
  29513. */
  29514. freeze(): void;
  29515. /**
  29516. * Unlocks updates for the material
  29517. */
  29518. unfreeze(): void;
  29519. /**
  29520. * Specifies if the material is ready to be used
  29521. * @param mesh defines the mesh to check
  29522. * @param useInstances specifies if instances should be used
  29523. * @returns a boolean indicating if the material is ready to be used
  29524. */
  29525. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  29526. /**
  29527. * Specifies that the submesh is ready to be used
  29528. * @param mesh defines the mesh to check
  29529. * @param subMesh defines which submesh to check
  29530. * @param useInstances specifies that instances should be used
  29531. * @returns a boolean indicating that the submesh is ready or not
  29532. */
  29533. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29534. /**
  29535. * Returns the material effect
  29536. * @returns the effect associated with the material
  29537. */
  29538. getEffect(): Nullable<Effect>;
  29539. /**
  29540. * Returns the current scene
  29541. * @returns a Scene
  29542. */
  29543. getScene(): Scene;
  29544. /**
  29545. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  29546. */
  29547. protected _forceAlphaTest: boolean;
  29548. /**
  29549. * The transparency mode of the material.
  29550. */
  29551. protected _transparencyMode: Nullable<number>;
  29552. /**
  29553. * Gets the current transparency mode.
  29554. */
  29555. get transparencyMode(): Nullable<number>;
  29556. /**
  29557. * Sets the transparency mode of the material.
  29558. *
  29559. * | Value | Type | Description |
  29560. * | ----- | ----------------------------------- | ----------- |
  29561. * | 0 | OPAQUE | |
  29562. * | 1 | ALPHATEST | |
  29563. * | 2 | ALPHABLEND | |
  29564. * | 3 | ALPHATESTANDBLEND | |
  29565. *
  29566. */
  29567. set transparencyMode(value: Nullable<number>);
  29568. /**
  29569. * Returns true if alpha blending should be disabled.
  29570. */
  29571. protected get _disableAlphaBlending(): boolean;
  29572. /**
  29573. * Specifies whether or not this material should be rendered in alpha blend mode.
  29574. * @returns a boolean specifying if alpha blending is needed
  29575. */
  29576. needAlphaBlending(): boolean;
  29577. /**
  29578. * Specifies if the mesh will require alpha blending
  29579. * @param mesh defines the mesh to check
  29580. * @returns a boolean specifying if alpha blending is needed for the mesh
  29581. */
  29582. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  29583. /**
  29584. * Specifies whether or not this material should be rendered in alpha test mode.
  29585. * @returns a boolean specifying if an alpha test is needed.
  29586. */
  29587. needAlphaTesting(): boolean;
  29588. /**
  29589. * Specifies if material alpha testing should be turned on for the mesh
  29590. * @param mesh defines the mesh to check
  29591. */
  29592. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  29593. /**
  29594. * Gets the texture used for the alpha test
  29595. * @returns the texture to use for alpha testing
  29596. */
  29597. getAlphaTestTexture(): Nullable<BaseTexture>;
  29598. /**
  29599. * Marks the material to indicate that it needs to be re-calculated
  29600. */
  29601. markDirty(): void;
  29602. /** @hidden */
  29603. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  29604. /**
  29605. * Binds the material to the mesh
  29606. * @param world defines the world transformation matrix
  29607. * @param mesh defines the mesh to bind the material to
  29608. */
  29609. bind(world: Matrix, mesh?: Mesh): void;
  29610. /**
  29611. * Binds the submesh to the material
  29612. * @param world defines the world transformation matrix
  29613. * @param mesh defines the mesh containing the submesh
  29614. * @param subMesh defines the submesh to bind the material to
  29615. */
  29616. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29617. /**
  29618. * Binds the world matrix to the material
  29619. * @param world defines the world transformation matrix
  29620. */
  29621. bindOnlyWorldMatrix(world: Matrix): void;
  29622. /**
  29623. * Binds the scene's uniform buffer to the effect.
  29624. * @param effect defines the effect to bind to the scene uniform buffer
  29625. * @param sceneUbo defines the uniform buffer storing scene data
  29626. */
  29627. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  29628. /**
  29629. * Binds the view matrix to the effect
  29630. * @param effect defines the effect to bind the view matrix to
  29631. */
  29632. bindView(effect: Effect): void;
  29633. /**
  29634. * Binds the view projection matrix to the effect
  29635. * @param effect defines the effect to bind the view projection matrix to
  29636. */
  29637. bindViewProjection(effect: Effect): void;
  29638. /**
  29639. * Processes to execute after binding the material to a mesh
  29640. * @param mesh defines the rendered mesh
  29641. */
  29642. protected _afterBind(mesh?: Mesh): void;
  29643. /**
  29644. * Unbinds the material from the mesh
  29645. */
  29646. unbind(): void;
  29647. /**
  29648. * Gets the active textures from the material
  29649. * @returns an array of textures
  29650. */
  29651. getActiveTextures(): BaseTexture[];
  29652. /**
  29653. * Specifies if the material uses a texture
  29654. * @param texture defines the texture to check against the material
  29655. * @returns a boolean specifying if the material uses the texture
  29656. */
  29657. hasTexture(texture: BaseTexture): boolean;
  29658. /**
  29659. * Makes a duplicate of the material, and gives it a new name
  29660. * @param name defines the new name for the duplicated material
  29661. * @returns the cloned material
  29662. */
  29663. clone(name: string): Nullable<Material>;
  29664. /**
  29665. * Gets the meshes bound to the material
  29666. * @returns an array of meshes bound to the material
  29667. */
  29668. getBindedMeshes(): AbstractMesh[];
  29669. /**
  29670. * Force shader compilation
  29671. * @param mesh defines the mesh associated with this material
  29672. * @param onCompiled defines a function to execute once the material is compiled
  29673. * @param options defines the options to configure the compilation
  29674. * @param onError defines a function to execute if the material fails compiling
  29675. */
  29676. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  29677. /**
  29678. * Force shader compilation
  29679. * @param mesh defines the mesh that will use this material
  29680. * @param options defines additional options for compiling the shaders
  29681. * @returns a promise that resolves when the compilation completes
  29682. */
  29683. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  29684. private static readonly _AllDirtyCallBack;
  29685. private static readonly _ImageProcessingDirtyCallBack;
  29686. private static readonly _TextureDirtyCallBack;
  29687. private static readonly _FresnelDirtyCallBack;
  29688. private static readonly _MiscDirtyCallBack;
  29689. private static readonly _PrePassDirtyCallBack;
  29690. private static readonly _LightsDirtyCallBack;
  29691. private static readonly _AttributeDirtyCallBack;
  29692. private static _FresnelAndMiscDirtyCallBack;
  29693. private static _TextureAndMiscDirtyCallBack;
  29694. private static readonly _DirtyCallbackArray;
  29695. private static readonly _RunDirtyCallBacks;
  29696. /**
  29697. * Marks a define in the material to indicate that it needs to be re-computed
  29698. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  29699. */
  29700. markAsDirty(flag: number): void;
  29701. /**
  29702. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  29703. * @param func defines a function which checks material defines against the submeshes
  29704. */
  29705. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  29706. /**
  29707. * Indicates that the scene should check if the rendering now needs a prepass
  29708. */
  29709. protected _markScenePrePassDirty(): void;
  29710. /**
  29711. * Indicates that we need to re-calculated for all submeshes
  29712. */
  29713. protected _markAllSubMeshesAsAllDirty(): void;
  29714. /**
  29715. * Indicates that image processing needs to be re-calculated for all submeshes
  29716. */
  29717. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  29718. /**
  29719. * Indicates that textures need to be re-calculated for all submeshes
  29720. */
  29721. protected _markAllSubMeshesAsTexturesDirty(): void;
  29722. /**
  29723. * Indicates that fresnel needs to be re-calculated for all submeshes
  29724. */
  29725. protected _markAllSubMeshesAsFresnelDirty(): void;
  29726. /**
  29727. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  29728. */
  29729. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  29730. /**
  29731. * Indicates that lights need to be re-calculated for all submeshes
  29732. */
  29733. protected _markAllSubMeshesAsLightsDirty(): void;
  29734. /**
  29735. * Indicates that attributes need to be re-calculated for all submeshes
  29736. */
  29737. protected _markAllSubMeshesAsAttributesDirty(): void;
  29738. /**
  29739. * Indicates that misc needs to be re-calculated for all submeshes
  29740. */
  29741. protected _markAllSubMeshesAsMiscDirty(): void;
  29742. /**
  29743. * Indicates that prepass needs to be re-calculated for all submeshes
  29744. */
  29745. protected _markAllSubMeshesAsPrePassDirty(): void;
  29746. /**
  29747. * Indicates that textures and misc need to be re-calculated for all submeshes
  29748. */
  29749. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  29750. /**
  29751. * Sets the required values to the prepass renderer.
  29752. * @param prePassRenderer defines the prepass renderer to setup.
  29753. * @returns true if the pre pass is needed.
  29754. */
  29755. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  29756. /**
  29757. * Disposes the material
  29758. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29759. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29760. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  29761. */
  29762. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  29763. /** @hidden */
  29764. private releaseVertexArrayObject;
  29765. /**
  29766. * Serializes this material
  29767. * @returns the serialized material object
  29768. */
  29769. serialize(): any;
  29770. /**
  29771. * Creates a material from parsed material data
  29772. * @param parsedMaterial defines parsed material data
  29773. * @param scene defines the hosting scene
  29774. * @param rootUrl defines the root URL to use to load textures
  29775. * @returns a new material
  29776. */
  29777. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  29778. }
  29779. }
  29780. declare module BABYLON {
  29781. /**
  29782. * A multi-material is used to apply different materials to different parts of the same object without the need of
  29783. * separate meshes. This can be use to improve performances.
  29784. * @see https://doc.babylonjs.com/how_to/multi_materials
  29785. */
  29786. export class MultiMaterial extends Material {
  29787. private _subMaterials;
  29788. /**
  29789. * Gets or Sets the list of Materials used within the multi material.
  29790. * They need to be ordered according to the submeshes order in the associated mesh
  29791. */
  29792. get subMaterials(): Nullable<Material>[];
  29793. set subMaterials(value: Nullable<Material>[]);
  29794. /**
  29795. * Function used to align with Node.getChildren()
  29796. * @returns the list of Materials used within the multi material
  29797. */
  29798. getChildren(): Nullable<Material>[];
  29799. /**
  29800. * Instantiates a new Multi Material
  29801. * A multi-material is used to apply different materials to different parts of the same object without the need of
  29802. * separate meshes. This can be use to improve performances.
  29803. * @see https://doc.babylonjs.com/how_to/multi_materials
  29804. * @param name Define the name in the scene
  29805. * @param scene Define the scene the material belongs to
  29806. */
  29807. constructor(name: string, scene: Scene);
  29808. private _hookArray;
  29809. /**
  29810. * Get one of the submaterial by its index in the submaterials array
  29811. * @param index The index to look the sub material at
  29812. * @returns The Material if the index has been defined
  29813. */
  29814. getSubMaterial(index: number): Nullable<Material>;
  29815. /**
  29816. * Get the list of active textures for the whole sub materials list.
  29817. * @returns All the textures that will be used during the rendering
  29818. */
  29819. getActiveTextures(): BaseTexture[];
  29820. /**
  29821. * Gets the current class name of the material e.g. "MultiMaterial"
  29822. * Mainly use in serialization.
  29823. * @returns the class name
  29824. */
  29825. getClassName(): string;
  29826. /**
  29827. * Checks if the material is ready to render the requested sub mesh
  29828. * @param mesh Define the mesh the submesh belongs to
  29829. * @param subMesh Define the sub mesh to look readyness for
  29830. * @param useInstances Define whether or not the material is used with instances
  29831. * @returns true if ready, otherwise false
  29832. */
  29833. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29834. /**
  29835. * Clones the current material and its related sub materials
  29836. * @param name Define the name of the newly cloned material
  29837. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  29838. * @returns the cloned material
  29839. */
  29840. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  29841. /**
  29842. * Serializes the materials into a JSON representation.
  29843. * @returns the JSON representation
  29844. */
  29845. serialize(): any;
  29846. /**
  29847. * Dispose the material and release its associated resources
  29848. * @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)
  29849. * @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)
  29850. * @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)
  29851. */
  29852. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  29853. /**
  29854. * Creates a MultiMaterial from parsed MultiMaterial data.
  29855. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  29856. * @param scene defines the hosting scene
  29857. * @returns a new MultiMaterial
  29858. */
  29859. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  29860. }
  29861. }
  29862. declare module BABYLON {
  29863. /**
  29864. * Defines a subdivision inside a mesh
  29865. */
  29866. export class SubMesh implements ICullable {
  29867. /** the material index to use */
  29868. materialIndex: number;
  29869. /** vertex index start */
  29870. verticesStart: number;
  29871. /** vertices count */
  29872. verticesCount: number;
  29873. /** index start */
  29874. indexStart: number;
  29875. /** indices count */
  29876. indexCount: number;
  29877. /** @hidden */
  29878. _materialDefines: Nullable<MaterialDefines>;
  29879. /** @hidden */
  29880. _materialEffect: Nullable<Effect>;
  29881. /** @hidden */
  29882. _effectOverride: Nullable<Effect>;
  29883. /**
  29884. * Gets material defines used by the effect associated to the sub mesh
  29885. */
  29886. get materialDefines(): Nullable<MaterialDefines>;
  29887. /**
  29888. * Sets material defines used by the effect associated to the sub mesh
  29889. */
  29890. set materialDefines(defines: Nullable<MaterialDefines>);
  29891. /**
  29892. * Gets associated effect
  29893. */
  29894. get effect(): Nullable<Effect>;
  29895. /**
  29896. * Sets associated effect (effect used to render this submesh)
  29897. * @param effect defines the effect to associate with
  29898. * @param defines defines the set of defines used to compile this effect
  29899. */
  29900. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  29901. /** @hidden */
  29902. _linesIndexCount: number;
  29903. private _mesh;
  29904. private _renderingMesh;
  29905. private _boundingInfo;
  29906. private _linesIndexBuffer;
  29907. /** @hidden */
  29908. _lastColliderWorldVertices: Nullable<Vector3[]>;
  29909. /** @hidden */
  29910. _trianglePlanes: Plane[];
  29911. /** @hidden */
  29912. _lastColliderTransformMatrix: Nullable<Matrix>;
  29913. /** @hidden */
  29914. _renderId: number;
  29915. /** @hidden */
  29916. _alphaIndex: number;
  29917. /** @hidden */
  29918. _distanceToCamera: number;
  29919. /** @hidden */
  29920. _id: number;
  29921. private _currentMaterial;
  29922. /**
  29923. * Add a new submesh to a mesh
  29924. * @param materialIndex defines the material index to use
  29925. * @param verticesStart defines vertex index start
  29926. * @param verticesCount defines vertices count
  29927. * @param indexStart defines index start
  29928. * @param indexCount defines indices count
  29929. * @param mesh defines the parent mesh
  29930. * @param renderingMesh defines an optional rendering mesh
  29931. * @param createBoundingBox defines if bounding box should be created for this submesh
  29932. * @returns the new submesh
  29933. */
  29934. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  29935. /**
  29936. * Creates a new submesh
  29937. * @param materialIndex defines the material index to use
  29938. * @param verticesStart defines vertex index start
  29939. * @param verticesCount defines vertices count
  29940. * @param indexStart defines index start
  29941. * @param indexCount defines indices count
  29942. * @param mesh defines the parent mesh
  29943. * @param renderingMesh defines an optional rendering mesh
  29944. * @param createBoundingBox defines if bounding box should be created for this submesh
  29945. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  29946. */
  29947. constructor(
  29948. /** the material index to use */
  29949. materialIndex: number,
  29950. /** vertex index start */
  29951. verticesStart: number,
  29952. /** vertices count */
  29953. verticesCount: number,
  29954. /** index start */
  29955. indexStart: number,
  29956. /** indices count */
  29957. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  29958. /**
  29959. * Returns true if this submesh covers the entire parent mesh
  29960. * @ignorenaming
  29961. */
  29962. get IsGlobal(): boolean;
  29963. /**
  29964. * Returns the submesh BoudingInfo object
  29965. * @returns current bounding info (or mesh's one if the submesh is global)
  29966. */
  29967. getBoundingInfo(): BoundingInfo;
  29968. /**
  29969. * Sets the submesh BoundingInfo
  29970. * @param boundingInfo defines the new bounding info to use
  29971. * @returns the SubMesh
  29972. */
  29973. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  29974. /**
  29975. * Returns the mesh of the current submesh
  29976. * @return the parent mesh
  29977. */
  29978. getMesh(): AbstractMesh;
  29979. /**
  29980. * Returns the rendering mesh of the submesh
  29981. * @returns the rendering mesh (could be different from parent mesh)
  29982. */
  29983. getRenderingMesh(): Mesh;
  29984. /**
  29985. * Returns the replacement mesh of the submesh
  29986. * @returns the replacement mesh (could be different from parent mesh)
  29987. */
  29988. getReplacementMesh(): Nullable<AbstractMesh>;
  29989. /**
  29990. * Returns the effective mesh of the submesh
  29991. * @returns the effective mesh (could be different from parent mesh)
  29992. */
  29993. getEffectiveMesh(): AbstractMesh;
  29994. /**
  29995. * Returns the submesh material
  29996. * @returns null or the current material
  29997. */
  29998. getMaterial(): Nullable<Material>;
  29999. private _IsMultiMaterial;
  30000. /**
  30001. * Sets a new updated BoundingInfo object to the submesh
  30002. * @param data defines an optional position array to use to determine the bounding info
  30003. * @returns the SubMesh
  30004. */
  30005. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  30006. /** @hidden */
  30007. _checkCollision(collider: Collider): boolean;
  30008. /**
  30009. * Updates the submesh BoundingInfo
  30010. * @param world defines the world matrix to use to update the bounding info
  30011. * @returns the submesh
  30012. */
  30013. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  30014. /**
  30015. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  30016. * @param frustumPlanes defines the frustum planes
  30017. * @returns true if the submesh is intersecting with the frustum
  30018. */
  30019. isInFrustum(frustumPlanes: Plane[]): boolean;
  30020. /**
  30021. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  30022. * @param frustumPlanes defines the frustum planes
  30023. * @returns true if the submesh is inside the frustum
  30024. */
  30025. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  30026. /**
  30027. * Renders the submesh
  30028. * @param enableAlphaMode defines if alpha needs to be used
  30029. * @returns the submesh
  30030. */
  30031. render(enableAlphaMode: boolean): SubMesh;
  30032. /**
  30033. * @hidden
  30034. */
  30035. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  30036. /**
  30037. * Checks if the submesh intersects with a ray
  30038. * @param ray defines the ray to test
  30039. * @returns true is the passed ray intersects the submesh bounding box
  30040. */
  30041. canIntersects(ray: Ray): boolean;
  30042. /**
  30043. * Intersects current submesh with a ray
  30044. * @param ray defines the ray to test
  30045. * @param positions defines mesh's positions array
  30046. * @param indices defines mesh's indices array
  30047. * @param fastCheck defines if the first intersection will be used (and not the closest)
  30048. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  30049. * @returns intersection info or null if no intersection
  30050. */
  30051. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  30052. /** @hidden */
  30053. private _intersectLines;
  30054. /** @hidden */
  30055. private _intersectUnIndexedLines;
  30056. /** @hidden */
  30057. private _intersectTriangles;
  30058. /** @hidden */
  30059. private _intersectUnIndexedTriangles;
  30060. /** @hidden */
  30061. _rebuild(): void;
  30062. /**
  30063. * Creates a new submesh from the passed mesh
  30064. * @param newMesh defines the new hosting mesh
  30065. * @param newRenderingMesh defines an optional rendering mesh
  30066. * @returns the new submesh
  30067. */
  30068. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  30069. /**
  30070. * Release associated resources
  30071. */
  30072. dispose(): void;
  30073. /**
  30074. * Gets the class name
  30075. * @returns the string "SubMesh".
  30076. */
  30077. getClassName(): string;
  30078. /**
  30079. * Creates a new submesh from indices data
  30080. * @param materialIndex the index of the main mesh material
  30081. * @param startIndex the index where to start the copy in the mesh indices array
  30082. * @param indexCount the number of indices to copy then from the startIndex
  30083. * @param mesh the main mesh to create the submesh from
  30084. * @param renderingMesh the optional rendering mesh
  30085. * @returns a new submesh
  30086. */
  30087. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  30088. }
  30089. }
  30090. declare module BABYLON {
  30091. /**
  30092. * Class used to represent data loading progression
  30093. */
  30094. export class SceneLoaderFlags {
  30095. private static _ForceFullSceneLoadingForIncremental;
  30096. private static _ShowLoadingScreen;
  30097. private static _CleanBoneMatrixWeights;
  30098. private static _loggingLevel;
  30099. /**
  30100. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  30101. */
  30102. static get ForceFullSceneLoadingForIncremental(): boolean;
  30103. static set ForceFullSceneLoadingForIncremental(value: boolean);
  30104. /**
  30105. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  30106. */
  30107. static get ShowLoadingScreen(): boolean;
  30108. static set ShowLoadingScreen(value: boolean);
  30109. /**
  30110. * Defines the current logging level (while loading the scene)
  30111. * @ignorenaming
  30112. */
  30113. static get loggingLevel(): number;
  30114. static set loggingLevel(value: number);
  30115. /**
  30116. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  30117. */
  30118. static get CleanBoneMatrixWeights(): boolean;
  30119. static set CleanBoneMatrixWeights(value: boolean);
  30120. }
  30121. }
  30122. declare module BABYLON {
  30123. /**
  30124. * Class used to store geometry data (vertex buffers + index buffer)
  30125. */
  30126. export class Geometry implements IGetSetVerticesData {
  30127. /**
  30128. * Gets or sets the ID of the geometry
  30129. */
  30130. id: string;
  30131. /**
  30132. * Gets or sets the unique ID of the geometry
  30133. */
  30134. uniqueId: number;
  30135. /**
  30136. * Gets the delay loading state of the geometry (none by default which means not delayed)
  30137. */
  30138. delayLoadState: number;
  30139. /**
  30140. * Gets the file containing the data to load when running in delay load state
  30141. */
  30142. delayLoadingFile: Nullable<string>;
  30143. /**
  30144. * Callback called when the geometry is updated
  30145. */
  30146. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  30147. private _scene;
  30148. private _engine;
  30149. private _meshes;
  30150. private _totalVertices;
  30151. /** @hidden */
  30152. _indices: IndicesArray;
  30153. /** @hidden */
  30154. _vertexBuffers: {
  30155. [key: string]: VertexBuffer;
  30156. };
  30157. private _isDisposed;
  30158. private _extend;
  30159. private _boundingBias;
  30160. /** @hidden */
  30161. _delayInfo: Array<string>;
  30162. private _indexBuffer;
  30163. private _indexBufferIsUpdatable;
  30164. /** @hidden */
  30165. _boundingInfo: Nullable<BoundingInfo>;
  30166. /** @hidden */
  30167. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  30168. /** @hidden */
  30169. _softwareSkinningFrameId: number;
  30170. private _vertexArrayObjects;
  30171. private _updatable;
  30172. /** @hidden */
  30173. _positions: Nullable<Vector3[]>;
  30174. private _positionsCache;
  30175. /**
  30176. * 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
  30177. */
  30178. get boundingBias(): Vector2;
  30179. /**
  30180. * 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
  30181. */
  30182. set boundingBias(value: Vector2);
  30183. /**
  30184. * Static function used to attach a new empty geometry to a mesh
  30185. * @param mesh defines the mesh to attach the geometry to
  30186. * @returns the new Geometry
  30187. */
  30188. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  30189. /** Get the list of meshes using this geometry */
  30190. get meshes(): Mesh[];
  30191. /**
  30192. * 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
  30193. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  30194. */
  30195. useBoundingInfoFromGeometry: boolean;
  30196. /**
  30197. * Creates a new geometry
  30198. * @param id defines the unique ID
  30199. * @param scene defines the hosting scene
  30200. * @param vertexData defines the VertexData used to get geometry data
  30201. * @param updatable defines if geometry must be updatable (false by default)
  30202. * @param mesh defines the mesh that will be associated with the geometry
  30203. */
  30204. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  30205. /**
  30206. * Gets the current extend of the geometry
  30207. */
  30208. get extend(): {
  30209. minimum: Vector3;
  30210. maximum: Vector3;
  30211. };
  30212. /**
  30213. * Gets the hosting scene
  30214. * @returns the hosting Scene
  30215. */
  30216. getScene(): Scene;
  30217. /**
  30218. * Gets the hosting engine
  30219. * @returns the hosting Engine
  30220. */
  30221. getEngine(): Engine;
  30222. /**
  30223. * Defines if the geometry is ready to use
  30224. * @returns true if the geometry is ready to be used
  30225. */
  30226. isReady(): boolean;
  30227. /**
  30228. * Gets a value indicating that the geometry should not be serialized
  30229. */
  30230. get doNotSerialize(): boolean;
  30231. /** @hidden */
  30232. _rebuild(): void;
  30233. /**
  30234. * Affects all geometry data in one call
  30235. * @param vertexData defines the geometry data
  30236. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  30237. */
  30238. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  30239. /**
  30240. * Set specific vertex data
  30241. * @param kind defines the data kind (Position, normal, etc...)
  30242. * @param data defines the vertex data to use
  30243. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  30244. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  30245. */
  30246. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  30247. /**
  30248. * Removes a specific vertex data
  30249. * @param kind defines the data kind (Position, normal, etc...)
  30250. */
  30251. removeVerticesData(kind: string): void;
  30252. /**
  30253. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  30254. * @param buffer defines the vertex buffer to use
  30255. * @param totalVertices defines the total number of vertices for position kind (could be null)
  30256. */
  30257. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  30258. /**
  30259. * Update a specific vertex buffer
  30260. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  30261. * It will do nothing if the buffer is not updatable
  30262. * @param kind defines the data kind (Position, normal, etc...)
  30263. * @param data defines the data to use
  30264. * @param offset defines the offset in the target buffer where to store the data
  30265. * @param useBytes set to true if the offset is in bytes
  30266. */
  30267. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  30268. /**
  30269. * Update a specific vertex buffer
  30270. * This function will create a new buffer if the current one is not updatable
  30271. * @param kind defines the data kind (Position, normal, etc...)
  30272. * @param data defines the data to use
  30273. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  30274. */
  30275. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  30276. private _updateBoundingInfo;
  30277. /** @hidden */
  30278. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  30279. /**
  30280. * Gets total number of vertices
  30281. * @returns the total number of vertices
  30282. */
  30283. getTotalVertices(): number;
  30284. /**
  30285. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  30286. * @param kind defines the data kind (Position, normal, etc...)
  30287. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30288. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30289. * @returns a float array containing vertex data
  30290. */
  30291. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  30292. /**
  30293. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  30294. * @param kind defines the data kind (Position, normal, etc...)
  30295. * @returns true if the vertex buffer with the specified kind is updatable
  30296. */
  30297. isVertexBufferUpdatable(kind: string): boolean;
  30298. /**
  30299. * Gets a specific vertex buffer
  30300. * @param kind defines the data kind (Position, normal, etc...)
  30301. * @returns a VertexBuffer
  30302. */
  30303. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  30304. /**
  30305. * Returns all vertex buffers
  30306. * @return an object holding all vertex buffers indexed by kind
  30307. */
  30308. getVertexBuffers(): Nullable<{
  30309. [key: string]: VertexBuffer;
  30310. }>;
  30311. /**
  30312. * Gets a boolean indicating if specific vertex buffer is present
  30313. * @param kind defines the data kind (Position, normal, etc...)
  30314. * @returns true if data is present
  30315. */
  30316. isVerticesDataPresent(kind: string): boolean;
  30317. /**
  30318. * Gets a list of all attached data kinds (Position, normal, etc...)
  30319. * @returns a list of string containing all kinds
  30320. */
  30321. getVerticesDataKinds(): string[];
  30322. /**
  30323. * Update index buffer
  30324. * @param indices defines the indices to store in the index buffer
  30325. * @param offset defines the offset in the target buffer where to store the data
  30326. * @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)
  30327. */
  30328. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  30329. /**
  30330. * Creates a new index buffer
  30331. * @param indices defines the indices to store in the index buffer
  30332. * @param totalVertices defines the total number of vertices (could be null)
  30333. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  30334. */
  30335. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  30336. /**
  30337. * Return the total number of indices
  30338. * @returns the total number of indices
  30339. */
  30340. getTotalIndices(): number;
  30341. /**
  30342. * Gets the index buffer array
  30343. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30344. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30345. * @returns the index buffer array
  30346. */
  30347. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  30348. /**
  30349. * Gets the index buffer
  30350. * @return the index buffer
  30351. */
  30352. getIndexBuffer(): Nullable<DataBuffer>;
  30353. /** @hidden */
  30354. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  30355. /**
  30356. * Release the associated resources for a specific mesh
  30357. * @param mesh defines the source mesh
  30358. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  30359. */
  30360. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  30361. /**
  30362. * Apply current geometry to a given mesh
  30363. * @param mesh defines the mesh to apply geometry to
  30364. */
  30365. applyToMesh(mesh: Mesh): void;
  30366. private _updateExtend;
  30367. private _applyToMesh;
  30368. private notifyUpdate;
  30369. /**
  30370. * Load the geometry if it was flagged as delay loaded
  30371. * @param scene defines the hosting scene
  30372. * @param onLoaded defines a callback called when the geometry is loaded
  30373. */
  30374. load(scene: Scene, onLoaded?: () => void): void;
  30375. private _queueLoad;
  30376. /**
  30377. * Invert the geometry to move from a right handed system to a left handed one.
  30378. */
  30379. toLeftHanded(): void;
  30380. /** @hidden */
  30381. _resetPointsArrayCache(): void;
  30382. /** @hidden */
  30383. _generatePointsArray(): boolean;
  30384. /**
  30385. * Gets a value indicating if the geometry is disposed
  30386. * @returns true if the geometry was disposed
  30387. */
  30388. isDisposed(): boolean;
  30389. private _disposeVertexArrayObjects;
  30390. /**
  30391. * Free all associated resources
  30392. */
  30393. dispose(): void;
  30394. /**
  30395. * Clone the current geometry into a new geometry
  30396. * @param id defines the unique ID of the new geometry
  30397. * @returns a new geometry object
  30398. */
  30399. copy(id: string): Geometry;
  30400. /**
  30401. * Serialize the current geometry info (and not the vertices data) into a JSON object
  30402. * @return a JSON representation of the current geometry data (without the vertices data)
  30403. */
  30404. serialize(): any;
  30405. private toNumberArray;
  30406. /**
  30407. * Serialize all vertices data into a JSON oject
  30408. * @returns a JSON representation of the current geometry data
  30409. */
  30410. serializeVerticeData(): any;
  30411. /**
  30412. * Extracts a clone of a mesh geometry
  30413. * @param mesh defines the source mesh
  30414. * @param id defines the unique ID of the new geometry object
  30415. * @returns the new geometry object
  30416. */
  30417. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  30418. /**
  30419. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  30420. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30421. * Be aware Math.random() could cause collisions, but:
  30422. * "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"
  30423. * @returns a string containing a new GUID
  30424. */
  30425. static RandomId(): string;
  30426. /** @hidden */
  30427. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  30428. private static _CleanMatricesWeights;
  30429. /**
  30430. * Create a new geometry from persisted data (Using .babylon file format)
  30431. * @param parsedVertexData defines the persisted data
  30432. * @param scene defines the hosting scene
  30433. * @param rootUrl defines the root url to use to load assets (like delayed data)
  30434. * @returns the new geometry object
  30435. */
  30436. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  30437. }
  30438. }
  30439. declare module BABYLON {
  30440. /**
  30441. * Define an interface for all classes that will get and set the data on vertices
  30442. */
  30443. export interface IGetSetVerticesData {
  30444. /**
  30445. * Gets a boolean indicating if specific vertex data is present
  30446. * @param kind defines the vertex data kind to use
  30447. * @returns true is data kind is present
  30448. */
  30449. isVerticesDataPresent(kind: string): boolean;
  30450. /**
  30451. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  30452. * @param kind defines the data kind (Position, normal, etc...)
  30453. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30454. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30455. * @returns a float array containing vertex data
  30456. */
  30457. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  30458. /**
  30459. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  30460. * @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.
  30461. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30462. * @returns the indices array or an empty array if the mesh has no geometry
  30463. */
  30464. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  30465. /**
  30466. * Set specific vertex data
  30467. * @param kind defines the data kind (Position, normal, etc...)
  30468. * @param data defines the vertex data to use
  30469. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  30470. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  30471. */
  30472. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  30473. /**
  30474. * Update a specific associated vertex buffer
  30475. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  30476. * - VertexBuffer.PositionKind
  30477. * - VertexBuffer.UVKind
  30478. * - VertexBuffer.UV2Kind
  30479. * - VertexBuffer.UV3Kind
  30480. * - VertexBuffer.UV4Kind
  30481. * - VertexBuffer.UV5Kind
  30482. * - VertexBuffer.UV6Kind
  30483. * - VertexBuffer.ColorKind
  30484. * - VertexBuffer.MatricesIndicesKind
  30485. * - VertexBuffer.MatricesIndicesExtraKind
  30486. * - VertexBuffer.MatricesWeightsKind
  30487. * - VertexBuffer.MatricesWeightsExtraKind
  30488. * @param data defines the data source
  30489. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  30490. * @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)
  30491. */
  30492. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  30493. /**
  30494. * Creates a new index buffer
  30495. * @param indices defines the indices to store in the index buffer
  30496. * @param totalVertices defines the total number of vertices (could be null)
  30497. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  30498. */
  30499. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  30500. }
  30501. /**
  30502. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  30503. */
  30504. export class VertexData {
  30505. /**
  30506. * Mesh side orientation : usually the external or front surface
  30507. */
  30508. static readonly FRONTSIDE: number;
  30509. /**
  30510. * Mesh side orientation : usually the internal or back surface
  30511. */
  30512. static readonly BACKSIDE: number;
  30513. /**
  30514. * Mesh side orientation : both internal and external or front and back surfaces
  30515. */
  30516. static readonly DOUBLESIDE: number;
  30517. /**
  30518. * Mesh side orientation : by default, `FRONTSIDE`
  30519. */
  30520. static readonly DEFAULTSIDE: number;
  30521. /**
  30522. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  30523. */
  30524. positions: Nullable<FloatArray>;
  30525. /**
  30526. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  30527. */
  30528. normals: Nullable<FloatArray>;
  30529. /**
  30530. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  30531. */
  30532. tangents: Nullable<FloatArray>;
  30533. /**
  30534. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30535. */
  30536. uvs: Nullable<FloatArray>;
  30537. /**
  30538. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30539. */
  30540. uvs2: Nullable<FloatArray>;
  30541. /**
  30542. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30543. */
  30544. uvs3: Nullable<FloatArray>;
  30545. /**
  30546. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30547. */
  30548. uvs4: Nullable<FloatArray>;
  30549. /**
  30550. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30551. */
  30552. uvs5: Nullable<FloatArray>;
  30553. /**
  30554. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30555. */
  30556. uvs6: Nullable<FloatArray>;
  30557. /**
  30558. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  30559. */
  30560. colors: Nullable<FloatArray>;
  30561. /**
  30562. * 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).
  30563. */
  30564. matricesIndices: Nullable<FloatArray>;
  30565. /**
  30566. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  30567. */
  30568. matricesWeights: Nullable<FloatArray>;
  30569. /**
  30570. * An array extending the number of possible indices
  30571. */
  30572. matricesIndicesExtra: Nullable<FloatArray>;
  30573. /**
  30574. * An array extending the number of possible weights when the number of indices is extended
  30575. */
  30576. matricesWeightsExtra: Nullable<FloatArray>;
  30577. /**
  30578. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  30579. */
  30580. indices: Nullable<IndicesArray>;
  30581. /**
  30582. * Uses the passed data array to set the set the values for the specified kind of data
  30583. * @param data a linear array of floating numbers
  30584. * @param kind the type of data that is being set, eg positions, colors etc
  30585. */
  30586. set(data: FloatArray, kind: string): void;
  30587. /**
  30588. * Associates the vertexData to the passed Mesh.
  30589. * Sets it as updatable or not (default `false`)
  30590. * @param mesh the mesh the vertexData is applied to
  30591. * @param updatable when used and having the value true allows new data to update the vertexData
  30592. * @returns the VertexData
  30593. */
  30594. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  30595. /**
  30596. * Associates the vertexData to the passed Geometry.
  30597. * Sets it as updatable or not (default `false`)
  30598. * @param geometry the geometry the vertexData is applied to
  30599. * @param updatable when used and having the value true allows new data to update the vertexData
  30600. * @returns VertexData
  30601. */
  30602. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  30603. /**
  30604. * Updates the associated mesh
  30605. * @param mesh the mesh to be updated
  30606. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  30607. * @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
  30608. * @returns VertexData
  30609. */
  30610. updateMesh(mesh: Mesh): VertexData;
  30611. /**
  30612. * Updates the associated geometry
  30613. * @param geometry the geometry to be updated
  30614. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  30615. * @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
  30616. * @returns VertexData.
  30617. */
  30618. updateGeometry(geometry: Geometry): VertexData;
  30619. private _applyTo;
  30620. private _update;
  30621. /**
  30622. * Transforms each position and each normal of the vertexData according to the passed Matrix
  30623. * @param matrix the transforming matrix
  30624. * @returns the VertexData
  30625. */
  30626. transform(matrix: Matrix): VertexData;
  30627. /**
  30628. * Merges the passed VertexData into the current one
  30629. * @param other the VertexData to be merged into the current one
  30630. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  30631. * @returns the modified VertexData
  30632. */
  30633. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  30634. private _mergeElement;
  30635. private _validate;
  30636. /**
  30637. * Serializes the VertexData
  30638. * @returns a serialized object
  30639. */
  30640. serialize(): any;
  30641. /**
  30642. * Extracts the vertexData from a mesh
  30643. * @param mesh the mesh from which to extract the VertexData
  30644. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  30645. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  30646. * @returns the object VertexData associated to the passed mesh
  30647. */
  30648. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  30649. /**
  30650. * Extracts the vertexData from the geometry
  30651. * @param geometry the geometry from which to extract the VertexData
  30652. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  30653. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  30654. * @returns the object VertexData associated to the passed mesh
  30655. */
  30656. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  30657. private static _ExtractFrom;
  30658. /**
  30659. * Creates the VertexData for a Ribbon
  30660. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  30661. * * pathArray array of paths, each of which an array of successive Vector3
  30662. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  30663. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  30664. * * 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
  30665. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30666. * * 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)
  30667. * * 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)
  30668. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  30669. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  30670. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  30671. * @returns the VertexData of the ribbon
  30672. */
  30673. static CreateRibbon(options: {
  30674. pathArray: Vector3[][];
  30675. closeArray?: boolean;
  30676. closePath?: boolean;
  30677. offset?: number;
  30678. sideOrientation?: number;
  30679. frontUVs?: Vector4;
  30680. backUVs?: Vector4;
  30681. invertUV?: boolean;
  30682. uvs?: Vector2[];
  30683. colors?: Color4[];
  30684. }): VertexData;
  30685. /**
  30686. * Creates the VertexData for a box
  30687. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30688. * * size sets the width, height and depth of the box to the value of size, optional default 1
  30689. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  30690. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  30691. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  30692. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  30693. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  30694. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30695. * * 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)
  30696. * * 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)
  30697. * @returns the VertexData of the box
  30698. */
  30699. static CreateBox(options: {
  30700. size?: number;
  30701. width?: number;
  30702. height?: number;
  30703. depth?: number;
  30704. faceUV?: Vector4[];
  30705. faceColors?: Color4[];
  30706. sideOrientation?: number;
  30707. frontUVs?: Vector4;
  30708. backUVs?: Vector4;
  30709. }): VertexData;
  30710. /**
  30711. * Creates the VertexData for a tiled box
  30712. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30713. * * faceTiles sets the pattern, tile size and number of tiles for a face
  30714. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  30715. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  30716. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30717. * @returns the VertexData of the box
  30718. */
  30719. static CreateTiledBox(options: {
  30720. pattern?: number;
  30721. width?: number;
  30722. height?: number;
  30723. depth?: number;
  30724. tileSize?: number;
  30725. tileWidth?: number;
  30726. tileHeight?: number;
  30727. alignHorizontal?: number;
  30728. alignVertical?: number;
  30729. faceUV?: Vector4[];
  30730. faceColors?: Color4[];
  30731. sideOrientation?: number;
  30732. }): VertexData;
  30733. /**
  30734. * Creates the VertexData for a tiled plane
  30735. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30736. * * pattern a limited pattern arrangement depending on the number
  30737. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  30738. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  30739. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  30740. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30741. * * 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)
  30742. * * 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)
  30743. * @returns the VertexData of the tiled plane
  30744. */
  30745. static CreateTiledPlane(options: {
  30746. pattern?: number;
  30747. tileSize?: number;
  30748. tileWidth?: number;
  30749. tileHeight?: number;
  30750. size?: number;
  30751. width?: number;
  30752. height?: number;
  30753. alignHorizontal?: number;
  30754. alignVertical?: number;
  30755. sideOrientation?: number;
  30756. frontUVs?: Vector4;
  30757. backUVs?: Vector4;
  30758. }): VertexData;
  30759. /**
  30760. * Creates the VertexData for an ellipsoid, defaults to a sphere
  30761. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30762. * * segments sets the number of horizontal strips optional, default 32
  30763. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  30764. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  30765. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  30766. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  30767. * * 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
  30768. * * 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
  30769. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30770. * * 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)
  30771. * * 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)
  30772. * @returns the VertexData of the ellipsoid
  30773. */
  30774. static CreateSphere(options: {
  30775. segments?: number;
  30776. diameter?: number;
  30777. diameterX?: number;
  30778. diameterY?: number;
  30779. diameterZ?: number;
  30780. arc?: number;
  30781. slice?: number;
  30782. sideOrientation?: number;
  30783. frontUVs?: Vector4;
  30784. backUVs?: Vector4;
  30785. }): VertexData;
  30786. /**
  30787. * Creates the VertexData for a cylinder, cone or prism
  30788. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30789. * * height sets the height (y direction) of the cylinder, optional, default 2
  30790. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  30791. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  30792. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  30793. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  30794. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  30795. * * 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
  30796. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  30797. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  30798. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  30799. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  30800. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30801. * * 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)
  30802. * * 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)
  30803. * @returns the VertexData of the cylinder, cone or prism
  30804. */
  30805. static CreateCylinder(options: {
  30806. height?: number;
  30807. diameterTop?: number;
  30808. diameterBottom?: number;
  30809. diameter?: number;
  30810. tessellation?: number;
  30811. subdivisions?: number;
  30812. arc?: number;
  30813. faceColors?: Color4[];
  30814. faceUV?: Vector4[];
  30815. hasRings?: boolean;
  30816. enclose?: boolean;
  30817. sideOrientation?: number;
  30818. frontUVs?: Vector4;
  30819. backUVs?: Vector4;
  30820. }): VertexData;
  30821. /**
  30822. * Creates the VertexData for a torus
  30823. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30824. * * diameter the diameter of the torus, optional default 1
  30825. * * thickness the diameter of the tube forming the torus, optional default 0.5
  30826. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  30827. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30828. * * 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)
  30829. * * 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)
  30830. * @returns the VertexData of the torus
  30831. */
  30832. static CreateTorus(options: {
  30833. diameter?: number;
  30834. thickness?: number;
  30835. tessellation?: number;
  30836. sideOrientation?: number;
  30837. frontUVs?: Vector4;
  30838. backUVs?: Vector4;
  30839. }): VertexData;
  30840. /**
  30841. * Creates the VertexData of the LineSystem
  30842. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  30843. * - lines an array of lines, each line being an array of successive Vector3
  30844. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  30845. * @returns the VertexData of the LineSystem
  30846. */
  30847. static CreateLineSystem(options: {
  30848. lines: Vector3[][];
  30849. colors?: Nullable<Color4[][]>;
  30850. }): VertexData;
  30851. /**
  30852. * Create the VertexData for a DashedLines
  30853. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  30854. * - points an array successive Vector3
  30855. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  30856. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  30857. * - dashNb the intended total number of dashes, optional, default 200
  30858. * @returns the VertexData for the DashedLines
  30859. */
  30860. static CreateDashedLines(options: {
  30861. points: Vector3[];
  30862. dashSize?: number;
  30863. gapSize?: number;
  30864. dashNb?: number;
  30865. }): VertexData;
  30866. /**
  30867. * Creates the VertexData for a Ground
  30868. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  30869. * - width the width (x direction) of the ground, optional, default 1
  30870. * - height the height (z direction) of the ground, optional, default 1
  30871. * - subdivisions the number of subdivisions per side, optional, default 1
  30872. * @returns the VertexData of the Ground
  30873. */
  30874. static CreateGround(options: {
  30875. width?: number;
  30876. height?: number;
  30877. subdivisions?: number;
  30878. subdivisionsX?: number;
  30879. subdivisionsY?: number;
  30880. }): VertexData;
  30881. /**
  30882. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  30883. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  30884. * * xmin the ground minimum X coordinate, optional, default -1
  30885. * * zmin the ground minimum Z coordinate, optional, default -1
  30886. * * xmax the ground maximum X coordinate, optional, default 1
  30887. * * zmax the ground maximum Z coordinate, optional, default 1
  30888. * * 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}
  30889. * * 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}
  30890. * @returns the VertexData of the TiledGround
  30891. */
  30892. static CreateTiledGround(options: {
  30893. xmin: number;
  30894. zmin: number;
  30895. xmax: number;
  30896. zmax: number;
  30897. subdivisions?: {
  30898. w: number;
  30899. h: number;
  30900. };
  30901. precision?: {
  30902. w: number;
  30903. h: number;
  30904. };
  30905. }): VertexData;
  30906. /**
  30907. * Creates the VertexData of the Ground designed from a heightmap
  30908. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  30909. * * width the width (x direction) of the ground
  30910. * * height the height (z direction) of the ground
  30911. * * subdivisions the number of subdivisions per side
  30912. * * minHeight the minimum altitude on the ground, optional, default 0
  30913. * * maxHeight the maximum altitude on the ground, optional default 1
  30914. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  30915. * * buffer the array holding the image color data
  30916. * * bufferWidth the width of image
  30917. * * bufferHeight the height of image
  30918. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  30919. * @returns the VertexData of the Ground designed from a heightmap
  30920. */
  30921. static CreateGroundFromHeightMap(options: {
  30922. width: number;
  30923. height: number;
  30924. subdivisions: number;
  30925. minHeight: number;
  30926. maxHeight: number;
  30927. colorFilter: Color3;
  30928. buffer: Uint8Array;
  30929. bufferWidth: number;
  30930. bufferHeight: number;
  30931. alphaFilter: number;
  30932. }): VertexData;
  30933. /**
  30934. * Creates the VertexData for a Plane
  30935. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  30936. * * size sets the width and height of the plane to the value of size, optional default 1
  30937. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  30938. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  30939. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30940. * * 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)
  30941. * * 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)
  30942. * @returns the VertexData of the box
  30943. */
  30944. static CreatePlane(options: {
  30945. size?: number;
  30946. width?: number;
  30947. height?: number;
  30948. sideOrientation?: number;
  30949. frontUVs?: Vector4;
  30950. backUVs?: Vector4;
  30951. }): VertexData;
  30952. /**
  30953. * Creates the VertexData of the Disc or regular Polygon
  30954. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  30955. * * radius the radius of the disc, optional default 0.5
  30956. * * tessellation the number of polygon sides, optional, default 64
  30957. * * 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
  30958. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30959. * * 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)
  30960. * * 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)
  30961. * @returns the VertexData of the box
  30962. */
  30963. static CreateDisc(options: {
  30964. radius?: number;
  30965. tessellation?: number;
  30966. arc?: number;
  30967. sideOrientation?: number;
  30968. frontUVs?: Vector4;
  30969. backUVs?: Vector4;
  30970. }): VertexData;
  30971. /**
  30972. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  30973. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  30974. * @param polygon a mesh built from polygonTriangulation.build()
  30975. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30976. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  30977. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  30978. * @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)
  30979. * @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)
  30980. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  30981. * @returns the VertexData of the Polygon
  30982. */
  30983. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  30984. /**
  30985. * Creates the VertexData of the IcoSphere
  30986. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  30987. * * radius the radius of the IcoSphere, optional default 1
  30988. * * radiusX allows stretching in the x direction, optional, default radius
  30989. * * radiusY allows stretching in the y direction, optional, default radius
  30990. * * radiusZ allows stretching in the z direction, optional, default radius
  30991. * * flat when true creates a flat shaded mesh, optional, default true
  30992. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  30993. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30994. * * 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)
  30995. * * 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)
  30996. * @returns the VertexData of the IcoSphere
  30997. */
  30998. static CreateIcoSphere(options: {
  30999. radius?: number;
  31000. radiusX?: number;
  31001. radiusY?: number;
  31002. radiusZ?: number;
  31003. flat?: boolean;
  31004. subdivisions?: number;
  31005. sideOrientation?: number;
  31006. frontUVs?: Vector4;
  31007. backUVs?: Vector4;
  31008. }): VertexData;
  31009. /**
  31010. * Creates the VertexData for a Polyhedron
  31011. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  31012. * * type provided types are:
  31013. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  31014. * * 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)
  31015. * * size the size of the IcoSphere, optional default 1
  31016. * * sizeX allows stretching in the x direction, optional, default size
  31017. * * sizeY allows stretching in the y direction, optional, default size
  31018. * * sizeZ allows stretching in the z direction, optional, default size
  31019. * * 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
  31020. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  31021. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  31022. * * flat when true creates a flat shaded mesh, optional, default true
  31023. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  31024. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31025. * * 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)
  31026. * * 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)
  31027. * @returns the VertexData of the Polyhedron
  31028. */
  31029. static CreatePolyhedron(options: {
  31030. type?: number;
  31031. size?: number;
  31032. sizeX?: number;
  31033. sizeY?: number;
  31034. sizeZ?: number;
  31035. custom?: any;
  31036. faceUV?: Vector4[];
  31037. faceColors?: Color4[];
  31038. flat?: boolean;
  31039. sideOrientation?: number;
  31040. frontUVs?: Vector4;
  31041. backUVs?: Vector4;
  31042. }): VertexData;
  31043. /**
  31044. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  31045. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  31046. * @returns the VertexData of the Capsule
  31047. */
  31048. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  31049. /**
  31050. * Creates the VertexData for a TorusKnot
  31051. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  31052. * * radius the radius of the torus knot, optional, default 2
  31053. * * tube the thickness of the tube, optional, default 0.5
  31054. * * radialSegments the number of sides on each tube segments, optional, default 32
  31055. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  31056. * * p the number of windings around the z axis, optional, default 2
  31057. * * q the number of windings around the x axis, optional, default 3
  31058. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31059. * * 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)
  31060. * * 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)
  31061. * @returns the VertexData of the Torus Knot
  31062. */
  31063. static CreateTorusKnot(options: {
  31064. radius?: number;
  31065. tube?: number;
  31066. radialSegments?: number;
  31067. tubularSegments?: number;
  31068. p?: number;
  31069. q?: number;
  31070. sideOrientation?: number;
  31071. frontUVs?: Vector4;
  31072. backUVs?: Vector4;
  31073. }): VertexData;
  31074. /**
  31075. * Compute normals for given positions and indices
  31076. * @param positions an array of vertex positions, [...., x, y, z, ......]
  31077. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  31078. * @param normals an array of vertex normals, [...., x, y, z, ......]
  31079. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  31080. * * facetNormals : optional array of facet normals (vector3)
  31081. * * facetPositions : optional array of facet positions (vector3)
  31082. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  31083. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  31084. * * bInfo : optional bounding info, required for facetPartitioning computation
  31085. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  31086. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  31087. * * useRightHandedSystem: optional boolean to for right handed system computation
  31088. * * depthSort : optional boolean to enable the facet depth sort computation
  31089. * * distanceTo : optional Vector3 to compute the facet depth from this location
  31090. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  31091. */
  31092. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  31093. facetNormals?: any;
  31094. facetPositions?: any;
  31095. facetPartitioning?: any;
  31096. ratio?: number;
  31097. bInfo?: any;
  31098. bbSize?: Vector3;
  31099. subDiv?: any;
  31100. useRightHandedSystem?: boolean;
  31101. depthSort?: boolean;
  31102. distanceTo?: Vector3;
  31103. depthSortedFacets?: any;
  31104. }): void;
  31105. /** @hidden */
  31106. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  31107. /**
  31108. * Applies VertexData created from the imported parameters to the geometry
  31109. * @param parsedVertexData the parsed data from an imported file
  31110. * @param geometry the geometry to apply the VertexData to
  31111. */
  31112. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  31113. }
  31114. }
  31115. declare module BABYLON {
  31116. /**
  31117. * Defines a target to use with MorphTargetManager
  31118. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31119. */
  31120. export class MorphTarget implements IAnimatable {
  31121. /** defines the name of the target */
  31122. name: string;
  31123. /**
  31124. * Gets or sets the list of animations
  31125. */
  31126. animations: Animation[];
  31127. private _scene;
  31128. private _positions;
  31129. private _normals;
  31130. private _tangents;
  31131. private _uvs;
  31132. private _influence;
  31133. private _uniqueId;
  31134. /**
  31135. * Observable raised when the influence changes
  31136. */
  31137. onInfluenceChanged: Observable<boolean>;
  31138. /** @hidden */
  31139. _onDataLayoutChanged: Observable<void>;
  31140. /**
  31141. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  31142. */
  31143. get influence(): number;
  31144. set influence(influence: number);
  31145. /**
  31146. * Gets or sets the id of the morph Target
  31147. */
  31148. id: string;
  31149. private _animationPropertiesOverride;
  31150. /**
  31151. * Gets or sets the animation properties override
  31152. */
  31153. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  31154. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  31155. /**
  31156. * Creates a new MorphTarget
  31157. * @param name defines the name of the target
  31158. * @param influence defines the influence to use
  31159. * @param scene defines the scene the morphtarget belongs to
  31160. */
  31161. constructor(
  31162. /** defines the name of the target */
  31163. name: string, influence?: number, scene?: Nullable<Scene>);
  31164. /**
  31165. * Gets the unique ID of this manager
  31166. */
  31167. get uniqueId(): number;
  31168. /**
  31169. * Gets a boolean defining if the target contains position data
  31170. */
  31171. get hasPositions(): boolean;
  31172. /**
  31173. * Gets a boolean defining if the target contains normal data
  31174. */
  31175. get hasNormals(): boolean;
  31176. /**
  31177. * Gets a boolean defining if the target contains tangent data
  31178. */
  31179. get hasTangents(): boolean;
  31180. /**
  31181. * Gets a boolean defining if the target contains texture coordinates data
  31182. */
  31183. get hasUVs(): boolean;
  31184. /**
  31185. * Affects position data to this target
  31186. * @param data defines the position data to use
  31187. */
  31188. setPositions(data: Nullable<FloatArray>): void;
  31189. /**
  31190. * Gets the position data stored in this target
  31191. * @returns a FloatArray containing the position data (or null if not present)
  31192. */
  31193. getPositions(): Nullable<FloatArray>;
  31194. /**
  31195. * Affects normal data to this target
  31196. * @param data defines the normal data to use
  31197. */
  31198. setNormals(data: Nullable<FloatArray>): void;
  31199. /**
  31200. * Gets the normal data stored in this target
  31201. * @returns a FloatArray containing the normal data (or null if not present)
  31202. */
  31203. getNormals(): Nullable<FloatArray>;
  31204. /**
  31205. * Affects tangent data to this target
  31206. * @param data defines the tangent data to use
  31207. */
  31208. setTangents(data: Nullable<FloatArray>): void;
  31209. /**
  31210. * Gets the tangent data stored in this target
  31211. * @returns a FloatArray containing the tangent data (or null if not present)
  31212. */
  31213. getTangents(): Nullable<FloatArray>;
  31214. /**
  31215. * Affects texture coordinates data to this target
  31216. * @param data defines the texture coordinates data to use
  31217. */
  31218. setUVs(data: Nullable<FloatArray>): void;
  31219. /**
  31220. * Gets the texture coordinates data stored in this target
  31221. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  31222. */
  31223. getUVs(): Nullable<FloatArray>;
  31224. /**
  31225. * Clone the current target
  31226. * @returns a new MorphTarget
  31227. */
  31228. clone(): MorphTarget;
  31229. /**
  31230. * Serializes the current target into a Serialization object
  31231. * @returns the serialized object
  31232. */
  31233. serialize(): any;
  31234. /**
  31235. * Returns the string "MorphTarget"
  31236. * @returns "MorphTarget"
  31237. */
  31238. getClassName(): string;
  31239. /**
  31240. * Creates a new target from serialized data
  31241. * @param serializationObject defines the serialized data to use
  31242. * @returns a new MorphTarget
  31243. */
  31244. static Parse(serializationObject: any): MorphTarget;
  31245. /**
  31246. * Creates a MorphTarget from mesh data
  31247. * @param mesh defines the source mesh
  31248. * @param name defines the name to use for the new target
  31249. * @param influence defines the influence to attach to the target
  31250. * @returns a new MorphTarget
  31251. */
  31252. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  31253. }
  31254. }
  31255. declare module BABYLON {
  31256. /**
  31257. * This class is used to deform meshes using morphing between different targets
  31258. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31259. */
  31260. export class MorphTargetManager {
  31261. private _targets;
  31262. private _targetInfluenceChangedObservers;
  31263. private _targetDataLayoutChangedObservers;
  31264. private _activeTargets;
  31265. private _scene;
  31266. private _influences;
  31267. private _supportsNormals;
  31268. private _supportsTangents;
  31269. private _supportsUVs;
  31270. private _vertexCount;
  31271. private _uniqueId;
  31272. private _tempInfluences;
  31273. /**
  31274. * Gets or sets a boolean indicating if normals must be morphed
  31275. */
  31276. enableNormalMorphing: boolean;
  31277. /**
  31278. * Gets or sets a boolean indicating if tangents must be morphed
  31279. */
  31280. enableTangentMorphing: boolean;
  31281. /**
  31282. * Gets or sets a boolean indicating if UV must be morphed
  31283. */
  31284. enableUVMorphing: boolean;
  31285. /**
  31286. * Creates a new MorphTargetManager
  31287. * @param scene defines the current scene
  31288. */
  31289. constructor(scene?: Nullable<Scene>);
  31290. /**
  31291. * Gets the unique ID of this manager
  31292. */
  31293. get uniqueId(): number;
  31294. /**
  31295. * Gets the number of vertices handled by this manager
  31296. */
  31297. get vertexCount(): number;
  31298. /**
  31299. * Gets a boolean indicating if this manager supports morphing of normals
  31300. */
  31301. get supportsNormals(): boolean;
  31302. /**
  31303. * Gets a boolean indicating if this manager supports morphing of tangents
  31304. */
  31305. get supportsTangents(): boolean;
  31306. /**
  31307. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  31308. */
  31309. get supportsUVs(): boolean;
  31310. /**
  31311. * Gets the number of targets stored in this manager
  31312. */
  31313. get numTargets(): number;
  31314. /**
  31315. * Gets the number of influencers (ie. the number of targets with influences > 0)
  31316. */
  31317. get numInfluencers(): number;
  31318. /**
  31319. * Gets the list of influences (one per target)
  31320. */
  31321. get influences(): Float32Array;
  31322. /**
  31323. * Gets the active target at specified index. An active target is a target with an influence > 0
  31324. * @param index defines the index to check
  31325. * @returns the requested target
  31326. */
  31327. getActiveTarget(index: number): MorphTarget;
  31328. /**
  31329. * Gets the target at specified index
  31330. * @param index defines the index to check
  31331. * @returns the requested target
  31332. */
  31333. getTarget(index: number): MorphTarget;
  31334. /**
  31335. * Add a new target to this manager
  31336. * @param target defines the target to add
  31337. */
  31338. addTarget(target: MorphTarget): void;
  31339. /**
  31340. * Removes a target from the manager
  31341. * @param target defines the target to remove
  31342. */
  31343. removeTarget(target: MorphTarget): void;
  31344. /**
  31345. * Clone the current manager
  31346. * @returns a new MorphTargetManager
  31347. */
  31348. clone(): MorphTargetManager;
  31349. /**
  31350. * Serializes the current manager into a Serialization object
  31351. * @returns the serialized object
  31352. */
  31353. serialize(): any;
  31354. private _syncActiveTargets;
  31355. /**
  31356. * Syncrhonize the targets with all the meshes using this morph target manager
  31357. */
  31358. synchronize(): void;
  31359. /**
  31360. * Creates a new MorphTargetManager from serialized data
  31361. * @param serializationObject defines the serialized data
  31362. * @param scene defines the hosting scene
  31363. * @returns the new MorphTargetManager
  31364. */
  31365. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  31366. }
  31367. }
  31368. declare module BABYLON {
  31369. /**
  31370. * Class used to represent a specific level of detail of a mesh
  31371. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  31372. */
  31373. export class MeshLODLevel {
  31374. /** Defines the distance where this level should start being displayed */
  31375. distance: number;
  31376. /** Defines the mesh to use to render this level */
  31377. mesh: Nullable<Mesh>;
  31378. /**
  31379. * Creates a new LOD level
  31380. * @param distance defines the distance where this level should star being displayed
  31381. * @param mesh defines the mesh to use to render this level
  31382. */
  31383. constructor(
  31384. /** Defines the distance where this level should start being displayed */
  31385. distance: number,
  31386. /** Defines the mesh to use to render this level */
  31387. mesh: Nullable<Mesh>);
  31388. }
  31389. }
  31390. declare module BABYLON {
  31391. /**
  31392. * Helper class used to generate a canvas to manipulate images
  31393. */
  31394. export class CanvasGenerator {
  31395. /**
  31396. * Create a new canvas (or offscreen canvas depending on the context)
  31397. * @param width defines the expected width
  31398. * @param height defines the expected height
  31399. * @return a new canvas or offscreen canvas
  31400. */
  31401. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  31402. }
  31403. }
  31404. declare module BABYLON {
  31405. /**
  31406. * Mesh representing the gorund
  31407. */
  31408. export class GroundMesh extends Mesh {
  31409. /** If octree should be generated */
  31410. generateOctree: boolean;
  31411. private _heightQuads;
  31412. /** @hidden */
  31413. _subdivisionsX: number;
  31414. /** @hidden */
  31415. _subdivisionsY: number;
  31416. /** @hidden */
  31417. _width: number;
  31418. /** @hidden */
  31419. _height: number;
  31420. /** @hidden */
  31421. _minX: number;
  31422. /** @hidden */
  31423. _maxX: number;
  31424. /** @hidden */
  31425. _minZ: number;
  31426. /** @hidden */
  31427. _maxZ: number;
  31428. constructor(name: string, scene: Scene);
  31429. /**
  31430. * "GroundMesh"
  31431. * @returns "GroundMesh"
  31432. */
  31433. getClassName(): string;
  31434. /**
  31435. * The minimum of x and y subdivisions
  31436. */
  31437. get subdivisions(): number;
  31438. /**
  31439. * X subdivisions
  31440. */
  31441. get subdivisionsX(): number;
  31442. /**
  31443. * Y subdivisions
  31444. */
  31445. get subdivisionsY(): number;
  31446. /**
  31447. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  31448. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  31449. * @param chunksCount the number of subdivisions for x and y
  31450. * @param octreeBlocksSize (Default: 32)
  31451. */
  31452. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  31453. /**
  31454. * Returns a height (y) value in the Worl system :
  31455. * the ground altitude at the coordinates (x, z) expressed in the World system.
  31456. * @param x x coordinate
  31457. * @param z z coordinate
  31458. * @returns the ground y position if (x, z) are outside the ground surface.
  31459. */
  31460. getHeightAtCoordinates(x: number, z: number): number;
  31461. /**
  31462. * Returns a normalized vector (Vector3) orthogonal to the ground
  31463. * at the ground coordinates (x, z) expressed in the World system.
  31464. * @param x x coordinate
  31465. * @param z z coordinate
  31466. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  31467. */
  31468. getNormalAtCoordinates(x: number, z: number): Vector3;
  31469. /**
  31470. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  31471. * at the ground coordinates (x, z) expressed in the World system.
  31472. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  31473. * @param x x coordinate
  31474. * @param z z coordinate
  31475. * @param ref vector to store the result
  31476. * @returns the GroundMesh.
  31477. */
  31478. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  31479. /**
  31480. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  31481. * if the ground has been updated.
  31482. * This can be used in the render loop.
  31483. * @returns the GroundMesh.
  31484. */
  31485. updateCoordinateHeights(): GroundMesh;
  31486. private _getFacetAt;
  31487. private _initHeightQuads;
  31488. private _computeHeightQuads;
  31489. /**
  31490. * Serializes this ground mesh
  31491. * @param serializationObject object to write serialization to
  31492. */
  31493. serialize(serializationObject: any): void;
  31494. /**
  31495. * Parses a serialized ground mesh
  31496. * @param parsedMesh the serialized mesh
  31497. * @param scene the scene to create the ground mesh in
  31498. * @returns the created ground mesh
  31499. */
  31500. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  31501. }
  31502. }
  31503. declare module BABYLON {
  31504. /**
  31505. * Interface for Physics-Joint data
  31506. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31507. */
  31508. export interface PhysicsJointData {
  31509. /**
  31510. * The main pivot of the joint
  31511. */
  31512. mainPivot?: Vector3;
  31513. /**
  31514. * The connected pivot of the joint
  31515. */
  31516. connectedPivot?: Vector3;
  31517. /**
  31518. * The main axis of the joint
  31519. */
  31520. mainAxis?: Vector3;
  31521. /**
  31522. * The connected axis of the joint
  31523. */
  31524. connectedAxis?: Vector3;
  31525. /**
  31526. * The collision of the joint
  31527. */
  31528. collision?: boolean;
  31529. /**
  31530. * Native Oimo/Cannon/Energy data
  31531. */
  31532. nativeParams?: any;
  31533. }
  31534. /**
  31535. * This is a holder class for the physics joint created by the physics plugin
  31536. * It holds a set of functions to control the underlying joint
  31537. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31538. */
  31539. export class PhysicsJoint {
  31540. /**
  31541. * The type of the physics joint
  31542. */
  31543. type: number;
  31544. /**
  31545. * The data for the physics joint
  31546. */
  31547. jointData: PhysicsJointData;
  31548. private _physicsJoint;
  31549. protected _physicsPlugin: IPhysicsEnginePlugin;
  31550. /**
  31551. * Initializes the physics joint
  31552. * @param type The type of the physics joint
  31553. * @param jointData The data for the physics joint
  31554. */
  31555. constructor(
  31556. /**
  31557. * The type of the physics joint
  31558. */
  31559. type: number,
  31560. /**
  31561. * The data for the physics joint
  31562. */
  31563. jointData: PhysicsJointData);
  31564. /**
  31565. * Gets the physics joint
  31566. */
  31567. get physicsJoint(): any;
  31568. /**
  31569. * Sets the physics joint
  31570. */
  31571. set physicsJoint(newJoint: any);
  31572. /**
  31573. * Sets the physics plugin
  31574. */
  31575. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  31576. /**
  31577. * Execute a function that is physics-plugin specific.
  31578. * @param {Function} func the function that will be executed.
  31579. * It accepts two parameters: the physics world and the physics joint
  31580. */
  31581. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  31582. /**
  31583. * Distance-Joint type
  31584. */
  31585. static DistanceJoint: number;
  31586. /**
  31587. * Hinge-Joint type
  31588. */
  31589. static HingeJoint: number;
  31590. /**
  31591. * Ball-and-Socket joint type
  31592. */
  31593. static BallAndSocketJoint: number;
  31594. /**
  31595. * Wheel-Joint type
  31596. */
  31597. static WheelJoint: number;
  31598. /**
  31599. * Slider-Joint type
  31600. */
  31601. static SliderJoint: number;
  31602. /**
  31603. * Prismatic-Joint type
  31604. */
  31605. static PrismaticJoint: number;
  31606. /**
  31607. * Universal-Joint type
  31608. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  31609. */
  31610. static UniversalJoint: number;
  31611. /**
  31612. * Hinge-Joint 2 type
  31613. */
  31614. static Hinge2Joint: number;
  31615. /**
  31616. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  31617. */
  31618. static PointToPointJoint: number;
  31619. /**
  31620. * Spring-Joint type
  31621. */
  31622. static SpringJoint: number;
  31623. /**
  31624. * Lock-Joint type
  31625. */
  31626. static LockJoint: number;
  31627. }
  31628. /**
  31629. * A class representing a physics distance joint
  31630. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31631. */
  31632. export class DistanceJoint extends PhysicsJoint {
  31633. /**
  31634. *
  31635. * @param jointData The data for the Distance-Joint
  31636. */
  31637. constructor(jointData: DistanceJointData);
  31638. /**
  31639. * Update the predefined distance.
  31640. * @param maxDistance The maximum preferred distance
  31641. * @param minDistance The minimum preferred distance
  31642. */
  31643. updateDistance(maxDistance: number, minDistance?: number): void;
  31644. }
  31645. /**
  31646. * Represents a Motor-Enabled Joint
  31647. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31648. */
  31649. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  31650. /**
  31651. * Initializes the Motor-Enabled Joint
  31652. * @param type The type of the joint
  31653. * @param jointData The physica joint data for the joint
  31654. */
  31655. constructor(type: number, jointData: PhysicsJointData);
  31656. /**
  31657. * Set the motor values.
  31658. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31659. * @param force the force to apply
  31660. * @param maxForce max force for this motor.
  31661. */
  31662. setMotor(force?: number, maxForce?: number): void;
  31663. /**
  31664. * Set the motor's limits.
  31665. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31666. * @param upperLimit The upper limit of the motor
  31667. * @param lowerLimit The lower limit of the motor
  31668. */
  31669. setLimit(upperLimit: number, lowerLimit?: number): void;
  31670. }
  31671. /**
  31672. * This class represents a single physics Hinge-Joint
  31673. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31674. */
  31675. export class HingeJoint extends MotorEnabledJoint {
  31676. /**
  31677. * Initializes the Hinge-Joint
  31678. * @param jointData The joint data for the Hinge-Joint
  31679. */
  31680. constructor(jointData: PhysicsJointData);
  31681. /**
  31682. * Set the motor values.
  31683. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31684. * @param {number} force the force to apply
  31685. * @param {number} maxForce max force for this motor.
  31686. */
  31687. setMotor(force?: number, maxForce?: number): void;
  31688. /**
  31689. * Set the motor's limits.
  31690. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31691. * @param upperLimit The upper limit of the motor
  31692. * @param lowerLimit The lower limit of the motor
  31693. */
  31694. setLimit(upperLimit: number, lowerLimit?: number): void;
  31695. }
  31696. /**
  31697. * This class represents a dual hinge physics joint (same as wheel joint)
  31698. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31699. */
  31700. export class Hinge2Joint extends MotorEnabledJoint {
  31701. /**
  31702. * Initializes the Hinge2-Joint
  31703. * @param jointData The joint data for the Hinge2-Joint
  31704. */
  31705. constructor(jointData: PhysicsJointData);
  31706. /**
  31707. * Set the motor values.
  31708. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31709. * @param {number} targetSpeed the speed the motor is to reach
  31710. * @param {number} maxForce max force for this motor.
  31711. * @param {motorIndex} the motor's index, 0 or 1.
  31712. */
  31713. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  31714. /**
  31715. * Set the motor limits.
  31716. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31717. * @param {number} upperLimit the upper limit
  31718. * @param {number} lowerLimit lower limit
  31719. * @param {motorIndex} the motor's index, 0 or 1.
  31720. */
  31721. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31722. }
  31723. /**
  31724. * Interface for a motor enabled joint
  31725. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31726. */
  31727. export interface IMotorEnabledJoint {
  31728. /**
  31729. * Physics joint
  31730. */
  31731. physicsJoint: any;
  31732. /**
  31733. * Sets the motor of the motor-enabled joint
  31734. * @param force The force of the motor
  31735. * @param maxForce The maximum force of the motor
  31736. * @param motorIndex The index of the motor
  31737. */
  31738. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  31739. /**
  31740. * Sets the limit of the motor
  31741. * @param upperLimit The upper limit of the motor
  31742. * @param lowerLimit The lower limit of the motor
  31743. * @param motorIndex The index of the motor
  31744. */
  31745. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31746. }
  31747. /**
  31748. * Joint data for a Distance-Joint
  31749. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31750. */
  31751. export interface DistanceJointData extends PhysicsJointData {
  31752. /**
  31753. * Max distance the 2 joint objects can be apart
  31754. */
  31755. maxDistance: number;
  31756. }
  31757. /**
  31758. * Joint data from a spring joint
  31759. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31760. */
  31761. export interface SpringJointData extends PhysicsJointData {
  31762. /**
  31763. * Length of the spring
  31764. */
  31765. length: number;
  31766. /**
  31767. * Stiffness of the spring
  31768. */
  31769. stiffness: number;
  31770. /**
  31771. * Damping of the spring
  31772. */
  31773. damping: number;
  31774. /** this callback will be called when applying the force to the impostors. */
  31775. forceApplicationCallback: () => void;
  31776. }
  31777. }
  31778. declare module BABYLON {
  31779. /**
  31780. * Holds the data for the raycast result
  31781. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31782. */
  31783. export class PhysicsRaycastResult {
  31784. private _hasHit;
  31785. private _hitDistance;
  31786. private _hitNormalWorld;
  31787. private _hitPointWorld;
  31788. private _rayFromWorld;
  31789. private _rayToWorld;
  31790. /**
  31791. * Gets if there was a hit
  31792. */
  31793. get hasHit(): boolean;
  31794. /**
  31795. * Gets the distance from the hit
  31796. */
  31797. get hitDistance(): number;
  31798. /**
  31799. * Gets the hit normal/direction in the world
  31800. */
  31801. get hitNormalWorld(): Vector3;
  31802. /**
  31803. * Gets the hit point in the world
  31804. */
  31805. get hitPointWorld(): Vector3;
  31806. /**
  31807. * Gets the ray "start point" of the ray in the world
  31808. */
  31809. get rayFromWorld(): Vector3;
  31810. /**
  31811. * Gets the ray "end point" of the ray in the world
  31812. */
  31813. get rayToWorld(): Vector3;
  31814. /**
  31815. * Sets the hit data (normal & point in world space)
  31816. * @param hitNormalWorld defines the normal in world space
  31817. * @param hitPointWorld defines the point in world space
  31818. */
  31819. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  31820. /**
  31821. * Sets the distance from the start point to the hit point
  31822. * @param distance
  31823. */
  31824. setHitDistance(distance: number): void;
  31825. /**
  31826. * Calculates the distance manually
  31827. */
  31828. calculateHitDistance(): void;
  31829. /**
  31830. * Resets all the values to default
  31831. * @param from The from point on world space
  31832. * @param to The to point on world space
  31833. */
  31834. reset(from?: Vector3, to?: Vector3): void;
  31835. }
  31836. /**
  31837. * Interface for the size containing width and height
  31838. */
  31839. interface IXYZ {
  31840. /**
  31841. * X
  31842. */
  31843. x: number;
  31844. /**
  31845. * Y
  31846. */
  31847. y: number;
  31848. /**
  31849. * Z
  31850. */
  31851. z: number;
  31852. }
  31853. }
  31854. declare module BABYLON {
  31855. /**
  31856. * Interface used to describe a physics joint
  31857. */
  31858. export interface PhysicsImpostorJoint {
  31859. /** Defines the main impostor to which the joint is linked */
  31860. mainImpostor: PhysicsImpostor;
  31861. /** Defines the impostor that is connected to the main impostor using this joint */
  31862. connectedImpostor: PhysicsImpostor;
  31863. /** Defines the joint itself */
  31864. joint: PhysicsJoint;
  31865. }
  31866. /** @hidden */
  31867. export interface IPhysicsEnginePlugin {
  31868. world: any;
  31869. name: string;
  31870. setGravity(gravity: Vector3): void;
  31871. setTimeStep(timeStep: number): void;
  31872. getTimeStep(): number;
  31873. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  31874. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31875. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31876. generatePhysicsBody(impostor: PhysicsImpostor): void;
  31877. removePhysicsBody(impostor: PhysicsImpostor): void;
  31878. generateJoint(joint: PhysicsImpostorJoint): void;
  31879. removeJoint(joint: PhysicsImpostorJoint): void;
  31880. isSupported(): boolean;
  31881. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  31882. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  31883. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31884. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31885. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31886. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31887. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  31888. getBodyMass(impostor: PhysicsImpostor): number;
  31889. getBodyFriction(impostor: PhysicsImpostor): number;
  31890. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  31891. getBodyRestitution(impostor: PhysicsImpostor): number;
  31892. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  31893. getBodyPressure?(impostor: PhysicsImpostor): number;
  31894. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  31895. getBodyStiffness?(impostor: PhysicsImpostor): number;
  31896. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  31897. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  31898. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  31899. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  31900. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  31901. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  31902. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  31903. sleepBody(impostor: PhysicsImpostor): void;
  31904. wakeUpBody(impostor: PhysicsImpostor): void;
  31905. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  31906. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  31907. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  31908. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31909. getRadius(impostor: PhysicsImpostor): number;
  31910. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  31911. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  31912. dispose(): void;
  31913. }
  31914. /**
  31915. * Interface used to define a physics engine
  31916. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31917. */
  31918. export interface IPhysicsEngine {
  31919. /**
  31920. * Gets the gravity vector used by the simulation
  31921. */
  31922. gravity: Vector3;
  31923. /**
  31924. * Sets the gravity vector used by the simulation
  31925. * @param gravity defines the gravity vector to use
  31926. */
  31927. setGravity(gravity: Vector3): void;
  31928. /**
  31929. * Set the time step of the physics engine.
  31930. * Default is 1/60.
  31931. * To slow it down, enter 1/600 for example.
  31932. * To speed it up, 1/30
  31933. * @param newTimeStep the new timestep to apply to this world.
  31934. */
  31935. setTimeStep(newTimeStep: number): void;
  31936. /**
  31937. * Get the time step of the physics engine.
  31938. * @returns the current time step
  31939. */
  31940. getTimeStep(): number;
  31941. /**
  31942. * Set the sub time step of the physics engine.
  31943. * Default is 0 meaning there is no sub steps
  31944. * To increase physics resolution precision, set a small value (like 1 ms)
  31945. * @param subTimeStep defines the new sub timestep used for physics resolution.
  31946. */
  31947. setSubTimeStep(subTimeStep: number): void;
  31948. /**
  31949. * Get the sub time step of the physics engine.
  31950. * @returns the current sub time step
  31951. */
  31952. getSubTimeStep(): number;
  31953. /**
  31954. * Release all resources
  31955. */
  31956. dispose(): void;
  31957. /**
  31958. * Gets the name of the current physics plugin
  31959. * @returns the name of the plugin
  31960. */
  31961. getPhysicsPluginName(): string;
  31962. /**
  31963. * Adding a new impostor for the impostor tracking.
  31964. * This will be done by the impostor itself.
  31965. * @param impostor the impostor to add
  31966. */
  31967. addImpostor(impostor: PhysicsImpostor): void;
  31968. /**
  31969. * Remove an impostor from the engine.
  31970. * This impostor and its mesh will not longer be updated by the physics engine.
  31971. * @param impostor the impostor to remove
  31972. */
  31973. removeImpostor(impostor: PhysicsImpostor): void;
  31974. /**
  31975. * Add a joint to the physics engine
  31976. * @param mainImpostor defines the main impostor to which the joint is added.
  31977. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  31978. * @param joint defines the joint that will connect both impostors.
  31979. */
  31980. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  31981. /**
  31982. * Removes a joint from the simulation
  31983. * @param mainImpostor defines the impostor used with the joint
  31984. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  31985. * @param joint defines the joint to remove
  31986. */
  31987. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  31988. /**
  31989. * Gets the current plugin used to run the simulation
  31990. * @returns current plugin
  31991. */
  31992. getPhysicsPlugin(): IPhysicsEnginePlugin;
  31993. /**
  31994. * Gets the list of physic impostors
  31995. * @returns an array of PhysicsImpostor
  31996. */
  31997. getImpostors(): Array<PhysicsImpostor>;
  31998. /**
  31999. * Gets the impostor for a physics enabled object
  32000. * @param object defines the object impersonated by the impostor
  32001. * @returns the PhysicsImpostor or null if not found
  32002. */
  32003. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32004. /**
  32005. * Gets the impostor for a physics body object
  32006. * @param body defines physics body used by the impostor
  32007. * @returns the PhysicsImpostor or null if not found
  32008. */
  32009. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32010. /**
  32011. * Does a raycast in the physics world
  32012. * @param from when should the ray start?
  32013. * @param to when should the ray end?
  32014. * @returns PhysicsRaycastResult
  32015. */
  32016. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32017. /**
  32018. * Called by the scene. No need to call it.
  32019. * @param delta defines the timespam between frames
  32020. */
  32021. _step(delta: number): void;
  32022. }
  32023. }
  32024. declare module BABYLON {
  32025. /**
  32026. * The interface for the physics imposter parameters
  32027. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32028. */
  32029. export interface PhysicsImpostorParameters {
  32030. /**
  32031. * The mass of the physics imposter
  32032. */
  32033. mass: number;
  32034. /**
  32035. * The friction of the physics imposter
  32036. */
  32037. friction?: number;
  32038. /**
  32039. * The coefficient of restitution of the physics imposter
  32040. */
  32041. restitution?: number;
  32042. /**
  32043. * The native options of the physics imposter
  32044. */
  32045. nativeOptions?: any;
  32046. /**
  32047. * Specifies if the parent should be ignored
  32048. */
  32049. ignoreParent?: boolean;
  32050. /**
  32051. * Specifies if bi-directional transformations should be disabled
  32052. */
  32053. disableBidirectionalTransformation?: boolean;
  32054. /**
  32055. * The pressure inside the physics imposter, soft object only
  32056. */
  32057. pressure?: number;
  32058. /**
  32059. * The stiffness the physics imposter, soft object only
  32060. */
  32061. stiffness?: number;
  32062. /**
  32063. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  32064. */
  32065. velocityIterations?: number;
  32066. /**
  32067. * The number of iterations used in maintaining consistent vertex positions, soft object only
  32068. */
  32069. positionIterations?: number;
  32070. /**
  32071. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  32072. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  32073. * Add to fix multiple points
  32074. */
  32075. fixedPoints?: number;
  32076. /**
  32077. * The collision margin around a soft object
  32078. */
  32079. margin?: number;
  32080. /**
  32081. * The collision margin around a soft object
  32082. */
  32083. damping?: number;
  32084. /**
  32085. * The path for a rope based on an extrusion
  32086. */
  32087. path?: any;
  32088. /**
  32089. * The shape of an extrusion used for a rope based on an extrusion
  32090. */
  32091. shape?: any;
  32092. }
  32093. /**
  32094. * Interface for a physics-enabled object
  32095. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32096. */
  32097. export interface IPhysicsEnabledObject {
  32098. /**
  32099. * The position of the physics-enabled object
  32100. */
  32101. position: Vector3;
  32102. /**
  32103. * The rotation of the physics-enabled object
  32104. */
  32105. rotationQuaternion: Nullable<Quaternion>;
  32106. /**
  32107. * The scale of the physics-enabled object
  32108. */
  32109. scaling: Vector3;
  32110. /**
  32111. * The rotation of the physics-enabled object
  32112. */
  32113. rotation?: Vector3;
  32114. /**
  32115. * The parent of the physics-enabled object
  32116. */
  32117. parent?: any;
  32118. /**
  32119. * The bounding info of the physics-enabled object
  32120. * @returns The bounding info of the physics-enabled object
  32121. */
  32122. getBoundingInfo(): BoundingInfo;
  32123. /**
  32124. * Computes the world matrix
  32125. * @param force Specifies if the world matrix should be computed by force
  32126. * @returns A world matrix
  32127. */
  32128. computeWorldMatrix(force: boolean): Matrix;
  32129. /**
  32130. * Gets the world matrix
  32131. * @returns A world matrix
  32132. */
  32133. getWorldMatrix?(): Matrix;
  32134. /**
  32135. * Gets the child meshes
  32136. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  32137. * @returns An array of abstract meshes
  32138. */
  32139. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  32140. /**
  32141. * Gets the vertex data
  32142. * @param kind The type of vertex data
  32143. * @returns A nullable array of numbers, or a float32 array
  32144. */
  32145. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  32146. /**
  32147. * Gets the indices from the mesh
  32148. * @returns A nullable array of index arrays
  32149. */
  32150. getIndices?(): Nullable<IndicesArray>;
  32151. /**
  32152. * Gets the scene from the mesh
  32153. * @returns the indices array or null
  32154. */
  32155. getScene?(): Scene;
  32156. /**
  32157. * Gets the absolute position from the mesh
  32158. * @returns the absolute position
  32159. */
  32160. getAbsolutePosition(): Vector3;
  32161. /**
  32162. * Gets the absolute pivot point from the mesh
  32163. * @returns the absolute pivot point
  32164. */
  32165. getAbsolutePivotPoint(): Vector3;
  32166. /**
  32167. * Rotates the mesh
  32168. * @param axis The axis of rotation
  32169. * @param amount The amount of rotation
  32170. * @param space The space of the rotation
  32171. * @returns The rotation transform node
  32172. */
  32173. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  32174. /**
  32175. * Translates the mesh
  32176. * @param axis The axis of translation
  32177. * @param distance The distance of translation
  32178. * @param space The space of the translation
  32179. * @returns The transform node
  32180. */
  32181. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  32182. /**
  32183. * Sets the absolute position of the mesh
  32184. * @param absolutePosition The absolute position of the mesh
  32185. * @returns The transform node
  32186. */
  32187. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  32188. /**
  32189. * Gets the class name of the mesh
  32190. * @returns The class name
  32191. */
  32192. getClassName(): string;
  32193. }
  32194. /**
  32195. * Represents a physics imposter
  32196. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32197. */
  32198. export class PhysicsImpostor {
  32199. /**
  32200. * The physics-enabled object used as the physics imposter
  32201. */
  32202. object: IPhysicsEnabledObject;
  32203. /**
  32204. * The type of the physics imposter
  32205. */
  32206. type: number;
  32207. private _options;
  32208. private _scene?;
  32209. /**
  32210. * The default object size of the imposter
  32211. */
  32212. static DEFAULT_OBJECT_SIZE: Vector3;
  32213. /**
  32214. * The identity quaternion of the imposter
  32215. */
  32216. static IDENTITY_QUATERNION: Quaternion;
  32217. /** @hidden */
  32218. _pluginData: any;
  32219. private _physicsEngine;
  32220. private _physicsBody;
  32221. private _bodyUpdateRequired;
  32222. private _onBeforePhysicsStepCallbacks;
  32223. private _onAfterPhysicsStepCallbacks;
  32224. /** @hidden */
  32225. _onPhysicsCollideCallbacks: Array<{
  32226. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  32227. otherImpostors: Array<PhysicsImpostor>;
  32228. }>;
  32229. private _deltaPosition;
  32230. private _deltaRotation;
  32231. private _deltaRotationConjugated;
  32232. /** @hidden */
  32233. _isFromLine: boolean;
  32234. private _parent;
  32235. private _isDisposed;
  32236. private static _tmpVecs;
  32237. private static _tmpQuat;
  32238. /**
  32239. * Specifies if the physics imposter is disposed
  32240. */
  32241. get isDisposed(): boolean;
  32242. /**
  32243. * Gets the mass of the physics imposter
  32244. */
  32245. get mass(): number;
  32246. set mass(value: number);
  32247. /**
  32248. * Gets the coefficient of friction
  32249. */
  32250. get friction(): number;
  32251. /**
  32252. * Sets the coefficient of friction
  32253. */
  32254. set friction(value: number);
  32255. /**
  32256. * Gets the coefficient of restitution
  32257. */
  32258. get restitution(): number;
  32259. /**
  32260. * Sets the coefficient of restitution
  32261. */
  32262. set restitution(value: number);
  32263. /**
  32264. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  32265. */
  32266. get pressure(): number;
  32267. /**
  32268. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  32269. */
  32270. set pressure(value: number);
  32271. /**
  32272. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32273. */
  32274. get stiffness(): number;
  32275. /**
  32276. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32277. */
  32278. set stiffness(value: number);
  32279. /**
  32280. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32281. */
  32282. get velocityIterations(): number;
  32283. /**
  32284. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32285. */
  32286. set velocityIterations(value: number);
  32287. /**
  32288. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32289. */
  32290. get positionIterations(): number;
  32291. /**
  32292. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32293. */
  32294. set positionIterations(value: number);
  32295. /**
  32296. * The unique id of the physics imposter
  32297. * set by the physics engine when adding this impostor to the array
  32298. */
  32299. uniqueId: number;
  32300. /**
  32301. * @hidden
  32302. */
  32303. soft: boolean;
  32304. /**
  32305. * @hidden
  32306. */
  32307. segments: number;
  32308. private _joints;
  32309. /**
  32310. * Initializes the physics imposter
  32311. * @param object The physics-enabled object used as the physics imposter
  32312. * @param type The type of the physics imposter
  32313. * @param _options The options for the physics imposter
  32314. * @param _scene The Babylon scene
  32315. */
  32316. constructor(
  32317. /**
  32318. * The physics-enabled object used as the physics imposter
  32319. */
  32320. object: IPhysicsEnabledObject,
  32321. /**
  32322. * The type of the physics imposter
  32323. */
  32324. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  32325. /**
  32326. * This function will completly initialize this impostor.
  32327. * It will create a new body - but only if this mesh has no parent.
  32328. * If it has, this impostor will not be used other than to define the impostor
  32329. * of the child mesh.
  32330. * @hidden
  32331. */
  32332. _init(): void;
  32333. private _getPhysicsParent;
  32334. /**
  32335. * Should a new body be generated.
  32336. * @returns boolean specifying if body initialization is required
  32337. */
  32338. isBodyInitRequired(): boolean;
  32339. /**
  32340. * Sets the updated scaling
  32341. * @param updated Specifies if the scaling is updated
  32342. */
  32343. setScalingUpdated(): void;
  32344. /**
  32345. * Force a regeneration of this or the parent's impostor's body.
  32346. * Use under cautious - This will remove all joints already implemented.
  32347. */
  32348. forceUpdate(): void;
  32349. /**
  32350. * Gets the body that holds this impostor. Either its own, or its parent.
  32351. */
  32352. get physicsBody(): any;
  32353. /**
  32354. * Get the parent of the physics imposter
  32355. * @returns Physics imposter or null
  32356. */
  32357. get parent(): Nullable<PhysicsImpostor>;
  32358. /**
  32359. * Sets the parent of the physics imposter
  32360. */
  32361. set parent(value: Nullable<PhysicsImpostor>);
  32362. /**
  32363. * Set the physics body. Used mainly by the physics engine/plugin
  32364. */
  32365. set physicsBody(physicsBody: any);
  32366. /**
  32367. * Resets the update flags
  32368. */
  32369. resetUpdateFlags(): void;
  32370. /**
  32371. * Gets the object extend size
  32372. * @returns the object extend size
  32373. */
  32374. getObjectExtendSize(): Vector3;
  32375. /**
  32376. * Gets the object center
  32377. * @returns The object center
  32378. */
  32379. getObjectCenter(): Vector3;
  32380. /**
  32381. * Get a specific parameter from the options parameters
  32382. * @param paramName The object parameter name
  32383. * @returns The object parameter
  32384. */
  32385. getParam(paramName: string): any;
  32386. /**
  32387. * Sets a specific parameter in the options given to the physics plugin
  32388. * @param paramName The parameter name
  32389. * @param value The value of the parameter
  32390. */
  32391. setParam(paramName: string, value: number): void;
  32392. /**
  32393. * Specifically change the body's mass option. Won't recreate the physics body object
  32394. * @param mass The mass of the physics imposter
  32395. */
  32396. setMass(mass: number): void;
  32397. /**
  32398. * Gets the linear velocity
  32399. * @returns linear velocity or null
  32400. */
  32401. getLinearVelocity(): Nullable<Vector3>;
  32402. /**
  32403. * Sets the linear velocity
  32404. * @param velocity linear velocity or null
  32405. */
  32406. setLinearVelocity(velocity: Nullable<Vector3>): void;
  32407. /**
  32408. * Gets the angular velocity
  32409. * @returns angular velocity or null
  32410. */
  32411. getAngularVelocity(): Nullable<Vector3>;
  32412. /**
  32413. * Sets the angular velocity
  32414. * @param velocity The velocity or null
  32415. */
  32416. setAngularVelocity(velocity: Nullable<Vector3>): void;
  32417. /**
  32418. * Execute a function with the physics plugin native code
  32419. * Provide a function the will have two variables - the world object and the physics body object
  32420. * @param func The function to execute with the physics plugin native code
  32421. */
  32422. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  32423. /**
  32424. * Register a function that will be executed before the physics world is stepping forward
  32425. * @param func The function to execute before the physics world is stepped forward
  32426. */
  32427. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32428. /**
  32429. * Unregister a function that will be executed before the physics world is stepping forward
  32430. * @param func The function to execute before the physics world is stepped forward
  32431. */
  32432. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32433. /**
  32434. * Register a function that will be executed after the physics step
  32435. * @param func The function to execute after physics step
  32436. */
  32437. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32438. /**
  32439. * Unregisters a function that will be executed after the physics step
  32440. * @param func The function to execute after physics step
  32441. */
  32442. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32443. /**
  32444. * register a function that will be executed when this impostor collides against a different body
  32445. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  32446. * @param func Callback that is executed on collision
  32447. */
  32448. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  32449. /**
  32450. * Unregisters the physics imposter on contact
  32451. * @param collideAgainst The physics object to collide against
  32452. * @param func Callback to execute on collision
  32453. */
  32454. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  32455. private _tmpQuat;
  32456. private _tmpQuat2;
  32457. /**
  32458. * Get the parent rotation
  32459. * @returns The parent rotation
  32460. */
  32461. getParentsRotation(): Quaternion;
  32462. /**
  32463. * this function is executed by the physics engine.
  32464. */
  32465. beforeStep: () => void;
  32466. /**
  32467. * this function is executed by the physics engine
  32468. */
  32469. afterStep: () => void;
  32470. /**
  32471. * Legacy collision detection event support
  32472. */
  32473. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  32474. /**
  32475. * event and body object due to cannon's event-based architecture.
  32476. */
  32477. onCollide: (e: {
  32478. body: any;
  32479. point: Nullable<Vector3>;
  32480. }) => void;
  32481. /**
  32482. * Apply a force
  32483. * @param force The force to apply
  32484. * @param contactPoint The contact point for the force
  32485. * @returns The physics imposter
  32486. */
  32487. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32488. /**
  32489. * Apply an impulse
  32490. * @param force The impulse force
  32491. * @param contactPoint The contact point for the impulse force
  32492. * @returns The physics imposter
  32493. */
  32494. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32495. /**
  32496. * A help function to create a joint
  32497. * @param otherImpostor A physics imposter used to create a joint
  32498. * @param jointType The type of joint
  32499. * @param jointData The data for the joint
  32500. * @returns The physics imposter
  32501. */
  32502. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  32503. /**
  32504. * Add a joint to this impostor with a different impostor
  32505. * @param otherImpostor A physics imposter used to add a joint
  32506. * @param joint The joint to add
  32507. * @returns The physics imposter
  32508. */
  32509. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  32510. /**
  32511. * Add an anchor to a cloth impostor
  32512. * @param otherImpostor rigid impostor to anchor to
  32513. * @param width ratio across width from 0 to 1
  32514. * @param height ratio up height from 0 to 1
  32515. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  32516. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  32517. * @returns impostor the soft imposter
  32518. */
  32519. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32520. /**
  32521. * Add a hook to a rope impostor
  32522. * @param otherImpostor rigid impostor to anchor to
  32523. * @param length ratio across rope from 0 to 1
  32524. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  32525. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  32526. * @returns impostor the rope imposter
  32527. */
  32528. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32529. /**
  32530. * Will keep this body still, in a sleep mode.
  32531. * @returns the physics imposter
  32532. */
  32533. sleep(): PhysicsImpostor;
  32534. /**
  32535. * Wake the body up.
  32536. * @returns The physics imposter
  32537. */
  32538. wakeUp(): PhysicsImpostor;
  32539. /**
  32540. * Clones the physics imposter
  32541. * @param newObject The physics imposter clones to this physics-enabled object
  32542. * @returns A nullable physics imposter
  32543. */
  32544. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32545. /**
  32546. * Disposes the physics imposter
  32547. */
  32548. dispose(): void;
  32549. /**
  32550. * Sets the delta position
  32551. * @param position The delta position amount
  32552. */
  32553. setDeltaPosition(position: Vector3): void;
  32554. /**
  32555. * Sets the delta rotation
  32556. * @param rotation The delta rotation amount
  32557. */
  32558. setDeltaRotation(rotation: Quaternion): void;
  32559. /**
  32560. * Gets the box size of the physics imposter and stores the result in the input parameter
  32561. * @param result Stores the box size
  32562. * @returns The physics imposter
  32563. */
  32564. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  32565. /**
  32566. * Gets the radius of the physics imposter
  32567. * @returns Radius of the physics imposter
  32568. */
  32569. getRadius(): number;
  32570. /**
  32571. * Sync a bone with this impostor
  32572. * @param bone The bone to sync to the impostor.
  32573. * @param boneMesh The mesh that the bone is influencing.
  32574. * @param jointPivot The pivot of the joint / bone in local space.
  32575. * @param distToJoint Optional distance from the impostor to the joint.
  32576. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32577. */
  32578. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  32579. /**
  32580. * Sync impostor to a bone
  32581. * @param bone The bone that the impostor will be synced to.
  32582. * @param boneMesh The mesh that the bone is influencing.
  32583. * @param jointPivot The pivot of the joint / bone in local space.
  32584. * @param distToJoint Optional distance from the impostor to the joint.
  32585. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32586. * @param boneAxis Optional vector3 axis the bone is aligned with
  32587. */
  32588. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  32589. /**
  32590. * No-Imposter type
  32591. */
  32592. static NoImpostor: number;
  32593. /**
  32594. * Sphere-Imposter type
  32595. */
  32596. static SphereImpostor: number;
  32597. /**
  32598. * Box-Imposter type
  32599. */
  32600. static BoxImpostor: number;
  32601. /**
  32602. * Plane-Imposter type
  32603. */
  32604. static PlaneImpostor: number;
  32605. /**
  32606. * Mesh-imposter type
  32607. */
  32608. static MeshImpostor: number;
  32609. /**
  32610. * Capsule-Impostor type (Ammo.js plugin only)
  32611. */
  32612. static CapsuleImpostor: number;
  32613. /**
  32614. * Cylinder-Imposter type
  32615. */
  32616. static CylinderImpostor: number;
  32617. /**
  32618. * Particle-Imposter type
  32619. */
  32620. static ParticleImpostor: number;
  32621. /**
  32622. * Heightmap-Imposter type
  32623. */
  32624. static HeightmapImpostor: number;
  32625. /**
  32626. * ConvexHull-Impostor type (Ammo.js plugin only)
  32627. */
  32628. static ConvexHullImpostor: number;
  32629. /**
  32630. * Custom-Imposter type (Ammo.js plugin only)
  32631. */
  32632. static CustomImpostor: number;
  32633. /**
  32634. * Rope-Imposter type
  32635. */
  32636. static RopeImpostor: number;
  32637. /**
  32638. * Cloth-Imposter type
  32639. */
  32640. static ClothImpostor: number;
  32641. /**
  32642. * Softbody-Imposter type
  32643. */
  32644. static SoftbodyImpostor: number;
  32645. }
  32646. }
  32647. declare module BABYLON {
  32648. /**
  32649. * @hidden
  32650. **/
  32651. export class _CreationDataStorage {
  32652. closePath?: boolean;
  32653. closeArray?: boolean;
  32654. idx: number[];
  32655. dashSize: number;
  32656. gapSize: number;
  32657. path3D: Path3D;
  32658. pathArray: Vector3[][];
  32659. arc: number;
  32660. radius: number;
  32661. cap: number;
  32662. tessellation: number;
  32663. }
  32664. /**
  32665. * @hidden
  32666. **/
  32667. class _InstanceDataStorage {
  32668. visibleInstances: any;
  32669. batchCache: _InstancesBatch;
  32670. instancesBufferSize: number;
  32671. instancesBuffer: Nullable<Buffer>;
  32672. instancesData: Float32Array;
  32673. overridenInstanceCount: number;
  32674. isFrozen: boolean;
  32675. previousBatch: Nullable<_InstancesBatch>;
  32676. hardwareInstancedRendering: boolean;
  32677. sideOrientation: number;
  32678. manualUpdate: boolean;
  32679. previousRenderId: number;
  32680. }
  32681. /**
  32682. * @hidden
  32683. **/
  32684. export class _InstancesBatch {
  32685. mustReturn: boolean;
  32686. visibleInstances: Nullable<InstancedMesh[]>[];
  32687. renderSelf: boolean[];
  32688. hardwareInstancedRendering: boolean[];
  32689. }
  32690. /**
  32691. * @hidden
  32692. **/
  32693. class _ThinInstanceDataStorage {
  32694. instancesCount: number;
  32695. matrixBuffer: Nullable<Buffer>;
  32696. matrixBufferSize: number;
  32697. matrixData: Nullable<Float32Array>;
  32698. boundingVectors: Array<Vector3>;
  32699. worldMatrices: Nullable<Matrix[]>;
  32700. }
  32701. /**
  32702. * Class used to represent renderable models
  32703. */
  32704. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  32705. /**
  32706. * Mesh side orientation : usually the external or front surface
  32707. */
  32708. static readonly FRONTSIDE: number;
  32709. /**
  32710. * Mesh side orientation : usually the internal or back surface
  32711. */
  32712. static readonly BACKSIDE: number;
  32713. /**
  32714. * Mesh side orientation : both internal and external or front and back surfaces
  32715. */
  32716. static readonly DOUBLESIDE: number;
  32717. /**
  32718. * Mesh side orientation : by default, `FRONTSIDE`
  32719. */
  32720. static readonly DEFAULTSIDE: number;
  32721. /**
  32722. * Mesh cap setting : no cap
  32723. */
  32724. static readonly NO_CAP: number;
  32725. /**
  32726. * Mesh cap setting : one cap at the beginning of the mesh
  32727. */
  32728. static readonly CAP_START: number;
  32729. /**
  32730. * Mesh cap setting : one cap at the end of the mesh
  32731. */
  32732. static readonly CAP_END: number;
  32733. /**
  32734. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  32735. */
  32736. static readonly CAP_ALL: number;
  32737. /**
  32738. * Mesh pattern setting : no flip or rotate
  32739. */
  32740. static readonly NO_FLIP: number;
  32741. /**
  32742. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  32743. */
  32744. static readonly FLIP_TILE: number;
  32745. /**
  32746. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  32747. */
  32748. static readonly ROTATE_TILE: number;
  32749. /**
  32750. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  32751. */
  32752. static readonly FLIP_ROW: number;
  32753. /**
  32754. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  32755. */
  32756. static readonly ROTATE_ROW: number;
  32757. /**
  32758. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  32759. */
  32760. static readonly FLIP_N_ROTATE_TILE: number;
  32761. /**
  32762. * Mesh pattern setting : rotate pattern and rotate
  32763. */
  32764. static readonly FLIP_N_ROTATE_ROW: number;
  32765. /**
  32766. * Mesh tile positioning : part tiles same on left/right or top/bottom
  32767. */
  32768. static readonly CENTER: number;
  32769. /**
  32770. * Mesh tile positioning : part tiles on left
  32771. */
  32772. static readonly LEFT: number;
  32773. /**
  32774. * Mesh tile positioning : part tiles on right
  32775. */
  32776. static readonly RIGHT: number;
  32777. /**
  32778. * Mesh tile positioning : part tiles on top
  32779. */
  32780. static readonly TOP: number;
  32781. /**
  32782. * Mesh tile positioning : part tiles on bottom
  32783. */
  32784. static readonly BOTTOM: number;
  32785. /**
  32786. * Gets the default side orientation.
  32787. * @param orientation the orientation to value to attempt to get
  32788. * @returns the default orientation
  32789. * @hidden
  32790. */
  32791. static _GetDefaultSideOrientation(orientation?: number): number;
  32792. private _internalMeshDataInfo;
  32793. get computeBonesUsingShaders(): boolean;
  32794. set computeBonesUsingShaders(value: boolean);
  32795. /**
  32796. * An event triggered before rendering the mesh
  32797. */
  32798. get onBeforeRenderObservable(): Observable<Mesh>;
  32799. /**
  32800. * An event triggered before binding the mesh
  32801. */
  32802. get onBeforeBindObservable(): Observable<Mesh>;
  32803. /**
  32804. * An event triggered after rendering the mesh
  32805. */
  32806. get onAfterRenderObservable(): Observable<Mesh>;
  32807. /**
  32808. * An event triggered before drawing the mesh
  32809. */
  32810. get onBeforeDrawObservable(): Observable<Mesh>;
  32811. private _onBeforeDrawObserver;
  32812. /**
  32813. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  32814. */
  32815. set onBeforeDraw(callback: () => void);
  32816. get hasInstances(): boolean;
  32817. get hasThinInstances(): boolean;
  32818. /**
  32819. * Gets the delay loading state of the mesh (when delay loading is turned on)
  32820. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  32821. */
  32822. delayLoadState: number;
  32823. /**
  32824. * Gets the list of instances created from this mesh
  32825. * it is not supposed to be modified manually.
  32826. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  32827. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  32828. */
  32829. instances: InstancedMesh[];
  32830. /**
  32831. * Gets the file containing delay loading data for this mesh
  32832. */
  32833. delayLoadingFile: string;
  32834. /** @hidden */
  32835. _binaryInfo: any;
  32836. /**
  32837. * User defined function used to change how LOD level selection is done
  32838. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32839. */
  32840. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  32841. /**
  32842. * Gets or sets the morph target manager
  32843. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32844. */
  32845. get morphTargetManager(): Nullable<MorphTargetManager>;
  32846. set morphTargetManager(value: Nullable<MorphTargetManager>);
  32847. /** @hidden */
  32848. _creationDataStorage: Nullable<_CreationDataStorage>;
  32849. /** @hidden */
  32850. _geometry: Nullable<Geometry>;
  32851. /** @hidden */
  32852. _delayInfo: Array<string>;
  32853. /** @hidden */
  32854. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  32855. /** @hidden */
  32856. _instanceDataStorage: _InstanceDataStorage;
  32857. /** @hidden */
  32858. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  32859. private _effectiveMaterial;
  32860. /** @hidden */
  32861. _shouldGenerateFlatShading: boolean;
  32862. /** @hidden */
  32863. _originalBuilderSideOrientation: number;
  32864. /**
  32865. * Use this property to change the original side orientation defined at construction time
  32866. */
  32867. overrideMaterialSideOrientation: Nullable<number>;
  32868. /**
  32869. * Gets the source mesh (the one used to clone this one from)
  32870. */
  32871. get source(): Nullable<Mesh>;
  32872. /**
  32873. * Gets the list of clones of this mesh
  32874. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  32875. * Note that useClonedMeshMap=true is the default setting
  32876. */
  32877. get cloneMeshMap(): Nullable<{
  32878. [id: string]: Mesh | undefined;
  32879. }>;
  32880. /**
  32881. * Gets or sets a boolean indicating that this mesh does not use index buffer
  32882. */
  32883. get isUnIndexed(): boolean;
  32884. set isUnIndexed(value: boolean);
  32885. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  32886. get worldMatrixInstancedBuffer(): Float32Array;
  32887. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  32888. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  32889. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  32890. /**
  32891. * @constructor
  32892. * @param name The value used by scene.getMeshByName() to do a lookup.
  32893. * @param scene The scene to add this mesh to.
  32894. * @param parent The parent of this mesh, if it has one
  32895. * @param source An optional Mesh from which geometry is shared, cloned.
  32896. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  32897. * When false, achieved by calling a clone(), also passing False.
  32898. * This will make creation of children, recursive.
  32899. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  32900. */
  32901. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  32902. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  32903. doNotInstantiate: boolean;
  32904. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  32905. /**
  32906. * Gets the class name
  32907. * @returns the string "Mesh".
  32908. */
  32909. getClassName(): string;
  32910. /** @hidden */
  32911. get _isMesh(): boolean;
  32912. /**
  32913. * Returns a description of this mesh
  32914. * @param fullDetails define if full details about this mesh must be used
  32915. * @returns a descriptive string representing this mesh
  32916. */
  32917. toString(fullDetails?: boolean): string;
  32918. /** @hidden */
  32919. _unBindEffect(): void;
  32920. /**
  32921. * Gets a boolean indicating if this mesh has LOD
  32922. */
  32923. get hasLODLevels(): boolean;
  32924. /**
  32925. * Gets the list of MeshLODLevel associated with the current mesh
  32926. * @returns an array of MeshLODLevel
  32927. */
  32928. getLODLevels(): MeshLODLevel[];
  32929. private _sortLODLevels;
  32930. /**
  32931. * Add a mesh as LOD level triggered at the given distance.
  32932. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32933. * @param distance The distance from the center of the object to show this level
  32934. * @param mesh The mesh to be added as LOD level (can be null)
  32935. * @return This mesh (for chaining)
  32936. */
  32937. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  32938. /**
  32939. * Returns the LOD level mesh at the passed distance or null if not found.
  32940. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32941. * @param distance The distance from the center of the object to show this level
  32942. * @returns a Mesh or `null`
  32943. */
  32944. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  32945. /**
  32946. * Remove a mesh from the LOD array
  32947. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32948. * @param mesh defines the mesh to be removed
  32949. * @return This mesh (for chaining)
  32950. */
  32951. removeLODLevel(mesh: Mesh): Mesh;
  32952. /**
  32953. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  32954. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32955. * @param camera defines the camera to use to compute distance
  32956. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  32957. * @return This mesh (for chaining)
  32958. */
  32959. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  32960. /**
  32961. * Gets the mesh internal Geometry object
  32962. */
  32963. get geometry(): Nullable<Geometry>;
  32964. /**
  32965. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  32966. * @returns the total number of vertices
  32967. */
  32968. getTotalVertices(): number;
  32969. /**
  32970. * Returns the content of an associated vertex buffer
  32971. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32972. * - VertexBuffer.PositionKind
  32973. * - VertexBuffer.UVKind
  32974. * - VertexBuffer.UV2Kind
  32975. * - VertexBuffer.UV3Kind
  32976. * - VertexBuffer.UV4Kind
  32977. * - VertexBuffer.UV5Kind
  32978. * - VertexBuffer.UV6Kind
  32979. * - VertexBuffer.ColorKind
  32980. * - VertexBuffer.MatricesIndicesKind
  32981. * - VertexBuffer.MatricesIndicesExtraKind
  32982. * - VertexBuffer.MatricesWeightsKind
  32983. * - VertexBuffer.MatricesWeightsExtraKind
  32984. * @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
  32985. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  32986. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  32987. */
  32988. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  32989. /**
  32990. * Returns the mesh VertexBuffer object from the requested `kind`
  32991. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32992. * - VertexBuffer.PositionKind
  32993. * - VertexBuffer.NormalKind
  32994. * - VertexBuffer.UVKind
  32995. * - VertexBuffer.UV2Kind
  32996. * - VertexBuffer.UV3Kind
  32997. * - VertexBuffer.UV4Kind
  32998. * - VertexBuffer.UV5Kind
  32999. * - VertexBuffer.UV6Kind
  33000. * - VertexBuffer.ColorKind
  33001. * - VertexBuffer.MatricesIndicesKind
  33002. * - VertexBuffer.MatricesIndicesExtraKind
  33003. * - VertexBuffer.MatricesWeightsKind
  33004. * - VertexBuffer.MatricesWeightsExtraKind
  33005. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  33006. */
  33007. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  33008. /**
  33009. * Tests if a specific vertex buffer is associated with this mesh
  33010. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33011. * - VertexBuffer.PositionKind
  33012. * - VertexBuffer.NormalKind
  33013. * - VertexBuffer.UVKind
  33014. * - VertexBuffer.UV2Kind
  33015. * - VertexBuffer.UV3Kind
  33016. * - VertexBuffer.UV4Kind
  33017. * - VertexBuffer.UV5Kind
  33018. * - VertexBuffer.UV6Kind
  33019. * - VertexBuffer.ColorKind
  33020. * - VertexBuffer.MatricesIndicesKind
  33021. * - VertexBuffer.MatricesIndicesExtraKind
  33022. * - VertexBuffer.MatricesWeightsKind
  33023. * - VertexBuffer.MatricesWeightsExtraKind
  33024. * @returns a boolean
  33025. */
  33026. isVerticesDataPresent(kind: string): boolean;
  33027. /**
  33028. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  33029. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33030. * - VertexBuffer.PositionKind
  33031. * - VertexBuffer.UVKind
  33032. * - VertexBuffer.UV2Kind
  33033. * - VertexBuffer.UV3Kind
  33034. * - VertexBuffer.UV4Kind
  33035. * - VertexBuffer.UV5Kind
  33036. * - VertexBuffer.UV6Kind
  33037. * - VertexBuffer.ColorKind
  33038. * - VertexBuffer.MatricesIndicesKind
  33039. * - VertexBuffer.MatricesIndicesExtraKind
  33040. * - VertexBuffer.MatricesWeightsKind
  33041. * - VertexBuffer.MatricesWeightsExtraKind
  33042. * @returns a boolean
  33043. */
  33044. isVertexBufferUpdatable(kind: string): boolean;
  33045. /**
  33046. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  33047. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33048. * - VertexBuffer.PositionKind
  33049. * - VertexBuffer.NormalKind
  33050. * - VertexBuffer.UVKind
  33051. * - VertexBuffer.UV2Kind
  33052. * - VertexBuffer.UV3Kind
  33053. * - VertexBuffer.UV4Kind
  33054. * - VertexBuffer.UV5Kind
  33055. * - VertexBuffer.UV6Kind
  33056. * - VertexBuffer.ColorKind
  33057. * - VertexBuffer.MatricesIndicesKind
  33058. * - VertexBuffer.MatricesIndicesExtraKind
  33059. * - VertexBuffer.MatricesWeightsKind
  33060. * - VertexBuffer.MatricesWeightsExtraKind
  33061. * @returns an array of strings
  33062. */
  33063. getVerticesDataKinds(): string[];
  33064. /**
  33065. * Returns a positive integer : the total number of indices in this mesh geometry.
  33066. * @returns the numner of indices or zero if the mesh has no geometry.
  33067. */
  33068. getTotalIndices(): number;
  33069. /**
  33070. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  33071. * @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.
  33072. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  33073. * @returns the indices array or an empty array if the mesh has no geometry
  33074. */
  33075. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  33076. get isBlocked(): boolean;
  33077. /**
  33078. * Determine if the current mesh is ready to be rendered
  33079. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33080. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  33081. * @returns true if all associated assets are ready (material, textures, shaders)
  33082. */
  33083. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  33084. /**
  33085. * 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.
  33086. */
  33087. get areNormalsFrozen(): boolean;
  33088. /**
  33089. * 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.
  33090. * @returns the current mesh
  33091. */
  33092. freezeNormals(): Mesh;
  33093. /**
  33094. * 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
  33095. * @returns the current mesh
  33096. */
  33097. unfreezeNormals(): Mesh;
  33098. /**
  33099. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  33100. */
  33101. set overridenInstanceCount(count: number);
  33102. /** @hidden */
  33103. _preActivate(): Mesh;
  33104. /** @hidden */
  33105. _preActivateForIntermediateRendering(renderId: number): Mesh;
  33106. /** @hidden */
  33107. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  33108. protected _afterComputeWorldMatrix(): void;
  33109. /** @hidden */
  33110. _postActivate(): void;
  33111. /**
  33112. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33113. * This means the mesh underlying bounding box and sphere are recomputed.
  33114. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33115. * @returns the current mesh
  33116. */
  33117. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  33118. /** @hidden */
  33119. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  33120. /**
  33121. * This function will subdivide the mesh into multiple submeshes
  33122. * @param count defines the expected number of submeshes
  33123. */
  33124. subdivide(count: number): void;
  33125. /**
  33126. * Copy a FloatArray into a specific associated vertex buffer
  33127. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33128. * - VertexBuffer.PositionKind
  33129. * - VertexBuffer.UVKind
  33130. * - VertexBuffer.UV2Kind
  33131. * - VertexBuffer.UV3Kind
  33132. * - VertexBuffer.UV4Kind
  33133. * - VertexBuffer.UV5Kind
  33134. * - VertexBuffer.UV6Kind
  33135. * - VertexBuffer.ColorKind
  33136. * - VertexBuffer.MatricesIndicesKind
  33137. * - VertexBuffer.MatricesIndicesExtraKind
  33138. * - VertexBuffer.MatricesWeightsKind
  33139. * - VertexBuffer.MatricesWeightsExtraKind
  33140. * @param data defines the data source
  33141. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33142. * @param stride defines the data stride size (can be null)
  33143. * @returns the current mesh
  33144. */
  33145. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33146. /**
  33147. * Delete a vertex buffer associated with this mesh
  33148. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  33149. * - VertexBuffer.PositionKind
  33150. * - VertexBuffer.UVKind
  33151. * - VertexBuffer.UV2Kind
  33152. * - VertexBuffer.UV3Kind
  33153. * - VertexBuffer.UV4Kind
  33154. * - VertexBuffer.UV5Kind
  33155. * - VertexBuffer.UV6Kind
  33156. * - VertexBuffer.ColorKind
  33157. * - VertexBuffer.MatricesIndicesKind
  33158. * - VertexBuffer.MatricesIndicesExtraKind
  33159. * - VertexBuffer.MatricesWeightsKind
  33160. * - VertexBuffer.MatricesWeightsExtraKind
  33161. */
  33162. removeVerticesData(kind: string): void;
  33163. /**
  33164. * Flags an associated vertex buffer as updatable
  33165. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  33166. * - VertexBuffer.PositionKind
  33167. * - VertexBuffer.UVKind
  33168. * - VertexBuffer.UV2Kind
  33169. * - VertexBuffer.UV3Kind
  33170. * - VertexBuffer.UV4Kind
  33171. * - VertexBuffer.UV5Kind
  33172. * - VertexBuffer.UV6Kind
  33173. * - VertexBuffer.ColorKind
  33174. * - VertexBuffer.MatricesIndicesKind
  33175. * - VertexBuffer.MatricesIndicesExtraKind
  33176. * - VertexBuffer.MatricesWeightsKind
  33177. * - VertexBuffer.MatricesWeightsExtraKind
  33178. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33179. */
  33180. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  33181. /**
  33182. * Sets the mesh global Vertex Buffer
  33183. * @param buffer defines the buffer to use
  33184. * @returns the current mesh
  33185. */
  33186. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  33187. /**
  33188. * Update a specific associated vertex buffer
  33189. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33190. * - VertexBuffer.PositionKind
  33191. * - VertexBuffer.UVKind
  33192. * - VertexBuffer.UV2Kind
  33193. * - VertexBuffer.UV3Kind
  33194. * - VertexBuffer.UV4Kind
  33195. * - VertexBuffer.UV5Kind
  33196. * - VertexBuffer.UV6Kind
  33197. * - VertexBuffer.ColorKind
  33198. * - VertexBuffer.MatricesIndicesKind
  33199. * - VertexBuffer.MatricesIndicesExtraKind
  33200. * - VertexBuffer.MatricesWeightsKind
  33201. * - VertexBuffer.MatricesWeightsExtraKind
  33202. * @param data defines the data source
  33203. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  33204. * @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)
  33205. * @returns the current mesh
  33206. */
  33207. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  33208. /**
  33209. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  33210. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  33211. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  33212. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  33213. * @returns the current mesh
  33214. */
  33215. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  33216. /**
  33217. * Creates a un-shared specific occurence of the geometry for the mesh.
  33218. * @returns the current mesh
  33219. */
  33220. makeGeometryUnique(): Mesh;
  33221. /**
  33222. * Set the index buffer of this mesh
  33223. * @param indices defines the source data
  33224. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  33225. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  33226. * @returns the current mesh
  33227. */
  33228. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  33229. /**
  33230. * Update the current index buffer
  33231. * @param indices defines the source data
  33232. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  33233. * @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)
  33234. * @returns the current mesh
  33235. */
  33236. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  33237. /**
  33238. * Invert the geometry to move from a right handed system to a left handed one.
  33239. * @returns the current mesh
  33240. */
  33241. toLeftHanded(): Mesh;
  33242. /** @hidden */
  33243. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  33244. /** @hidden */
  33245. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  33246. /**
  33247. * Registers for this mesh a javascript function called just before the rendering process
  33248. * @param func defines the function to call before rendering this mesh
  33249. * @returns the current mesh
  33250. */
  33251. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  33252. /**
  33253. * Disposes a previously registered javascript function called before the rendering
  33254. * @param func defines the function to remove
  33255. * @returns the current mesh
  33256. */
  33257. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  33258. /**
  33259. * Registers for this mesh a javascript function called just after the rendering is complete
  33260. * @param func defines the function to call after rendering this mesh
  33261. * @returns the current mesh
  33262. */
  33263. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33264. /**
  33265. * Disposes a previously registered javascript function called after the rendering.
  33266. * @param func defines the function to remove
  33267. * @returns the current mesh
  33268. */
  33269. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33270. /** @hidden */
  33271. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  33272. /** @hidden */
  33273. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  33274. /** @hidden */
  33275. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  33276. /** @hidden */
  33277. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  33278. /** @hidden */
  33279. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  33280. /** @hidden */
  33281. _rebuild(): void;
  33282. /** @hidden */
  33283. _freeze(): void;
  33284. /** @hidden */
  33285. _unFreeze(): void;
  33286. /**
  33287. * 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
  33288. * @param subMesh defines the subMesh to render
  33289. * @param enableAlphaMode defines if alpha mode can be changed
  33290. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  33291. * @returns the current mesh
  33292. */
  33293. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  33294. private _onBeforeDraw;
  33295. /**
  33296. * Renormalize the mesh and patch it up if there are no weights
  33297. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  33298. * However in the case of zero weights then we set just a single influence to 1.
  33299. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  33300. */
  33301. cleanMatrixWeights(): void;
  33302. private normalizeSkinFourWeights;
  33303. private normalizeSkinWeightsAndExtra;
  33304. /**
  33305. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  33306. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  33307. * the user know there was an issue with importing the mesh
  33308. * @returns a validation object with skinned, valid and report string
  33309. */
  33310. validateSkinning(): {
  33311. skinned: boolean;
  33312. valid: boolean;
  33313. report: string;
  33314. };
  33315. /** @hidden */
  33316. _checkDelayState(): Mesh;
  33317. private _queueLoad;
  33318. /**
  33319. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  33320. * A mesh is in the frustum if its bounding box intersects the frustum
  33321. * @param frustumPlanes defines the frustum to test
  33322. * @returns true if the mesh is in the frustum planes
  33323. */
  33324. isInFrustum(frustumPlanes: Plane[]): boolean;
  33325. /**
  33326. * Sets the mesh material by the material or multiMaterial `id` property
  33327. * @param id is a string identifying the material or the multiMaterial
  33328. * @returns the current mesh
  33329. */
  33330. setMaterialByID(id: string): Mesh;
  33331. /**
  33332. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  33333. * @returns an array of IAnimatable
  33334. */
  33335. getAnimatables(): IAnimatable[];
  33336. /**
  33337. * Modifies the mesh geometry according to the passed transformation matrix.
  33338. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  33339. * The mesh normals are modified using the same transformation.
  33340. * Note that, under the hood, this method sets a new VertexBuffer each call.
  33341. * @param transform defines the transform matrix to use
  33342. * @see https://doc.babylonjs.com/resources/baking_transformations
  33343. * @returns the current mesh
  33344. */
  33345. bakeTransformIntoVertices(transform: Matrix): Mesh;
  33346. /**
  33347. * Modifies the mesh geometry according to its own current World Matrix.
  33348. * The mesh World Matrix is then reset.
  33349. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  33350. * Note that, under the hood, this method sets a new VertexBuffer each call.
  33351. * @see https://doc.babylonjs.com/resources/baking_transformations
  33352. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  33353. * @returns the current mesh
  33354. */
  33355. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  33356. /** @hidden */
  33357. get _positions(): Nullable<Vector3[]>;
  33358. /** @hidden */
  33359. _resetPointsArrayCache(): Mesh;
  33360. /** @hidden */
  33361. _generatePointsArray(): boolean;
  33362. /**
  33363. * Returns a new Mesh object generated from the current mesh properties.
  33364. * This method must not get confused with createInstance()
  33365. * @param name is a string, the name given to the new mesh
  33366. * @param newParent can be any Node object (default `null`)
  33367. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  33368. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  33369. * @returns a new mesh
  33370. */
  33371. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  33372. /**
  33373. * Releases resources associated with this mesh.
  33374. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33375. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33376. */
  33377. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33378. /** @hidden */
  33379. _disposeInstanceSpecificData(): void;
  33380. /** @hidden */
  33381. _disposeThinInstanceSpecificData(): void;
  33382. /**
  33383. * Modifies the mesh geometry according to a displacement map.
  33384. * 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.
  33385. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  33386. * @param url is a string, the URL from the image file is to be downloaded.
  33387. * @param minHeight is the lower limit of the displacement.
  33388. * @param maxHeight is the upper limit of the displacement.
  33389. * @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.
  33390. * @param uvOffset is an optional vector2 used to offset UV.
  33391. * @param uvScale is an optional vector2 used to scale UV.
  33392. * @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.
  33393. * @returns the Mesh.
  33394. */
  33395. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33396. /**
  33397. * Modifies the mesh geometry according to a displacementMap buffer.
  33398. * 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.
  33399. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  33400. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  33401. * @param heightMapWidth is the width of the buffer image.
  33402. * @param heightMapHeight is the height of the buffer image.
  33403. * @param minHeight is the lower limit of the displacement.
  33404. * @param maxHeight is the upper limit of the displacement.
  33405. * @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.
  33406. * @param uvOffset is an optional vector2 used to offset UV.
  33407. * @param uvScale is an optional vector2 used to scale UV.
  33408. * @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.
  33409. * @returns the Mesh.
  33410. */
  33411. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33412. /**
  33413. * Modify the mesh to get a flat shading rendering.
  33414. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  33415. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  33416. * @returns current mesh
  33417. */
  33418. convertToFlatShadedMesh(): Mesh;
  33419. /**
  33420. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  33421. * In other words, more vertices, no more indices and a single bigger VBO.
  33422. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  33423. * @returns current mesh
  33424. */
  33425. convertToUnIndexedMesh(): Mesh;
  33426. /**
  33427. * Inverses facet orientations.
  33428. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33429. * @param flipNormals will also inverts the normals
  33430. * @returns current mesh
  33431. */
  33432. flipFaces(flipNormals?: boolean): Mesh;
  33433. /**
  33434. * Increase the number of facets and hence vertices in a mesh
  33435. * Vertex normals are interpolated from existing vertex normals
  33436. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33437. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  33438. */
  33439. increaseVertices(numberPerEdge: number): void;
  33440. /**
  33441. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  33442. * This will undo any application of covertToFlatShadedMesh
  33443. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33444. */
  33445. forceSharedVertices(): void;
  33446. /** @hidden */
  33447. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  33448. /** @hidden */
  33449. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  33450. /**
  33451. * Creates a new InstancedMesh object from the mesh model.
  33452. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33453. * @param name defines the name of the new instance
  33454. * @returns a new InstancedMesh
  33455. */
  33456. createInstance(name: string): InstancedMesh;
  33457. /**
  33458. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  33459. * After this call, all the mesh instances have the same submeshes than the current mesh.
  33460. * @returns the current mesh
  33461. */
  33462. synchronizeInstances(): Mesh;
  33463. /**
  33464. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  33465. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  33466. * This should be used together with the simplification to avoid disappearing triangles.
  33467. * @param successCallback an optional success callback to be called after the optimization finished.
  33468. * @returns the current mesh
  33469. */
  33470. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  33471. /**
  33472. * Serialize current mesh
  33473. * @param serializationObject defines the object which will receive the serialization data
  33474. */
  33475. serialize(serializationObject: any): void;
  33476. /** @hidden */
  33477. _syncGeometryWithMorphTargetManager(): void;
  33478. /** @hidden */
  33479. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  33480. /**
  33481. * Returns a new Mesh object parsed from the source provided.
  33482. * @param parsedMesh is the source
  33483. * @param scene defines the hosting scene
  33484. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  33485. * @returns a new Mesh
  33486. */
  33487. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  33488. /**
  33489. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  33490. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33491. * @param name defines the name of the mesh to create
  33492. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  33493. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  33494. * @param closePath creates a seam between the first and the last points of each path of the path array
  33495. * @param offset is taken in account only if the `pathArray` is containing a single path
  33496. * @param scene defines the hosting scene
  33497. * @param updatable defines if the mesh must be flagged as updatable
  33498. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33499. * @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)
  33500. * @returns a new Mesh
  33501. */
  33502. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33503. /**
  33504. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  33505. * @param name defines the name of the mesh to create
  33506. * @param radius sets the radius size (float) of the polygon (default 0.5)
  33507. * @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
  33508. * @param scene defines the hosting scene
  33509. * @param updatable defines if the mesh must be flagged as updatable
  33510. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33511. * @returns a new Mesh
  33512. */
  33513. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33514. /**
  33515. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  33516. * @param name defines the name of the mesh to create
  33517. * @param size sets the size (float) of each box side (default 1)
  33518. * @param scene defines the hosting scene
  33519. * @param updatable defines if the mesh must be flagged as updatable
  33520. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33521. * @returns a new Mesh
  33522. */
  33523. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33524. /**
  33525. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  33526. * @param name defines the name of the mesh to create
  33527. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33528. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33529. * @param scene defines the hosting scene
  33530. * @param updatable defines if the mesh must be flagged as updatable
  33531. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33532. * @returns a new Mesh
  33533. */
  33534. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33535. /**
  33536. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  33537. * @param name defines the name of the mesh to create
  33538. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33539. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33540. * @param scene defines the hosting scene
  33541. * @returns a new Mesh
  33542. */
  33543. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  33544. /**
  33545. * Creates a cylinder or a cone 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 height sets the height size (float) of the cylinder/cone (float, default 2)
  33548. * @param diameterTop set the top cap diameter (floats, default 1)
  33549. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  33550. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  33551. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  33552. * @param scene defines the hosting scene
  33553. * @param updatable defines if the mesh must be flagged as updatable
  33554. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33555. * @returns a new Mesh
  33556. */
  33557. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  33558. /**
  33559. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  33560. * @param name defines the name of the mesh to create
  33561. * @param diameter sets the diameter size (float) of the torus (default 1)
  33562. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  33563. * @param tessellation sets the number of torus sides (postive integer, default 16)
  33564. * @param scene defines the hosting scene
  33565. * @param updatable defines if the mesh must be flagged as updatable
  33566. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33567. * @returns a new Mesh
  33568. */
  33569. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33570. /**
  33571. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  33572. * @param name defines the name of the mesh to create
  33573. * @param radius sets the global radius size (float) of the torus knot (default 2)
  33574. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  33575. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  33576. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  33577. * @param p the number of windings on X axis (positive integers, default 2)
  33578. * @param q the number of windings on Y axis (positive integers, default 3)
  33579. * @param scene defines the hosting scene
  33580. * @param updatable defines if the mesh must be flagged as updatable
  33581. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33582. * @returns a new Mesh
  33583. */
  33584. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33585. /**
  33586. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  33587. * @param name defines the name of the mesh to create
  33588. * @param points is an array successive Vector3
  33589. * @param scene defines the hosting scene
  33590. * @param updatable defines if the mesh must be flagged as updatable
  33591. * @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).
  33592. * @returns a new Mesh
  33593. */
  33594. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  33595. /**
  33596. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  33597. * @param name defines the name of the mesh to create
  33598. * @param points is an array successive Vector3
  33599. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  33600. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  33601. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  33602. * @param scene defines the hosting scene
  33603. * @param updatable defines if the mesh must be flagged as updatable
  33604. * @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)
  33605. * @returns a new Mesh
  33606. */
  33607. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  33608. /**
  33609. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  33610. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  33611. * 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.
  33612. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33613. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  33614. * Remember you can only change the shape positions, not their number when updating a polygon.
  33615. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  33616. * @param name defines the name of the mesh to create
  33617. * @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
  33618. * @param scene defines the hosting scene
  33619. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33620. * @param updatable defines if the mesh must be flagged as updatable
  33621. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33622. * @param earcutInjection can be used to inject your own earcut reference
  33623. * @returns a new Mesh
  33624. */
  33625. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33626. /**
  33627. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  33628. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  33629. * @param name defines the name of the mesh to create
  33630. * @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
  33631. * @param depth defines the height of extrusion
  33632. * @param scene defines the hosting scene
  33633. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33634. * @param updatable defines if the mesh must be flagged as updatable
  33635. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33636. * @param earcutInjection can be used to inject your own earcut reference
  33637. * @returns a new Mesh
  33638. */
  33639. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33640. /**
  33641. * Creates an extruded shape mesh.
  33642. * 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
  33643. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33644. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33645. * @param name defines the name of the mesh to create
  33646. * @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
  33647. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33648. * @param scale is the value to scale the shape
  33649. * @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
  33650. * @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
  33651. * @param scene defines the hosting scene
  33652. * @param updatable defines if the mesh must be flagged as updatable
  33653. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33654. * @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)
  33655. * @returns a new Mesh
  33656. */
  33657. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33658. /**
  33659. * Creates an custom extruded shape mesh.
  33660. * The custom extrusion is a parametric shape.
  33661. * It has no predefined shape. Its final shape will depend on the input parameters.
  33662. * Please consider using the same method from the MeshBuilder class instead
  33663. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33664. * @param name defines the name of the mesh to create
  33665. * @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
  33666. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33667. * @param scaleFunction is a custom Javascript function called on each path point
  33668. * @param rotationFunction is a custom Javascript function called on each path point
  33669. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  33670. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  33671. * @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
  33672. * @param scene defines the hosting scene
  33673. * @param updatable defines if the mesh must be flagged as updatable
  33674. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33675. * @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)
  33676. * @returns a new Mesh
  33677. */
  33678. 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;
  33679. /**
  33680. * Creates lathe mesh.
  33681. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  33682. * Please consider using the same method from the MeshBuilder class instead
  33683. * @param name defines the name of the mesh to create
  33684. * @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
  33685. * @param radius is the radius value of the lathe
  33686. * @param tessellation is the side number of the lathe.
  33687. * @param scene defines the hosting scene
  33688. * @param updatable defines if the mesh must be flagged as updatable
  33689. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33690. * @returns a new Mesh
  33691. */
  33692. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33693. /**
  33694. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  33695. * @param name defines the name of the mesh to create
  33696. * @param size sets the size (float) of both sides of the plane at once (default 1)
  33697. * @param scene defines the hosting scene
  33698. * @param updatable defines if the mesh must be flagged as updatable
  33699. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33700. * @returns a new Mesh
  33701. */
  33702. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33703. /**
  33704. * Creates a ground mesh.
  33705. * Please consider using the same method from the MeshBuilder class instead
  33706. * @param name defines the name of the mesh to create
  33707. * @param width set the width of the ground
  33708. * @param height set the height of the ground
  33709. * @param subdivisions sets the number of subdivisions per side
  33710. * @param scene defines the hosting scene
  33711. * @param updatable defines if the mesh must be flagged as updatable
  33712. * @returns a new Mesh
  33713. */
  33714. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  33715. /**
  33716. * Creates a tiled ground mesh.
  33717. * Please consider using the same method from the MeshBuilder class instead
  33718. * @param name defines the name of the mesh to create
  33719. * @param xmin set the ground minimum X coordinate
  33720. * @param zmin set the ground minimum Y coordinate
  33721. * @param xmax set the ground maximum X coordinate
  33722. * @param zmax set the ground maximum Z coordinate
  33723. * @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
  33724. * @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
  33725. * @param scene defines the hosting scene
  33726. * @param updatable defines if the mesh must be flagged as updatable
  33727. * @returns a new Mesh
  33728. */
  33729. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  33730. w: number;
  33731. h: number;
  33732. }, precision: {
  33733. w: number;
  33734. h: number;
  33735. }, scene: Scene, updatable?: boolean): Mesh;
  33736. /**
  33737. * Creates a ground mesh from a height map.
  33738. * Please consider using the same method from the MeshBuilder class instead
  33739. * @see https://doc.babylonjs.com/babylon101/height_map
  33740. * @param name defines the name of the mesh to create
  33741. * @param url sets the URL of the height map image resource
  33742. * @param width set the ground width size
  33743. * @param height set the ground height size
  33744. * @param subdivisions sets the number of subdivision per side
  33745. * @param minHeight is the minimum altitude on the ground
  33746. * @param maxHeight is the maximum altitude on the ground
  33747. * @param scene defines the hosting scene
  33748. * @param updatable defines if the mesh must be flagged as updatable
  33749. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  33750. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  33751. * @returns a new Mesh
  33752. */
  33753. 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;
  33754. /**
  33755. * Creates a tube mesh.
  33756. * The tube is a parametric shape.
  33757. * It has no predefined shape. Its final shape will depend on the input parameters.
  33758. * Please consider using the same method from the MeshBuilder class instead
  33759. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33760. * @param name defines the name of the mesh to create
  33761. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  33762. * @param radius sets the tube radius size
  33763. * @param tessellation is the number of sides on the tubular surface
  33764. * @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
  33765. * @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
  33766. * @param scene defines the hosting scene
  33767. * @param updatable defines if the mesh must be flagged as updatable
  33768. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33769. * @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)
  33770. * @returns a new Mesh
  33771. */
  33772. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  33773. (i: number, distance: number): number;
  33774. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33775. /**
  33776. * Creates a polyhedron mesh.
  33777. * Please consider using the same method from the MeshBuilder class instead.
  33778. * * 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
  33779. * * The parameter `size` (positive float, default 1) sets the polygon size
  33780. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  33781. * * 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`
  33782. * * 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
  33783. * * 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)`)
  33784. * * 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
  33785. * * 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
  33786. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33787. * * 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
  33788. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33789. * @param name defines the name of the mesh to create
  33790. * @param options defines the options used to create the mesh
  33791. * @param scene defines the hosting scene
  33792. * @returns a new Mesh
  33793. */
  33794. static CreatePolyhedron(name: string, options: {
  33795. type?: number;
  33796. size?: number;
  33797. sizeX?: number;
  33798. sizeY?: number;
  33799. sizeZ?: number;
  33800. custom?: any;
  33801. faceUV?: Vector4[];
  33802. faceColors?: Color4[];
  33803. updatable?: boolean;
  33804. sideOrientation?: number;
  33805. }, scene: Scene): Mesh;
  33806. /**
  33807. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  33808. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  33809. * * 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`)
  33810. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  33811. * * 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
  33812. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33813. * * 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
  33814. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33815. * @param name defines the name of the mesh
  33816. * @param options defines the options used to create the mesh
  33817. * @param scene defines the hosting scene
  33818. * @returns a new Mesh
  33819. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  33820. */
  33821. static CreateIcoSphere(name: string, options: {
  33822. radius?: number;
  33823. flat?: boolean;
  33824. subdivisions?: number;
  33825. sideOrientation?: number;
  33826. updatable?: boolean;
  33827. }, scene: Scene): Mesh;
  33828. /**
  33829. * Creates a decal mesh.
  33830. * Please consider using the same method from the MeshBuilder class instead.
  33831. * A decal is a mesh usually applied as a model onto the surface of another mesh
  33832. * @param name defines the name of the mesh
  33833. * @param sourceMesh defines the mesh receiving the decal
  33834. * @param position sets the position of the decal in world coordinates
  33835. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  33836. * @param size sets the decal scaling
  33837. * @param angle sets the angle to rotate the decal
  33838. * @returns a new Mesh
  33839. */
  33840. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  33841. /** Creates a Capsule Mesh
  33842. * @param name defines the name of the mesh.
  33843. * @param options the constructors options used to shape the mesh.
  33844. * @param scene defines the scene the mesh is scoped to.
  33845. * @returns the capsule mesh
  33846. * @see https://doc.babylonjs.com/how_to/capsule_shape
  33847. */
  33848. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  33849. /**
  33850. * Prepare internal position array for software CPU skinning
  33851. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  33852. */
  33853. setPositionsForCPUSkinning(): Float32Array;
  33854. /**
  33855. * Prepare internal normal array for software CPU skinning
  33856. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  33857. */
  33858. setNormalsForCPUSkinning(): Float32Array;
  33859. /**
  33860. * Updates the vertex buffer by applying transformation from the bones
  33861. * @param skeleton defines the skeleton to apply to current mesh
  33862. * @returns the current mesh
  33863. */
  33864. applySkeleton(skeleton: Skeleton): Mesh;
  33865. /**
  33866. * 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
  33867. * @param meshes defines the list of meshes to scan
  33868. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  33869. */
  33870. static MinMax(meshes: AbstractMesh[]): {
  33871. min: Vector3;
  33872. max: Vector3;
  33873. };
  33874. /**
  33875. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  33876. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  33877. * @returns a vector3
  33878. */
  33879. static Center(meshesOrMinMaxVector: {
  33880. min: Vector3;
  33881. max: Vector3;
  33882. } | AbstractMesh[]): Vector3;
  33883. /**
  33884. * Merge the array of meshes into a single mesh for performance reasons.
  33885. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  33886. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  33887. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  33888. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  33889. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  33890. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  33891. * @returns a new mesh
  33892. */
  33893. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  33894. /** @hidden */
  33895. addInstance(instance: InstancedMesh): void;
  33896. /** @hidden */
  33897. removeInstance(instance: InstancedMesh): void;
  33898. }
  33899. }
  33900. declare module BABYLON {
  33901. /**
  33902. * This is the base class of all the camera used in the application.
  33903. * @see https://doc.babylonjs.com/features/cameras
  33904. */
  33905. export class Camera extends Node {
  33906. /** @hidden */
  33907. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  33908. /**
  33909. * This is the default projection mode used by the cameras.
  33910. * It helps recreating a feeling of perspective and better appreciate depth.
  33911. * This is the best way to simulate real life cameras.
  33912. */
  33913. static readonly PERSPECTIVE_CAMERA: number;
  33914. /**
  33915. * This helps creating camera with an orthographic mode.
  33916. * 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.
  33917. */
  33918. static readonly ORTHOGRAPHIC_CAMERA: number;
  33919. /**
  33920. * This is the default FOV mode for perspective cameras.
  33921. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  33922. */
  33923. static readonly FOVMODE_VERTICAL_FIXED: number;
  33924. /**
  33925. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  33926. */
  33927. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  33928. /**
  33929. * This specifies ther is no need for a camera rig.
  33930. * Basically only one eye is rendered corresponding to the camera.
  33931. */
  33932. static readonly RIG_MODE_NONE: number;
  33933. /**
  33934. * Simulates a camera Rig with one blue eye and one red eye.
  33935. * This can be use with 3d blue and red glasses.
  33936. */
  33937. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  33938. /**
  33939. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  33940. */
  33941. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  33942. /**
  33943. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  33944. */
  33945. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  33946. /**
  33947. * Defines that both eyes of the camera will be rendered over under each other.
  33948. */
  33949. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  33950. /**
  33951. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  33952. */
  33953. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  33954. /**
  33955. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  33956. */
  33957. static readonly RIG_MODE_VR: number;
  33958. /**
  33959. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  33960. */
  33961. static readonly RIG_MODE_WEBVR: number;
  33962. /**
  33963. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  33964. */
  33965. static readonly RIG_MODE_CUSTOM: number;
  33966. /**
  33967. * Defines if by default attaching controls should prevent the default javascript event to continue.
  33968. */
  33969. static ForceAttachControlToAlwaysPreventDefault: boolean;
  33970. /**
  33971. * Define the input manager associated with the camera.
  33972. */
  33973. inputs: CameraInputsManager<Camera>;
  33974. /** @hidden */
  33975. _position: Vector3;
  33976. /**
  33977. * Define the current local position of the camera in the scene
  33978. */
  33979. get position(): Vector3;
  33980. set position(newPosition: Vector3);
  33981. protected _upVector: Vector3;
  33982. /**
  33983. * The vector the camera should consider as up.
  33984. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  33985. */
  33986. set upVector(vec: Vector3);
  33987. get upVector(): Vector3;
  33988. /**
  33989. * Define the current limit on the left side for an orthographic camera
  33990. * In scene unit
  33991. */
  33992. orthoLeft: Nullable<number>;
  33993. /**
  33994. * Define the current limit on the right side for an orthographic camera
  33995. * In scene unit
  33996. */
  33997. orthoRight: Nullable<number>;
  33998. /**
  33999. * Define the current limit on the bottom side for an orthographic camera
  34000. * In scene unit
  34001. */
  34002. orthoBottom: Nullable<number>;
  34003. /**
  34004. * Define the current limit on the top side for an orthographic camera
  34005. * In scene unit
  34006. */
  34007. orthoTop: Nullable<number>;
  34008. /**
  34009. * Field Of View is set in Radians. (default is 0.8)
  34010. */
  34011. fov: number;
  34012. /**
  34013. * Define the minimum distance the camera can see from.
  34014. * This is important to note that the depth buffer are not infinite and the closer it starts
  34015. * the more your scene might encounter depth fighting issue.
  34016. */
  34017. minZ: number;
  34018. /**
  34019. * Define the maximum distance the camera can see to.
  34020. * This is important to note that the depth buffer are not infinite and the further it end
  34021. * the more your scene might encounter depth fighting issue.
  34022. */
  34023. maxZ: number;
  34024. /**
  34025. * Define the default inertia of the camera.
  34026. * This helps giving a smooth feeling to the camera movement.
  34027. */
  34028. inertia: number;
  34029. /**
  34030. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  34031. */
  34032. mode: number;
  34033. /**
  34034. * Define whether the camera is intermediate.
  34035. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  34036. */
  34037. isIntermediate: boolean;
  34038. /**
  34039. * Define the viewport of the camera.
  34040. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  34041. */
  34042. viewport: Viewport;
  34043. /**
  34044. * Restricts the camera to viewing objects with the same layerMask.
  34045. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  34046. */
  34047. layerMask: number;
  34048. /**
  34049. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  34050. */
  34051. fovMode: number;
  34052. /**
  34053. * Rig mode of the camera.
  34054. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  34055. * This is normally controlled byt the camera themselves as internal use.
  34056. */
  34057. cameraRigMode: number;
  34058. /**
  34059. * Defines the distance between both "eyes" in case of a RIG
  34060. */
  34061. interaxialDistance: number;
  34062. /**
  34063. * Defines if stereoscopic rendering is done side by side or over under.
  34064. */
  34065. isStereoscopicSideBySide: boolean;
  34066. /**
  34067. * 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
  34068. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  34069. * else in the scene. (Eg. security camera)
  34070. *
  34071. * 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)
  34072. */
  34073. customRenderTargets: RenderTargetTexture[];
  34074. /**
  34075. * When set, the camera will render to this render target instead of the default canvas
  34076. *
  34077. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  34078. */
  34079. outputRenderTarget: Nullable<RenderTargetTexture>;
  34080. /**
  34081. * Observable triggered when the camera view matrix has changed.
  34082. */
  34083. onViewMatrixChangedObservable: Observable<Camera>;
  34084. /**
  34085. * Observable triggered when the camera Projection matrix has changed.
  34086. */
  34087. onProjectionMatrixChangedObservable: Observable<Camera>;
  34088. /**
  34089. * Observable triggered when the inputs have been processed.
  34090. */
  34091. onAfterCheckInputsObservable: Observable<Camera>;
  34092. /**
  34093. * Observable triggered when reset has been called and applied to the camera.
  34094. */
  34095. onRestoreStateObservable: Observable<Camera>;
  34096. /**
  34097. * Is this camera a part of a rig system?
  34098. */
  34099. isRigCamera: boolean;
  34100. /**
  34101. * If isRigCamera set to true this will be set with the parent camera.
  34102. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  34103. */
  34104. rigParent?: Camera;
  34105. /** @hidden */
  34106. _cameraRigParams: any;
  34107. /** @hidden */
  34108. _rigCameras: Camera[];
  34109. /** @hidden */
  34110. _rigPostProcess: Nullable<PostProcess>;
  34111. protected _webvrViewMatrix: Matrix;
  34112. /** @hidden */
  34113. _skipRendering: boolean;
  34114. /** @hidden */
  34115. _projectionMatrix: Matrix;
  34116. /** @hidden */
  34117. _postProcesses: Nullable<PostProcess>[];
  34118. /** @hidden */
  34119. _activeMeshes: SmartArray<AbstractMesh>;
  34120. protected _globalPosition: Vector3;
  34121. /** @hidden */
  34122. _computedViewMatrix: Matrix;
  34123. private _doNotComputeProjectionMatrix;
  34124. private _transformMatrix;
  34125. private _frustumPlanes;
  34126. private _refreshFrustumPlanes;
  34127. private _storedFov;
  34128. private _stateStored;
  34129. /**
  34130. * Instantiates a new camera object.
  34131. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  34132. * @see https://doc.babylonjs.com/features/cameras
  34133. * @param name Defines the name of the camera in the scene
  34134. * @param position Defines the position of the camera
  34135. * @param scene Defines the scene the camera belongs too
  34136. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  34137. */
  34138. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  34139. /**
  34140. * Store current camera state (fov, position, etc..)
  34141. * @returns the camera
  34142. */
  34143. storeState(): Camera;
  34144. /**
  34145. * Restores the camera state values if it has been stored. You must call storeState() first
  34146. */
  34147. protected _restoreStateValues(): boolean;
  34148. /**
  34149. * Restored camera state. You must call storeState() first.
  34150. * @returns true if restored and false otherwise
  34151. */
  34152. restoreState(): boolean;
  34153. /**
  34154. * Gets the class name of the camera.
  34155. * @returns the class name
  34156. */
  34157. getClassName(): string;
  34158. /** @hidden */
  34159. readonly _isCamera: boolean;
  34160. /**
  34161. * Gets a string representation of the camera useful for debug purpose.
  34162. * @param fullDetails Defines that a more verboe level of logging is required
  34163. * @returns the string representation
  34164. */
  34165. toString(fullDetails?: boolean): string;
  34166. /**
  34167. * Gets the current world space position of the camera.
  34168. */
  34169. get globalPosition(): Vector3;
  34170. /**
  34171. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  34172. * @returns the active meshe list
  34173. */
  34174. getActiveMeshes(): SmartArray<AbstractMesh>;
  34175. /**
  34176. * Check whether a mesh is part of the current active mesh list of the camera
  34177. * @param mesh Defines the mesh to check
  34178. * @returns true if active, false otherwise
  34179. */
  34180. isActiveMesh(mesh: Mesh): boolean;
  34181. /**
  34182. * Is this camera ready to be used/rendered
  34183. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  34184. * @return true if the camera is ready
  34185. */
  34186. isReady(completeCheck?: boolean): boolean;
  34187. /** @hidden */
  34188. _initCache(): void;
  34189. /** @hidden */
  34190. _updateCache(ignoreParentClass?: boolean): void;
  34191. /** @hidden */
  34192. _isSynchronized(): boolean;
  34193. /** @hidden */
  34194. _isSynchronizedViewMatrix(): boolean;
  34195. /** @hidden */
  34196. _isSynchronizedProjectionMatrix(): boolean;
  34197. /**
  34198. * Attach the input controls to a specific dom element to get the input from.
  34199. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34200. */
  34201. attachControl(noPreventDefault?: boolean): void;
  34202. /**
  34203. * Detach the current controls from the specified dom element.
  34204. */
  34205. detachControl(): void;
  34206. /**
  34207. * Update the camera state according to the different inputs gathered during the frame.
  34208. */
  34209. update(): void;
  34210. /** @hidden */
  34211. _checkInputs(): void;
  34212. /** @hidden */
  34213. get rigCameras(): Camera[];
  34214. /**
  34215. * Gets the post process used by the rig cameras
  34216. */
  34217. get rigPostProcess(): Nullable<PostProcess>;
  34218. /**
  34219. * Internal, gets the first post proces.
  34220. * @returns the first post process to be run on this camera.
  34221. */
  34222. _getFirstPostProcess(): Nullable<PostProcess>;
  34223. private _cascadePostProcessesToRigCams;
  34224. /**
  34225. * Attach a post process to the camera.
  34226. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  34227. * @param postProcess The post process to attach to the camera
  34228. * @param insertAt The position of the post process in case several of them are in use in the scene
  34229. * @returns the position the post process has been inserted at
  34230. */
  34231. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  34232. /**
  34233. * Detach a post process to the camera.
  34234. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  34235. * @param postProcess The post process to detach from the camera
  34236. */
  34237. detachPostProcess(postProcess: PostProcess): void;
  34238. /**
  34239. * Gets the current world matrix of the camera
  34240. */
  34241. getWorldMatrix(): Matrix;
  34242. /** @hidden */
  34243. _getViewMatrix(): Matrix;
  34244. /**
  34245. * Gets the current view matrix of the camera.
  34246. * @param force forces the camera to recompute the matrix without looking at the cached state
  34247. * @returns the view matrix
  34248. */
  34249. getViewMatrix(force?: boolean): Matrix;
  34250. /**
  34251. * Freeze the projection matrix.
  34252. * It will prevent the cache check of the camera projection compute and can speed up perf
  34253. * if no parameter of the camera are meant to change
  34254. * @param projection Defines manually a projection if necessary
  34255. */
  34256. freezeProjectionMatrix(projection?: Matrix): void;
  34257. /**
  34258. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  34259. */
  34260. unfreezeProjectionMatrix(): void;
  34261. /**
  34262. * Gets the current projection matrix of the camera.
  34263. * @param force forces the camera to recompute the matrix without looking at the cached state
  34264. * @returns the projection matrix
  34265. */
  34266. getProjectionMatrix(force?: boolean): Matrix;
  34267. /**
  34268. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  34269. * @returns a Matrix
  34270. */
  34271. getTransformationMatrix(): Matrix;
  34272. private _updateFrustumPlanes;
  34273. /**
  34274. * Checks if a cullable object (mesh...) is in the camera frustum
  34275. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  34276. * @param target The object to check
  34277. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  34278. * @returns true if the object is in frustum otherwise false
  34279. */
  34280. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  34281. /**
  34282. * Checks if a cullable object (mesh...) is in the camera frustum
  34283. * Unlike isInFrustum this cheks the full bounding box
  34284. * @param target The object to check
  34285. * @returns true if the object is in frustum otherwise false
  34286. */
  34287. isCompletelyInFrustum(target: ICullable): boolean;
  34288. /**
  34289. * Gets a ray in the forward direction from the camera.
  34290. * @param length Defines the length of the ray to create
  34291. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  34292. * @param origin Defines the start point of the ray which defaults to the camera position
  34293. * @returns the forward ray
  34294. */
  34295. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  34296. /**
  34297. * Gets a ray in the forward direction from the camera.
  34298. * @param refRay the ray to (re)use when setting the values
  34299. * @param length Defines the length of the ray to create
  34300. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  34301. * @param origin Defines the start point of the ray which defaults to the camera position
  34302. * @returns the forward ray
  34303. */
  34304. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  34305. /**
  34306. * Releases resources associated with this node.
  34307. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34308. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34309. */
  34310. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34311. /** @hidden */
  34312. _isLeftCamera: boolean;
  34313. /**
  34314. * Gets the left camera of a rig setup in case of Rigged Camera
  34315. */
  34316. get isLeftCamera(): boolean;
  34317. /** @hidden */
  34318. _isRightCamera: boolean;
  34319. /**
  34320. * Gets the right camera of a rig setup in case of Rigged Camera
  34321. */
  34322. get isRightCamera(): boolean;
  34323. /**
  34324. * Gets the left camera of a rig setup in case of Rigged Camera
  34325. */
  34326. get leftCamera(): Nullable<FreeCamera>;
  34327. /**
  34328. * Gets the right camera of a rig setup in case of Rigged Camera
  34329. */
  34330. get rightCamera(): Nullable<FreeCamera>;
  34331. /**
  34332. * Gets the left camera target of a rig setup in case of Rigged Camera
  34333. * @returns the target position
  34334. */
  34335. getLeftTarget(): Nullable<Vector3>;
  34336. /**
  34337. * Gets the right camera target of a rig setup in case of Rigged Camera
  34338. * @returns the target position
  34339. */
  34340. getRightTarget(): Nullable<Vector3>;
  34341. /**
  34342. * @hidden
  34343. */
  34344. setCameraRigMode(mode: number, rigParams: any): void;
  34345. /** @hidden */
  34346. static _setStereoscopicRigMode(camera: Camera): void;
  34347. /** @hidden */
  34348. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  34349. /** @hidden */
  34350. static _setVRRigMode(camera: Camera, rigParams: any): void;
  34351. /** @hidden */
  34352. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  34353. /** @hidden */
  34354. _getVRProjectionMatrix(): Matrix;
  34355. protected _updateCameraRotationMatrix(): void;
  34356. protected _updateWebVRCameraRotationMatrix(): void;
  34357. /**
  34358. * This function MUST be overwritten by the different WebVR cameras available.
  34359. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  34360. * @hidden
  34361. */
  34362. _getWebVRProjectionMatrix(): Matrix;
  34363. /**
  34364. * This function MUST be overwritten by the different WebVR cameras available.
  34365. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  34366. * @hidden
  34367. */
  34368. _getWebVRViewMatrix(): Matrix;
  34369. /** @hidden */
  34370. setCameraRigParameter(name: string, value: any): void;
  34371. /**
  34372. * needs to be overridden by children so sub has required properties to be copied
  34373. * @hidden
  34374. */
  34375. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  34376. /**
  34377. * May need to be overridden by children
  34378. * @hidden
  34379. */
  34380. _updateRigCameras(): void;
  34381. /** @hidden */
  34382. _setupInputs(): void;
  34383. /**
  34384. * Serialiaze the camera setup to a json represention
  34385. * @returns the JSON representation
  34386. */
  34387. serialize(): any;
  34388. /**
  34389. * Clones the current camera.
  34390. * @param name The cloned camera name
  34391. * @returns the cloned camera
  34392. */
  34393. clone(name: string): Camera;
  34394. /**
  34395. * Gets the direction of the camera relative to a given local axis.
  34396. * @param localAxis Defines the reference axis to provide a relative direction.
  34397. * @return the direction
  34398. */
  34399. getDirection(localAxis: Vector3): Vector3;
  34400. /**
  34401. * Returns the current camera absolute rotation
  34402. */
  34403. get absoluteRotation(): Quaternion;
  34404. /**
  34405. * Gets the direction of the camera relative to a given local axis into a passed vector.
  34406. * @param localAxis Defines the reference axis to provide a relative direction.
  34407. * @param result Defines the vector to store the result in
  34408. */
  34409. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  34410. /**
  34411. * Gets a camera constructor for a given camera type
  34412. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  34413. * @param name The name of the camera the result will be able to instantiate
  34414. * @param scene The scene the result will construct the camera in
  34415. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  34416. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  34417. * @returns a factory method to construc the camera
  34418. */
  34419. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  34420. /**
  34421. * Compute the world matrix of the camera.
  34422. * @returns the camera world matrix
  34423. */
  34424. computeWorldMatrix(): Matrix;
  34425. /**
  34426. * Parse a JSON and creates the camera from the parsed information
  34427. * @param parsedCamera The JSON to parse
  34428. * @param scene The scene to instantiate the camera in
  34429. * @returns the newly constructed camera
  34430. */
  34431. static Parse(parsedCamera: any, scene: Scene): Camera;
  34432. }
  34433. }
  34434. declare module BABYLON {
  34435. /**
  34436. * Class containing static functions to help procedurally build meshes
  34437. */
  34438. export class DiscBuilder {
  34439. /**
  34440. * Creates a plane polygonal mesh. By default, this is a disc
  34441. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  34442. * * 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
  34443. * * 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
  34444. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  34445. * * 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
  34446. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34447. * @param name defines the name of the mesh
  34448. * @param options defines the options used to create the mesh
  34449. * @param scene defines the hosting scene
  34450. * @returns the plane polygonal mesh
  34451. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  34452. */
  34453. static CreateDisc(name: string, options: {
  34454. radius?: number;
  34455. tessellation?: number;
  34456. arc?: number;
  34457. updatable?: boolean;
  34458. sideOrientation?: number;
  34459. frontUVs?: Vector4;
  34460. backUVs?: Vector4;
  34461. }, scene?: Nullable<Scene>): Mesh;
  34462. }
  34463. }
  34464. declare module BABYLON {
  34465. /**
  34466. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  34467. *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.
  34468. * The SPS is also a particle system. It provides some methods to manage the particles.
  34469. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  34470. *
  34471. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  34472. */
  34473. export class SolidParticleSystem implements IDisposable {
  34474. /**
  34475. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  34476. * Example : var p = SPS.particles[i];
  34477. */
  34478. particles: SolidParticle[];
  34479. /**
  34480. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  34481. */
  34482. nbParticles: number;
  34483. /**
  34484. * If the particles must ever face the camera (default false). Useful for planar particles.
  34485. */
  34486. billboard: boolean;
  34487. /**
  34488. * Recompute normals when adding a shape
  34489. */
  34490. recomputeNormals: boolean;
  34491. /**
  34492. * This a counter ofr your own usage. It's not set by any SPS functions.
  34493. */
  34494. counter: number;
  34495. /**
  34496. * The SPS name. This name is also given to the underlying mesh.
  34497. */
  34498. name: string;
  34499. /**
  34500. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  34501. */
  34502. mesh: Mesh;
  34503. /**
  34504. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  34505. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  34506. */
  34507. vars: any;
  34508. /**
  34509. * This array is populated when the SPS is set as 'pickable'.
  34510. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  34511. * Each element of this array is an object `{idx: int, faceId: int}`.
  34512. * `idx` is the picked particle index in the `SPS.particles` array
  34513. * `faceId` is the picked face index counted within this particle.
  34514. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  34515. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  34516. * Use the method SPS.pickedParticle(pickingInfo) instead.
  34517. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34518. */
  34519. pickedParticles: {
  34520. idx: number;
  34521. faceId: number;
  34522. }[];
  34523. /**
  34524. * This array is populated when the SPS is set as 'pickable'
  34525. * Each key of this array is a submesh index.
  34526. * Each element of this array is a second array defined like this :
  34527. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  34528. * Each element of this second array is an object `{idx: int, faceId: int}`.
  34529. * `idx` is the picked particle index in the `SPS.particles` array
  34530. * `faceId` is the picked face index counted within this particle.
  34531. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  34532. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34533. */
  34534. pickedBySubMesh: {
  34535. idx: number;
  34536. faceId: number;
  34537. }[][];
  34538. /**
  34539. * This array is populated when `enableDepthSort` is set to true.
  34540. * Each element of this array is an instance of the class DepthSortedParticle.
  34541. */
  34542. depthSortedParticles: DepthSortedParticle[];
  34543. /**
  34544. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  34545. * @hidden
  34546. */
  34547. _bSphereOnly: boolean;
  34548. /**
  34549. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  34550. * @hidden
  34551. */
  34552. _bSphereRadiusFactor: number;
  34553. private _scene;
  34554. private _positions;
  34555. private _indices;
  34556. private _normals;
  34557. private _colors;
  34558. private _uvs;
  34559. private _indices32;
  34560. private _positions32;
  34561. private _normals32;
  34562. private _fixedNormal32;
  34563. private _colors32;
  34564. private _uvs32;
  34565. private _index;
  34566. private _updatable;
  34567. private _pickable;
  34568. private _isVisibilityBoxLocked;
  34569. private _alwaysVisible;
  34570. private _depthSort;
  34571. private _expandable;
  34572. private _shapeCounter;
  34573. private _copy;
  34574. private _color;
  34575. private _computeParticleColor;
  34576. private _computeParticleTexture;
  34577. private _computeParticleRotation;
  34578. private _computeParticleVertex;
  34579. private _computeBoundingBox;
  34580. private _depthSortParticles;
  34581. private _camera;
  34582. private _mustUnrotateFixedNormals;
  34583. private _particlesIntersect;
  34584. private _needs32Bits;
  34585. private _isNotBuilt;
  34586. private _lastParticleId;
  34587. private _idxOfId;
  34588. private _multimaterialEnabled;
  34589. private _useModelMaterial;
  34590. private _indicesByMaterial;
  34591. private _materialIndexes;
  34592. private _depthSortFunction;
  34593. private _materialSortFunction;
  34594. private _materials;
  34595. private _multimaterial;
  34596. private _materialIndexesById;
  34597. private _defaultMaterial;
  34598. private _autoUpdateSubMeshes;
  34599. private _tmpVertex;
  34600. /**
  34601. * Creates a SPS (Solid Particle System) object.
  34602. * @param name (String) is the SPS name, this will be the underlying mesh name.
  34603. * @param scene (Scene) is the scene in which the SPS is added.
  34604. * @param options defines the options of the sps e.g.
  34605. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  34606. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  34607. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  34608. * * 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.
  34609. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  34610. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  34611. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  34612. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  34613. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  34614. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  34615. */
  34616. constructor(name: string, scene: Scene, options?: {
  34617. updatable?: boolean;
  34618. isPickable?: boolean;
  34619. enableDepthSort?: boolean;
  34620. particleIntersection?: boolean;
  34621. boundingSphereOnly?: boolean;
  34622. bSphereRadiusFactor?: number;
  34623. expandable?: boolean;
  34624. useModelMaterial?: boolean;
  34625. enableMultiMaterial?: boolean;
  34626. });
  34627. /**
  34628. * Builds the SPS underlying mesh. Returns a standard Mesh.
  34629. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  34630. * @returns the created mesh
  34631. */
  34632. buildMesh(): Mesh;
  34633. /**
  34634. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  34635. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  34636. * Thus the particles generated from `digest()` have their property `position` set yet.
  34637. * @param mesh ( Mesh ) is the mesh to be digested
  34638. * @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
  34639. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  34640. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  34641. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  34642. * @returns the current SPS
  34643. */
  34644. digest(mesh: Mesh, options?: {
  34645. facetNb?: number;
  34646. number?: number;
  34647. delta?: number;
  34648. storage?: [];
  34649. }): SolidParticleSystem;
  34650. /**
  34651. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  34652. * @hidden
  34653. */
  34654. private _unrotateFixedNormals;
  34655. /**
  34656. * Resets the temporary working copy particle
  34657. * @hidden
  34658. */
  34659. private _resetCopy;
  34660. /**
  34661. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  34662. * @param p the current index in the positions array to be updated
  34663. * @param ind the current index in the indices array
  34664. * @param shape a Vector3 array, the shape geometry
  34665. * @param positions the positions array to be updated
  34666. * @param meshInd the shape indices array
  34667. * @param indices the indices array to be updated
  34668. * @param meshUV the shape uv array
  34669. * @param uvs the uv array to be updated
  34670. * @param meshCol the shape color array
  34671. * @param colors the color array to be updated
  34672. * @param meshNor the shape normals array
  34673. * @param normals the normals array to be updated
  34674. * @param idx the particle index
  34675. * @param idxInShape the particle index in its shape
  34676. * @param options the addShape() method passed options
  34677. * @model the particle model
  34678. * @hidden
  34679. */
  34680. private _meshBuilder;
  34681. /**
  34682. * Returns a shape Vector3 array from positions float array
  34683. * @param positions float array
  34684. * @returns a vector3 array
  34685. * @hidden
  34686. */
  34687. private _posToShape;
  34688. /**
  34689. * Returns a shapeUV array from a float uvs (array deep copy)
  34690. * @param uvs as a float array
  34691. * @returns a shapeUV array
  34692. * @hidden
  34693. */
  34694. private _uvsToShapeUV;
  34695. /**
  34696. * Adds a new particle object in the particles array
  34697. * @param idx particle index in particles array
  34698. * @param id particle id
  34699. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  34700. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  34701. * @param model particle ModelShape object
  34702. * @param shapeId model shape identifier
  34703. * @param idxInShape index of the particle in the current model
  34704. * @param bInfo model bounding info object
  34705. * @param storage target storage array, if any
  34706. * @hidden
  34707. */
  34708. private _addParticle;
  34709. /**
  34710. * Adds some particles to the SPS from the model shape. Returns the shape id.
  34711. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  34712. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  34713. * @param nb (positive integer) the number of particles to be created from this model
  34714. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  34715. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  34716. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  34717. * @returns the number of shapes in the system
  34718. */
  34719. addShape(mesh: Mesh, nb: number, options?: {
  34720. positionFunction?: any;
  34721. vertexFunction?: any;
  34722. storage?: [];
  34723. }): number;
  34724. /**
  34725. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  34726. * @hidden
  34727. */
  34728. private _rebuildParticle;
  34729. /**
  34730. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  34731. * @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.
  34732. * @returns the SPS.
  34733. */
  34734. rebuildMesh(reset?: boolean): SolidParticleSystem;
  34735. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  34736. * Returns an array with the removed particles.
  34737. * 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.
  34738. * The SPS can't be empty so at least one particle needs to remain in place.
  34739. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  34740. * @param start index of the first particle to remove
  34741. * @param end index of the last particle to remove (included)
  34742. * @returns an array populated with the removed particles
  34743. */
  34744. removeParticles(start: number, end: number): SolidParticle[];
  34745. /**
  34746. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  34747. * @param solidParticleArray an array populated with Solid Particles objects
  34748. * @returns the SPS
  34749. */
  34750. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  34751. /**
  34752. * Creates a new particle and modifies the SPS mesh geometry :
  34753. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  34754. * - calls _addParticle() to populate the particle array
  34755. * factorized code from addShape() and insertParticlesFromArray()
  34756. * @param idx particle index in the particles array
  34757. * @param i particle index in its shape
  34758. * @param modelShape particle ModelShape object
  34759. * @param shape shape vertex array
  34760. * @param meshInd shape indices array
  34761. * @param meshUV shape uv array
  34762. * @param meshCol shape color array
  34763. * @param meshNor shape normals array
  34764. * @param bbInfo shape bounding info
  34765. * @param storage target particle storage
  34766. * @options addShape() passed options
  34767. * @hidden
  34768. */
  34769. private _insertNewParticle;
  34770. /**
  34771. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  34772. * This method calls `updateParticle()` for each particle of the SPS.
  34773. * For an animated SPS, it is usually called within the render loop.
  34774. * 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.
  34775. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  34776. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  34777. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  34778. * @returns the SPS.
  34779. */
  34780. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  34781. /**
  34782. * Disposes the SPS.
  34783. */
  34784. dispose(): void;
  34785. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  34786. * idx is the particle index in the SPS
  34787. * faceId is the picked face index counted within this particle.
  34788. * Returns null if the pickInfo can't identify a picked particle.
  34789. * @param pickingInfo (PickingInfo object)
  34790. * @returns {idx: number, faceId: number} or null
  34791. */
  34792. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  34793. idx: number;
  34794. faceId: number;
  34795. }>;
  34796. /**
  34797. * Returns a SolidParticle object from its identifier : particle.id
  34798. * @param id (integer) the particle Id
  34799. * @returns the searched particle or null if not found in the SPS.
  34800. */
  34801. getParticleById(id: number): Nullable<SolidParticle>;
  34802. /**
  34803. * Returns a new array populated with the particles having the passed shapeId.
  34804. * @param shapeId (integer) the shape identifier
  34805. * @returns a new solid particle array
  34806. */
  34807. getParticlesByShapeId(shapeId: number): SolidParticle[];
  34808. /**
  34809. * Populates the passed array "ref" with the particles having the passed shapeId.
  34810. * @param shapeId the shape identifier
  34811. * @returns the SPS
  34812. * @param ref
  34813. */
  34814. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  34815. /**
  34816. * Computes the required SubMeshes according the materials assigned to the particles.
  34817. * @returns the solid particle system.
  34818. * Does nothing if called before the SPS mesh is built.
  34819. */
  34820. computeSubMeshes(): SolidParticleSystem;
  34821. /**
  34822. * Sorts the solid particles by material when MultiMaterial is enabled.
  34823. * Updates the indices32 array.
  34824. * Updates the indicesByMaterial array.
  34825. * Updates the mesh indices array.
  34826. * @returns the SPS
  34827. * @hidden
  34828. */
  34829. private _sortParticlesByMaterial;
  34830. /**
  34831. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  34832. * @hidden
  34833. */
  34834. private _setMaterialIndexesById;
  34835. /**
  34836. * Returns an array with unique values of Materials from the passed array
  34837. * @param array the material array to be checked and filtered
  34838. * @hidden
  34839. */
  34840. private _filterUniqueMaterialId;
  34841. /**
  34842. * Sets a new Standard Material as _defaultMaterial if not already set.
  34843. * @hidden
  34844. */
  34845. private _setDefaultMaterial;
  34846. /**
  34847. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  34848. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34849. * @returns the SPS.
  34850. */
  34851. refreshVisibleSize(): SolidParticleSystem;
  34852. /**
  34853. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  34854. * @param size the size (float) of the visibility box
  34855. * note : this doesn't lock the SPS mesh bounding box.
  34856. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34857. */
  34858. setVisibilityBox(size: number): void;
  34859. /**
  34860. * Gets whether the SPS as always visible or not
  34861. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34862. */
  34863. get isAlwaysVisible(): boolean;
  34864. /**
  34865. * Sets the SPS as always visible or not
  34866. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34867. */
  34868. set isAlwaysVisible(val: boolean);
  34869. /**
  34870. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34871. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34872. */
  34873. set isVisibilityBoxLocked(val: boolean);
  34874. /**
  34875. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34876. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34877. */
  34878. get isVisibilityBoxLocked(): boolean;
  34879. /**
  34880. * Tells to `setParticles()` to compute the particle rotations or not.
  34881. * Default value : true. The SPS is faster when it's set to false.
  34882. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34883. */
  34884. set computeParticleRotation(val: boolean);
  34885. /**
  34886. * Tells to `setParticles()` to compute the particle colors or not.
  34887. * Default value : true. The SPS is faster when it's set to false.
  34888. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34889. */
  34890. set computeParticleColor(val: boolean);
  34891. set computeParticleTexture(val: boolean);
  34892. /**
  34893. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  34894. * Default value : false. The SPS is faster when it's set to false.
  34895. * Note : the particle custom vertex positions aren't stored values.
  34896. */
  34897. set computeParticleVertex(val: boolean);
  34898. /**
  34899. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  34900. */
  34901. set computeBoundingBox(val: boolean);
  34902. /**
  34903. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  34904. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34905. * Default : `true`
  34906. */
  34907. set depthSortParticles(val: boolean);
  34908. /**
  34909. * Gets if `setParticles()` computes the particle rotations or not.
  34910. * Default value : true. The SPS is faster when it's set to false.
  34911. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34912. */
  34913. get computeParticleRotation(): boolean;
  34914. /**
  34915. * Gets if `setParticles()` computes the particle colors or not.
  34916. * Default value : true. The SPS is faster when it's set to false.
  34917. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34918. */
  34919. get computeParticleColor(): boolean;
  34920. /**
  34921. * Gets if `setParticles()` computes the particle textures or not.
  34922. * Default value : true. The SPS is faster when it's set to false.
  34923. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  34924. */
  34925. get computeParticleTexture(): boolean;
  34926. /**
  34927. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  34928. * Default value : false. The SPS is faster when it's set to false.
  34929. * Note : the particle custom vertex positions aren't stored values.
  34930. */
  34931. get computeParticleVertex(): boolean;
  34932. /**
  34933. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  34934. */
  34935. get computeBoundingBox(): boolean;
  34936. /**
  34937. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  34938. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34939. * Default : `true`
  34940. */
  34941. get depthSortParticles(): boolean;
  34942. /**
  34943. * Gets if the SPS is created as expandable at construction time.
  34944. * Default : `false`
  34945. */
  34946. get expandable(): boolean;
  34947. /**
  34948. * Gets if the SPS supports the Multi Materials
  34949. */
  34950. get multimaterialEnabled(): boolean;
  34951. /**
  34952. * Gets if the SPS uses the model materials for its own multimaterial.
  34953. */
  34954. get useModelMaterial(): boolean;
  34955. /**
  34956. * The SPS used material array.
  34957. */
  34958. get materials(): Material[];
  34959. /**
  34960. * Sets the SPS MultiMaterial from the passed materials.
  34961. * Note : the passed array is internally copied and not used then by reference.
  34962. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  34963. */
  34964. setMultiMaterial(materials: Material[]): void;
  34965. /**
  34966. * The SPS computed multimaterial object
  34967. */
  34968. get multimaterial(): MultiMaterial;
  34969. set multimaterial(mm: MultiMaterial);
  34970. /**
  34971. * If the subMeshes must be updated on the next call to setParticles()
  34972. */
  34973. get autoUpdateSubMeshes(): boolean;
  34974. set autoUpdateSubMeshes(val: boolean);
  34975. /**
  34976. * This function does nothing. It may be overwritten to set all the particle first values.
  34977. * The SPS doesn't call this function, you may have to call it by your own.
  34978. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34979. */
  34980. initParticles(): void;
  34981. /**
  34982. * This function does nothing. It may be overwritten to recycle a particle.
  34983. * The SPS doesn't call this function, you may have to call it by your own.
  34984. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34985. * @param particle The particle to recycle
  34986. * @returns the recycled particle
  34987. */
  34988. recycleParticle(particle: SolidParticle): SolidParticle;
  34989. /**
  34990. * Updates a particle : this function should be overwritten by the user.
  34991. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  34992. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34993. * @example : just set a particle position or velocity and recycle conditions
  34994. * @param particle The particle to update
  34995. * @returns the updated particle
  34996. */
  34997. updateParticle(particle: SolidParticle): SolidParticle;
  34998. /**
  34999. * Updates a vertex of a particle : it can be overwritten by the user.
  35000. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  35001. * @param particle the current particle
  35002. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  35003. * @param pt the index of the current vertex in the particle shape
  35004. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  35005. * @example : just set a vertex particle position or color
  35006. * @returns the sps
  35007. */
  35008. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  35009. /**
  35010. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  35011. * This does nothing and may be overwritten by the user.
  35012. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35013. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35014. * @param update the boolean update value actually passed to setParticles()
  35015. */
  35016. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  35017. /**
  35018. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  35019. * This will be passed three parameters.
  35020. * This does nothing and may be overwritten by the user.
  35021. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35022. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35023. * @param update the boolean update value actually passed to setParticles()
  35024. */
  35025. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  35026. }
  35027. }
  35028. declare module BABYLON {
  35029. /**
  35030. * Represents one particle of a solid particle system.
  35031. */
  35032. export class SolidParticle {
  35033. /**
  35034. * particle global index
  35035. */
  35036. idx: number;
  35037. /**
  35038. * particle identifier
  35039. */
  35040. id: number;
  35041. /**
  35042. * The color of the particle
  35043. */
  35044. color: Nullable<Color4>;
  35045. /**
  35046. * The world space position of the particle.
  35047. */
  35048. position: Vector3;
  35049. /**
  35050. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  35051. */
  35052. rotation: Vector3;
  35053. /**
  35054. * The world space rotation quaternion of the particle.
  35055. */
  35056. rotationQuaternion: Nullable<Quaternion>;
  35057. /**
  35058. * The scaling of the particle.
  35059. */
  35060. scaling: Vector3;
  35061. /**
  35062. * The uvs of the particle.
  35063. */
  35064. uvs: Vector4;
  35065. /**
  35066. * The current speed of the particle.
  35067. */
  35068. velocity: Vector3;
  35069. /**
  35070. * The pivot point in the particle local space.
  35071. */
  35072. pivot: Vector3;
  35073. /**
  35074. * Must the particle be translated from its pivot point in its local space ?
  35075. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  35076. * Default : false
  35077. */
  35078. translateFromPivot: boolean;
  35079. /**
  35080. * Is the particle active or not ?
  35081. */
  35082. alive: boolean;
  35083. /**
  35084. * Is the particle visible or not ?
  35085. */
  35086. isVisible: boolean;
  35087. /**
  35088. * Index of this particle in the global "positions" array (Internal use)
  35089. * @hidden
  35090. */
  35091. _pos: number;
  35092. /**
  35093. * @hidden Index of this particle in the global "indices" array (Internal use)
  35094. */
  35095. _ind: number;
  35096. /**
  35097. * @hidden ModelShape of this particle (Internal use)
  35098. */
  35099. _model: ModelShape;
  35100. /**
  35101. * ModelShape id of this particle
  35102. */
  35103. shapeId: number;
  35104. /**
  35105. * Index of the particle in its shape id
  35106. */
  35107. idxInShape: number;
  35108. /**
  35109. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  35110. */
  35111. _modelBoundingInfo: BoundingInfo;
  35112. /**
  35113. * @hidden Particle BoundingInfo object (Internal use)
  35114. */
  35115. _boundingInfo: BoundingInfo;
  35116. /**
  35117. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  35118. */
  35119. _sps: SolidParticleSystem;
  35120. /**
  35121. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  35122. */
  35123. _stillInvisible: boolean;
  35124. /**
  35125. * @hidden Last computed particle rotation matrix
  35126. */
  35127. _rotationMatrix: number[];
  35128. /**
  35129. * Parent particle Id, if any.
  35130. * Default null.
  35131. */
  35132. parentId: Nullable<number>;
  35133. /**
  35134. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  35135. */
  35136. materialIndex: Nullable<number>;
  35137. /**
  35138. * Custom object or properties.
  35139. */
  35140. props: Nullable<any>;
  35141. /**
  35142. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  35143. * The possible values are :
  35144. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35145. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35146. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  35147. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  35148. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35149. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  35150. * */
  35151. cullingStrategy: number;
  35152. /**
  35153. * @hidden Internal global position in the SPS.
  35154. */
  35155. _globalPosition: Vector3;
  35156. /**
  35157. * Creates a Solid Particle object.
  35158. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  35159. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  35160. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  35161. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  35162. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  35163. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  35164. * @param shapeId (integer) is the model shape identifier in the SPS.
  35165. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  35166. * @param sps defines the sps it is associated to
  35167. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  35168. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  35169. */
  35170. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  35171. /**
  35172. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  35173. * @param target the particle target
  35174. * @returns the current particle
  35175. */
  35176. copyToRef(target: SolidParticle): SolidParticle;
  35177. /**
  35178. * Legacy support, changed scale to scaling
  35179. */
  35180. get scale(): Vector3;
  35181. /**
  35182. * Legacy support, changed scale to scaling
  35183. */
  35184. set scale(scale: Vector3);
  35185. /**
  35186. * Legacy support, changed quaternion to rotationQuaternion
  35187. */
  35188. get quaternion(): Nullable<Quaternion>;
  35189. /**
  35190. * Legacy support, changed quaternion to rotationQuaternion
  35191. */
  35192. set quaternion(q: Nullable<Quaternion>);
  35193. /**
  35194. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  35195. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  35196. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  35197. * @returns true if it intersects
  35198. */
  35199. intersectsMesh(target: Mesh | SolidParticle): boolean;
  35200. /**
  35201. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  35202. * A particle is in the frustum if its bounding box intersects the frustum
  35203. * @param frustumPlanes defines the frustum to test
  35204. * @returns true if the particle is in the frustum planes
  35205. */
  35206. isInFrustum(frustumPlanes: Plane[]): boolean;
  35207. /**
  35208. * get the rotation matrix of the particle
  35209. * @hidden
  35210. */
  35211. getRotationMatrix(m: Matrix): void;
  35212. }
  35213. /**
  35214. * Represents the shape of the model used by one particle of a solid particle system.
  35215. * SPS internal tool, don't use it manually.
  35216. */
  35217. export class ModelShape {
  35218. /**
  35219. * The shape id
  35220. * @hidden
  35221. */
  35222. shapeID: number;
  35223. /**
  35224. * flat array of model positions (internal use)
  35225. * @hidden
  35226. */
  35227. _shape: Vector3[];
  35228. /**
  35229. * flat array of model UVs (internal use)
  35230. * @hidden
  35231. */
  35232. _shapeUV: number[];
  35233. /**
  35234. * color array of the model
  35235. * @hidden
  35236. */
  35237. _shapeColors: number[];
  35238. /**
  35239. * indices array of the model
  35240. * @hidden
  35241. */
  35242. _indices: number[];
  35243. /**
  35244. * normals array of the model
  35245. * @hidden
  35246. */
  35247. _normals: number[];
  35248. /**
  35249. * length of the shape in the model indices array (internal use)
  35250. * @hidden
  35251. */
  35252. _indicesLength: number;
  35253. /**
  35254. * Custom position function (internal use)
  35255. * @hidden
  35256. */
  35257. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  35258. /**
  35259. * Custom vertex function (internal use)
  35260. * @hidden
  35261. */
  35262. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  35263. /**
  35264. * Model material (internal use)
  35265. * @hidden
  35266. */
  35267. _material: Nullable<Material>;
  35268. /**
  35269. * 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.
  35270. * SPS internal tool, don't use it manually.
  35271. * @hidden
  35272. */
  35273. 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>);
  35274. }
  35275. /**
  35276. * Represents a Depth Sorted Particle in the solid particle system.
  35277. * @hidden
  35278. */
  35279. export class DepthSortedParticle {
  35280. /**
  35281. * Particle index
  35282. */
  35283. idx: number;
  35284. /**
  35285. * Index of the particle in the "indices" array
  35286. */
  35287. ind: number;
  35288. /**
  35289. * Length of the particle shape in the "indices" array
  35290. */
  35291. indicesLength: number;
  35292. /**
  35293. * Squared distance from the particle to the camera
  35294. */
  35295. sqDistance: number;
  35296. /**
  35297. * Material index when used with MultiMaterials
  35298. */
  35299. materialIndex: number;
  35300. /**
  35301. * Creates a new sorted particle
  35302. * @param materialIndex
  35303. */
  35304. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  35305. }
  35306. /**
  35307. * Represents a solid particle vertex
  35308. */
  35309. export class SolidParticleVertex {
  35310. /**
  35311. * Vertex position
  35312. */
  35313. position: Vector3;
  35314. /**
  35315. * Vertex color
  35316. */
  35317. color: Color4;
  35318. /**
  35319. * Vertex UV
  35320. */
  35321. uv: Vector2;
  35322. /**
  35323. * Creates a new solid particle vertex
  35324. */
  35325. constructor();
  35326. /** Vertex x coordinate */
  35327. get x(): number;
  35328. set x(val: number);
  35329. /** Vertex y coordinate */
  35330. get y(): number;
  35331. set y(val: number);
  35332. /** Vertex z coordinate */
  35333. get z(): number;
  35334. set z(val: number);
  35335. }
  35336. }
  35337. declare module BABYLON {
  35338. /**
  35339. * @hidden
  35340. */
  35341. export class _MeshCollisionData {
  35342. _checkCollisions: boolean;
  35343. _collisionMask: number;
  35344. _collisionGroup: number;
  35345. _surroundingMeshes: Nullable<AbstractMesh[]>;
  35346. _collider: Nullable<Collider>;
  35347. _oldPositionForCollisions: Vector3;
  35348. _diffPositionForCollisions: Vector3;
  35349. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  35350. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  35351. _collisionResponse: boolean;
  35352. }
  35353. }
  35354. declare module BABYLON {
  35355. /** @hidden */
  35356. class _FacetDataStorage {
  35357. facetPositions: Vector3[];
  35358. facetNormals: Vector3[];
  35359. facetPartitioning: number[][];
  35360. facetNb: number;
  35361. partitioningSubdivisions: number;
  35362. partitioningBBoxRatio: number;
  35363. facetDataEnabled: boolean;
  35364. facetParameters: any;
  35365. bbSize: Vector3;
  35366. subDiv: {
  35367. max: number;
  35368. X: number;
  35369. Y: number;
  35370. Z: number;
  35371. };
  35372. facetDepthSort: boolean;
  35373. facetDepthSortEnabled: boolean;
  35374. depthSortedIndices: IndicesArray;
  35375. depthSortedFacets: {
  35376. ind: number;
  35377. sqDistance: number;
  35378. }[];
  35379. facetDepthSortFunction: (f1: {
  35380. ind: number;
  35381. sqDistance: number;
  35382. }, f2: {
  35383. ind: number;
  35384. sqDistance: number;
  35385. }) => number;
  35386. facetDepthSortFrom: Vector3;
  35387. facetDepthSortOrigin: Vector3;
  35388. invertedMatrix: Matrix;
  35389. }
  35390. /**
  35391. * @hidden
  35392. **/
  35393. class _InternalAbstractMeshDataInfo {
  35394. _hasVertexAlpha: boolean;
  35395. _useVertexColors: boolean;
  35396. _numBoneInfluencers: number;
  35397. _applyFog: boolean;
  35398. _receiveShadows: boolean;
  35399. _facetData: _FacetDataStorage;
  35400. _visibility: number;
  35401. _skeleton: Nullable<Skeleton>;
  35402. _layerMask: number;
  35403. _computeBonesUsingShaders: boolean;
  35404. _isActive: boolean;
  35405. _onlyForInstances: boolean;
  35406. _isActiveIntermediate: boolean;
  35407. _onlyForInstancesIntermediate: boolean;
  35408. _actAsRegularMesh: boolean;
  35409. _currentLOD: Nullable<AbstractMesh>;
  35410. }
  35411. /**
  35412. * Class used to store all common mesh properties
  35413. */
  35414. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  35415. /** No occlusion */
  35416. static OCCLUSION_TYPE_NONE: number;
  35417. /** Occlusion set to optimisitic */
  35418. static OCCLUSION_TYPE_OPTIMISTIC: number;
  35419. /** Occlusion set to strict */
  35420. static OCCLUSION_TYPE_STRICT: number;
  35421. /** Use an accurante occlusion algorithm */
  35422. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  35423. /** Use a conservative occlusion algorithm */
  35424. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  35425. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  35426. * Test order :
  35427. * Is the bounding sphere outside the frustum ?
  35428. * If not, are the bounding box vertices outside the frustum ?
  35429. * It not, then the cullable object is in the frustum.
  35430. */
  35431. static readonly CULLINGSTRATEGY_STANDARD: number;
  35432. /** Culling strategy : Bounding Sphere Only.
  35433. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  35434. * It's also less accurate than the standard because some not visible objects can still be selected.
  35435. * Test : is the bounding sphere outside the frustum ?
  35436. * If not, then the cullable object is in the frustum.
  35437. */
  35438. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  35439. /** Culling strategy : Optimistic Inclusion.
  35440. * This in an inclusion test first, then the standard exclusion test.
  35441. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  35442. * 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.
  35443. * Anyway, it's as accurate as the standard strategy.
  35444. * Test :
  35445. * Is the cullable object bounding sphere center in the frustum ?
  35446. * If not, apply the default culling strategy.
  35447. */
  35448. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  35449. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  35450. * This in an inclusion test first, then the bounding sphere only exclusion test.
  35451. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  35452. * 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.
  35453. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  35454. * Test :
  35455. * Is the cullable object bounding sphere center in the frustum ?
  35456. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  35457. */
  35458. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  35459. /**
  35460. * No billboard
  35461. */
  35462. static get BILLBOARDMODE_NONE(): number;
  35463. /** Billboard on X axis */
  35464. static get BILLBOARDMODE_X(): number;
  35465. /** Billboard on Y axis */
  35466. static get BILLBOARDMODE_Y(): number;
  35467. /** Billboard on Z axis */
  35468. static get BILLBOARDMODE_Z(): number;
  35469. /** Billboard on all axes */
  35470. static get BILLBOARDMODE_ALL(): number;
  35471. /** Billboard on using position instead of orientation */
  35472. static get BILLBOARDMODE_USE_POSITION(): number;
  35473. /** @hidden */
  35474. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  35475. /**
  35476. * The culling strategy to use to check whether the mesh must be rendered or not.
  35477. * This value can be changed at any time and will be used on the next render mesh selection.
  35478. * The possible values are :
  35479. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35480. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35481. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  35482. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  35483. * Please read each static variable documentation to get details about the culling process.
  35484. * */
  35485. cullingStrategy: number;
  35486. /**
  35487. * Gets the number of facets in the mesh
  35488. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35489. */
  35490. get facetNb(): number;
  35491. /**
  35492. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  35493. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35494. */
  35495. get partitioningSubdivisions(): number;
  35496. set partitioningSubdivisions(nb: number);
  35497. /**
  35498. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  35499. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  35500. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35501. */
  35502. get partitioningBBoxRatio(): number;
  35503. set partitioningBBoxRatio(ratio: number);
  35504. /**
  35505. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  35506. * Works only for updatable meshes.
  35507. * Doesn't work with multi-materials
  35508. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35509. */
  35510. get mustDepthSortFacets(): boolean;
  35511. set mustDepthSortFacets(sort: boolean);
  35512. /**
  35513. * The location (Vector3) where the facet depth sort must be computed from.
  35514. * By default, the active camera position.
  35515. * Used only when facet depth sort is enabled
  35516. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35517. */
  35518. get facetDepthSortFrom(): Vector3;
  35519. set facetDepthSortFrom(location: Vector3);
  35520. /**
  35521. * gets a boolean indicating if facetData is enabled
  35522. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35523. */
  35524. get isFacetDataEnabled(): boolean;
  35525. /** @hidden */
  35526. _updateNonUniformScalingState(value: boolean): boolean;
  35527. /**
  35528. * An event triggered when this mesh collides with another one
  35529. */
  35530. onCollideObservable: Observable<AbstractMesh>;
  35531. /** Set a function to call when this mesh collides with another one */
  35532. set onCollide(callback: () => void);
  35533. /**
  35534. * An event triggered when the collision's position changes
  35535. */
  35536. onCollisionPositionChangeObservable: Observable<Vector3>;
  35537. /** Set a function to call when the collision's position changes */
  35538. set onCollisionPositionChange(callback: () => void);
  35539. /**
  35540. * An event triggered when material is changed
  35541. */
  35542. onMaterialChangedObservable: Observable<AbstractMesh>;
  35543. /**
  35544. * Gets or sets the orientation for POV movement & rotation
  35545. */
  35546. definedFacingForward: boolean;
  35547. /** @hidden */
  35548. _occlusionQuery: Nullable<WebGLQuery>;
  35549. /** @hidden */
  35550. _renderingGroup: Nullable<RenderingGroup>;
  35551. /**
  35552. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  35553. */
  35554. get visibility(): number;
  35555. /**
  35556. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  35557. */
  35558. set visibility(value: number);
  35559. /** Gets or sets the alpha index used to sort transparent meshes
  35560. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  35561. */
  35562. alphaIndex: number;
  35563. /**
  35564. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  35565. */
  35566. isVisible: boolean;
  35567. /**
  35568. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  35569. */
  35570. isPickable: boolean;
  35571. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  35572. showSubMeshesBoundingBox: boolean;
  35573. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  35574. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  35575. */
  35576. isBlocker: boolean;
  35577. /**
  35578. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  35579. */
  35580. enablePointerMoveEvents: boolean;
  35581. private _renderingGroupId;
  35582. /**
  35583. * Specifies the rendering group id for this mesh (0 by default)
  35584. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  35585. */
  35586. get renderingGroupId(): number;
  35587. set renderingGroupId(value: number);
  35588. private _material;
  35589. /** Gets or sets current material */
  35590. get material(): Nullable<Material>;
  35591. set material(value: Nullable<Material>);
  35592. /**
  35593. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  35594. * @see https://doc.babylonjs.com/babylon101/shadows
  35595. */
  35596. get receiveShadows(): boolean;
  35597. set receiveShadows(value: boolean);
  35598. /** Defines color to use when rendering outline */
  35599. outlineColor: Color3;
  35600. /** Define width to use when rendering outline */
  35601. outlineWidth: number;
  35602. /** Defines color to use when rendering overlay */
  35603. overlayColor: Color3;
  35604. /** Defines alpha to use when rendering overlay */
  35605. overlayAlpha: number;
  35606. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  35607. get hasVertexAlpha(): boolean;
  35608. set hasVertexAlpha(value: boolean);
  35609. /** 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) */
  35610. get useVertexColors(): boolean;
  35611. set useVertexColors(value: boolean);
  35612. /**
  35613. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  35614. */
  35615. get computeBonesUsingShaders(): boolean;
  35616. set computeBonesUsingShaders(value: boolean);
  35617. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  35618. get numBoneInfluencers(): number;
  35619. set numBoneInfluencers(value: number);
  35620. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  35621. get applyFog(): boolean;
  35622. set applyFog(value: boolean);
  35623. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  35624. useOctreeForRenderingSelection: boolean;
  35625. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  35626. useOctreeForPicking: boolean;
  35627. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  35628. useOctreeForCollisions: boolean;
  35629. /**
  35630. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  35631. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  35632. */
  35633. get layerMask(): number;
  35634. set layerMask(value: number);
  35635. /**
  35636. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  35637. */
  35638. alwaysSelectAsActiveMesh: boolean;
  35639. /**
  35640. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  35641. */
  35642. doNotSyncBoundingInfo: boolean;
  35643. /**
  35644. * Gets or sets the current action manager
  35645. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  35646. */
  35647. actionManager: Nullable<AbstractActionManager>;
  35648. private _meshCollisionData;
  35649. /**
  35650. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  35651. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35652. */
  35653. ellipsoid: Vector3;
  35654. /**
  35655. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  35656. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35657. */
  35658. ellipsoidOffset: Vector3;
  35659. /**
  35660. * Gets or sets a collision mask used to mask collisions (default is -1).
  35661. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  35662. */
  35663. get collisionMask(): number;
  35664. set collisionMask(mask: number);
  35665. /**
  35666. * Gets or sets a collision response flag (default is true).
  35667. * when collisionResponse is false, events are still triggered but colliding entity has no response
  35668. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  35669. * to respond to the collision.
  35670. */
  35671. get collisionResponse(): boolean;
  35672. set collisionResponse(response: boolean);
  35673. /**
  35674. * Gets or sets the current collision group mask (-1 by default).
  35675. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  35676. */
  35677. get collisionGroup(): number;
  35678. set collisionGroup(mask: number);
  35679. /**
  35680. * Gets or sets current surrounding meshes (null by default).
  35681. *
  35682. * By default collision detection is tested against every mesh in the scene.
  35683. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  35684. * meshes will be tested for the collision.
  35685. *
  35686. * Note: if set to an empty array no collision will happen when this mesh is moved.
  35687. */
  35688. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  35689. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  35690. /**
  35691. * Defines edge width used when edgesRenderer is enabled
  35692. * @see https://www.babylonjs-playground.com/#10OJSG#13
  35693. */
  35694. edgesWidth: number;
  35695. /**
  35696. * Defines edge color used when edgesRenderer is enabled
  35697. * @see https://www.babylonjs-playground.com/#10OJSG#13
  35698. */
  35699. edgesColor: Color4;
  35700. /** @hidden */
  35701. _edgesRenderer: Nullable<IEdgesRenderer>;
  35702. /** @hidden */
  35703. _masterMesh: Nullable<AbstractMesh>;
  35704. /** @hidden */
  35705. _boundingInfo: Nullable<BoundingInfo>;
  35706. /** @hidden */
  35707. _renderId: number;
  35708. /**
  35709. * Gets or sets the list of subMeshes
  35710. * @see https://doc.babylonjs.com/how_to/multi_materials
  35711. */
  35712. subMeshes: SubMesh[];
  35713. /** @hidden */
  35714. _intersectionsInProgress: AbstractMesh[];
  35715. /** @hidden */
  35716. _unIndexed: boolean;
  35717. /** @hidden */
  35718. _lightSources: Light[];
  35719. /** Gets the list of lights affecting that mesh */
  35720. get lightSources(): Light[];
  35721. /** @hidden */
  35722. get _positions(): Nullable<Vector3[]>;
  35723. /** @hidden */
  35724. _waitingData: {
  35725. lods: Nullable<any>;
  35726. actions: Nullable<any>;
  35727. freezeWorldMatrix: Nullable<boolean>;
  35728. };
  35729. /** @hidden */
  35730. _bonesTransformMatrices: Nullable<Float32Array>;
  35731. /** @hidden */
  35732. _transformMatrixTexture: Nullable<RawTexture>;
  35733. /**
  35734. * Gets or sets a skeleton to apply skining transformations
  35735. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35736. */
  35737. set skeleton(value: Nullable<Skeleton>);
  35738. get skeleton(): Nullable<Skeleton>;
  35739. /**
  35740. * An event triggered when the mesh is rebuilt.
  35741. */
  35742. onRebuildObservable: Observable<AbstractMesh>;
  35743. /**
  35744. * Creates a new AbstractMesh
  35745. * @param name defines the name of the mesh
  35746. * @param scene defines the hosting scene
  35747. */
  35748. constructor(name: string, scene?: Nullable<Scene>);
  35749. /**
  35750. * Returns the string "AbstractMesh"
  35751. * @returns "AbstractMesh"
  35752. */
  35753. getClassName(): string;
  35754. /**
  35755. * Gets a string representation of the current mesh
  35756. * @param fullDetails defines a boolean indicating if full details must be included
  35757. * @returns a string representation of the current mesh
  35758. */
  35759. toString(fullDetails?: boolean): string;
  35760. /**
  35761. * @hidden
  35762. */
  35763. protected _getEffectiveParent(): Nullable<Node>;
  35764. /** @hidden */
  35765. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  35766. /** @hidden */
  35767. _rebuild(): void;
  35768. /** @hidden */
  35769. _resyncLightSources(): void;
  35770. /** @hidden */
  35771. _resyncLightSource(light: Light): void;
  35772. /** @hidden */
  35773. _unBindEffect(): void;
  35774. /** @hidden */
  35775. _removeLightSource(light: Light, dispose: boolean): void;
  35776. private _markSubMeshesAsDirty;
  35777. /** @hidden */
  35778. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  35779. /** @hidden */
  35780. _markSubMeshesAsAttributesDirty(): void;
  35781. /** @hidden */
  35782. _markSubMeshesAsMiscDirty(): void;
  35783. /**
  35784. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  35785. */
  35786. get scaling(): Vector3;
  35787. set scaling(newScaling: Vector3);
  35788. /**
  35789. * Returns true if the mesh is blocked. Implemented by child classes
  35790. */
  35791. get isBlocked(): boolean;
  35792. /**
  35793. * Returns the mesh itself by default. Implemented by child classes
  35794. * @param camera defines the camera to use to pick the right LOD level
  35795. * @returns the currentAbstractMesh
  35796. */
  35797. getLOD(camera: Camera): Nullable<AbstractMesh>;
  35798. /**
  35799. * Returns 0 by default. Implemented by child classes
  35800. * @returns an integer
  35801. */
  35802. getTotalVertices(): number;
  35803. /**
  35804. * Returns a positive integer : the total number of indices in this mesh geometry.
  35805. * @returns the numner of indices or zero if the mesh has no geometry.
  35806. */
  35807. getTotalIndices(): number;
  35808. /**
  35809. * Returns null by default. Implemented by child classes
  35810. * @returns null
  35811. */
  35812. getIndices(): Nullable<IndicesArray>;
  35813. /**
  35814. * Returns the array of the requested vertex data kind. Implemented by child classes
  35815. * @param kind defines the vertex data kind to use
  35816. * @returns null
  35817. */
  35818. getVerticesData(kind: string): Nullable<FloatArray>;
  35819. /**
  35820. * Sets the vertex data of the mesh geometry for the requested `kind`.
  35821. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  35822. * Note that a new underlying VertexBuffer object is created each call.
  35823. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  35824. * @param kind defines vertex data kind:
  35825. * * VertexBuffer.PositionKind
  35826. * * VertexBuffer.UVKind
  35827. * * VertexBuffer.UV2Kind
  35828. * * VertexBuffer.UV3Kind
  35829. * * VertexBuffer.UV4Kind
  35830. * * VertexBuffer.UV5Kind
  35831. * * VertexBuffer.UV6Kind
  35832. * * VertexBuffer.ColorKind
  35833. * * VertexBuffer.MatricesIndicesKind
  35834. * * VertexBuffer.MatricesIndicesExtraKind
  35835. * * VertexBuffer.MatricesWeightsKind
  35836. * * VertexBuffer.MatricesWeightsExtraKind
  35837. * @param data defines the data source
  35838. * @param updatable defines if the data must be flagged as updatable (or static)
  35839. * @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
  35840. * @returns the current mesh
  35841. */
  35842. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  35843. /**
  35844. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  35845. * If the mesh has no geometry, it is simply returned as it is.
  35846. * @param kind defines vertex data kind:
  35847. * * VertexBuffer.PositionKind
  35848. * * VertexBuffer.UVKind
  35849. * * VertexBuffer.UV2Kind
  35850. * * VertexBuffer.UV3Kind
  35851. * * VertexBuffer.UV4Kind
  35852. * * VertexBuffer.UV5Kind
  35853. * * VertexBuffer.UV6Kind
  35854. * * VertexBuffer.ColorKind
  35855. * * VertexBuffer.MatricesIndicesKind
  35856. * * VertexBuffer.MatricesIndicesExtraKind
  35857. * * VertexBuffer.MatricesWeightsKind
  35858. * * VertexBuffer.MatricesWeightsExtraKind
  35859. * @param data defines the data source
  35860. * @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
  35861. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  35862. * @returns the current mesh
  35863. */
  35864. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  35865. /**
  35866. * Sets the mesh indices,
  35867. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  35868. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  35869. * @param totalVertices Defines the total number of vertices
  35870. * @returns the current mesh
  35871. */
  35872. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  35873. /**
  35874. * Gets a boolean indicating if specific vertex data is present
  35875. * @param kind defines the vertex data kind to use
  35876. * @returns true is data kind is present
  35877. */
  35878. isVerticesDataPresent(kind: string): boolean;
  35879. /**
  35880. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  35881. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  35882. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  35883. * @returns a BoundingInfo
  35884. */
  35885. getBoundingInfo(): BoundingInfo;
  35886. /**
  35887. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  35888. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  35889. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  35890. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  35891. * @returns the current mesh
  35892. */
  35893. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  35894. /**
  35895. * Overwrite the current bounding info
  35896. * @param boundingInfo defines the new bounding info
  35897. * @returns the current mesh
  35898. */
  35899. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  35900. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  35901. get useBones(): boolean;
  35902. /** @hidden */
  35903. _preActivate(): void;
  35904. /** @hidden */
  35905. _preActivateForIntermediateRendering(renderId: number): void;
  35906. /** @hidden */
  35907. _activate(renderId: number, intermediateRendering: boolean): boolean;
  35908. /** @hidden */
  35909. _postActivate(): void;
  35910. /** @hidden */
  35911. _freeze(): void;
  35912. /** @hidden */
  35913. _unFreeze(): void;
  35914. /**
  35915. * Gets the current world matrix
  35916. * @returns a Matrix
  35917. */
  35918. getWorldMatrix(): Matrix;
  35919. /** @hidden */
  35920. _getWorldMatrixDeterminant(): number;
  35921. /**
  35922. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  35923. */
  35924. get isAnInstance(): boolean;
  35925. /**
  35926. * Gets a boolean indicating if this mesh has instances
  35927. */
  35928. get hasInstances(): boolean;
  35929. /**
  35930. * Gets a boolean indicating if this mesh has thin instances
  35931. */
  35932. get hasThinInstances(): boolean;
  35933. /**
  35934. * Perform relative position change from the point of view of behind the front of the mesh.
  35935. * This is performed taking into account the meshes current rotation, so you do not have to care.
  35936. * Supports definition of mesh facing forward or backward
  35937. * @param amountRight defines the distance on the right axis
  35938. * @param amountUp defines the distance on the up axis
  35939. * @param amountForward defines the distance on the forward axis
  35940. * @returns the current mesh
  35941. */
  35942. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  35943. /**
  35944. * Calculate relative position change from the point of view of behind the front of the mesh.
  35945. * This is performed taking into account the meshes current rotation, so you do not have to care.
  35946. * Supports definition of mesh facing forward or backward
  35947. * @param amountRight defines the distance on the right axis
  35948. * @param amountUp defines the distance on the up axis
  35949. * @param amountForward defines the distance on the forward axis
  35950. * @returns the new displacement vector
  35951. */
  35952. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  35953. /**
  35954. * Perform relative rotation change from the point of view of behind the front of the mesh.
  35955. * Supports definition of mesh facing forward or backward
  35956. * @param flipBack defines the flip
  35957. * @param twirlClockwise defines the twirl
  35958. * @param tiltRight defines the tilt
  35959. * @returns the current mesh
  35960. */
  35961. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  35962. /**
  35963. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  35964. * Supports definition of mesh facing forward or backward.
  35965. * @param flipBack defines the flip
  35966. * @param twirlClockwise defines the twirl
  35967. * @param tiltRight defines the tilt
  35968. * @returns the new rotation vector
  35969. */
  35970. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  35971. /**
  35972. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  35973. * This means the mesh underlying bounding box and sphere are recomputed.
  35974. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  35975. * @returns the current mesh
  35976. */
  35977. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  35978. /** @hidden */
  35979. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  35980. /** @hidden */
  35981. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  35982. /** @hidden */
  35983. _updateBoundingInfo(): AbstractMesh;
  35984. /** @hidden */
  35985. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  35986. /** @hidden */
  35987. protected _afterComputeWorldMatrix(): void;
  35988. /** @hidden */
  35989. get _effectiveMesh(): AbstractMesh;
  35990. /**
  35991. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  35992. * A mesh is in the frustum if its bounding box intersects the frustum
  35993. * @param frustumPlanes defines the frustum to test
  35994. * @returns true if the mesh is in the frustum planes
  35995. */
  35996. isInFrustum(frustumPlanes: Plane[]): boolean;
  35997. /**
  35998. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  35999. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  36000. * @param frustumPlanes defines the frustum to test
  36001. * @returns true if the mesh is completely in the frustum planes
  36002. */
  36003. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  36004. /**
  36005. * True if the mesh intersects another mesh or a SolidParticle object
  36006. * @param mesh defines a target mesh or SolidParticle to test
  36007. * @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)
  36008. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  36009. * @returns true if there is an intersection
  36010. */
  36011. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  36012. /**
  36013. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  36014. * @param point defines the point to test
  36015. * @returns true if there is an intersection
  36016. */
  36017. intersectsPoint(point: Vector3): boolean;
  36018. /**
  36019. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  36020. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36021. */
  36022. get checkCollisions(): boolean;
  36023. set checkCollisions(collisionEnabled: boolean);
  36024. /**
  36025. * Gets Collider object used to compute collisions (not physics)
  36026. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36027. */
  36028. get collider(): Nullable<Collider>;
  36029. /**
  36030. * Move the mesh using collision engine
  36031. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36032. * @param displacement defines the requested displacement vector
  36033. * @returns the current mesh
  36034. */
  36035. moveWithCollisions(displacement: Vector3): AbstractMesh;
  36036. private _onCollisionPositionChange;
  36037. /** @hidden */
  36038. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  36039. /** @hidden */
  36040. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  36041. /** @hidden */
  36042. _checkCollision(collider: Collider): AbstractMesh;
  36043. /** @hidden */
  36044. _generatePointsArray(): boolean;
  36045. /**
  36046. * Checks if the passed Ray intersects with the mesh
  36047. * @param ray defines the ray to use
  36048. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  36049. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36050. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  36051. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  36052. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  36053. * @returns the picking info
  36054. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  36055. */
  36056. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  36057. /**
  36058. * Clones the current mesh
  36059. * @param name defines the mesh name
  36060. * @param newParent defines the new mesh parent
  36061. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  36062. * @returns the new mesh
  36063. */
  36064. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  36065. /**
  36066. * Disposes all the submeshes of the current meshnp
  36067. * @returns the current mesh
  36068. */
  36069. releaseSubMeshes(): AbstractMesh;
  36070. /**
  36071. * Releases resources associated with this abstract mesh.
  36072. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  36073. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  36074. */
  36075. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  36076. /**
  36077. * Adds the passed mesh as a child to the current mesh
  36078. * @param mesh defines the child mesh
  36079. * @returns the current mesh
  36080. */
  36081. addChild(mesh: AbstractMesh): AbstractMesh;
  36082. /**
  36083. * Removes the passed mesh from the current mesh children list
  36084. * @param mesh defines the child mesh
  36085. * @returns the current mesh
  36086. */
  36087. removeChild(mesh: AbstractMesh): AbstractMesh;
  36088. /** @hidden */
  36089. private _initFacetData;
  36090. /**
  36091. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  36092. * This method can be called within the render loop.
  36093. * 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
  36094. * @returns the current mesh
  36095. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36096. */
  36097. updateFacetData(): AbstractMesh;
  36098. /**
  36099. * Returns the facetLocalNormals array.
  36100. * The normals are expressed in the mesh local spac
  36101. * @returns an array of Vector3
  36102. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36103. */
  36104. getFacetLocalNormals(): Vector3[];
  36105. /**
  36106. * Returns the facetLocalPositions array.
  36107. * The facet positions are expressed in the mesh local space
  36108. * @returns an array of Vector3
  36109. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36110. */
  36111. getFacetLocalPositions(): Vector3[];
  36112. /**
  36113. * Returns the facetLocalPartioning array
  36114. * @returns an array of array of numbers
  36115. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36116. */
  36117. getFacetLocalPartitioning(): number[][];
  36118. /**
  36119. * Returns the i-th facet position in the world system.
  36120. * This method allocates a new Vector3 per call
  36121. * @param i defines the facet index
  36122. * @returns a new Vector3
  36123. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36124. */
  36125. getFacetPosition(i: number): Vector3;
  36126. /**
  36127. * Sets the reference Vector3 with the i-th facet position in the world system
  36128. * @param i defines the facet index
  36129. * @param ref defines the target vector
  36130. * @returns the current mesh
  36131. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36132. */
  36133. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  36134. /**
  36135. * Returns the i-th facet normal in the world system.
  36136. * This method allocates a new Vector3 per call
  36137. * @param i defines the facet index
  36138. * @returns a new Vector3
  36139. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36140. */
  36141. getFacetNormal(i: number): Vector3;
  36142. /**
  36143. * Sets the reference Vector3 with the i-th facet normal in the world system
  36144. * @param i defines the facet index
  36145. * @param ref defines the target vector
  36146. * @returns the current mesh
  36147. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36148. */
  36149. getFacetNormalToRef(i: number, ref: Vector3): this;
  36150. /**
  36151. * 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)
  36152. * @param x defines x coordinate
  36153. * @param y defines y coordinate
  36154. * @param z defines z coordinate
  36155. * @returns the array of facet indexes
  36156. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36157. */
  36158. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  36159. /**
  36160. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  36161. * @param projected sets as the (x,y,z) world projection on the facet
  36162. * @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
  36163. * @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
  36164. * @param x defines x coordinate
  36165. * @param y defines y coordinate
  36166. * @param z defines z coordinate
  36167. * @returns the face index if found (or null instead)
  36168. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36169. */
  36170. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  36171. /**
  36172. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  36173. * @param projected sets as the (x,y,z) local projection on the facet
  36174. * @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
  36175. * @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
  36176. * @param x defines x coordinate
  36177. * @param y defines y coordinate
  36178. * @param z defines z coordinate
  36179. * @returns the face index if found (or null instead)
  36180. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36181. */
  36182. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  36183. /**
  36184. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  36185. * @returns the parameters
  36186. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36187. */
  36188. getFacetDataParameters(): any;
  36189. /**
  36190. * Disables the feature FacetData and frees the related memory
  36191. * @returns the current mesh
  36192. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36193. */
  36194. disableFacetData(): AbstractMesh;
  36195. /**
  36196. * Updates the AbstractMesh indices array
  36197. * @param indices defines the data source
  36198. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  36199. * @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)
  36200. * @returns the current mesh
  36201. */
  36202. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  36203. /**
  36204. * Creates new normals data for the mesh
  36205. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  36206. * @returns the current mesh
  36207. */
  36208. createNormals(updatable: boolean): AbstractMesh;
  36209. /**
  36210. * Align the mesh with a normal
  36211. * @param normal defines the normal to use
  36212. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  36213. * @returns the current mesh
  36214. */
  36215. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  36216. /** @hidden */
  36217. _checkOcclusionQuery(): boolean;
  36218. /**
  36219. * Disables the mesh edge rendering mode
  36220. * @returns the currentAbstractMesh
  36221. */
  36222. disableEdgesRendering(): AbstractMesh;
  36223. /**
  36224. * Enables the edge rendering mode on the mesh.
  36225. * This mode makes the mesh edges visible
  36226. * @param epsilon defines the maximal distance between two angles to detect a face
  36227. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  36228. * @returns the currentAbstractMesh
  36229. * @see https://www.babylonjs-playground.com/#19O9TU#0
  36230. */
  36231. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  36232. /**
  36233. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  36234. * @returns an array of particle systems in the scene that use the mesh as an emitter
  36235. */
  36236. getConnectedParticleSystems(): IParticleSystem[];
  36237. }
  36238. }
  36239. declare module BABYLON {
  36240. /**
  36241. * Interface used to define ActionEvent
  36242. */
  36243. export interface IActionEvent {
  36244. /** The mesh or sprite that triggered the action */
  36245. source: any;
  36246. /** The X mouse cursor position at the time of the event */
  36247. pointerX: number;
  36248. /** The Y mouse cursor position at the time of the event */
  36249. pointerY: number;
  36250. /** The mesh that is currently pointed at (can be null) */
  36251. meshUnderPointer: Nullable<AbstractMesh>;
  36252. /** the original (browser) event that triggered the ActionEvent */
  36253. sourceEvent?: any;
  36254. /** additional data for the event */
  36255. additionalData?: any;
  36256. }
  36257. /**
  36258. * ActionEvent is the event being sent when an action is triggered.
  36259. */
  36260. export class ActionEvent implements IActionEvent {
  36261. /** The mesh or sprite that triggered the action */
  36262. source: any;
  36263. /** The X mouse cursor position at the time of the event */
  36264. pointerX: number;
  36265. /** The Y mouse cursor position at the time of the event */
  36266. pointerY: number;
  36267. /** The mesh that is currently pointed at (can be null) */
  36268. meshUnderPointer: Nullable<AbstractMesh>;
  36269. /** the original (browser) event that triggered the ActionEvent */
  36270. sourceEvent?: any;
  36271. /** additional data for the event */
  36272. additionalData?: any;
  36273. /**
  36274. * Creates a new ActionEvent
  36275. * @param source The mesh or sprite that triggered the action
  36276. * @param pointerX The X mouse cursor position at the time of the event
  36277. * @param pointerY The Y mouse cursor position at the time of the event
  36278. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  36279. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  36280. * @param additionalData additional data for the event
  36281. */
  36282. constructor(
  36283. /** The mesh or sprite that triggered the action */
  36284. source: any,
  36285. /** The X mouse cursor position at the time of the event */
  36286. pointerX: number,
  36287. /** The Y mouse cursor position at the time of the event */
  36288. pointerY: number,
  36289. /** The mesh that is currently pointed at (can be null) */
  36290. meshUnderPointer: Nullable<AbstractMesh>,
  36291. /** the original (browser) event that triggered the ActionEvent */
  36292. sourceEvent?: any,
  36293. /** additional data for the event */
  36294. additionalData?: any);
  36295. /**
  36296. * Helper function to auto-create an ActionEvent from a source mesh.
  36297. * @param source The source mesh that triggered the event
  36298. * @param evt The original (browser) event
  36299. * @param additionalData additional data for the event
  36300. * @returns the new ActionEvent
  36301. */
  36302. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  36303. /**
  36304. * Helper function to auto-create an ActionEvent from a source sprite
  36305. * @param source The source sprite that triggered the event
  36306. * @param scene Scene associated with the sprite
  36307. * @param evt The original (browser) event
  36308. * @param additionalData additional data for the event
  36309. * @returns the new ActionEvent
  36310. */
  36311. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  36312. /**
  36313. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  36314. * @param scene the scene where the event occurred
  36315. * @param evt The original (browser) event
  36316. * @returns the new ActionEvent
  36317. */
  36318. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  36319. /**
  36320. * Helper function to auto-create an ActionEvent from a primitive
  36321. * @param prim defines the target primitive
  36322. * @param pointerPos defines the pointer position
  36323. * @param evt The original (browser) event
  36324. * @param additionalData additional data for the event
  36325. * @returns the new ActionEvent
  36326. */
  36327. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  36328. }
  36329. }
  36330. declare module BABYLON {
  36331. /**
  36332. * Abstract class used to decouple action Manager from scene and meshes.
  36333. * Do not instantiate.
  36334. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36335. */
  36336. export abstract class AbstractActionManager implements IDisposable {
  36337. /** Gets the list of active triggers */
  36338. static Triggers: {
  36339. [key: string]: number;
  36340. };
  36341. /** Gets the cursor to use when hovering items */
  36342. hoverCursor: string;
  36343. /** Gets the list of actions */
  36344. actions: IAction[];
  36345. /**
  36346. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  36347. */
  36348. isRecursive: boolean;
  36349. /**
  36350. * Releases all associated resources
  36351. */
  36352. abstract dispose(): void;
  36353. /**
  36354. * Does this action manager has pointer triggers
  36355. */
  36356. abstract get hasPointerTriggers(): boolean;
  36357. /**
  36358. * Does this action manager has pick triggers
  36359. */
  36360. abstract get hasPickTriggers(): boolean;
  36361. /**
  36362. * Process a specific trigger
  36363. * @param trigger defines the trigger to process
  36364. * @param evt defines the event details to be processed
  36365. */
  36366. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  36367. /**
  36368. * Does this action manager handles actions of any of the given triggers
  36369. * @param triggers defines the triggers to be tested
  36370. * @return a boolean indicating whether one (or more) of the triggers is handled
  36371. */
  36372. abstract hasSpecificTriggers(triggers: number[]): boolean;
  36373. /**
  36374. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  36375. * speed.
  36376. * @param triggerA defines the trigger to be tested
  36377. * @param triggerB defines the trigger to be tested
  36378. * @return a boolean indicating whether one (or more) of the triggers is handled
  36379. */
  36380. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  36381. /**
  36382. * Does this action manager handles actions of a given trigger
  36383. * @param trigger defines the trigger to be tested
  36384. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  36385. * @return whether the trigger is handled
  36386. */
  36387. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  36388. /**
  36389. * Serialize this manager to a JSON object
  36390. * @param name defines the property name to store this manager
  36391. * @returns a JSON representation of this manager
  36392. */
  36393. abstract serialize(name: string): any;
  36394. /**
  36395. * Registers an action to this action manager
  36396. * @param action defines the action to be registered
  36397. * @return the action amended (prepared) after registration
  36398. */
  36399. abstract registerAction(action: IAction): Nullable<IAction>;
  36400. /**
  36401. * Unregisters an action to this action manager
  36402. * @param action defines the action to be unregistered
  36403. * @return a boolean indicating whether the action has been unregistered
  36404. */
  36405. abstract unregisterAction(action: IAction): Boolean;
  36406. /**
  36407. * Does exist one action manager with at least one trigger
  36408. **/
  36409. static get HasTriggers(): boolean;
  36410. /**
  36411. * Does exist one action manager with at least one pick trigger
  36412. **/
  36413. static get HasPickTriggers(): boolean;
  36414. /**
  36415. * Does exist one action manager that handles actions of a given trigger
  36416. * @param trigger defines the trigger to be tested
  36417. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  36418. **/
  36419. static HasSpecificTrigger(trigger: number): boolean;
  36420. }
  36421. }
  36422. declare module BABYLON {
  36423. /**
  36424. * Defines how a node can be built from a string name.
  36425. */
  36426. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  36427. /**
  36428. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  36429. */
  36430. export class Node implements IBehaviorAware<Node> {
  36431. /** @hidden */
  36432. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  36433. private static _NodeConstructors;
  36434. /**
  36435. * Add a new node constructor
  36436. * @param type defines the type name of the node to construct
  36437. * @param constructorFunc defines the constructor function
  36438. */
  36439. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  36440. /**
  36441. * Returns a node constructor based on type name
  36442. * @param type defines the type name
  36443. * @param name defines the new node name
  36444. * @param scene defines the hosting scene
  36445. * @param options defines optional options to transmit to constructors
  36446. * @returns the new constructor or null
  36447. */
  36448. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  36449. /**
  36450. * Gets or sets the name of the node
  36451. */
  36452. name: string;
  36453. /**
  36454. * Gets or sets the id of the node
  36455. */
  36456. id: string;
  36457. /**
  36458. * Gets or sets the unique id of the node
  36459. */
  36460. uniqueId: number;
  36461. /**
  36462. * Gets or sets a string used to store user defined state for the node
  36463. */
  36464. state: string;
  36465. /**
  36466. * Gets or sets an object used to store user defined information for the node
  36467. */
  36468. metadata: any;
  36469. /**
  36470. * For internal use only. Please do not use.
  36471. */
  36472. reservedDataStore: any;
  36473. /**
  36474. * List of inspectable custom properties (used by the Inspector)
  36475. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  36476. */
  36477. inspectableCustomProperties: IInspectable[];
  36478. private _doNotSerialize;
  36479. /**
  36480. * Gets or sets a boolean used to define if the node must be serialized
  36481. */
  36482. get doNotSerialize(): boolean;
  36483. set doNotSerialize(value: boolean);
  36484. /** @hidden */
  36485. _isDisposed: boolean;
  36486. /**
  36487. * Gets a list of Animations associated with the node
  36488. */
  36489. animations: Animation[];
  36490. protected _ranges: {
  36491. [name: string]: Nullable<AnimationRange>;
  36492. };
  36493. /**
  36494. * Callback raised when the node is ready to be used
  36495. */
  36496. onReady: Nullable<(node: Node) => void>;
  36497. private _isEnabled;
  36498. private _isParentEnabled;
  36499. private _isReady;
  36500. /** @hidden */
  36501. _currentRenderId: number;
  36502. private _parentUpdateId;
  36503. /** @hidden */
  36504. _childUpdateId: number;
  36505. /** @hidden */
  36506. _waitingParentId: Nullable<string>;
  36507. /** @hidden */
  36508. _scene: Scene;
  36509. /** @hidden */
  36510. _cache: any;
  36511. private _parentNode;
  36512. private _children;
  36513. /** @hidden */
  36514. _worldMatrix: Matrix;
  36515. /** @hidden */
  36516. _worldMatrixDeterminant: number;
  36517. /** @hidden */
  36518. _worldMatrixDeterminantIsDirty: boolean;
  36519. /** @hidden */
  36520. private _sceneRootNodesIndex;
  36521. /**
  36522. * Gets a boolean indicating if the node has been disposed
  36523. * @returns true if the node was disposed
  36524. */
  36525. isDisposed(): boolean;
  36526. /**
  36527. * Gets or sets the parent of the node (without keeping the current position in the scene)
  36528. * @see https://doc.babylonjs.com/how_to/parenting
  36529. */
  36530. set parent(parent: Nullable<Node>);
  36531. get parent(): Nullable<Node>;
  36532. /** @hidden */
  36533. _addToSceneRootNodes(): void;
  36534. /** @hidden */
  36535. _removeFromSceneRootNodes(): void;
  36536. private _animationPropertiesOverride;
  36537. /**
  36538. * Gets or sets the animation properties override
  36539. */
  36540. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36541. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36542. /**
  36543. * Gets a string identifying the name of the class
  36544. * @returns "Node" string
  36545. */
  36546. getClassName(): string;
  36547. /** @hidden */
  36548. readonly _isNode: boolean;
  36549. /**
  36550. * An event triggered when the mesh is disposed
  36551. */
  36552. onDisposeObservable: Observable<Node>;
  36553. private _onDisposeObserver;
  36554. /**
  36555. * Sets a callback that will be raised when the node will be disposed
  36556. */
  36557. set onDispose(callback: () => void);
  36558. /**
  36559. * Creates a new Node
  36560. * @param name the name and id to be given to this node
  36561. * @param scene the scene this node will be added to
  36562. */
  36563. constructor(name: string, scene?: Nullable<Scene>);
  36564. /**
  36565. * Gets the scene of the node
  36566. * @returns a scene
  36567. */
  36568. getScene(): Scene;
  36569. /**
  36570. * Gets the engine of the node
  36571. * @returns a Engine
  36572. */
  36573. getEngine(): Engine;
  36574. private _behaviors;
  36575. /**
  36576. * Attach a behavior to the node
  36577. * @see https://doc.babylonjs.com/features/behaviour
  36578. * @param behavior defines the behavior to attach
  36579. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  36580. * @returns the current Node
  36581. */
  36582. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  36583. /**
  36584. * Remove an attached behavior
  36585. * @see https://doc.babylonjs.com/features/behaviour
  36586. * @param behavior defines the behavior to attach
  36587. * @returns the current Node
  36588. */
  36589. removeBehavior(behavior: Behavior<Node>): Node;
  36590. /**
  36591. * Gets the list of attached behaviors
  36592. * @see https://doc.babylonjs.com/features/behaviour
  36593. */
  36594. get behaviors(): Behavior<Node>[];
  36595. /**
  36596. * Gets an attached behavior by name
  36597. * @param name defines the name of the behavior to look for
  36598. * @see https://doc.babylonjs.com/features/behaviour
  36599. * @returns null if behavior was not found else the requested behavior
  36600. */
  36601. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  36602. /**
  36603. * Returns the latest update of the World matrix
  36604. * @returns a Matrix
  36605. */
  36606. getWorldMatrix(): Matrix;
  36607. /** @hidden */
  36608. _getWorldMatrixDeterminant(): number;
  36609. /**
  36610. * Returns directly the latest state of the mesh World matrix.
  36611. * A Matrix is returned.
  36612. */
  36613. get worldMatrixFromCache(): Matrix;
  36614. /** @hidden */
  36615. _initCache(): void;
  36616. /** @hidden */
  36617. updateCache(force?: boolean): void;
  36618. /** @hidden */
  36619. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36620. /** @hidden */
  36621. _updateCache(ignoreParentClass?: boolean): void;
  36622. /** @hidden */
  36623. _isSynchronized(): boolean;
  36624. /** @hidden */
  36625. _markSyncedWithParent(): void;
  36626. /** @hidden */
  36627. isSynchronizedWithParent(): boolean;
  36628. /** @hidden */
  36629. isSynchronized(): boolean;
  36630. /**
  36631. * Is this node ready to be used/rendered
  36632. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  36633. * @return true if the node is ready
  36634. */
  36635. isReady(completeCheck?: boolean): boolean;
  36636. /**
  36637. * Is this node enabled?
  36638. * 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
  36639. * @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
  36640. * @return whether this node (and its parent) is enabled
  36641. */
  36642. isEnabled(checkAncestors?: boolean): boolean;
  36643. /** @hidden */
  36644. protected _syncParentEnabledState(): void;
  36645. /**
  36646. * Set the enabled state of this node
  36647. * @param value defines the new enabled state
  36648. */
  36649. setEnabled(value: boolean): void;
  36650. /**
  36651. * Is this node a descendant of the given node?
  36652. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  36653. * @param ancestor defines the parent node to inspect
  36654. * @returns a boolean indicating if this node is a descendant of the given node
  36655. */
  36656. isDescendantOf(ancestor: Node): boolean;
  36657. /** @hidden */
  36658. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  36659. /**
  36660. * Will return all nodes that have this node as ascendant
  36661. * @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
  36662. * @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
  36663. * @return all children nodes of all types
  36664. */
  36665. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  36666. /**
  36667. * Get all child-meshes of this node
  36668. * @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)
  36669. * @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
  36670. * @returns an array of AbstractMesh
  36671. */
  36672. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  36673. /**
  36674. * Get all direct children of this node
  36675. * @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
  36676. * @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)
  36677. * @returns an array of Node
  36678. */
  36679. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  36680. /** @hidden */
  36681. _setReady(state: boolean): void;
  36682. /**
  36683. * Get an animation by name
  36684. * @param name defines the name of the animation to look for
  36685. * @returns null if not found else the requested animation
  36686. */
  36687. getAnimationByName(name: string): Nullable<Animation>;
  36688. /**
  36689. * Creates an animation range for this node
  36690. * @param name defines the name of the range
  36691. * @param from defines the starting key
  36692. * @param to defines the end key
  36693. */
  36694. createAnimationRange(name: string, from: number, to: number): void;
  36695. /**
  36696. * Delete a specific animation range
  36697. * @param name defines the name of the range to delete
  36698. * @param deleteFrames defines if animation frames from the range must be deleted as well
  36699. */
  36700. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  36701. /**
  36702. * Get an animation range by name
  36703. * @param name defines the name of the animation range to look for
  36704. * @returns null if not found else the requested animation range
  36705. */
  36706. getAnimationRange(name: string): Nullable<AnimationRange>;
  36707. /**
  36708. * Gets the list of all animation ranges defined on this node
  36709. * @returns an array
  36710. */
  36711. getAnimationRanges(): Nullable<AnimationRange>[];
  36712. /**
  36713. * Will start the animation sequence
  36714. * @param name defines the range frames for animation sequence
  36715. * @param loop defines if the animation should loop (false by default)
  36716. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  36717. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  36718. * @returns the object created for this animation. If range does not exist, it will return null
  36719. */
  36720. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  36721. /**
  36722. * Serialize animation ranges into a JSON compatible object
  36723. * @returns serialization object
  36724. */
  36725. serializeAnimationRanges(): any;
  36726. /**
  36727. * Computes the world matrix of the node
  36728. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  36729. * @returns the world matrix
  36730. */
  36731. computeWorldMatrix(force?: boolean): Matrix;
  36732. /**
  36733. * Releases resources associated with this node.
  36734. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  36735. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  36736. */
  36737. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  36738. /**
  36739. * Parse animation range data from a serialization object and store them into a given node
  36740. * @param node defines where to store the animation ranges
  36741. * @param parsedNode defines the serialization object to read data from
  36742. * @param scene defines the hosting scene
  36743. */
  36744. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  36745. /**
  36746. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  36747. * @param includeDescendants Include bounding info from descendants as well (true by default)
  36748. * @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
  36749. * @returns the new bounding vectors
  36750. */
  36751. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  36752. min: Vector3;
  36753. max: Vector3;
  36754. };
  36755. }
  36756. }
  36757. declare module BABYLON {
  36758. /**
  36759. * @hidden
  36760. */
  36761. export class _IAnimationState {
  36762. key: number;
  36763. repeatCount: number;
  36764. workValue?: any;
  36765. loopMode?: number;
  36766. offsetValue?: any;
  36767. highLimitValue?: any;
  36768. }
  36769. /**
  36770. * Class used to store any kind of animation
  36771. */
  36772. export class Animation {
  36773. /**Name of the animation */
  36774. name: string;
  36775. /**Property to animate */
  36776. targetProperty: string;
  36777. /**The frames per second of the animation */
  36778. framePerSecond: number;
  36779. /**The data type of the animation */
  36780. dataType: number;
  36781. /**The loop mode of the animation */
  36782. loopMode?: number | undefined;
  36783. /**Specifies if blending should be enabled */
  36784. enableBlending?: boolean | undefined;
  36785. /**
  36786. * Use matrix interpolation instead of using direct key value when animating matrices
  36787. */
  36788. static AllowMatricesInterpolation: boolean;
  36789. /**
  36790. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  36791. */
  36792. static AllowMatrixDecomposeForInterpolation: boolean;
  36793. /** Define the Url to load snippets */
  36794. static SnippetUrl: string;
  36795. /** Snippet ID if the animation was created from the snippet server */
  36796. snippetId: string;
  36797. /**
  36798. * Stores the key frames of the animation
  36799. */
  36800. private _keys;
  36801. /**
  36802. * Stores the easing function of the animation
  36803. */
  36804. private _easingFunction;
  36805. /**
  36806. * @hidden Internal use only
  36807. */
  36808. _runtimeAnimations: RuntimeAnimation[];
  36809. /**
  36810. * The set of event that will be linked to this animation
  36811. */
  36812. private _events;
  36813. /**
  36814. * Stores an array of target property paths
  36815. */
  36816. targetPropertyPath: string[];
  36817. /**
  36818. * Stores the blending speed of the animation
  36819. */
  36820. blendingSpeed: number;
  36821. /**
  36822. * Stores the animation ranges for the animation
  36823. */
  36824. private _ranges;
  36825. /**
  36826. * @hidden Internal use
  36827. */
  36828. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  36829. /**
  36830. * Sets up an animation
  36831. * @param property The property to animate
  36832. * @param animationType The animation type to apply
  36833. * @param framePerSecond The frames per second of the animation
  36834. * @param easingFunction The easing function used in the animation
  36835. * @returns The created animation
  36836. */
  36837. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  36838. /**
  36839. * Create and start an animation on a node
  36840. * @param name defines the name of the global animation that will be run on all nodes
  36841. * @param node defines the root node where the animation will take place
  36842. * @param targetProperty defines property to animate
  36843. * @param framePerSecond defines the number of frame per second yo use
  36844. * @param totalFrame defines the number of frames in total
  36845. * @param from defines the initial value
  36846. * @param to defines the final value
  36847. * @param loopMode defines which loop mode you want to use (off by default)
  36848. * @param easingFunction defines the easing function to use (linear by default)
  36849. * @param onAnimationEnd defines the callback to call when animation end
  36850. * @returns the animatable created for this animation
  36851. */
  36852. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  36853. /**
  36854. * Create and start an animation on a node and its descendants
  36855. * @param name defines the name of the global animation that will be run on all nodes
  36856. * @param node defines the root node where the animation will take place
  36857. * @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
  36858. * @param targetProperty defines property to animate
  36859. * @param framePerSecond defines the number of frame per second to use
  36860. * @param totalFrame defines the number of frames in total
  36861. * @param from defines the initial value
  36862. * @param to defines the final value
  36863. * @param loopMode defines which loop mode you want to use (off by default)
  36864. * @param easingFunction defines the easing function to use (linear by default)
  36865. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  36866. * @returns the list of animatables created for all nodes
  36867. * @example https://www.babylonjs-playground.com/#MH0VLI
  36868. */
  36869. 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[]>;
  36870. /**
  36871. * Creates a new animation, merges it with the existing animations and starts it
  36872. * @param name Name of the animation
  36873. * @param node Node which contains the scene that begins the animations
  36874. * @param targetProperty Specifies which property to animate
  36875. * @param framePerSecond The frames per second of the animation
  36876. * @param totalFrame The total number of frames
  36877. * @param from The frame at the beginning of the animation
  36878. * @param to The frame at the end of the animation
  36879. * @param loopMode Specifies the loop mode of the animation
  36880. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  36881. * @param onAnimationEnd Callback to run once the animation is complete
  36882. * @returns Nullable animation
  36883. */
  36884. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  36885. /**
  36886. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  36887. * @param sourceAnimation defines the Animation containing keyframes to convert
  36888. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  36889. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  36890. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  36891. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  36892. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  36893. */
  36894. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  36895. /**
  36896. * Transition property of an host to the target Value
  36897. * @param property The property to transition
  36898. * @param targetValue The target Value of the property
  36899. * @param host The object where the property to animate belongs
  36900. * @param scene Scene used to run the animation
  36901. * @param frameRate Framerate (in frame/s) to use
  36902. * @param transition The transition type we want to use
  36903. * @param duration The duration of the animation, in milliseconds
  36904. * @param onAnimationEnd Callback trigger at the end of the animation
  36905. * @returns Nullable animation
  36906. */
  36907. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  36908. /**
  36909. * Return the array of runtime animations currently using this animation
  36910. */
  36911. get runtimeAnimations(): RuntimeAnimation[];
  36912. /**
  36913. * Specifies if any of the runtime animations are currently running
  36914. */
  36915. get hasRunningRuntimeAnimations(): boolean;
  36916. /**
  36917. * Initializes the animation
  36918. * @param name Name of the animation
  36919. * @param targetProperty Property to animate
  36920. * @param framePerSecond The frames per second of the animation
  36921. * @param dataType The data type of the animation
  36922. * @param loopMode The loop mode of the animation
  36923. * @param enableBlending Specifies if blending should be enabled
  36924. */
  36925. constructor(
  36926. /**Name of the animation */
  36927. name: string,
  36928. /**Property to animate */
  36929. targetProperty: string,
  36930. /**The frames per second of the animation */
  36931. framePerSecond: number,
  36932. /**The data type of the animation */
  36933. dataType: number,
  36934. /**The loop mode of the animation */
  36935. loopMode?: number | undefined,
  36936. /**Specifies if blending should be enabled */
  36937. enableBlending?: boolean | undefined);
  36938. /**
  36939. * Converts the animation to a string
  36940. * @param fullDetails support for multiple levels of logging within scene loading
  36941. * @returns String form of the animation
  36942. */
  36943. toString(fullDetails?: boolean): string;
  36944. /**
  36945. * Add an event to this animation
  36946. * @param event Event to add
  36947. */
  36948. addEvent(event: AnimationEvent): void;
  36949. /**
  36950. * Remove all events found at the given frame
  36951. * @param frame The frame to remove events from
  36952. */
  36953. removeEvents(frame: number): void;
  36954. /**
  36955. * Retrieves all the events from the animation
  36956. * @returns Events from the animation
  36957. */
  36958. getEvents(): AnimationEvent[];
  36959. /**
  36960. * Creates an animation range
  36961. * @param name Name of the animation range
  36962. * @param from Starting frame of the animation range
  36963. * @param to Ending frame of the animation
  36964. */
  36965. createRange(name: string, from: number, to: number): void;
  36966. /**
  36967. * Deletes an animation range by name
  36968. * @param name Name of the animation range to delete
  36969. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  36970. */
  36971. deleteRange(name: string, deleteFrames?: boolean): void;
  36972. /**
  36973. * Gets the animation range by name, or null if not defined
  36974. * @param name Name of the animation range
  36975. * @returns Nullable animation range
  36976. */
  36977. getRange(name: string): Nullable<AnimationRange>;
  36978. /**
  36979. * Gets the key frames from the animation
  36980. * @returns The key frames of the animation
  36981. */
  36982. getKeys(): Array<IAnimationKey>;
  36983. /**
  36984. * Gets the highest frame rate of the animation
  36985. * @returns Highest frame rate of the animation
  36986. */
  36987. getHighestFrame(): number;
  36988. /**
  36989. * Gets the easing function of the animation
  36990. * @returns Easing function of the animation
  36991. */
  36992. getEasingFunction(): IEasingFunction;
  36993. /**
  36994. * Sets the easing function of the animation
  36995. * @param easingFunction A custom mathematical formula for animation
  36996. */
  36997. setEasingFunction(easingFunction: EasingFunction): void;
  36998. /**
  36999. * Interpolates a scalar linearly
  37000. * @param startValue Start value of the animation curve
  37001. * @param endValue End value of the animation curve
  37002. * @param gradient Scalar amount to interpolate
  37003. * @returns Interpolated scalar value
  37004. */
  37005. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  37006. /**
  37007. * Interpolates a scalar cubically
  37008. * @param startValue Start value of the animation curve
  37009. * @param outTangent End tangent of the animation
  37010. * @param endValue End value of the animation curve
  37011. * @param inTangent Start tangent of the animation curve
  37012. * @param gradient Scalar amount to interpolate
  37013. * @returns Interpolated scalar value
  37014. */
  37015. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  37016. /**
  37017. * Interpolates a quaternion using a spherical linear interpolation
  37018. * @param startValue Start value of the animation curve
  37019. * @param endValue End value of the animation curve
  37020. * @param gradient Scalar amount to interpolate
  37021. * @returns Interpolated quaternion value
  37022. */
  37023. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  37024. /**
  37025. * Interpolates a quaternion cubically
  37026. * @param startValue Start value of the animation curve
  37027. * @param outTangent End tangent of the animation curve
  37028. * @param endValue End value of the animation curve
  37029. * @param inTangent Start tangent of the animation curve
  37030. * @param gradient Scalar amount to interpolate
  37031. * @returns Interpolated quaternion value
  37032. */
  37033. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  37034. /**
  37035. * Interpolates a Vector3 linearl
  37036. * @param startValue Start value of the animation curve
  37037. * @param endValue End value of the animation curve
  37038. * @param gradient Scalar amount to interpolate
  37039. * @returns Interpolated scalar value
  37040. */
  37041. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  37042. /**
  37043. * Interpolates a Vector3 cubically
  37044. * @param startValue Start value of the animation curve
  37045. * @param outTangent End tangent of the animation
  37046. * @param endValue End value of the animation curve
  37047. * @param inTangent Start tangent of the animation curve
  37048. * @param gradient Scalar amount to interpolate
  37049. * @returns InterpolatedVector3 value
  37050. */
  37051. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  37052. /**
  37053. * Interpolates a Vector2 linearly
  37054. * @param startValue Start value of the animation curve
  37055. * @param endValue End value of the animation curve
  37056. * @param gradient Scalar amount to interpolate
  37057. * @returns Interpolated Vector2 value
  37058. */
  37059. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  37060. /**
  37061. * Interpolates a Vector2 cubically
  37062. * @param startValue Start value of the animation curve
  37063. * @param outTangent End tangent of the animation
  37064. * @param endValue End value of the animation curve
  37065. * @param inTangent Start tangent of the animation curve
  37066. * @param gradient Scalar amount to interpolate
  37067. * @returns Interpolated Vector2 value
  37068. */
  37069. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  37070. /**
  37071. * Interpolates a size linearly
  37072. * @param startValue Start value of the animation curve
  37073. * @param endValue End value of the animation curve
  37074. * @param gradient Scalar amount to interpolate
  37075. * @returns Interpolated Size value
  37076. */
  37077. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  37078. /**
  37079. * Interpolates a Color3 linearly
  37080. * @param startValue Start value of the animation curve
  37081. * @param endValue End value of the animation curve
  37082. * @param gradient Scalar amount to interpolate
  37083. * @returns Interpolated Color3 value
  37084. */
  37085. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  37086. /**
  37087. * Interpolates a Color4 linearly
  37088. * @param startValue Start value of the animation curve
  37089. * @param endValue End value of the animation curve
  37090. * @param gradient Scalar amount to interpolate
  37091. * @returns Interpolated Color3 value
  37092. */
  37093. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  37094. /**
  37095. * @hidden Internal use only
  37096. */
  37097. _getKeyValue(value: any): any;
  37098. /**
  37099. * @hidden Internal use only
  37100. */
  37101. _interpolate(currentFrame: number, state: _IAnimationState): any;
  37102. /**
  37103. * Defines the function to use to interpolate matrices
  37104. * @param startValue defines the start matrix
  37105. * @param endValue defines the end matrix
  37106. * @param gradient defines the gradient between both matrices
  37107. * @param result defines an optional target matrix where to store the interpolation
  37108. * @returns the interpolated matrix
  37109. */
  37110. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  37111. /**
  37112. * Makes a copy of the animation
  37113. * @returns Cloned animation
  37114. */
  37115. clone(): Animation;
  37116. /**
  37117. * Sets the key frames of the animation
  37118. * @param values The animation key frames to set
  37119. */
  37120. setKeys(values: Array<IAnimationKey>): void;
  37121. /**
  37122. * Serializes the animation to an object
  37123. * @returns Serialized object
  37124. */
  37125. serialize(): any;
  37126. /**
  37127. * Float animation type
  37128. */
  37129. static readonly ANIMATIONTYPE_FLOAT: number;
  37130. /**
  37131. * Vector3 animation type
  37132. */
  37133. static readonly ANIMATIONTYPE_VECTOR3: number;
  37134. /**
  37135. * Quaternion animation type
  37136. */
  37137. static readonly ANIMATIONTYPE_QUATERNION: number;
  37138. /**
  37139. * Matrix animation type
  37140. */
  37141. static readonly ANIMATIONTYPE_MATRIX: number;
  37142. /**
  37143. * Color3 animation type
  37144. */
  37145. static readonly ANIMATIONTYPE_COLOR3: number;
  37146. /**
  37147. * Color3 animation type
  37148. */
  37149. static readonly ANIMATIONTYPE_COLOR4: number;
  37150. /**
  37151. * Vector2 animation type
  37152. */
  37153. static readonly ANIMATIONTYPE_VECTOR2: number;
  37154. /**
  37155. * Size animation type
  37156. */
  37157. static readonly ANIMATIONTYPE_SIZE: number;
  37158. /**
  37159. * Relative Loop Mode
  37160. */
  37161. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  37162. /**
  37163. * Cycle Loop Mode
  37164. */
  37165. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  37166. /**
  37167. * Constant Loop Mode
  37168. */
  37169. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  37170. /** @hidden */
  37171. static _UniversalLerp(left: any, right: any, amount: number): any;
  37172. /**
  37173. * Parses an animation object and creates an animation
  37174. * @param parsedAnimation Parsed animation object
  37175. * @returns Animation object
  37176. */
  37177. static Parse(parsedAnimation: any): Animation;
  37178. /**
  37179. * Appends the serialized animations from the source animations
  37180. * @param source Source containing the animations
  37181. * @param destination Target to store the animations
  37182. */
  37183. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  37184. /**
  37185. * Creates a new animation or an array of animations from a snippet saved in a remote file
  37186. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  37187. * @param url defines the url to load from
  37188. * @returns a promise that will resolve to the new animation or an array of animations
  37189. */
  37190. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  37191. /**
  37192. * Creates an animation or an array of animations from a snippet saved by the Inspector
  37193. * @param snippetId defines the snippet to load
  37194. * @returns a promise that will resolve to the new animation or a new array of animations
  37195. */
  37196. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  37197. }
  37198. }
  37199. declare module BABYLON {
  37200. /**
  37201. * Interface containing an array of animations
  37202. */
  37203. export interface IAnimatable {
  37204. /**
  37205. * Array of animations
  37206. */
  37207. animations: Nullable<Array<Animation>>;
  37208. }
  37209. }
  37210. declare module BABYLON {
  37211. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  37212. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37213. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37214. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37215. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37216. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37217. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37218. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37219. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37220. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37221. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37222. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37223. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37224. /**
  37225. * Decorator used to define property that can be serialized as reference to a camera
  37226. * @param sourceName defines the name of the property to decorate
  37227. */
  37228. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37229. /**
  37230. * Class used to help serialization objects
  37231. */
  37232. export class SerializationHelper {
  37233. /** @hidden */
  37234. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  37235. /** @hidden */
  37236. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  37237. /** @hidden */
  37238. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  37239. /** @hidden */
  37240. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  37241. /**
  37242. * Appends the serialized animations from the source animations
  37243. * @param source Source containing the animations
  37244. * @param destination Target to store the animations
  37245. */
  37246. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  37247. /**
  37248. * Static function used to serialized a specific entity
  37249. * @param entity defines the entity to serialize
  37250. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  37251. * @returns a JSON compatible object representing the serialization of the entity
  37252. */
  37253. static Serialize<T>(entity: T, serializationObject?: any): any;
  37254. /**
  37255. * Creates a new entity from a serialization data object
  37256. * @param creationFunction defines a function used to instanciated the new entity
  37257. * @param source defines the source serialization data
  37258. * @param scene defines the hosting scene
  37259. * @param rootUrl defines the root url for resources
  37260. * @returns a new entity
  37261. */
  37262. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  37263. /**
  37264. * Clones an object
  37265. * @param creationFunction defines the function used to instanciate the new object
  37266. * @param source defines the source object
  37267. * @returns the cloned object
  37268. */
  37269. static Clone<T>(creationFunction: () => T, source: T): T;
  37270. /**
  37271. * Instanciates a new object based on a source one (some data will be shared between both object)
  37272. * @param creationFunction defines the function used to instanciate the new object
  37273. * @param source defines the source object
  37274. * @returns the new object
  37275. */
  37276. static Instanciate<T>(creationFunction: () => T, source: T): T;
  37277. }
  37278. }
  37279. declare module BABYLON {
  37280. /**
  37281. * Base class of all the textures in babylon.
  37282. * It groups all the common properties the materials, post process, lights... might need
  37283. * in order to make a correct use of the texture.
  37284. */
  37285. export class BaseTexture implements IAnimatable {
  37286. /**
  37287. * Default anisotropic filtering level for the application.
  37288. * It is set to 4 as a good tradeoff between perf and quality.
  37289. */
  37290. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  37291. /**
  37292. * Gets or sets the unique id of the texture
  37293. */
  37294. uniqueId: number;
  37295. /**
  37296. * Define the name of the texture.
  37297. */
  37298. name: string;
  37299. /**
  37300. * Gets or sets an object used to store user defined information.
  37301. */
  37302. metadata: any;
  37303. /**
  37304. * For internal use only. Please do not use.
  37305. */
  37306. reservedDataStore: any;
  37307. private _hasAlpha;
  37308. /**
  37309. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  37310. */
  37311. set hasAlpha(value: boolean);
  37312. get hasAlpha(): boolean;
  37313. /**
  37314. * Defines if the alpha value should be determined via the rgb values.
  37315. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  37316. */
  37317. getAlphaFromRGB: boolean;
  37318. /**
  37319. * Intensity or strength of the texture.
  37320. * It is commonly used by materials to fine tune the intensity of the texture
  37321. */
  37322. level: number;
  37323. /**
  37324. * Define the UV chanel to use starting from 0 and defaulting to 0.
  37325. * This is part of the texture as textures usually maps to one uv set.
  37326. */
  37327. coordinatesIndex: number;
  37328. protected _coordinatesMode: number;
  37329. /**
  37330. * How a texture is mapped.
  37331. *
  37332. * | Value | Type | Description |
  37333. * | ----- | ----------------------------------- | ----------- |
  37334. * | 0 | EXPLICIT_MODE | |
  37335. * | 1 | SPHERICAL_MODE | |
  37336. * | 2 | PLANAR_MODE | |
  37337. * | 3 | CUBIC_MODE | |
  37338. * | 4 | PROJECTION_MODE | |
  37339. * | 5 | SKYBOX_MODE | |
  37340. * | 6 | INVCUBIC_MODE | |
  37341. * | 7 | EQUIRECTANGULAR_MODE | |
  37342. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  37343. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  37344. */
  37345. set coordinatesMode(value: number);
  37346. get coordinatesMode(): number;
  37347. private _wrapU;
  37348. /**
  37349. * | Value | Type | Description |
  37350. * | ----- | ------------------ | ----------- |
  37351. * | 0 | CLAMP_ADDRESSMODE | |
  37352. * | 1 | WRAP_ADDRESSMODE | |
  37353. * | 2 | MIRROR_ADDRESSMODE | |
  37354. */
  37355. get wrapU(): number;
  37356. set wrapU(value: number);
  37357. private _wrapV;
  37358. /**
  37359. * | Value | Type | Description |
  37360. * | ----- | ------------------ | ----------- |
  37361. * | 0 | CLAMP_ADDRESSMODE | |
  37362. * | 1 | WRAP_ADDRESSMODE | |
  37363. * | 2 | MIRROR_ADDRESSMODE | |
  37364. */
  37365. get wrapV(): number;
  37366. set wrapV(value: number);
  37367. /**
  37368. * | Value | Type | Description |
  37369. * | ----- | ------------------ | ----------- |
  37370. * | 0 | CLAMP_ADDRESSMODE | |
  37371. * | 1 | WRAP_ADDRESSMODE | |
  37372. * | 2 | MIRROR_ADDRESSMODE | |
  37373. */
  37374. wrapR: number;
  37375. /**
  37376. * With compliant hardware and browser (supporting anisotropic filtering)
  37377. * this defines the level of anisotropic filtering in the texture.
  37378. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  37379. */
  37380. anisotropicFilteringLevel: number;
  37381. /**
  37382. * Define if the texture is a cube texture or if false a 2d texture.
  37383. */
  37384. get isCube(): boolean;
  37385. set isCube(value: boolean);
  37386. /**
  37387. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  37388. */
  37389. get is3D(): boolean;
  37390. set is3D(value: boolean);
  37391. /**
  37392. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  37393. */
  37394. get is2DArray(): boolean;
  37395. set is2DArray(value: boolean);
  37396. private _gammaSpace;
  37397. /**
  37398. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  37399. * HDR texture are usually stored in linear space.
  37400. * This only impacts the PBR and Background materials
  37401. */
  37402. get gammaSpace(): boolean;
  37403. set gammaSpace(gamma: boolean);
  37404. /**
  37405. * Gets or sets whether or not the texture contains RGBD data.
  37406. */
  37407. get isRGBD(): boolean;
  37408. set isRGBD(value: boolean);
  37409. /**
  37410. * Is Z inverted in the texture (useful in a cube texture).
  37411. */
  37412. invertZ: boolean;
  37413. /**
  37414. * Are mip maps generated for this texture or not.
  37415. */
  37416. get noMipmap(): boolean;
  37417. /**
  37418. * @hidden
  37419. */
  37420. lodLevelInAlpha: boolean;
  37421. /**
  37422. * With prefiltered texture, defined the offset used during the prefiltering steps.
  37423. */
  37424. get lodGenerationOffset(): number;
  37425. set lodGenerationOffset(value: number);
  37426. /**
  37427. * With prefiltered texture, defined the scale used during the prefiltering steps.
  37428. */
  37429. get lodGenerationScale(): number;
  37430. set lodGenerationScale(value: number);
  37431. /**
  37432. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  37433. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  37434. * average roughness values.
  37435. */
  37436. get linearSpecularLOD(): boolean;
  37437. set linearSpecularLOD(value: boolean);
  37438. /**
  37439. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  37440. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  37441. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  37442. */
  37443. get irradianceTexture(): Nullable<BaseTexture>;
  37444. set irradianceTexture(value: Nullable<BaseTexture>);
  37445. /**
  37446. * Define if the texture is a render target.
  37447. */
  37448. isRenderTarget: boolean;
  37449. /**
  37450. * Define the unique id of the texture in the scene.
  37451. */
  37452. get uid(): string;
  37453. /** @hidden */
  37454. _prefiltered: boolean;
  37455. /**
  37456. * Return a string representation of the texture.
  37457. * @returns the texture as a string
  37458. */
  37459. toString(): string;
  37460. /**
  37461. * Get the class name of the texture.
  37462. * @returns "BaseTexture"
  37463. */
  37464. getClassName(): string;
  37465. /**
  37466. * Define the list of animation attached to the texture.
  37467. */
  37468. animations: Animation[];
  37469. /**
  37470. * An event triggered when the texture is disposed.
  37471. */
  37472. onDisposeObservable: Observable<BaseTexture>;
  37473. private _onDisposeObserver;
  37474. /**
  37475. * Callback triggered when the texture has been disposed.
  37476. * Kept for back compatibility, you can use the onDisposeObservable instead.
  37477. */
  37478. set onDispose(callback: () => void);
  37479. /**
  37480. * Define the current state of the loading sequence when in delayed load mode.
  37481. */
  37482. delayLoadState: number;
  37483. protected _scene: Nullable<Scene>;
  37484. protected _engine: Nullable<ThinEngine>;
  37485. /** @hidden */
  37486. _texture: Nullable<InternalTexture>;
  37487. private _uid;
  37488. /**
  37489. * Define if the texture is preventinga material to render or not.
  37490. * If not and the texture is not ready, the engine will use a default black texture instead.
  37491. */
  37492. get isBlocking(): boolean;
  37493. /**
  37494. * Instantiates a new BaseTexture.
  37495. * Base class of all the textures in babylon.
  37496. * It groups all the common properties the materials, post process, lights... might need
  37497. * in order to make a correct use of the texture.
  37498. * @param sceneOrEngine Define the scene or engine the texture blongs to
  37499. */
  37500. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  37501. /**
  37502. * Get the scene the texture belongs to.
  37503. * @returns the scene or null if undefined
  37504. */
  37505. getScene(): Nullable<Scene>;
  37506. /** @hidden */
  37507. protected _getEngine(): Nullable<ThinEngine>;
  37508. /**
  37509. * Checks if the texture has the same transform matrix than another texture
  37510. * @param texture texture to check against
  37511. * @returns true if the transforms are the same, else false
  37512. */
  37513. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  37514. /**
  37515. * Get the texture transform matrix used to offset tile the texture for istance.
  37516. * @returns the transformation matrix
  37517. */
  37518. getTextureMatrix(): Matrix;
  37519. /**
  37520. * Get the texture reflection matrix used to rotate/transform the reflection.
  37521. * @returns the reflection matrix
  37522. */
  37523. getReflectionTextureMatrix(): Matrix;
  37524. /**
  37525. * Get the underlying lower level texture from Babylon.
  37526. * @returns the insternal texture
  37527. */
  37528. getInternalTexture(): Nullable<InternalTexture>;
  37529. /**
  37530. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  37531. * @returns true if ready or not blocking
  37532. */
  37533. isReadyOrNotBlocking(): boolean;
  37534. /**
  37535. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  37536. * @returns true if fully ready
  37537. */
  37538. isReady(): boolean;
  37539. private _cachedSize;
  37540. /**
  37541. * Get the size of the texture.
  37542. * @returns the texture size.
  37543. */
  37544. getSize(): ISize;
  37545. /**
  37546. * Get the base size of the texture.
  37547. * It can be different from the size if the texture has been resized for POT for instance
  37548. * @returns the base size
  37549. */
  37550. getBaseSize(): ISize;
  37551. /**
  37552. * Update the sampling mode of the texture.
  37553. * Default is Trilinear mode.
  37554. *
  37555. * | Value | Type | Description |
  37556. * | ----- | ------------------ | ----------- |
  37557. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  37558. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  37559. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  37560. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  37561. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  37562. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  37563. * | 7 | NEAREST_LINEAR | |
  37564. * | 8 | NEAREST_NEAREST | |
  37565. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  37566. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  37567. * | 11 | LINEAR_LINEAR | |
  37568. * | 12 | LINEAR_NEAREST | |
  37569. *
  37570. * > _mag_: magnification filter (close to the viewer)
  37571. * > _min_: minification filter (far from the viewer)
  37572. * > _mip_: filter used between mip map levels
  37573. *@param samplingMode Define the new sampling mode of the texture
  37574. */
  37575. updateSamplingMode(samplingMode: number): void;
  37576. /**
  37577. * Scales the texture if is `canRescale()`
  37578. * @param ratio the resize factor we want to use to rescale
  37579. */
  37580. scale(ratio: number): void;
  37581. /**
  37582. * Get if the texture can rescale.
  37583. */
  37584. get canRescale(): boolean;
  37585. /** @hidden */
  37586. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  37587. /** @hidden */
  37588. _rebuild(): void;
  37589. /**
  37590. * Triggers the load sequence in delayed load mode.
  37591. */
  37592. delayLoad(): void;
  37593. /**
  37594. * Clones the texture.
  37595. * @returns the cloned texture
  37596. */
  37597. clone(): Nullable<BaseTexture>;
  37598. /**
  37599. * Get the texture underlying type (INT, FLOAT...)
  37600. */
  37601. get textureType(): number;
  37602. /**
  37603. * Get the texture underlying format (RGB, RGBA...)
  37604. */
  37605. get textureFormat(): number;
  37606. /**
  37607. * Indicates that textures need to be re-calculated for all materials
  37608. */
  37609. protected _markAllSubMeshesAsTexturesDirty(): void;
  37610. /**
  37611. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  37612. * This will returns an RGBA array buffer containing either in values (0-255) or
  37613. * float values (0-1) depending of the underlying buffer type.
  37614. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  37615. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  37616. * @param buffer defines a user defined buffer to fill with data (can be null)
  37617. * @returns The Array buffer containing the pixels data.
  37618. */
  37619. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  37620. /**
  37621. * Release and destroy the underlying lower level texture aka internalTexture.
  37622. */
  37623. releaseInternalTexture(): void;
  37624. /** @hidden */
  37625. get _lodTextureHigh(): Nullable<BaseTexture>;
  37626. /** @hidden */
  37627. get _lodTextureMid(): Nullable<BaseTexture>;
  37628. /** @hidden */
  37629. get _lodTextureLow(): Nullable<BaseTexture>;
  37630. /**
  37631. * Dispose the texture and release its associated resources.
  37632. */
  37633. dispose(): void;
  37634. /**
  37635. * Serialize the texture into a JSON representation that can be parsed later on.
  37636. * @returns the JSON representation of the texture
  37637. */
  37638. serialize(): any;
  37639. /**
  37640. * Helper function to be called back once a list of texture contains only ready textures.
  37641. * @param textures Define the list of textures to wait for
  37642. * @param callback Define the callback triggered once the entire list will be ready
  37643. */
  37644. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  37645. private static _isScene;
  37646. }
  37647. }
  37648. declare module BABYLON {
  37649. /**
  37650. * Options to be used when creating an effect.
  37651. */
  37652. export interface IEffectCreationOptions {
  37653. /**
  37654. * Atrributes that will be used in the shader.
  37655. */
  37656. attributes: string[];
  37657. /**
  37658. * Uniform varible names that will be set in the shader.
  37659. */
  37660. uniformsNames: string[];
  37661. /**
  37662. * Uniform buffer variable names that will be set in the shader.
  37663. */
  37664. uniformBuffersNames: string[];
  37665. /**
  37666. * Sampler texture variable names that will be set in the shader.
  37667. */
  37668. samplers: string[];
  37669. /**
  37670. * Define statements that will be set in the shader.
  37671. */
  37672. defines: any;
  37673. /**
  37674. * Possible fallbacks for this effect to improve performance when needed.
  37675. */
  37676. fallbacks: Nullable<IEffectFallbacks>;
  37677. /**
  37678. * Callback that will be called when the shader is compiled.
  37679. */
  37680. onCompiled: Nullable<(effect: Effect) => void>;
  37681. /**
  37682. * Callback that will be called if an error occurs during shader compilation.
  37683. */
  37684. onError: Nullable<(effect: Effect, errors: string) => void>;
  37685. /**
  37686. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  37687. */
  37688. indexParameters?: any;
  37689. /**
  37690. * Max number of lights that can be used in the shader.
  37691. */
  37692. maxSimultaneousLights?: number;
  37693. /**
  37694. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  37695. */
  37696. transformFeedbackVaryings?: Nullable<string[]>;
  37697. /**
  37698. * 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
  37699. */
  37700. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  37701. /**
  37702. * Is this effect rendering to several color attachments ?
  37703. */
  37704. multiTarget?: boolean;
  37705. }
  37706. /**
  37707. * Effect containing vertex and fragment shader that can be executed on an object.
  37708. */
  37709. export class Effect implements IDisposable {
  37710. /**
  37711. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  37712. */
  37713. static ShadersRepository: string;
  37714. /**
  37715. * Enable logging of the shader code when a compilation error occurs
  37716. */
  37717. static LogShaderCodeOnCompilationError: boolean;
  37718. /**
  37719. * Name of the effect.
  37720. */
  37721. name: any;
  37722. /**
  37723. * String container all the define statements that should be set on the shader.
  37724. */
  37725. defines: string;
  37726. /**
  37727. * Callback that will be called when the shader is compiled.
  37728. */
  37729. onCompiled: Nullable<(effect: Effect) => void>;
  37730. /**
  37731. * Callback that will be called if an error occurs during shader compilation.
  37732. */
  37733. onError: Nullable<(effect: Effect, errors: string) => void>;
  37734. /**
  37735. * Callback that will be called when effect is bound.
  37736. */
  37737. onBind: Nullable<(effect: Effect) => void>;
  37738. /**
  37739. * Unique ID of the effect.
  37740. */
  37741. uniqueId: number;
  37742. /**
  37743. * Observable that will be called when the shader is compiled.
  37744. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  37745. */
  37746. onCompileObservable: Observable<Effect>;
  37747. /**
  37748. * Observable that will be called if an error occurs during shader compilation.
  37749. */
  37750. onErrorObservable: Observable<Effect>;
  37751. /** @hidden */
  37752. _onBindObservable: Nullable<Observable<Effect>>;
  37753. /**
  37754. * @hidden
  37755. * Specifies if the effect was previously ready
  37756. */
  37757. _wasPreviouslyReady: boolean;
  37758. /**
  37759. * Observable that will be called when effect is bound.
  37760. */
  37761. get onBindObservable(): Observable<Effect>;
  37762. /** @hidden */
  37763. _bonesComputationForcedToCPU: boolean;
  37764. /** @hidden */
  37765. _multiTarget: boolean;
  37766. private static _uniqueIdSeed;
  37767. private _engine;
  37768. private _uniformBuffersNames;
  37769. private _uniformBuffersNamesList;
  37770. private _uniformsNames;
  37771. private _samplerList;
  37772. private _samplers;
  37773. private _isReady;
  37774. private _compilationError;
  37775. private _allFallbacksProcessed;
  37776. private _attributesNames;
  37777. private _attributes;
  37778. private _attributeLocationByName;
  37779. private _uniforms;
  37780. /**
  37781. * Key for the effect.
  37782. * @hidden
  37783. */
  37784. _key: string;
  37785. private _indexParameters;
  37786. private _fallbacks;
  37787. private _vertexSourceCode;
  37788. private _fragmentSourceCode;
  37789. private _vertexSourceCodeOverride;
  37790. private _fragmentSourceCodeOverride;
  37791. private _transformFeedbackVaryings;
  37792. /**
  37793. * Compiled shader to webGL program.
  37794. * @hidden
  37795. */
  37796. _pipelineContext: Nullable<IPipelineContext>;
  37797. private _valueCache;
  37798. private static _baseCache;
  37799. /**
  37800. * Instantiates an effect.
  37801. * An effect can be used to create/manage/execute vertex and fragment shaders.
  37802. * @param baseName Name of the effect.
  37803. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  37804. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  37805. * @param samplers List of sampler variables that will be passed to the shader.
  37806. * @param engine Engine to be used to render the effect
  37807. * @param defines Define statements to be added to the shader.
  37808. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  37809. * @param onCompiled Callback that will be called when the shader is compiled.
  37810. * @param onError Callback that will be called if an error occurs during shader compilation.
  37811. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  37812. */
  37813. 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);
  37814. private _useFinalCode;
  37815. /**
  37816. * Unique key for this effect
  37817. */
  37818. get key(): string;
  37819. /**
  37820. * If the effect has been compiled and prepared.
  37821. * @returns if the effect is compiled and prepared.
  37822. */
  37823. isReady(): boolean;
  37824. private _isReadyInternal;
  37825. /**
  37826. * The engine the effect was initialized with.
  37827. * @returns the engine.
  37828. */
  37829. getEngine(): Engine;
  37830. /**
  37831. * The pipeline context for this effect
  37832. * @returns the associated pipeline context
  37833. */
  37834. getPipelineContext(): Nullable<IPipelineContext>;
  37835. /**
  37836. * The set of names of attribute variables for the shader.
  37837. * @returns An array of attribute names.
  37838. */
  37839. getAttributesNames(): string[];
  37840. /**
  37841. * Returns the attribute at the given index.
  37842. * @param index The index of the attribute.
  37843. * @returns The location of the attribute.
  37844. */
  37845. getAttributeLocation(index: number): number;
  37846. /**
  37847. * Returns the attribute based on the name of the variable.
  37848. * @param name of the attribute to look up.
  37849. * @returns the attribute location.
  37850. */
  37851. getAttributeLocationByName(name: string): number;
  37852. /**
  37853. * The number of attributes.
  37854. * @returns the numnber of attributes.
  37855. */
  37856. getAttributesCount(): number;
  37857. /**
  37858. * Gets the index of a uniform variable.
  37859. * @param uniformName of the uniform to look up.
  37860. * @returns the index.
  37861. */
  37862. getUniformIndex(uniformName: string): number;
  37863. /**
  37864. * Returns the attribute based on the name of the variable.
  37865. * @param uniformName of the uniform to look up.
  37866. * @returns the location of the uniform.
  37867. */
  37868. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  37869. /**
  37870. * Returns an array of sampler variable names
  37871. * @returns The array of sampler variable names.
  37872. */
  37873. getSamplers(): string[];
  37874. /**
  37875. * Returns an array of uniform variable names
  37876. * @returns The array of uniform variable names.
  37877. */
  37878. getUniformNames(): string[];
  37879. /**
  37880. * Returns an array of uniform buffer variable names
  37881. * @returns The array of uniform buffer variable names.
  37882. */
  37883. getUniformBuffersNames(): string[];
  37884. /**
  37885. * Returns the index parameters used to create the effect
  37886. * @returns The index parameters object
  37887. */
  37888. getIndexParameters(): any;
  37889. /**
  37890. * The error from the last compilation.
  37891. * @returns the error string.
  37892. */
  37893. getCompilationError(): string;
  37894. /**
  37895. * Gets a boolean indicating that all fallbacks were used during compilation
  37896. * @returns true if all fallbacks were used
  37897. */
  37898. allFallbacksProcessed(): boolean;
  37899. /**
  37900. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  37901. * @param func The callback to be used.
  37902. */
  37903. executeWhenCompiled(func: (effect: Effect) => void): void;
  37904. private _checkIsReady;
  37905. private _loadShader;
  37906. /**
  37907. * Gets the vertex shader source code of this effect
  37908. */
  37909. get vertexSourceCode(): string;
  37910. /**
  37911. * Gets the fragment shader source code of this effect
  37912. */
  37913. get fragmentSourceCode(): string;
  37914. /**
  37915. * Recompiles the webGL program
  37916. * @param vertexSourceCode The source code for the vertex shader.
  37917. * @param fragmentSourceCode The source code for the fragment shader.
  37918. * @param onCompiled Callback called when completed.
  37919. * @param onError Callback called on error.
  37920. * @hidden
  37921. */
  37922. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  37923. /**
  37924. * Prepares the effect
  37925. * @hidden
  37926. */
  37927. _prepareEffect(): void;
  37928. private _getShaderCodeAndErrorLine;
  37929. private _processCompilationErrors;
  37930. /**
  37931. * Checks if the effect is supported. (Must be called after compilation)
  37932. */
  37933. get isSupported(): boolean;
  37934. /**
  37935. * Binds a texture to the engine to be used as output of the shader.
  37936. * @param channel Name of the output variable.
  37937. * @param texture Texture to bind.
  37938. * @hidden
  37939. */
  37940. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  37941. /**
  37942. * Sets a texture on the engine to be used in the shader.
  37943. * @param channel Name of the sampler variable.
  37944. * @param texture Texture to set.
  37945. */
  37946. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  37947. /**
  37948. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  37949. * @param channel Name of the sampler variable.
  37950. * @param texture Texture to set.
  37951. */
  37952. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  37953. /**
  37954. * Sets an array of textures on the engine to be used in the shader.
  37955. * @param channel Name of the variable.
  37956. * @param textures Textures to set.
  37957. */
  37958. setTextureArray(channel: string, textures: BaseTexture[]): void;
  37959. /**
  37960. * 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)
  37961. * @param channel Name of the sampler variable.
  37962. * @param postProcess Post process to get the input texture from.
  37963. */
  37964. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  37965. /**
  37966. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  37967. * 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)
  37968. * @param channel Name of the sampler variable.
  37969. * @param postProcess Post process to get the output texture from.
  37970. */
  37971. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  37972. /** @hidden */
  37973. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  37974. /** @hidden */
  37975. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  37976. /** @hidden */
  37977. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  37978. /** @hidden */
  37979. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  37980. /**
  37981. * Binds a buffer to a uniform.
  37982. * @param buffer Buffer to bind.
  37983. * @param name Name of the uniform variable to bind to.
  37984. */
  37985. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  37986. /**
  37987. * Binds block to a uniform.
  37988. * @param blockName Name of the block to bind.
  37989. * @param index Index to bind.
  37990. */
  37991. bindUniformBlock(blockName: string, index: number): void;
  37992. /**
  37993. * Sets an interger value on a uniform variable.
  37994. * @param uniformName Name of the variable.
  37995. * @param value Value to be set.
  37996. * @returns this effect.
  37997. */
  37998. setInt(uniformName: string, value: number): Effect;
  37999. /**
  38000. * Sets an int array on a uniform variable.
  38001. * @param uniformName Name of the variable.
  38002. * @param array array to be set.
  38003. * @returns this effect.
  38004. */
  38005. setIntArray(uniformName: string, array: Int32Array): Effect;
  38006. /**
  38007. * 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)
  38008. * @param uniformName Name of the variable.
  38009. * @param array array to be set.
  38010. * @returns this effect.
  38011. */
  38012. setIntArray2(uniformName: string, array: Int32Array): Effect;
  38013. /**
  38014. * 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)
  38015. * @param uniformName Name of the variable.
  38016. * @param array array to be set.
  38017. * @returns this effect.
  38018. */
  38019. setIntArray3(uniformName: string, array: Int32Array): Effect;
  38020. /**
  38021. * 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)
  38022. * @param uniformName Name of the variable.
  38023. * @param array array to be set.
  38024. * @returns this effect.
  38025. */
  38026. setIntArray4(uniformName: string, array: Int32Array): Effect;
  38027. /**
  38028. * Sets an float array on a uniform variable.
  38029. * @param uniformName Name of the variable.
  38030. * @param array array to be set.
  38031. * @returns this effect.
  38032. */
  38033. setFloatArray(uniformName: string, array: Float32Array): Effect;
  38034. /**
  38035. * 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)
  38036. * @param uniformName Name of the variable.
  38037. * @param array array to be set.
  38038. * @returns this effect.
  38039. */
  38040. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  38041. /**
  38042. * 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)
  38043. * @param uniformName Name of the variable.
  38044. * @param array array to be set.
  38045. * @returns this effect.
  38046. */
  38047. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  38048. /**
  38049. * 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)
  38050. * @param uniformName Name of the variable.
  38051. * @param array array to be set.
  38052. * @returns this effect.
  38053. */
  38054. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  38055. /**
  38056. * Sets an array on a uniform variable.
  38057. * @param uniformName Name of the variable.
  38058. * @param array array to be set.
  38059. * @returns this effect.
  38060. */
  38061. setArray(uniformName: string, array: number[]): Effect;
  38062. /**
  38063. * 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)
  38064. * @param uniformName Name of the variable.
  38065. * @param array array to be set.
  38066. * @returns this effect.
  38067. */
  38068. setArray2(uniformName: string, array: number[]): Effect;
  38069. /**
  38070. * 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)
  38071. * @param uniformName Name of the variable.
  38072. * @param array array to be set.
  38073. * @returns this effect.
  38074. */
  38075. setArray3(uniformName: string, array: number[]): Effect;
  38076. /**
  38077. * 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)
  38078. * @param uniformName Name of the variable.
  38079. * @param array array to be set.
  38080. * @returns this effect.
  38081. */
  38082. setArray4(uniformName: string, array: number[]): Effect;
  38083. /**
  38084. * Sets matrices on a uniform variable.
  38085. * @param uniformName Name of the variable.
  38086. * @param matrices matrices to be set.
  38087. * @returns this effect.
  38088. */
  38089. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  38090. /**
  38091. * Sets matrix on a uniform variable.
  38092. * @param uniformName Name of the variable.
  38093. * @param matrix matrix to be set.
  38094. * @returns this effect.
  38095. */
  38096. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  38097. /**
  38098. * 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)
  38099. * @param uniformName Name of the variable.
  38100. * @param matrix matrix to be set.
  38101. * @returns this effect.
  38102. */
  38103. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  38104. /**
  38105. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  38106. * @param uniformName Name of the variable.
  38107. * @param matrix matrix to be set.
  38108. * @returns this effect.
  38109. */
  38110. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  38111. /**
  38112. * Sets a float on a uniform variable.
  38113. * @param uniformName Name of the variable.
  38114. * @param value value to be set.
  38115. * @returns this effect.
  38116. */
  38117. setFloat(uniformName: string, value: number): Effect;
  38118. /**
  38119. * Sets a boolean on a uniform variable.
  38120. * @param uniformName Name of the variable.
  38121. * @param bool value to be set.
  38122. * @returns this effect.
  38123. */
  38124. setBool(uniformName: string, bool: boolean): Effect;
  38125. /**
  38126. * Sets a Vector2 on a uniform variable.
  38127. * @param uniformName Name of the variable.
  38128. * @param vector2 vector2 to be set.
  38129. * @returns this effect.
  38130. */
  38131. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  38132. /**
  38133. * Sets a float2 on a uniform variable.
  38134. * @param uniformName Name of the variable.
  38135. * @param x First float in float2.
  38136. * @param y Second float in float2.
  38137. * @returns this effect.
  38138. */
  38139. setFloat2(uniformName: string, x: number, y: number): Effect;
  38140. /**
  38141. * Sets a Vector3 on a uniform variable.
  38142. * @param uniformName Name of the variable.
  38143. * @param vector3 Value to be set.
  38144. * @returns this effect.
  38145. */
  38146. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  38147. /**
  38148. * Sets a float3 on a uniform variable.
  38149. * @param uniformName Name of the variable.
  38150. * @param x First float in float3.
  38151. * @param y Second float in float3.
  38152. * @param z Third float in float3.
  38153. * @returns this effect.
  38154. */
  38155. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  38156. /**
  38157. * Sets a Vector4 on a uniform variable.
  38158. * @param uniformName Name of the variable.
  38159. * @param vector4 Value to be set.
  38160. * @returns this effect.
  38161. */
  38162. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  38163. /**
  38164. * Sets a float4 on a uniform variable.
  38165. * @param uniformName Name of the variable.
  38166. * @param x First float in float4.
  38167. * @param y Second float in float4.
  38168. * @param z Third float in float4.
  38169. * @param w Fourth float in float4.
  38170. * @returns this effect.
  38171. */
  38172. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  38173. /**
  38174. * Sets a Color3 on a uniform variable.
  38175. * @param uniformName Name of the variable.
  38176. * @param color3 Value to be set.
  38177. * @returns this effect.
  38178. */
  38179. setColor3(uniformName: string, color3: IColor3Like): Effect;
  38180. /**
  38181. * Sets a Color4 on a uniform variable.
  38182. * @param uniformName Name of the variable.
  38183. * @param color3 Value to be set.
  38184. * @param alpha Alpha value to be set.
  38185. * @returns this effect.
  38186. */
  38187. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  38188. /**
  38189. * Sets a Color4 on a uniform variable
  38190. * @param uniformName defines the name of the variable
  38191. * @param color4 defines the value to be set
  38192. * @returns this effect.
  38193. */
  38194. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  38195. /** Release all associated resources */
  38196. dispose(): void;
  38197. /**
  38198. * This function will add a new shader to the shader store
  38199. * @param name the name of the shader
  38200. * @param pixelShader optional pixel shader content
  38201. * @param vertexShader optional vertex shader content
  38202. */
  38203. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  38204. /**
  38205. * Store of each shader (The can be looked up using effect.key)
  38206. */
  38207. static ShadersStore: {
  38208. [key: string]: string;
  38209. };
  38210. /**
  38211. * Store of each included file for a shader (The can be looked up using effect.key)
  38212. */
  38213. static IncludesShadersStore: {
  38214. [key: string]: string;
  38215. };
  38216. /**
  38217. * Resets the cache of effects.
  38218. */
  38219. static ResetCache(): void;
  38220. }
  38221. }
  38222. declare module BABYLON {
  38223. /**
  38224. * Interface used to describe the capabilities of the engine relatively to the current browser
  38225. */
  38226. export interface EngineCapabilities {
  38227. /** Maximum textures units per fragment shader */
  38228. maxTexturesImageUnits: number;
  38229. /** Maximum texture units per vertex shader */
  38230. maxVertexTextureImageUnits: number;
  38231. /** Maximum textures units in the entire pipeline */
  38232. maxCombinedTexturesImageUnits: number;
  38233. /** Maximum texture size */
  38234. maxTextureSize: number;
  38235. /** Maximum texture samples */
  38236. maxSamples?: number;
  38237. /** Maximum cube texture size */
  38238. maxCubemapTextureSize: number;
  38239. /** Maximum render texture size */
  38240. maxRenderTextureSize: number;
  38241. /** Maximum number of vertex attributes */
  38242. maxVertexAttribs: number;
  38243. /** Maximum number of varyings */
  38244. maxVaryingVectors: number;
  38245. /** Maximum number of uniforms per vertex shader */
  38246. maxVertexUniformVectors: number;
  38247. /** Maximum number of uniforms per fragment shader */
  38248. maxFragmentUniformVectors: number;
  38249. /** Defines if standard derivates (dx/dy) are supported */
  38250. standardDerivatives: boolean;
  38251. /** Defines if s3tc texture compression is supported */
  38252. s3tc?: WEBGL_compressed_texture_s3tc;
  38253. /** Defines if pvrtc texture compression is supported */
  38254. pvrtc: any;
  38255. /** Defines if etc1 texture compression is supported */
  38256. etc1: any;
  38257. /** Defines if etc2 texture compression is supported */
  38258. etc2: any;
  38259. /** Defines if astc texture compression is supported */
  38260. astc: any;
  38261. /** Defines if bptc texture compression is supported */
  38262. bptc: any;
  38263. /** Defines if float textures are supported */
  38264. textureFloat: boolean;
  38265. /** Defines if vertex array objects are supported */
  38266. vertexArrayObject: boolean;
  38267. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  38268. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  38269. /** Gets the maximum level of anisotropy supported */
  38270. maxAnisotropy: number;
  38271. /** Defines if instancing is supported */
  38272. instancedArrays: boolean;
  38273. /** Defines if 32 bits indices are supported */
  38274. uintIndices: boolean;
  38275. /** Defines if high precision shaders are supported */
  38276. highPrecisionShaderSupported: boolean;
  38277. /** Defines if depth reading in the fragment shader is supported */
  38278. fragmentDepthSupported: boolean;
  38279. /** Defines if float texture linear filtering is supported*/
  38280. textureFloatLinearFiltering: boolean;
  38281. /** Defines if rendering to float textures is supported */
  38282. textureFloatRender: boolean;
  38283. /** Defines if half float textures are supported*/
  38284. textureHalfFloat: boolean;
  38285. /** Defines if half float texture linear filtering is supported*/
  38286. textureHalfFloatLinearFiltering: boolean;
  38287. /** Defines if rendering to half float textures is supported */
  38288. textureHalfFloatRender: boolean;
  38289. /** Defines if textureLOD shader command is supported */
  38290. textureLOD: boolean;
  38291. /** Defines if draw buffers extension is supported */
  38292. drawBuffersExtension: boolean;
  38293. /** Defines if depth textures are supported */
  38294. depthTextureExtension: boolean;
  38295. /** Defines if float color buffer are supported */
  38296. colorBufferFloat: boolean;
  38297. /** Gets disjoint timer query extension (null if not supported) */
  38298. timerQuery?: EXT_disjoint_timer_query;
  38299. /** Defines if timestamp can be used with timer query */
  38300. canUseTimestampForTimerQuery: boolean;
  38301. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  38302. multiview?: any;
  38303. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  38304. oculusMultiview?: any;
  38305. /** Function used to let the system compiles shaders in background */
  38306. parallelShaderCompile?: {
  38307. COMPLETION_STATUS_KHR: number;
  38308. };
  38309. /** Max number of texture samples for MSAA */
  38310. maxMSAASamples: number;
  38311. /** Defines if the blend min max extension is supported */
  38312. blendMinMax: boolean;
  38313. }
  38314. }
  38315. declare module BABYLON {
  38316. /**
  38317. * @hidden
  38318. **/
  38319. export class DepthCullingState {
  38320. private _isDepthTestDirty;
  38321. private _isDepthMaskDirty;
  38322. private _isDepthFuncDirty;
  38323. private _isCullFaceDirty;
  38324. private _isCullDirty;
  38325. private _isZOffsetDirty;
  38326. private _isFrontFaceDirty;
  38327. private _depthTest;
  38328. private _depthMask;
  38329. private _depthFunc;
  38330. private _cull;
  38331. private _cullFace;
  38332. private _zOffset;
  38333. private _frontFace;
  38334. /**
  38335. * Initializes the state.
  38336. */
  38337. constructor();
  38338. get isDirty(): boolean;
  38339. get zOffset(): number;
  38340. set zOffset(value: number);
  38341. get cullFace(): Nullable<number>;
  38342. set cullFace(value: Nullable<number>);
  38343. get cull(): Nullable<boolean>;
  38344. set cull(value: Nullable<boolean>);
  38345. get depthFunc(): Nullable<number>;
  38346. set depthFunc(value: Nullable<number>);
  38347. get depthMask(): boolean;
  38348. set depthMask(value: boolean);
  38349. get depthTest(): boolean;
  38350. set depthTest(value: boolean);
  38351. get frontFace(): Nullable<number>;
  38352. set frontFace(value: Nullable<number>);
  38353. reset(): void;
  38354. apply(gl: WebGLRenderingContext): void;
  38355. }
  38356. }
  38357. declare module BABYLON {
  38358. /**
  38359. * @hidden
  38360. **/
  38361. export class StencilState {
  38362. /** 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 */
  38363. static readonly ALWAYS: number;
  38364. /** Passed to stencilOperation to specify that stencil value must be kept */
  38365. static readonly KEEP: number;
  38366. /** Passed to stencilOperation to specify that stencil value must be replaced */
  38367. static readonly REPLACE: number;
  38368. private _isStencilTestDirty;
  38369. private _isStencilMaskDirty;
  38370. private _isStencilFuncDirty;
  38371. private _isStencilOpDirty;
  38372. private _stencilTest;
  38373. private _stencilMask;
  38374. private _stencilFunc;
  38375. private _stencilFuncRef;
  38376. private _stencilFuncMask;
  38377. private _stencilOpStencilFail;
  38378. private _stencilOpDepthFail;
  38379. private _stencilOpStencilDepthPass;
  38380. get isDirty(): boolean;
  38381. get stencilFunc(): number;
  38382. set stencilFunc(value: number);
  38383. get stencilFuncRef(): number;
  38384. set stencilFuncRef(value: number);
  38385. get stencilFuncMask(): number;
  38386. set stencilFuncMask(value: number);
  38387. get stencilOpStencilFail(): number;
  38388. set stencilOpStencilFail(value: number);
  38389. get stencilOpDepthFail(): number;
  38390. set stencilOpDepthFail(value: number);
  38391. get stencilOpStencilDepthPass(): number;
  38392. set stencilOpStencilDepthPass(value: number);
  38393. get stencilMask(): number;
  38394. set stencilMask(value: number);
  38395. get stencilTest(): boolean;
  38396. set stencilTest(value: boolean);
  38397. constructor();
  38398. reset(): void;
  38399. apply(gl: WebGLRenderingContext): void;
  38400. }
  38401. }
  38402. declare module BABYLON {
  38403. /**
  38404. * @hidden
  38405. **/
  38406. export class AlphaState {
  38407. private _isAlphaBlendDirty;
  38408. private _isBlendFunctionParametersDirty;
  38409. private _isBlendEquationParametersDirty;
  38410. private _isBlendConstantsDirty;
  38411. private _alphaBlend;
  38412. private _blendFunctionParameters;
  38413. private _blendEquationParameters;
  38414. private _blendConstants;
  38415. /**
  38416. * Initializes the state.
  38417. */
  38418. constructor();
  38419. get isDirty(): boolean;
  38420. get alphaBlend(): boolean;
  38421. set alphaBlend(value: boolean);
  38422. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  38423. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  38424. setAlphaEquationParameters(rgb: number, alpha: number): void;
  38425. reset(): void;
  38426. apply(gl: WebGLRenderingContext): void;
  38427. }
  38428. }
  38429. declare module BABYLON {
  38430. /** @hidden */
  38431. export class WebGLShaderProcessor implements IShaderProcessor {
  38432. postProcessor(code: string, defines: string[], isFragment: boolean, engine: ThinEngine): string;
  38433. }
  38434. }
  38435. declare module BABYLON {
  38436. /** @hidden */
  38437. export class WebGL2ShaderProcessor implements IShaderProcessor {
  38438. attributeProcessor(attribute: string): string;
  38439. varyingProcessor(varying: string, isFragment: boolean): string;
  38440. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  38441. }
  38442. }
  38443. declare module BABYLON {
  38444. /**
  38445. * Interface for attribute information associated with buffer instanciation
  38446. */
  38447. export interface InstancingAttributeInfo {
  38448. /**
  38449. * Name of the GLSL attribute
  38450. * if attribute index is not specified, this is used to retrieve the index from the effect
  38451. */
  38452. attributeName: string;
  38453. /**
  38454. * Index/offset of the attribute in the vertex shader
  38455. * if not specified, this will be computes from the name.
  38456. */
  38457. index?: number;
  38458. /**
  38459. * size of the attribute, 1, 2, 3 or 4
  38460. */
  38461. attributeSize: number;
  38462. /**
  38463. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  38464. */
  38465. offset: number;
  38466. /**
  38467. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  38468. * default to 1
  38469. */
  38470. divisor?: number;
  38471. /**
  38472. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  38473. * default is FLOAT
  38474. */
  38475. attributeType?: number;
  38476. /**
  38477. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  38478. */
  38479. normalized?: boolean;
  38480. }
  38481. }
  38482. declare module BABYLON {
  38483. interface ThinEngine {
  38484. /**
  38485. * Update a video texture
  38486. * @param texture defines the texture to update
  38487. * @param video defines the video element to use
  38488. * @param invertY defines if data must be stored with Y axis inverted
  38489. */
  38490. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  38491. }
  38492. }
  38493. declare module BABYLON {
  38494. interface ThinEngine {
  38495. /**
  38496. * Creates a dynamic texture
  38497. * @param width defines the width of the texture
  38498. * @param height defines the height of the texture
  38499. * @param generateMipMaps defines if the engine should generate the mip levels
  38500. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  38501. * @returns the dynamic texture inside an InternalTexture
  38502. */
  38503. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  38504. /**
  38505. * Update the content of a dynamic texture
  38506. * @param texture defines the texture to update
  38507. * @param canvas defines the canvas containing the source
  38508. * @param invertY defines if data must be stored with Y axis inverted
  38509. * @param premulAlpha defines if alpha is stored as premultiplied
  38510. * @param format defines the format of the data
  38511. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  38512. */
  38513. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  38514. }
  38515. }
  38516. declare module BABYLON {
  38517. /**
  38518. * Settings for finer control over video usage
  38519. */
  38520. export interface VideoTextureSettings {
  38521. /**
  38522. * Applies `autoplay` to video, if specified
  38523. */
  38524. autoPlay?: boolean;
  38525. /**
  38526. * Applies `muted` to video, if specified
  38527. */
  38528. muted?: boolean;
  38529. /**
  38530. * Applies `loop` to video, if specified
  38531. */
  38532. loop?: boolean;
  38533. /**
  38534. * Automatically updates internal texture from video at every frame in the render loop
  38535. */
  38536. autoUpdateTexture: boolean;
  38537. /**
  38538. * Image src displayed during the video loading or until the user interacts with the video.
  38539. */
  38540. poster?: string;
  38541. }
  38542. /**
  38543. * If you want to display a video in your scene, this is the special texture for that.
  38544. * This special texture works similar to other textures, with the exception of a few parameters.
  38545. * @see https://doc.babylonjs.com/how_to/video_texture
  38546. */
  38547. export class VideoTexture extends Texture {
  38548. /**
  38549. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  38550. */
  38551. readonly autoUpdateTexture: boolean;
  38552. /**
  38553. * The video instance used by the texture internally
  38554. */
  38555. readonly video: HTMLVideoElement;
  38556. private _onUserActionRequestedObservable;
  38557. /**
  38558. * Event triggerd when a dom action is required by the user to play the video.
  38559. * This happens due to recent changes in browser policies preventing video to auto start.
  38560. */
  38561. get onUserActionRequestedObservable(): Observable<Texture>;
  38562. private _generateMipMaps;
  38563. private _stillImageCaptured;
  38564. private _displayingPosterTexture;
  38565. private _settings;
  38566. private _createInternalTextureOnEvent;
  38567. private _frameId;
  38568. private _currentSrc;
  38569. /**
  38570. * Creates a video texture.
  38571. * If you want to display a video in your scene, this is the special texture for that.
  38572. * This special texture works similar to other textures, with the exception of a few parameters.
  38573. * @see https://doc.babylonjs.com/how_to/video_texture
  38574. * @param name optional name, will detect from video source, if not defined
  38575. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  38576. * @param scene is obviously the current scene.
  38577. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  38578. * @param invertY is false by default but can be used to invert video on Y axis
  38579. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  38580. * @param settings allows finer control over video usage
  38581. */
  38582. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  38583. private _getName;
  38584. private _getVideo;
  38585. private _createInternalTexture;
  38586. private reset;
  38587. /**
  38588. * @hidden Internal method to initiate `update`.
  38589. */
  38590. _rebuild(): void;
  38591. /**
  38592. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  38593. */
  38594. update(): void;
  38595. /**
  38596. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  38597. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  38598. */
  38599. updateTexture(isVisible: boolean): void;
  38600. protected _updateInternalTexture: () => void;
  38601. /**
  38602. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  38603. * @param url New url.
  38604. */
  38605. updateURL(url: string): void;
  38606. /**
  38607. * Clones the texture.
  38608. * @returns the cloned texture
  38609. */
  38610. clone(): VideoTexture;
  38611. /**
  38612. * Dispose the texture and release its associated resources.
  38613. */
  38614. dispose(): void;
  38615. /**
  38616. * Creates a video texture straight from a stream.
  38617. * @param scene Define the scene the texture should be created in
  38618. * @param stream Define the stream the texture should be created from
  38619. * @returns The created video texture as a promise
  38620. */
  38621. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  38622. /**
  38623. * Creates a video texture straight from your WebCam video feed.
  38624. * @param scene Define the scene the texture should be created in
  38625. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  38626. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  38627. * @returns The created video texture as a promise
  38628. */
  38629. static CreateFromWebCamAsync(scene: Scene, constraints: {
  38630. minWidth: number;
  38631. maxWidth: number;
  38632. minHeight: number;
  38633. maxHeight: number;
  38634. deviceId: string;
  38635. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  38636. /**
  38637. * Creates a video texture straight from your WebCam video feed.
  38638. * @param scene Define the scene the texture should be created in
  38639. * @param onReady Define a callback to triggered once the texture will be ready
  38640. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  38641. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  38642. */
  38643. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  38644. minWidth: number;
  38645. maxWidth: number;
  38646. minHeight: number;
  38647. maxHeight: number;
  38648. deviceId: string;
  38649. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  38650. }
  38651. }
  38652. declare module BABYLON {
  38653. /**
  38654. * Defines the interface used by objects working like Scene
  38655. * @hidden
  38656. */
  38657. export interface ISceneLike {
  38658. _addPendingData(data: any): void;
  38659. _removePendingData(data: any): void;
  38660. offlineProvider: IOfflineProvider;
  38661. }
  38662. /**
  38663. * Information about the current host
  38664. */
  38665. export interface HostInformation {
  38666. /**
  38667. * Defines if the current host is a mobile
  38668. */
  38669. isMobile: boolean;
  38670. }
  38671. /** Interface defining initialization parameters for Engine class */
  38672. export interface EngineOptions extends WebGLContextAttributes {
  38673. /**
  38674. * Defines if the engine should no exceed a specified device ratio
  38675. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  38676. */
  38677. limitDeviceRatio?: number;
  38678. /**
  38679. * Defines if webvr should be enabled automatically
  38680. * @see https://doc.babylonjs.com/how_to/webvr_camera
  38681. */
  38682. autoEnableWebVR?: boolean;
  38683. /**
  38684. * Defines if webgl2 should be turned off even if supported
  38685. * @see https://doc.babylonjs.com/features/webgl2
  38686. */
  38687. disableWebGL2Support?: boolean;
  38688. /**
  38689. * Defines if webaudio should be initialized as well
  38690. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38691. */
  38692. audioEngine?: boolean;
  38693. /**
  38694. * Defines if animations should run using a deterministic lock step
  38695. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38696. */
  38697. deterministicLockstep?: boolean;
  38698. /** Defines the maximum steps to use with deterministic lock step mode */
  38699. lockstepMaxSteps?: number;
  38700. /** Defines the seconds between each deterministic lock step */
  38701. timeStep?: number;
  38702. /**
  38703. * Defines that engine should ignore context lost events
  38704. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  38705. */
  38706. doNotHandleContextLost?: boolean;
  38707. /**
  38708. * Defines that engine should ignore modifying touch action attribute and style
  38709. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  38710. */
  38711. doNotHandleTouchAction?: boolean;
  38712. /**
  38713. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  38714. */
  38715. useHighPrecisionFloats?: boolean;
  38716. /**
  38717. * Make the canvas XR Compatible for XR sessions
  38718. */
  38719. xrCompatible?: boolean;
  38720. /**
  38721. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  38722. */
  38723. useHighPrecisionMatrix?: boolean;
  38724. /**
  38725. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  38726. */
  38727. failIfMajorPerformanceCaveat?: boolean;
  38728. }
  38729. /**
  38730. * The base engine class (root of all engines)
  38731. */
  38732. export class ThinEngine {
  38733. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  38734. static ExceptionList: ({
  38735. key: string;
  38736. capture: string;
  38737. captureConstraint: number;
  38738. targets: string[];
  38739. } | {
  38740. key: string;
  38741. capture: null;
  38742. captureConstraint: null;
  38743. targets: string[];
  38744. })[];
  38745. /** @hidden */
  38746. static _TextureLoaders: IInternalTextureLoader[];
  38747. /**
  38748. * Returns the current npm package of the sdk
  38749. */
  38750. static get NpmPackage(): string;
  38751. /**
  38752. * Returns the current version of the framework
  38753. */
  38754. static get Version(): string;
  38755. /**
  38756. * Returns a string describing the current engine
  38757. */
  38758. get description(): string;
  38759. /**
  38760. * Gets or sets the epsilon value used by collision engine
  38761. */
  38762. static CollisionsEpsilon: number;
  38763. /**
  38764. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  38765. */
  38766. static get ShadersRepository(): string;
  38767. static set ShadersRepository(value: string);
  38768. /** @hidden */
  38769. _shaderProcessor: IShaderProcessor;
  38770. /**
  38771. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  38772. */
  38773. forcePOTTextures: boolean;
  38774. /**
  38775. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  38776. */
  38777. isFullscreen: boolean;
  38778. /**
  38779. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  38780. */
  38781. cullBackFaces: boolean;
  38782. /**
  38783. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  38784. */
  38785. renderEvenInBackground: boolean;
  38786. /**
  38787. * Gets or sets a boolean indicating that cache can be kept between frames
  38788. */
  38789. preventCacheWipeBetweenFrames: boolean;
  38790. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  38791. validateShaderPrograms: boolean;
  38792. /**
  38793. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  38794. * This can provide greater z depth for distant objects.
  38795. */
  38796. useReverseDepthBuffer: boolean;
  38797. /**
  38798. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  38799. */
  38800. disableUniformBuffers: boolean;
  38801. /** @hidden */
  38802. _uniformBuffers: UniformBuffer[];
  38803. /**
  38804. * Gets a boolean indicating that the engine supports uniform buffers
  38805. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  38806. */
  38807. get supportsUniformBuffers(): boolean;
  38808. /** @hidden */
  38809. _gl: WebGLRenderingContext;
  38810. /** @hidden */
  38811. _webGLVersion: number;
  38812. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  38813. protected _windowIsBackground: boolean;
  38814. protected _creationOptions: EngineOptions;
  38815. protected _highPrecisionShadersAllowed: boolean;
  38816. /** @hidden */
  38817. get _shouldUseHighPrecisionShader(): boolean;
  38818. /**
  38819. * Gets a boolean indicating that only power of 2 textures are supported
  38820. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  38821. */
  38822. get needPOTTextures(): boolean;
  38823. /** @hidden */
  38824. _badOS: boolean;
  38825. /** @hidden */
  38826. _badDesktopOS: boolean;
  38827. private _hardwareScalingLevel;
  38828. /** @hidden */
  38829. _caps: EngineCapabilities;
  38830. private _isStencilEnable;
  38831. private _glVersion;
  38832. private _glRenderer;
  38833. private _glVendor;
  38834. /** @hidden */
  38835. _videoTextureSupported: boolean;
  38836. protected _renderingQueueLaunched: boolean;
  38837. protected _activeRenderLoops: (() => void)[];
  38838. /**
  38839. * Observable signaled when a context lost event is raised
  38840. */
  38841. onContextLostObservable: Observable<ThinEngine>;
  38842. /**
  38843. * Observable signaled when a context restored event is raised
  38844. */
  38845. onContextRestoredObservable: Observable<ThinEngine>;
  38846. private _onContextLost;
  38847. private _onContextRestored;
  38848. protected _contextWasLost: boolean;
  38849. /** @hidden */
  38850. _doNotHandleContextLost: boolean;
  38851. /**
  38852. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  38853. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  38854. */
  38855. get doNotHandleContextLost(): boolean;
  38856. set doNotHandleContextLost(value: boolean);
  38857. /**
  38858. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  38859. */
  38860. disableVertexArrayObjects: boolean;
  38861. /** @hidden */
  38862. protected _colorWrite: boolean;
  38863. /** @hidden */
  38864. protected _colorWriteChanged: boolean;
  38865. /** @hidden */
  38866. protected _depthCullingState: DepthCullingState;
  38867. /** @hidden */
  38868. protected _stencilState: StencilState;
  38869. /** @hidden */
  38870. _alphaState: AlphaState;
  38871. /** @hidden */
  38872. _alphaMode: number;
  38873. /** @hidden */
  38874. _alphaEquation: number;
  38875. /** @hidden */
  38876. _internalTexturesCache: InternalTexture[];
  38877. /** @hidden */
  38878. protected _activeChannel: number;
  38879. private _currentTextureChannel;
  38880. /** @hidden */
  38881. protected _boundTexturesCache: {
  38882. [key: string]: Nullable<InternalTexture>;
  38883. };
  38884. /** @hidden */
  38885. protected _currentEffect: Nullable<Effect>;
  38886. /** @hidden */
  38887. protected _currentProgram: Nullable<WebGLProgram>;
  38888. private _compiledEffects;
  38889. private _vertexAttribArraysEnabled;
  38890. /** @hidden */
  38891. protected _cachedViewport: Nullable<IViewportLike>;
  38892. private _cachedVertexArrayObject;
  38893. /** @hidden */
  38894. protected _cachedVertexBuffers: any;
  38895. /** @hidden */
  38896. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  38897. /** @hidden */
  38898. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  38899. /** @hidden */
  38900. _currentRenderTarget: Nullable<InternalTexture>;
  38901. private _uintIndicesCurrentlySet;
  38902. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  38903. /** @hidden */
  38904. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  38905. /** @hidden */
  38906. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  38907. private _currentBufferPointers;
  38908. private _currentInstanceLocations;
  38909. private _currentInstanceBuffers;
  38910. private _textureUnits;
  38911. /** @hidden */
  38912. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  38913. /** @hidden */
  38914. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  38915. /** @hidden */
  38916. _boundRenderFunction: any;
  38917. private _vaoRecordInProgress;
  38918. private _mustWipeVertexAttributes;
  38919. private _emptyTexture;
  38920. private _emptyCubeTexture;
  38921. private _emptyTexture3D;
  38922. private _emptyTexture2DArray;
  38923. /** @hidden */
  38924. _frameHandler: number;
  38925. private _nextFreeTextureSlots;
  38926. private _maxSimultaneousTextures;
  38927. private _activeRequests;
  38928. /** @hidden */
  38929. _transformTextureUrl: Nullable<(url: string) => string>;
  38930. /**
  38931. * Gets information about the current host
  38932. */
  38933. hostInformation: HostInformation;
  38934. protected get _supportsHardwareTextureRescaling(): boolean;
  38935. private _framebufferDimensionsObject;
  38936. /**
  38937. * sets the object from which width and height will be taken from when getting render width and height
  38938. * Will fallback to the gl object
  38939. * @param dimensions the framebuffer width and height that will be used.
  38940. */
  38941. set framebufferDimensionsObject(dimensions: Nullable<{
  38942. framebufferWidth: number;
  38943. framebufferHeight: number;
  38944. }>);
  38945. /**
  38946. * Gets the current viewport
  38947. */
  38948. get currentViewport(): Nullable<IViewportLike>;
  38949. /**
  38950. * Gets the default empty texture
  38951. */
  38952. get emptyTexture(): InternalTexture;
  38953. /**
  38954. * Gets the default empty 3D texture
  38955. */
  38956. get emptyTexture3D(): InternalTexture;
  38957. /**
  38958. * Gets the default empty 2D array texture
  38959. */
  38960. get emptyTexture2DArray(): InternalTexture;
  38961. /**
  38962. * Gets the default empty cube texture
  38963. */
  38964. get emptyCubeTexture(): InternalTexture;
  38965. /**
  38966. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  38967. */
  38968. readonly premultipliedAlpha: boolean;
  38969. /**
  38970. * Observable event triggered before each texture is initialized
  38971. */
  38972. onBeforeTextureInitObservable: Observable<Texture>;
  38973. /**
  38974. * Creates a new engine
  38975. * @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
  38976. * @param antialias defines enable antialiasing (default: false)
  38977. * @param options defines further options to be sent to the getContext() function
  38978. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  38979. */
  38980. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  38981. private _rebuildInternalTextures;
  38982. private _rebuildEffects;
  38983. /**
  38984. * Gets a boolean indicating if all created effects are ready
  38985. * @returns true if all effects are ready
  38986. */
  38987. areAllEffectsReady(): boolean;
  38988. protected _rebuildBuffers(): void;
  38989. protected _initGLContext(): void;
  38990. /**
  38991. * Gets version of the current webGL context
  38992. */
  38993. get webGLVersion(): number;
  38994. /**
  38995. * Gets a string identifying the name of the class
  38996. * @returns "Engine" string
  38997. */
  38998. getClassName(): string;
  38999. /**
  39000. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  39001. */
  39002. get isStencilEnable(): boolean;
  39003. /** @hidden */
  39004. _prepareWorkingCanvas(): void;
  39005. /**
  39006. * Reset the texture cache to empty state
  39007. */
  39008. resetTextureCache(): void;
  39009. /**
  39010. * Gets an object containing information about the current webGL context
  39011. * @returns an object containing the vender, the renderer and the version of the current webGL context
  39012. */
  39013. getGlInfo(): {
  39014. vendor: string;
  39015. renderer: string;
  39016. version: string;
  39017. };
  39018. /**
  39019. * Defines the hardware scaling level.
  39020. * By default the hardware scaling level is computed from the window device ratio.
  39021. * 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.
  39022. * @param level defines the level to use
  39023. */
  39024. setHardwareScalingLevel(level: number): void;
  39025. /**
  39026. * Gets the current hardware scaling level.
  39027. * By default the hardware scaling level is computed from the window device ratio.
  39028. * 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.
  39029. * @returns a number indicating the current hardware scaling level
  39030. */
  39031. getHardwareScalingLevel(): number;
  39032. /**
  39033. * Gets the list of loaded textures
  39034. * @returns an array containing all loaded textures
  39035. */
  39036. getLoadedTexturesCache(): InternalTexture[];
  39037. /**
  39038. * Gets the object containing all engine capabilities
  39039. * @returns the EngineCapabilities object
  39040. */
  39041. getCaps(): EngineCapabilities;
  39042. /**
  39043. * stop executing a render loop function and remove it from the execution array
  39044. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  39045. */
  39046. stopRenderLoop(renderFunction?: () => void): void;
  39047. /** @hidden */
  39048. _renderLoop(): void;
  39049. /**
  39050. * Gets the HTML canvas attached with the current webGL context
  39051. * @returns a HTML canvas
  39052. */
  39053. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  39054. /**
  39055. * Gets host window
  39056. * @returns the host window object
  39057. */
  39058. getHostWindow(): Nullable<Window>;
  39059. /**
  39060. * Gets the current render width
  39061. * @param useScreen defines if screen size must be used (or the current render target if any)
  39062. * @returns a number defining the current render width
  39063. */
  39064. getRenderWidth(useScreen?: boolean): number;
  39065. /**
  39066. * Gets the current render height
  39067. * @param useScreen defines if screen size must be used (or the current render target if any)
  39068. * @returns a number defining the current render height
  39069. */
  39070. getRenderHeight(useScreen?: boolean): number;
  39071. /**
  39072. * Can be used to override the current requestAnimationFrame requester.
  39073. * @hidden
  39074. */
  39075. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  39076. /**
  39077. * Register and execute a render loop. The engine can have more than one render function
  39078. * @param renderFunction defines the function to continuously execute
  39079. */
  39080. runRenderLoop(renderFunction: () => void): void;
  39081. /**
  39082. * Clear the current render buffer or the current render target (if any is set up)
  39083. * @param color defines the color to use
  39084. * @param backBuffer defines if the back buffer must be cleared
  39085. * @param depth defines if the depth buffer must be cleared
  39086. * @param stencil defines if the stencil buffer must be cleared
  39087. */
  39088. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  39089. private _viewportCached;
  39090. /** @hidden */
  39091. _viewport(x: number, y: number, width: number, height: number): void;
  39092. /**
  39093. * Set the WebGL's viewport
  39094. * @param viewport defines the viewport element to be used
  39095. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  39096. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  39097. */
  39098. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  39099. /**
  39100. * Begin a new frame
  39101. */
  39102. beginFrame(): void;
  39103. /**
  39104. * Enf the current frame
  39105. */
  39106. endFrame(): void;
  39107. /**
  39108. * Resize the view according to the canvas' size
  39109. */
  39110. resize(): void;
  39111. /**
  39112. * Force a specific size of the canvas
  39113. * @param width defines the new canvas' width
  39114. * @param height defines the new canvas' height
  39115. * @returns true if the size was changed
  39116. */
  39117. setSize(width: number, height: number): boolean;
  39118. /**
  39119. * Binds the frame buffer to the specified texture.
  39120. * @param texture The texture to render to or null for the default canvas
  39121. * @param faceIndex The face of the texture to render to in case of cube texture
  39122. * @param requiredWidth The width of the target to render to
  39123. * @param requiredHeight The height of the target to render to
  39124. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  39125. * @param lodLevel defines the lod level to bind to the frame buffer
  39126. * @param layer defines the 2d array index to bind to frame buffer to
  39127. */
  39128. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  39129. /** @hidden */
  39130. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  39131. /**
  39132. * Unbind the current render target texture from the webGL context
  39133. * @param texture defines the render target texture to unbind
  39134. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  39135. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  39136. */
  39137. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  39138. /**
  39139. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  39140. */
  39141. flushFramebuffer(): void;
  39142. /**
  39143. * Unbind the current render target and bind the default framebuffer
  39144. */
  39145. restoreDefaultFramebuffer(): void;
  39146. /** @hidden */
  39147. protected _resetVertexBufferBinding(): void;
  39148. /**
  39149. * Creates a vertex buffer
  39150. * @param data the data for the vertex buffer
  39151. * @returns the new WebGL static buffer
  39152. */
  39153. createVertexBuffer(data: DataArray): DataBuffer;
  39154. private _createVertexBuffer;
  39155. /**
  39156. * Creates a dynamic vertex buffer
  39157. * @param data the data for the dynamic vertex buffer
  39158. * @returns the new WebGL dynamic buffer
  39159. */
  39160. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  39161. protected _resetIndexBufferBinding(): void;
  39162. /**
  39163. * Creates a new index buffer
  39164. * @param indices defines the content of the index buffer
  39165. * @param updatable defines if the index buffer must be updatable
  39166. * @returns a new webGL buffer
  39167. */
  39168. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  39169. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  39170. /**
  39171. * Bind a webGL buffer to the webGL context
  39172. * @param buffer defines the buffer to bind
  39173. */
  39174. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  39175. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  39176. private bindBuffer;
  39177. /**
  39178. * update the bound buffer with the given data
  39179. * @param data defines the data to update
  39180. */
  39181. updateArrayBuffer(data: Float32Array): void;
  39182. private _vertexAttribPointer;
  39183. /** @hidden */
  39184. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  39185. private _bindVertexBuffersAttributes;
  39186. /**
  39187. * Records a vertex array object
  39188. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  39189. * @param vertexBuffers defines the list of vertex buffers to store
  39190. * @param indexBuffer defines the index buffer to store
  39191. * @param effect defines the effect to store
  39192. * @returns the new vertex array object
  39193. */
  39194. recordVertexArrayObject(vertexBuffers: {
  39195. [key: string]: VertexBuffer;
  39196. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  39197. /**
  39198. * Bind a specific vertex array object
  39199. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  39200. * @param vertexArrayObject defines the vertex array object to bind
  39201. * @param indexBuffer defines the index buffer to bind
  39202. */
  39203. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  39204. /**
  39205. * Bind webGl buffers directly to the webGL context
  39206. * @param vertexBuffer defines the vertex buffer to bind
  39207. * @param indexBuffer defines the index buffer to bind
  39208. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  39209. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  39210. * @param effect defines the effect associated with the vertex buffer
  39211. */
  39212. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  39213. private _unbindVertexArrayObject;
  39214. /**
  39215. * Bind a list of vertex buffers to the webGL context
  39216. * @param vertexBuffers defines the list of vertex buffers to bind
  39217. * @param indexBuffer defines the index buffer to bind
  39218. * @param effect defines the effect associated with the vertex buffers
  39219. */
  39220. bindBuffers(vertexBuffers: {
  39221. [key: string]: Nullable<VertexBuffer>;
  39222. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  39223. /**
  39224. * Unbind all instance attributes
  39225. */
  39226. unbindInstanceAttributes(): void;
  39227. /**
  39228. * Release and free the memory of a vertex array object
  39229. * @param vao defines the vertex array object to delete
  39230. */
  39231. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  39232. /** @hidden */
  39233. _releaseBuffer(buffer: DataBuffer): boolean;
  39234. protected _deleteBuffer(buffer: DataBuffer): void;
  39235. /**
  39236. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  39237. * @param instancesBuffer defines the webGL buffer to update and bind
  39238. * @param data defines the data to store in the buffer
  39239. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  39240. */
  39241. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  39242. /**
  39243. * Bind the content of a webGL buffer used with instantiation
  39244. * @param instancesBuffer defines the webGL buffer to bind
  39245. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  39246. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  39247. */
  39248. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  39249. /**
  39250. * Disable the instance attribute corresponding to the name in parameter
  39251. * @param name defines the name of the attribute to disable
  39252. */
  39253. disableInstanceAttributeByName(name: string): void;
  39254. /**
  39255. * Disable the instance attribute corresponding to the location in parameter
  39256. * @param attributeLocation defines the attribute location of the attribute to disable
  39257. */
  39258. disableInstanceAttribute(attributeLocation: number): void;
  39259. /**
  39260. * Disable the attribute corresponding to the location in parameter
  39261. * @param attributeLocation defines the attribute location of the attribute to disable
  39262. */
  39263. disableAttributeByIndex(attributeLocation: number): void;
  39264. /**
  39265. * Send a draw order
  39266. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  39267. * @param indexStart defines the starting index
  39268. * @param indexCount defines the number of index to draw
  39269. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39270. */
  39271. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  39272. /**
  39273. * Draw a list of points
  39274. * @param verticesStart defines the index of first vertex to draw
  39275. * @param verticesCount defines the count of vertices to draw
  39276. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39277. */
  39278. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39279. /**
  39280. * Draw a list of unindexed primitives
  39281. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  39282. * @param verticesStart defines the index of first vertex to draw
  39283. * @param verticesCount defines the count of vertices to draw
  39284. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39285. */
  39286. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39287. /**
  39288. * Draw a list of indexed primitives
  39289. * @param fillMode defines the primitive to use
  39290. * @param indexStart defines the starting index
  39291. * @param indexCount defines the number of index to draw
  39292. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39293. */
  39294. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  39295. /**
  39296. * Draw a list of unindexed primitives
  39297. * @param fillMode defines the primitive to use
  39298. * @param verticesStart defines the index of first vertex to draw
  39299. * @param verticesCount defines the count of vertices to draw
  39300. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39301. */
  39302. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39303. private _drawMode;
  39304. /** @hidden */
  39305. protected _reportDrawCall(): void;
  39306. /** @hidden */
  39307. _releaseEffect(effect: Effect): void;
  39308. /** @hidden */
  39309. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  39310. /**
  39311. * Create a new effect (used to store vertex/fragment shaders)
  39312. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  39313. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  39314. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  39315. * @param samplers defines an array of string used to represent textures
  39316. * @param defines defines the string containing the defines to use to compile the shaders
  39317. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  39318. * @param onCompiled defines a function to call when the effect creation is successful
  39319. * @param onError defines a function to call when the effect creation has failed
  39320. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  39321. * @returns the new Effect
  39322. */
  39323. 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;
  39324. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  39325. private _compileShader;
  39326. private _compileRawShader;
  39327. /** @hidden */
  39328. _getShaderSource(shader: WebGLShader): Nullable<string>;
  39329. /**
  39330. * Directly creates a webGL program
  39331. * @param pipelineContext defines the pipeline context to attach to
  39332. * @param vertexCode defines the vertex shader code to use
  39333. * @param fragmentCode defines the fragment shader code to use
  39334. * @param context defines the webGL context to use (if not set, the current one will be used)
  39335. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  39336. * @returns the new webGL program
  39337. */
  39338. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39339. /**
  39340. * Creates a webGL program
  39341. * @param pipelineContext defines the pipeline context to attach to
  39342. * @param vertexCode defines the vertex shader code to use
  39343. * @param fragmentCode defines the fragment shader code to use
  39344. * @param defines defines the string containing the defines to use to compile the shaders
  39345. * @param context defines the webGL context to use (if not set, the current one will be used)
  39346. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  39347. * @returns the new webGL program
  39348. */
  39349. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39350. /**
  39351. * Creates a new pipeline context
  39352. * @returns the new pipeline
  39353. */
  39354. createPipelineContext(): IPipelineContext;
  39355. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39356. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  39357. /** @hidden */
  39358. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  39359. /** @hidden */
  39360. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  39361. /** @hidden */
  39362. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  39363. /**
  39364. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  39365. * @param pipelineContext defines the pipeline context to use
  39366. * @param uniformsNames defines the list of uniform names
  39367. * @returns an array of webGL uniform locations
  39368. */
  39369. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  39370. /**
  39371. * Gets the lsit of active attributes for a given webGL program
  39372. * @param pipelineContext defines the pipeline context to use
  39373. * @param attributesNames defines the list of attribute names to get
  39374. * @returns an array of indices indicating the offset of each attribute
  39375. */
  39376. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  39377. /**
  39378. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  39379. * @param effect defines the effect to activate
  39380. */
  39381. enableEffect(effect: Nullable<Effect>): void;
  39382. /**
  39383. * Set the value of an uniform to a number (int)
  39384. * @param uniform defines the webGL uniform location where to store the value
  39385. * @param value defines the int number to store
  39386. * @returns true if the value was set
  39387. */
  39388. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  39389. /**
  39390. * Set the value of an uniform to an array of int32
  39391. * @param uniform defines the webGL uniform location where to store the value
  39392. * @param array defines the array of int32 to store
  39393. * @returns true if the value was set
  39394. */
  39395. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39396. /**
  39397. * Set the value of an uniform to an array of int32 (stored as vec2)
  39398. * @param uniform defines the webGL uniform location where to store the value
  39399. * @param array defines the array of int32 to store
  39400. * @returns true if the value was set
  39401. */
  39402. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39403. /**
  39404. * Set the value of an uniform to an array of int32 (stored as vec3)
  39405. * @param uniform defines the webGL uniform location where to store the value
  39406. * @param array defines the array of int32 to store
  39407. * @returns true if the value was set
  39408. */
  39409. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39410. /**
  39411. * Set the value of an uniform to an array of int32 (stored as vec4)
  39412. * @param uniform defines the webGL uniform location where to store the value
  39413. * @param array defines the array of int32 to store
  39414. * @returns true if the value was set
  39415. */
  39416. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39417. /**
  39418. * Set the value of an uniform to an array of number
  39419. * @param uniform defines the webGL uniform location where to store the value
  39420. * @param array defines the array of number to store
  39421. * @returns true if the value was set
  39422. */
  39423. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39424. /**
  39425. * Set the value of an uniform to an array of number (stored as vec2)
  39426. * @param uniform defines the webGL uniform location where to store the value
  39427. * @param array defines the array of number to store
  39428. * @returns true if the value was set
  39429. */
  39430. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39431. /**
  39432. * Set the value of an uniform to an array of number (stored as vec3)
  39433. * @param uniform defines the webGL uniform location where to store the value
  39434. * @param array defines the array of number to store
  39435. * @returns true if the value was set
  39436. */
  39437. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39438. /**
  39439. * Set the value of an uniform to an array of number (stored as vec4)
  39440. * @param uniform defines the webGL uniform location where to store the value
  39441. * @param array defines the array of number to store
  39442. * @returns true if the value was set
  39443. */
  39444. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39445. /**
  39446. * Set the value of an uniform to an array of float32 (stored as matrices)
  39447. * @param uniform defines the webGL uniform location where to store the value
  39448. * @param matrices defines the array of float32 to store
  39449. * @returns true if the value was set
  39450. */
  39451. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  39452. /**
  39453. * Set the value of an uniform to a matrix (3x3)
  39454. * @param uniform defines the webGL uniform location where to store the value
  39455. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  39456. * @returns true if the value was set
  39457. */
  39458. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  39459. /**
  39460. * Set the value of an uniform to a matrix (2x2)
  39461. * @param uniform defines the webGL uniform location where to store the value
  39462. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  39463. * @returns true if the value was set
  39464. */
  39465. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  39466. /**
  39467. * Set the value of an uniform to a number (float)
  39468. * @param uniform defines the webGL uniform location where to store the value
  39469. * @param value defines the float number to store
  39470. * @returns true if the value was transfered
  39471. */
  39472. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  39473. /**
  39474. * Set the value of an uniform to a vec2
  39475. * @param uniform defines the webGL uniform location where to store the value
  39476. * @param x defines the 1st component of the value
  39477. * @param y defines the 2nd component of the value
  39478. * @returns true if the value was set
  39479. */
  39480. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  39481. /**
  39482. * Set the value of an uniform to a vec3
  39483. * @param uniform defines the webGL uniform location where to store the value
  39484. * @param x defines the 1st component of the value
  39485. * @param y defines the 2nd component of the value
  39486. * @param z defines the 3rd component of the value
  39487. * @returns true if the value was set
  39488. */
  39489. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  39490. /**
  39491. * Set the value of an uniform to a vec4
  39492. * @param uniform defines the webGL uniform location where to store the value
  39493. * @param x defines the 1st component of the value
  39494. * @param y defines the 2nd component of the value
  39495. * @param z defines the 3rd component of the value
  39496. * @param w defines the 4th component of the value
  39497. * @returns true if the value was set
  39498. */
  39499. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  39500. /**
  39501. * Apply all cached states (depth, culling, stencil and alpha)
  39502. */
  39503. applyStates(): void;
  39504. /**
  39505. * Enable or disable color writing
  39506. * @param enable defines the state to set
  39507. */
  39508. setColorWrite(enable: boolean): void;
  39509. /**
  39510. * Gets a boolean indicating if color writing is enabled
  39511. * @returns the current color writing state
  39512. */
  39513. getColorWrite(): boolean;
  39514. /**
  39515. * Gets the depth culling state manager
  39516. */
  39517. get depthCullingState(): DepthCullingState;
  39518. /**
  39519. * Gets the alpha state manager
  39520. */
  39521. get alphaState(): AlphaState;
  39522. /**
  39523. * Gets the stencil state manager
  39524. */
  39525. get stencilState(): StencilState;
  39526. /**
  39527. * Clears the list of texture accessible through engine.
  39528. * This can help preventing texture load conflict due to name collision.
  39529. */
  39530. clearInternalTexturesCache(): void;
  39531. /**
  39532. * Force the entire cache to be cleared
  39533. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  39534. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  39535. */
  39536. wipeCaches(bruteForce?: boolean): void;
  39537. /** @hidden */
  39538. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  39539. min: number;
  39540. mag: number;
  39541. };
  39542. /** @hidden */
  39543. _createTexture(): WebGLTexture;
  39544. /**
  39545. * Usually called from Texture.ts.
  39546. * Passed information to create a WebGLTexture
  39547. * @param url defines a value which contains one of the following:
  39548. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  39549. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  39550. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  39551. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  39552. * @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)
  39553. * @param scene needed for loading to the correct scene
  39554. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  39555. * @param onLoad optional callback to be called upon successful completion
  39556. * @param onError optional callback to be called upon failure
  39557. * @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
  39558. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  39559. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  39560. * @param forcedExtension defines the extension to use to pick the right loader
  39561. * @param mimeType defines an optional mime type
  39562. * @param loaderOptions options to be passed to the loader
  39563. * @returns a InternalTexture for assignment back into BABYLON.Texture
  39564. */
  39565. 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;
  39566. /**
  39567. * Loads an image as an HTMLImageElement.
  39568. * @param input url string, ArrayBuffer, or Blob to load
  39569. * @param onLoad callback called when the image successfully loads
  39570. * @param onError callback called when the image fails to load
  39571. * @param offlineProvider offline provider for caching
  39572. * @param mimeType optional mime type
  39573. * @returns the HTMLImageElement of the loaded image
  39574. * @hidden
  39575. */
  39576. 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>;
  39577. /**
  39578. * @hidden
  39579. */
  39580. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  39581. private _unpackFlipYCached;
  39582. /**
  39583. * In case you are sharing the context with other applications, it might
  39584. * be interested to not cache the unpack flip y state to ensure a consistent
  39585. * value would be set.
  39586. */
  39587. enableUnpackFlipYCached: boolean;
  39588. /** @hidden */
  39589. _unpackFlipY(value: boolean): void;
  39590. /** @hidden */
  39591. _getUnpackAlignement(): number;
  39592. private _getTextureTarget;
  39593. /**
  39594. * Update the sampling mode of a given texture
  39595. * @param samplingMode defines the required sampling mode
  39596. * @param texture defines the texture to update
  39597. * @param generateMipMaps defines whether to generate mipmaps for the texture
  39598. */
  39599. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  39600. /**
  39601. * Update the sampling mode of a given texture
  39602. * @param texture defines the texture to update
  39603. * @param wrapU defines the texture wrap mode of the u coordinates
  39604. * @param wrapV defines the texture wrap mode of the v coordinates
  39605. * @param wrapR defines the texture wrap mode of the r coordinates
  39606. */
  39607. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  39608. /** @hidden */
  39609. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  39610. width: number;
  39611. height: number;
  39612. layers?: number;
  39613. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  39614. /** @hidden */
  39615. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39616. /** @hidden */
  39617. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  39618. /**
  39619. * Update a portion of an internal texture
  39620. * @param texture defines the texture to update
  39621. * @param imageData defines the data to store into the texture
  39622. * @param xOffset defines the x coordinates of the update rectangle
  39623. * @param yOffset defines the y coordinates of the update rectangle
  39624. * @param width defines the width of the update rectangle
  39625. * @param height defines the height of the update rectangle
  39626. * @param faceIndex defines the face index if texture is a cube (0 by default)
  39627. * @param lod defines the lod level to update (0 by default)
  39628. */
  39629. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  39630. /** @hidden */
  39631. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39632. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  39633. private _prepareWebGLTexture;
  39634. /** @hidden */
  39635. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  39636. private _getDepthStencilBuffer;
  39637. /** @hidden */
  39638. _releaseFramebufferObjects(texture: InternalTexture): void;
  39639. /** @hidden */
  39640. _releaseTexture(texture: InternalTexture): void;
  39641. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  39642. protected _setProgram(program: WebGLProgram): void;
  39643. protected _boundUniforms: {
  39644. [key: number]: WebGLUniformLocation;
  39645. };
  39646. /**
  39647. * Binds an effect to the webGL context
  39648. * @param effect defines the effect to bind
  39649. */
  39650. bindSamplers(effect: Effect): void;
  39651. private _activateCurrentTexture;
  39652. /** @hidden */
  39653. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  39654. /** @hidden */
  39655. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  39656. /**
  39657. * Unbind all textures from the webGL context
  39658. */
  39659. unbindAllTextures(): void;
  39660. /**
  39661. * Sets a texture to the according uniform.
  39662. * @param channel The texture channel
  39663. * @param uniform The uniform to set
  39664. * @param texture The texture to apply
  39665. */
  39666. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  39667. private _bindSamplerUniformToChannel;
  39668. private _getTextureWrapMode;
  39669. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  39670. /**
  39671. * Sets an array of texture to the webGL context
  39672. * @param channel defines the channel where the texture array must be set
  39673. * @param uniform defines the associated uniform location
  39674. * @param textures defines the array of textures to bind
  39675. */
  39676. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  39677. /** @hidden */
  39678. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  39679. private _setTextureParameterFloat;
  39680. private _setTextureParameterInteger;
  39681. /**
  39682. * Unbind all vertex attributes from the webGL context
  39683. */
  39684. unbindAllAttributes(): void;
  39685. /**
  39686. * 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
  39687. */
  39688. releaseEffects(): void;
  39689. /**
  39690. * Dispose and release all associated resources
  39691. */
  39692. dispose(): void;
  39693. /**
  39694. * Attach a new callback raised when context lost event is fired
  39695. * @param callback defines the callback to call
  39696. */
  39697. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  39698. /**
  39699. * Attach a new callback raised when context restored event is fired
  39700. * @param callback defines the callback to call
  39701. */
  39702. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  39703. /**
  39704. * Get the current error code of the webGL context
  39705. * @returns the error code
  39706. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  39707. */
  39708. getError(): number;
  39709. private _canRenderToFloatFramebuffer;
  39710. private _canRenderToHalfFloatFramebuffer;
  39711. private _canRenderToFramebuffer;
  39712. /** @hidden */
  39713. _getWebGLTextureType(type: number): number;
  39714. /** @hidden */
  39715. _getInternalFormat(format: number): number;
  39716. /** @hidden */
  39717. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  39718. /** @hidden */
  39719. _getRGBAMultiSampleBufferFormat(type: number): number;
  39720. /** @hidden */
  39721. _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;
  39722. /**
  39723. * Loads a file from a url
  39724. * @param url url to load
  39725. * @param onSuccess callback called when the file successfully loads
  39726. * @param onProgress callback called while file is loading (if the server supports this mode)
  39727. * @param offlineProvider defines the offline provider for caching
  39728. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39729. * @param onError callback called when the file fails to load
  39730. * @returns a file request object
  39731. * @hidden
  39732. */
  39733. 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;
  39734. /**
  39735. * Reads pixels from the current frame buffer. Please note that this function can be slow
  39736. * @param x defines the x coordinate of the rectangle where pixels must be read
  39737. * @param y defines the y coordinate of the rectangle where pixels must be read
  39738. * @param width defines the width of the rectangle where pixels must be read
  39739. * @param height defines the height of the rectangle where pixels must be read
  39740. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  39741. * @returns a Uint8Array containing RGBA colors
  39742. */
  39743. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  39744. private static _IsSupported;
  39745. private static _HasMajorPerformanceCaveat;
  39746. /**
  39747. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  39748. */
  39749. static get IsSupported(): boolean;
  39750. /**
  39751. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  39752. * @returns true if the engine can be created
  39753. * @ignorenaming
  39754. */
  39755. static isSupported(): boolean;
  39756. /**
  39757. * 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)
  39758. */
  39759. static get HasMajorPerformanceCaveat(): boolean;
  39760. /**
  39761. * Find the next highest power of two.
  39762. * @param x Number to start search from.
  39763. * @return Next highest power of two.
  39764. */
  39765. static CeilingPOT(x: number): number;
  39766. /**
  39767. * Find the next lowest power of two.
  39768. * @param x Number to start search from.
  39769. * @return Next lowest power of two.
  39770. */
  39771. static FloorPOT(x: number): number;
  39772. /**
  39773. * Find the nearest power of two.
  39774. * @param x Number to start search from.
  39775. * @return Next nearest power of two.
  39776. */
  39777. static NearestPOT(x: number): number;
  39778. /**
  39779. * Get the closest exponent of two
  39780. * @param value defines the value to approximate
  39781. * @param max defines the maximum value to return
  39782. * @param mode defines how to define the closest value
  39783. * @returns closest exponent of two of the given value
  39784. */
  39785. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  39786. /**
  39787. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  39788. * @param func - the function to be called
  39789. * @param requester - the object that will request the next frame. Falls back to window.
  39790. * @returns frame number
  39791. */
  39792. static QueueNewFrame(func: () => void, requester?: any): number;
  39793. /**
  39794. * Gets host document
  39795. * @returns the host document object
  39796. */
  39797. getHostDocument(): Nullable<Document>;
  39798. }
  39799. }
  39800. declare module BABYLON {
  39801. /**
  39802. * Defines the source of the internal texture
  39803. */
  39804. export enum InternalTextureSource {
  39805. /**
  39806. * The source of the texture data is unknown
  39807. */
  39808. Unknown = 0,
  39809. /**
  39810. * Texture data comes from an URL
  39811. */
  39812. Url = 1,
  39813. /**
  39814. * Texture data is only used for temporary storage
  39815. */
  39816. Temp = 2,
  39817. /**
  39818. * Texture data comes from raw data (ArrayBuffer)
  39819. */
  39820. Raw = 3,
  39821. /**
  39822. * Texture content is dynamic (video or dynamic texture)
  39823. */
  39824. Dynamic = 4,
  39825. /**
  39826. * Texture content is generated by rendering to it
  39827. */
  39828. RenderTarget = 5,
  39829. /**
  39830. * Texture content is part of a multi render target process
  39831. */
  39832. MultiRenderTarget = 6,
  39833. /**
  39834. * Texture data comes from a cube data file
  39835. */
  39836. Cube = 7,
  39837. /**
  39838. * Texture data comes from a raw cube data
  39839. */
  39840. CubeRaw = 8,
  39841. /**
  39842. * Texture data come from a prefiltered cube data file
  39843. */
  39844. CubePrefiltered = 9,
  39845. /**
  39846. * Texture content is raw 3D data
  39847. */
  39848. Raw3D = 10,
  39849. /**
  39850. * Texture content is raw 2D array data
  39851. */
  39852. Raw2DArray = 11,
  39853. /**
  39854. * Texture content is a depth texture
  39855. */
  39856. Depth = 12,
  39857. /**
  39858. * Texture data comes from a raw cube data encoded with RGBD
  39859. */
  39860. CubeRawRGBD = 13
  39861. }
  39862. /**
  39863. * Class used to store data associated with WebGL texture data for the engine
  39864. * This class should not be used directly
  39865. */
  39866. export class InternalTexture {
  39867. /** @hidden */
  39868. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  39869. /**
  39870. * Defines if the texture is ready
  39871. */
  39872. isReady: boolean;
  39873. /**
  39874. * Defines if the texture is a cube texture
  39875. */
  39876. isCube: boolean;
  39877. /**
  39878. * Defines if the texture contains 3D data
  39879. */
  39880. is3D: boolean;
  39881. /**
  39882. * Defines if the texture contains 2D array data
  39883. */
  39884. is2DArray: boolean;
  39885. /**
  39886. * Defines if the texture contains multiview data
  39887. */
  39888. isMultiview: boolean;
  39889. /**
  39890. * Gets the URL used to load this texture
  39891. */
  39892. url: string;
  39893. /**
  39894. * Gets the sampling mode of the texture
  39895. */
  39896. samplingMode: number;
  39897. /**
  39898. * Gets a boolean indicating if the texture needs mipmaps generation
  39899. */
  39900. generateMipMaps: boolean;
  39901. /**
  39902. * Gets the number of samples used by the texture (WebGL2+ only)
  39903. */
  39904. samples: number;
  39905. /**
  39906. * Gets the type of the texture (int, float...)
  39907. */
  39908. type: number;
  39909. /**
  39910. * Gets the format of the texture (RGB, RGBA...)
  39911. */
  39912. format: number;
  39913. /**
  39914. * Observable called when the texture is loaded
  39915. */
  39916. onLoadedObservable: Observable<InternalTexture>;
  39917. /**
  39918. * Gets the width of the texture
  39919. */
  39920. width: number;
  39921. /**
  39922. * Gets the height of the texture
  39923. */
  39924. height: number;
  39925. /**
  39926. * Gets the depth of the texture
  39927. */
  39928. depth: number;
  39929. /**
  39930. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  39931. */
  39932. baseWidth: number;
  39933. /**
  39934. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  39935. */
  39936. baseHeight: number;
  39937. /**
  39938. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  39939. */
  39940. baseDepth: number;
  39941. /**
  39942. * Gets a boolean indicating if the texture is inverted on Y axis
  39943. */
  39944. invertY: boolean;
  39945. /** @hidden */
  39946. _invertVScale: boolean;
  39947. /** @hidden */
  39948. _associatedChannel: number;
  39949. /** @hidden */
  39950. _source: InternalTextureSource;
  39951. /** @hidden */
  39952. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  39953. /** @hidden */
  39954. _bufferView: Nullable<ArrayBufferView>;
  39955. /** @hidden */
  39956. _bufferViewArray: Nullable<ArrayBufferView[]>;
  39957. /** @hidden */
  39958. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  39959. /** @hidden */
  39960. _size: number;
  39961. /** @hidden */
  39962. _extension: string;
  39963. /** @hidden */
  39964. _files: Nullable<string[]>;
  39965. /** @hidden */
  39966. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  39967. /** @hidden */
  39968. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  39969. /** @hidden */
  39970. _framebuffer: Nullable<WebGLFramebuffer>;
  39971. /** @hidden */
  39972. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  39973. /** @hidden */
  39974. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  39975. /** @hidden */
  39976. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  39977. /** @hidden */
  39978. _attachments: Nullable<number[]>;
  39979. /** @hidden */
  39980. _textureArray: Nullable<InternalTexture[]>;
  39981. /** @hidden */
  39982. _cachedCoordinatesMode: Nullable<number>;
  39983. /** @hidden */
  39984. _cachedWrapU: Nullable<number>;
  39985. /** @hidden */
  39986. _cachedWrapV: Nullable<number>;
  39987. /** @hidden */
  39988. _cachedWrapR: Nullable<number>;
  39989. /** @hidden */
  39990. _cachedAnisotropicFilteringLevel: Nullable<number>;
  39991. /** @hidden */
  39992. _isDisabled: boolean;
  39993. /** @hidden */
  39994. _compression: Nullable<string>;
  39995. /** @hidden */
  39996. _generateStencilBuffer: boolean;
  39997. /** @hidden */
  39998. _generateDepthBuffer: boolean;
  39999. /** @hidden */
  40000. _comparisonFunction: number;
  40001. /** @hidden */
  40002. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  40003. /** @hidden */
  40004. _lodGenerationScale: number;
  40005. /** @hidden */
  40006. _lodGenerationOffset: number;
  40007. /** @hidden */
  40008. _depthStencilTexture: Nullable<InternalTexture>;
  40009. /** @hidden */
  40010. _colorTextureArray: Nullable<WebGLTexture>;
  40011. /** @hidden */
  40012. _depthStencilTextureArray: Nullable<WebGLTexture>;
  40013. /** @hidden */
  40014. _lodTextureHigh: Nullable<BaseTexture>;
  40015. /** @hidden */
  40016. _lodTextureMid: Nullable<BaseTexture>;
  40017. /** @hidden */
  40018. _lodTextureLow: Nullable<BaseTexture>;
  40019. /** @hidden */
  40020. _isRGBD: boolean;
  40021. /** @hidden */
  40022. _linearSpecularLOD: boolean;
  40023. /** @hidden */
  40024. _irradianceTexture: Nullable<BaseTexture>;
  40025. /** @hidden */
  40026. _webGLTexture: Nullable<WebGLTexture>;
  40027. /** @hidden */
  40028. _references: number;
  40029. /** @hidden */
  40030. _gammaSpace: Nullable<boolean>;
  40031. private _engine;
  40032. /**
  40033. * Gets the Engine the texture belongs to.
  40034. * @returns The babylon engine
  40035. */
  40036. getEngine(): ThinEngine;
  40037. /**
  40038. * Gets the data source type of the texture
  40039. */
  40040. get source(): InternalTextureSource;
  40041. /**
  40042. * Creates a new InternalTexture
  40043. * @param engine defines the engine to use
  40044. * @param source defines the type of data that will be used
  40045. * @param delayAllocation if the texture allocation should be delayed (default: false)
  40046. */
  40047. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  40048. /**
  40049. * Increments the number of references (ie. the number of Texture that point to it)
  40050. */
  40051. incrementReferences(): void;
  40052. /**
  40053. * Change the size of the texture (not the size of the content)
  40054. * @param width defines the new width
  40055. * @param height defines the new height
  40056. * @param depth defines the new depth (1 by default)
  40057. */
  40058. updateSize(width: int, height: int, depth?: int): void;
  40059. /** @hidden */
  40060. _rebuild(): void;
  40061. /** @hidden */
  40062. _swapAndDie(target: InternalTexture): void;
  40063. /**
  40064. * Dispose the current allocated resources
  40065. */
  40066. dispose(): void;
  40067. }
  40068. }
  40069. declare module BABYLON {
  40070. /**
  40071. * Class used to work with sound analyzer using fast fourier transform (FFT)
  40072. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40073. */
  40074. export class Analyser {
  40075. /**
  40076. * Gets or sets the smoothing
  40077. * @ignorenaming
  40078. */
  40079. SMOOTHING: number;
  40080. /**
  40081. * Gets or sets the FFT table size
  40082. * @ignorenaming
  40083. */
  40084. FFT_SIZE: number;
  40085. /**
  40086. * Gets or sets the bar graph amplitude
  40087. * @ignorenaming
  40088. */
  40089. BARGRAPHAMPLITUDE: number;
  40090. /**
  40091. * Gets or sets the position of the debug canvas
  40092. * @ignorenaming
  40093. */
  40094. DEBUGCANVASPOS: {
  40095. x: number;
  40096. y: number;
  40097. };
  40098. /**
  40099. * Gets or sets the debug canvas size
  40100. * @ignorenaming
  40101. */
  40102. DEBUGCANVASSIZE: {
  40103. width: number;
  40104. height: number;
  40105. };
  40106. private _byteFreqs;
  40107. private _byteTime;
  40108. private _floatFreqs;
  40109. private _webAudioAnalyser;
  40110. private _debugCanvas;
  40111. private _debugCanvasContext;
  40112. private _scene;
  40113. private _registerFunc;
  40114. private _audioEngine;
  40115. /**
  40116. * Creates a new analyser
  40117. * @param scene defines hosting scene
  40118. */
  40119. constructor(scene: Scene);
  40120. /**
  40121. * Get the number of data values you will have to play with for the visualization
  40122. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  40123. * @returns a number
  40124. */
  40125. getFrequencyBinCount(): number;
  40126. /**
  40127. * Gets the current frequency data as a byte array
  40128. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  40129. * @returns a Uint8Array
  40130. */
  40131. getByteFrequencyData(): Uint8Array;
  40132. /**
  40133. * Gets the current waveform as a byte array
  40134. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  40135. * @returns a Uint8Array
  40136. */
  40137. getByteTimeDomainData(): Uint8Array;
  40138. /**
  40139. * Gets the current frequency data as a float array
  40140. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  40141. * @returns a Float32Array
  40142. */
  40143. getFloatFrequencyData(): Float32Array;
  40144. /**
  40145. * Renders the debug canvas
  40146. */
  40147. drawDebugCanvas(): void;
  40148. /**
  40149. * Stops rendering the debug canvas and removes it
  40150. */
  40151. stopDebugCanvas(): void;
  40152. /**
  40153. * Connects two audio nodes
  40154. * @param inputAudioNode defines first node to connect
  40155. * @param outputAudioNode defines second node to connect
  40156. */
  40157. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  40158. /**
  40159. * Releases all associated resources
  40160. */
  40161. dispose(): void;
  40162. }
  40163. }
  40164. declare module BABYLON {
  40165. /**
  40166. * This represents an audio engine and it is responsible
  40167. * to play, synchronize and analyse sounds throughout the application.
  40168. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40169. */
  40170. export interface IAudioEngine extends IDisposable {
  40171. /**
  40172. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  40173. */
  40174. readonly canUseWebAudio: boolean;
  40175. /**
  40176. * Gets the current AudioContext if available.
  40177. */
  40178. readonly audioContext: Nullable<AudioContext>;
  40179. /**
  40180. * The master gain node defines the global audio volume of your audio engine.
  40181. */
  40182. readonly masterGain: GainNode;
  40183. /**
  40184. * Gets whether or not mp3 are supported by your browser.
  40185. */
  40186. readonly isMP3supported: boolean;
  40187. /**
  40188. * Gets whether or not ogg are supported by your browser.
  40189. */
  40190. readonly isOGGsupported: boolean;
  40191. /**
  40192. * Defines if Babylon should emit a warning if WebAudio is not supported.
  40193. * @ignoreNaming
  40194. */
  40195. WarnedWebAudioUnsupported: boolean;
  40196. /**
  40197. * Defines if the audio engine relies on a custom unlocked button.
  40198. * In this case, the embedded button will not be displayed.
  40199. */
  40200. useCustomUnlockedButton: boolean;
  40201. /**
  40202. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  40203. */
  40204. readonly unlocked: boolean;
  40205. /**
  40206. * Event raised when audio has been unlocked on the browser.
  40207. */
  40208. onAudioUnlockedObservable: Observable<AudioEngine>;
  40209. /**
  40210. * Event raised when audio has been locked on the browser.
  40211. */
  40212. onAudioLockedObservable: Observable<AudioEngine>;
  40213. /**
  40214. * Flags the audio engine in Locked state.
  40215. * This happens due to new browser policies preventing audio to autoplay.
  40216. */
  40217. lock(): void;
  40218. /**
  40219. * Unlocks the audio engine once a user action has been done on the dom.
  40220. * This is helpful to resume play once browser policies have been satisfied.
  40221. */
  40222. unlock(): void;
  40223. /**
  40224. * Gets the global volume sets on the master gain.
  40225. * @returns the global volume if set or -1 otherwise
  40226. */
  40227. getGlobalVolume(): number;
  40228. /**
  40229. * Sets the global volume of your experience (sets on the master gain).
  40230. * @param newVolume Defines the new global volume of the application
  40231. */
  40232. setGlobalVolume(newVolume: number): void;
  40233. /**
  40234. * Connect the audio engine to an audio analyser allowing some amazing
  40235. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  40236. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  40237. * @param analyser The analyser to connect to the engine
  40238. */
  40239. connectToAnalyser(analyser: Analyser): void;
  40240. }
  40241. /**
  40242. * This represents the default audio engine used in babylon.
  40243. * It is responsible to play, synchronize and analyse sounds throughout the application.
  40244. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40245. */
  40246. export class AudioEngine implements IAudioEngine {
  40247. private _audioContext;
  40248. private _audioContextInitialized;
  40249. private _muteButton;
  40250. private _hostElement;
  40251. /**
  40252. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  40253. */
  40254. canUseWebAudio: boolean;
  40255. /**
  40256. * The master gain node defines the global audio volume of your audio engine.
  40257. */
  40258. masterGain: GainNode;
  40259. /**
  40260. * Defines if Babylon should emit a warning if WebAudio is not supported.
  40261. * @ignoreNaming
  40262. */
  40263. WarnedWebAudioUnsupported: boolean;
  40264. /**
  40265. * Gets whether or not mp3 are supported by your browser.
  40266. */
  40267. isMP3supported: boolean;
  40268. /**
  40269. * Gets whether or not ogg are supported by your browser.
  40270. */
  40271. isOGGsupported: boolean;
  40272. /**
  40273. * Gets whether audio has been unlocked on the device.
  40274. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  40275. * a user interaction has happened.
  40276. */
  40277. unlocked: boolean;
  40278. /**
  40279. * Defines if the audio engine relies on a custom unlocked button.
  40280. * In this case, the embedded button will not be displayed.
  40281. */
  40282. useCustomUnlockedButton: boolean;
  40283. /**
  40284. * Event raised when audio has been unlocked on the browser.
  40285. */
  40286. onAudioUnlockedObservable: Observable<AudioEngine>;
  40287. /**
  40288. * Event raised when audio has been locked on the browser.
  40289. */
  40290. onAudioLockedObservable: Observable<AudioEngine>;
  40291. /**
  40292. * Gets the current AudioContext if available.
  40293. */
  40294. get audioContext(): Nullable<AudioContext>;
  40295. private _connectedAnalyser;
  40296. /**
  40297. * Instantiates a new audio engine.
  40298. *
  40299. * There should be only one per page as some browsers restrict the number
  40300. * of audio contexts you can create.
  40301. * @param hostElement defines the host element where to display the mute icon if necessary
  40302. */
  40303. constructor(hostElement?: Nullable<HTMLElement>);
  40304. /**
  40305. * Flags the audio engine in Locked state.
  40306. * This happens due to new browser policies preventing audio to autoplay.
  40307. */
  40308. lock(): void;
  40309. /**
  40310. * Unlocks the audio engine once a user action has been done on the dom.
  40311. * This is helpful to resume play once browser policies have been satisfied.
  40312. */
  40313. unlock(): void;
  40314. private _resumeAudioContext;
  40315. private _initializeAudioContext;
  40316. private _tryToRun;
  40317. private _triggerRunningState;
  40318. private _triggerSuspendedState;
  40319. private _displayMuteButton;
  40320. private _moveButtonToTopLeft;
  40321. private _onResize;
  40322. private _hideMuteButton;
  40323. /**
  40324. * Destroy and release the resources associated with the audio ccontext.
  40325. */
  40326. dispose(): void;
  40327. /**
  40328. * Gets the global volume sets on the master gain.
  40329. * @returns the global volume if set or -1 otherwise
  40330. */
  40331. getGlobalVolume(): number;
  40332. /**
  40333. * Sets the global volume of your experience (sets on the master gain).
  40334. * @param newVolume Defines the new global volume of the application
  40335. */
  40336. setGlobalVolume(newVolume: number): void;
  40337. /**
  40338. * Connect the audio engine to an audio analyser allowing some amazing
  40339. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  40340. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  40341. * @param analyser The analyser to connect to the engine
  40342. */
  40343. connectToAnalyser(analyser: Analyser): void;
  40344. }
  40345. }
  40346. declare module BABYLON {
  40347. /**
  40348. * Interface used to present a loading screen while loading a scene
  40349. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  40350. */
  40351. export interface ILoadingScreen {
  40352. /**
  40353. * Function called to display the loading screen
  40354. */
  40355. displayLoadingUI: () => void;
  40356. /**
  40357. * Function called to hide the loading screen
  40358. */
  40359. hideLoadingUI: () => void;
  40360. /**
  40361. * Gets or sets the color to use for the background
  40362. */
  40363. loadingUIBackgroundColor: string;
  40364. /**
  40365. * Gets or sets the text to display while loading
  40366. */
  40367. loadingUIText: string;
  40368. }
  40369. /**
  40370. * Class used for the default loading screen
  40371. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  40372. */
  40373. export class DefaultLoadingScreen implements ILoadingScreen {
  40374. private _renderingCanvas;
  40375. private _loadingText;
  40376. private _loadingDivBackgroundColor;
  40377. private _loadingDiv;
  40378. private _loadingTextDiv;
  40379. /** Gets or sets the logo url to use for the default loading screen */
  40380. static DefaultLogoUrl: string;
  40381. /** Gets or sets the spinner url to use for the default loading screen */
  40382. static DefaultSpinnerUrl: string;
  40383. /**
  40384. * Creates a new default loading screen
  40385. * @param _renderingCanvas defines the canvas used to render the scene
  40386. * @param _loadingText defines the default text to display
  40387. * @param _loadingDivBackgroundColor defines the default background color
  40388. */
  40389. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  40390. /**
  40391. * Function called to display the loading screen
  40392. */
  40393. displayLoadingUI(): void;
  40394. /**
  40395. * Function called to hide the loading screen
  40396. */
  40397. hideLoadingUI(): void;
  40398. /**
  40399. * Gets or sets the text to display while loading
  40400. */
  40401. set loadingUIText(text: string);
  40402. get loadingUIText(): string;
  40403. /**
  40404. * Gets or sets the color to use for the background
  40405. */
  40406. get loadingUIBackgroundColor(): string;
  40407. set loadingUIBackgroundColor(color: string);
  40408. private _resizeLoadingUI;
  40409. }
  40410. }
  40411. declare module BABYLON {
  40412. /**
  40413. * Interface for any object that can request an animation frame
  40414. */
  40415. export interface ICustomAnimationFrameRequester {
  40416. /**
  40417. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  40418. */
  40419. renderFunction?: Function;
  40420. /**
  40421. * Called to request the next frame to render to
  40422. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  40423. */
  40424. requestAnimationFrame: Function;
  40425. /**
  40426. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  40427. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  40428. */
  40429. requestID?: number;
  40430. }
  40431. }
  40432. declare module BABYLON {
  40433. /**
  40434. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  40435. */
  40436. export class PerformanceMonitor {
  40437. private _enabled;
  40438. private _rollingFrameTime;
  40439. private _lastFrameTimeMs;
  40440. /**
  40441. * constructor
  40442. * @param frameSampleSize The number of samples required to saturate the sliding window
  40443. */
  40444. constructor(frameSampleSize?: number);
  40445. /**
  40446. * Samples current frame
  40447. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  40448. */
  40449. sampleFrame(timeMs?: number): void;
  40450. /**
  40451. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  40452. */
  40453. get averageFrameTime(): number;
  40454. /**
  40455. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  40456. */
  40457. get averageFrameTimeVariance(): number;
  40458. /**
  40459. * Returns the frame time of the most recent frame
  40460. */
  40461. get instantaneousFrameTime(): number;
  40462. /**
  40463. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  40464. */
  40465. get averageFPS(): number;
  40466. /**
  40467. * Returns the average framerate in frames per second using the most recent frame time
  40468. */
  40469. get instantaneousFPS(): number;
  40470. /**
  40471. * Returns true if enough samples have been taken to completely fill the sliding window
  40472. */
  40473. get isSaturated(): boolean;
  40474. /**
  40475. * Enables contributions to the sliding window sample set
  40476. */
  40477. enable(): void;
  40478. /**
  40479. * Disables contributions to the sliding window sample set
  40480. * Samples will not be interpolated over the disabled period
  40481. */
  40482. disable(): void;
  40483. /**
  40484. * Returns true if sampling is enabled
  40485. */
  40486. get isEnabled(): boolean;
  40487. /**
  40488. * Resets performance monitor
  40489. */
  40490. reset(): void;
  40491. }
  40492. /**
  40493. * RollingAverage
  40494. *
  40495. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  40496. */
  40497. export class RollingAverage {
  40498. /**
  40499. * Current average
  40500. */
  40501. average: number;
  40502. /**
  40503. * Current variance
  40504. */
  40505. variance: number;
  40506. protected _samples: Array<number>;
  40507. protected _sampleCount: number;
  40508. protected _pos: number;
  40509. protected _m2: number;
  40510. /**
  40511. * constructor
  40512. * @param length The number of samples required to saturate the sliding window
  40513. */
  40514. constructor(length: number);
  40515. /**
  40516. * Adds a sample to the sample set
  40517. * @param v The sample value
  40518. */
  40519. add(v: number): void;
  40520. /**
  40521. * Returns previously added values or null if outside of history or outside the sliding window domain
  40522. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  40523. * @return Value previously recorded with add() or null if outside of range
  40524. */
  40525. history(i: number): number;
  40526. /**
  40527. * Returns true if enough samples have been taken to completely fill the sliding window
  40528. * @return true if sample-set saturated
  40529. */
  40530. isSaturated(): boolean;
  40531. /**
  40532. * Resets the rolling average (equivalent to 0 samples taken so far)
  40533. */
  40534. reset(): void;
  40535. /**
  40536. * Wraps a value around the sample range boundaries
  40537. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  40538. * @return Wrapped position in sample range
  40539. */
  40540. protected _wrapPosition(i: number): number;
  40541. }
  40542. }
  40543. declare module BABYLON {
  40544. /**
  40545. * This class is used to track a performance counter which is number based.
  40546. * The user has access to many properties which give statistics of different nature.
  40547. *
  40548. * The implementer can track two kinds of Performance Counter: time and count.
  40549. * 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.
  40550. * 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.
  40551. */
  40552. export class PerfCounter {
  40553. /**
  40554. * Gets or sets a global boolean to turn on and off all the counters
  40555. */
  40556. static Enabled: boolean;
  40557. /**
  40558. * Returns the smallest value ever
  40559. */
  40560. get min(): number;
  40561. /**
  40562. * Returns the biggest value ever
  40563. */
  40564. get max(): number;
  40565. /**
  40566. * Returns the average value since the performance counter is running
  40567. */
  40568. get average(): number;
  40569. /**
  40570. * Returns the average value of the last second the counter was monitored
  40571. */
  40572. get lastSecAverage(): number;
  40573. /**
  40574. * Returns the current value
  40575. */
  40576. get current(): number;
  40577. /**
  40578. * Gets the accumulated total
  40579. */
  40580. get total(): number;
  40581. /**
  40582. * Gets the total value count
  40583. */
  40584. get count(): number;
  40585. /**
  40586. * Creates a new counter
  40587. */
  40588. constructor();
  40589. /**
  40590. * Call this method to start monitoring a new frame.
  40591. * 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.
  40592. */
  40593. fetchNewFrame(): void;
  40594. /**
  40595. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  40596. * @param newCount the count value to add to the monitored count
  40597. * @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.
  40598. */
  40599. addCount(newCount: number, fetchResult: boolean): void;
  40600. /**
  40601. * Start monitoring this performance counter
  40602. */
  40603. beginMonitoring(): void;
  40604. /**
  40605. * Compute the time lapsed since the previous beginMonitoring() call.
  40606. * @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
  40607. */
  40608. endMonitoring(newFrame?: boolean): void;
  40609. private _fetchResult;
  40610. private _startMonitoringTime;
  40611. private _min;
  40612. private _max;
  40613. private _average;
  40614. private _current;
  40615. private _totalValueCount;
  40616. private _totalAccumulated;
  40617. private _lastSecAverage;
  40618. private _lastSecAccumulated;
  40619. private _lastSecTime;
  40620. private _lastSecValueCount;
  40621. }
  40622. }
  40623. declare module BABYLON {
  40624. interface ThinEngine {
  40625. /** @hidden */
  40626. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  40627. }
  40628. }
  40629. declare module BABYLON {
  40630. /**
  40631. * Defines the interface used by display changed events
  40632. */
  40633. export interface IDisplayChangedEventArgs {
  40634. /** Gets the vrDisplay object (if any) */
  40635. vrDisplay: Nullable<any>;
  40636. /** Gets a boolean indicating if webVR is supported */
  40637. vrSupported: boolean;
  40638. }
  40639. /**
  40640. * Defines the interface used by objects containing a viewport (like a camera)
  40641. */
  40642. interface IViewportOwnerLike {
  40643. /**
  40644. * Gets or sets the viewport
  40645. */
  40646. viewport: IViewportLike;
  40647. }
  40648. /**
  40649. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  40650. */
  40651. export class Engine extends ThinEngine {
  40652. /** Defines that alpha blending is disabled */
  40653. static readonly ALPHA_DISABLE: number;
  40654. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  40655. static readonly ALPHA_ADD: number;
  40656. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  40657. static readonly ALPHA_COMBINE: number;
  40658. /** Defines that alpha blending to DEST - SRC * DEST */
  40659. static readonly ALPHA_SUBTRACT: number;
  40660. /** Defines that alpha blending to SRC * DEST */
  40661. static readonly ALPHA_MULTIPLY: number;
  40662. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  40663. static readonly ALPHA_MAXIMIZED: number;
  40664. /** Defines that alpha blending to SRC + DEST */
  40665. static readonly ALPHA_ONEONE: number;
  40666. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  40667. static readonly ALPHA_PREMULTIPLIED: number;
  40668. /**
  40669. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  40670. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  40671. */
  40672. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  40673. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  40674. static readonly ALPHA_INTERPOLATE: number;
  40675. /**
  40676. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  40677. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  40678. */
  40679. static readonly ALPHA_SCREENMODE: number;
  40680. /** Defines that the ressource is not delayed*/
  40681. static readonly DELAYLOADSTATE_NONE: number;
  40682. /** Defines that the ressource was successfully delay loaded */
  40683. static readonly DELAYLOADSTATE_LOADED: number;
  40684. /** Defines that the ressource is currently delay loading */
  40685. static readonly DELAYLOADSTATE_LOADING: number;
  40686. /** Defines that the ressource is delayed and has not started loading */
  40687. static readonly DELAYLOADSTATE_NOTLOADED: number;
  40688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  40689. static readonly NEVER: number;
  40690. /** 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 */
  40691. static readonly ALWAYS: number;
  40692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  40693. static readonly LESS: number;
  40694. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  40695. static readonly EQUAL: number;
  40696. /** 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 */
  40697. static readonly LEQUAL: number;
  40698. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  40699. static readonly GREATER: number;
  40700. /** 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 */
  40701. static readonly GEQUAL: number;
  40702. /** 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 */
  40703. static readonly NOTEQUAL: number;
  40704. /** Passed to stencilOperation to specify that stencil value must be kept */
  40705. static readonly KEEP: number;
  40706. /** Passed to stencilOperation to specify that stencil value must be replaced */
  40707. static readonly REPLACE: number;
  40708. /** Passed to stencilOperation to specify that stencil value must be incremented */
  40709. static readonly INCR: number;
  40710. /** Passed to stencilOperation to specify that stencil value must be decremented */
  40711. static readonly DECR: number;
  40712. /** Passed to stencilOperation to specify that stencil value must be inverted */
  40713. static readonly INVERT: number;
  40714. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  40715. static readonly INCR_WRAP: number;
  40716. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  40717. static readonly DECR_WRAP: number;
  40718. /** Texture is not repeating outside of 0..1 UVs */
  40719. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  40720. /** Texture is repeating outside of 0..1 UVs */
  40721. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  40722. /** Texture is repeating and mirrored */
  40723. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  40724. /** ALPHA */
  40725. static readonly TEXTUREFORMAT_ALPHA: number;
  40726. /** LUMINANCE */
  40727. static readonly TEXTUREFORMAT_LUMINANCE: number;
  40728. /** LUMINANCE_ALPHA */
  40729. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  40730. /** RGB */
  40731. static readonly TEXTUREFORMAT_RGB: number;
  40732. /** RGBA */
  40733. static readonly TEXTUREFORMAT_RGBA: number;
  40734. /** RED */
  40735. static readonly TEXTUREFORMAT_RED: number;
  40736. /** RED (2nd reference) */
  40737. static readonly TEXTUREFORMAT_R: number;
  40738. /** RG */
  40739. static readonly TEXTUREFORMAT_RG: number;
  40740. /** RED_INTEGER */
  40741. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  40742. /** RED_INTEGER (2nd reference) */
  40743. static readonly TEXTUREFORMAT_R_INTEGER: number;
  40744. /** RG_INTEGER */
  40745. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  40746. /** RGB_INTEGER */
  40747. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  40748. /** RGBA_INTEGER */
  40749. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  40750. /** UNSIGNED_BYTE */
  40751. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  40752. /** UNSIGNED_BYTE (2nd reference) */
  40753. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  40754. /** FLOAT */
  40755. static readonly TEXTURETYPE_FLOAT: number;
  40756. /** HALF_FLOAT */
  40757. static readonly TEXTURETYPE_HALF_FLOAT: number;
  40758. /** BYTE */
  40759. static readonly TEXTURETYPE_BYTE: number;
  40760. /** SHORT */
  40761. static readonly TEXTURETYPE_SHORT: number;
  40762. /** UNSIGNED_SHORT */
  40763. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  40764. /** INT */
  40765. static readonly TEXTURETYPE_INT: number;
  40766. /** UNSIGNED_INT */
  40767. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  40768. /** UNSIGNED_SHORT_4_4_4_4 */
  40769. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  40770. /** UNSIGNED_SHORT_5_5_5_1 */
  40771. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  40772. /** UNSIGNED_SHORT_5_6_5 */
  40773. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  40774. /** UNSIGNED_INT_2_10_10_10_REV */
  40775. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  40776. /** UNSIGNED_INT_24_8 */
  40777. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  40778. /** UNSIGNED_INT_10F_11F_11F_REV */
  40779. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  40780. /** UNSIGNED_INT_5_9_9_9_REV */
  40781. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  40782. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  40783. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  40784. /** nearest is mag = nearest and min = nearest and mip = linear */
  40785. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  40786. /** Bilinear is mag = linear and min = linear and mip = nearest */
  40787. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  40788. /** Trilinear is mag = linear and min = linear and mip = linear */
  40789. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  40790. /** nearest is mag = nearest and min = nearest and mip = linear */
  40791. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  40792. /** Bilinear is mag = linear and min = linear and mip = nearest */
  40793. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  40794. /** Trilinear is mag = linear and min = linear and mip = linear */
  40795. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  40796. /** mag = nearest and min = nearest and mip = nearest */
  40797. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  40798. /** mag = nearest and min = linear and mip = nearest */
  40799. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  40800. /** mag = nearest and min = linear and mip = linear */
  40801. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  40802. /** mag = nearest and min = linear and mip = none */
  40803. static readonly TEXTURE_NEAREST_LINEAR: number;
  40804. /** mag = nearest and min = nearest and mip = none */
  40805. static readonly TEXTURE_NEAREST_NEAREST: number;
  40806. /** mag = linear and min = nearest and mip = nearest */
  40807. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  40808. /** mag = linear and min = nearest and mip = linear */
  40809. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  40810. /** mag = linear and min = linear and mip = none */
  40811. static readonly TEXTURE_LINEAR_LINEAR: number;
  40812. /** mag = linear and min = nearest and mip = none */
  40813. static readonly TEXTURE_LINEAR_NEAREST: number;
  40814. /** Explicit coordinates mode */
  40815. static readonly TEXTURE_EXPLICIT_MODE: number;
  40816. /** Spherical coordinates mode */
  40817. static readonly TEXTURE_SPHERICAL_MODE: number;
  40818. /** Planar coordinates mode */
  40819. static readonly TEXTURE_PLANAR_MODE: number;
  40820. /** Cubic coordinates mode */
  40821. static readonly TEXTURE_CUBIC_MODE: number;
  40822. /** Projection coordinates mode */
  40823. static readonly TEXTURE_PROJECTION_MODE: number;
  40824. /** Skybox coordinates mode */
  40825. static readonly TEXTURE_SKYBOX_MODE: number;
  40826. /** Inverse Cubic coordinates mode */
  40827. static readonly TEXTURE_INVCUBIC_MODE: number;
  40828. /** Equirectangular coordinates mode */
  40829. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  40830. /** Equirectangular Fixed coordinates mode */
  40831. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  40832. /** Equirectangular Fixed Mirrored coordinates mode */
  40833. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  40834. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  40835. static readonly SCALEMODE_FLOOR: number;
  40836. /** Defines that texture rescaling will look for the nearest power of 2 size */
  40837. static readonly SCALEMODE_NEAREST: number;
  40838. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  40839. static readonly SCALEMODE_CEILING: number;
  40840. /**
  40841. * Returns the current npm package of the sdk
  40842. */
  40843. static get NpmPackage(): string;
  40844. /**
  40845. * Returns the current version of the framework
  40846. */
  40847. static get Version(): string;
  40848. /** Gets the list of created engines */
  40849. static get Instances(): Engine[];
  40850. /**
  40851. * Gets the latest created engine
  40852. */
  40853. static get LastCreatedEngine(): Nullable<Engine>;
  40854. /**
  40855. * Gets the latest created scene
  40856. */
  40857. static get LastCreatedScene(): Nullable<Scene>;
  40858. /**
  40859. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  40860. * @param flag defines which part of the materials must be marked as dirty
  40861. * @param predicate defines a predicate used to filter which materials should be affected
  40862. */
  40863. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  40864. /**
  40865. * Method called to create the default loading screen.
  40866. * This can be overriden in your own app.
  40867. * @param canvas The rendering canvas element
  40868. * @returns The loading screen
  40869. */
  40870. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  40871. /**
  40872. * Method called to create the default rescale post process on each engine.
  40873. */
  40874. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  40875. /**
  40876. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  40877. **/
  40878. enableOfflineSupport: boolean;
  40879. /**
  40880. * 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)
  40881. **/
  40882. disableManifestCheck: boolean;
  40883. /**
  40884. * Gets the list of created scenes
  40885. */
  40886. scenes: Scene[];
  40887. /**
  40888. * Event raised when a new scene is created
  40889. */
  40890. onNewSceneAddedObservable: Observable<Scene>;
  40891. /**
  40892. * Gets the list of created postprocesses
  40893. */
  40894. postProcesses: PostProcess[];
  40895. /**
  40896. * Gets a boolean indicating if the pointer is currently locked
  40897. */
  40898. isPointerLock: boolean;
  40899. /**
  40900. * Observable event triggered each time the rendering canvas is resized
  40901. */
  40902. onResizeObservable: Observable<Engine>;
  40903. /**
  40904. * Observable event triggered each time the canvas loses focus
  40905. */
  40906. onCanvasBlurObservable: Observable<Engine>;
  40907. /**
  40908. * Observable event triggered each time the canvas gains focus
  40909. */
  40910. onCanvasFocusObservable: Observable<Engine>;
  40911. /**
  40912. * Observable event triggered each time the canvas receives pointerout event
  40913. */
  40914. onCanvasPointerOutObservable: Observable<PointerEvent>;
  40915. /**
  40916. * Observable raised when the engine begins a new frame
  40917. */
  40918. onBeginFrameObservable: Observable<Engine>;
  40919. /**
  40920. * If set, will be used to request the next animation frame for the render loop
  40921. */
  40922. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  40923. /**
  40924. * Observable raised when the engine ends the current frame
  40925. */
  40926. onEndFrameObservable: Observable<Engine>;
  40927. /**
  40928. * Observable raised when the engine is about to compile a shader
  40929. */
  40930. onBeforeShaderCompilationObservable: Observable<Engine>;
  40931. /**
  40932. * Observable raised when the engine has jsut compiled a shader
  40933. */
  40934. onAfterShaderCompilationObservable: Observable<Engine>;
  40935. /**
  40936. * Gets the audio engine
  40937. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40938. * @ignorenaming
  40939. */
  40940. static audioEngine: IAudioEngine;
  40941. /**
  40942. * Default AudioEngine factory responsible of creating the Audio Engine.
  40943. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  40944. */
  40945. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  40946. /**
  40947. * Default offline support factory responsible of creating a tool used to store data locally.
  40948. * By default, this will create a Database object if the workload has been embedded.
  40949. */
  40950. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  40951. private _loadingScreen;
  40952. private _pointerLockRequested;
  40953. private _rescalePostProcess;
  40954. private _deterministicLockstep;
  40955. private _lockstepMaxSteps;
  40956. private _timeStep;
  40957. protected get _supportsHardwareTextureRescaling(): boolean;
  40958. private _fps;
  40959. private _deltaTime;
  40960. /** @hidden */
  40961. _drawCalls: PerfCounter;
  40962. /** 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 */
  40963. canvasTabIndex: number;
  40964. /**
  40965. * Turn this value on if you want to pause FPS computation when in background
  40966. */
  40967. disablePerformanceMonitorInBackground: boolean;
  40968. private _performanceMonitor;
  40969. /**
  40970. * Gets the performance monitor attached to this engine
  40971. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  40972. */
  40973. get performanceMonitor(): PerformanceMonitor;
  40974. private _onFocus;
  40975. private _onBlur;
  40976. private _onCanvasPointerOut;
  40977. private _onCanvasBlur;
  40978. private _onCanvasFocus;
  40979. private _onFullscreenChange;
  40980. private _onPointerLockChange;
  40981. /**
  40982. * Gets the HTML element used to attach event listeners
  40983. * @returns a HTML element
  40984. */
  40985. getInputElement(): Nullable<HTMLElement>;
  40986. /**
  40987. * Creates a new engine
  40988. * @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
  40989. * @param antialias defines enable antialiasing (default: false)
  40990. * @param options defines further options to be sent to the getContext() function
  40991. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  40992. */
  40993. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  40994. /**
  40995. * Gets current aspect ratio
  40996. * @param viewportOwner defines the camera to use to get the aspect ratio
  40997. * @param useScreen defines if screen size must be used (or the current render target if any)
  40998. * @returns a number defining the aspect ratio
  40999. */
  41000. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  41001. /**
  41002. * Gets current screen aspect ratio
  41003. * @returns a number defining the aspect ratio
  41004. */
  41005. getScreenAspectRatio(): number;
  41006. /**
  41007. * Gets the client rect of the HTML canvas attached with the current webGL context
  41008. * @returns a client rectanglee
  41009. */
  41010. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  41011. /**
  41012. * Gets the client rect of the HTML element used for events
  41013. * @returns a client rectanglee
  41014. */
  41015. getInputElementClientRect(): Nullable<ClientRect>;
  41016. /**
  41017. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  41018. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41019. * @returns true if engine is in deterministic lock step mode
  41020. */
  41021. isDeterministicLockStep(): boolean;
  41022. /**
  41023. * Gets the max steps when engine is running in deterministic lock step
  41024. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41025. * @returns the max steps
  41026. */
  41027. getLockstepMaxSteps(): number;
  41028. /**
  41029. * Returns the time in ms between steps when using deterministic lock step.
  41030. * @returns time step in (ms)
  41031. */
  41032. getTimeStep(): number;
  41033. /**
  41034. * Force the mipmap generation for the given render target texture
  41035. * @param texture defines the render target texture to use
  41036. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  41037. */
  41038. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  41039. /** States */
  41040. /**
  41041. * Set various states to the webGL context
  41042. * @param culling defines backface culling state
  41043. * @param zOffset defines the value to apply to zOffset (0 by default)
  41044. * @param force defines if states must be applied even if cache is up to date
  41045. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  41046. */
  41047. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41048. /**
  41049. * Set the z offset to apply to current rendering
  41050. * @param value defines the offset to apply
  41051. */
  41052. setZOffset(value: number): void;
  41053. /**
  41054. * Gets the current value of the zOffset
  41055. * @returns the current zOffset state
  41056. */
  41057. getZOffset(): number;
  41058. /**
  41059. * Enable or disable depth buffering
  41060. * @param enable defines the state to set
  41061. */
  41062. setDepthBuffer(enable: boolean): void;
  41063. /**
  41064. * Gets a boolean indicating if depth writing is enabled
  41065. * @returns the current depth writing state
  41066. */
  41067. getDepthWrite(): boolean;
  41068. /**
  41069. * Enable or disable depth writing
  41070. * @param enable defines the state to set
  41071. */
  41072. setDepthWrite(enable: boolean): void;
  41073. /**
  41074. * Gets a boolean indicating if stencil buffer is enabled
  41075. * @returns the current stencil buffer state
  41076. */
  41077. getStencilBuffer(): boolean;
  41078. /**
  41079. * Enable or disable the stencil buffer
  41080. * @param enable defines if the stencil buffer must be enabled or disabled
  41081. */
  41082. setStencilBuffer(enable: boolean): void;
  41083. /**
  41084. * Gets the current stencil mask
  41085. * @returns a number defining the new stencil mask to use
  41086. */
  41087. getStencilMask(): number;
  41088. /**
  41089. * Sets the current stencil mask
  41090. * @param mask defines the new stencil mask to use
  41091. */
  41092. setStencilMask(mask: number): void;
  41093. /**
  41094. * Gets the current stencil function
  41095. * @returns a number defining the stencil function to use
  41096. */
  41097. getStencilFunction(): number;
  41098. /**
  41099. * Gets the current stencil reference value
  41100. * @returns a number defining the stencil reference value to use
  41101. */
  41102. getStencilFunctionReference(): number;
  41103. /**
  41104. * Gets the current stencil mask
  41105. * @returns a number defining the stencil mask to use
  41106. */
  41107. getStencilFunctionMask(): number;
  41108. /**
  41109. * Sets the current stencil function
  41110. * @param stencilFunc defines the new stencil function to use
  41111. */
  41112. setStencilFunction(stencilFunc: number): void;
  41113. /**
  41114. * Sets the current stencil reference
  41115. * @param reference defines the new stencil reference to use
  41116. */
  41117. setStencilFunctionReference(reference: number): void;
  41118. /**
  41119. * Sets the current stencil mask
  41120. * @param mask defines the new stencil mask to use
  41121. */
  41122. setStencilFunctionMask(mask: number): void;
  41123. /**
  41124. * Gets the current stencil operation when stencil fails
  41125. * @returns a number defining stencil operation to use when stencil fails
  41126. */
  41127. getStencilOperationFail(): number;
  41128. /**
  41129. * Gets the current stencil operation when depth fails
  41130. * @returns a number defining stencil operation to use when depth fails
  41131. */
  41132. getStencilOperationDepthFail(): number;
  41133. /**
  41134. * Gets the current stencil operation when stencil passes
  41135. * @returns a number defining stencil operation to use when stencil passes
  41136. */
  41137. getStencilOperationPass(): number;
  41138. /**
  41139. * Sets the stencil operation to use when stencil fails
  41140. * @param operation defines the stencil operation to use when stencil fails
  41141. */
  41142. setStencilOperationFail(operation: number): void;
  41143. /**
  41144. * Sets the stencil operation to use when depth fails
  41145. * @param operation defines the stencil operation to use when depth fails
  41146. */
  41147. setStencilOperationDepthFail(operation: number): void;
  41148. /**
  41149. * Sets the stencil operation to use when stencil passes
  41150. * @param operation defines the stencil operation to use when stencil passes
  41151. */
  41152. setStencilOperationPass(operation: number): void;
  41153. /**
  41154. * Sets a boolean indicating if the dithering state is enabled or disabled
  41155. * @param value defines the dithering state
  41156. */
  41157. setDitheringState(value: boolean): void;
  41158. /**
  41159. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  41160. * @param value defines the rasterizer state
  41161. */
  41162. setRasterizerState(value: boolean): void;
  41163. /**
  41164. * Gets the current depth function
  41165. * @returns a number defining the depth function
  41166. */
  41167. getDepthFunction(): Nullable<number>;
  41168. /**
  41169. * Sets the current depth function
  41170. * @param depthFunc defines the function to use
  41171. */
  41172. setDepthFunction(depthFunc: number): void;
  41173. /**
  41174. * Sets the current depth function to GREATER
  41175. */
  41176. setDepthFunctionToGreater(): void;
  41177. /**
  41178. * Sets the current depth function to GEQUAL
  41179. */
  41180. setDepthFunctionToGreaterOrEqual(): void;
  41181. /**
  41182. * Sets the current depth function to LESS
  41183. */
  41184. setDepthFunctionToLess(): void;
  41185. /**
  41186. * Sets the current depth function to LEQUAL
  41187. */
  41188. setDepthFunctionToLessOrEqual(): void;
  41189. private _cachedStencilBuffer;
  41190. private _cachedStencilFunction;
  41191. private _cachedStencilMask;
  41192. private _cachedStencilOperationPass;
  41193. private _cachedStencilOperationFail;
  41194. private _cachedStencilOperationDepthFail;
  41195. private _cachedStencilReference;
  41196. /**
  41197. * Caches the the state of the stencil buffer
  41198. */
  41199. cacheStencilState(): void;
  41200. /**
  41201. * Restores the state of the stencil buffer
  41202. */
  41203. restoreStencilState(): void;
  41204. /**
  41205. * Directly set the WebGL Viewport
  41206. * @param x defines the x coordinate of the viewport (in screen space)
  41207. * @param y defines the y coordinate of the viewport (in screen space)
  41208. * @param width defines the width of the viewport (in screen space)
  41209. * @param height defines the height of the viewport (in screen space)
  41210. * @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
  41211. */
  41212. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  41213. /**
  41214. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  41215. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  41216. * @param y defines the y-coordinate of the corner of the clear rectangle
  41217. * @param width defines the width of the clear rectangle
  41218. * @param height defines the height of the clear rectangle
  41219. * @param clearColor defines the clear color
  41220. */
  41221. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  41222. /**
  41223. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  41224. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  41225. * @param y defines the y-coordinate of the corner of the clear rectangle
  41226. * @param width defines the width of the clear rectangle
  41227. * @param height defines the height of the clear rectangle
  41228. */
  41229. enableScissor(x: number, y: number, width: number, height: number): void;
  41230. /**
  41231. * Disable previously set scissor test rectangle
  41232. */
  41233. disableScissor(): void;
  41234. protected _reportDrawCall(): void;
  41235. /**
  41236. * Initializes a webVR display and starts listening to display change events
  41237. * The onVRDisplayChangedObservable will be notified upon these changes
  41238. * @returns The onVRDisplayChangedObservable
  41239. */
  41240. initWebVR(): Observable<IDisplayChangedEventArgs>;
  41241. /** @hidden */
  41242. _prepareVRComponent(): void;
  41243. /** @hidden */
  41244. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  41245. /** @hidden */
  41246. _submitVRFrame(): void;
  41247. /**
  41248. * Call this function to leave webVR mode
  41249. * Will do nothing if webVR is not supported or if there is no webVR device
  41250. * @see https://doc.babylonjs.com/how_to/webvr_camera
  41251. */
  41252. disableVR(): void;
  41253. /**
  41254. * Gets a boolean indicating that the system is in VR mode and is presenting
  41255. * @returns true if VR mode is engaged
  41256. */
  41257. isVRPresenting(): boolean;
  41258. /** @hidden */
  41259. _requestVRFrame(): void;
  41260. /** @hidden */
  41261. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41262. /**
  41263. * Gets the source code of the vertex shader associated with a specific webGL program
  41264. * @param program defines the program to use
  41265. * @returns a string containing the source code of the vertex shader associated with the program
  41266. */
  41267. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  41268. /**
  41269. * Gets the source code of the fragment shader associated with a specific webGL program
  41270. * @param program defines the program to use
  41271. * @returns a string containing the source code of the fragment shader associated with the program
  41272. */
  41273. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  41274. /**
  41275. * Sets a depth stencil texture from a render target to the according uniform.
  41276. * @param channel The texture channel
  41277. * @param uniform The uniform to set
  41278. * @param texture The render target texture containing the depth stencil texture to apply
  41279. */
  41280. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  41281. /**
  41282. * Sets a texture to the webGL context from a postprocess
  41283. * @param channel defines the channel to use
  41284. * @param postProcess defines the source postprocess
  41285. */
  41286. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  41287. /**
  41288. * Binds the output of the passed in post process to the texture channel specified
  41289. * @param channel The channel the texture should be bound to
  41290. * @param postProcess The post process which's output should be bound
  41291. */
  41292. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  41293. protected _rebuildBuffers(): void;
  41294. /** @hidden */
  41295. _renderFrame(): void;
  41296. _renderLoop(): void;
  41297. /** @hidden */
  41298. _renderViews(): boolean;
  41299. /**
  41300. * Toggle full screen mode
  41301. * @param requestPointerLock defines if a pointer lock should be requested from the user
  41302. */
  41303. switchFullscreen(requestPointerLock: boolean): void;
  41304. /**
  41305. * Enters full screen mode
  41306. * @param requestPointerLock defines if a pointer lock should be requested from the user
  41307. */
  41308. enterFullscreen(requestPointerLock: boolean): void;
  41309. /**
  41310. * Exits full screen mode
  41311. */
  41312. exitFullscreen(): void;
  41313. /**
  41314. * Enters Pointerlock mode
  41315. */
  41316. enterPointerlock(): void;
  41317. /**
  41318. * Exits Pointerlock mode
  41319. */
  41320. exitPointerlock(): void;
  41321. /**
  41322. * Begin a new frame
  41323. */
  41324. beginFrame(): void;
  41325. /**
  41326. * Enf the current frame
  41327. */
  41328. endFrame(): void;
  41329. resize(): void;
  41330. /**
  41331. * Force a specific size of the canvas
  41332. * @param width defines the new canvas' width
  41333. * @param height defines the new canvas' height
  41334. * @returns true if the size was changed
  41335. */
  41336. setSize(width: number, height: number): boolean;
  41337. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  41338. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41339. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41340. _releaseTexture(texture: InternalTexture): void;
  41341. /**
  41342. * @hidden
  41343. * Rescales a texture
  41344. * @param source input texutre
  41345. * @param destination destination texture
  41346. * @param scene scene to use to render the resize
  41347. * @param internalFormat format to use when resizing
  41348. * @param onComplete callback to be called when resize has completed
  41349. */
  41350. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  41351. /**
  41352. * Gets the current framerate
  41353. * @returns a number representing the framerate
  41354. */
  41355. getFps(): number;
  41356. /**
  41357. * Gets the time spent between current and previous frame
  41358. * @returns a number representing the delta time in ms
  41359. */
  41360. getDeltaTime(): number;
  41361. private _measureFps;
  41362. /** @hidden */
  41363. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  41364. /**
  41365. * Updates the sample count of a render target texture
  41366. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  41367. * @param texture defines the texture to update
  41368. * @param samples defines the sample count to set
  41369. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  41370. */
  41371. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  41372. /**
  41373. * Updates a depth texture Comparison Mode and Function.
  41374. * If the comparison Function is equal to 0, the mode will be set to none.
  41375. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  41376. * @param texture The texture to set the comparison function for
  41377. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  41378. */
  41379. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  41380. /**
  41381. * Creates a webGL buffer to use with instanciation
  41382. * @param capacity defines the size of the buffer
  41383. * @returns the webGL buffer
  41384. */
  41385. createInstancesBuffer(capacity: number): DataBuffer;
  41386. /**
  41387. * Delete a webGL buffer used with instanciation
  41388. * @param buffer defines the webGL buffer to delete
  41389. */
  41390. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  41391. private _clientWaitAsync;
  41392. /** @hidden */
  41393. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  41394. dispose(): void;
  41395. private _disableTouchAction;
  41396. /**
  41397. * Display the loading screen
  41398. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41399. */
  41400. displayLoadingUI(): void;
  41401. /**
  41402. * Hide the loading screen
  41403. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41404. */
  41405. hideLoadingUI(): void;
  41406. /**
  41407. * Gets the current loading screen object
  41408. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41409. */
  41410. get loadingScreen(): ILoadingScreen;
  41411. /**
  41412. * Sets the current loading screen object
  41413. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41414. */
  41415. set loadingScreen(loadingScreen: ILoadingScreen);
  41416. /**
  41417. * Sets the current loading screen text
  41418. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41419. */
  41420. set loadingUIText(text: string);
  41421. /**
  41422. * Sets the current loading screen background color
  41423. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41424. */
  41425. set loadingUIBackgroundColor(color: string);
  41426. /** Pointerlock and fullscreen */
  41427. /**
  41428. * Ask the browser to promote the current element to pointerlock mode
  41429. * @param element defines the DOM element to promote
  41430. */
  41431. static _RequestPointerlock(element: HTMLElement): void;
  41432. /**
  41433. * Asks the browser to exit pointerlock mode
  41434. */
  41435. static _ExitPointerlock(): void;
  41436. /**
  41437. * Ask the browser to promote the current element to fullscreen rendering mode
  41438. * @param element defines the DOM element to promote
  41439. */
  41440. static _RequestFullscreen(element: HTMLElement): void;
  41441. /**
  41442. * Asks the browser to exit fullscreen mode
  41443. */
  41444. static _ExitFullscreen(): void;
  41445. }
  41446. }
  41447. declare module BABYLON {
  41448. /**
  41449. * The engine store class is responsible to hold all the instances of Engine and Scene created
  41450. * during the life time of the application.
  41451. */
  41452. export class EngineStore {
  41453. /** Gets the list of created engines */
  41454. static Instances: Engine[];
  41455. /** @hidden */
  41456. static _LastCreatedScene: Nullable<Scene>;
  41457. /**
  41458. * Gets the latest created engine
  41459. */
  41460. static get LastCreatedEngine(): Nullable<Engine>;
  41461. /**
  41462. * Gets the latest created scene
  41463. */
  41464. static get LastCreatedScene(): Nullable<Scene>;
  41465. /**
  41466. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  41467. * @ignorenaming
  41468. */
  41469. static UseFallbackTexture: boolean;
  41470. /**
  41471. * Texture content used if a texture cannot loaded
  41472. * @ignorenaming
  41473. */
  41474. static FallbackTexture: string;
  41475. }
  41476. }
  41477. declare module BABYLON {
  41478. /**
  41479. * Helper class that provides a small promise polyfill
  41480. */
  41481. export class PromisePolyfill {
  41482. /**
  41483. * Static function used to check if the polyfill is required
  41484. * If this is the case then the function will inject the polyfill to window.Promise
  41485. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  41486. */
  41487. static Apply(force?: boolean): void;
  41488. }
  41489. }
  41490. declare module BABYLON {
  41491. /**
  41492. * Interface for screenshot methods with describe argument called `size` as object with options
  41493. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  41494. */
  41495. export interface IScreenshotSize {
  41496. /**
  41497. * number in pixels for canvas height
  41498. */
  41499. height?: number;
  41500. /**
  41501. * multiplier allowing render at a higher or lower resolution
  41502. * If value is defined then height and width will be ignored and taken from camera
  41503. */
  41504. precision?: number;
  41505. /**
  41506. * number in pixels for canvas width
  41507. */
  41508. width?: number;
  41509. }
  41510. }
  41511. declare module BABYLON {
  41512. interface IColor4Like {
  41513. r: float;
  41514. g: float;
  41515. b: float;
  41516. a: float;
  41517. }
  41518. /**
  41519. * Class containing a set of static utilities functions
  41520. */
  41521. export class Tools {
  41522. /**
  41523. * Gets or sets the base URL to use to load assets
  41524. */
  41525. static get BaseUrl(): string;
  41526. static set BaseUrl(value: string);
  41527. /**
  41528. * Enable/Disable Custom HTTP Request Headers globally.
  41529. * default = false
  41530. * @see CustomRequestHeaders
  41531. */
  41532. static UseCustomRequestHeaders: boolean;
  41533. /**
  41534. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  41535. * i.e. when loading files, where the server/service expects an Authorization header
  41536. */
  41537. static CustomRequestHeaders: {
  41538. [key: string]: string;
  41539. };
  41540. /**
  41541. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  41542. */
  41543. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  41544. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  41545. /**
  41546. * Default behaviour for cors in the application.
  41547. * It can be a string if the expected behavior is identical in the entire app.
  41548. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  41549. */
  41550. static get CorsBehavior(): string | ((url: string | string[]) => string);
  41551. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  41552. /**
  41553. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  41554. * @ignorenaming
  41555. */
  41556. static get UseFallbackTexture(): boolean;
  41557. static set UseFallbackTexture(value: boolean);
  41558. /**
  41559. * Use this object to register external classes like custom textures or material
  41560. * to allow the laoders to instantiate them
  41561. */
  41562. static get RegisteredExternalClasses(): {
  41563. [key: string]: Object;
  41564. };
  41565. static set RegisteredExternalClasses(classes: {
  41566. [key: string]: Object;
  41567. });
  41568. /**
  41569. * Texture content used if a texture cannot loaded
  41570. * @ignorenaming
  41571. */
  41572. static get fallbackTexture(): string;
  41573. static set fallbackTexture(value: string);
  41574. /**
  41575. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  41576. * @param u defines the coordinate on X axis
  41577. * @param v defines the coordinate on Y axis
  41578. * @param width defines the width of the source data
  41579. * @param height defines the height of the source data
  41580. * @param pixels defines the source byte array
  41581. * @param color defines the output color
  41582. */
  41583. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  41584. /**
  41585. * Interpolates between a and b via alpha
  41586. * @param a The lower value (returned when alpha = 0)
  41587. * @param b The upper value (returned when alpha = 1)
  41588. * @param alpha The interpolation-factor
  41589. * @return The mixed value
  41590. */
  41591. static Mix(a: number, b: number, alpha: number): number;
  41592. /**
  41593. * Tries to instantiate a new object from a given class name
  41594. * @param className defines the class name to instantiate
  41595. * @returns the new object or null if the system was not able to do the instantiation
  41596. */
  41597. static Instantiate(className: string): any;
  41598. /**
  41599. * Provides a slice function that will work even on IE
  41600. * @param data defines the array to slice
  41601. * @param start defines the start of the data (optional)
  41602. * @param end defines the end of the data (optional)
  41603. * @returns the new sliced array
  41604. */
  41605. static Slice<T>(data: T, start?: number, end?: number): T;
  41606. /**
  41607. * Provides a slice function that will work even on IE
  41608. * The difference between this and Slice is that this will force-convert to array
  41609. * @param data defines the array to slice
  41610. * @param start defines the start of the data (optional)
  41611. * @param end defines the end of the data (optional)
  41612. * @returns the new sliced array
  41613. */
  41614. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  41615. /**
  41616. * Polyfill for setImmediate
  41617. * @param action defines the action to execute after the current execution block
  41618. */
  41619. static SetImmediate(action: () => void): void;
  41620. /**
  41621. * Function indicating if a number is an exponent of 2
  41622. * @param value defines the value to test
  41623. * @returns true if the value is an exponent of 2
  41624. */
  41625. static IsExponentOfTwo(value: number): boolean;
  41626. private static _tmpFloatArray;
  41627. /**
  41628. * Returns the nearest 32-bit single precision float representation of a Number
  41629. * @param value A Number. If the parameter is of a different type, it will get converted
  41630. * to a number or to NaN if it cannot be converted
  41631. * @returns number
  41632. */
  41633. static FloatRound(value: number): number;
  41634. /**
  41635. * Extracts the filename from a path
  41636. * @param path defines the path to use
  41637. * @returns the filename
  41638. */
  41639. static GetFilename(path: string): string;
  41640. /**
  41641. * Extracts the "folder" part of a path (everything before the filename).
  41642. * @param uri The URI to extract the info from
  41643. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  41644. * @returns The "folder" part of the path
  41645. */
  41646. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  41647. /**
  41648. * Extracts text content from a DOM element hierarchy
  41649. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  41650. */
  41651. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  41652. /**
  41653. * Convert an angle in radians to degrees
  41654. * @param angle defines the angle to convert
  41655. * @returns the angle in degrees
  41656. */
  41657. static ToDegrees(angle: number): number;
  41658. /**
  41659. * Convert an angle in degrees to radians
  41660. * @param angle defines the angle to convert
  41661. * @returns the angle in radians
  41662. */
  41663. static ToRadians(angle: number): number;
  41664. /**
  41665. * Returns an array if obj is not an array
  41666. * @param obj defines the object to evaluate as an array
  41667. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  41668. * @returns either obj directly if obj is an array or a new array containing obj
  41669. */
  41670. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  41671. /**
  41672. * Gets the pointer prefix to use
  41673. * @param engine defines the engine we are finding the prefix for
  41674. * @returns "pointer" if touch is enabled. Else returns "mouse"
  41675. */
  41676. static GetPointerPrefix(engine: Engine): string;
  41677. /**
  41678. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  41679. * @param url define the url we are trying
  41680. * @param element define the dom element where to configure the cors policy
  41681. */
  41682. static SetCorsBehavior(url: string | string[], element: {
  41683. crossOrigin: string | null;
  41684. }): void;
  41685. /**
  41686. * Removes unwanted characters from an url
  41687. * @param url defines the url to clean
  41688. * @returns the cleaned url
  41689. */
  41690. static CleanUrl(url: string): string;
  41691. /**
  41692. * Gets or sets a function used to pre-process url before using them to load assets
  41693. */
  41694. static get PreprocessUrl(): (url: string) => string;
  41695. static set PreprocessUrl(processor: (url: string) => string);
  41696. /**
  41697. * Loads an image as an HTMLImageElement.
  41698. * @param input url string, ArrayBuffer, or Blob to load
  41699. * @param onLoad callback called when the image successfully loads
  41700. * @param onError callback called when the image fails to load
  41701. * @param offlineProvider offline provider for caching
  41702. * @param mimeType optional mime type
  41703. * @returns the HTMLImageElement of the loaded image
  41704. */
  41705. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  41706. /**
  41707. * Loads a file from a url
  41708. * @param url url string, ArrayBuffer, or Blob to load
  41709. * @param onSuccess callback called when the file successfully loads
  41710. * @param onProgress callback called while file is loading (if the server supports this mode)
  41711. * @param offlineProvider defines the offline provider for caching
  41712. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41713. * @param onError callback called when the file fails to load
  41714. * @returns a file request object
  41715. */
  41716. 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;
  41717. /**
  41718. * Loads a file from a url
  41719. * @param url the file url to load
  41720. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41721. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  41722. */
  41723. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  41724. /**
  41725. * Load a script (identified by an url). When the url returns, the
  41726. * content of this file is added into a new script element, attached to the DOM (body element)
  41727. * @param scriptUrl defines the url of the script to laod
  41728. * @param onSuccess defines the callback called when the script is loaded
  41729. * @param onError defines the callback to call if an error occurs
  41730. * @param scriptId defines the id of the script element
  41731. */
  41732. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  41733. /**
  41734. * Load an asynchronous script (identified by an url). When the url returns, the
  41735. * content of this file is added into a new script element, attached to the DOM (body element)
  41736. * @param scriptUrl defines the url of the script to laod
  41737. * @param scriptId defines the id of the script element
  41738. * @returns a promise request object
  41739. */
  41740. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  41741. /**
  41742. * Loads a file from a blob
  41743. * @param fileToLoad defines the blob to use
  41744. * @param callback defines the callback to call when data is loaded
  41745. * @param progressCallback defines the callback to call during loading process
  41746. * @returns a file request object
  41747. */
  41748. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  41749. /**
  41750. * Reads a file from a File object
  41751. * @param file defines the file to load
  41752. * @param onSuccess defines the callback to call when data is loaded
  41753. * @param onProgress defines the callback to call during loading process
  41754. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  41755. * @param onError defines the callback to call when an error occurs
  41756. * @returns a file request object
  41757. */
  41758. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41759. /**
  41760. * Creates a data url from a given string content
  41761. * @param content defines the content to convert
  41762. * @returns the new data url link
  41763. */
  41764. static FileAsURL(content: string): string;
  41765. /**
  41766. * Format the given number to a specific decimal format
  41767. * @param value defines the number to format
  41768. * @param decimals defines the number of decimals to use
  41769. * @returns the formatted string
  41770. */
  41771. static Format(value: number, decimals?: number): string;
  41772. /**
  41773. * Tries to copy an object by duplicating every property
  41774. * @param source defines the source object
  41775. * @param destination defines the target object
  41776. * @param doNotCopyList defines a list of properties to avoid
  41777. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  41778. */
  41779. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  41780. /**
  41781. * Gets a boolean indicating if the given object has no own property
  41782. * @param obj defines the object to test
  41783. * @returns true if object has no own property
  41784. */
  41785. static IsEmpty(obj: any): boolean;
  41786. /**
  41787. * Function used to register events at window level
  41788. * @param windowElement defines the Window object to use
  41789. * @param events defines the events to register
  41790. */
  41791. static RegisterTopRootEvents(windowElement: Window, events: {
  41792. name: string;
  41793. handler: Nullable<(e: FocusEvent) => any>;
  41794. }[]): void;
  41795. /**
  41796. * Function used to unregister events from window level
  41797. * @param windowElement defines the Window object to use
  41798. * @param events defines the events to unregister
  41799. */
  41800. static UnregisterTopRootEvents(windowElement: Window, events: {
  41801. name: string;
  41802. handler: Nullable<(e: FocusEvent) => any>;
  41803. }[]): void;
  41804. /**
  41805. * @ignore
  41806. */
  41807. static _ScreenshotCanvas: HTMLCanvasElement;
  41808. /**
  41809. * Dumps the current bound framebuffer
  41810. * @param width defines the rendering width
  41811. * @param height defines the rendering height
  41812. * @param engine defines the hosting engine
  41813. * @param successCallback defines the callback triggered once the data are available
  41814. * @param mimeType defines the mime type of the result
  41815. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  41816. */
  41817. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  41818. /**
  41819. * Converts the canvas data to blob.
  41820. * This acts as a polyfill for browsers not supporting the to blob function.
  41821. * @param canvas Defines the canvas to extract the data from
  41822. * @param successCallback Defines the callback triggered once the data are available
  41823. * @param mimeType Defines the mime type of the result
  41824. */
  41825. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  41826. /**
  41827. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  41828. * @param successCallback defines the callback triggered once the data are available
  41829. * @param mimeType defines the mime type of the result
  41830. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  41831. */
  41832. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  41833. /**
  41834. * Downloads a blob in the browser
  41835. * @param blob defines the blob to download
  41836. * @param fileName defines the name of the downloaded file
  41837. */
  41838. static Download(blob: Blob, fileName: string): void;
  41839. /**
  41840. * Will return the right value of the noPreventDefault variable
  41841. * Needed to keep backwards compatibility to the old API.
  41842. *
  41843. * @param args arguments passed to the attachControl function
  41844. * @returns the correct value for noPreventDefault
  41845. */
  41846. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  41847. /**
  41848. * Captures a screenshot of the current rendering
  41849. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41850. * @param engine defines the rendering engine
  41851. * @param camera defines the source camera
  41852. * @param size This parameter can be set to a single number or to an object with the
  41853. * following (optional) properties: precision, width, height. If a single number is passed,
  41854. * it will be used for both width and height. If an object is passed, the screenshot size
  41855. * will be derived from the parameters. The precision property is a multiplier allowing
  41856. * rendering at a higher or lower resolution
  41857. * @param successCallback defines the callback receives a single parameter which contains the
  41858. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  41859. * src parameter of an <img> to display it
  41860. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  41861. * Check your browser for supported MIME types
  41862. */
  41863. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  41864. /**
  41865. * Captures a screenshot of the current rendering
  41866. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41867. * @param engine defines the rendering engine
  41868. * @param camera defines the source camera
  41869. * @param size This parameter can be set to a single number or to an object with the
  41870. * following (optional) properties: precision, width, height. If a single number is passed,
  41871. * it will be used for both width and height. If an object is passed, the screenshot size
  41872. * will be derived from the parameters. The precision property is a multiplier allowing
  41873. * rendering at a higher or lower resolution
  41874. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  41875. * Check your browser for supported MIME types
  41876. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  41877. * to the src parameter of an <img> to display it
  41878. */
  41879. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  41880. /**
  41881. * Generates an image screenshot from the specified camera.
  41882. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41883. * @param engine The engine to use for rendering
  41884. * @param camera The camera to use for rendering
  41885. * @param size This parameter can be set to a single number or to an object with the
  41886. * following (optional) properties: precision, width, height. If a single number is passed,
  41887. * it will be used for both width and height. If an object is passed, the screenshot size
  41888. * will be derived from the parameters. The precision property is a multiplier allowing
  41889. * rendering at a higher or lower resolution
  41890. * @param successCallback The callback receives a single parameter which contains the
  41891. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  41892. * src parameter of an <img> to display it
  41893. * @param mimeType The MIME type of the screenshot image (default: image/png).
  41894. * Check your browser for supported MIME types
  41895. * @param samples Texture samples (default: 1)
  41896. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  41897. * @param fileName A name for for the downloaded file.
  41898. */
  41899. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  41900. /**
  41901. * Generates an image screenshot from the specified camera.
  41902. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41903. * @param engine The engine to use for rendering
  41904. * @param camera The camera to use for rendering
  41905. * @param size This parameter can be set to a single number or to an object with the
  41906. * following (optional) properties: precision, width, height. If a single number is passed,
  41907. * it will be used for both width and height. If an object is passed, the screenshot size
  41908. * will be derived from the parameters. The precision property is a multiplier allowing
  41909. * rendering at a higher or lower resolution
  41910. * @param mimeType The MIME type of the screenshot image (default: image/png).
  41911. * Check your browser for supported MIME types
  41912. * @param samples Texture samples (default: 1)
  41913. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  41914. * @param fileName A name for for the downloaded file.
  41915. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  41916. * to the src parameter of an <img> to display it
  41917. */
  41918. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  41919. /**
  41920. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  41921. * Be aware Math.random() could cause collisions, but:
  41922. * "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"
  41923. * @returns a pseudo random id
  41924. */
  41925. static RandomId(): string;
  41926. /**
  41927. * Test if the given uri is a base64 string
  41928. * @param uri The uri to test
  41929. * @return True if the uri is a base64 string or false otherwise
  41930. */
  41931. static IsBase64(uri: string): boolean;
  41932. /**
  41933. * Decode the given base64 uri.
  41934. * @param uri The uri to decode
  41935. * @return The decoded base64 data.
  41936. */
  41937. static DecodeBase64(uri: string): ArrayBuffer;
  41938. /**
  41939. * Gets the absolute url.
  41940. * @param url the input url
  41941. * @return the absolute url
  41942. */
  41943. static GetAbsoluteUrl(url: string): string;
  41944. /**
  41945. * No log
  41946. */
  41947. static readonly NoneLogLevel: number;
  41948. /**
  41949. * Only message logs
  41950. */
  41951. static readonly MessageLogLevel: number;
  41952. /**
  41953. * Only warning logs
  41954. */
  41955. static readonly WarningLogLevel: number;
  41956. /**
  41957. * Only error logs
  41958. */
  41959. static readonly ErrorLogLevel: number;
  41960. /**
  41961. * All logs
  41962. */
  41963. static readonly AllLogLevel: number;
  41964. /**
  41965. * Gets a value indicating the number of loading errors
  41966. * @ignorenaming
  41967. */
  41968. static get errorsCount(): number;
  41969. /**
  41970. * Callback called when a new log is added
  41971. */
  41972. static OnNewCacheEntry: (entry: string) => void;
  41973. /**
  41974. * Log a message to the console
  41975. * @param message defines the message to log
  41976. */
  41977. static Log(message: string): void;
  41978. /**
  41979. * Write a warning message to the console
  41980. * @param message defines the message to log
  41981. */
  41982. static Warn(message: string): void;
  41983. /**
  41984. * Write an error message to the console
  41985. * @param message defines the message to log
  41986. */
  41987. static Error(message: string): void;
  41988. /**
  41989. * Gets current log cache (list of logs)
  41990. */
  41991. static get LogCache(): string;
  41992. /**
  41993. * Clears the log cache
  41994. */
  41995. static ClearLogCache(): void;
  41996. /**
  41997. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  41998. */
  41999. static set LogLevels(level: number);
  42000. /**
  42001. * Checks if the window object exists
  42002. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  42003. */
  42004. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  42005. /**
  42006. * No performance log
  42007. */
  42008. static readonly PerformanceNoneLogLevel: number;
  42009. /**
  42010. * Use user marks to log performance
  42011. */
  42012. static readonly PerformanceUserMarkLogLevel: number;
  42013. /**
  42014. * Log performance to the console
  42015. */
  42016. static readonly PerformanceConsoleLogLevel: number;
  42017. private static _performance;
  42018. /**
  42019. * Sets the current performance log level
  42020. */
  42021. static set PerformanceLogLevel(level: number);
  42022. private static _StartPerformanceCounterDisabled;
  42023. private static _EndPerformanceCounterDisabled;
  42024. private static _StartUserMark;
  42025. private static _EndUserMark;
  42026. private static _StartPerformanceConsole;
  42027. private static _EndPerformanceConsole;
  42028. /**
  42029. * Starts a performance counter
  42030. */
  42031. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  42032. /**
  42033. * Ends a specific performance coutner
  42034. */
  42035. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  42036. /**
  42037. * Gets either window.performance.now() if supported or Date.now() else
  42038. */
  42039. static get Now(): number;
  42040. /**
  42041. * This method will return the name of the class used to create the instance of the given object.
  42042. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  42043. * @param object the object to get the class name from
  42044. * @param isType defines if the object is actually a type
  42045. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  42046. */
  42047. static GetClassName(object: any, isType?: boolean): string;
  42048. /**
  42049. * Gets the first element of an array satisfying a given predicate
  42050. * @param array defines the array to browse
  42051. * @param predicate defines the predicate to use
  42052. * @returns null if not found or the element
  42053. */
  42054. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  42055. /**
  42056. * This method will return the name of the full name of the class, including its owning module (if any).
  42057. * 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).
  42058. * @param object the object to get the class name from
  42059. * @param isType defines if the object is actually a type
  42060. * @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.
  42061. * @ignorenaming
  42062. */
  42063. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  42064. /**
  42065. * Returns a promise that resolves after the given amount of time.
  42066. * @param delay Number of milliseconds to delay
  42067. * @returns Promise that resolves after the given amount of time
  42068. */
  42069. static DelayAsync(delay: number): Promise<void>;
  42070. /**
  42071. * Utility function to detect if the current user agent is Safari
  42072. * @returns whether or not the current user agent is safari
  42073. */
  42074. static IsSafari(): boolean;
  42075. }
  42076. /**
  42077. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  42078. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  42079. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  42080. * @param name The name of the class, case should be preserved
  42081. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  42082. */
  42083. export function className(name: string, module?: string): (target: Object) => void;
  42084. /**
  42085. * An implementation of a loop for asynchronous functions.
  42086. */
  42087. export class AsyncLoop {
  42088. /**
  42089. * Defines the number of iterations for the loop
  42090. */
  42091. iterations: number;
  42092. /**
  42093. * Defines the current index of the loop.
  42094. */
  42095. index: number;
  42096. private _done;
  42097. private _fn;
  42098. private _successCallback;
  42099. /**
  42100. * Constructor.
  42101. * @param iterations the number of iterations.
  42102. * @param func the function to run each iteration
  42103. * @param successCallback the callback that will be called upon succesful execution
  42104. * @param offset starting offset.
  42105. */
  42106. constructor(
  42107. /**
  42108. * Defines the number of iterations for the loop
  42109. */
  42110. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  42111. /**
  42112. * Execute the next iteration. Must be called after the last iteration was finished.
  42113. */
  42114. executeNext(): void;
  42115. /**
  42116. * Break the loop and run the success callback.
  42117. */
  42118. breakLoop(): void;
  42119. /**
  42120. * Create and run an async loop.
  42121. * @param iterations the number of iterations.
  42122. * @param fn the function to run each iteration
  42123. * @param successCallback the callback that will be called upon succesful execution
  42124. * @param offset starting offset.
  42125. * @returns the created async loop object
  42126. */
  42127. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  42128. /**
  42129. * A for-loop that will run a given number of iterations synchronous and the rest async.
  42130. * @param iterations total number of iterations
  42131. * @param syncedIterations number of synchronous iterations in each async iteration.
  42132. * @param fn the function to call each iteration.
  42133. * @param callback a success call back that will be called when iterating stops.
  42134. * @param breakFunction a break condition (optional)
  42135. * @param timeout timeout settings for the setTimeout function. default - 0.
  42136. * @returns the created async loop object
  42137. */
  42138. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  42139. }
  42140. }
  42141. declare module BABYLON {
  42142. /**
  42143. * This class implement a typical dictionary using a string as key and the generic type T as value.
  42144. * The underlying implementation relies on an associative array to ensure the best performances.
  42145. * The value can be anything including 'null' but except 'undefined'
  42146. */
  42147. export class StringDictionary<T> {
  42148. /**
  42149. * This will clear this dictionary and copy the content from the 'source' one.
  42150. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  42151. * @param source the dictionary to take the content from and copy to this dictionary
  42152. */
  42153. copyFrom(source: StringDictionary<T>): void;
  42154. /**
  42155. * Get a value based from its key
  42156. * @param key the given key to get the matching value from
  42157. * @return the value if found, otherwise undefined is returned
  42158. */
  42159. get(key: string): T | undefined;
  42160. /**
  42161. * Get a value from its key or add it if it doesn't exist.
  42162. * This method will ensure you that a given key/data will be present in the dictionary.
  42163. * @param key the given key to get the matching value from
  42164. * @param factory the factory that will create the value if the key is not present in the dictionary.
  42165. * The factory will only be invoked if there's no data for the given key.
  42166. * @return the value corresponding to the key.
  42167. */
  42168. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  42169. /**
  42170. * Get a value from its key if present in the dictionary otherwise add it
  42171. * @param key the key to get the value from
  42172. * @param val if there's no such key/value pair in the dictionary add it with this value
  42173. * @return the value corresponding to the key
  42174. */
  42175. getOrAdd(key: string, val: T): T;
  42176. /**
  42177. * Check if there's a given key in the dictionary
  42178. * @param key the key to check for
  42179. * @return true if the key is present, false otherwise
  42180. */
  42181. contains(key: string): boolean;
  42182. /**
  42183. * Add a new key and its corresponding value
  42184. * @param key the key to add
  42185. * @param value the value corresponding to the key
  42186. * @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
  42187. */
  42188. add(key: string, value: T): boolean;
  42189. /**
  42190. * Update a specific value associated to a key
  42191. * @param key defines the key to use
  42192. * @param value defines the value to store
  42193. * @returns true if the value was updated (or false if the key was not found)
  42194. */
  42195. set(key: string, value: T): boolean;
  42196. /**
  42197. * Get the element of the given key and remove it from the dictionary
  42198. * @param key defines the key to search
  42199. * @returns the value associated with the key or null if not found
  42200. */
  42201. getAndRemove(key: string): Nullable<T>;
  42202. /**
  42203. * Remove a key/value from the dictionary.
  42204. * @param key the key to remove
  42205. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  42206. */
  42207. remove(key: string): boolean;
  42208. /**
  42209. * Clear the whole content of the dictionary
  42210. */
  42211. clear(): void;
  42212. /**
  42213. * Gets the current count
  42214. */
  42215. get count(): number;
  42216. /**
  42217. * Execute a callback on each key/val of the dictionary.
  42218. * Note that you can remove any element in this dictionary in the callback implementation
  42219. * @param callback the callback to execute on a given key/value pair
  42220. */
  42221. forEach(callback: (key: string, val: T) => void): void;
  42222. /**
  42223. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  42224. * If the callback returns null or undefined the method will iterate to the next key/value pair
  42225. * Note that you can remove any element in this dictionary in the callback implementation
  42226. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  42227. * @returns the first item
  42228. */
  42229. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  42230. private _count;
  42231. private _data;
  42232. }
  42233. }
  42234. declare module BABYLON {
  42235. /** @hidden */
  42236. export interface ICollisionCoordinator {
  42237. createCollider(): Collider;
  42238. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  42239. init(scene: Scene): void;
  42240. }
  42241. /** @hidden */
  42242. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  42243. private _scene;
  42244. private _scaledPosition;
  42245. private _scaledVelocity;
  42246. private _finalPosition;
  42247. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  42248. createCollider(): Collider;
  42249. init(scene: Scene): void;
  42250. private _collideWithWorld;
  42251. }
  42252. }
  42253. declare module BABYLON {
  42254. /**
  42255. * Class used to manage all inputs for the scene.
  42256. */
  42257. export class InputManager {
  42258. /** The distance in pixel that you have to move to prevent some events */
  42259. static DragMovementThreshold: number;
  42260. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  42261. static LongPressDelay: number;
  42262. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  42263. static DoubleClickDelay: number;
  42264. /** If you need to check double click without raising a single click at first click, enable this flag */
  42265. static ExclusiveDoubleClickMode: boolean;
  42266. /** 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. */
  42267. private _alreadyAttached;
  42268. private _alreadyAttachedTo;
  42269. private _wheelEventName;
  42270. private _onPointerMove;
  42271. private _onPointerDown;
  42272. private _onPointerUp;
  42273. private _initClickEvent;
  42274. private _initActionManager;
  42275. private _delayedSimpleClick;
  42276. private _delayedSimpleClickTimeout;
  42277. private _previousDelayedSimpleClickTimeout;
  42278. private _meshPickProceed;
  42279. private _previousButtonPressed;
  42280. private _currentPickResult;
  42281. private _previousPickResult;
  42282. private _totalPointersPressed;
  42283. private _doubleClickOccured;
  42284. private _pointerOverMesh;
  42285. private _pickedDownMesh;
  42286. private _pickedUpMesh;
  42287. private _pointerX;
  42288. private _pointerY;
  42289. private _unTranslatedPointerX;
  42290. private _unTranslatedPointerY;
  42291. private _startingPointerPosition;
  42292. private _previousStartingPointerPosition;
  42293. private _startingPointerTime;
  42294. private _previousStartingPointerTime;
  42295. private _pointerCaptures;
  42296. private _meshUnderPointerId;
  42297. private _onKeyDown;
  42298. private _onKeyUp;
  42299. private _keyboardIsAttached;
  42300. private _onCanvasFocusObserver;
  42301. private _onCanvasBlurObserver;
  42302. private _scene;
  42303. /**
  42304. * Creates a new InputManager
  42305. * @param scene defines the hosting scene
  42306. */
  42307. constructor(scene: Scene);
  42308. /**
  42309. * Gets the mesh that is currently under the pointer
  42310. */
  42311. get meshUnderPointer(): Nullable<AbstractMesh>;
  42312. /**
  42313. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  42314. * @param pointerId the pointer id to use
  42315. * @returns The mesh under this pointer id or null if not found
  42316. */
  42317. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  42318. /**
  42319. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  42320. */
  42321. get unTranslatedPointer(): Vector2;
  42322. /**
  42323. * Gets or sets the current on-screen X position of the pointer
  42324. */
  42325. get pointerX(): number;
  42326. set pointerX(value: number);
  42327. /**
  42328. * Gets or sets the current on-screen Y position of the pointer
  42329. */
  42330. get pointerY(): number;
  42331. set pointerY(value: number);
  42332. private _updatePointerPosition;
  42333. private _processPointerMove;
  42334. private _setRayOnPointerInfo;
  42335. private _checkPrePointerObservable;
  42336. /**
  42337. * Use this method to simulate a pointer move on a mesh
  42338. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42339. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42340. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42341. */
  42342. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  42343. /**
  42344. * Use this method to simulate a pointer down on a mesh
  42345. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42346. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42347. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42348. */
  42349. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  42350. private _processPointerDown;
  42351. /** @hidden */
  42352. _isPointerSwiping(): boolean;
  42353. /**
  42354. * Use this method to simulate a pointer up on a mesh
  42355. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42356. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42357. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42358. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  42359. */
  42360. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  42361. private _processPointerUp;
  42362. /**
  42363. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  42364. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  42365. * @returns true if the pointer was captured
  42366. */
  42367. isPointerCaptured(pointerId?: number): boolean;
  42368. /**
  42369. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  42370. * @param attachUp defines if you want to attach events to pointerup
  42371. * @param attachDown defines if you want to attach events to pointerdown
  42372. * @param attachMove defines if you want to attach events to pointermove
  42373. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  42374. */
  42375. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  42376. /**
  42377. * Detaches all event handlers
  42378. */
  42379. detachControl(): void;
  42380. /**
  42381. * Force the value of meshUnderPointer
  42382. * @param mesh defines the mesh to use
  42383. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  42384. */
  42385. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  42386. /**
  42387. * Gets the mesh under the pointer
  42388. * @returns a Mesh or null if no mesh is under the pointer
  42389. */
  42390. getPointerOverMesh(): Nullable<AbstractMesh>;
  42391. }
  42392. }
  42393. declare module BABYLON {
  42394. /**
  42395. * This class defines the direct association between an animation and a target
  42396. */
  42397. export class TargetedAnimation {
  42398. /**
  42399. * Animation to perform
  42400. */
  42401. animation: Animation;
  42402. /**
  42403. * Target to animate
  42404. */
  42405. target: any;
  42406. /**
  42407. * Returns the string "TargetedAnimation"
  42408. * @returns "TargetedAnimation"
  42409. */
  42410. getClassName(): string;
  42411. /**
  42412. * Serialize the object
  42413. * @returns the JSON object representing the current entity
  42414. */
  42415. serialize(): any;
  42416. }
  42417. /**
  42418. * Use this class to create coordinated animations on multiple targets
  42419. */
  42420. export class AnimationGroup implements IDisposable {
  42421. /** The name of the animation group */
  42422. name: string;
  42423. private _scene;
  42424. private _targetedAnimations;
  42425. private _animatables;
  42426. private _from;
  42427. private _to;
  42428. private _isStarted;
  42429. private _isPaused;
  42430. private _speedRatio;
  42431. private _loopAnimation;
  42432. private _isAdditive;
  42433. /**
  42434. * Gets or sets the unique id of the node
  42435. */
  42436. uniqueId: number;
  42437. /**
  42438. * This observable will notify when one animation have ended
  42439. */
  42440. onAnimationEndObservable: Observable<TargetedAnimation>;
  42441. /**
  42442. * Observer raised when one animation loops
  42443. */
  42444. onAnimationLoopObservable: Observable<TargetedAnimation>;
  42445. /**
  42446. * Observer raised when all animations have looped
  42447. */
  42448. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  42449. /**
  42450. * This observable will notify when all animations have ended.
  42451. */
  42452. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  42453. /**
  42454. * This observable will notify when all animations have paused.
  42455. */
  42456. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  42457. /**
  42458. * This observable will notify when all animations are playing.
  42459. */
  42460. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  42461. /**
  42462. * Gets the first frame
  42463. */
  42464. get from(): number;
  42465. /**
  42466. * Gets the last frame
  42467. */
  42468. get to(): number;
  42469. /**
  42470. * Define if the animations are started
  42471. */
  42472. get isStarted(): boolean;
  42473. /**
  42474. * Gets a value indicating that the current group is playing
  42475. */
  42476. get isPlaying(): boolean;
  42477. /**
  42478. * Gets or sets the speed ratio to use for all animations
  42479. */
  42480. get speedRatio(): number;
  42481. /**
  42482. * Gets or sets the speed ratio to use for all animations
  42483. */
  42484. set speedRatio(value: number);
  42485. /**
  42486. * Gets or sets if all animations should loop or not
  42487. */
  42488. get loopAnimation(): boolean;
  42489. set loopAnimation(value: boolean);
  42490. /**
  42491. * Gets or sets if all animations should be evaluated additively
  42492. */
  42493. get isAdditive(): boolean;
  42494. set isAdditive(value: boolean);
  42495. /**
  42496. * Gets the targeted animations for this animation group
  42497. */
  42498. get targetedAnimations(): Array<TargetedAnimation>;
  42499. /**
  42500. * returning the list of animatables controlled by this animation group.
  42501. */
  42502. get animatables(): Array<Animatable>;
  42503. /**
  42504. * Gets the list of target animations
  42505. */
  42506. get children(): TargetedAnimation[];
  42507. /**
  42508. * Instantiates a new Animation Group.
  42509. * This helps managing several animations at once.
  42510. * @see https://doc.babylonjs.com/how_to/group
  42511. * @param name Defines the name of the group
  42512. * @param scene Defines the scene the group belongs to
  42513. */
  42514. constructor(
  42515. /** The name of the animation group */
  42516. name: string, scene?: Nullable<Scene>);
  42517. /**
  42518. * Add an animation (with its target) in the group
  42519. * @param animation defines the animation we want to add
  42520. * @param target defines the target of the animation
  42521. * @returns the TargetedAnimation object
  42522. */
  42523. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  42524. /**
  42525. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  42526. * It can add constant keys at begin or end
  42527. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  42528. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  42529. * @returns the animation group
  42530. */
  42531. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  42532. private _animationLoopCount;
  42533. private _animationLoopFlags;
  42534. private _processLoop;
  42535. /**
  42536. * Start all animations on given targets
  42537. * @param loop defines if animations must loop
  42538. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  42539. * @param from defines the from key (optional)
  42540. * @param to defines the to key (optional)
  42541. * @param isAdditive defines the additive state for the resulting animatables (optional)
  42542. * @returns the current animation group
  42543. */
  42544. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  42545. /**
  42546. * Pause all animations
  42547. * @returns the animation group
  42548. */
  42549. pause(): AnimationGroup;
  42550. /**
  42551. * Play all animations to initial state
  42552. * This function will start() the animations if they were not started or will restart() them if they were paused
  42553. * @param loop defines if animations must loop
  42554. * @returns the animation group
  42555. */
  42556. play(loop?: boolean): AnimationGroup;
  42557. /**
  42558. * Reset all animations to initial state
  42559. * @returns the animation group
  42560. */
  42561. reset(): AnimationGroup;
  42562. /**
  42563. * Restart animations from key 0
  42564. * @returns the animation group
  42565. */
  42566. restart(): AnimationGroup;
  42567. /**
  42568. * Stop all animations
  42569. * @returns the animation group
  42570. */
  42571. stop(): AnimationGroup;
  42572. /**
  42573. * Set animation weight for all animatables
  42574. * @param weight defines the weight to use
  42575. * @return the animationGroup
  42576. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  42577. */
  42578. setWeightForAllAnimatables(weight: number): AnimationGroup;
  42579. /**
  42580. * Synchronize and normalize all animatables with a source animatable
  42581. * @param root defines the root animatable to synchronize with
  42582. * @return the animationGroup
  42583. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  42584. */
  42585. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  42586. /**
  42587. * Goes to a specific frame in this animation group
  42588. * @param frame the frame number to go to
  42589. * @return the animationGroup
  42590. */
  42591. goToFrame(frame: number): AnimationGroup;
  42592. /**
  42593. * Dispose all associated resources
  42594. */
  42595. dispose(): void;
  42596. private _checkAnimationGroupEnded;
  42597. /**
  42598. * Clone the current animation group and returns a copy
  42599. * @param newName defines the name of the new group
  42600. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  42601. * @returns the new aniamtion group
  42602. */
  42603. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  42604. /**
  42605. * Serializes the animationGroup to an object
  42606. * @returns Serialized object
  42607. */
  42608. serialize(): any;
  42609. /**
  42610. * Returns a new AnimationGroup object parsed from the source provided.
  42611. * @param parsedAnimationGroup defines the source
  42612. * @param scene defines the scene that will receive the animationGroup
  42613. * @returns a new AnimationGroup
  42614. */
  42615. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  42616. /**
  42617. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  42618. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  42619. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  42620. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  42621. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  42622. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  42623. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  42624. */
  42625. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  42626. /**
  42627. * Returns the string "AnimationGroup"
  42628. * @returns "AnimationGroup"
  42629. */
  42630. getClassName(): string;
  42631. /**
  42632. * Creates a detailled string about the object
  42633. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  42634. * @returns a string representing the object
  42635. */
  42636. toString(fullDetails?: boolean): string;
  42637. }
  42638. }
  42639. declare module BABYLON {
  42640. /**
  42641. * Define an interface for all classes that will hold resources
  42642. */
  42643. export interface IDisposable {
  42644. /**
  42645. * Releases all held resources
  42646. */
  42647. dispose(): void;
  42648. }
  42649. /** Interface defining initialization parameters for Scene class */
  42650. export interface SceneOptions {
  42651. /**
  42652. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  42653. * It will improve performance when the number of geometries becomes important.
  42654. */
  42655. useGeometryUniqueIdsMap?: boolean;
  42656. /**
  42657. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  42658. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  42659. */
  42660. useMaterialMeshMap?: boolean;
  42661. /**
  42662. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  42663. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  42664. */
  42665. useClonedMeshMap?: boolean;
  42666. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  42667. virtual?: boolean;
  42668. }
  42669. /**
  42670. * Represents a scene to be rendered by the engine.
  42671. * @see https://doc.babylonjs.com/features/scene
  42672. */
  42673. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  42674. /** The fog is deactivated */
  42675. static readonly FOGMODE_NONE: number;
  42676. /** The fog density is following an exponential function */
  42677. static readonly FOGMODE_EXP: number;
  42678. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  42679. static readonly FOGMODE_EXP2: number;
  42680. /** The fog density is following a linear function. */
  42681. static readonly FOGMODE_LINEAR: number;
  42682. /**
  42683. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  42684. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42685. */
  42686. static MinDeltaTime: number;
  42687. /**
  42688. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  42689. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42690. */
  42691. static MaxDeltaTime: number;
  42692. /**
  42693. * Factory used to create the default material.
  42694. * @param name The name of the material to create
  42695. * @param scene The scene to create the material for
  42696. * @returns The default material
  42697. */
  42698. static DefaultMaterialFactory(scene: Scene): Material;
  42699. /**
  42700. * Factory used to create the a collision coordinator.
  42701. * @returns The collision coordinator
  42702. */
  42703. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  42704. /** @hidden */
  42705. _inputManager: InputManager;
  42706. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  42707. cameraToUseForPointers: Nullable<Camera>;
  42708. /** @hidden */
  42709. readonly _isScene: boolean;
  42710. /** @hidden */
  42711. _blockEntityCollection: boolean;
  42712. /**
  42713. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  42714. */
  42715. autoClear: boolean;
  42716. /**
  42717. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  42718. */
  42719. autoClearDepthAndStencil: boolean;
  42720. /**
  42721. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  42722. */
  42723. clearColor: Color4;
  42724. /**
  42725. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  42726. */
  42727. ambientColor: Color3;
  42728. /**
  42729. * This is use to store the default BRDF lookup for PBR materials in your scene.
  42730. * It should only be one of the following (if not the default embedded one):
  42731. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  42732. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  42733. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  42734. * The material properties need to be setup according to the type of texture in use.
  42735. */
  42736. environmentBRDFTexture: BaseTexture;
  42737. /**
  42738. * Texture used in all pbr material as the reflection texture.
  42739. * As in the majority of the scene they are the same (exception for multi room and so on),
  42740. * this is easier to reference from here than from all the materials.
  42741. */
  42742. get environmentTexture(): Nullable<BaseTexture>;
  42743. /**
  42744. * Texture used in all pbr material as the reflection texture.
  42745. * As in the majority of the scene they are the same (exception for multi room and so on),
  42746. * this is easier to set here than in all the materials.
  42747. */
  42748. set environmentTexture(value: Nullable<BaseTexture>);
  42749. /** @hidden */
  42750. protected _environmentIntensity: number;
  42751. /**
  42752. * Intensity of the environment in all pbr material.
  42753. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  42754. * As in the majority of the scene they are the same (exception for multi room and so on),
  42755. * this is easier to reference from here than from all the materials.
  42756. */
  42757. get environmentIntensity(): number;
  42758. /**
  42759. * Intensity of the environment in all pbr material.
  42760. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  42761. * As in the majority of the scene they are the same (exception for multi room and so on),
  42762. * this is easier to set here than in all the materials.
  42763. */
  42764. set environmentIntensity(value: number);
  42765. /** @hidden */
  42766. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42767. /**
  42768. * Default image processing configuration used either in the rendering
  42769. * Forward main pass or through the imageProcessingPostProcess if present.
  42770. * As in the majority of the scene they are the same (exception for multi camera),
  42771. * this is easier to reference from here than from all the materials and post process.
  42772. *
  42773. * No setter as we it is a shared configuration, you can set the values instead.
  42774. */
  42775. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42776. private _forceWireframe;
  42777. /**
  42778. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  42779. */
  42780. set forceWireframe(value: boolean);
  42781. get forceWireframe(): boolean;
  42782. private _skipFrustumClipping;
  42783. /**
  42784. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  42785. */
  42786. set skipFrustumClipping(value: boolean);
  42787. get skipFrustumClipping(): boolean;
  42788. private _forcePointsCloud;
  42789. /**
  42790. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  42791. */
  42792. set forcePointsCloud(value: boolean);
  42793. get forcePointsCloud(): boolean;
  42794. /**
  42795. * Gets or sets the active clipplane 1
  42796. */
  42797. clipPlane: Nullable<Plane>;
  42798. /**
  42799. * Gets or sets the active clipplane 2
  42800. */
  42801. clipPlane2: Nullable<Plane>;
  42802. /**
  42803. * Gets or sets the active clipplane 3
  42804. */
  42805. clipPlane3: Nullable<Plane>;
  42806. /**
  42807. * Gets or sets the active clipplane 4
  42808. */
  42809. clipPlane4: Nullable<Plane>;
  42810. /**
  42811. * Gets or sets the active clipplane 5
  42812. */
  42813. clipPlane5: Nullable<Plane>;
  42814. /**
  42815. * Gets or sets the active clipplane 6
  42816. */
  42817. clipPlane6: Nullable<Plane>;
  42818. /**
  42819. * Gets or sets a boolean indicating if animations are enabled
  42820. */
  42821. animationsEnabled: boolean;
  42822. private _animationPropertiesOverride;
  42823. /**
  42824. * Gets or sets the animation properties override
  42825. */
  42826. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  42827. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  42828. /**
  42829. * Gets or sets a boolean indicating if a constant deltatime has to be used
  42830. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  42831. */
  42832. useConstantAnimationDeltaTime: boolean;
  42833. /**
  42834. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  42835. * Please note that it requires to run a ray cast through the scene on every frame
  42836. */
  42837. constantlyUpdateMeshUnderPointer: boolean;
  42838. /**
  42839. * Defines the HTML cursor to use when hovering over interactive elements
  42840. */
  42841. hoverCursor: string;
  42842. /**
  42843. * Defines the HTML default cursor to use (empty by default)
  42844. */
  42845. defaultCursor: string;
  42846. /**
  42847. * Defines whether cursors are handled by the scene.
  42848. */
  42849. doNotHandleCursors: boolean;
  42850. /**
  42851. * This is used to call preventDefault() on pointer down
  42852. * in order to block unwanted artifacts like system double clicks
  42853. */
  42854. preventDefaultOnPointerDown: boolean;
  42855. /**
  42856. * This is used to call preventDefault() on pointer up
  42857. * in order to block unwanted artifacts like system double clicks
  42858. */
  42859. preventDefaultOnPointerUp: boolean;
  42860. /**
  42861. * Gets or sets user defined metadata
  42862. */
  42863. metadata: any;
  42864. /**
  42865. * For internal use only. Please do not use.
  42866. */
  42867. reservedDataStore: any;
  42868. /**
  42869. * Gets the name of the plugin used to load this scene (null by default)
  42870. */
  42871. loadingPluginName: string;
  42872. /**
  42873. * Use this array to add regular expressions used to disable offline support for specific urls
  42874. */
  42875. disableOfflineSupportExceptionRules: RegExp[];
  42876. /**
  42877. * An event triggered when the scene is disposed.
  42878. */
  42879. onDisposeObservable: Observable<Scene>;
  42880. private _onDisposeObserver;
  42881. /** Sets a function to be executed when this scene is disposed. */
  42882. set onDispose(callback: () => void);
  42883. /**
  42884. * An event triggered before rendering the scene (right after animations and physics)
  42885. */
  42886. onBeforeRenderObservable: Observable<Scene>;
  42887. private _onBeforeRenderObserver;
  42888. /** Sets a function to be executed before rendering this scene */
  42889. set beforeRender(callback: Nullable<() => void>);
  42890. /**
  42891. * An event triggered after rendering the scene
  42892. */
  42893. onAfterRenderObservable: Observable<Scene>;
  42894. /**
  42895. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  42896. */
  42897. onAfterRenderCameraObservable: Observable<Camera>;
  42898. private _onAfterRenderObserver;
  42899. /** Sets a function to be executed after rendering this scene */
  42900. set afterRender(callback: Nullable<() => void>);
  42901. /**
  42902. * An event triggered before animating the scene
  42903. */
  42904. onBeforeAnimationsObservable: Observable<Scene>;
  42905. /**
  42906. * An event triggered after animations processing
  42907. */
  42908. onAfterAnimationsObservable: Observable<Scene>;
  42909. /**
  42910. * An event triggered before draw calls are ready to be sent
  42911. */
  42912. onBeforeDrawPhaseObservable: Observable<Scene>;
  42913. /**
  42914. * An event triggered after draw calls have been sent
  42915. */
  42916. onAfterDrawPhaseObservable: Observable<Scene>;
  42917. /**
  42918. * An event triggered when the scene is ready
  42919. */
  42920. onReadyObservable: Observable<Scene>;
  42921. /**
  42922. * An event triggered before rendering a camera
  42923. */
  42924. onBeforeCameraRenderObservable: Observable<Camera>;
  42925. private _onBeforeCameraRenderObserver;
  42926. /** Sets a function to be executed before rendering a camera*/
  42927. set beforeCameraRender(callback: () => void);
  42928. /**
  42929. * An event triggered after rendering a camera
  42930. */
  42931. onAfterCameraRenderObservable: Observable<Camera>;
  42932. private _onAfterCameraRenderObserver;
  42933. /** Sets a function to be executed after rendering a camera*/
  42934. set afterCameraRender(callback: () => void);
  42935. /**
  42936. * An event triggered when active meshes evaluation is about to start
  42937. */
  42938. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  42939. /**
  42940. * An event triggered when active meshes evaluation is done
  42941. */
  42942. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  42943. /**
  42944. * An event triggered when particles rendering is about to start
  42945. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  42946. */
  42947. onBeforeParticlesRenderingObservable: Observable<Scene>;
  42948. /**
  42949. * An event triggered when particles rendering is done
  42950. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  42951. */
  42952. onAfterParticlesRenderingObservable: Observable<Scene>;
  42953. /**
  42954. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  42955. */
  42956. onDataLoadedObservable: Observable<Scene>;
  42957. /**
  42958. * An event triggered when a camera is created
  42959. */
  42960. onNewCameraAddedObservable: Observable<Camera>;
  42961. /**
  42962. * An event triggered when a camera is removed
  42963. */
  42964. onCameraRemovedObservable: Observable<Camera>;
  42965. /**
  42966. * An event triggered when a light is created
  42967. */
  42968. onNewLightAddedObservable: Observable<Light>;
  42969. /**
  42970. * An event triggered when a light is removed
  42971. */
  42972. onLightRemovedObservable: Observable<Light>;
  42973. /**
  42974. * An event triggered when a geometry is created
  42975. */
  42976. onNewGeometryAddedObservable: Observable<Geometry>;
  42977. /**
  42978. * An event triggered when a geometry is removed
  42979. */
  42980. onGeometryRemovedObservable: Observable<Geometry>;
  42981. /**
  42982. * An event triggered when a transform node is created
  42983. */
  42984. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  42985. /**
  42986. * An event triggered when a transform node is removed
  42987. */
  42988. onTransformNodeRemovedObservable: Observable<TransformNode>;
  42989. /**
  42990. * An event triggered when a mesh is created
  42991. */
  42992. onNewMeshAddedObservable: Observable<AbstractMesh>;
  42993. /**
  42994. * An event triggered when a mesh is removed
  42995. */
  42996. onMeshRemovedObservable: Observable<AbstractMesh>;
  42997. /**
  42998. * An event triggered when a skeleton is created
  42999. */
  43000. onNewSkeletonAddedObservable: Observable<Skeleton>;
  43001. /**
  43002. * An event triggered when a skeleton is removed
  43003. */
  43004. onSkeletonRemovedObservable: Observable<Skeleton>;
  43005. /**
  43006. * An event triggered when a material is created
  43007. */
  43008. onNewMaterialAddedObservable: Observable<Material>;
  43009. /**
  43010. * An event triggered when a material is removed
  43011. */
  43012. onMaterialRemovedObservable: Observable<Material>;
  43013. /**
  43014. * An event triggered when a texture is created
  43015. */
  43016. onNewTextureAddedObservable: Observable<BaseTexture>;
  43017. /**
  43018. * An event triggered when a texture is removed
  43019. */
  43020. onTextureRemovedObservable: Observable<BaseTexture>;
  43021. /**
  43022. * An event triggered when render targets are about to be rendered
  43023. * Can happen multiple times per frame.
  43024. */
  43025. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  43026. /**
  43027. * An event triggered when render targets were rendered.
  43028. * Can happen multiple times per frame.
  43029. */
  43030. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  43031. /**
  43032. * An event triggered before calculating deterministic simulation step
  43033. */
  43034. onBeforeStepObservable: Observable<Scene>;
  43035. /**
  43036. * An event triggered after calculating deterministic simulation step
  43037. */
  43038. onAfterStepObservable: Observable<Scene>;
  43039. /**
  43040. * An event triggered when the activeCamera property is updated
  43041. */
  43042. onActiveCameraChanged: Observable<Scene>;
  43043. /**
  43044. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  43045. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  43046. * 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)
  43047. */
  43048. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  43049. /**
  43050. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  43051. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  43052. * 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)
  43053. */
  43054. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  43055. /**
  43056. * This Observable will when a mesh has been imported into the scene.
  43057. */
  43058. onMeshImportedObservable: Observable<AbstractMesh>;
  43059. /**
  43060. * This Observable will when an animation file has been imported into the scene.
  43061. */
  43062. onAnimationFileImportedObservable: Observable<Scene>;
  43063. /**
  43064. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  43065. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  43066. */
  43067. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  43068. /** @hidden */
  43069. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  43070. /**
  43071. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  43072. */
  43073. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  43074. /**
  43075. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  43076. */
  43077. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  43078. /**
  43079. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  43080. */
  43081. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  43082. /** Callback called when a pointer move is detected */
  43083. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  43084. /** Callback called when a pointer down is detected */
  43085. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  43086. /** Callback called when a pointer up is detected */
  43087. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  43088. /** Callback called when a pointer pick is detected */
  43089. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  43090. /**
  43091. * 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).
  43092. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  43093. */
  43094. onPrePointerObservable: Observable<PointerInfoPre>;
  43095. /**
  43096. * Observable event triggered each time an input event is received from the rendering canvas
  43097. */
  43098. onPointerObservable: Observable<PointerInfo>;
  43099. /**
  43100. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  43101. */
  43102. get unTranslatedPointer(): Vector2;
  43103. /**
  43104. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  43105. */
  43106. static get DragMovementThreshold(): number;
  43107. static set DragMovementThreshold(value: number);
  43108. /**
  43109. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  43110. */
  43111. static get LongPressDelay(): number;
  43112. static set LongPressDelay(value: number);
  43113. /**
  43114. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  43115. */
  43116. static get DoubleClickDelay(): number;
  43117. static set DoubleClickDelay(value: number);
  43118. /** If you need to check double click without raising a single click at first click, enable this flag */
  43119. static get ExclusiveDoubleClickMode(): boolean;
  43120. static set ExclusiveDoubleClickMode(value: boolean);
  43121. /** @hidden */
  43122. _mirroredCameraPosition: Nullable<Vector3>;
  43123. /**
  43124. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  43125. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  43126. */
  43127. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  43128. /**
  43129. * Observable event triggered each time an keyboard event is received from the hosting window
  43130. */
  43131. onKeyboardObservable: Observable<KeyboardInfo>;
  43132. private _useRightHandedSystem;
  43133. /**
  43134. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  43135. */
  43136. set useRightHandedSystem(value: boolean);
  43137. get useRightHandedSystem(): boolean;
  43138. private _timeAccumulator;
  43139. private _currentStepId;
  43140. private _currentInternalStep;
  43141. /**
  43142. * Sets the step Id used by deterministic lock step
  43143. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43144. * @param newStepId defines the step Id
  43145. */
  43146. setStepId(newStepId: number): void;
  43147. /**
  43148. * Gets the step Id used by deterministic lock step
  43149. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43150. * @returns the step Id
  43151. */
  43152. getStepId(): number;
  43153. /**
  43154. * Gets the internal step used by deterministic lock step
  43155. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43156. * @returns the internal step
  43157. */
  43158. getInternalStep(): number;
  43159. private _fogEnabled;
  43160. /**
  43161. * Gets or sets a boolean indicating if fog is enabled on this scene
  43162. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43163. * (Default is true)
  43164. */
  43165. set fogEnabled(value: boolean);
  43166. get fogEnabled(): boolean;
  43167. private _fogMode;
  43168. /**
  43169. * Gets or sets the fog mode to use
  43170. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43171. * | mode | value |
  43172. * | --- | --- |
  43173. * | FOGMODE_NONE | 0 |
  43174. * | FOGMODE_EXP | 1 |
  43175. * | FOGMODE_EXP2 | 2 |
  43176. * | FOGMODE_LINEAR | 3 |
  43177. */
  43178. set fogMode(value: number);
  43179. get fogMode(): number;
  43180. /**
  43181. * Gets or sets the fog color to use
  43182. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43183. * (Default is Color3(0.2, 0.2, 0.3))
  43184. */
  43185. fogColor: Color3;
  43186. /**
  43187. * Gets or sets the fog density to use
  43188. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43189. * (Default is 0.1)
  43190. */
  43191. fogDensity: number;
  43192. /**
  43193. * Gets or sets the fog start distance to use
  43194. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43195. * (Default is 0)
  43196. */
  43197. fogStart: number;
  43198. /**
  43199. * Gets or sets the fog end distance to use
  43200. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43201. * (Default is 1000)
  43202. */
  43203. fogEnd: number;
  43204. /**
  43205. * Flag indicating that the frame buffer binding is handled by another component
  43206. */
  43207. prePass: boolean;
  43208. private _shadowsEnabled;
  43209. /**
  43210. * Gets or sets a boolean indicating if shadows are enabled on this scene
  43211. */
  43212. set shadowsEnabled(value: boolean);
  43213. get shadowsEnabled(): boolean;
  43214. private _lightsEnabled;
  43215. /**
  43216. * Gets or sets a boolean indicating if lights are enabled on this scene
  43217. */
  43218. set lightsEnabled(value: boolean);
  43219. get lightsEnabled(): boolean;
  43220. /** All of the active cameras added to this scene. */
  43221. activeCameras: Camera[];
  43222. /** @hidden */
  43223. _activeCamera: Nullable<Camera>;
  43224. /** Gets or sets the current active camera */
  43225. get activeCamera(): Nullable<Camera>;
  43226. set activeCamera(value: Nullable<Camera>);
  43227. private _defaultMaterial;
  43228. /** The default material used on meshes when no material is affected */
  43229. get defaultMaterial(): Material;
  43230. /** The default material used on meshes when no material is affected */
  43231. set defaultMaterial(value: Material);
  43232. private _texturesEnabled;
  43233. /**
  43234. * Gets or sets a boolean indicating if textures are enabled on this scene
  43235. */
  43236. set texturesEnabled(value: boolean);
  43237. get texturesEnabled(): boolean;
  43238. /**
  43239. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  43240. */
  43241. physicsEnabled: boolean;
  43242. /**
  43243. * Gets or sets a boolean indicating if particles are enabled on this scene
  43244. */
  43245. particlesEnabled: boolean;
  43246. /**
  43247. * Gets or sets a boolean indicating if sprites are enabled on this scene
  43248. */
  43249. spritesEnabled: boolean;
  43250. private _skeletonsEnabled;
  43251. /**
  43252. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  43253. */
  43254. set skeletonsEnabled(value: boolean);
  43255. get skeletonsEnabled(): boolean;
  43256. /**
  43257. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  43258. */
  43259. lensFlaresEnabled: boolean;
  43260. /**
  43261. * Gets or sets a boolean indicating if collisions are enabled on this scene
  43262. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  43263. */
  43264. collisionsEnabled: boolean;
  43265. private _collisionCoordinator;
  43266. /** @hidden */
  43267. get collisionCoordinator(): ICollisionCoordinator;
  43268. /**
  43269. * Defines the gravity applied to this scene (used only for collisions)
  43270. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  43271. */
  43272. gravity: Vector3;
  43273. /**
  43274. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  43275. */
  43276. postProcessesEnabled: boolean;
  43277. /**
  43278. * Gets the current postprocess manager
  43279. */
  43280. postProcessManager: PostProcessManager;
  43281. /**
  43282. * Gets or sets a boolean indicating if render targets are enabled on this scene
  43283. */
  43284. renderTargetsEnabled: boolean;
  43285. /**
  43286. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  43287. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  43288. */
  43289. dumpNextRenderTargets: boolean;
  43290. /**
  43291. * The list of user defined render targets added to the scene
  43292. */
  43293. customRenderTargets: RenderTargetTexture[];
  43294. /**
  43295. * Defines if texture loading must be delayed
  43296. * If true, textures will only be loaded when they need to be rendered
  43297. */
  43298. useDelayedTextureLoading: boolean;
  43299. /**
  43300. * Gets the list of meshes imported to the scene through SceneLoader
  43301. */
  43302. importedMeshesFiles: String[];
  43303. /**
  43304. * Gets or sets a boolean indicating if probes are enabled on this scene
  43305. */
  43306. probesEnabled: boolean;
  43307. /**
  43308. * Gets or sets the current offline provider to use to store scene data
  43309. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  43310. */
  43311. offlineProvider: IOfflineProvider;
  43312. /**
  43313. * Gets or sets the action manager associated with the scene
  43314. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  43315. */
  43316. actionManager: AbstractActionManager;
  43317. private _meshesForIntersections;
  43318. /**
  43319. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  43320. */
  43321. proceduralTexturesEnabled: boolean;
  43322. private _engine;
  43323. private _totalVertices;
  43324. /** @hidden */
  43325. _activeIndices: PerfCounter;
  43326. /** @hidden */
  43327. _activeParticles: PerfCounter;
  43328. /** @hidden */
  43329. _activeBones: PerfCounter;
  43330. private _animationRatio;
  43331. /** @hidden */
  43332. _animationTimeLast: number;
  43333. /** @hidden */
  43334. _animationTime: number;
  43335. /**
  43336. * Gets or sets a general scale for animation speed
  43337. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  43338. */
  43339. animationTimeScale: number;
  43340. /** @hidden */
  43341. _cachedMaterial: Nullable<Material>;
  43342. /** @hidden */
  43343. _cachedEffect: Nullable<Effect>;
  43344. /** @hidden */
  43345. _cachedVisibility: Nullable<number>;
  43346. private _renderId;
  43347. private _frameId;
  43348. private _executeWhenReadyTimeoutId;
  43349. private _intermediateRendering;
  43350. private _viewUpdateFlag;
  43351. private _projectionUpdateFlag;
  43352. /** @hidden */
  43353. _toBeDisposed: Nullable<IDisposable>[];
  43354. private _activeRequests;
  43355. /** @hidden */
  43356. _pendingData: any[];
  43357. private _isDisposed;
  43358. /**
  43359. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  43360. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  43361. */
  43362. dispatchAllSubMeshesOfActiveMeshes: boolean;
  43363. private _activeMeshes;
  43364. private _processedMaterials;
  43365. private _renderTargets;
  43366. /** @hidden */
  43367. _activeParticleSystems: SmartArray<IParticleSystem>;
  43368. private _activeSkeletons;
  43369. private _softwareSkinnedMeshes;
  43370. private _renderingManager;
  43371. /** @hidden */
  43372. _activeAnimatables: Animatable[];
  43373. private _transformMatrix;
  43374. private _sceneUbo;
  43375. /** @hidden */
  43376. _viewMatrix: Matrix;
  43377. private _projectionMatrix;
  43378. /** @hidden */
  43379. _forcedViewPosition: Nullable<Vector3>;
  43380. /** @hidden */
  43381. _frustumPlanes: Plane[];
  43382. /**
  43383. * Gets the list of frustum planes (built from the active camera)
  43384. */
  43385. get frustumPlanes(): Plane[];
  43386. /**
  43387. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  43388. * This is useful if there are more lights that the maximum simulteanous authorized
  43389. */
  43390. requireLightSorting: boolean;
  43391. /** @hidden */
  43392. readonly useMaterialMeshMap: boolean;
  43393. /** @hidden */
  43394. readonly useClonedMeshMap: boolean;
  43395. private _externalData;
  43396. private _uid;
  43397. /**
  43398. * @hidden
  43399. * Backing store of defined scene components.
  43400. */
  43401. _components: ISceneComponent[];
  43402. /**
  43403. * @hidden
  43404. * Backing store of defined scene components.
  43405. */
  43406. _serializableComponents: ISceneSerializableComponent[];
  43407. /**
  43408. * List of components to register on the next registration step.
  43409. */
  43410. private _transientComponents;
  43411. /**
  43412. * Registers the transient components if needed.
  43413. */
  43414. private _registerTransientComponents;
  43415. /**
  43416. * @hidden
  43417. * Add a component to the scene.
  43418. * Note that the ccomponent could be registered on th next frame if this is called after
  43419. * the register component stage.
  43420. * @param component Defines the component to add to the scene
  43421. */
  43422. _addComponent(component: ISceneComponent): void;
  43423. /**
  43424. * @hidden
  43425. * Gets a component from the scene.
  43426. * @param name defines the name of the component to retrieve
  43427. * @returns the component or null if not present
  43428. */
  43429. _getComponent(name: string): Nullable<ISceneComponent>;
  43430. /**
  43431. * @hidden
  43432. * Defines the actions happening before camera updates.
  43433. */
  43434. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  43435. /**
  43436. * @hidden
  43437. * Defines the actions happening before clear the canvas.
  43438. */
  43439. _beforeClearStage: Stage<SimpleStageAction>;
  43440. /**
  43441. * @hidden
  43442. * Defines the actions when collecting render targets for the frame.
  43443. */
  43444. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  43445. /**
  43446. * @hidden
  43447. * Defines the actions happening for one camera in the frame.
  43448. */
  43449. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  43450. /**
  43451. * @hidden
  43452. * Defines the actions happening during the per mesh ready checks.
  43453. */
  43454. _isReadyForMeshStage: Stage<MeshStageAction>;
  43455. /**
  43456. * @hidden
  43457. * Defines the actions happening before evaluate active mesh checks.
  43458. */
  43459. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  43460. /**
  43461. * @hidden
  43462. * Defines the actions happening during the evaluate sub mesh checks.
  43463. */
  43464. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  43465. /**
  43466. * @hidden
  43467. * Defines the actions happening during the active mesh stage.
  43468. */
  43469. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  43470. /**
  43471. * @hidden
  43472. * Defines the actions happening during the per camera render target step.
  43473. */
  43474. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  43475. /**
  43476. * @hidden
  43477. * Defines the actions happening just before the active camera is drawing.
  43478. */
  43479. _beforeCameraDrawStage: Stage<CameraStageAction>;
  43480. /**
  43481. * @hidden
  43482. * Defines the actions happening just before a render target is drawing.
  43483. */
  43484. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  43485. /**
  43486. * @hidden
  43487. * Defines the actions happening just before a rendering group is drawing.
  43488. */
  43489. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  43490. /**
  43491. * @hidden
  43492. * Defines the actions happening just before a mesh is drawing.
  43493. */
  43494. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  43495. /**
  43496. * @hidden
  43497. * Defines the actions happening just after a mesh has been drawn.
  43498. */
  43499. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  43500. /**
  43501. * @hidden
  43502. * Defines the actions happening just after a rendering group has been drawn.
  43503. */
  43504. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  43505. /**
  43506. * @hidden
  43507. * Defines the actions happening just after the active camera has been drawn.
  43508. */
  43509. _afterCameraDrawStage: Stage<CameraStageAction>;
  43510. /**
  43511. * @hidden
  43512. * Defines the actions happening just after a render target has been drawn.
  43513. */
  43514. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  43515. /**
  43516. * @hidden
  43517. * Defines the actions happening just after rendering all cameras and computing intersections.
  43518. */
  43519. _afterRenderStage: Stage<SimpleStageAction>;
  43520. /**
  43521. * @hidden
  43522. * Defines the actions happening when a pointer move event happens.
  43523. */
  43524. _pointerMoveStage: Stage<PointerMoveStageAction>;
  43525. /**
  43526. * @hidden
  43527. * Defines the actions happening when a pointer down event happens.
  43528. */
  43529. _pointerDownStage: Stage<PointerUpDownStageAction>;
  43530. /**
  43531. * @hidden
  43532. * Defines the actions happening when a pointer up event happens.
  43533. */
  43534. _pointerUpStage: Stage<PointerUpDownStageAction>;
  43535. /**
  43536. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  43537. */
  43538. private geometriesByUniqueId;
  43539. /**
  43540. * Creates a new Scene
  43541. * @param engine defines the engine to use to render this scene
  43542. * @param options defines the scene options
  43543. */
  43544. constructor(engine: Engine, options?: SceneOptions);
  43545. /**
  43546. * Gets a string identifying the name of the class
  43547. * @returns "Scene" string
  43548. */
  43549. getClassName(): string;
  43550. private _defaultMeshCandidates;
  43551. /**
  43552. * @hidden
  43553. */
  43554. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43555. private _defaultSubMeshCandidates;
  43556. /**
  43557. * @hidden
  43558. */
  43559. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43560. /**
  43561. * Sets the default candidate providers for the scene.
  43562. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  43563. * and getCollidingSubMeshCandidates to their default function
  43564. */
  43565. setDefaultCandidateProviders(): void;
  43566. /**
  43567. * Gets the mesh that is currently under the pointer
  43568. */
  43569. get meshUnderPointer(): Nullable<AbstractMesh>;
  43570. /**
  43571. * Gets or sets the current on-screen X position of the pointer
  43572. */
  43573. get pointerX(): number;
  43574. set pointerX(value: number);
  43575. /**
  43576. * Gets or sets the current on-screen Y position of the pointer
  43577. */
  43578. get pointerY(): number;
  43579. set pointerY(value: number);
  43580. /**
  43581. * Gets the cached material (ie. the latest rendered one)
  43582. * @returns the cached material
  43583. */
  43584. getCachedMaterial(): Nullable<Material>;
  43585. /**
  43586. * Gets the cached effect (ie. the latest rendered one)
  43587. * @returns the cached effect
  43588. */
  43589. getCachedEffect(): Nullable<Effect>;
  43590. /**
  43591. * Gets the cached visibility state (ie. the latest rendered one)
  43592. * @returns the cached visibility state
  43593. */
  43594. getCachedVisibility(): Nullable<number>;
  43595. /**
  43596. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  43597. * @param material defines the current material
  43598. * @param effect defines the current effect
  43599. * @param visibility defines the current visibility state
  43600. * @returns true if one parameter is not cached
  43601. */
  43602. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  43603. /**
  43604. * Gets the engine associated with the scene
  43605. * @returns an Engine
  43606. */
  43607. getEngine(): Engine;
  43608. /**
  43609. * Gets the total number of vertices rendered per frame
  43610. * @returns the total number of vertices rendered per frame
  43611. */
  43612. getTotalVertices(): number;
  43613. /**
  43614. * Gets the performance counter for total vertices
  43615. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43616. */
  43617. get totalVerticesPerfCounter(): PerfCounter;
  43618. /**
  43619. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  43620. * @returns the total number of active indices rendered per frame
  43621. */
  43622. getActiveIndices(): number;
  43623. /**
  43624. * Gets the performance counter for active indices
  43625. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43626. */
  43627. get totalActiveIndicesPerfCounter(): PerfCounter;
  43628. /**
  43629. * Gets the total number of active particles rendered per frame
  43630. * @returns the total number of active particles rendered per frame
  43631. */
  43632. getActiveParticles(): number;
  43633. /**
  43634. * Gets the performance counter for active particles
  43635. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43636. */
  43637. get activeParticlesPerfCounter(): PerfCounter;
  43638. /**
  43639. * Gets the total number of active bones rendered per frame
  43640. * @returns the total number of active bones rendered per frame
  43641. */
  43642. getActiveBones(): number;
  43643. /**
  43644. * Gets the performance counter for active bones
  43645. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43646. */
  43647. get activeBonesPerfCounter(): PerfCounter;
  43648. /**
  43649. * Gets the array of active meshes
  43650. * @returns an array of AbstractMesh
  43651. */
  43652. getActiveMeshes(): SmartArray<AbstractMesh>;
  43653. /**
  43654. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  43655. * @returns a number
  43656. */
  43657. getAnimationRatio(): number;
  43658. /**
  43659. * Gets an unique Id for the current render phase
  43660. * @returns a number
  43661. */
  43662. getRenderId(): number;
  43663. /**
  43664. * Gets an unique Id for the current frame
  43665. * @returns a number
  43666. */
  43667. getFrameId(): number;
  43668. /** Call this function if you want to manually increment the render Id*/
  43669. incrementRenderId(): void;
  43670. private _createUbo;
  43671. /**
  43672. * Use this method to simulate a pointer move on a mesh
  43673. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43674. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43675. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43676. * @returns the current scene
  43677. */
  43678. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  43679. /**
  43680. * Use this method to simulate a pointer down on a mesh
  43681. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43682. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43683. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43684. * @returns the current scene
  43685. */
  43686. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  43687. /**
  43688. * Use this method to simulate a pointer up on a mesh
  43689. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43690. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43691. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43692. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43693. * @returns the current scene
  43694. */
  43695. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  43696. /**
  43697. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  43698. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  43699. * @returns true if the pointer was captured
  43700. */
  43701. isPointerCaptured(pointerId?: number): boolean;
  43702. /**
  43703. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  43704. * @param attachUp defines if you want to attach events to pointerup
  43705. * @param attachDown defines if you want to attach events to pointerdown
  43706. * @param attachMove defines if you want to attach events to pointermove
  43707. */
  43708. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  43709. /** Detaches all event handlers*/
  43710. detachControl(): void;
  43711. /**
  43712. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  43713. * Delay loaded resources are not taking in account
  43714. * @return true if all required resources are ready
  43715. */
  43716. isReady(): boolean;
  43717. /** Resets all cached information relative to material (including effect and visibility) */
  43718. resetCachedMaterial(): void;
  43719. /**
  43720. * Registers a function to be called before every frame render
  43721. * @param func defines the function to register
  43722. */
  43723. registerBeforeRender(func: () => void): void;
  43724. /**
  43725. * Unregisters a function called before every frame render
  43726. * @param func defines the function to unregister
  43727. */
  43728. unregisterBeforeRender(func: () => void): void;
  43729. /**
  43730. * Registers a function to be called after every frame render
  43731. * @param func defines the function to register
  43732. */
  43733. registerAfterRender(func: () => void): void;
  43734. /**
  43735. * Unregisters a function called after every frame render
  43736. * @param func defines the function to unregister
  43737. */
  43738. unregisterAfterRender(func: () => void): void;
  43739. private _executeOnceBeforeRender;
  43740. /**
  43741. * The provided function will run before render once and will be disposed afterwards.
  43742. * A timeout delay can be provided so that the function will be executed in N ms.
  43743. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  43744. * @param func The function to be executed.
  43745. * @param timeout optional delay in ms
  43746. */
  43747. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  43748. /** @hidden */
  43749. _addPendingData(data: any): void;
  43750. /** @hidden */
  43751. _removePendingData(data: any): void;
  43752. /**
  43753. * Returns the number of items waiting to be loaded
  43754. * @returns the number of items waiting to be loaded
  43755. */
  43756. getWaitingItemsCount(): number;
  43757. /**
  43758. * Returns a boolean indicating if the scene is still loading data
  43759. */
  43760. get isLoading(): boolean;
  43761. /**
  43762. * Registers a function to be executed when the scene is ready
  43763. * @param {Function} func - the function to be executed
  43764. */
  43765. executeWhenReady(func: () => void): void;
  43766. /**
  43767. * Returns a promise that resolves when the scene is ready
  43768. * @returns A promise that resolves when the scene is ready
  43769. */
  43770. whenReadyAsync(): Promise<void>;
  43771. /** @hidden */
  43772. _checkIsReady(): void;
  43773. /**
  43774. * Gets all animatable attached to the scene
  43775. */
  43776. get animatables(): Animatable[];
  43777. /**
  43778. * Resets the last animation time frame.
  43779. * Useful to override when animations start running when loading a scene for the first time.
  43780. */
  43781. resetLastAnimationTimeFrame(): void;
  43782. /**
  43783. * Gets the current view matrix
  43784. * @returns a Matrix
  43785. */
  43786. getViewMatrix(): Matrix;
  43787. /**
  43788. * Gets the current projection matrix
  43789. * @returns a Matrix
  43790. */
  43791. getProjectionMatrix(): Matrix;
  43792. /**
  43793. * Gets the current transform matrix
  43794. * @returns a Matrix made of View * Projection
  43795. */
  43796. getTransformMatrix(): Matrix;
  43797. /**
  43798. * Sets the current transform matrix
  43799. * @param viewL defines the View matrix to use
  43800. * @param projectionL defines the Projection matrix to use
  43801. * @param viewR defines the right View matrix to use (if provided)
  43802. * @param projectionR defines the right Projection matrix to use (if provided)
  43803. */
  43804. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  43805. /**
  43806. * Gets the uniform buffer used to store scene data
  43807. * @returns a UniformBuffer
  43808. */
  43809. getSceneUniformBuffer(): UniformBuffer;
  43810. /**
  43811. * Gets an unique (relatively to the current scene) Id
  43812. * @returns an unique number for the scene
  43813. */
  43814. getUniqueId(): number;
  43815. /**
  43816. * Add a mesh to the list of scene's meshes
  43817. * @param newMesh defines the mesh to add
  43818. * @param recursive if all child meshes should also be added to the scene
  43819. */
  43820. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  43821. /**
  43822. * Remove a mesh for the list of scene's meshes
  43823. * @param toRemove defines the mesh to remove
  43824. * @param recursive if all child meshes should also be removed from the scene
  43825. * @returns the index where the mesh was in the mesh list
  43826. */
  43827. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  43828. /**
  43829. * Add a transform node to the list of scene's transform nodes
  43830. * @param newTransformNode defines the transform node to add
  43831. */
  43832. addTransformNode(newTransformNode: TransformNode): void;
  43833. /**
  43834. * Remove a transform node for the list of scene's transform nodes
  43835. * @param toRemove defines the transform node to remove
  43836. * @returns the index where the transform node was in the transform node list
  43837. */
  43838. removeTransformNode(toRemove: TransformNode): number;
  43839. /**
  43840. * Remove a skeleton for the list of scene's skeletons
  43841. * @param toRemove defines the skeleton to remove
  43842. * @returns the index where the skeleton was in the skeleton list
  43843. */
  43844. removeSkeleton(toRemove: Skeleton): number;
  43845. /**
  43846. * Remove a morph target for the list of scene's morph targets
  43847. * @param toRemove defines the morph target to remove
  43848. * @returns the index where the morph target was in the morph target list
  43849. */
  43850. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  43851. /**
  43852. * Remove a light for the list of scene's lights
  43853. * @param toRemove defines the light to remove
  43854. * @returns the index where the light was in the light list
  43855. */
  43856. removeLight(toRemove: Light): number;
  43857. /**
  43858. * Remove a camera for the list of scene's cameras
  43859. * @param toRemove defines the camera to remove
  43860. * @returns the index where the camera was in the camera list
  43861. */
  43862. removeCamera(toRemove: Camera): number;
  43863. /**
  43864. * Remove a particle system for the list of scene's particle systems
  43865. * @param toRemove defines the particle system to remove
  43866. * @returns the index where the particle system was in the particle system list
  43867. */
  43868. removeParticleSystem(toRemove: IParticleSystem): number;
  43869. /**
  43870. * Remove a animation for the list of scene's animations
  43871. * @param toRemove defines the animation to remove
  43872. * @returns the index where the animation was in the animation list
  43873. */
  43874. removeAnimation(toRemove: Animation): number;
  43875. /**
  43876. * Will stop the animation of the given target
  43877. * @param target - the target
  43878. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  43879. * @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)
  43880. */
  43881. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  43882. /**
  43883. * Removes the given animation group from this scene.
  43884. * @param toRemove The animation group to remove
  43885. * @returns The index of the removed animation group
  43886. */
  43887. removeAnimationGroup(toRemove: AnimationGroup): number;
  43888. /**
  43889. * Removes the given multi-material from this scene.
  43890. * @param toRemove The multi-material to remove
  43891. * @returns The index of the removed multi-material
  43892. */
  43893. removeMultiMaterial(toRemove: MultiMaterial): number;
  43894. /**
  43895. * Removes the given material from this scene.
  43896. * @param toRemove The material to remove
  43897. * @returns The index of the removed material
  43898. */
  43899. removeMaterial(toRemove: Material): number;
  43900. /**
  43901. * Removes the given action manager from this scene.
  43902. * @param toRemove The action manager to remove
  43903. * @returns The index of the removed action manager
  43904. */
  43905. removeActionManager(toRemove: AbstractActionManager): number;
  43906. /**
  43907. * Removes the given texture from this scene.
  43908. * @param toRemove The texture to remove
  43909. * @returns The index of the removed texture
  43910. */
  43911. removeTexture(toRemove: BaseTexture): number;
  43912. /**
  43913. * Adds the given light to this scene
  43914. * @param newLight The light to add
  43915. */
  43916. addLight(newLight: Light): void;
  43917. /**
  43918. * Sorts the list list based on light priorities
  43919. */
  43920. sortLightsByPriority(): void;
  43921. /**
  43922. * Adds the given camera to this scene
  43923. * @param newCamera The camera to add
  43924. */
  43925. addCamera(newCamera: Camera): void;
  43926. /**
  43927. * Adds the given skeleton to this scene
  43928. * @param newSkeleton The skeleton to add
  43929. */
  43930. addSkeleton(newSkeleton: Skeleton): void;
  43931. /**
  43932. * Adds the given particle system to this scene
  43933. * @param newParticleSystem The particle system to add
  43934. */
  43935. addParticleSystem(newParticleSystem: IParticleSystem): void;
  43936. /**
  43937. * Adds the given animation to this scene
  43938. * @param newAnimation The animation to add
  43939. */
  43940. addAnimation(newAnimation: Animation): void;
  43941. /**
  43942. * Adds the given animation group to this scene.
  43943. * @param newAnimationGroup The animation group to add
  43944. */
  43945. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  43946. /**
  43947. * Adds the given multi-material to this scene
  43948. * @param newMultiMaterial The multi-material to add
  43949. */
  43950. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  43951. /**
  43952. * Adds the given material to this scene
  43953. * @param newMaterial The material to add
  43954. */
  43955. addMaterial(newMaterial: Material): void;
  43956. /**
  43957. * Adds the given morph target to this scene
  43958. * @param newMorphTargetManager The morph target to add
  43959. */
  43960. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  43961. /**
  43962. * Adds the given geometry to this scene
  43963. * @param newGeometry The geometry to add
  43964. */
  43965. addGeometry(newGeometry: Geometry): void;
  43966. /**
  43967. * Adds the given action manager to this scene
  43968. * @param newActionManager The action manager to add
  43969. */
  43970. addActionManager(newActionManager: AbstractActionManager): void;
  43971. /**
  43972. * Adds the given texture to this scene.
  43973. * @param newTexture The texture to add
  43974. */
  43975. addTexture(newTexture: BaseTexture): void;
  43976. /**
  43977. * Switch active camera
  43978. * @param newCamera defines the new active camera
  43979. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  43980. */
  43981. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  43982. /**
  43983. * sets the active camera of the scene using its ID
  43984. * @param id defines the camera's ID
  43985. * @return the new active camera or null if none found.
  43986. */
  43987. setActiveCameraByID(id: string): Nullable<Camera>;
  43988. /**
  43989. * sets the active camera of the scene using its name
  43990. * @param name defines the camera's name
  43991. * @returns the new active camera or null if none found.
  43992. */
  43993. setActiveCameraByName(name: string): Nullable<Camera>;
  43994. /**
  43995. * get an animation group using its name
  43996. * @param name defines the material's name
  43997. * @return the animation group or null if none found.
  43998. */
  43999. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  44000. /**
  44001. * Get a material using its unique id
  44002. * @param uniqueId defines the material's unique id
  44003. * @return the material or null if none found.
  44004. */
  44005. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  44006. /**
  44007. * get a material using its id
  44008. * @param id defines the material's ID
  44009. * @return the material or null if none found.
  44010. */
  44011. getMaterialByID(id: string): Nullable<Material>;
  44012. /**
  44013. * Gets a the last added material using a given id
  44014. * @param id defines the material's ID
  44015. * @return the last material with the given id or null if none found.
  44016. */
  44017. getLastMaterialByID(id: string): Nullable<Material>;
  44018. /**
  44019. * Gets a material using its name
  44020. * @param name defines the material's name
  44021. * @return the material or null if none found.
  44022. */
  44023. getMaterialByName(name: string): Nullable<Material>;
  44024. /**
  44025. * Get a texture using its unique id
  44026. * @param uniqueId defines the texture's unique id
  44027. * @return the texture or null if none found.
  44028. */
  44029. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  44030. /**
  44031. * Gets a camera using its id
  44032. * @param id defines the id to look for
  44033. * @returns the camera or null if not found
  44034. */
  44035. getCameraByID(id: string): Nullable<Camera>;
  44036. /**
  44037. * Gets a camera using its unique id
  44038. * @param uniqueId defines the unique id to look for
  44039. * @returns the camera or null if not found
  44040. */
  44041. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  44042. /**
  44043. * Gets a camera using its name
  44044. * @param name defines the camera's name
  44045. * @return the camera or null if none found.
  44046. */
  44047. getCameraByName(name: string): Nullable<Camera>;
  44048. /**
  44049. * Gets a bone using its id
  44050. * @param id defines the bone's id
  44051. * @return the bone or null if not found
  44052. */
  44053. getBoneByID(id: string): Nullable<Bone>;
  44054. /**
  44055. * Gets a bone using its id
  44056. * @param name defines the bone's name
  44057. * @return the bone or null if not found
  44058. */
  44059. getBoneByName(name: string): Nullable<Bone>;
  44060. /**
  44061. * Gets a light node using its name
  44062. * @param name defines the the light's name
  44063. * @return the light or null if none found.
  44064. */
  44065. getLightByName(name: string): Nullable<Light>;
  44066. /**
  44067. * Gets a light node using its id
  44068. * @param id defines the light's id
  44069. * @return the light or null if none found.
  44070. */
  44071. getLightByID(id: string): Nullable<Light>;
  44072. /**
  44073. * Gets a light node using its scene-generated unique ID
  44074. * @param uniqueId defines the light's unique id
  44075. * @return the light or null if none found.
  44076. */
  44077. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  44078. /**
  44079. * Gets a particle system by id
  44080. * @param id defines the particle system id
  44081. * @return the corresponding system or null if none found
  44082. */
  44083. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  44084. /**
  44085. * Gets a geometry using its ID
  44086. * @param id defines the geometry's id
  44087. * @return the geometry or null if none found.
  44088. */
  44089. getGeometryByID(id: string): Nullable<Geometry>;
  44090. private _getGeometryByUniqueID;
  44091. /**
  44092. * Add a new geometry to this scene
  44093. * @param geometry defines the geometry to be added to the scene.
  44094. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  44095. * @return a boolean defining if the geometry was added or not
  44096. */
  44097. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  44098. /**
  44099. * Removes an existing geometry
  44100. * @param geometry defines the geometry to be removed from the scene
  44101. * @return a boolean defining if the geometry was removed or not
  44102. */
  44103. removeGeometry(geometry: Geometry): boolean;
  44104. /**
  44105. * Gets the list of geometries attached to the scene
  44106. * @returns an array of Geometry
  44107. */
  44108. getGeometries(): Geometry[];
  44109. /**
  44110. * Gets the first added mesh found of a given ID
  44111. * @param id defines the id to search for
  44112. * @return the mesh found or null if not found at all
  44113. */
  44114. getMeshByID(id: string): Nullable<AbstractMesh>;
  44115. /**
  44116. * Gets a list of meshes using their id
  44117. * @param id defines the id to search for
  44118. * @returns a list of meshes
  44119. */
  44120. getMeshesByID(id: string): Array<AbstractMesh>;
  44121. /**
  44122. * Gets the first added transform node found of a given ID
  44123. * @param id defines the id to search for
  44124. * @return the found transform node or null if not found at all.
  44125. */
  44126. getTransformNodeByID(id: string): Nullable<TransformNode>;
  44127. /**
  44128. * Gets a transform node with its auto-generated unique id
  44129. * @param uniqueId efines the unique id to search for
  44130. * @return the found transform node or null if not found at all.
  44131. */
  44132. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  44133. /**
  44134. * Gets a list of transform nodes using their id
  44135. * @param id defines the id to search for
  44136. * @returns a list of transform nodes
  44137. */
  44138. getTransformNodesByID(id: string): Array<TransformNode>;
  44139. /**
  44140. * Gets a mesh with its auto-generated unique id
  44141. * @param uniqueId defines the unique id to search for
  44142. * @return the found mesh or null if not found at all.
  44143. */
  44144. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  44145. /**
  44146. * Gets a the last added mesh using a given id
  44147. * @param id defines the id to search for
  44148. * @return the found mesh or null if not found at all.
  44149. */
  44150. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  44151. /**
  44152. * Gets a the last added node (Mesh, Camera, Light) using a given id
  44153. * @param id defines the id to search for
  44154. * @return the found node or null if not found at all
  44155. */
  44156. getLastEntryByID(id: string): Nullable<Node>;
  44157. /**
  44158. * Gets a node (Mesh, Camera, Light) using a given id
  44159. * @param id defines the id to search for
  44160. * @return the found node or null if not found at all
  44161. */
  44162. getNodeByID(id: string): Nullable<Node>;
  44163. /**
  44164. * Gets a node (Mesh, Camera, Light) using a given name
  44165. * @param name defines the name to search for
  44166. * @return the found node or null if not found at all.
  44167. */
  44168. getNodeByName(name: string): Nullable<Node>;
  44169. /**
  44170. * Gets a mesh using a given name
  44171. * @param name defines the name to search for
  44172. * @return the found mesh or null if not found at all.
  44173. */
  44174. getMeshByName(name: string): Nullable<AbstractMesh>;
  44175. /**
  44176. * Gets a transform node using a given name
  44177. * @param name defines the name to search for
  44178. * @return the found transform node or null if not found at all.
  44179. */
  44180. getTransformNodeByName(name: string): Nullable<TransformNode>;
  44181. /**
  44182. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  44183. * @param id defines the id to search for
  44184. * @return the found skeleton or null if not found at all.
  44185. */
  44186. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  44187. /**
  44188. * Gets a skeleton using a given auto generated unique id
  44189. * @param uniqueId defines the unique id to search for
  44190. * @return the found skeleton or null if not found at all.
  44191. */
  44192. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  44193. /**
  44194. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  44195. * @param id defines the id to search for
  44196. * @return the found skeleton or null if not found at all.
  44197. */
  44198. getSkeletonById(id: string): Nullable<Skeleton>;
  44199. /**
  44200. * Gets a skeleton using a given name
  44201. * @param name defines the name to search for
  44202. * @return the found skeleton or null if not found at all.
  44203. */
  44204. getSkeletonByName(name: string): Nullable<Skeleton>;
  44205. /**
  44206. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  44207. * @param id defines the id to search for
  44208. * @return the found morph target manager or null if not found at all.
  44209. */
  44210. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  44211. /**
  44212. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  44213. * @param id defines the id to search for
  44214. * @return the found morph target or null if not found at all.
  44215. */
  44216. getMorphTargetById(id: string): Nullable<MorphTarget>;
  44217. /**
  44218. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  44219. * @param name defines the name to search for
  44220. * @return the found morph target or null if not found at all.
  44221. */
  44222. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  44223. /**
  44224. * Gets a post process using a given name (if many are found, this function will pick the first one)
  44225. * @param name defines the name to search for
  44226. * @return the found post process or null if not found at all.
  44227. */
  44228. getPostProcessByName(name: string): Nullable<PostProcess>;
  44229. /**
  44230. * Gets a boolean indicating if the given mesh is active
  44231. * @param mesh defines the mesh to look for
  44232. * @returns true if the mesh is in the active list
  44233. */
  44234. isActiveMesh(mesh: AbstractMesh): boolean;
  44235. /**
  44236. * Return a unique id as a string which can serve as an identifier for the scene
  44237. */
  44238. get uid(): string;
  44239. /**
  44240. * Add an externaly attached data from its key.
  44241. * This method call will fail and return false, if such key already exists.
  44242. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  44243. * @param key the unique key that identifies the data
  44244. * @param data the data object to associate to the key for this Engine instance
  44245. * @return true if no such key were already present and the data was added successfully, false otherwise
  44246. */
  44247. addExternalData<T>(key: string, data: T): boolean;
  44248. /**
  44249. * Get an externaly attached data from its key
  44250. * @param key the unique key that identifies the data
  44251. * @return the associated data, if present (can be null), or undefined if not present
  44252. */
  44253. getExternalData<T>(key: string): Nullable<T>;
  44254. /**
  44255. * Get an externaly attached data from its key, create it using a factory if it's not already present
  44256. * @param key the unique key that identifies the data
  44257. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  44258. * @return the associated data, can be null if the factory returned null.
  44259. */
  44260. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  44261. /**
  44262. * Remove an externaly attached data from the Engine instance
  44263. * @param key the unique key that identifies the data
  44264. * @return true if the data was successfully removed, false if it doesn't exist
  44265. */
  44266. removeExternalData(key: string): boolean;
  44267. private _evaluateSubMesh;
  44268. /**
  44269. * Clear the processed materials smart array preventing retention point in material dispose.
  44270. */
  44271. freeProcessedMaterials(): void;
  44272. private _preventFreeActiveMeshesAndRenderingGroups;
  44273. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  44274. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  44275. * when disposing several meshes in a row or a hierarchy of meshes.
  44276. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  44277. */
  44278. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  44279. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  44280. /**
  44281. * Clear the active meshes smart array preventing retention point in mesh dispose.
  44282. */
  44283. freeActiveMeshes(): void;
  44284. /**
  44285. * Clear the info related to rendering groups preventing retention points during dispose.
  44286. */
  44287. freeRenderingGroups(): void;
  44288. /** @hidden */
  44289. _isInIntermediateRendering(): boolean;
  44290. /**
  44291. * Lambda returning the list of potentially active meshes.
  44292. */
  44293. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  44294. /**
  44295. * Lambda returning the list of potentially active sub meshes.
  44296. */
  44297. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  44298. /**
  44299. * Lambda returning the list of potentially intersecting sub meshes.
  44300. */
  44301. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  44302. /**
  44303. * Lambda returning the list of potentially colliding sub meshes.
  44304. */
  44305. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  44306. private _activeMeshesFrozen;
  44307. private _skipEvaluateActiveMeshesCompletely;
  44308. /**
  44309. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  44310. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  44311. * @param onSuccess optional success callback
  44312. * @param onError optional error callback
  44313. * @returns the current scene
  44314. */
  44315. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  44316. /**
  44317. * Use this function to restart evaluating active meshes on every frame
  44318. * @returns the current scene
  44319. */
  44320. unfreezeActiveMeshes(): Scene;
  44321. private _evaluateActiveMeshes;
  44322. private _activeMesh;
  44323. /**
  44324. * Update the transform matrix to update from the current active camera
  44325. * @param force defines a boolean used to force the update even if cache is up to date
  44326. */
  44327. updateTransformMatrix(force?: boolean): void;
  44328. private _bindFrameBuffer;
  44329. /** @hidden */
  44330. _allowPostProcessClearColor: boolean;
  44331. /** @hidden */
  44332. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  44333. private _processSubCameras;
  44334. private _checkIntersections;
  44335. /** @hidden */
  44336. _advancePhysicsEngineStep(step: number): void;
  44337. /**
  44338. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  44339. */
  44340. getDeterministicFrameTime: () => number;
  44341. /** @hidden */
  44342. _animate(): void;
  44343. /** Execute all animations (for a frame) */
  44344. animate(): void;
  44345. /**
  44346. * Render the scene
  44347. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  44348. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  44349. */
  44350. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  44351. /**
  44352. * Freeze all materials
  44353. * A frozen material will not be updatable but should be faster to render
  44354. */
  44355. freezeMaterials(): void;
  44356. /**
  44357. * Unfreeze all materials
  44358. * A frozen material will not be updatable but should be faster to render
  44359. */
  44360. unfreezeMaterials(): void;
  44361. /**
  44362. * Releases all held ressources
  44363. */
  44364. dispose(): void;
  44365. /**
  44366. * Gets if the scene is already disposed
  44367. */
  44368. get isDisposed(): boolean;
  44369. /**
  44370. * Call this function to reduce memory footprint of the scene.
  44371. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  44372. */
  44373. clearCachedVertexData(): void;
  44374. /**
  44375. * This function will remove the local cached buffer data from texture.
  44376. * It will save memory but will prevent the texture from being rebuilt
  44377. */
  44378. cleanCachedTextureBuffer(): void;
  44379. /**
  44380. * Get the world extend vectors with an optional filter
  44381. *
  44382. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  44383. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  44384. */
  44385. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  44386. min: Vector3;
  44387. max: Vector3;
  44388. };
  44389. /**
  44390. * Creates a ray that can be used to pick in the scene
  44391. * @param x defines the x coordinate of the origin (on-screen)
  44392. * @param y defines the y coordinate of the origin (on-screen)
  44393. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  44394. * @param camera defines the camera to use for the picking
  44395. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  44396. * @returns a Ray
  44397. */
  44398. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  44399. /**
  44400. * Creates a ray that can be used to pick in the scene
  44401. * @param x defines the x coordinate of the origin (on-screen)
  44402. * @param y defines the y coordinate of the origin (on-screen)
  44403. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  44404. * @param result defines the ray where to store the picking ray
  44405. * @param camera defines the camera to use for the picking
  44406. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  44407. * @returns the current scene
  44408. */
  44409. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  44410. /**
  44411. * Creates a ray that can be used to pick in the scene
  44412. * @param x defines the x coordinate of the origin (on-screen)
  44413. * @param y defines the y coordinate of the origin (on-screen)
  44414. * @param camera defines the camera to use for the picking
  44415. * @returns a Ray
  44416. */
  44417. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  44418. /**
  44419. * Creates a ray that can be used to pick in the scene
  44420. * @param x defines the x coordinate of the origin (on-screen)
  44421. * @param y defines the y coordinate of the origin (on-screen)
  44422. * @param result defines the ray where to store the picking ray
  44423. * @param camera defines the camera to use for the picking
  44424. * @returns the current scene
  44425. */
  44426. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  44427. /** Launch a ray to try to pick a mesh in the scene
  44428. * @param x position on screen
  44429. * @param y position on screen
  44430. * @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
  44431. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44432. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44433. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44434. * @returns a PickingInfo
  44435. */
  44436. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  44437. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  44438. * @param x position on screen
  44439. * @param y position on screen
  44440. * @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
  44441. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44442. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44443. * @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)
  44444. */
  44445. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  44446. /** Use the given ray to pick a mesh in the scene
  44447. * @param ray The ray to use to pick meshes
  44448. * @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
  44449. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44450. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44451. * @returns a PickingInfo
  44452. */
  44453. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  44454. /**
  44455. * Launch a ray to try to pick a mesh in the scene
  44456. * @param x X position on screen
  44457. * @param y Y position on screen
  44458. * @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
  44459. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44460. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44461. * @returns an array of PickingInfo
  44462. */
  44463. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  44464. /**
  44465. * Launch a ray to try to pick a mesh in the scene
  44466. * @param ray Ray to use
  44467. * @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
  44468. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44469. * @returns an array of PickingInfo
  44470. */
  44471. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  44472. /**
  44473. * Force the value of meshUnderPointer
  44474. * @param mesh defines the mesh to use
  44475. * @param pointerId optional pointer id when using more than one pointer
  44476. */
  44477. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  44478. /**
  44479. * Gets the mesh under the pointer
  44480. * @returns a Mesh or null if no mesh is under the pointer
  44481. */
  44482. getPointerOverMesh(): Nullable<AbstractMesh>;
  44483. /** @hidden */
  44484. _rebuildGeometries(): void;
  44485. /** @hidden */
  44486. _rebuildTextures(): void;
  44487. private _getByTags;
  44488. /**
  44489. * Get a list of meshes by tags
  44490. * @param tagsQuery defines the tags query to use
  44491. * @param forEach defines a predicate used to filter results
  44492. * @returns an array of Mesh
  44493. */
  44494. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  44495. /**
  44496. * Get a list of cameras by tags
  44497. * @param tagsQuery defines the tags query to use
  44498. * @param forEach defines a predicate used to filter results
  44499. * @returns an array of Camera
  44500. */
  44501. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  44502. /**
  44503. * Get a list of lights by tags
  44504. * @param tagsQuery defines the tags query to use
  44505. * @param forEach defines a predicate used to filter results
  44506. * @returns an array of Light
  44507. */
  44508. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  44509. /**
  44510. * Get a list of materials by tags
  44511. * @param tagsQuery defines the tags query to use
  44512. * @param forEach defines a predicate used to filter results
  44513. * @returns an array of Material
  44514. */
  44515. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  44516. /**
  44517. * Get a list of transform nodes by tags
  44518. * @param tagsQuery defines the tags query to use
  44519. * @param forEach defines a predicate used to filter results
  44520. * @returns an array of TransformNode
  44521. */
  44522. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  44523. /**
  44524. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  44525. * This allowed control for front to back rendering or reversly depending of the special needs.
  44526. *
  44527. * @param renderingGroupId The rendering group id corresponding to its index
  44528. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  44529. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  44530. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  44531. */
  44532. 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;
  44533. /**
  44534. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  44535. *
  44536. * @param renderingGroupId The rendering group id corresponding to its index
  44537. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  44538. * @param depth Automatically clears depth between groups if true and autoClear is true.
  44539. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  44540. */
  44541. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  44542. /**
  44543. * Gets the current auto clear configuration for one rendering group of the rendering
  44544. * manager.
  44545. * @param index the rendering group index to get the information for
  44546. * @returns The auto clear setup for the requested rendering group
  44547. */
  44548. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  44549. private _blockMaterialDirtyMechanism;
  44550. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  44551. get blockMaterialDirtyMechanism(): boolean;
  44552. set blockMaterialDirtyMechanism(value: boolean);
  44553. /**
  44554. * Will flag all materials as dirty to trigger new shader compilation
  44555. * @param flag defines the flag used to specify which material part must be marked as dirty
  44556. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  44557. */
  44558. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  44559. /** @hidden */
  44560. _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;
  44561. /** @hidden */
  44562. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44563. /** @hidden */
  44564. _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;
  44565. /** @hidden */
  44566. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  44567. /** @hidden */
  44568. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  44569. /** @hidden */
  44570. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44571. }
  44572. }
  44573. declare module BABYLON {
  44574. /**
  44575. * Set of assets to keep when moving a scene into an asset container.
  44576. */
  44577. export class KeepAssets extends AbstractScene {
  44578. }
  44579. /**
  44580. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  44581. */
  44582. export class InstantiatedEntries {
  44583. /**
  44584. * List of new root nodes (eg. nodes with no parent)
  44585. */
  44586. rootNodes: TransformNode[];
  44587. /**
  44588. * List of new skeletons
  44589. */
  44590. skeletons: Skeleton[];
  44591. /**
  44592. * List of new animation groups
  44593. */
  44594. animationGroups: AnimationGroup[];
  44595. }
  44596. /**
  44597. * Container with a set of assets that can be added or removed from a scene.
  44598. */
  44599. export class AssetContainer extends AbstractScene {
  44600. private _wasAddedToScene;
  44601. /**
  44602. * The scene the AssetContainer belongs to.
  44603. */
  44604. scene: Scene;
  44605. /**
  44606. * Instantiates an AssetContainer.
  44607. * @param scene The scene the AssetContainer belongs to.
  44608. */
  44609. constructor(scene: Scene);
  44610. /**
  44611. * Instantiate or clone all meshes and add the new ones to the scene.
  44612. * Skeletons and animation groups will all be cloned
  44613. * @param nameFunction defines an optional function used to get new names for clones
  44614. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  44615. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  44616. */
  44617. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  44618. /**
  44619. * Adds all the assets from the container to the scene.
  44620. */
  44621. addAllToScene(): void;
  44622. /**
  44623. * Removes all the assets in the container from the scene
  44624. */
  44625. removeAllFromScene(): void;
  44626. /**
  44627. * Disposes all the assets in the container
  44628. */
  44629. dispose(): void;
  44630. private _moveAssets;
  44631. /**
  44632. * Removes all the assets contained in the scene and adds them to the container.
  44633. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  44634. */
  44635. moveAllFromScene(keepAssets?: KeepAssets): void;
  44636. /**
  44637. * 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.
  44638. * @returns the root mesh
  44639. */
  44640. createRootMesh(): Mesh;
  44641. /**
  44642. * Merge animations (direct and animation groups) from this asset container into a scene
  44643. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44644. * @param animatables set of animatables to retarget to a node from the scene
  44645. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  44646. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  44647. */
  44648. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  44649. }
  44650. }
  44651. declare module BABYLON {
  44652. /**
  44653. * Defines how the parser contract is defined.
  44654. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  44655. */
  44656. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  44657. /**
  44658. * Defines how the individual parser contract is defined.
  44659. * These parser can parse an individual asset
  44660. */
  44661. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  44662. /**
  44663. * Base class of the scene acting as a container for the different elements composing a scene.
  44664. * This class is dynamically extended by the different components of the scene increasing
  44665. * flexibility and reducing coupling
  44666. */
  44667. export abstract class AbstractScene {
  44668. /**
  44669. * Stores the list of available parsers in the application.
  44670. */
  44671. private static _BabylonFileParsers;
  44672. /**
  44673. * Stores the list of available individual parsers in the application.
  44674. */
  44675. private static _IndividualBabylonFileParsers;
  44676. /**
  44677. * Adds a parser in the list of available ones
  44678. * @param name Defines the name of the parser
  44679. * @param parser Defines the parser to add
  44680. */
  44681. static AddParser(name: string, parser: BabylonFileParser): void;
  44682. /**
  44683. * Gets a general parser from the list of avaialble ones
  44684. * @param name Defines the name of the parser
  44685. * @returns the requested parser or null
  44686. */
  44687. static GetParser(name: string): Nullable<BabylonFileParser>;
  44688. /**
  44689. * Adds n individual parser in the list of available ones
  44690. * @param name Defines the name of the parser
  44691. * @param parser Defines the parser to add
  44692. */
  44693. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  44694. /**
  44695. * Gets an individual parser from the list of avaialble ones
  44696. * @param name Defines the name of the parser
  44697. * @returns the requested parser or null
  44698. */
  44699. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  44700. /**
  44701. * Parser json data and populate both a scene and its associated container object
  44702. * @param jsonData Defines the data to parse
  44703. * @param scene Defines the scene to parse the data for
  44704. * @param container Defines the container attached to the parsing sequence
  44705. * @param rootUrl Defines the root url of the data
  44706. */
  44707. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  44708. /**
  44709. * Gets the list of root nodes (ie. nodes with no parent)
  44710. */
  44711. rootNodes: Node[];
  44712. /** All of the cameras added to this scene
  44713. * @see https://doc.babylonjs.com/babylon101/cameras
  44714. */
  44715. cameras: Camera[];
  44716. /**
  44717. * All of the lights added to this scene
  44718. * @see https://doc.babylonjs.com/babylon101/lights
  44719. */
  44720. lights: Light[];
  44721. /**
  44722. * All of the (abstract) meshes added to this scene
  44723. */
  44724. meshes: AbstractMesh[];
  44725. /**
  44726. * The list of skeletons added to the scene
  44727. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  44728. */
  44729. skeletons: Skeleton[];
  44730. /**
  44731. * All of the particle systems added to this scene
  44732. * @see https://doc.babylonjs.com/babylon101/particles
  44733. */
  44734. particleSystems: IParticleSystem[];
  44735. /**
  44736. * Gets a list of Animations associated with the scene
  44737. */
  44738. animations: Animation[];
  44739. /**
  44740. * All of the animation groups added to this scene
  44741. * @see https://doc.babylonjs.com/how_to/group
  44742. */
  44743. animationGroups: AnimationGroup[];
  44744. /**
  44745. * All of the multi-materials added to this scene
  44746. * @see https://doc.babylonjs.com/how_to/multi_materials
  44747. */
  44748. multiMaterials: MultiMaterial[];
  44749. /**
  44750. * All of the materials added to this scene
  44751. * In the context of a Scene, it is not supposed to be modified manually.
  44752. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  44753. * Note also that the order of the Material within the array is not significant and might change.
  44754. * @see https://doc.babylonjs.com/babylon101/materials
  44755. */
  44756. materials: Material[];
  44757. /**
  44758. * The list of morph target managers added to the scene
  44759. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  44760. */
  44761. morphTargetManagers: MorphTargetManager[];
  44762. /**
  44763. * The list of geometries used in the scene.
  44764. */
  44765. geometries: Geometry[];
  44766. /**
  44767. * All of the tranform nodes added to this scene
  44768. * In the context of a Scene, it is not supposed to be modified manually.
  44769. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  44770. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  44771. * @see https://doc.babylonjs.com/how_to/transformnode
  44772. */
  44773. transformNodes: TransformNode[];
  44774. /**
  44775. * ActionManagers available on the scene.
  44776. */
  44777. actionManagers: AbstractActionManager[];
  44778. /**
  44779. * Textures to keep.
  44780. */
  44781. textures: BaseTexture[];
  44782. /** @hidden */
  44783. protected _environmentTexture: Nullable<BaseTexture>;
  44784. /**
  44785. * Texture used in all pbr material as the reflection texture.
  44786. * As in the majority of the scene they are the same (exception for multi room and so on),
  44787. * this is easier to reference from here than from all the materials.
  44788. */
  44789. get environmentTexture(): Nullable<BaseTexture>;
  44790. set environmentTexture(value: Nullable<BaseTexture>);
  44791. /**
  44792. * The list of postprocesses added to the scene
  44793. */
  44794. postProcesses: PostProcess[];
  44795. /**
  44796. * @returns all meshes, lights, cameras, transformNodes and bones
  44797. */
  44798. getNodes(): Array<Node>;
  44799. }
  44800. }
  44801. declare module BABYLON {
  44802. /**
  44803. * Interface used to define options for Sound class
  44804. */
  44805. export interface ISoundOptions {
  44806. /**
  44807. * Does the sound autoplay once loaded.
  44808. */
  44809. autoplay?: boolean;
  44810. /**
  44811. * Does the sound loop after it finishes playing once.
  44812. */
  44813. loop?: boolean;
  44814. /**
  44815. * Sound's volume
  44816. */
  44817. volume?: number;
  44818. /**
  44819. * Is it a spatial sound?
  44820. */
  44821. spatialSound?: boolean;
  44822. /**
  44823. * Maximum distance to hear that sound
  44824. */
  44825. maxDistance?: number;
  44826. /**
  44827. * Uses user defined attenuation function
  44828. */
  44829. useCustomAttenuation?: boolean;
  44830. /**
  44831. * Define the roll off factor of spatial sounds.
  44832. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44833. */
  44834. rolloffFactor?: number;
  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 distance attenuation model the sound will follow.
  44842. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44843. */
  44844. distanceModel?: string;
  44845. /**
  44846. * Defines the playback speed (1 by default)
  44847. */
  44848. playbackRate?: number;
  44849. /**
  44850. * Defines if the sound is from a streaming source
  44851. */
  44852. streaming?: boolean;
  44853. /**
  44854. * Defines an optional length (in seconds) inside the sound file
  44855. */
  44856. length?: number;
  44857. /**
  44858. * Defines an optional offset (in seconds) inside the sound file
  44859. */
  44860. offset?: number;
  44861. /**
  44862. * If true, URLs will not be required to state the audio file codec to use.
  44863. */
  44864. skipCodecCheck?: boolean;
  44865. }
  44866. /**
  44867. * Defines a sound that can be played in the application.
  44868. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  44869. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  44870. */
  44871. export class Sound {
  44872. /**
  44873. * The name of the sound in the scene.
  44874. */
  44875. name: string;
  44876. /**
  44877. * Does the sound autoplay once loaded.
  44878. */
  44879. autoplay: boolean;
  44880. /**
  44881. * Does the sound loop after it finishes playing once.
  44882. */
  44883. loop: boolean;
  44884. /**
  44885. * Does the sound use a custom attenuation curve to simulate the falloff
  44886. * happening when the source gets further away from the camera.
  44887. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  44888. */
  44889. useCustomAttenuation: boolean;
  44890. /**
  44891. * The sound track id this sound belongs to.
  44892. */
  44893. soundTrackId: number;
  44894. /**
  44895. * Is this sound currently played.
  44896. */
  44897. isPlaying: boolean;
  44898. /**
  44899. * Is this sound currently paused.
  44900. */
  44901. isPaused: boolean;
  44902. /**
  44903. * Does this sound enables spatial sound.
  44904. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44905. */
  44906. spatialSound: boolean;
  44907. /**
  44908. * Define the reference distance the sound should be heard perfectly.
  44909. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44910. */
  44911. refDistance: number;
  44912. /**
  44913. * Define the roll off factor of spatial sounds.
  44914. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44915. */
  44916. rolloffFactor: number;
  44917. /**
  44918. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  44919. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44920. */
  44921. maxDistance: number;
  44922. /**
  44923. * Define the distance attenuation model the sound will follow.
  44924. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44925. */
  44926. distanceModel: string;
  44927. /**
  44928. * @hidden
  44929. * Back Compat
  44930. **/
  44931. onended: () => any;
  44932. /**
  44933. * Gets or sets an object used to store user defined information for the sound.
  44934. */
  44935. metadata: any;
  44936. /**
  44937. * Observable event when the current playing sound finishes.
  44938. */
  44939. onEndedObservable: Observable<Sound>;
  44940. /**
  44941. * Gets the current time for the sound.
  44942. */
  44943. get currentTime(): number;
  44944. private _panningModel;
  44945. private _playbackRate;
  44946. private _streaming;
  44947. private _startTime;
  44948. private _startOffset;
  44949. private _position;
  44950. /** @hidden */
  44951. _positionInEmitterSpace: boolean;
  44952. private _localDirection;
  44953. private _volume;
  44954. private _isReadyToPlay;
  44955. private _isDirectional;
  44956. private _readyToPlayCallback;
  44957. private _audioBuffer;
  44958. private _soundSource;
  44959. private _streamingSource;
  44960. private _soundPanner;
  44961. private _soundGain;
  44962. private _inputAudioNode;
  44963. private _outputAudioNode;
  44964. private _coneInnerAngle;
  44965. private _coneOuterAngle;
  44966. private _coneOuterGain;
  44967. private _scene;
  44968. private _connectedTransformNode;
  44969. private _customAttenuationFunction;
  44970. private _registerFunc;
  44971. private _isOutputConnected;
  44972. private _htmlAudioElement;
  44973. private _urlType;
  44974. private _length?;
  44975. private _offset?;
  44976. /** @hidden */
  44977. static _SceneComponentInitialization: (scene: Scene) => void;
  44978. /**
  44979. * Create a sound and attach it to a scene
  44980. * @param name Name of your sound
  44981. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  44982. * @param scene defines the scene the sound belongs to
  44983. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  44984. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  44985. */
  44986. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  44987. /**
  44988. * Release the sound and its associated resources
  44989. */
  44990. dispose(): void;
  44991. /**
  44992. * Gets if the sounds is ready to be played or not.
  44993. * @returns true if ready, otherwise false
  44994. */
  44995. isReady(): boolean;
  44996. private _soundLoaded;
  44997. /**
  44998. * Sets the data of the sound from an audiobuffer
  44999. * @param audioBuffer The audioBuffer containing the data
  45000. */
  45001. setAudioBuffer(audioBuffer: AudioBuffer): void;
  45002. /**
  45003. * Updates the current sounds options such as maxdistance, loop...
  45004. * @param options A JSON object containing values named as the object properties
  45005. */
  45006. updateOptions(options: ISoundOptions): void;
  45007. private _createSpatialParameters;
  45008. private _updateSpatialParameters;
  45009. /**
  45010. * Switch the panning model to HRTF:
  45011. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  45012. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45013. */
  45014. switchPanningModelToHRTF(): void;
  45015. /**
  45016. * Switch the panning model to Equal Power:
  45017. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  45018. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45019. */
  45020. switchPanningModelToEqualPower(): void;
  45021. private _switchPanningModel;
  45022. /**
  45023. * Connect this sound to a sound track audio node like gain...
  45024. * @param soundTrackAudioNode the sound track audio node to connect to
  45025. */
  45026. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  45027. /**
  45028. * Transform this sound into a directional source
  45029. * @param coneInnerAngle Size of the inner cone in degree
  45030. * @param coneOuterAngle Size of the outer cone in degree
  45031. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  45032. */
  45033. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  45034. /**
  45035. * Gets or sets the inner angle for the directional cone.
  45036. */
  45037. get directionalConeInnerAngle(): number;
  45038. /**
  45039. * Gets or sets the inner angle for the directional cone.
  45040. */
  45041. set directionalConeInnerAngle(value: number);
  45042. /**
  45043. * Gets or sets the outer angle for the directional cone.
  45044. */
  45045. get directionalConeOuterAngle(): number;
  45046. /**
  45047. * Gets or sets the outer angle for the directional cone.
  45048. */
  45049. set directionalConeOuterAngle(value: number);
  45050. /**
  45051. * Sets the position of the emitter if spatial sound is enabled
  45052. * @param newPosition Defines the new posisiton
  45053. */
  45054. setPosition(newPosition: Vector3): void;
  45055. /**
  45056. * Sets the local direction of the emitter if spatial sound is enabled
  45057. * @param newLocalDirection Defines the new local direction
  45058. */
  45059. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  45060. private _updateDirection;
  45061. /** @hidden */
  45062. updateDistanceFromListener(): void;
  45063. /**
  45064. * Sets a new custom attenuation function for the sound.
  45065. * @param callback Defines the function used for the attenuation
  45066. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  45067. */
  45068. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  45069. /**
  45070. * Play the sound
  45071. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  45072. * @param offset (optional) Start the sound at a specific time in seconds
  45073. * @param length (optional) Sound duration (in seconds)
  45074. */
  45075. play(time?: number, offset?: number, length?: number): void;
  45076. private _onended;
  45077. /**
  45078. * Stop the sound
  45079. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  45080. */
  45081. stop(time?: number): void;
  45082. /**
  45083. * Put the sound in pause
  45084. */
  45085. pause(): void;
  45086. /**
  45087. * Sets a dedicated volume for this sounds
  45088. * @param newVolume Define the new volume of the sound
  45089. * @param time Define time for gradual change to new volume
  45090. */
  45091. setVolume(newVolume: number, time?: number): void;
  45092. /**
  45093. * Set the sound play back rate
  45094. * @param newPlaybackRate Define the playback rate the sound should be played at
  45095. */
  45096. setPlaybackRate(newPlaybackRate: number): void;
  45097. /**
  45098. * Gets the volume of the sound.
  45099. * @returns the volume of the sound
  45100. */
  45101. getVolume(): number;
  45102. /**
  45103. * Attach the sound to a dedicated mesh
  45104. * @param transformNode The transform node to connect the sound with
  45105. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  45106. */
  45107. attachToMesh(transformNode: TransformNode): void;
  45108. /**
  45109. * Detach the sound from the previously attached mesh
  45110. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  45111. */
  45112. detachFromMesh(): void;
  45113. private _onRegisterAfterWorldMatrixUpdate;
  45114. /**
  45115. * Clone the current sound in the scene.
  45116. * @returns the new sound clone
  45117. */
  45118. clone(): Nullable<Sound>;
  45119. /**
  45120. * Gets the current underlying audio buffer containing the data
  45121. * @returns the audio buffer
  45122. */
  45123. getAudioBuffer(): Nullable<AudioBuffer>;
  45124. /**
  45125. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  45126. * @returns the source node
  45127. */
  45128. getSoundSource(): Nullable<AudioBufferSourceNode>;
  45129. /**
  45130. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  45131. * @returns the gain node
  45132. */
  45133. getSoundGain(): Nullable<GainNode>;
  45134. /**
  45135. * Serializes the Sound in a JSON representation
  45136. * @returns the JSON representation of the sound
  45137. */
  45138. serialize(): any;
  45139. /**
  45140. * Parse a JSON representation of a sound to innstantiate in a given scene
  45141. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  45142. * @param scene Define the scene the new parsed sound should be created in
  45143. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  45144. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  45145. * @returns the newly parsed sound
  45146. */
  45147. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  45148. }
  45149. }
  45150. declare module BABYLON {
  45151. /**
  45152. * This defines an action helpful to play a defined sound on a triggered action.
  45153. */
  45154. export class PlaySoundAction extends Action {
  45155. private _sound;
  45156. /**
  45157. * Instantiate the action
  45158. * @param triggerOptions defines the trigger options
  45159. * @param sound defines the sound to play
  45160. * @param condition defines the trigger related conditions
  45161. */
  45162. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  45163. /** @hidden */
  45164. _prepare(): void;
  45165. /**
  45166. * Execute the action and play the sound.
  45167. */
  45168. execute(): void;
  45169. /**
  45170. * Serializes the actions and its related information.
  45171. * @param parent defines the object to serialize in
  45172. * @returns the serialized object
  45173. */
  45174. serialize(parent: any): any;
  45175. }
  45176. /**
  45177. * This defines an action helpful to stop a defined sound on a triggered action.
  45178. */
  45179. export class StopSoundAction extends Action {
  45180. private _sound;
  45181. /**
  45182. * Instantiate the action
  45183. * @param triggerOptions defines the trigger options
  45184. * @param sound defines the sound to stop
  45185. * @param condition defines the trigger related conditions
  45186. */
  45187. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  45188. /** @hidden */
  45189. _prepare(): void;
  45190. /**
  45191. * Execute the action and stop the sound.
  45192. */
  45193. execute(): void;
  45194. /**
  45195. * Serializes the actions and its related information.
  45196. * @param parent defines the object to serialize in
  45197. * @returns the serialized object
  45198. */
  45199. serialize(parent: any): any;
  45200. }
  45201. }
  45202. declare module BABYLON {
  45203. /**
  45204. * This defines an action responsible to change the value of a property
  45205. * by interpolating between its current value and the newly set one once triggered.
  45206. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  45207. */
  45208. export class InterpolateValueAction extends Action {
  45209. /**
  45210. * Defines the path of the property where the value should be interpolated
  45211. */
  45212. propertyPath: string;
  45213. /**
  45214. * Defines the target value at the end of the interpolation.
  45215. */
  45216. value: any;
  45217. /**
  45218. * Defines the time it will take for the property to interpolate to the value.
  45219. */
  45220. duration: number;
  45221. /**
  45222. * Defines if the other scene animations should be stopped when the action has been triggered
  45223. */
  45224. stopOtherAnimations?: boolean;
  45225. /**
  45226. * Defines a callback raised once the interpolation animation has been done.
  45227. */
  45228. onInterpolationDone?: () => void;
  45229. /**
  45230. * Observable triggered once the interpolation animation has been done.
  45231. */
  45232. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  45233. private _target;
  45234. private _effectiveTarget;
  45235. private _property;
  45236. /**
  45237. * Instantiate the action
  45238. * @param triggerOptions defines the trigger options
  45239. * @param target defines the object containing the value to interpolate
  45240. * @param propertyPath defines the path to the property in the target object
  45241. * @param value defines the target value at the end of the interpolation
  45242. * @param duration deines the time it will take for the property to interpolate to the value.
  45243. * @param condition defines the trigger related conditions
  45244. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  45245. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  45246. */
  45247. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  45248. /** @hidden */
  45249. _prepare(): void;
  45250. /**
  45251. * Execute the action starts the value interpolation.
  45252. */
  45253. execute(): void;
  45254. /**
  45255. * Serializes the actions and its related information.
  45256. * @param parent defines the object to serialize in
  45257. * @returns the serialized object
  45258. */
  45259. serialize(parent: any): any;
  45260. }
  45261. }
  45262. declare module BABYLON {
  45263. /**
  45264. * Options allowed during the creation of a sound track.
  45265. */
  45266. export interface ISoundTrackOptions {
  45267. /**
  45268. * The volume the sound track should take during creation
  45269. */
  45270. volume?: number;
  45271. /**
  45272. * Define if the sound track is the main sound track of the scene
  45273. */
  45274. mainTrack?: boolean;
  45275. }
  45276. /**
  45277. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  45278. * It will be also used in a future release to apply effects on a specific track.
  45279. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  45280. */
  45281. export class SoundTrack {
  45282. /**
  45283. * The unique identifier of the sound track in the scene.
  45284. */
  45285. id: number;
  45286. /**
  45287. * The list of sounds included in the sound track.
  45288. */
  45289. soundCollection: Array<Sound>;
  45290. private _outputAudioNode;
  45291. private _scene;
  45292. private _connectedAnalyser;
  45293. private _options;
  45294. private _isInitialized;
  45295. /**
  45296. * Creates a new sound track.
  45297. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  45298. * @param scene Define the scene the sound track belongs to
  45299. * @param options
  45300. */
  45301. constructor(scene: Scene, options?: ISoundTrackOptions);
  45302. private _initializeSoundTrackAudioGraph;
  45303. /**
  45304. * Release the sound track and its associated resources
  45305. */
  45306. dispose(): void;
  45307. /**
  45308. * Adds a sound to this sound track
  45309. * @param sound define the cound to add
  45310. * @ignoreNaming
  45311. */
  45312. AddSound(sound: Sound): void;
  45313. /**
  45314. * Removes a sound to this sound track
  45315. * @param sound define the cound to remove
  45316. * @ignoreNaming
  45317. */
  45318. RemoveSound(sound: Sound): void;
  45319. /**
  45320. * Set a global volume for the full sound track.
  45321. * @param newVolume Define the new volume of the sound track
  45322. */
  45323. setVolume(newVolume: number): void;
  45324. /**
  45325. * Switch the panning model to HRTF:
  45326. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  45327. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45328. */
  45329. switchPanningModelToHRTF(): void;
  45330. /**
  45331. * Switch the panning model to Equal Power:
  45332. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  45333. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45334. */
  45335. switchPanningModelToEqualPower(): void;
  45336. /**
  45337. * Connect the sound track to an audio analyser allowing some amazing
  45338. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  45339. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  45340. * @param analyser The analyser to connect to the engine
  45341. */
  45342. connectToAnalyser(analyser: Analyser): void;
  45343. }
  45344. }
  45345. declare module BABYLON {
  45346. interface AbstractScene {
  45347. /**
  45348. * The list of sounds used in the scene.
  45349. */
  45350. sounds: Nullable<Array<Sound>>;
  45351. }
  45352. interface Scene {
  45353. /**
  45354. * @hidden
  45355. * Backing field
  45356. */
  45357. _mainSoundTrack: SoundTrack;
  45358. /**
  45359. * The main sound track played by the scene.
  45360. * It cotains your primary collection of sounds.
  45361. */
  45362. mainSoundTrack: SoundTrack;
  45363. /**
  45364. * The list of sound tracks added to the scene
  45365. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45366. */
  45367. soundTracks: Nullable<Array<SoundTrack>>;
  45368. /**
  45369. * Gets a sound using a given name
  45370. * @param name defines the name to search for
  45371. * @return the found sound or null if not found at all.
  45372. */
  45373. getSoundByName(name: string): Nullable<Sound>;
  45374. /**
  45375. * Gets or sets if audio support is enabled
  45376. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45377. */
  45378. audioEnabled: boolean;
  45379. /**
  45380. * Gets or sets if audio will be output to headphones
  45381. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45382. */
  45383. headphone: boolean;
  45384. /**
  45385. * Gets or sets custom audio listener position provider
  45386. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45387. */
  45388. audioListenerPositionProvider: Nullable<() => Vector3>;
  45389. /**
  45390. * Gets or sets a refresh rate when using 3D audio positioning
  45391. */
  45392. audioPositioningRefreshRate: number;
  45393. }
  45394. /**
  45395. * Defines the sound scene component responsible to manage any sounds
  45396. * in a given scene.
  45397. */
  45398. export class AudioSceneComponent implements ISceneSerializableComponent {
  45399. private static _CameraDirectionLH;
  45400. private static _CameraDirectionRH;
  45401. /**
  45402. * The component name helpfull to identify the component in the list of scene components.
  45403. */
  45404. readonly name: string;
  45405. /**
  45406. * The scene the component belongs to.
  45407. */
  45408. scene: Scene;
  45409. private _audioEnabled;
  45410. /**
  45411. * Gets whether audio is enabled or not.
  45412. * Please use related enable/disable method to switch state.
  45413. */
  45414. get audioEnabled(): boolean;
  45415. private _headphone;
  45416. /**
  45417. * Gets whether audio is outputing to headphone or not.
  45418. * Please use the according Switch methods to change output.
  45419. */
  45420. get headphone(): boolean;
  45421. /**
  45422. * Gets or sets a refresh rate when using 3D audio positioning
  45423. */
  45424. audioPositioningRefreshRate: number;
  45425. private _audioListenerPositionProvider;
  45426. /**
  45427. * Gets the current audio listener position provider
  45428. */
  45429. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  45430. /**
  45431. * Sets a custom listener position for all sounds in the scene
  45432. * By default, this is the position of the first active camera
  45433. */
  45434. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  45435. /**
  45436. * Creates a new instance of the component for the given scene
  45437. * @param scene Defines the scene to register the component in
  45438. */
  45439. constructor(scene: Scene);
  45440. /**
  45441. * Registers the component in a given scene
  45442. */
  45443. register(): void;
  45444. /**
  45445. * Rebuilds the elements related to this component in case of
  45446. * context lost for instance.
  45447. */
  45448. rebuild(): void;
  45449. /**
  45450. * Serializes the component data to the specified json object
  45451. * @param serializationObject The object to serialize to
  45452. */
  45453. serialize(serializationObject: any): void;
  45454. /**
  45455. * Adds all the elements from the container to the scene
  45456. * @param container the container holding the elements
  45457. */
  45458. addFromContainer(container: AbstractScene): void;
  45459. /**
  45460. * Removes all the elements in the container from the scene
  45461. * @param container contains the elements to remove
  45462. * @param dispose if the removed element should be disposed (default: false)
  45463. */
  45464. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  45465. /**
  45466. * Disposes the component and the associated ressources.
  45467. */
  45468. dispose(): void;
  45469. /**
  45470. * Disables audio in the associated scene.
  45471. */
  45472. disableAudio(): void;
  45473. /**
  45474. * Enables audio in the associated scene.
  45475. */
  45476. enableAudio(): void;
  45477. /**
  45478. * Switch audio to headphone output.
  45479. */
  45480. switchAudioModeForHeadphones(): void;
  45481. /**
  45482. * Switch audio to normal speakers.
  45483. */
  45484. switchAudioModeForNormalSpeakers(): void;
  45485. private _cachedCameraDirection;
  45486. private _cachedCameraPosition;
  45487. private _lastCheck;
  45488. private _afterRender;
  45489. }
  45490. }
  45491. declare module BABYLON {
  45492. /**
  45493. * Wraps one or more Sound objects and selects one with random weight for playback.
  45494. */
  45495. export class WeightedSound {
  45496. /** When true a Sound will be selected and played when the current playing Sound completes. */
  45497. loop: boolean;
  45498. private _coneInnerAngle;
  45499. private _coneOuterAngle;
  45500. private _volume;
  45501. /** A Sound is currently playing. */
  45502. isPlaying: boolean;
  45503. /** A Sound is currently paused. */
  45504. isPaused: boolean;
  45505. private _sounds;
  45506. private _weights;
  45507. private _currentIndex?;
  45508. /**
  45509. * Creates a new WeightedSound from the list of sounds given.
  45510. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  45511. * @param sounds Array of Sounds that will be selected from.
  45512. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  45513. */
  45514. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  45515. /**
  45516. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  45517. */
  45518. get directionalConeInnerAngle(): number;
  45519. /**
  45520. * The size of cone in degress for a directional sound in which there will be no attenuation.
  45521. */
  45522. set directionalConeInnerAngle(value: number);
  45523. /**
  45524. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  45525. * Listener angles between innerAngle and outerAngle will falloff linearly.
  45526. */
  45527. get directionalConeOuterAngle(): number;
  45528. /**
  45529. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  45530. * Listener angles between innerAngle and outerAngle will falloff linearly.
  45531. */
  45532. set directionalConeOuterAngle(value: number);
  45533. /**
  45534. * Playback volume.
  45535. */
  45536. get volume(): number;
  45537. /**
  45538. * Playback volume.
  45539. */
  45540. set volume(value: number);
  45541. private _onended;
  45542. /**
  45543. * Suspend playback
  45544. */
  45545. pause(): void;
  45546. /**
  45547. * Stop playback
  45548. */
  45549. stop(): void;
  45550. /**
  45551. * Start playback.
  45552. * @param startOffset Position the clip head at a specific time in seconds.
  45553. */
  45554. play(startOffset?: number): void;
  45555. }
  45556. }
  45557. declare module BABYLON {
  45558. /**
  45559. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  45560. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  45561. */
  45562. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  45563. /**
  45564. * Gets the name of the behavior.
  45565. */
  45566. get name(): string;
  45567. /**
  45568. * The easing function used by animations
  45569. */
  45570. static EasingFunction: BackEase;
  45571. /**
  45572. * The easing mode used by animations
  45573. */
  45574. static EasingMode: number;
  45575. /**
  45576. * The duration of the animation, in milliseconds
  45577. */
  45578. transitionDuration: number;
  45579. /**
  45580. * Length of the distance animated by the transition when lower radius is reached
  45581. */
  45582. lowerRadiusTransitionRange: number;
  45583. /**
  45584. * Length of the distance animated by the transition when upper radius is reached
  45585. */
  45586. upperRadiusTransitionRange: number;
  45587. private _autoTransitionRange;
  45588. /**
  45589. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  45590. */
  45591. get autoTransitionRange(): boolean;
  45592. /**
  45593. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  45594. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  45595. */
  45596. set autoTransitionRange(value: boolean);
  45597. private _attachedCamera;
  45598. private _onAfterCheckInputsObserver;
  45599. private _onMeshTargetChangedObserver;
  45600. /**
  45601. * Initializes the behavior.
  45602. */
  45603. init(): void;
  45604. /**
  45605. * Attaches the behavior to its arc rotate camera.
  45606. * @param camera Defines the camera to attach the behavior to
  45607. */
  45608. attach(camera: ArcRotateCamera): void;
  45609. /**
  45610. * Detaches the behavior from its current arc rotate camera.
  45611. */
  45612. detach(): void;
  45613. private _radiusIsAnimating;
  45614. private _radiusBounceTransition;
  45615. private _animatables;
  45616. private _cachedWheelPrecision;
  45617. /**
  45618. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  45619. * @param radiusLimit The limit to check against.
  45620. * @return Bool to indicate if at limit.
  45621. */
  45622. private _isRadiusAtLimit;
  45623. /**
  45624. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  45625. * @param radiusDelta The delta by which to animate to. Can be negative.
  45626. */
  45627. private _applyBoundRadiusAnimation;
  45628. /**
  45629. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  45630. */
  45631. protected _clearAnimationLocks(): void;
  45632. /**
  45633. * Stops and removes all animations that have been applied to the camera
  45634. */
  45635. stopAllAnimations(): void;
  45636. }
  45637. }
  45638. declare module BABYLON {
  45639. /**
  45640. * 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.
  45641. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  45642. */
  45643. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  45644. /**
  45645. * Gets the name of the behavior.
  45646. */
  45647. get name(): string;
  45648. private _mode;
  45649. private _radiusScale;
  45650. private _positionScale;
  45651. private _defaultElevation;
  45652. private _elevationReturnTime;
  45653. private _elevationReturnWaitTime;
  45654. private _zoomStopsAnimation;
  45655. private _framingTime;
  45656. /**
  45657. * The easing function used by animations
  45658. */
  45659. static EasingFunction: ExponentialEase;
  45660. /**
  45661. * The easing mode used by animations
  45662. */
  45663. static EasingMode: number;
  45664. /**
  45665. * Sets the current mode used by the behavior
  45666. */
  45667. set mode(mode: number);
  45668. /**
  45669. * Gets current mode used by the behavior.
  45670. */
  45671. get mode(): number;
  45672. /**
  45673. * Sets the scale applied to the radius (1 by default)
  45674. */
  45675. set radiusScale(radius: number);
  45676. /**
  45677. * Gets the scale applied to the radius
  45678. */
  45679. get radiusScale(): number;
  45680. /**
  45681. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  45682. */
  45683. set positionScale(scale: number);
  45684. /**
  45685. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  45686. */
  45687. get positionScale(): number;
  45688. /**
  45689. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  45690. * behaviour is triggered, in radians.
  45691. */
  45692. set defaultElevation(elevation: number);
  45693. /**
  45694. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  45695. * behaviour is triggered, in radians.
  45696. */
  45697. get defaultElevation(): number;
  45698. /**
  45699. * Sets the time (in milliseconds) taken to return to the default beta position.
  45700. * Negative value indicates camera should not return to default.
  45701. */
  45702. set elevationReturnTime(speed: number);
  45703. /**
  45704. * Gets the time (in milliseconds) taken to return to the default beta position.
  45705. * Negative value indicates camera should not return to default.
  45706. */
  45707. get elevationReturnTime(): number;
  45708. /**
  45709. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  45710. */
  45711. set elevationReturnWaitTime(time: number);
  45712. /**
  45713. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  45714. */
  45715. get elevationReturnWaitTime(): number;
  45716. /**
  45717. * Sets the flag that indicates if user zooming should stop animation.
  45718. */
  45719. set zoomStopsAnimation(flag: boolean);
  45720. /**
  45721. * Gets the flag that indicates if user zooming should stop animation.
  45722. */
  45723. get zoomStopsAnimation(): boolean;
  45724. /**
  45725. * Sets the transition time when framing the mesh, in milliseconds
  45726. */
  45727. set framingTime(time: number);
  45728. /**
  45729. * Gets the transition time when framing the mesh, in milliseconds
  45730. */
  45731. get framingTime(): number;
  45732. /**
  45733. * Define if the behavior should automatically change the configured
  45734. * camera limits and sensibilities.
  45735. */
  45736. autoCorrectCameraLimitsAndSensibility: boolean;
  45737. private _onPrePointerObservableObserver;
  45738. private _onAfterCheckInputsObserver;
  45739. private _onMeshTargetChangedObserver;
  45740. private _attachedCamera;
  45741. private _isPointerDown;
  45742. private _lastInteractionTime;
  45743. /**
  45744. * Initializes the behavior.
  45745. */
  45746. init(): void;
  45747. /**
  45748. * Attaches the behavior to its arc rotate camera.
  45749. * @param camera Defines the camera to attach the behavior to
  45750. */
  45751. attach(camera: ArcRotateCamera): void;
  45752. /**
  45753. * Detaches the behavior from its current arc rotate camera.
  45754. */
  45755. detach(): void;
  45756. private _animatables;
  45757. private _betaIsAnimating;
  45758. private _betaTransition;
  45759. private _radiusTransition;
  45760. private _vectorTransition;
  45761. /**
  45762. * Targets the given mesh and updates zoom level accordingly.
  45763. * @param mesh The mesh to target.
  45764. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45765. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45766. */
  45767. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45768. /**
  45769. * Targets the given mesh with its children and updates zoom level accordingly.
  45770. * @param mesh The mesh to target.
  45771. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45772. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45773. */
  45774. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45775. /**
  45776. * Targets the given meshes with their children and updates zoom level accordingly.
  45777. * @param meshes The mesh to target.
  45778. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45779. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45780. */
  45781. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45782. /**
  45783. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  45784. * @param minimumWorld Determines the smaller position of the bounding box extend
  45785. * @param maximumWorld Determines the bigger position of the bounding box extend
  45786. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45787. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45788. */
  45789. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45790. /**
  45791. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  45792. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  45793. * frustum width.
  45794. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  45795. * to fully enclose the mesh in the viewing frustum.
  45796. */
  45797. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  45798. /**
  45799. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  45800. * is automatically returned to its default position (expected to be above ground plane).
  45801. */
  45802. private _maintainCameraAboveGround;
  45803. /**
  45804. * Returns the frustum slope based on the canvas ratio and camera FOV
  45805. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  45806. */
  45807. private _getFrustumSlope;
  45808. /**
  45809. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  45810. */
  45811. private _clearAnimationLocks;
  45812. /**
  45813. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  45814. */
  45815. private _applyUserInteraction;
  45816. /**
  45817. * Stops and removes all animations that have been applied to the camera
  45818. */
  45819. stopAllAnimations(): void;
  45820. /**
  45821. * Gets a value indicating if the user is moving the camera
  45822. */
  45823. get isUserIsMoving(): boolean;
  45824. /**
  45825. * The camera can move all the way towards the mesh.
  45826. */
  45827. static IgnoreBoundsSizeMode: number;
  45828. /**
  45829. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  45830. */
  45831. static FitFrustumSidesMode: number;
  45832. }
  45833. }
  45834. declare module BABYLON {
  45835. /**
  45836. * Base class for Camera Pointer Inputs.
  45837. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  45838. * for example usage.
  45839. */
  45840. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  45841. /**
  45842. * Defines the camera the input is attached to.
  45843. */
  45844. abstract camera: Camera;
  45845. /**
  45846. * Whether keyboard modifier keys are pressed at time of last mouse event.
  45847. */
  45848. protected _altKey: boolean;
  45849. protected _ctrlKey: boolean;
  45850. protected _metaKey: boolean;
  45851. protected _shiftKey: boolean;
  45852. /**
  45853. * Which mouse buttons were pressed at time of last mouse event.
  45854. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  45855. */
  45856. protected _buttonsPressed: number;
  45857. /**
  45858. * Defines the buttons associated with the input to handle camera move.
  45859. */
  45860. buttons: number[];
  45861. /**
  45862. * Attach the input controls to a specific dom element to get the input from.
  45863. * @param element Defines the element the controls should be listened from
  45864. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45865. */
  45866. attachControl(noPreventDefault?: boolean): void;
  45867. /**
  45868. * Detach the current controls from the specified dom element.
  45869. */
  45870. detachControl(): void;
  45871. /**
  45872. * Gets the class name of the current input.
  45873. * @returns the class name
  45874. */
  45875. getClassName(): string;
  45876. /**
  45877. * Get the friendly name associated with the input class.
  45878. * @returns the input friendly name
  45879. */
  45880. getSimpleName(): string;
  45881. /**
  45882. * Called on pointer POINTERDOUBLETAP event.
  45883. * Override this method to provide functionality on POINTERDOUBLETAP event.
  45884. */
  45885. protected onDoubleTap(type: string): void;
  45886. /**
  45887. * Called on pointer POINTERMOVE event if only a single touch is active.
  45888. * Override this method to provide functionality.
  45889. */
  45890. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  45891. /**
  45892. * Called on pointer POINTERMOVE event if multiple touches are active.
  45893. * Override this method to provide functionality.
  45894. */
  45895. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  45896. /**
  45897. * Called on JS contextmenu event.
  45898. * Override this method to provide functionality.
  45899. */
  45900. protected onContextMenu(evt: PointerEvent): void;
  45901. /**
  45902. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  45903. * press.
  45904. * Override this method to provide functionality.
  45905. */
  45906. protected onButtonDown(evt: PointerEvent): void;
  45907. /**
  45908. * Called each time a new POINTERUP event occurs. Ie, for each button
  45909. * release.
  45910. * Override this method to provide functionality.
  45911. */
  45912. protected onButtonUp(evt: PointerEvent): void;
  45913. /**
  45914. * Called when window becomes inactive.
  45915. * Override this method to provide functionality.
  45916. */
  45917. protected onLostFocus(): void;
  45918. private _pointerInput;
  45919. private _observer;
  45920. private _onLostFocus;
  45921. private pointA;
  45922. private pointB;
  45923. }
  45924. }
  45925. declare module BABYLON {
  45926. /**
  45927. * Manage the pointers inputs to control an arc rotate camera.
  45928. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45929. */
  45930. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  45931. /**
  45932. * Defines the camera the input is attached to.
  45933. */
  45934. camera: ArcRotateCamera;
  45935. /**
  45936. * Gets the class name of the current input.
  45937. * @returns the class name
  45938. */
  45939. getClassName(): string;
  45940. /**
  45941. * Defines the buttons associated with the input to handle camera move.
  45942. */
  45943. buttons: number[];
  45944. /**
  45945. * Defines the pointer angular sensibility along the X axis or how fast is
  45946. * the camera rotating.
  45947. */
  45948. angularSensibilityX: number;
  45949. /**
  45950. * Defines the pointer angular sensibility along the Y axis or how fast is
  45951. * the camera rotating.
  45952. */
  45953. angularSensibilityY: number;
  45954. /**
  45955. * Defines the pointer pinch precision or how fast is the camera zooming.
  45956. */
  45957. pinchPrecision: number;
  45958. /**
  45959. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  45960. * from 0.
  45961. * It defines the percentage of current camera.radius to use as delta when
  45962. * pinch zoom is used.
  45963. */
  45964. pinchDeltaPercentage: number;
  45965. /**
  45966. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  45967. * that any object in the plane at the camera's target point will scale
  45968. * perfectly with finger motion.
  45969. * Overrides pinchDeltaPercentage and pinchPrecision.
  45970. */
  45971. useNaturalPinchZoom: boolean;
  45972. /**
  45973. * Defines the pointer panning sensibility or how fast is the camera moving.
  45974. */
  45975. panningSensibility: number;
  45976. /**
  45977. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  45978. */
  45979. multiTouchPanning: boolean;
  45980. /**
  45981. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  45982. * zoom (pinch) through multitouch.
  45983. */
  45984. multiTouchPanAndZoom: boolean;
  45985. /**
  45986. * Revers pinch action direction.
  45987. */
  45988. pinchInwards: boolean;
  45989. private _isPanClick;
  45990. private _twoFingerActivityCount;
  45991. private _isPinching;
  45992. /**
  45993. * Called on pointer POINTERMOVE event if only a single touch is active.
  45994. */
  45995. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  45996. /**
  45997. * Called on pointer POINTERDOUBLETAP event.
  45998. */
  45999. protected onDoubleTap(type: string): void;
  46000. /**
  46001. * Called on pointer POINTERMOVE event if multiple touches are active.
  46002. */
  46003. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  46004. /**
  46005. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  46006. * press.
  46007. */
  46008. protected onButtonDown(evt: PointerEvent): void;
  46009. /**
  46010. * Called each time a new POINTERUP event occurs. Ie, for each button
  46011. * release.
  46012. */
  46013. protected onButtonUp(evt: PointerEvent): void;
  46014. /**
  46015. * Called when window becomes inactive.
  46016. */
  46017. protected onLostFocus(): void;
  46018. }
  46019. }
  46020. declare module BABYLON {
  46021. /**
  46022. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  46023. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46024. */
  46025. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  46026. /**
  46027. * Defines the camera the input is attached to.
  46028. */
  46029. camera: ArcRotateCamera;
  46030. /**
  46031. * Defines the list of key codes associated with the up action (increase alpha)
  46032. */
  46033. keysUp: number[];
  46034. /**
  46035. * Defines the list of key codes associated with the down action (decrease alpha)
  46036. */
  46037. keysDown: number[];
  46038. /**
  46039. * Defines the list of key codes associated with the left action (increase beta)
  46040. */
  46041. keysLeft: number[];
  46042. /**
  46043. * Defines the list of key codes associated with the right action (decrease beta)
  46044. */
  46045. keysRight: number[];
  46046. /**
  46047. * Defines the list of key codes associated with the reset action.
  46048. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  46049. */
  46050. keysReset: number[];
  46051. /**
  46052. * Defines the panning sensibility of the inputs.
  46053. * (How fast is the camera panning)
  46054. */
  46055. panningSensibility: number;
  46056. /**
  46057. * Defines the zooming sensibility of the inputs.
  46058. * (How fast is the camera zooming)
  46059. */
  46060. zoomingSensibility: number;
  46061. /**
  46062. * Defines whether maintaining the alt key down switch the movement mode from
  46063. * orientation to zoom.
  46064. */
  46065. useAltToZoom: boolean;
  46066. /**
  46067. * Rotation speed of the camera
  46068. */
  46069. angularSpeed: number;
  46070. private _keys;
  46071. private _ctrlPressed;
  46072. private _altPressed;
  46073. private _onCanvasBlurObserver;
  46074. private _onKeyboardObserver;
  46075. private _engine;
  46076. private _scene;
  46077. /**
  46078. * Attach the input controls to a specific dom element to get the input from.
  46079. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46080. */
  46081. attachControl(noPreventDefault?: boolean): void;
  46082. /**
  46083. * Detach the current controls from the specified dom element.
  46084. */
  46085. detachControl(): void;
  46086. /**
  46087. * Update the current camera state depending on the inputs that have been used this frame.
  46088. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46089. */
  46090. checkInputs(): void;
  46091. /**
  46092. * Gets the class name of the current intput.
  46093. * @returns the class name
  46094. */
  46095. getClassName(): string;
  46096. /**
  46097. * Get the friendly name associated with the input class.
  46098. * @returns the input friendly name
  46099. */
  46100. getSimpleName(): string;
  46101. }
  46102. }
  46103. declare module BABYLON {
  46104. /**
  46105. * Manage the mouse wheel inputs to control an arc rotate camera.
  46106. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46107. */
  46108. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  46109. /**
  46110. * Defines the camera the input is attached to.
  46111. */
  46112. camera: ArcRotateCamera;
  46113. /**
  46114. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  46115. */
  46116. wheelPrecision: number;
  46117. /**
  46118. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  46119. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  46120. */
  46121. wheelDeltaPercentage: number;
  46122. private _wheel;
  46123. private _observer;
  46124. private computeDeltaFromMouseWheelLegacyEvent;
  46125. /**
  46126. * Attach the input controls to a specific dom element to get the input from.
  46127. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46128. */
  46129. attachControl(noPreventDefault?: boolean): void;
  46130. /**
  46131. * Detach the current controls from the specified dom element.
  46132. */
  46133. detachControl(): void;
  46134. /**
  46135. * Gets the class name of the current intput.
  46136. * @returns the class name
  46137. */
  46138. getClassName(): string;
  46139. /**
  46140. * Get the friendly name associated with the input class.
  46141. * @returns the input friendly name
  46142. */
  46143. getSimpleName(): string;
  46144. }
  46145. }
  46146. declare module BABYLON {
  46147. /**
  46148. * Default Inputs manager for the ArcRotateCamera.
  46149. * It groups all the default supported inputs for ease of use.
  46150. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46151. */
  46152. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  46153. /**
  46154. * Instantiates a new ArcRotateCameraInputsManager.
  46155. * @param camera Defines the camera the inputs belong to
  46156. */
  46157. constructor(camera: ArcRotateCamera);
  46158. /**
  46159. * Add mouse wheel input support to the input manager.
  46160. * @returns the current input manager
  46161. */
  46162. addMouseWheel(): ArcRotateCameraInputsManager;
  46163. /**
  46164. * Add pointers input support to the input manager.
  46165. * @returns the current input manager
  46166. */
  46167. addPointers(): ArcRotateCameraInputsManager;
  46168. /**
  46169. * Add keyboard input support to the input manager.
  46170. * @returns the current input manager
  46171. */
  46172. addKeyboard(): ArcRotateCameraInputsManager;
  46173. }
  46174. }
  46175. declare module BABYLON {
  46176. /**
  46177. * This represents an orbital type of camera.
  46178. *
  46179. * 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.
  46180. * 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.
  46181. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  46182. */
  46183. export class ArcRotateCamera extends TargetCamera {
  46184. /**
  46185. * Defines the rotation angle of the camera along the longitudinal axis.
  46186. */
  46187. alpha: number;
  46188. /**
  46189. * Defines the rotation angle of the camera along the latitudinal axis.
  46190. */
  46191. beta: number;
  46192. /**
  46193. * Defines the radius of the camera from it s target point.
  46194. */
  46195. radius: number;
  46196. protected _target: Vector3;
  46197. protected _targetHost: Nullable<AbstractMesh>;
  46198. /**
  46199. * Defines the target point of the camera.
  46200. * The camera looks towards it form the radius distance.
  46201. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  46202. */
  46203. get target(): Vector3;
  46204. set target(value: Vector3);
  46205. /**
  46206. * Define the current local position of the camera in the scene
  46207. */
  46208. get position(): Vector3;
  46209. set position(newPosition: Vector3);
  46210. protected _upToYMatrix: Matrix;
  46211. protected _YToUpMatrix: Matrix;
  46212. /**
  46213. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  46214. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  46215. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  46216. */
  46217. set upVector(vec: Vector3);
  46218. get upVector(): Vector3;
  46219. /**
  46220. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  46221. */
  46222. setMatUp(): void;
  46223. /**
  46224. * Current inertia value on the longitudinal axis.
  46225. * The bigger this number the longer it will take for the camera to stop.
  46226. */
  46227. inertialAlphaOffset: number;
  46228. /**
  46229. * Current inertia value on the latitudinal axis.
  46230. * The bigger this number the longer it will take for the camera to stop.
  46231. */
  46232. inertialBetaOffset: number;
  46233. /**
  46234. * Current inertia value on the radius axis.
  46235. * The bigger this number the longer it will take for the camera to stop.
  46236. */
  46237. inertialRadiusOffset: number;
  46238. /**
  46239. * Minimum allowed angle on the longitudinal axis.
  46240. * This can help limiting how the Camera is able to move in the scene.
  46241. */
  46242. lowerAlphaLimit: Nullable<number>;
  46243. /**
  46244. * Maximum allowed angle on the longitudinal axis.
  46245. * This can help limiting how the Camera is able to move in the scene.
  46246. */
  46247. upperAlphaLimit: Nullable<number>;
  46248. /**
  46249. * Minimum allowed angle on the latitudinal axis.
  46250. * This can help limiting how the Camera is able to move in the scene.
  46251. */
  46252. lowerBetaLimit: number;
  46253. /**
  46254. * Maximum allowed angle on the latitudinal axis.
  46255. * This can help limiting how the Camera is able to move in the scene.
  46256. */
  46257. upperBetaLimit: number;
  46258. /**
  46259. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  46260. * This can help limiting how the Camera is able to move in the scene.
  46261. */
  46262. lowerRadiusLimit: Nullable<number>;
  46263. /**
  46264. * Maximum allowed distance of the camera to the target (The camera can not get further).
  46265. * This can help limiting how the Camera is able to move in the scene.
  46266. */
  46267. upperRadiusLimit: Nullable<number>;
  46268. /**
  46269. * Defines the current inertia value used during panning of the camera along the X axis.
  46270. */
  46271. inertialPanningX: number;
  46272. /**
  46273. * Defines the current inertia value used during panning of the camera along the Y axis.
  46274. */
  46275. inertialPanningY: number;
  46276. /**
  46277. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  46278. * Basically if your fingers moves away from more than this distance you will be considered
  46279. * in pinch mode.
  46280. */
  46281. pinchToPanMaxDistance: number;
  46282. /**
  46283. * Defines the maximum distance the camera can pan.
  46284. * This could help keeping the cammera always in your scene.
  46285. */
  46286. panningDistanceLimit: Nullable<number>;
  46287. /**
  46288. * Defines the target of the camera before paning.
  46289. */
  46290. panningOriginTarget: Vector3;
  46291. /**
  46292. * Defines the value of the inertia used during panning.
  46293. * 0 would mean stop inertia and one would mean no decelleration at all.
  46294. */
  46295. panningInertia: number;
  46296. /**
  46297. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  46298. */
  46299. get angularSensibilityX(): number;
  46300. set angularSensibilityX(value: number);
  46301. /**
  46302. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  46303. */
  46304. get angularSensibilityY(): number;
  46305. set angularSensibilityY(value: number);
  46306. /**
  46307. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  46308. */
  46309. get pinchPrecision(): number;
  46310. set pinchPrecision(value: number);
  46311. /**
  46312. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  46313. * It will be used instead of pinchDeltaPrecision if different from 0.
  46314. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  46315. */
  46316. get pinchDeltaPercentage(): number;
  46317. set pinchDeltaPercentage(value: number);
  46318. /**
  46319. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  46320. * and pinch delta percentage.
  46321. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  46322. * that any object in the plane at the camera's target point will scale
  46323. * perfectly with finger motion.
  46324. */
  46325. get useNaturalPinchZoom(): boolean;
  46326. set useNaturalPinchZoom(value: boolean);
  46327. /**
  46328. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  46329. */
  46330. get panningSensibility(): number;
  46331. set panningSensibility(value: number);
  46332. /**
  46333. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  46334. */
  46335. get keysUp(): number[];
  46336. set keysUp(value: number[]);
  46337. /**
  46338. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  46339. */
  46340. get keysDown(): number[];
  46341. set keysDown(value: number[]);
  46342. /**
  46343. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  46344. */
  46345. get keysLeft(): number[];
  46346. set keysLeft(value: number[]);
  46347. /**
  46348. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  46349. */
  46350. get keysRight(): number[];
  46351. set keysRight(value: number[]);
  46352. /**
  46353. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  46354. */
  46355. get wheelPrecision(): number;
  46356. set wheelPrecision(value: number);
  46357. /**
  46358. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  46359. * It will be used instead of pinchDeltaPrecision if different from 0.
  46360. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  46361. */
  46362. get wheelDeltaPercentage(): number;
  46363. set wheelDeltaPercentage(value: number);
  46364. /**
  46365. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  46366. */
  46367. zoomOnFactor: number;
  46368. /**
  46369. * Defines a screen offset for the camera position.
  46370. */
  46371. targetScreenOffset: Vector2;
  46372. /**
  46373. * Allows the camera to be completely reversed.
  46374. * If false the camera can not arrive upside down.
  46375. */
  46376. allowUpsideDown: boolean;
  46377. /**
  46378. * Define if double tap/click is used to restore the previously saved state of the camera.
  46379. */
  46380. useInputToRestoreState: boolean;
  46381. /** @hidden */
  46382. _viewMatrix: Matrix;
  46383. /** @hidden */
  46384. _useCtrlForPanning: boolean;
  46385. /** @hidden */
  46386. _panningMouseButton: number;
  46387. /**
  46388. * Defines the input associated to the camera.
  46389. */
  46390. inputs: ArcRotateCameraInputsManager;
  46391. /** @hidden */
  46392. _reset: () => void;
  46393. /**
  46394. * Defines the allowed panning axis.
  46395. */
  46396. panningAxis: Vector3;
  46397. protected _localDirection: Vector3;
  46398. protected _transformedDirection: Vector3;
  46399. private _bouncingBehavior;
  46400. /**
  46401. * Gets the bouncing behavior of the camera if it has been enabled.
  46402. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46403. */
  46404. get bouncingBehavior(): Nullable<BouncingBehavior>;
  46405. /**
  46406. * Defines if the bouncing behavior of the camera is enabled on the camera.
  46407. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46408. */
  46409. get useBouncingBehavior(): boolean;
  46410. set useBouncingBehavior(value: boolean);
  46411. private _framingBehavior;
  46412. /**
  46413. * Gets the framing behavior of the camera if it has been enabled.
  46414. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46415. */
  46416. get framingBehavior(): Nullable<FramingBehavior>;
  46417. /**
  46418. * Defines if the framing behavior of the camera is enabled on the camera.
  46419. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46420. */
  46421. get useFramingBehavior(): boolean;
  46422. set useFramingBehavior(value: boolean);
  46423. private _autoRotationBehavior;
  46424. /**
  46425. * Gets the auto rotation behavior of the camera if it has been enabled.
  46426. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46427. */
  46428. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  46429. /**
  46430. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  46431. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46432. */
  46433. get useAutoRotationBehavior(): boolean;
  46434. set useAutoRotationBehavior(value: boolean);
  46435. /**
  46436. * Observable triggered when the mesh target has been changed on the camera.
  46437. */
  46438. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  46439. /**
  46440. * Event raised when the camera is colliding with a mesh.
  46441. */
  46442. onCollide: (collidedMesh: AbstractMesh) => void;
  46443. /**
  46444. * Defines whether the camera should check collision with the objects oh the scene.
  46445. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  46446. */
  46447. checkCollisions: boolean;
  46448. /**
  46449. * Defines the collision radius of the camera.
  46450. * This simulates a sphere around the camera.
  46451. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  46452. */
  46453. collisionRadius: Vector3;
  46454. protected _collider: Collider;
  46455. protected _previousPosition: Vector3;
  46456. protected _collisionVelocity: Vector3;
  46457. protected _newPosition: Vector3;
  46458. protected _previousAlpha: number;
  46459. protected _previousBeta: number;
  46460. protected _previousRadius: number;
  46461. protected _collisionTriggered: boolean;
  46462. protected _targetBoundingCenter: Nullable<Vector3>;
  46463. private _computationVector;
  46464. /**
  46465. * Instantiates a new ArcRotateCamera in a given scene
  46466. * @param name Defines the name of the camera
  46467. * @param alpha Defines the camera rotation along the logitudinal axis
  46468. * @param beta Defines the camera rotation along the latitudinal axis
  46469. * @param radius Defines the camera distance from its target
  46470. * @param target Defines the camera target
  46471. * @param scene Defines the scene the camera belongs to
  46472. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  46473. */
  46474. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  46475. /** @hidden */
  46476. _initCache(): void;
  46477. /** @hidden */
  46478. _updateCache(ignoreParentClass?: boolean): void;
  46479. protected _getTargetPosition(): Vector3;
  46480. private _storedAlpha;
  46481. private _storedBeta;
  46482. private _storedRadius;
  46483. private _storedTarget;
  46484. private _storedTargetScreenOffset;
  46485. /**
  46486. * Stores the current state of the camera (alpha, beta, radius and target)
  46487. * @returns the camera itself
  46488. */
  46489. storeState(): Camera;
  46490. /**
  46491. * @hidden
  46492. * Restored camera state. You must call storeState() first
  46493. */
  46494. _restoreStateValues(): boolean;
  46495. /** @hidden */
  46496. _isSynchronizedViewMatrix(): boolean;
  46497. /**
  46498. * Attached controls to the current camera.
  46499. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46500. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  46501. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  46502. */
  46503. attachControl(noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  46504. /**
  46505. * Detach the current controls from the camera.
  46506. * The camera will stop reacting to inputs.
  46507. */
  46508. detachControl(): void;
  46509. /** @hidden */
  46510. _checkInputs(): void;
  46511. protected _checkLimits(): void;
  46512. /**
  46513. * Rebuilds angles (alpha, beta) and radius from the give position and target
  46514. */
  46515. rebuildAnglesAndRadius(): void;
  46516. /**
  46517. * Use a position to define the current camera related information like alpha, beta and radius
  46518. * @param position Defines the position to set the camera at
  46519. */
  46520. setPosition(position: Vector3): void;
  46521. /**
  46522. * Defines the target the camera should look at.
  46523. * This will automatically adapt alpha beta and radius to fit within the new target.
  46524. * @param target Defines the new target as a Vector or a mesh
  46525. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  46526. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  46527. */
  46528. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  46529. /** @hidden */
  46530. _getViewMatrix(): Matrix;
  46531. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  46532. /**
  46533. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  46534. * @param meshes Defines the mesh to zoom on
  46535. * @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)
  46536. */
  46537. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  46538. /**
  46539. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  46540. * The target will be changed but the radius
  46541. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  46542. * @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)
  46543. */
  46544. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  46545. min: Vector3;
  46546. max: Vector3;
  46547. distance: number;
  46548. }, doNotUpdateMaxZ?: boolean): void;
  46549. /**
  46550. * @override
  46551. * Override Camera.createRigCamera
  46552. */
  46553. createRigCamera(name: string, cameraIndex: number): Camera;
  46554. /**
  46555. * @hidden
  46556. * @override
  46557. * Override Camera._updateRigCameras
  46558. */
  46559. _updateRigCameras(): void;
  46560. /**
  46561. * Destroy the camera and release the current resources hold by it.
  46562. */
  46563. dispose(): void;
  46564. /**
  46565. * Gets the current object class name.
  46566. * @return the class name
  46567. */
  46568. getClassName(): string;
  46569. }
  46570. }
  46571. declare module BABYLON {
  46572. /**
  46573. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  46574. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46575. */
  46576. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  46577. /**
  46578. * Gets the name of the behavior.
  46579. */
  46580. get name(): string;
  46581. private _zoomStopsAnimation;
  46582. private _idleRotationSpeed;
  46583. private _idleRotationWaitTime;
  46584. private _idleRotationSpinupTime;
  46585. /**
  46586. * Sets the flag that indicates if user zooming should stop animation.
  46587. */
  46588. set zoomStopsAnimation(flag: boolean);
  46589. /**
  46590. * Gets the flag that indicates if user zooming should stop animation.
  46591. */
  46592. get zoomStopsAnimation(): boolean;
  46593. /**
  46594. * Sets the default speed at which the camera rotates around the model.
  46595. */
  46596. set idleRotationSpeed(speed: number);
  46597. /**
  46598. * Gets the default speed at which the camera rotates around the model.
  46599. */
  46600. get idleRotationSpeed(): number;
  46601. /**
  46602. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  46603. */
  46604. set idleRotationWaitTime(time: number);
  46605. /**
  46606. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  46607. */
  46608. get idleRotationWaitTime(): number;
  46609. /**
  46610. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  46611. */
  46612. set idleRotationSpinupTime(time: number);
  46613. /**
  46614. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  46615. */
  46616. get idleRotationSpinupTime(): number;
  46617. /**
  46618. * Gets a value indicating if the camera is currently rotating because of this behavior
  46619. */
  46620. get rotationInProgress(): boolean;
  46621. private _onPrePointerObservableObserver;
  46622. private _onAfterCheckInputsObserver;
  46623. private _attachedCamera;
  46624. private _isPointerDown;
  46625. private _lastFrameTime;
  46626. private _lastInteractionTime;
  46627. private _cameraRotationSpeed;
  46628. /**
  46629. * Initializes the behavior.
  46630. */
  46631. init(): void;
  46632. /**
  46633. * Attaches the behavior to its arc rotate camera.
  46634. * @param camera Defines the camera to attach the behavior to
  46635. */
  46636. attach(camera: ArcRotateCamera): void;
  46637. /**
  46638. * Detaches the behavior from its current arc rotate camera.
  46639. */
  46640. detach(): void;
  46641. /**
  46642. * Returns true if user is scrolling.
  46643. * @return true if user is scrolling.
  46644. */
  46645. private _userIsZooming;
  46646. private _lastFrameRadius;
  46647. private _shouldAnimationStopForInteraction;
  46648. /**
  46649. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  46650. */
  46651. private _applyUserInteraction;
  46652. private _userIsMoving;
  46653. }
  46654. }
  46655. declare module BABYLON {
  46656. /**
  46657. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  46658. */
  46659. export class AttachToBoxBehavior implements Behavior<Mesh> {
  46660. private ui;
  46661. /**
  46662. * The name of the behavior
  46663. */
  46664. name: string;
  46665. /**
  46666. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  46667. */
  46668. distanceAwayFromFace: number;
  46669. /**
  46670. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  46671. */
  46672. distanceAwayFromBottomOfFace: number;
  46673. private _faceVectors;
  46674. private _target;
  46675. private _scene;
  46676. private _onRenderObserver;
  46677. private _tmpMatrix;
  46678. private _tmpVector;
  46679. /**
  46680. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  46681. * @param ui The transform node that should be attched to the mesh
  46682. */
  46683. constructor(ui: TransformNode);
  46684. /**
  46685. * Initializes the behavior
  46686. */
  46687. init(): void;
  46688. private _closestFace;
  46689. private _zeroVector;
  46690. private _lookAtTmpMatrix;
  46691. private _lookAtToRef;
  46692. /**
  46693. * Attaches the AttachToBoxBehavior to the passed in mesh
  46694. * @param target The mesh that the specified node will be attached to
  46695. */
  46696. attach(target: Mesh): void;
  46697. /**
  46698. * Detaches the behavior from the mesh
  46699. */
  46700. detach(): void;
  46701. }
  46702. }
  46703. declare module BABYLON {
  46704. /**
  46705. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  46706. */
  46707. export class FadeInOutBehavior implements Behavior<Mesh> {
  46708. /**
  46709. * Time in milliseconds to delay before fading in (Default: 0)
  46710. */
  46711. delay: number;
  46712. /**
  46713. * Time in milliseconds for the mesh to fade in (Default: 300)
  46714. */
  46715. fadeInTime: number;
  46716. private _millisecondsPerFrame;
  46717. private _hovered;
  46718. private _hoverValue;
  46719. private _ownerNode;
  46720. /**
  46721. * Instatiates the FadeInOutBehavior
  46722. */
  46723. constructor();
  46724. /**
  46725. * The name of the behavior
  46726. */
  46727. get name(): string;
  46728. /**
  46729. * Initializes the behavior
  46730. */
  46731. init(): void;
  46732. /**
  46733. * Attaches the fade behavior on the passed in mesh
  46734. * @param ownerNode The mesh that will be faded in/out once attached
  46735. */
  46736. attach(ownerNode: Mesh): void;
  46737. /**
  46738. * Detaches the behavior from the mesh
  46739. */
  46740. detach(): void;
  46741. /**
  46742. * Triggers the mesh to begin fading in or out
  46743. * @param value if the object should fade in or out (true to fade in)
  46744. */
  46745. fadeIn(value: boolean): void;
  46746. private _update;
  46747. private _setAllVisibility;
  46748. }
  46749. }
  46750. declare module BABYLON {
  46751. /**
  46752. * Class containing a set of static utilities functions for managing Pivots
  46753. * @hidden
  46754. */
  46755. export class PivotTools {
  46756. private static _PivotCached;
  46757. private static _OldPivotPoint;
  46758. private static _PivotTranslation;
  46759. private static _PivotTmpVector;
  46760. private static _PivotPostMultiplyPivotMatrix;
  46761. /** @hidden */
  46762. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  46763. /** @hidden */
  46764. static _RestorePivotPoint(mesh: AbstractMesh): void;
  46765. }
  46766. }
  46767. declare module BABYLON {
  46768. /**
  46769. * Class containing static functions to help procedurally build meshes
  46770. */
  46771. export class PlaneBuilder {
  46772. /**
  46773. * Creates a plane mesh
  46774. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  46775. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  46776. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  46777. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46778. * * 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
  46779. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46780. * @param name defines the name of the mesh
  46781. * @param options defines the options used to create the mesh
  46782. * @param scene defines the hosting scene
  46783. * @returns the plane mesh
  46784. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  46785. */
  46786. static CreatePlane(name: string, options: {
  46787. size?: number;
  46788. width?: number;
  46789. height?: number;
  46790. sideOrientation?: number;
  46791. frontUVs?: Vector4;
  46792. backUVs?: Vector4;
  46793. updatable?: boolean;
  46794. sourcePlane?: Plane;
  46795. }, scene?: Nullable<Scene>): Mesh;
  46796. }
  46797. }
  46798. declare module BABYLON {
  46799. /**
  46800. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  46801. */
  46802. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  46803. private static _AnyMouseID;
  46804. /**
  46805. * Abstract mesh the behavior is set on
  46806. */
  46807. attachedNode: AbstractMesh;
  46808. private _dragPlane;
  46809. private _scene;
  46810. private _pointerObserver;
  46811. private _beforeRenderObserver;
  46812. private static _planeScene;
  46813. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  46814. /**
  46815. * 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)
  46816. */
  46817. maxDragAngle: number;
  46818. /**
  46819. * @hidden
  46820. */
  46821. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  46822. /**
  46823. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  46824. */
  46825. currentDraggingPointerID: number;
  46826. /**
  46827. * The last position where the pointer hit the drag plane in world space
  46828. */
  46829. lastDragPosition: Vector3;
  46830. /**
  46831. * If the behavior is currently in a dragging state
  46832. */
  46833. dragging: boolean;
  46834. /**
  46835. * 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)
  46836. */
  46837. dragDeltaRatio: number;
  46838. /**
  46839. * If the drag plane orientation should be updated during the dragging (Default: true)
  46840. */
  46841. updateDragPlane: boolean;
  46842. private _debugMode;
  46843. private _moving;
  46844. /**
  46845. * Fires each time the attached mesh is dragged with the pointer
  46846. * * delta between last drag position and current drag position in world space
  46847. * * dragDistance along the drag axis
  46848. * * dragPlaneNormal normal of the current drag plane used during the drag
  46849. * * dragPlanePoint in world space where the drag intersects the drag plane
  46850. */
  46851. onDragObservable: Observable<{
  46852. delta: Vector3;
  46853. dragPlanePoint: Vector3;
  46854. dragPlaneNormal: Vector3;
  46855. dragDistance: number;
  46856. pointerId: number;
  46857. }>;
  46858. /**
  46859. * Fires each time a drag begins (eg. mouse down on mesh)
  46860. */
  46861. onDragStartObservable: Observable<{
  46862. dragPlanePoint: Vector3;
  46863. pointerId: number;
  46864. }>;
  46865. /**
  46866. * Fires each time a drag ends (eg. mouse release after drag)
  46867. */
  46868. onDragEndObservable: Observable<{
  46869. dragPlanePoint: Vector3;
  46870. pointerId: number;
  46871. }>;
  46872. /**
  46873. * If the attached mesh should be moved when dragged
  46874. */
  46875. moveAttached: boolean;
  46876. /**
  46877. * If the drag behavior will react to drag events (Default: true)
  46878. */
  46879. enabled: boolean;
  46880. /**
  46881. * If pointer events should start and release the drag (Default: true)
  46882. */
  46883. startAndReleaseDragOnPointerEvents: boolean;
  46884. /**
  46885. * If camera controls should be detached during the drag
  46886. */
  46887. detachCameraControls: boolean;
  46888. /**
  46889. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  46890. */
  46891. useObjectOrientationForDragging: boolean;
  46892. private _options;
  46893. /**
  46894. * Gets the options used by the behavior
  46895. */
  46896. get options(): {
  46897. dragAxis?: Vector3;
  46898. dragPlaneNormal?: Vector3;
  46899. };
  46900. /**
  46901. * Sets the options used by the behavior
  46902. */
  46903. set options(options: {
  46904. dragAxis?: Vector3;
  46905. dragPlaneNormal?: Vector3;
  46906. });
  46907. /**
  46908. * Creates a pointer drag behavior that can be attached to a mesh
  46909. * @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)
  46910. */
  46911. constructor(options?: {
  46912. dragAxis?: Vector3;
  46913. dragPlaneNormal?: Vector3;
  46914. });
  46915. /**
  46916. * Predicate to determine if it is valid to move the object to a new position when it is moved
  46917. */
  46918. validateDrag: (targetPosition: Vector3) => boolean;
  46919. /**
  46920. * The name of the behavior
  46921. */
  46922. get name(): string;
  46923. /**
  46924. * Initializes the behavior
  46925. */
  46926. init(): void;
  46927. private _tmpVector;
  46928. private _alternatePickedPoint;
  46929. private _worldDragAxis;
  46930. private _targetPosition;
  46931. private _attachedElement;
  46932. /**
  46933. * Attaches the drag behavior the passed in mesh
  46934. * @param ownerNode The mesh that will be dragged around once attached
  46935. * @param predicate Predicate to use for pick filtering
  46936. */
  46937. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  46938. /**
  46939. * Force relase the drag action by code.
  46940. */
  46941. releaseDrag(): void;
  46942. private _startDragRay;
  46943. private _lastPointerRay;
  46944. /**
  46945. * Simulates the start of a pointer drag event on the behavior
  46946. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  46947. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  46948. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  46949. */
  46950. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  46951. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  46952. private _dragDelta;
  46953. protected _moveDrag(ray: Ray): void;
  46954. private _pickWithRayOnDragPlane;
  46955. private _pointA;
  46956. private _pointC;
  46957. private _localAxis;
  46958. private _lookAt;
  46959. private _updateDragPlanePosition;
  46960. /**
  46961. * Detaches the behavior from the mesh
  46962. */
  46963. detach(): void;
  46964. }
  46965. }
  46966. declare module BABYLON {
  46967. /**
  46968. * A behavior that when attached to a mesh will allow the mesh to be scaled
  46969. */
  46970. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  46971. private _dragBehaviorA;
  46972. private _dragBehaviorB;
  46973. private _startDistance;
  46974. private _initialScale;
  46975. private _targetScale;
  46976. private _ownerNode;
  46977. private _sceneRenderObserver;
  46978. /**
  46979. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  46980. */
  46981. constructor();
  46982. /**
  46983. * The name of the behavior
  46984. */
  46985. get name(): string;
  46986. /**
  46987. * Initializes the behavior
  46988. */
  46989. init(): void;
  46990. private _getCurrentDistance;
  46991. /**
  46992. * Attaches the scale behavior the passed in mesh
  46993. * @param ownerNode The mesh that will be scaled around once attached
  46994. */
  46995. attach(ownerNode: Mesh): void;
  46996. /**
  46997. * Detaches the behavior from the mesh
  46998. */
  46999. detach(): void;
  47000. }
  47001. }
  47002. declare module BABYLON {
  47003. /**
  47004. * 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
  47005. */
  47006. export class SixDofDragBehavior implements Behavior<Mesh> {
  47007. private static _virtualScene;
  47008. private _ownerNode;
  47009. private _sceneRenderObserver;
  47010. private _scene;
  47011. private _targetPosition;
  47012. private _virtualOriginMesh;
  47013. private _virtualDragMesh;
  47014. private _pointerObserver;
  47015. private _moving;
  47016. private _startingOrientation;
  47017. private _attachedElement;
  47018. /**
  47019. * 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)
  47020. */
  47021. private zDragFactor;
  47022. /**
  47023. * If the object should rotate to face the drag origin
  47024. */
  47025. rotateDraggedObject: boolean;
  47026. /**
  47027. * If the behavior is currently in a dragging state
  47028. */
  47029. dragging: boolean;
  47030. /**
  47031. * 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)
  47032. */
  47033. dragDeltaRatio: number;
  47034. /**
  47035. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  47036. */
  47037. currentDraggingPointerID: number;
  47038. /**
  47039. * If camera controls should be detached during the drag
  47040. */
  47041. detachCameraControls: boolean;
  47042. /**
  47043. * Fires each time a drag starts
  47044. */
  47045. onDragStartObservable: Observable<{}>;
  47046. /**
  47047. * Fires each time a drag ends (eg. mouse release after drag)
  47048. */
  47049. onDragEndObservable: Observable<{}>;
  47050. /**
  47051. * 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
  47052. */
  47053. constructor();
  47054. /**
  47055. * The name of the behavior
  47056. */
  47057. get name(): string;
  47058. /**
  47059. * Initializes the behavior
  47060. */
  47061. init(): void;
  47062. /**
  47063. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  47064. */
  47065. private get _pointerCamera();
  47066. /**
  47067. * Attaches the scale behavior the passed in mesh
  47068. * @param ownerNode The mesh that will be scaled around once attached
  47069. */
  47070. attach(ownerNode: Mesh): void;
  47071. /**
  47072. * Detaches the behavior from the mesh
  47073. */
  47074. detach(): void;
  47075. }
  47076. }
  47077. declare module BABYLON {
  47078. /**
  47079. * Class used to apply inverse kinematics to bones
  47080. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  47081. */
  47082. export class BoneIKController {
  47083. private static _tmpVecs;
  47084. private static _tmpQuat;
  47085. private static _tmpMats;
  47086. /**
  47087. * Gets or sets the target mesh
  47088. */
  47089. targetMesh: AbstractMesh;
  47090. /** Gets or sets the mesh used as pole */
  47091. poleTargetMesh: AbstractMesh;
  47092. /**
  47093. * Gets or sets the bone used as pole
  47094. */
  47095. poleTargetBone: Nullable<Bone>;
  47096. /**
  47097. * Gets or sets the target position
  47098. */
  47099. targetPosition: Vector3;
  47100. /**
  47101. * Gets or sets the pole target position
  47102. */
  47103. poleTargetPosition: Vector3;
  47104. /**
  47105. * Gets or sets the pole target local offset
  47106. */
  47107. poleTargetLocalOffset: Vector3;
  47108. /**
  47109. * Gets or sets the pole angle
  47110. */
  47111. poleAngle: number;
  47112. /**
  47113. * Gets or sets the mesh associated with the controller
  47114. */
  47115. mesh: AbstractMesh;
  47116. /**
  47117. * 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)
  47118. */
  47119. slerpAmount: number;
  47120. private _bone1Quat;
  47121. private _bone1Mat;
  47122. private _bone2Ang;
  47123. private _bone1;
  47124. private _bone2;
  47125. private _bone1Length;
  47126. private _bone2Length;
  47127. private _maxAngle;
  47128. private _maxReach;
  47129. private _rightHandedSystem;
  47130. private _bendAxis;
  47131. private _slerping;
  47132. private _adjustRoll;
  47133. /**
  47134. * Gets or sets maximum allowed angle
  47135. */
  47136. get maxAngle(): number;
  47137. set maxAngle(value: number);
  47138. /**
  47139. * Creates a new BoneIKController
  47140. * @param mesh defines the mesh to control
  47141. * @param bone defines the bone to control
  47142. * @param options defines options to set up the controller
  47143. */
  47144. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  47145. targetMesh?: AbstractMesh;
  47146. poleTargetMesh?: AbstractMesh;
  47147. poleTargetBone?: Bone;
  47148. poleTargetLocalOffset?: Vector3;
  47149. poleAngle?: number;
  47150. bendAxis?: Vector3;
  47151. maxAngle?: number;
  47152. slerpAmount?: number;
  47153. });
  47154. private _setMaxAngle;
  47155. /**
  47156. * Force the controller to update the bones
  47157. */
  47158. update(): void;
  47159. }
  47160. }
  47161. declare module BABYLON {
  47162. /**
  47163. * Class used to make a bone look toward a point in space
  47164. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  47165. */
  47166. export class BoneLookController {
  47167. private static _tmpVecs;
  47168. private static _tmpQuat;
  47169. private static _tmpMats;
  47170. /**
  47171. * The target Vector3 that the bone will look at
  47172. */
  47173. target: Vector3;
  47174. /**
  47175. * The mesh that the bone is attached to
  47176. */
  47177. mesh: AbstractMesh;
  47178. /**
  47179. * The bone that will be looking to the target
  47180. */
  47181. bone: Bone;
  47182. /**
  47183. * The up axis of the coordinate system that is used when the bone is rotated
  47184. */
  47185. upAxis: Vector3;
  47186. /**
  47187. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  47188. */
  47189. upAxisSpace: Space;
  47190. /**
  47191. * Used to make an adjustment to the yaw of the bone
  47192. */
  47193. adjustYaw: number;
  47194. /**
  47195. * Used to make an adjustment to the pitch of the bone
  47196. */
  47197. adjustPitch: number;
  47198. /**
  47199. * Used to make an adjustment to the roll of the bone
  47200. */
  47201. adjustRoll: number;
  47202. /**
  47203. * 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)
  47204. */
  47205. slerpAmount: number;
  47206. private _minYaw;
  47207. private _maxYaw;
  47208. private _minPitch;
  47209. private _maxPitch;
  47210. private _minYawSin;
  47211. private _minYawCos;
  47212. private _maxYawSin;
  47213. private _maxYawCos;
  47214. private _midYawConstraint;
  47215. private _minPitchTan;
  47216. private _maxPitchTan;
  47217. private _boneQuat;
  47218. private _slerping;
  47219. private _transformYawPitch;
  47220. private _transformYawPitchInv;
  47221. private _firstFrameSkipped;
  47222. private _yawRange;
  47223. private _fowardAxis;
  47224. /**
  47225. * Gets or sets the minimum yaw angle that the bone can look to
  47226. */
  47227. get minYaw(): number;
  47228. set minYaw(value: number);
  47229. /**
  47230. * Gets or sets the maximum yaw angle that the bone can look to
  47231. */
  47232. get maxYaw(): number;
  47233. set maxYaw(value: number);
  47234. /**
  47235. * Gets or sets the minimum pitch angle that the bone can look to
  47236. */
  47237. get minPitch(): number;
  47238. set minPitch(value: number);
  47239. /**
  47240. * Gets or sets the maximum pitch angle that the bone can look to
  47241. */
  47242. get maxPitch(): number;
  47243. set maxPitch(value: number);
  47244. /**
  47245. * Create a BoneLookController
  47246. * @param mesh the mesh that the bone belongs to
  47247. * @param bone the bone that will be looking to the target
  47248. * @param target the target Vector3 to look at
  47249. * @param options optional settings:
  47250. * * maxYaw: the maximum angle the bone will yaw to
  47251. * * minYaw: the minimum angle the bone will yaw to
  47252. * * maxPitch: the maximum angle the bone will pitch to
  47253. * * minPitch: the minimum angle the bone will yaw to
  47254. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  47255. * * upAxis: the up axis of the coordinate system
  47256. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  47257. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  47258. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  47259. * * adjustYaw: used to make an adjustment to the yaw of the bone
  47260. * * adjustPitch: used to make an adjustment to the pitch of the bone
  47261. * * adjustRoll: used to make an adjustment to the roll of the bone
  47262. **/
  47263. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  47264. maxYaw?: number;
  47265. minYaw?: number;
  47266. maxPitch?: number;
  47267. minPitch?: number;
  47268. slerpAmount?: number;
  47269. upAxis?: Vector3;
  47270. upAxisSpace?: Space;
  47271. yawAxis?: Vector3;
  47272. pitchAxis?: Vector3;
  47273. adjustYaw?: number;
  47274. adjustPitch?: number;
  47275. adjustRoll?: number;
  47276. });
  47277. /**
  47278. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  47279. */
  47280. update(): void;
  47281. private _getAngleDiff;
  47282. private _getAngleBetween;
  47283. private _isAngleBetween;
  47284. }
  47285. }
  47286. declare module BABYLON {
  47287. /**
  47288. * Manage the gamepad inputs to control an arc rotate camera.
  47289. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47290. */
  47291. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  47292. /**
  47293. * Defines the camera the input is attached to.
  47294. */
  47295. camera: ArcRotateCamera;
  47296. /**
  47297. * Defines the gamepad the input is gathering event from.
  47298. */
  47299. gamepad: Nullable<Gamepad>;
  47300. /**
  47301. * Defines the gamepad rotation sensiblity.
  47302. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  47303. */
  47304. gamepadRotationSensibility: number;
  47305. /**
  47306. * Defines the gamepad move sensiblity.
  47307. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  47308. */
  47309. gamepadMoveSensibility: number;
  47310. private _yAxisScale;
  47311. /**
  47312. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  47313. */
  47314. get invertYAxis(): boolean;
  47315. set invertYAxis(value: boolean);
  47316. private _onGamepadConnectedObserver;
  47317. private _onGamepadDisconnectedObserver;
  47318. /**
  47319. * Attach the input controls to a specific dom element to get the input from.
  47320. */
  47321. attachControl(): void;
  47322. /**
  47323. * Detach the current controls from the specified dom element.
  47324. * @param element Defines the element to stop listening the inputs from
  47325. */
  47326. detachControl(): void;
  47327. /**
  47328. * Update the current camera state depending on the inputs that have been used this frame.
  47329. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47330. */
  47331. checkInputs(): void;
  47332. /**
  47333. * Gets the class name of the current intput.
  47334. * @returns the class name
  47335. */
  47336. getClassName(): string;
  47337. /**
  47338. * Get the friendly name associated with the input class.
  47339. * @returns the input friendly name
  47340. */
  47341. getSimpleName(): string;
  47342. }
  47343. }
  47344. declare module BABYLON {
  47345. interface ArcRotateCameraInputsManager {
  47346. /**
  47347. * Add orientation input support to the input manager.
  47348. * @returns the current input manager
  47349. */
  47350. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  47351. }
  47352. /**
  47353. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  47354. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47355. */
  47356. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  47357. /**
  47358. * Defines the camera the input is attached to.
  47359. */
  47360. camera: ArcRotateCamera;
  47361. /**
  47362. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  47363. */
  47364. alphaCorrection: number;
  47365. /**
  47366. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  47367. */
  47368. gammaCorrection: number;
  47369. private _alpha;
  47370. private _gamma;
  47371. private _dirty;
  47372. private _deviceOrientationHandler;
  47373. /**
  47374. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  47375. */
  47376. constructor();
  47377. /**
  47378. * Attach the input controls to a specific dom element to get the input from.
  47379. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47380. */
  47381. attachControl(noPreventDefault?: boolean): void;
  47382. /** @hidden */
  47383. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  47384. /**
  47385. * Update the current camera state depending on the inputs that have been used this frame.
  47386. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47387. */
  47388. checkInputs(): void;
  47389. /**
  47390. * Detach the current controls from the specified dom element.
  47391. */
  47392. detachControl(): void;
  47393. /**
  47394. * Gets the class name of the current intput.
  47395. * @returns the class name
  47396. */
  47397. getClassName(): string;
  47398. /**
  47399. * Get the friendly name associated with the input class.
  47400. * @returns the input friendly name
  47401. */
  47402. getSimpleName(): string;
  47403. }
  47404. }
  47405. declare module BABYLON {
  47406. /**
  47407. * Listen to mouse events to control the camera.
  47408. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47409. */
  47410. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  47411. /**
  47412. * Defines the camera the input is attached to.
  47413. */
  47414. camera: FlyCamera;
  47415. /**
  47416. * Defines if touch is enabled. (Default is true.)
  47417. */
  47418. touchEnabled: boolean;
  47419. /**
  47420. * Defines the buttons associated with the input to handle camera rotation.
  47421. */
  47422. buttons: number[];
  47423. /**
  47424. * Assign buttons for Yaw control.
  47425. */
  47426. buttonsYaw: number[];
  47427. /**
  47428. * Assign buttons for Pitch control.
  47429. */
  47430. buttonsPitch: number[];
  47431. /**
  47432. * Assign buttons for Roll control.
  47433. */
  47434. buttonsRoll: number[];
  47435. /**
  47436. * Detect if any button is being pressed while mouse is moved.
  47437. * -1 = Mouse locked.
  47438. * 0 = Left button.
  47439. * 1 = Middle Button.
  47440. * 2 = Right Button.
  47441. */
  47442. activeButton: number;
  47443. /**
  47444. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  47445. * Higher values reduce its sensitivity.
  47446. */
  47447. angularSensibility: number;
  47448. private _observer;
  47449. private _rollObserver;
  47450. private previousPosition;
  47451. private noPreventDefault;
  47452. private element;
  47453. /**
  47454. * Listen to mouse events to control the camera.
  47455. * @param touchEnabled Define if touch is enabled. (Default is true.)
  47456. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47457. */
  47458. constructor(touchEnabled?: boolean);
  47459. /**
  47460. * Attach the mouse control to the HTML DOM element.
  47461. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  47462. */
  47463. attachControl(noPreventDefault?: boolean): void;
  47464. /**
  47465. * Detach the current controls from the specified dom element.
  47466. */
  47467. detachControl(): void;
  47468. /**
  47469. * Gets the class name of the current input.
  47470. * @returns the class name.
  47471. */
  47472. getClassName(): string;
  47473. /**
  47474. * Get the friendly name associated with the input class.
  47475. * @returns the input's friendly name.
  47476. */
  47477. getSimpleName(): string;
  47478. private _pointerInput;
  47479. private _onMouseMove;
  47480. /**
  47481. * Rotate camera by mouse offset.
  47482. */
  47483. private rotateCamera;
  47484. }
  47485. }
  47486. declare module BABYLON {
  47487. /**
  47488. * Default Inputs manager for the FlyCamera.
  47489. * It groups all the default supported inputs for ease of use.
  47490. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47491. */
  47492. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  47493. /**
  47494. * Instantiates a new FlyCameraInputsManager.
  47495. * @param camera Defines the camera the inputs belong to.
  47496. */
  47497. constructor(camera: FlyCamera);
  47498. /**
  47499. * Add keyboard input support to the input manager.
  47500. * @returns the new FlyCameraKeyboardMoveInput().
  47501. */
  47502. addKeyboard(): FlyCameraInputsManager;
  47503. /**
  47504. * Add mouse input support to the input manager.
  47505. * @param touchEnabled Enable touch screen support.
  47506. * @returns the new FlyCameraMouseInput().
  47507. */
  47508. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  47509. }
  47510. }
  47511. declare module BABYLON {
  47512. /**
  47513. * This is a flying camera, designed for 3D movement and rotation in all directions,
  47514. * such as in a 3D Space Shooter or a Flight Simulator.
  47515. */
  47516. export class FlyCamera extends TargetCamera {
  47517. /**
  47518. * Define the collision ellipsoid of the camera.
  47519. * This is helpful for simulating a camera body, like a player's body.
  47520. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  47521. */
  47522. ellipsoid: Vector3;
  47523. /**
  47524. * Define an offset for the position of the ellipsoid around the camera.
  47525. * This can be helpful if the camera is attached away from the player's body center,
  47526. * such as at its head.
  47527. */
  47528. ellipsoidOffset: Vector3;
  47529. /**
  47530. * Enable or disable collisions of the camera with the rest of the scene objects.
  47531. */
  47532. checkCollisions: boolean;
  47533. /**
  47534. * Enable or disable gravity on the camera.
  47535. */
  47536. applyGravity: boolean;
  47537. /**
  47538. * Define the current direction the camera is moving to.
  47539. */
  47540. cameraDirection: Vector3;
  47541. /**
  47542. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  47543. * This overrides and empties cameraRotation.
  47544. */
  47545. rotationQuaternion: Quaternion;
  47546. /**
  47547. * Track Roll to maintain the wanted Rolling when looking around.
  47548. */
  47549. _trackRoll: number;
  47550. /**
  47551. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  47552. */
  47553. rollCorrect: number;
  47554. /**
  47555. * Mimic a banked turn, Rolling the camera when Yawing.
  47556. * It's recommended to use rollCorrect = 10 for faster banking correction.
  47557. */
  47558. bankedTurn: boolean;
  47559. /**
  47560. * Limit in radians for how much Roll banking will add. (Default: 90°)
  47561. */
  47562. bankedTurnLimit: number;
  47563. /**
  47564. * Value of 0 disables the banked Roll.
  47565. * Value of 1 is equal to the Yaw angle in radians.
  47566. */
  47567. bankedTurnMultiplier: number;
  47568. /**
  47569. * The inputs manager loads all the input sources, such as keyboard and mouse.
  47570. */
  47571. inputs: FlyCameraInputsManager;
  47572. /**
  47573. * Gets the input sensibility for mouse input.
  47574. * Higher values reduce sensitivity.
  47575. */
  47576. get angularSensibility(): number;
  47577. /**
  47578. * Sets the input sensibility for a mouse input.
  47579. * Higher values reduce sensitivity.
  47580. */
  47581. set angularSensibility(value: number);
  47582. /**
  47583. * Get the keys for camera movement forward.
  47584. */
  47585. get keysForward(): number[];
  47586. /**
  47587. * Set the keys for camera movement forward.
  47588. */
  47589. set keysForward(value: number[]);
  47590. /**
  47591. * Get the keys for camera movement backward.
  47592. */
  47593. get keysBackward(): number[];
  47594. set keysBackward(value: number[]);
  47595. /**
  47596. * Get the keys for camera movement up.
  47597. */
  47598. get keysUp(): number[];
  47599. /**
  47600. * Set the keys for camera movement up.
  47601. */
  47602. set keysUp(value: number[]);
  47603. /**
  47604. * Get the keys for camera movement down.
  47605. */
  47606. get keysDown(): number[];
  47607. /**
  47608. * Set the keys for camera movement down.
  47609. */
  47610. set keysDown(value: number[]);
  47611. /**
  47612. * Get the keys for camera movement left.
  47613. */
  47614. get keysLeft(): number[];
  47615. /**
  47616. * Set the keys for camera movement left.
  47617. */
  47618. set keysLeft(value: number[]);
  47619. /**
  47620. * Set the keys for camera movement right.
  47621. */
  47622. get keysRight(): number[];
  47623. /**
  47624. * Set the keys for camera movement right.
  47625. */
  47626. set keysRight(value: number[]);
  47627. /**
  47628. * Event raised when the camera collides with a mesh in the scene.
  47629. */
  47630. onCollide: (collidedMesh: AbstractMesh) => void;
  47631. private _collider;
  47632. private _needMoveForGravity;
  47633. private _oldPosition;
  47634. private _diffPosition;
  47635. private _newPosition;
  47636. /** @hidden */
  47637. _localDirection: Vector3;
  47638. /** @hidden */
  47639. _transformedDirection: Vector3;
  47640. /**
  47641. * Instantiates a FlyCamera.
  47642. * This is a flying camera, designed for 3D movement and rotation in all directions,
  47643. * such as in a 3D Space Shooter or a Flight Simulator.
  47644. * @param name Define the name of the camera in the scene.
  47645. * @param position Define the starting position of the camera in the scene.
  47646. * @param scene Define the scene the camera belongs to.
  47647. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  47648. */
  47649. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  47650. /**
  47651. * Attach a control to the HTML DOM element.
  47652. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  47653. */
  47654. attachControl(noPreventDefault?: boolean): void;
  47655. /**
  47656. * Detach a control from the HTML DOM element.
  47657. * The camera will stop reacting to that input.
  47658. */
  47659. detachControl(): void;
  47660. private _collisionMask;
  47661. /**
  47662. * Get the mask that the camera ignores in collision events.
  47663. */
  47664. get collisionMask(): number;
  47665. /**
  47666. * Set the mask that the camera ignores in collision events.
  47667. */
  47668. set collisionMask(mask: number);
  47669. /** @hidden */
  47670. _collideWithWorld(displacement: Vector3): void;
  47671. /** @hidden */
  47672. private _onCollisionPositionChange;
  47673. /** @hidden */
  47674. _checkInputs(): void;
  47675. /** @hidden */
  47676. _decideIfNeedsToMove(): boolean;
  47677. /** @hidden */
  47678. _updatePosition(): void;
  47679. /**
  47680. * Restore the Roll to its target value at the rate specified.
  47681. * @param rate - Higher means slower restoring.
  47682. * @hidden
  47683. */
  47684. restoreRoll(rate: number): void;
  47685. /**
  47686. * Destroy the camera and release the current resources held by it.
  47687. */
  47688. dispose(): void;
  47689. /**
  47690. * Get the current object class name.
  47691. * @returns the class name.
  47692. */
  47693. getClassName(): string;
  47694. }
  47695. }
  47696. declare module BABYLON {
  47697. /**
  47698. * Listen to keyboard events to control the camera.
  47699. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47700. */
  47701. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  47702. /**
  47703. * Defines the camera the input is attached to.
  47704. */
  47705. camera: FlyCamera;
  47706. /**
  47707. * The list of keyboard keys used to control the forward move of the camera.
  47708. */
  47709. keysForward: number[];
  47710. /**
  47711. * The list of keyboard keys used to control the backward move of the camera.
  47712. */
  47713. keysBackward: number[];
  47714. /**
  47715. * The list of keyboard keys used to control the forward move of the camera.
  47716. */
  47717. keysUp: number[];
  47718. /**
  47719. * The list of keyboard keys used to control the backward move of the camera.
  47720. */
  47721. keysDown: number[];
  47722. /**
  47723. * The list of keyboard keys used to control the right strafe move of the camera.
  47724. */
  47725. keysRight: number[];
  47726. /**
  47727. * The list of keyboard keys used to control the left strafe move of the camera.
  47728. */
  47729. keysLeft: number[];
  47730. private _keys;
  47731. private _onCanvasBlurObserver;
  47732. private _onKeyboardObserver;
  47733. private _engine;
  47734. private _scene;
  47735. /**
  47736. * Attach the input controls to a specific dom element to get the input from.
  47737. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47738. */
  47739. attachControl(noPreventDefault?: boolean): void;
  47740. /**
  47741. * Detach the current controls from the specified dom element.
  47742. */
  47743. detachControl(): void;
  47744. /**
  47745. * Gets the class name of the current intput.
  47746. * @returns the class name
  47747. */
  47748. getClassName(): string;
  47749. /** @hidden */
  47750. _onLostFocus(e: FocusEvent): void;
  47751. /**
  47752. * Get the friendly name associated with the input class.
  47753. * @returns the input friendly name
  47754. */
  47755. getSimpleName(): string;
  47756. /**
  47757. * Update the current camera state depending on the inputs that have been used this frame.
  47758. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47759. */
  47760. checkInputs(): void;
  47761. }
  47762. }
  47763. declare module BABYLON {
  47764. /**
  47765. * Manage the mouse wheel inputs to control a follow camera.
  47766. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47767. */
  47768. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  47769. /**
  47770. * Defines the camera the input is attached to.
  47771. */
  47772. camera: FollowCamera;
  47773. /**
  47774. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  47775. */
  47776. axisControlRadius: boolean;
  47777. /**
  47778. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  47779. */
  47780. axisControlHeight: boolean;
  47781. /**
  47782. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  47783. */
  47784. axisControlRotation: boolean;
  47785. /**
  47786. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  47787. * relation to mouseWheel events.
  47788. */
  47789. wheelPrecision: number;
  47790. /**
  47791. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  47792. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  47793. */
  47794. wheelDeltaPercentage: number;
  47795. private _wheel;
  47796. private _observer;
  47797. /**
  47798. * Attach the input controls to a specific dom element to get the input from.
  47799. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47800. */
  47801. attachControl(noPreventDefault?: boolean): void;
  47802. /**
  47803. * Detach the current controls from the specified dom element.
  47804. */
  47805. detachControl(): void;
  47806. /**
  47807. * Gets the class name of the current intput.
  47808. * @returns the class name
  47809. */
  47810. getClassName(): string;
  47811. /**
  47812. * Get the friendly name associated with the input class.
  47813. * @returns the input friendly name
  47814. */
  47815. getSimpleName(): string;
  47816. }
  47817. }
  47818. declare module BABYLON {
  47819. /**
  47820. * Manage the pointers inputs to control an follow camera.
  47821. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47822. */
  47823. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  47824. /**
  47825. * Defines the camera the input is attached to.
  47826. */
  47827. camera: FollowCamera;
  47828. /**
  47829. * Gets the class name of the current input.
  47830. * @returns the class name
  47831. */
  47832. getClassName(): string;
  47833. /**
  47834. * Defines the pointer angular sensibility along the X axis or how fast is
  47835. * the camera rotating.
  47836. * A negative number will reverse the axis direction.
  47837. */
  47838. angularSensibilityX: number;
  47839. /**
  47840. * Defines the pointer angular sensibility along the Y axis or how fast is
  47841. * the camera rotating.
  47842. * A negative number will reverse the axis direction.
  47843. */
  47844. angularSensibilityY: number;
  47845. /**
  47846. * Defines the pointer pinch precision or how fast is the camera zooming.
  47847. * A negative number will reverse the axis direction.
  47848. */
  47849. pinchPrecision: number;
  47850. /**
  47851. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  47852. * from 0.
  47853. * It defines the percentage of current camera.radius to use as delta when
  47854. * pinch zoom is used.
  47855. */
  47856. pinchDeltaPercentage: number;
  47857. /**
  47858. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  47859. */
  47860. axisXControlRadius: boolean;
  47861. /**
  47862. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  47863. */
  47864. axisXControlHeight: boolean;
  47865. /**
  47866. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  47867. */
  47868. axisXControlRotation: boolean;
  47869. /**
  47870. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  47871. */
  47872. axisYControlRadius: boolean;
  47873. /**
  47874. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  47875. */
  47876. axisYControlHeight: boolean;
  47877. /**
  47878. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  47879. */
  47880. axisYControlRotation: boolean;
  47881. /**
  47882. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  47883. */
  47884. axisPinchControlRadius: boolean;
  47885. /**
  47886. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  47887. */
  47888. axisPinchControlHeight: boolean;
  47889. /**
  47890. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  47891. */
  47892. axisPinchControlRotation: boolean;
  47893. /**
  47894. * Log error messages if basic misconfiguration has occurred.
  47895. */
  47896. warningEnable: boolean;
  47897. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  47898. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  47899. private _warningCounter;
  47900. private _warning;
  47901. }
  47902. }
  47903. declare module BABYLON {
  47904. /**
  47905. * Default Inputs manager for the FollowCamera.
  47906. * It groups all the default supported inputs for ease of use.
  47907. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47908. */
  47909. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  47910. /**
  47911. * Instantiates a new FollowCameraInputsManager.
  47912. * @param camera Defines the camera the inputs belong to
  47913. */
  47914. constructor(camera: FollowCamera);
  47915. /**
  47916. * Add keyboard input support to the input manager.
  47917. * @returns the current input manager
  47918. */
  47919. addKeyboard(): FollowCameraInputsManager;
  47920. /**
  47921. * Add mouse wheel input support to the input manager.
  47922. * @returns the current input manager
  47923. */
  47924. addMouseWheel(): FollowCameraInputsManager;
  47925. /**
  47926. * Add pointers input support to the input manager.
  47927. * @returns the current input manager
  47928. */
  47929. addPointers(): FollowCameraInputsManager;
  47930. /**
  47931. * Add orientation input support to the input manager.
  47932. * @returns the current input manager
  47933. */
  47934. addVRDeviceOrientation(): FollowCameraInputsManager;
  47935. }
  47936. }
  47937. declare module BABYLON {
  47938. /**
  47939. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  47940. * an arc rotate version arcFollowCamera are available.
  47941. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  47942. */
  47943. export class FollowCamera extends TargetCamera {
  47944. /**
  47945. * Distance the follow camera should follow an object at
  47946. */
  47947. radius: number;
  47948. /**
  47949. * Minimum allowed distance of the camera to the axis of rotation
  47950. * (The camera can not get closer).
  47951. * This can help limiting how the Camera is able to move in the scene.
  47952. */
  47953. lowerRadiusLimit: Nullable<number>;
  47954. /**
  47955. * Maximum allowed distance of the camera to the axis of rotation
  47956. * (The camera can not get further).
  47957. * This can help limiting how the Camera is able to move in the scene.
  47958. */
  47959. upperRadiusLimit: Nullable<number>;
  47960. /**
  47961. * Define a rotation offset between the camera and the object it follows
  47962. */
  47963. rotationOffset: number;
  47964. /**
  47965. * Minimum allowed angle to camera position relative to target object.
  47966. * This can help limiting how the Camera is able to move in the scene.
  47967. */
  47968. lowerRotationOffsetLimit: Nullable<number>;
  47969. /**
  47970. * Maximum allowed angle to camera position relative to target object.
  47971. * This can help limiting how the Camera is able to move in the scene.
  47972. */
  47973. upperRotationOffsetLimit: Nullable<number>;
  47974. /**
  47975. * Define a height offset between the camera and the object it follows.
  47976. * It can help following an object from the top (like a car chaing a plane)
  47977. */
  47978. heightOffset: number;
  47979. /**
  47980. * Minimum allowed height of camera position relative to target object.
  47981. * This can help limiting how the Camera is able to move in the scene.
  47982. */
  47983. lowerHeightOffsetLimit: Nullable<number>;
  47984. /**
  47985. * Maximum allowed height of camera position relative to target object.
  47986. * This can help limiting how the Camera is able to move in the scene.
  47987. */
  47988. upperHeightOffsetLimit: Nullable<number>;
  47989. /**
  47990. * Define how fast the camera can accelerate to follow it s target.
  47991. */
  47992. cameraAcceleration: number;
  47993. /**
  47994. * Define the speed limit of the camera following an object.
  47995. */
  47996. maxCameraSpeed: number;
  47997. /**
  47998. * Define the target of the camera.
  47999. */
  48000. lockedTarget: Nullable<AbstractMesh>;
  48001. /**
  48002. * Defines the input associated with the camera.
  48003. */
  48004. inputs: FollowCameraInputsManager;
  48005. /**
  48006. * Instantiates the follow camera.
  48007. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48008. * @param name Define the name of the camera in the scene
  48009. * @param position Define the position of the camera
  48010. * @param scene Define the scene the camera belong to
  48011. * @param lockedTarget Define the target of the camera
  48012. */
  48013. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  48014. private _follow;
  48015. /**
  48016. * Attached controls to the current camera.
  48017. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48018. */
  48019. attachControl(noPreventDefault?: boolean): void;
  48020. /**
  48021. * Detach the current controls from the camera.
  48022. * The camera will stop reacting to inputs.
  48023. */
  48024. detachControl(): void;
  48025. /** @hidden */
  48026. _checkInputs(): void;
  48027. private _checkLimits;
  48028. /**
  48029. * Gets the camera class name.
  48030. * @returns the class name
  48031. */
  48032. getClassName(): string;
  48033. }
  48034. /**
  48035. * Arc Rotate version of the follow camera.
  48036. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  48037. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48038. */
  48039. export class ArcFollowCamera extends TargetCamera {
  48040. /** The longitudinal angle of the camera */
  48041. alpha: number;
  48042. /** The latitudinal angle of the camera */
  48043. beta: number;
  48044. /** The radius of the camera from its target */
  48045. radius: number;
  48046. private _cartesianCoordinates;
  48047. /** Define the camera target (the mesh it should follow) */
  48048. private _meshTarget;
  48049. /**
  48050. * Instantiates a new ArcFollowCamera
  48051. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48052. * @param name Define the name of the camera
  48053. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  48054. * @param beta Define the rotation angle of the camera around the elevation axis
  48055. * @param radius Define the radius of the camera from its target point
  48056. * @param target Define the target of the camera
  48057. * @param scene Define the scene the camera belongs to
  48058. */
  48059. constructor(name: string,
  48060. /** The longitudinal angle of the camera */
  48061. alpha: number,
  48062. /** The latitudinal angle of the camera */
  48063. beta: number,
  48064. /** The radius of the camera from its target */
  48065. radius: number,
  48066. /** Define the camera target (the mesh it should follow) */
  48067. target: Nullable<AbstractMesh>, scene: Scene);
  48068. private _follow;
  48069. /** @hidden */
  48070. _checkInputs(): void;
  48071. /**
  48072. * Returns the class name of the object.
  48073. * It is mostly used internally for serialization purposes.
  48074. */
  48075. getClassName(): string;
  48076. }
  48077. }
  48078. declare module BABYLON {
  48079. /**
  48080. * Manage the keyboard inputs to control the movement of a follow camera.
  48081. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48082. */
  48083. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  48084. /**
  48085. * Defines the camera the input is attached to.
  48086. */
  48087. camera: FollowCamera;
  48088. /**
  48089. * Defines the list of key codes associated with the up action (increase heightOffset)
  48090. */
  48091. keysHeightOffsetIncr: number[];
  48092. /**
  48093. * Defines the list of key codes associated with the down action (decrease heightOffset)
  48094. */
  48095. keysHeightOffsetDecr: number[];
  48096. /**
  48097. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  48098. */
  48099. keysHeightOffsetModifierAlt: boolean;
  48100. /**
  48101. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  48102. */
  48103. keysHeightOffsetModifierCtrl: boolean;
  48104. /**
  48105. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  48106. */
  48107. keysHeightOffsetModifierShift: boolean;
  48108. /**
  48109. * Defines the list of key codes associated with the left action (increase rotationOffset)
  48110. */
  48111. keysRotationOffsetIncr: number[];
  48112. /**
  48113. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  48114. */
  48115. keysRotationOffsetDecr: number[];
  48116. /**
  48117. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  48118. */
  48119. keysRotationOffsetModifierAlt: boolean;
  48120. /**
  48121. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  48122. */
  48123. keysRotationOffsetModifierCtrl: boolean;
  48124. /**
  48125. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  48126. */
  48127. keysRotationOffsetModifierShift: boolean;
  48128. /**
  48129. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  48130. */
  48131. keysRadiusIncr: number[];
  48132. /**
  48133. * Defines the list of key codes associated with the zoom-out action (increase radius)
  48134. */
  48135. keysRadiusDecr: number[];
  48136. /**
  48137. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  48138. */
  48139. keysRadiusModifierAlt: boolean;
  48140. /**
  48141. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  48142. */
  48143. keysRadiusModifierCtrl: boolean;
  48144. /**
  48145. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  48146. */
  48147. keysRadiusModifierShift: boolean;
  48148. /**
  48149. * Defines the rate of change of heightOffset.
  48150. */
  48151. heightSensibility: number;
  48152. /**
  48153. * Defines the rate of change of rotationOffset.
  48154. */
  48155. rotationSensibility: number;
  48156. /**
  48157. * Defines the rate of change of radius.
  48158. */
  48159. radiusSensibility: number;
  48160. private _keys;
  48161. private _ctrlPressed;
  48162. private _altPressed;
  48163. private _shiftPressed;
  48164. private _onCanvasBlurObserver;
  48165. private _onKeyboardObserver;
  48166. private _engine;
  48167. private _scene;
  48168. /**
  48169. * Attach the input controls to a specific dom element to get the input from.
  48170. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48171. */
  48172. attachControl(noPreventDefault?: boolean): void;
  48173. /**
  48174. * Detach the current controls from the specified dom element.
  48175. */
  48176. detachControl(): void;
  48177. /**
  48178. * Update the current camera state depending on the inputs that have been used this frame.
  48179. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48180. */
  48181. checkInputs(): void;
  48182. /**
  48183. * Gets the class name of the current input.
  48184. * @returns the class name
  48185. */
  48186. getClassName(): string;
  48187. /**
  48188. * Get the friendly name associated with the input class.
  48189. * @returns the input friendly name
  48190. */
  48191. getSimpleName(): string;
  48192. /**
  48193. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48194. * allow modification of the heightOffset value.
  48195. */
  48196. private _modifierHeightOffset;
  48197. /**
  48198. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48199. * allow modification of the rotationOffset value.
  48200. */
  48201. private _modifierRotationOffset;
  48202. /**
  48203. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48204. * allow modification of the radius value.
  48205. */
  48206. private _modifierRadius;
  48207. }
  48208. }
  48209. declare module BABYLON {
  48210. interface FreeCameraInputsManager {
  48211. /**
  48212. * @hidden
  48213. */
  48214. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  48215. /**
  48216. * Add orientation input support to the input manager.
  48217. * @returns the current input manager
  48218. */
  48219. addDeviceOrientation(): FreeCameraInputsManager;
  48220. }
  48221. /**
  48222. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  48223. * Screen rotation is taken into account.
  48224. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48225. */
  48226. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  48227. private _camera;
  48228. private _screenOrientationAngle;
  48229. private _constantTranform;
  48230. private _screenQuaternion;
  48231. private _alpha;
  48232. private _beta;
  48233. private _gamma;
  48234. /**
  48235. * Can be used to detect if a device orientation sensor is available on a device
  48236. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  48237. * @returns a promise that will resolve on orientation change
  48238. */
  48239. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  48240. /**
  48241. * @hidden
  48242. */
  48243. _onDeviceOrientationChangedObservable: Observable<void>;
  48244. /**
  48245. * Instantiates a new input
  48246. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48247. */
  48248. constructor();
  48249. /**
  48250. * Define the camera controlled by the input.
  48251. */
  48252. get camera(): FreeCamera;
  48253. set camera(camera: FreeCamera);
  48254. /**
  48255. * Attach the input controls to a specific dom element to get the input from.
  48256. */
  48257. attachControl(): void;
  48258. private _orientationChanged;
  48259. private _deviceOrientation;
  48260. /**
  48261. * Detach the current controls from the specified dom element.
  48262. */
  48263. detachControl(): void;
  48264. /**
  48265. * Update the current camera state depending on the inputs that have been used this frame.
  48266. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48267. */
  48268. checkInputs(): void;
  48269. /**
  48270. * Gets the class name of the current intput.
  48271. * @returns the class name
  48272. */
  48273. getClassName(): string;
  48274. /**
  48275. * Get the friendly name associated with the input class.
  48276. * @returns the input friendly name
  48277. */
  48278. getSimpleName(): string;
  48279. }
  48280. }
  48281. declare module BABYLON {
  48282. /**
  48283. * Manage the gamepad inputs to control a free camera.
  48284. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48285. */
  48286. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  48287. /**
  48288. * Define the camera the input is attached to.
  48289. */
  48290. camera: FreeCamera;
  48291. /**
  48292. * Define the Gamepad controlling the input
  48293. */
  48294. gamepad: Nullable<Gamepad>;
  48295. /**
  48296. * Defines the gamepad rotation sensiblity.
  48297. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  48298. */
  48299. gamepadAngularSensibility: number;
  48300. /**
  48301. * Defines the gamepad move sensiblity.
  48302. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  48303. */
  48304. gamepadMoveSensibility: number;
  48305. private _yAxisScale;
  48306. /**
  48307. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  48308. */
  48309. get invertYAxis(): boolean;
  48310. set invertYAxis(value: boolean);
  48311. private _onGamepadConnectedObserver;
  48312. private _onGamepadDisconnectedObserver;
  48313. private _cameraTransform;
  48314. private _deltaTransform;
  48315. private _vector3;
  48316. private _vector2;
  48317. /**
  48318. * Attach the input controls to a specific dom element to get the input from.
  48319. */
  48320. attachControl(): void;
  48321. /**
  48322. * Detach the current controls from the specified dom element.
  48323. */
  48324. detachControl(): void;
  48325. /**
  48326. * Update the current camera state depending on the inputs that have been used this frame.
  48327. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48328. */
  48329. checkInputs(): void;
  48330. /**
  48331. * Gets the class name of the current intput.
  48332. * @returns the class name
  48333. */
  48334. getClassName(): string;
  48335. /**
  48336. * Get the friendly name associated with the input class.
  48337. * @returns the input friendly name
  48338. */
  48339. getSimpleName(): string;
  48340. }
  48341. }
  48342. declare module BABYLON {
  48343. /**
  48344. * Defines the potential axis of a Joystick
  48345. */
  48346. export enum JoystickAxis {
  48347. /** X axis */
  48348. X = 0,
  48349. /** Y axis */
  48350. Y = 1,
  48351. /** Z axis */
  48352. Z = 2
  48353. }
  48354. /**
  48355. * Represents the different customization options available
  48356. * for VirtualJoystick
  48357. */
  48358. interface VirtualJoystickCustomizations {
  48359. /**
  48360. * Size of the joystick's puck
  48361. */
  48362. puckSize: number;
  48363. /**
  48364. * Size of the joystick's container
  48365. */
  48366. containerSize: number;
  48367. /**
  48368. * Color of the joystick && puck
  48369. */
  48370. color: string;
  48371. /**
  48372. * Image URL for the joystick's puck
  48373. */
  48374. puckImage?: string;
  48375. /**
  48376. * Image URL for the joystick's container
  48377. */
  48378. containerImage?: string;
  48379. /**
  48380. * Defines the unmoving position of the joystick container
  48381. */
  48382. position?: {
  48383. x: number;
  48384. y: number;
  48385. };
  48386. /**
  48387. * Defines whether or not the joystick container is always visible
  48388. */
  48389. alwaysVisible: boolean;
  48390. /**
  48391. * Defines whether or not to limit the movement of the puck to the joystick's container
  48392. */
  48393. limitToContainer: boolean;
  48394. }
  48395. /**
  48396. * Class used to define virtual joystick (used in touch mode)
  48397. */
  48398. export class VirtualJoystick {
  48399. /**
  48400. * Gets or sets a boolean indicating that left and right values must be inverted
  48401. */
  48402. reverseLeftRight: boolean;
  48403. /**
  48404. * Gets or sets a boolean indicating that up and down values must be inverted
  48405. */
  48406. reverseUpDown: boolean;
  48407. /**
  48408. * Gets the offset value for the position (ie. the change of the position value)
  48409. */
  48410. deltaPosition: Vector3;
  48411. /**
  48412. * Gets a boolean indicating if the virtual joystick was pressed
  48413. */
  48414. pressed: boolean;
  48415. /**
  48416. * Canvas the virtual joystick will render onto, default z-index of this is 5
  48417. */
  48418. static Canvas: Nullable<HTMLCanvasElement>;
  48419. /**
  48420. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  48421. */
  48422. limitToContainer: boolean;
  48423. private static _globalJoystickIndex;
  48424. private static _alwaysVisibleSticks;
  48425. private static vjCanvasContext;
  48426. private static vjCanvasWidth;
  48427. private static vjCanvasHeight;
  48428. private static halfWidth;
  48429. private static _GetDefaultOptions;
  48430. private _action;
  48431. private _axisTargetedByLeftAndRight;
  48432. private _axisTargetedByUpAndDown;
  48433. private _joystickSensibility;
  48434. private _inversedSensibility;
  48435. private _joystickPointerID;
  48436. private _joystickColor;
  48437. private _joystickPointerPos;
  48438. private _joystickPreviousPointerPos;
  48439. private _joystickPointerStartPos;
  48440. private _deltaJoystickVector;
  48441. private _leftJoystick;
  48442. private _touches;
  48443. private _joystickPosition;
  48444. private _alwaysVisible;
  48445. private _puckImage;
  48446. private _containerImage;
  48447. private _joystickPuckSize;
  48448. private _joystickContainerSize;
  48449. private _clearPuckSize;
  48450. private _clearContainerSize;
  48451. private _clearPuckSizeOffset;
  48452. private _clearContainerSizeOffset;
  48453. private _onPointerDownHandlerRef;
  48454. private _onPointerMoveHandlerRef;
  48455. private _onPointerUpHandlerRef;
  48456. private _onResize;
  48457. /**
  48458. * Creates a new virtual joystick
  48459. * @param leftJoystick defines that the joystick is for left hand (false by default)
  48460. * @param customizations Defines the options we want to customize the VirtualJoystick
  48461. */
  48462. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  48463. /**
  48464. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  48465. * @param newJoystickSensibility defines the new sensibility
  48466. */
  48467. setJoystickSensibility(newJoystickSensibility: number): void;
  48468. private _onPointerDown;
  48469. private _onPointerMove;
  48470. private _onPointerUp;
  48471. /**
  48472. * Change the color of the virtual joystick
  48473. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  48474. */
  48475. setJoystickColor(newColor: string): void;
  48476. /**
  48477. * Size of the joystick's container
  48478. */
  48479. set containerSize(newSize: number);
  48480. get containerSize(): number;
  48481. /**
  48482. * Size of the joystick's puck
  48483. */
  48484. set puckSize(newSize: number);
  48485. get puckSize(): number;
  48486. /**
  48487. * Clears the set position of the joystick
  48488. */
  48489. clearPosition(): void;
  48490. /**
  48491. * Defines whether or not the joystick container is always visible
  48492. */
  48493. set alwaysVisible(value: boolean);
  48494. get alwaysVisible(): boolean;
  48495. /**
  48496. * Sets the constant position of the Joystick container
  48497. * @param x X axis coordinate
  48498. * @param y Y axis coordinate
  48499. */
  48500. setPosition(x: number, y: number): void;
  48501. /**
  48502. * Defines a callback to call when the joystick is touched
  48503. * @param action defines the callback
  48504. */
  48505. setActionOnTouch(action: () => any): void;
  48506. /**
  48507. * Defines which axis you'd like to control for left & right
  48508. * @param axis defines the axis to use
  48509. */
  48510. setAxisForLeftRight(axis: JoystickAxis): void;
  48511. /**
  48512. * Defines which axis you'd like to control for up & down
  48513. * @param axis defines the axis to use
  48514. */
  48515. setAxisForUpDown(axis: JoystickAxis): void;
  48516. /**
  48517. * Clears the canvas from the previous puck / container draw
  48518. */
  48519. private _clearPreviousDraw;
  48520. /**
  48521. * Loads `urlPath` to be used for the container's image
  48522. * @param urlPath defines the urlPath of an image to use
  48523. */
  48524. setContainerImage(urlPath: string): void;
  48525. /**
  48526. * Loads `urlPath` to be used for the puck's image
  48527. * @param urlPath defines the urlPath of an image to use
  48528. */
  48529. setPuckImage(urlPath: string): void;
  48530. /**
  48531. * Draws the Virtual Joystick's container
  48532. */
  48533. private _drawContainer;
  48534. /**
  48535. * Draws the Virtual Joystick's puck
  48536. */
  48537. private _drawPuck;
  48538. private _drawVirtualJoystick;
  48539. /**
  48540. * Release internal HTML canvas
  48541. */
  48542. releaseCanvas(): void;
  48543. }
  48544. }
  48545. declare module BABYLON {
  48546. interface FreeCameraInputsManager {
  48547. /**
  48548. * Add virtual joystick input support to the input manager.
  48549. * @returns the current input manager
  48550. */
  48551. addVirtualJoystick(): FreeCameraInputsManager;
  48552. }
  48553. /**
  48554. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  48555. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48556. */
  48557. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  48558. /**
  48559. * Defines the camera the input is attached to.
  48560. */
  48561. camera: FreeCamera;
  48562. private _leftjoystick;
  48563. private _rightjoystick;
  48564. /**
  48565. * Gets the left stick of the virtual joystick.
  48566. * @returns The virtual Joystick
  48567. */
  48568. getLeftJoystick(): VirtualJoystick;
  48569. /**
  48570. * Gets the right stick of the virtual joystick.
  48571. * @returns The virtual Joystick
  48572. */
  48573. getRightJoystick(): VirtualJoystick;
  48574. /**
  48575. * Update the current camera state depending on the inputs that have been used this frame.
  48576. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48577. */
  48578. checkInputs(): void;
  48579. /**
  48580. * Attach the input controls to a specific dom element to get the input from.
  48581. */
  48582. attachControl(): void;
  48583. /**
  48584. * Detach the current controls from the specified dom element.
  48585. */
  48586. detachControl(): void;
  48587. /**
  48588. * Gets the class name of the current intput.
  48589. * @returns the class name
  48590. */
  48591. getClassName(): string;
  48592. /**
  48593. * Get the friendly name associated with the input class.
  48594. * @returns the input friendly name
  48595. */
  48596. getSimpleName(): string;
  48597. }
  48598. }
  48599. declare module BABYLON {
  48600. /**
  48601. * This represents a FPS type of camera controlled by touch.
  48602. * This is like a universal camera minus the Gamepad controls.
  48603. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48604. */
  48605. export class TouchCamera extends FreeCamera {
  48606. /**
  48607. * Defines the touch sensibility for rotation.
  48608. * The higher the faster.
  48609. */
  48610. get touchAngularSensibility(): number;
  48611. set touchAngularSensibility(value: number);
  48612. /**
  48613. * Defines the touch sensibility for move.
  48614. * The higher the faster.
  48615. */
  48616. get touchMoveSensibility(): number;
  48617. set touchMoveSensibility(value: number);
  48618. /**
  48619. * Instantiates a new touch camera.
  48620. * This represents a FPS type of camera controlled by touch.
  48621. * This is like a universal camera minus the Gamepad controls.
  48622. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48623. * @param name Define the name of the camera in the scene
  48624. * @param position Define the start position of the camera in the scene
  48625. * @param scene Define the scene the camera belongs to
  48626. */
  48627. constructor(name: string, position: Vector3, scene: Scene);
  48628. /**
  48629. * Gets the current object class name.
  48630. * @return the class name
  48631. */
  48632. getClassName(): string;
  48633. /** @hidden */
  48634. _setupInputs(): void;
  48635. }
  48636. }
  48637. declare module BABYLON {
  48638. /**
  48639. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  48640. * being tilted forward or back and left or right.
  48641. */
  48642. export class DeviceOrientationCamera extends FreeCamera {
  48643. private _initialQuaternion;
  48644. private _quaternionCache;
  48645. private _tmpDragQuaternion;
  48646. private _disablePointerInputWhenUsingDeviceOrientation;
  48647. /**
  48648. * Creates a new device orientation camera
  48649. * @param name The name of the camera
  48650. * @param position The start position camera
  48651. * @param scene The scene the camera belongs to
  48652. */
  48653. constructor(name: string, position: Vector3, scene: Scene);
  48654. /**
  48655. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  48656. */
  48657. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  48658. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  48659. private _dragFactor;
  48660. /**
  48661. * Enabled turning on the y axis when the orientation sensor is active
  48662. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  48663. */
  48664. enableHorizontalDragging(dragFactor?: number): void;
  48665. /**
  48666. * Gets the current instance class name ("DeviceOrientationCamera").
  48667. * This helps avoiding instanceof at run time.
  48668. * @returns the class name
  48669. */
  48670. getClassName(): string;
  48671. /**
  48672. * @hidden
  48673. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  48674. */
  48675. _checkInputs(): void;
  48676. /**
  48677. * Reset the camera to its default orientation on the specified axis only.
  48678. * @param axis The axis to reset
  48679. */
  48680. resetToCurrentRotation(axis?: Axis): void;
  48681. }
  48682. }
  48683. declare module BABYLON {
  48684. /**
  48685. * Defines supported buttons for XBox360 compatible gamepads
  48686. */
  48687. export enum Xbox360Button {
  48688. /** A */
  48689. A = 0,
  48690. /** B */
  48691. B = 1,
  48692. /** X */
  48693. X = 2,
  48694. /** Y */
  48695. Y = 3,
  48696. /** Left button */
  48697. LB = 4,
  48698. /** Right button */
  48699. RB = 5,
  48700. /** Back */
  48701. Back = 8,
  48702. /** Start */
  48703. Start = 9,
  48704. /** Left stick */
  48705. LeftStick = 10,
  48706. /** Right stick */
  48707. RightStick = 11
  48708. }
  48709. /** Defines values for XBox360 DPad */
  48710. export enum Xbox360Dpad {
  48711. /** Up */
  48712. Up = 12,
  48713. /** Down */
  48714. Down = 13,
  48715. /** Left */
  48716. Left = 14,
  48717. /** Right */
  48718. Right = 15
  48719. }
  48720. /**
  48721. * Defines a XBox360 gamepad
  48722. */
  48723. export class Xbox360Pad extends Gamepad {
  48724. private _leftTrigger;
  48725. private _rightTrigger;
  48726. private _onlefttriggerchanged;
  48727. private _onrighttriggerchanged;
  48728. private _onbuttondown;
  48729. private _onbuttonup;
  48730. private _ondpaddown;
  48731. private _ondpadup;
  48732. /** Observable raised when a button is pressed */
  48733. onButtonDownObservable: Observable<Xbox360Button>;
  48734. /** Observable raised when a button is released */
  48735. onButtonUpObservable: Observable<Xbox360Button>;
  48736. /** Observable raised when a pad is pressed */
  48737. onPadDownObservable: Observable<Xbox360Dpad>;
  48738. /** Observable raised when a pad is released */
  48739. onPadUpObservable: Observable<Xbox360Dpad>;
  48740. private _buttonA;
  48741. private _buttonB;
  48742. private _buttonX;
  48743. private _buttonY;
  48744. private _buttonBack;
  48745. private _buttonStart;
  48746. private _buttonLB;
  48747. private _buttonRB;
  48748. private _buttonLeftStick;
  48749. private _buttonRightStick;
  48750. private _dPadUp;
  48751. private _dPadDown;
  48752. private _dPadLeft;
  48753. private _dPadRight;
  48754. private _isXboxOnePad;
  48755. /**
  48756. * Creates a new XBox360 gamepad object
  48757. * @param id defines the id of this gamepad
  48758. * @param index defines its index
  48759. * @param gamepad defines the internal HTML gamepad object
  48760. * @param xboxOne defines if it is a XBox One gamepad
  48761. */
  48762. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  48763. /**
  48764. * Defines the callback to call when left trigger is pressed
  48765. * @param callback defines the callback to use
  48766. */
  48767. onlefttriggerchanged(callback: (value: number) => void): void;
  48768. /**
  48769. * Defines the callback to call when right trigger is pressed
  48770. * @param callback defines the callback to use
  48771. */
  48772. onrighttriggerchanged(callback: (value: number) => void): void;
  48773. /**
  48774. * Gets the left trigger value
  48775. */
  48776. get leftTrigger(): number;
  48777. /**
  48778. * Sets the left trigger value
  48779. */
  48780. set leftTrigger(newValue: number);
  48781. /**
  48782. * Gets the right trigger value
  48783. */
  48784. get rightTrigger(): number;
  48785. /**
  48786. * Sets the right trigger value
  48787. */
  48788. set rightTrigger(newValue: number);
  48789. /**
  48790. * Defines the callback to call when a button is pressed
  48791. * @param callback defines the callback to use
  48792. */
  48793. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  48794. /**
  48795. * Defines the callback to call when a button is released
  48796. * @param callback defines the callback to use
  48797. */
  48798. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  48799. /**
  48800. * Defines the callback to call when a pad is pressed
  48801. * @param callback defines the callback to use
  48802. */
  48803. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  48804. /**
  48805. * Defines the callback to call when a pad is released
  48806. * @param callback defines the callback to use
  48807. */
  48808. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  48809. private _setButtonValue;
  48810. private _setDPadValue;
  48811. /**
  48812. * Gets the value of the `A` button
  48813. */
  48814. get buttonA(): number;
  48815. /**
  48816. * Sets the value of the `A` button
  48817. */
  48818. set buttonA(value: number);
  48819. /**
  48820. * Gets the value of the `B` button
  48821. */
  48822. get buttonB(): number;
  48823. /**
  48824. * Sets the value of the `B` button
  48825. */
  48826. set buttonB(value: number);
  48827. /**
  48828. * Gets the value of the `X` button
  48829. */
  48830. get buttonX(): number;
  48831. /**
  48832. * Sets the value of the `X` button
  48833. */
  48834. set buttonX(value: number);
  48835. /**
  48836. * Gets the value of the `Y` button
  48837. */
  48838. get buttonY(): number;
  48839. /**
  48840. * Sets the value of the `Y` button
  48841. */
  48842. set buttonY(value: number);
  48843. /**
  48844. * Gets the value of the `Start` button
  48845. */
  48846. get buttonStart(): number;
  48847. /**
  48848. * Sets the value of the `Start` button
  48849. */
  48850. set buttonStart(value: number);
  48851. /**
  48852. * Gets the value of the `Back` button
  48853. */
  48854. get buttonBack(): number;
  48855. /**
  48856. * Sets the value of the `Back` button
  48857. */
  48858. set buttonBack(value: number);
  48859. /**
  48860. * Gets the value of the `Left` button
  48861. */
  48862. get buttonLB(): number;
  48863. /**
  48864. * Sets the value of the `Left` button
  48865. */
  48866. set buttonLB(value: number);
  48867. /**
  48868. * Gets the value of the `Right` button
  48869. */
  48870. get buttonRB(): number;
  48871. /**
  48872. * Sets the value of the `Right` button
  48873. */
  48874. set buttonRB(value: number);
  48875. /**
  48876. * Gets the value of the Left joystick
  48877. */
  48878. get buttonLeftStick(): number;
  48879. /**
  48880. * Sets the value of the Left joystick
  48881. */
  48882. set buttonLeftStick(value: number);
  48883. /**
  48884. * Gets the value of the Right joystick
  48885. */
  48886. get buttonRightStick(): number;
  48887. /**
  48888. * Sets the value of the Right joystick
  48889. */
  48890. set buttonRightStick(value: number);
  48891. /**
  48892. * Gets the value of D-pad up
  48893. */
  48894. get dPadUp(): number;
  48895. /**
  48896. * Sets the value of D-pad up
  48897. */
  48898. set dPadUp(value: number);
  48899. /**
  48900. * Gets the value of D-pad down
  48901. */
  48902. get dPadDown(): number;
  48903. /**
  48904. * Sets the value of D-pad down
  48905. */
  48906. set dPadDown(value: number);
  48907. /**
  48908. * Gets the value of D-pad left
  48909. */
  48910. get dPadLeft(): number;
  48911. /**
  48912. * Sets the value of D-pad left
  48913. */
  48914. set dPadLeft(value: number);
  48915. /**
  48916. * Gets the value of D-pad right
  48917. */
  48918. get dPadRight(): number;
  48919. /**
  48920. * Sets the value of D-pad right
  48921. */
  48922. set dPadRight(value: number);
  48923. /**
  48924. * Force the gamepad to synchronize with device values
  48925. */
  48926. update(): void;
  48927. /**
  48928. * Disposes the gamepad
  48929. */
  48930. dispose(): void;
  48931. }
  48932. }
  48933. declare module BABYLON {
  48934. /**
  48935. * Defines supported buttons for DualShock compatible gamepads
  48936. */
  48937. export enum DualShockButton {
  48938. /** Cross */
  48939. Cross = 0,
  48940. /** Circle */
  48941. Circle = 1,
  48942. /** Square */
  48943. Square = 2,
  48944. /** Triangle */
  48945. Triangle = 3,
  48946. /** L1 */
  48947. L1 = 4,
  48948. /** R1 */
  48949. R1 = 5,
  48950. /** Share */
  48951. Share = 8,
  48952. /** Options */
  48953. Options = 9,
  48954. /** Left stick */
  48955. LeftStick = 10,
  48956. /** Right stick */
  48957. RightStick = 11
  48958. }
  48959. /** Defines values for DualShock DPad */
  48960. export enum DualShockDpad {
  48961. /** Up */
  48962. Up = 12,
  48963. /** Down */
  48964. Down = 13,
  48965. /** Left */
  48966. Left = 14,
  48967. /** Right */
  48968. Right = 15
  48969. }
  48970. /**
  48971. * Defines a DualShock gamepad
  48972. */
  48973. export class DualShockPad extends Gamepad {
  48974. private _leftTrigger;
  48975. private _rightTrigger;
  48976. private _onlefttriggerchanged;
  48977. private _onrighttriggerchanged;
  48978. private _onbuttondown;
  48979. private _onbuttonup;
  48980. private _ondpaddown;
  48981. private _ondpadup;
  48982. /** Observable raised when a button is pressed */
  48983. onButtonDownObservable: Observable<DualShockButton>;
  48984. /** Observable raised when a button is released */
  48985. onButtonUpObservable: Observable<DualShockButton>;
  48986. /** Observable raised when a pad is pressed */
  48987. onPadDownObservable: Observable<DualShockDpad>;
  48988. /** Observable raised when a pad is released */
  48989. onPadUpObservable: Observable<DualShockDpad>;
  48990. private _buttonCross;
  48991. private _buttonCircle;
  48992. private _buttonSquare;
  48993. private _buttonTriangle;
  48994. private _buttonShare;
  48995. private _buttonOptions;
  48996. private _buttonL1;
  48997. private _buttonR1;
  48998. private _buttonLeftStick;
  48999. private _buttonRightStick;
  49000. private _dPadUp;
  49001. private _dPadDown;
  49002. private _dPadLeft;
  49003. private _dPadRight;
  49004. /**
  49005. * Creates a new DualShock gamepad object
  49006. * @param id defines the id of this gamepad
  49007. * @param index defines its index
  49008. * @param gamepad defines the internal HTML gamepad object
  49009. */
  49010. constructor(id: string, index: number, gamepad: any);
  49011. /**
  49012. * Defines the callback to call when left trigger is pressed
  49013. * @param callback defines the callback to use
  49014. */
  49015. onlefttriggerchanged(callback: (value: number) => void): void;
  49016. /**
  49017. * Defines the callback to call when right trigger is pressed
  49018. * @param callback defines the callback to use
  49019. */
  49020. onrighttriggerchanged(callback: (value: number) => void): void;
  49021. /**
  49022. * Gets the left trigger value
  49023. */
  49024. get leftTrigger(): number;
  49025. /**
  49026. * Sets the left trigger value
  49027. */
  49028. set leftTrigger(newValue: number);
  49029. /**
  49030. * Gets the right trigger value
  49031. */
  49032. get rightTrigger(): number;
  49033. /**
  49034. * Sets the right trigger value
  49035. */
  49036. set rightTrigger(newValue: number);
  49037. /**
  49038. * Defines the callback to call when a button is pressed
  49039. * @param callback defines the callback to use
  49040. */
  49041. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  49042. /**
  49043. * Defines the callback to call when a button is released
  49044. * @param callback defines the callback to use
  49045. */
  49046. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  49047. /**
  49048. * Defines the callback to call when a pad is pressed
  49049. * @param callback defines the callback to use
  49050. */
  49051. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  49052. /**
  49053. * Defines the callback to call when a pad is released
  49054. * @param callback defines the callback to use
  49055. */
  49056. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  49057. private _setButtonValue;
  49058. private _setDPadValue;
  49059. /**
  49060. * Gets the value of the `Cross` button
  49061. */
  49062. get buttonCross(): number;
  49063. /**
  49064. * Sets the value of the `Cross` button
  49065. */
  49066. set buttonCross(value: number);
  49067. /**
  49068. * Gets the value of the `Circle` button
  49069. */
  49070. get buttonCircle(): number;
  49071. /**
  49072. * Sets the value of the `Circle` button
  49073. */
  49074. set buttonCircle(value: number);
  49075. /**
  49076. * Gets the value of the `Square` button
  49077. */
  49078. get buttonSquare(): number;
  49079. /**
  49080. * Sets the value of the `Square` button
  49081. */
  49082. set buttonSquare(value: number);
  49083. /**
  49084. * Gets the value of the `Triangle` button
  49085. */
  49086. get buttonTriangle(): number;
  49087. /**
  49088. * Sets the value of the `Triangle` button
  49089. */
  49090. set buttonTriangle(value: number);
  49091. /**
  49092. * Gets the value of the `Options` button
  49093. */
  49094. get buttonOptions(): number;
  49095. /**
  49096. * Sets the value of the `Options` button
  49097. */
  49098. set buttonOptions(value: number);
  49099. /**
  49100. * Gets the value of the `Share` button
  49101. */
  49102. get buttonShare(): number;
  49103. /**
  49104. * Sets the value of the `Share` button
  49105. */
  49106. set buttonShare(value: number);
  49107. /**
  49108. * Gets the value of the `L1` button
  49109. */
  49110. get buttonL1(): number;
  49111. /**
  49112. * Sets the value of the `L1` button
  49113. */
  49114. set buttonL1(value: number);
  49115. /**
  49116. * Gets the value of the `R1` button
  49117. */
  49118. get buttonR1(): number;
  49119. /**
  49120. * Sets the value of the `R1` button
  49121. */
  49122. set buttonR1(value: number);
  49123. /**
  49124. * Gets the value of the Left joystick
  49125. */
  49126. get buttonLeftStick(): number;
  49127. /**
  49128. * Sets the value of the Left joystick
  49129. */
  49130. set buttonLeftStick(value: number);
  49131. /**
  49132. * Gets the value of the Right joystick
  49133. */
  49134. get buttonRightStick(): number;
  49135. /**
  49136. * Sets the value of the Right joystick
  49137. */
  49138. set buttonRightStick(value: number);
  49139. /**
  49140. * Gets the value of D-pad up
  49141. */
  49142. get dPadUp(): number;
  49143. /**
  49144. * Sets the value of D-pad up
  49145. */
  49146. set dPadUp(value: number);
  49147. /**
  49148. * Gets the value of D-pad down
  49149. */
  49150. get dPadDown(): number;
  49151. /**
  49152. * Sets the value of D-pad down
  49153. */
  49154. set dPadDown(value: number);
  49155. /**
  49156. * Gets the value of D-pad left
  49157. */
  49158. get dPadLeft(): number;
  49159. /**
  49160. * Sets the value of D-pad left
  49161. */
  49162. set dPadLeft(value: number);
  49163. /**
  49164. * Gets the value of D-pad right
  49165. */
  49166. get dPadRight(): number;
  49167. /**
  49168. * Sets the value of D-pad right
  49169. */
  49170. set dPadRight(value: number);
  49171. /**
  49172. * Force the gamepad to synchronize with device values
  49173. */
  49174. update(): void;
  49175. /**
  49176. * Disposes the gamepad
  49177. */
  49178. dispose(): void;
  49179. }
  49180. }
  49181. declare module BABYLON {
  49182. /**
  49183. * Manager for handling gamepads
  49184. */
  49185. export class GamepadManager {
  49186. private _scene?;
  49187. private _babylonGamepads;
  49188. private _oneGamepadConnected;
  49189. /** @hidden */
  49190. _isMonitoring: boolean;
  49191. private _gamepadEventSupported;
  49192. private _gamepadSupport?;
  49193. /**
  49194. * observable to be triggered when the gamepad controller has been connected
  49195. */
  49196. onGamepadConnectedObservable: Observable<Gamepad>;
  49197. /**
  49198. * observable to be triggered when the gamepad controller has been disconnected
  49199. */
  49200. onGamepadDisconnectedObservable: Observable<Gamepad>;
  49201. private _onGamepadConnectedEvent;
  49202. private _onGamepadDisconnectedEvent;
  49203. /**
  49204. * Initializes the gamepad manager
  49205. * @param _scene BabylonJS scene
  49206. */
  49207. constructor(_scene?: Scene | undefined);
  49208. /**
  49209. * The gamepads in the game pad manager
  49210. */
  49211. get gamepads(): Gamepad[];
  49212. /**
  49213. * Get the gamepad controllers based on type
  49214. * @param type The type of gamepad controller
  49215. * @returns Nullable gamepad
  49216. */
  49217. getGamepadByType(type?: number): Nullable<Gamepad>;
  49218. /**
  49219. * Disposes the gamepad manager
  49220. */
  49221. dispose(): void;
  49222. private _addNewGamepad;
  49223. private _startMonitoringGamepads;
  49224. private _stopMonitoringGamepads;
  49225. /** @hidden */
  49226. _checkGamepadsStatus(): void;
  49227. private _updateGamepadObjects;
  49228. }
  49229. }
  49230. declare module BABYLON {
  49231. interface Scene {
  49232. /** @hidden */
  49233. _gamepadManager: Nullable<GamepadManager>;
  49234. /**
  49235. * Gets the gamepad manager associated with the scene
  49236. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  49237. */
  49238. gamepadManager: GamepadManager;
  49239. }
  49240. /**
  49241. * Interface representing a free camera inputs manager
  49242. */
  49243. interface FreeCameraInputsManager {
  49244. /**
  49245. * Adds gamepad input support to the FreeCameraInputsManager.
  49246. * @returns the FreeCameraInputsManager
  49247. */
  49248. addGamepad(): FreeCameraInputsManager;
  49249. }
  49250. /**
  49251. * Interface representing an arc rotate camera inputs manager
  49252. */
  49253. interface ArcRotateCameraInputsManager {
  49254. /**
  49255. * Adds gamepad input support to the ArcRotateCamera InputManager.
  49256. * @returns the camera inputs manager
  49257. */
  49258. addGamepad(): ArcRotateCameraInputsManager;
  49259. }
  49260. /**
  49261. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  49262. */
  49263. export class GamepadSystemSceneComponent implements ISceneComponent {
  49264. /**
  49265. * The component name helpfull to identify the component in the list of scene components.
  49266. */
  49267. readonly name: string;
  49268. /**
  49269. * The scene the component belongs to.
  49270. */
  49271. scene: Scene;
  49272. /**
  49273. * Creates a new instance of the component for the given scene
  49274. * @param scene Defines the scene to register the component in
  49275. */
  49276. constructor(scene: Scene);
  49277. /**
  49278. * Registers the component in a given scene
  49279. */
  49280. register(): void;
  49281. /**
  49282. * Rebuilds the elements related to this component in case of
  49283. * context lost for instance.
  49284. */
  49285. rebuild(): void;
  49286. /**
  49287. * Disposes the component and the associated ressources
  49288. */
  49289. dispose(): void;
  49290. private _beforeCameraUpdate;
  49291. }
  49292. }
  49293. declare module BABYLON {
  49294. /**
  49295. * 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,
  49296. * which still works and will still be found in many Playgrounds.
  49297. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49298. */
  49299. export class UniversalCamera extends TouchCamera {
  49300. /**
  49301. * Defines the gamepad rotation sensiblity.
  49302. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  49303. */
  49304. get gamepadAngularSensibility(): number;
  49305. set gamepadAngularSensibility(value: number);
  49306. /**
  49307. * Defines the gamepad move sensiblity.
  49308. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  49309. */
  49310. get gamepadMoveSensibility(): number;
  49311. set gamepadMoveSensibility(value: number);
  49312. /**
  49313. * 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,
  49314. * which still works and will still be found in many Playgrounds.
  49315. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49316. * @param name Define the name of the camera in the scene
  49317. * @param position Define the start position of the camera in the scene
  49318. * @param scene Define the scene the camera belongs to
  49319. */
  49320. constructor(name: string, position: Vector3, scene: Scene);
  49321. /**
  49322. * Gets the current object class name.
  49323. * @return the class name
  49324. */
  49325. getClassName(): string;
  49326. }
  49327. }
  49328. declare module BABYLON {
  49329. /**
  49330. * This represents a FPS type of camera. This is only here for back compat purpose.
  49331. * Please use the UniversalCamera instead as both are identical.
  49332. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49333. */
  49334. export class GamepadCamera extends UniversalCamera {
  49335. /**
  49336. * Instantiates a new Gamepad Camera
  49337. * This represents a FPS type of camera. This is only here for back compat purpose.
  49338. * Please use the UniversalCamera instead as both are identical.
  49339. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49340. * @param name Define the name of the camera in the scene
  49341. * @param position Define the start position of the camera in the scene
  49342. * @param scene Define the scene the camera belongs to
  49343. */
  49344. constructor(name: string, position: Vector3, scene: Scene);
  49345. /**
  49346. * Gets the current object class name.
  49347. * @return the class name
  49348. */
  49349. getClassName(): string;
  49350. }
  49351. }
  49352. declare module BABYLON {
  49353. /** @hidden */
  49354. export var passPixelShader: {
  49355. name: string;
  49356. shader: string;
  49357. };
  49358. }
  49359. declare module BABYLON {
  49360. /** @hidden */
  49361. export var passCubePixelShader: {
  49362. name: string;
  49363. shader: string;
  49364. };
  49365. }
  49366. declare module BABYLON {
  49367. /**
  49368. * PassPostProcess which produces an output the same as it's input
  49369. */
  49370. export class PassPostProcess extends PostProcess {
  49371. /**
  49372. * Gets a string identifying the name of the class
  49373. * @returns "PassPostProcess" string
  49374. */
  49375. getClassName(): string;
  49376. /**
  49377. * Creates the PassPostProcess
  49378. * @param name The name of the effect.
  49379. * @param options The required width/height ratio to downsize to before computing the render pass.
  49380. * @param camera The camera to apply the render pass to.
  49381. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49382. * @param engine The engine which the post process will be applied. (default: current engine)
  49383. * @param reusable If the post process can be reused on the same frame. (default: false)
  49384. * @param textureType The type of texture to be used when performing the post processing.
  49385. * @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)
  49386. */
  49387. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49388. /** @hidden */
  49389. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  49390. }
  49391. /**
  49392. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  49393. */
  49394. export class PassCubePostProcess extends PostProcess {
  49395. private _face;
  49396. /**
  49397. * Gets or sets the cube face to display.
  49398. * * 0 is +X
  49399. * * 1 is -X
  49400. * * 2 is +Y
  49401. * * 3 is -Y
  49402. * * 4 is +Z
  49403. * * 5 is -Z
  49404. */
  49405. get face(): number;
  49406. set face(value: number);
  49407. /**
  49408. * Gets a string identifying the name of the class
  49409. * @returns "PassCubePostProcess" string
  49410. */
  49411. getClassName(): string;
  49412. /**
  49413. * Creates the PassCubePostProcess
  49414. * @param name The name of the effect.
  49415. * @param options The required width/height ratio to downsize to before computing the render pass.
  49416. * @param camera The camera to apply the render pass to.
  49417. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49418. * @param engine The engine which the post process will be applied. (default: current engine)
  49419. * @param reusable If the post process can be reused on the same frame. (default: false)
  49420. * @param textureType The type of texture to be used when performing the post processing.
  49421. * @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)
  49422. */
  49423. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49424. /** @hidden */
  49425. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  49426. }
  49427. }
  49428. declare module BABYLON {
  49429. /** @hidden */
  49430. export var anaglyphPixelShader: {
  49431. name: string;
  49432. shader: string;
  49433. };
  49434. }
  49435. declare module BABYLON {
  49436. /**
  49437. * Postprocess used to generate anaglyphic rendering
  49438. */
  49439. export class AnaglyphPostProcess extends PostProcess {
  49440. private _passedProcess;
  49441. /**
  49442. * Gets a string identifying the name of the class
  49443. * @returns "AnaglyphPostProcess" string
  49444. */
  49445. getClassName(): string;
  49446. /**
  49447. * Creates a new AnaglyphPostProcess
  49448. * @param name defines postprocess name
  49449. * @param options defines creation options or target ratio scale
  49450. * @param rigCameras defines cameras using this postprocess
  49451. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  49452. * @param engine defines hosting engine
  49453. * @param reusable defines if the postprocess will be reused multiple times per frame
  49454. */
  49455. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  49456. }
  49457. }
  49458. declare module BABYLON {
  49459. /**
  49460. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  49461. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49462. */
  49463. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  49464. /**
  49465. * Creates a new AnaglyphArcRotateCamera
  49466. * @param name defines camera name
  49467. * @param alpha defines alpha angle (in radians)
  49468. * @param beta defines beta angle (in radians)
  49469. * @param radius defines radius
  49470. * @param target defines camera target
  49471. * @param interaxialDistance defines distance between each color axis
  49472. * @param scene defines the hosting scene
  49473. */
  49474. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  49475. /**
  49476. * Gets camera class name
  49477. * @returns AnaglyphArcRotateCamera
  49478. */
  49479. getClassName(): string;
  49480. }
  49481. }
  49482. declare module BABYLON {
  49483. /**
  49484. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  49485. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49486. */
  49487. export class AnaglyphFreeCamera extends FreeCamera {
  49488. /**
  49489. * Creates a new AnaglyphFreeCamera
  49490. * @param name defines camera name
  49491. * @param position defines initial position
  49492. * @param interaxialDistance defines distance between each color axis
  49493. * @param scene defines the hosting scene
  49494. */
  49495. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49496. /**
  49497. * Gets camera class name
  49498. * @returns AnaglyphFreeCamera
  49499. */
  49500. getClassName(): string;
  49501. }
  49502. }
  49503. declare module BABYLON {
  49504. /**
  49505. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  49506. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49507. */
  49508. export class AnaglyphGamepadCamera extends GamepadCamera {
  49509. /**
  49510. * Creates a new AnaglyphGamepadCamera
  49511. * @param name defines camera name
  49512. * @param position defines initial position
  49513. * @param interaxialDistance defines distance between each color axis
  49514. * @param scene defines the hosting scene
  49515. */
  49516. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49517. /**
  49518. * Gets camera class name
  49519. * @returns AnaglyphGamepadCamera
  49520. */
  49521. getClassName(): string;
  49522. }
  49523. }
  49524. declare module BABYLON {
  49525. /**
  49526. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  49527. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49528. */
  49529. export class AnaglyphUniversalCamera extends UniversalCamera {
  49530. /**
  49531. * Creates a new AnaglyphUniversalCamera
  49532. * @param name defines camera name
  49533. * @param position defines initial position
  49534. * @param interaxialDistance defines distance between each color axis
  49535. * @param scene defines the hosting scene
  49536. */
  49537. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49538. /**
  49539. * Gets camera class name
  49540. * @returns AnaglyphUniversalCamera
  49541. */
  49542. getClassName(): string;
  49543. }
  49544. }
  49545. declare module BABYLON {
  49546. /**
  49547. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  49548. * @see https://doc.babylonjs.com/features/cameras
  49549. */
  49550. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  49551. /**
  49552. * Creates a new StereoscopicArcRotateCamera
  49553. * @param name defines camera name
  49554. * @param alpha defines alpha angle (in radians)
  49555. * @param beta defines beta angle (in radians)
  49556. * @param radius defines radius
  49557. * @param target defines camera target
  49558. * @param interaxialDistance defines distance between each color axis
  49559. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49560. * @param scene defines the hosting scene
  49561. */
  49562. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49563. /**
  49564. * Gets camera class name
  49565. * @returns StereoscopicArcRotateCamera
  49566. */
  49567. getClassName(): string;
  49568. }
  49569. }
  49570. declare module BABYLON {
  49571. /**
  49572. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  49573. * @see https://doc.babylonjs.com/features/cameras
  49574. */
  49575. export class StereoscopicFreeCamera extends FreeCamera {
  49576. /**
  49577. * Creates a new StereoscopicFreeCamera
  49578. * @param name defines camera name
  49579. * @param position defines initial position
  49580. * @param interaxialDistance defines distance between each color axis
  49581. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49582. * @param scene defines the hosting scene
  49583. */
  49584. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49585. /**
  49586. * Gets camera class name
  49587. * @returns StereoscopicFreeCamera
  49588. */
  49589. getClassName(): string;
  49590. }
  49591. }
  49592. declare module BABYLON {
  49593. /**
  49594. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  49595. * @see https://doc.babylonjs.com/features/cameras
  49596. */
  49597. export class StereoscopicGamepadCamera extends GamepadCamera {
  49598. /**
  49599. * Creates a new StereoscopicGamepadCamera
  49600. * @param name defines camera name
  49601. * @param position defines initial position
  49602. * @param interaxialDistance defines distance between each color axis
  49603. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49604. * @param scene defines the hosting scene
  49605. */
  49606. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49607. /**
  49608. * Gets camera class name
  49609. * @returns StereoscopicGamepadCamera
  49610. */
  49611. getClassName(): string;
  49612. }
  49613. }
  49614. declare module BABYLON {
  49615. /**
  49616. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  49617. * @see https://doc.babylonjs.com/features/cameras
  49618. */
  49619. export class StereoscopicUniversalCamera extends UniversalCamera {
  49620. /**
  49621. * Creates a new StereoscopicUniversalCamera
  49622. * @param name defines camera name
  49623. * @param position defines initial position
  49624. * @param interaxialDistance defines distance between each color axis
  49625. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49626. * @param scene defines the hosting scene
  49627. */
  49628. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49629. /**
  49630. * Gets camera class name
  49631. * @returns StereoscopicUniversalCamera
  49632. */
  49633. getClassName(): string;
  49634. }
  49635. }
  49636. declare module BABYLON {
  49637. /**
  49638. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  49639. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  49640. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  49641. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  49642. */
  49643. export class VirtualJoysticksCamera extends FreeCamera {
  49644. /**
  49645. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  49646. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  49647. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  49648. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  49649. * @param name Define the name of the camera in the scene
  49650. * @param position Define the start position of the camera in the scene
  49651. * @param scene Define the scene the camera belongs to
  49652. */
  49653. constructor(name: string, position: Vector3, scene: Scene);
  49654. /**
  49655. * Gets the current object class name.
  49656. * @return the class name
  49657. */
  49658. getClassName(): string;
  49659. }
  49660. }
  49661. declare module BABYLON {
  49662. /**
  49663. * This represents all the required metrics to create a VR camera.
  49664. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  49665. */
  49666. export class VRCameraMetrics {
  49667. /**
  49668. * Define the horizontal resolution off the screen.
  49669. */
  49670. hResolution: number;
  49671. /**
  49672. * Define the vertical resolution off the screen.
  49673. */
  49674. vResolution: number;
  49675. /**
  49676. * Define the horizontal screen size.
  49677. */
  49678. hScreenSize: number;
  49679. /**
  49680. * Define the vertical screen size.
  49681. */
  49682. vScreenSize: number;
  49683. /**
  49684. * Define the vertical screen center position.
  49685. */
  49686. vScreenCenter: number;
  49687. /**
  49688. * Define the distance of the eyes to the screen.
  49689. */
  49690. eyeToScreenDistance: number;
  49691. /**
  49692. * Define the distance between both lenses
  49693. */
  49694. lensSeparationDistance: number;
  49695. /**
  49696. * Define the distance between both viewer's eyes.
  49697. */
  49698. interpupillaryDistance: number;
  49699. /**
  49700. * Define the distortion factor of the VR postprocess.
  49701. * Please, touch with care.
  49702. */
  49703. distortionK: number[];
  49704. /**
  49705. * Define the chromatic aberration correction factors for the VR post process.
  49706. */
  49707. chromaAbCorrection: number[];
  49708. /**
  49709. * Define the scale factor of the post process.
  49710. * The smaller the better but the slower.
  49711. */
  49712. postProcessScaleFactor: number;
  49713. /**
  49714. * Define an offset for the lens center.
  49715. */
  49716. lensCenterOffset: number;
  49717. /**
  49718. * Define if the current vr camera should compensate the distortion of the lense or not.
  49719. */
  49720. compensateDistortion: boolean;
  49721. /**
  49722. * Defines if multiview should be enabled when rendering (Default: false)
  49723. */
  49724. multiviewEnabled: boolean;
  49725. /**
  49726. * Gets the rendering aspect ratio based on the provided resolutions.
  49727. */
  49728. get aspectRatio(): number;
  49729. /**
  49730. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  49731. */
  49732. get aspectRatioFov(): number;
  49733. /**
  49734. * @hidden
  49735. */
  49736. get leftHMatrix(): Matrix;
  49737. /**
  49738. * @hidden
  49739. */
  49740. get rightHMatrix(): Matrix;
  49741. /**
  49742. * @hidden
  49743. */
  49744. get leftPreViewMatrix(): Matrix;
  49745. /**
  49746. * @hidden
  49747. */
  49748. get rightPreViewMatrix(): Matrix;
  49749. /**
  49750. * Get the default VRMetrics based on the most generic setup.
  49751. * @returns the default vr metrics
  49752. */
  49753. static GetDefault(): VRCameraMetrics;
  49754. }
  49755. }
  49756. declare module BABYLON {
  49757. /** @hidden */
  49758. export var vrDistortionCorrectionPixelShader: {
  49759. name: string;
  49760. shader: string;
  49761. };
  49762. }
  49763. declare module BABYLON {
  49764. /**
  49765. * VRDistortionCorrectionPostProcess used for mobile VR
  49766. */
  49767. export class VRDistortionCorrectionPostProcess extends PostProcess {
  49768. private _isRightEye;
  49769. private _distortionFactors;
  49770. private _postProcessScaleFactor;
  49771. private _lensCenterOffset;
  49772. private _scaleIn;
  49773. private _scaleFactor;
  49774. private _lensCenter;
  49775. /**
  49776. * Gets a string identifying the name of the class
  49777. * @returns "VRDistortionCorrectionPostProcess" string
  49778. */
  49779. getClassName(): string;
  49780. /**
  49781. * Initializes the VRDistortionCorrectionPostProcess
  49782. * @param name The name of the effect.
  49783. * @param camera The camera to apply the render pass to.
  49784. * @param isRightEye If this is for the right eye distortion
  49785. * @param vrMetrics All the required metrics for the VR camera
  49786. */
  49787. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  49788. }
  49789. }
  49790. declare module BABYLON {
  49791. /**
  49792. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  49793. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  49794. */
  49795. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  49796. /**
  49797. * Creates a new VRDeviceOrientationArcRotateCamera
  49798. * @param name defines camera name
  49799. * @param alpha defines the camera rotation along the logitudinal axis
  49800. * @param beta defines the camera rotation along the latitudinal axis
  49801. * @param radius defines the camera distance from its target
  49802. * @param target defines the camera target
  49803. * @param scene defines the scene the camera belongs to
  49804. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  49805. * @param vrCameraMetrics defines the vr metrics associated to the camera
  49806. */
  49807. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  49808. /**
  49809. * Gets camera class name
  49810. * @returns VRDeviceOrientationArcRotateCamera
  49811. */
  49812. getClassName(): string;
  49813. }
  49814. }
  49815. declare module BABYLON {
  49816. /**
  49817. * Camera used to simulate VR rendering (based on FreeCamera)
  49818. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  49819. */
  49820. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  49821. /**
  49822. * Creates a new VRDeviceOrientationFreeCamera
  49823. * @param name defines camera name
  49824. * @param position defines the start position of the camera
  49825. * @param scene defines the scene the camera belongs to
  49826. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  49827. * @param vrCameraMetrics defines the vr metrics associated to the camera
  49828. */
  49829. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  49830. /**
  49831. * Gets camera class name
  49832. * @returns VRDeviceOrientationFreeCamera
  49833. */
  49834. getClassName(): string;
  49835. }
  49836. }
  49837. declare module BABYLON {
  49838. /**
  49839. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  49840. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  49841. */
  49842. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  49843. /**
  49844. * Creates a new VRDeviceOrientationGamepadCamera
  49845. * @param name defines camera name
  49846. * @param position defines the start position of the camera
  49847. * @param scene defines the scene the camera belongs to
  49848. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  49849. * @param vrCameraMetrics defines the vr metrics associated to the camera
  49850. */
  49851. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  49852. /**
  49853. * Gets camera class name
  49854. * @returns VRDeviceOrientationGamepadCamera
  49855. */
  49856. getClassName(): string;
  49857. }
  49858. }
  49859. declare module BABYLON {
  49860. /**
  49861. * A class extending Texture allowing drawing on a texture
  49862. * @see https://doc.babylonjs.com/how_to/dynamictexture
  49863. */
  49864. export class DynamicTexture extends Texture {
  49865. private _generateMipMaps;
  49866. private _canvas;
  49867. private _context;
  49868. /**
  49869. * Creates a DynamicTexture
  49870. * @param name defines the name of the texture
  49871. * @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
  49872. * @param scene defines the scene where you want the texture
  49873. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  49874. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  49875. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  49876. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  49877. */
  49878. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  49879. /**
  49880. * Get the current class name of the texture useful for serialization or dynamic coding.
  49881. * @returns "DynamicTexture"
  49882. */
  49883. getClassName(): string;
  49884. /**
  49885. * Gets the current state of canRescale
  49886. */
  49887. get canRescale(): boolean;
  49888. private _recreate;
  49889. /**
  49890. * Scales the texture
  49891. * @param ratio the scale factor to apply to both width and height
  49892. */
  49893. scale(ratio: number): void;
  49894. /**
  49895. * Resizes the texture
  49896. * @param width the new width
  49897. * @param height the new height
  49898. */
  49899. scaleTo(width: number, height: number): void;
  49900. /**
  49901. * Gets the context of the canvas used by the texture
  49902. * @returns the canvas context of the dynamic texture
  49903. */
  49904. getContext(): CanvasRenderingContext2D;
  49905. /**
  49906. * Clears the texture
  49907. */
  49908. clear(): void;
  49909. /**
  49910. * Updates the texture
  49911. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  49912. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  49913. */
  49914. update(invertY?: boolean, premulAlpha?: boolean): void;
  49915. /**
  49916. * Draws text onto the texture
  49917. * @param text defines the text to be drawn
  49918. * @param x defines the placement of the text from the left
  49919. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  49920. * @param font defines the font to be used with font-style, font-size, font-name
  49921. * @param color defines the color used for the text
  49922. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  49923. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  49924. * @param update defines whether texture is immediately update (default is true)
  49925. */
  49926. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  49927. /**
  49928. * Clones the texture
  49929. * @returns the clone of the texture.
  49930. */
  49931. clone(): DynamicTexture;
  49932. /**
  49933. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  49934. * @returns a serialized dynamic texture object
  49935. */
  49936. serialize(): any;
  49937. private _IsCanvasElement;
  49938. /** @hidden */
  49939. _rebuild(): void;
  49940. }
  49941. }
  49942. declare module BABYLON {
  49943. /**
  49944. * Class containing static functions to help procedurally build meshes
  49945. */
  49946. export class GroundBuilder {
  49947. /**
  49948. * Creates a ground mesh
  49949. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  49950. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  49951. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49952. * @param name defines the name of the mesh
  49953. * @param options defines the options used to create the mesh
  49954. * @param scene defines the hosting scene
  49955. * @returns the ground mesh
  49956. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  49957. */
  49958. static CreateGround(name: string, options: {
  49959. width?: number;
  49960. height?: number;
  49961. subdivisions?: number;
  49962. subdivisionsX?: number;
  49963. subdivisionsY?: number;
  49964. updatable?: boolean;
  49965. }, scene: any): Mesh;
  49966. /**
  49967. * Creates a tiled ground mesh
  49968. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  49969. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  49970. * * 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
  49971. * * 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
  49972. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49973. * @param name defines the name of the mesh
  49974. * @param options defines the options used to create the mesh
  49975. * @param scene defines the hosting scene
  49976. * @returns the tiled ground mesh
  49977. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  49978. */
  49979. static CreateTiledGround(name: string, options: {
  49980. xmin: number;
  49981. zmin: number;
  49982. xmax: number;
  49983. zmax: number;
  49984. subdivisions?: {
  49985. w: number;
  49986. h: number;
  49987. };
  49988. precision?: {
  49989. w: number;
  49990. h: number;
  49991. };
  49992. updatable?: boolean;
  49993. }, scene?: Nullable<Scene>): Mesh;
  49994. /**
  49995. * Creates a ground mesh from a height map
  49996. * * The parameter `url` sets the URL of the height map image resource.
  49997. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  49998. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  49999. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  50000. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  50001. * * 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.
  50002. * * 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).
  50003. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  50004. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50005. * @param name defines the name of the mesh
  50006. * @param url defines the url to the height map
  50007. * @param options defines the options used to create the mesh
  50008. * @param scene defines the hosting scene
  50009. * @returns the ground mesh
  50010. * @see https://doc.babylonjs.com/babylon101/height_map
  50011. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  50012. */
  50013. static CreateGroundFromHeightMap(name: string, url: string, options: {
  50014. width?: number;
  50015. height?: number;
  50016. subdivisions?: number;
  50017. minHeight?: number;
  50018. maxHeight?: number;
  50019. colorFilter?: Color3;
  50020. alphaFilter?: number;
  50021. updatable?: boolean;
  50022. onReady?: (mesh: GroundMesh) => void;
  50023. }, scene?: Nullable<Scene>): GroundMesh;
  50024. }
  50025. }
  50026. declare module BABYLON {
  50027. /**
  50028. * Class containing static functions to help procedurally build meshes
  50029. */
  50030. export class TorusBuilder {
  50031. /**
  50032. * Creates a torus mesh
  50033. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  50034. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  50035. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  50036. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50037. * * 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
  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 options defines the options used to create the mesh
  50041. * @param scene defines the hosting scene
  50042. * @returns the torus mesh
  50043. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  50044. */
  50045. static CreateTorus(name: string, options: {
  50046. diameter?: number;
  50047. thickness?: number;
  50048. tessellation?: number;
  50049. updatable?: boolean;
  50050. sideOrientation?: number;
  50051. frontUVs?: Vector4;
  50052. backUVs?: Vector4;
  50053. }, scene: any): Mesh;
  50054. }
  50055. }
  50056. declare module BABYLON {
  50057. /**
  50058. * Class containing static functions to help procedurally build meshes
  50059. */
  50060. export class CylinderBuilder {
  50061. /**
  50062. * Creates a cylinder or a cone mesh
  50063. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  50064. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  50065. * * 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.
  50066. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  50067. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  50068. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  50069. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  50070. * * 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).
  50071. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  50072. * * 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).
  50073. * * 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
  50074. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  50075. * * 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
  50076. * * 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.
  50077. * * If `enclose` is false, a ring surface is one element.
  50078. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  50079. * * 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
  50080. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50081. * * 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
  50082. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50083. * @param name defines the name of the mesh
  50084. * @param options defines the options used to create the mesh
  50085. * @param scene defines the hosting scene
  50086. * @returns the cylinder mesh
  50087. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  50088. */
  50089. static CreateCylinder(name: string, options: {
  50090. height?: number;
  50091. diameterTop?: number;
  50092. diameterBottom?: number;
  50093. diameter?: number;
  50094. tessellation?: number;
  50095. subdivisions?: number;
  50096. arc?: number;
  50097. faceColors?: Color4[];
  50098. faceUV?: Vector4[];
  50099. updatable?: boolean;
  50100. hasRings?: boolean;
  50101. enclose?: boolean;
  50102. cap?: number;
  50103. sideOrientation?: number;
  50104. frontUVs?: Vector4;
  50105. backUVs?: Vector4;
  50106. }, scene: any): Mesh;
  50107. }
  50108. }
  50109. declare module BABYLON {
  50110. /**
  50111. * States of the webXR experience
  50112. */
  50113. export enum WebXRState {
  50114. /**
  50115. * Transitioning to being in XR mode
  50116. */
  50117. ENTERING_XR = 0,
  50118. /**
  50119. * Transitioning to non XR mode
  50120. */
  50121. EXITING_XR = 1,
  50122. /**
  50123. * In XR mode and presenting
  50124. */
  50125. IN_XR = 2,
  50126. /**
  50127. * Not entered XR mode
  50128. */
  50129. NOT_IN_XR = 3
  50130. }
  50131. /**
  50132. * The state of the XR camera's tracking
  50133. */
  50134. export enum WebXRTrackingState {
  50135. /**
  50136. * No transformation received, device is not being tracked
  50137. */
  50138. NOT_TRACKING = 0,
  50139. /**
  50140. * Tracking lost - using emulated position
  50141. */
  50142. TRACKING_LOST = 1,
  50143. /**
  50144. * Transformation tracking works normally
  50145. */
  50146. TRACKING = 2
  50147. }
  50148. /**
  50149. * Abstraction of the XR render target
  50150. */
  50151. export interface WebXRRenderTarget extends IDisposable {
  50152. /**
  50153. * xrpresent context of the canvas which can be used to display/mirror xr content
  50154. */
  50155. canvasContext: WebGLRenderingContext;
  50156. /**
  50157. * xr layer for the canvas
  50158. */
  50159. xrLayer: Nullable<XRWebGLLayer>;
  50160. /**
  50161. * Initializes the xr layer for the session
  50162. * @param xrSession xr session
  50163. * @returns a promise that will resolve once the XR Layer has been created
  50164. */
  50165. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  50166. }
  50167. }
  50168. declare module BABYLON {
  50169. /**
  50170. * COnfiguration object for WebXR output canvas
  50171. */
  50172. export class WebXRManagedOutputCanvasOptions {
  50173. /**
  50174. * An optional canvas in case you wish to create it yourself and provide it here.
  50175. * If not provided, a new canvas will be created
  50176. */
  50177. canvasElement?: HTMLCanvasElement;
  50178. /**
  50179. * Options for this XR Layer output
  50180. */
  50181. canvasOptions?: XRWebGLLayerInit;
  50182. /**
  50183. * CSS styling for a newly created canvas (if not provided)
  50184. */
  50185. newCanvasCssStyle?: string;
  50186. /**
  50187. * Get the default values of the configuration object
  50188. * @param engine defines the engine to use (can be null)
  50189. * @returns default values of this configuration object
  50190. */
  50191. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  50192. }
  50193. /**
  50194. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  50195. */
  50196. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  50197. private _options;
  50198. private _canvas;
  50199. private _engine;
  50200. private _originalCanvasSize;
  50201. /**
  50202. * Rendering context of the canvas which can be used to display/mirror xr content
  50203. */
  50204. canvasContext: WebGLRenderingContext;
  50205. /**
  50206. * xr layer for the canvas
  50207. */
  50208. xrLayer: Nullable<XRWebGLLayer>;
  50209. /**
  50210. * Obseervers registered here will be triggered when the xr layer was initialized
  50211. */
  50212. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  50213. /**
  50214. * Initializes the canvas to be added/removed upon entering/exiting xr
  50215. * @param _xrSessionManager The XR Session manager
  50216. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  50217. */
  50218. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  50219. /**
  50220. * Disposes of the object
  50221. */
  50222. dispose(): void;
  50223. /**
  50224. * Initializes the xr layer for the session
  50225. * @param xrSession xr session
  50226. * @returns a promise that will resolve once the XR Layer has been created
  50227. */
  50228. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  50229. private _addCanvas;
  50230. private _removeCanvas;
  50231. private _setCanvasSize;
  50232. private _setManagedOutputCanvas;
  50233. }
  50234. }
  50235. declare module BABYLON {
  50236. /**
  50237. * Manages an XRSession to work with Babylon's engine
  50238. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  50239. */
  50240. export class WebXRSessionManager implements IDisposable {
  50241. /** The scene which the session should be created for */
  50242. scene: Scene;
  50243. private _referenceSpace;
  50244. private _rttProvider;
  50245. private _sessionEnded;
  50246. private _xrNavigator;
  50247. private baseLayer;
  50248. /**
  50249. * The base reference space from which the session started. good if you want to reset your
  50250. * reference space
  50251. */
  50252. baseReferenceSpace: XRReferenceSpace;
  50253. /**
  50254. * Current XR frame
  50255. */
  50256. currentFrame: Nullable<XRFrame>;
  50257. /** WebXR timestamp updated every frame */
  50258. currentTimestamp: number;
  50259. /**
  50260. * Used just in case of a failure to initialize an immersive session.
  50261. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  50262. */
  50263. defaultHeightCompensation: number;
  50264. /**
  50265. * Fires every time a new xrFrame arrives which can be used to update the camera
  50266. */
  50267. onXRFrameObservable: Observable<XRFrame>;
  50268. /**
  50269. * Fires when the reference space changed
  50270. */
  50271. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  50272. /**
  50273. * Fires when the xr session is ended either by the device or manually done
  50274. */
  50275. onXRSessionEnded: Observable<any>;
  50276. /**
  50277. * Fires when the xr session is ended either by the device or manually done
  50278. */
  50279. onXRSessionInit: Observable<XRSession>;
  50280. /**
  50281. * Underlying xr session
  50282. */
  50283. session: XRSession;
  50284. /**
  50285. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  50286. * or get the offset the player is currently at.
  50287. */
  50288. viewerReferenceSpace: XRReferenceSpace;
  50289. /**
  50290. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  50291. * @param scene The scene which the session should be created for
  50292. */
  50293. constructor(
  50294. /** The scene which the session should be created for */
  50295. scene: Scene);
  50296. /**
  50297. * The current reference space used in this session. This reference space can constantly change!
  50298. * It is mainly used to offset the camera's position.
  50299. */
  50300. get referenceSpace(): XRReferenceSpace;
  50301. /**
  50302. * Set a new reference space and triggers the observable
  50303. */
  50304. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  50305. /**
  50306. * Disposes of the session manager
  50307. */
  50308. dispose(): void;
  50309. /**
  50310. * Stops the xrSession and restores the render loop
  50311. * @returns Promise which resolves after it exits XR
  50312. */
  50313. exitXRAsync(): Promise<void>;
  50314. /**
  50315. * Gets the correct render target texture to be rendered this frame for this eye
  50316. * @param eye the eye for which to get the render target
  50317. * @returns the render target for the specified eye
  50318. */
  50319. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  50320. /**
  50321. * Creates a WebXRRenderTarget object for the XR session
  50322. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  50323. * @param options optional options to provide when creating a new render target
  50324. * @returns a WebXR render target to which the session can render
  50325. */
  50326. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  50327. /**
  50328. * Initializes the manager
  50329. * After initialization enterXR can be called to start an XR session
  50330. * @returns Promise which resolves after it is initialized
  50331. */
  50332. initializeAsync(): Promise<void>;
  50333. /**
  50334. * Initializes an xr session
  50335. * @param xrSessionMode mode to initialize
  50336. * @param xrSessionInit defines optional and required values to pass to the session builder
  50337. * @returns a promise which will resolve once the session has been initialized
  50338. */
  50339. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  50340. /**
  50341. * Checks if a session would be supported for the creation options specified
  50342. * @param sessionMode session mode to check if supported eg. immersive-vr
  50343. * @returns A Promise that resolves to true if supported and false if not
  50344. */
  50345. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  50346. /**
  50347. * Resets the reference space to the one started the session
  50348. */
  50349. resetReferenceSpace(): void;
  50350. /**
  50351. * Starts rendering to the xr layer
  50352. */
  50353. runXRRenderLoop(): void;
  50354. /**
  50355. * Sets the reference space on the xr session
  50356. * @param referenceSpaceType space to set
  50357. * @returns a promise that will resolve once the reference space has been set
  50358. */
  50359. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  50360. /**
  50361. * Updates the render state of the session
  50362. * @param state state to set
  50363. * @returns a promise that resolves once the render state has been updated
  50364. */
  50365. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  50366. /**
  50367. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  50368. * @param sessionMode defines the session to test
  50369. * @returns a promise with boolean as final value
  50370. */
  50371. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  50372. private _createRenderTargetTexture;
  50373. }
  50374. }
  50375. declare module BABYLON {
  50376. /**
  50377. * WebXR Camera which holds the views for the xrSession
  50378. * @see https://doc.babylonjs.com/how_to/webxr_camera
  50379. */
  50380. export class WebXRCamera extends FreeCamera {
  50381. private _xrSessionManager;
  50382. private _firstFrame;
  50383. private _referenceQuaternion;
  50384. private _referencedPosition;
  50385. private _xrInvPositionCache;
  50386. private _xrInvQuaternionCache;
  50387. private _trackingState;
  50388. /**
  50389. * Observable raised before camera teleportation
  50390. */
  50391. onBeforeCameraTeleport: Observable<Vector3>;
  50392. /**
  50393. * Observable raised after camera teleportation
  50394. */
  50395. onAfterCameraTeleport: Observable<Vector3>;
  50396. /**
  50397. * Notifies when the camera's tracking state has changed.
  50398. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  50399. */
  50400. onTrackingStateChanged: Observable<WebXRTrackingState>;
  50401. /**
  50402. * Should position compensation execute on first frame.
  50403. * This is used when copying the position from a native (non XR) camera
  50404. */
  50405. compensateOnFirstFrame: boolean;
  50406. /**
  50407. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  50408. * @param name the name of the camera
  50409. * @param scene the scene to add the camera to
  50410. * @param _xrSessionManager a constructed xr session manager
  50411. */
  50412. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  50413. /**
  50414. * Get the current XR tracking state of the camera
  50415. */
  50416. get trackingState(): WebXRTrackingState;
  50417. private _setTrackingState;
  50418. /**
  50419. * Return the user's height, unrelated to the current ground.
  50420. * This will be the y position of this camera, when ground level is 0.
  50421. */
  50422. get realWorldHeight(): number;
  50423. /** @hidden */
  50424. _updateForDualEyeDebugging(): void;
  50425. /**
  50426. * Sets this camera's transformation based on a non-vr camera
  50427. * @param otherCamera the non-vr camera to copy the transformation from
  50428. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  50429. */
  50430. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  50431. /**
  50432. * Gets the current instance class name ("WebXRCamera").
  50433. * @returns the class name
  50434. */
  50435. getClassName(): string;
  50436. private _rotate180;
  50437. private _updateFromXRSession;
  50438. private _updateNumberOfRigCameras;
  50439. private _updateReferenceSpace;
  50440. private _updateReferenceSpaceOffset;
  50441. }
  50442. }
  50443. declare module BABYLON {
  50444. /**
  50445. * Defining the interface required for a (webxr) feature
  50446. */
  50447. export interface IWebXRFeature extends IDisposable {
  50448. /**
  50449. * Is this feature attached
  50450. */
  50451. attached: boolean;
  50452. /**
  50453. * Should auto-attach be disabled?
  50454. */
  50455. disableAutoAttach: boolean;
  50456. /**
  50457. * Attach the feature to the session
  50458. * Will usually be called by the features manager
  50459. *
  50460. * @param force should attachment be forced (even when already attached)
  50461. * @returns true if successful.
  50462. */
  50463. attach(force?: boolean): boolean;
  50464. /**
  50465. * Detach the feature from the session
  50466. * Will usually be called by the features manager
  50467. *
  50468. * @returns true if successful.
  50469. */
  50470. detach(): boolean;
  50471. /**
  50472. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  50473. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  50474. *
  50475. * @returns whether or not the feature is compatible in this environment
  50476. */
  50477. isCompatible(): boolean;
  50478. /**
  50479. * Was this feature disposed;
  50480. */
  50481. isDisposed: boolean;
  50482. /**
  50483. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  50484. */
  50485. xrNativeFeatureName?: string;
  50486. /**
  50487. * A list of (Babylon WebXR) features this feature depends on
  50488. */
  50489. dependsOn?: string[];
  50490. }
  50491. /**
  50492. * A list of the currently available features without referencing them
  50493. */
  50494. export class WebXRFeatureName {
  50495. /**
  50496. * The name of the anchor system feature
  50497. */
  50498. static readonly ANCHOR_SYSTEM: string;
  50499. /**
  50500. * The name of the background remover feature
  50501. */
  50502. static readonly BACKGROUND_REMOVER: string;
  50503. /**
  50504. * The name of the hit test feature
  50505. */
  50506. static readonly HIT_TEST: string;
  50507. /**
  50508. * physics impostors for xr controllers feature
  50509. */
  50510. static readonly PHYSICS_CONTROLLERS: string;
  50511. /**
  50512. * The name of the plane detection feature
  50513. */
  50514. static readonly PLANE_DETECTION: string;
  50515. /**
  50516. * The name of the pointer selection feature
  50517. */
  50518. static readonly POINTER_SELECTION: string;
  50519. /**
  50520. * The name of the teleportation feature
  50521. */
  50522. static readonly TELEPORTATION: string;
  50523. /**
  50524. * The name of the feature points feature.
  50525. */
  50526. static readonly FEATURE_POINTS: string;
  50527. /**
  50528. * The name of the hand tracking feature.
  50529. */
  50530. static readonly HAND_TRACKING: string;
  50531. }
  50532. /**
  50533. * Defining the constructor of a feature. Used to register the modules.
  50534. */
  50535. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  50536. /**
  50537. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  50538. * It is mainly used in AR sessions.
  50539. *
  50540. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  50541. */
  50542. export class WebXRFeaturesManager implements IDisposable {
  50543. private _xrSessionManager;
  50544. private static readonly _AvailableFeatures;
  50545. private _features;
  50546. /**
  50547. * constructs a new features manages.
  50548. *
  50549. * @param _xrSessionManager an instance of WebXRSessionManager
  50550. */
  50551. constructor(_xrSessionManager: WebXRSessionManager);
  50552. /**
  50553. * Used to register a module. After calling this function a developer can use this feature in the scene.
  50554. * Mainly used internally.
  50555. *
  50556. * @param featureName the name of the feature to register
  50557. * @param constructorFunction the function used to construct the module
  50558. * @param version the (babylon) version of the module
  50559. * @param stable is that a stable version of this module
  50560. */
  50561. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  50562. /**
  50563. * Returns a constructor of a specific feature.
  50564. *
  50565. * @param featureName the name of the feature to construct
  50566. * @param version the version of the feature to load
  50567. * @param xrSessionManager the xrSessionManager. Used to construct the module
  50568. * @param options optional options provided to the module.
  50569. * @returns a function that, when called, will return a new instance of this feature
  50570. */
  50571. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  50572. /**
  50573. * Can be used to return the list of features currently registered
  50574. *
  50575. * @returns an Array of available features
  50576. */
  50577. static GetAvailableFeatures(): string[];
  50578. /**
  50579. * Gets the versions available for a specific feature
  50580. * @param featureName the name of the feature
  50581. * @returns an array with the available versions
  50582. */
  50583. static GetAvailableVersions(featureName: string): string[];
  50584. /**
  50585. * Return the latest unstable version of this feature
  50586. * @param featureName the name of the feature to search
  50587. * @returns the version number. if not found will return -1
  50588. */
  50589. static GetLatestVersionOfFeature(featureName: string): number;
  50590. /**
  50591. * Return the latest stable version of this feature
  50592. * @param featureName the name of the feature to search
  50593. * @returns the version number. if not found will return -1
  50594. */
  50595. static GetStableVersionOfFeature(featureName: string): number;
  50596. /**
  50597. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  50598. * Can be used during a session to start a feature
  50599. * @param featureName the name of feature to attach
  50600. */
  50601. attachFeature(featureName: string): void;
  50602. /**
  50603. * Can be used inside a session or when the session ends to detach a specific feature
  50604. * @param featureName the name of the feature to detach
  50605. */
  50606. detachFeature(featureName: string): void;
  50607. /**
  50608. * Used to disable an already-enabled feature
  50609. * The feature will be disposed and will be recreated once enabled.
  50610. * @param featureName the feature to disable
  50611. * @returns true if disable was successful
  50612. */
  50613. disableFeature(featureName: string | {
  50614. Name: string;
  50615. }): boolean;
  50616. /**
  50617. * dispose this features manager
  50618. */
  50619. dispose(): void;
  50620. /**
  50621. * 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.
  50622. * 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.
  50623. *
  50624. * @param featureName the name of the feature to load or the class of the feature
  50625. * @param version optional version to load. if not provided the latest version will be enabled
  50626. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  50627. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  50628. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  50629. * @returns a new constructed feature or throws an error if feature not found.
  50630. */
  50631. enableFeature(featureName: string | {
  50632. Name: string;
  50633. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  50634. /**
  50635. * get the implementation of an enabled feature.
  50636. * @param featureName the name of the feature to load
  50637. * @returns the feature class, if found
  50638. */
  50639. getEnabledFeature(featureName: string): IWebXRFeature;
  50640. /**
  50641. * Get the list of enabled features
  50642. * @returns an array of enabled features
  50643. */
  50644. getEnabledFeatures(): string[];
  50645. /**
  50646. * This function will exten the session creation configuration object with enabled features.
  50647. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  50648. * according to the defined "required" variable, provided during enableFeature call
  50649. * @param xrSessionInit the xr Session init object to extend
  50650. *
  50651. * @returns an extended XRSessionInit object
  50652. */
  50653. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  50654. }
  50655. }
  50656. declare module BABYLON {
  50657. /**
  50658. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  50659. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  50660. */
  50661. export class WebXRExperienceHelper implements IDisposable {
  50662. private scene;
  50663. private _nonVRCamera;
  50664. private _originalSceneAutoClear;
  50665. private _supported;
  50666. /**
  50667. * Camera used to render xr content
  50668. */
  50669. camera: WebXRCamera;
  50670. /** A features manager for this xr session */
  50671. featuresManager: WebXRFeaturesManager;
  50672. /**
  50673. * Observers registered here will be triggered after the camera's initial transformation is set
  50674. * This can be used to set a different ground level or an extra rotation.
  50675. *
  50676. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  50677. * to the position set after this observable is done executing.
  50678. */
  50679. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  50680. /**
  50681. * Fires when the state of the experience helper has changed
  50682. */
  50683. onStateChangedObservable: Observable<WebXRState>;
  50684. /** Session manager used to keep track of xr session */
  50685. sessionManager: WebXRSessionManager;
  50686. /**
  50687. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  50688. */
  50689. state: WebXRState;
  50690. /**
  50691. * Creates a WebXRExperienceHelper
  50692. * @param scene The scene the helper should be created in
  50693. */
  50694. private constructor();
  50695. /**
  50696. * Creates the experience helper
  50697. * @param scene the scene to attach the experience helper to
  50698. * @returns a promise for the experience helper
  50699. */
  50700. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  50701. /**
  50702. * Disposes of the experience helper
  50703. */
  50704. dispose(): void;
  50705. /**
  50706. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  50707. * @param sessionMode options for the XR session
  50708. * @param referenceSpaceType frame of reference of the XR session
  50709. * @param renderTarget the output canvas that will be used to enter XR mode
  50710. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  50711. * @returns promise that resolves after xr mode has entered
  50712. */
  50713. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  50714. /**
  50715. * Exits XR mode and returns the scene to its original state
  50716. * @returns promise that resolves after xr mode has exited
  50717. */
  50718. exitXRAsync(): Promise<void>;
  50719. private _nonXRToXRCamera;
  50720. private _setState;
  50721. }
  50722. }
  50723. declare module BABYLON {
  50724. /**
  50725. * X-Y values for axes in WebXR
  50726. */
  50727. export interface IWebXRMotionControllerAxesValue {
  50728. /**
  50729. * The value of the x axis
  50730. */
  50731. x: number;
  50732. /**
  50733. * The value of the y-axis
  50734. */
  50735. y: number;
  50736. }
  50737. /**
  50738. * changed / previous values for the values of this component
  50739. */
  50740. export interface IWebXRMotionControllerComponentChangesValues<T> {
  50741. /**
  50742. * current (this frame) value
  50743. */
  50744. current: T;
  50745. /**
  50746. * previous (last change) value
  50747. */
  50748. previous: T;
  50749. }
  50750. /**
  50751. * Represents changes in the component between current frame and last values recorded
  50752. */
  50753. export interface IWebXRMotionControllerComponentChanges {
  50754. /**
  50755. * will be populated with previous and current values if axes changed
  50756. */
  50757. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  50758. /**
  50759. * will be populated with previous and current values if pressed changed
  50760. */
  50761. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  50762. /**
  50763. * will be populated with previous and current values if touched changed
  50764. */
  50765. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  50766. /**
  50767. * will be populated with previous and current values if value changed
  50768. */
  50769. value?: IWebXRMotionControllerComponentChangesValues<number>;
  50770. }
  50771. /**
  50772. * This class represents a single component (for example button or thumbstick) of a motion controller
  50773. */
  50774. export class WebXRControllerComponent implements IDisposable {
  50775. /**
  50776. * the id of this component
  50777. */
  50778. id: string;
  50779. /**
  50780. * the type of the component
  50781. */
  50782. type: MotionControllerComponentType;
  50783. private _buttonIndex;
  50784. private _axesIndices;
  50785. private _axes;
  50786. private _changes;
  50787. private _currentValue;
  50788. private _hasChanges;
  50789. private _pressed;
  50790. private _touched;
  50791. /**
  50792. * button component type
  50793. */
  50794. static BUTTON_TYPE: MotionControllerComponentType;
  50795. /**
  50796. * squeeze component type
  50797. */
  50798. static SQUEEZE_TYPE: MotionControllerComponentType;
  50799. /**
  50800. * Thumbstick component type
  50801. */
  50802. static THUMBSTICK_TYPE: MotionControllerComponentType;
  50803. /**
  50804. * Touchpad component type
  50805. */
  50806. static TOUCHPAD_TYPE: MotionControllerComponentType;
  50807. /**
  50808. * trigger component type
  50809. */
  50810. static TRIGGER_TYPE: MotionControllerComponentType;
  50811. /**
  50812. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  50813. * the axes data changes
  50814. */
  50815. onAxisValueChangedObservable: Observable<{
  50816. x: number;
  50817. y: number;
  50818. }>;
  50819. /**
  50820. * Observers registered here will be triggered when the state of a button changes
  50821. * State change is either pressed / touched / value
  50822. */
  50823. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  50824. /**
  50825. * Creates a new component for a motion controller.
  50826. * It is created by the motion controller itself
  50827. *
  50828. * @param id the id of this component
  50829. * @param type the type of the component
  50830. * @param _buttonIndex index in the buttons array of the gamepad
  50831. * @param _axesIndices indices of the values in the axes array of the gamepad
  50832. */
  50833. constructor(
  50834. /**
  50835. * the id of this component
  50836. */
  50837. id: string,
  50838. /**
  50839. * the type of the component
  50840. */
  50841. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  50842. /**
  50843. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  50844. */
  50845. get axes(): IWebXRMotionControllerAxesValue;
  50846. /**
  50847. * Get the changes. Elements will be populated only if they changed with their previous and current value
  50848. */
  50849. get changes(): IWebXRMotionControllerComponentChanges;
  50850. /**
  50851. * Return whether or not the component changed the last frame
  50852. */
  50853. get hasChanges(): boolean;
  50854. /**
  50855. * is the button currently pressed
  50856. */
  50857. get pressed(): boolean;
  50858. /**
  50859. * is the button currently touched
  50860. */
  50861. get touched(): boolean;
  50862. /**
  50863. * Get the current value of this component
  50864. */
  50865. get value(): number;
  50866. /**
  50867. * Dispose this component
  50868. */
  50869. dispose(): void;
  50870. /**
  50871. * Are there axes correlating to this component
  50872. * @return true is axes data is available
  50873. */
  50874. isAxes(): boolean;
  50875. /**
  50876. * Is this component a button (hence - pressable)
  50877. * @returns true if can be pressed
  50878. */
  50879. isButton(): boolean;
  50880. /**
  50881. * update this component using the gamepad object it is in. Called on every frame
  50882. * @param nativeController the native gamepad controller object
  50883. */
  50884. update(nativeController: IMinimalMotionControllerObject): void;
  50885. }
  50886. }
  50887. declare module BABYLON {
  50888. /**
  50889. * Interface used to represent data loading progression
  50890. */
  50891. export interface ISceneLoaderProgressEvent {
  50892. /**
  50893. * Defines if data length to load can be evaluated
  50894. */
  50895. readonly lengthComputable: boolean;
  50896. /**
  50897. * Defines the loaded data length
  50898. */
  50899. readonly loaded: number;
  50900. /**
  50901. * Defines the data length to load
  50902. */
  50903. readonly total: number;
  50904. }
  50905. /**
  50906. * Interface used by SceneLoader plugins to define supported file extensions
  50907. */
  50908. export interface ISceneLoaderPluginExtensions {
  50909. /**
  50910. * Defines the list of supported extensions
  50911. */
  50912. [extension: string]: {
  50913. isBinary: boolean;
  50914. };
  50915. }
  50916. /**
  50917. * Interface used by SceneLoader plugin factory
  50918. */
  50919. export interface ISceneLoaderPluginFactory {
  50920. /**
  50921. * Defines the name of the factory
  50922. */
  50923. name: string;
  50924. /**
  50925. * Function called to create a new plugin
  50926. * @return the new plugin
  50927. */
  50928. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  50929. /**
  50930. * The callback that returns true if the data can be directly loaded.
  50931. * @param data string containing the file data
  50932. * @returns if the data can be loaded directly
  50933. */
  50934. canDirectLoad?(data: string): boolean;
  50935. }
  50936. /**
  50937. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  50938. */
  50939. export interface ISceneLoaderPluginBase {
  50940. /**
  50941. * The friendly name of this plugin.
  50942. */
  50943. name: string;
  50944. /**
  50945. * The file extensions supported by this plugin.
  50946. */
  50947. extensions: string | ISceneLoaderPluginExtensions;
  50948. /**
  50949. * The callback called when loading from a url.
  50950. * @param scene scene loading this url
  50951. * @param url url to load
  50952. * @param onSuccess callback called when the file successfully loads
  50953. * @param onProgress callback called while file is loading (if the server supports this mode)
  50954. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  50955. * @param onError callback called when the file fails to load
  50956. * @returns a file request object
  50957. */
  50958. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  50959. /**
  50960. * The callback called when loading from a file object.
  50961. * @param scene scene loading this file
  50962. * @param file defines the file to load
  50963. * @param onSuccess defines the callback to call when data is loaded
  50964. * @param onProgress defines the callback to call during loading process
  50965. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  50966. * @param onError defines the callback to call when an error occurs
  50967. * @returns a file request object
  50968. */
  50969. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  50970. /**
  50971. * The callback that returns true if the data can be directly loaded.
  50972. * @param data string containing the file data
  50973. * @returns if the data can be loaded directly
  50974. */
  50975. canDirectLoad?(data: string): boolean;
  50976. /**
  50977. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  50978. * @param scene scene loading this data
  50979. * @param data string containing the data
  50980. * @returns data to pass to the plugin
  50981. */
  50982. directLoad?(scene: Scene, data: string): any;
  50983. /**
  50984. * The callback that allows custom handling of the root url based on the response url.
  50985. * @param rootUrl the original root url
  50986. * @param responseURL the response url if available
  50987. * @returns the new root url
  50988. */
  50989. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  50990. }
  50991. /**
  50992. * Interface used to define a SceneLoader plugin
  50993. */
  50994. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  50995. /**
  50996. * Import meshes into a scene.
  50997. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  50998. * @param scene The scene to import into
  50999. * @param data The data to import
  51000. * @param rootUrl The root url for scene and resources
  51001. * @param meshes The meshes array to import into
  51002. * @param particleSystems The particle systems array to import into
  51003. * @param skeletons The skeletons array to import into
  51004. * @param onError The callback when import fails
  51005. * @returns True if successful or false otherwise
  51006. */
  51007. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  51008. /**
  51009. * Load into a scene.
  51010. * @param scene The scene to load into
  51011. * @param data The data to import
  51012. * @param rootUrl The root url for scene and resources
  51013. * @param onError The callback when import fails
  51014. * @returns True if successful or false otherwise
  51015. */
  51016. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  51017. /**
  51018. * Load into an asset container.
  51019. * @param scene The scene to load into
  51020. * @param data The data to import
  51021. * @param rootUrl The root url for scene and resources
  51022. * @param onError The callback when import fails
  51023. * @returns The loaded asset container
  51024. */
  51025. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  51026. }
  51027. /**
  51028. * Interface used to define an async SceneLoader plugin
  51029. */
  51030. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  51031. /**
  51032. * Import meshes into a scene.
  51033. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51034. * @param scene The scene to import into
  51035. * @param data The data to import
  51036. * @param rootUrl The root url for scene and resources
  51037. * @param onProgress The callback when the load progresses
  51038. * @param fileName Defines the name of the file to load
  51039. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  51040. */
  51041. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  51042. meshes: AbstractMesh[];
  51043. particleSystems: IParticleSystem[];
  51044. skeletons: Skeleton[];
  51045. animationGroups: AnimationGroup[];
  51046. }>;
  51047. /**
  51048. * Load into a scene.
  51049. * @param scene The scene to load into
  51050. * @param data The data to import
  51051. * @param rootUrl The root url for scene and resources
  51052. * @param onProgress The callback when the load progresses
  51053. * @param fileName Defines the name of the file to load
  51054. * @returns Nothing
  51055. */
  51056. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  51057. /**
  51058. * Load into an asset container.
  51059. * @param scene The scene to load into
  51060. * @param data The data to import
  51061. * @param rootUrl The root url for scene and resources
  51062. * @param onProgress The callback when the load progresses
  51063. * @param fileName Defines the name of the file to load
  51064. * @returns The loaded asset container
  51065. */
  51066. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  51067. }
  51068. /**
  51069. * Mode that determines how to handle old animation groups before loading new ones.
  51070. */
  51071. export enum SceneLoaderAnimationGroupLoadingMode {
  51072. /**
  51073. * Reset all old animations to initial state then dispose them.
  51074. */
  51075. Clean = 0,
  51076. /**
  51077. * Stop all old animations.
  51078. */
  51079. Stop = 1,
  51080. /**
  51081. * Restart old animations from first frame.
  51082. */
  51083. Sync = 2,
  51084. /**
  51085. * Old animations remains untouched.
  51086. */
  51087. NoSync = 3
  51088. }
  51089. /**
  51090. * Defines a plugin registered by the SceneLoader
  51091. */
  51092. interface IRegisteredPlugin {
  51093. /**
  51094. * Defines the plugin to use
  51095. */
  51096. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  51097. /**
  51098. * Defines if the plugin supports binary data
  51099. */
  51100. isBinary: boolean;
  51101. }
  51102. /**
  51103. * Class used to load scene from various file formats using registered plugins
  51104. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  51105. */
  51106. export class SceneLoader {
  51107. /**
  51108. * No logging while loading
  51109. */
  51110. static readonly NO_LOGGING: number;
  51111. /**
  51112. * Minimal logging while loading
  51113. */
  51114. static readonly MINIMAL_LOGGING: number;
  51115. /**
  51116. * Summary logging while loading
  51117. */
  51118. static readonly SUMMARY_LOGGING: number;
  51119. /**
  51120. * Detailled logging while loading
  51121. */
  51122. static readonly DETAILED_LOGGING: number;
  51123. /**
  51124. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  51125. */
  51126. static get ForceFullSceneLoadingForIncremental(): boolean;
  51127. static set ForceFullSceneLoadingForIncremental(value: boolean);
  51128. /**
  51129. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  51130. */
  51131. static get ShowLoadingScreen(): boolean;
  51132. static set ShowLoadingScreen(value: boolean);
  51133. /**
  51134. * Defines the current logging level (while loading the scene)
  51135. * @ignorenaming
  51136. */
  51137. static get loggingLevel(): number;
  51138. static set loggingLevel(value: number);
  51139. /**
  51140. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  51141. */
  51142. static get CleanBoneMatrixWeights(): boolean;
  51143. static set CleanBoneMatrixWeights(value: boolean);
  51144. /**
  51145. * Event raised when a plugin is used to load a scene
  51146. */
  51147. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  51148. private static _registeredPlugins;
  51149. private static _showingLoadingScreen;
  51150. /**
  51151. * Gets the default plugin (used to load Babylon files)
  51152. * @returns the .babylon plugin
  51153. */
  51154. static GetDefaultPlugin(): IRegisteredPlugin;
  51155. private static _GetPluginForExtension;
  51156. private static _GetPluginForDirectLoad;
  51157. private static _GetPluginForFilename;
  51158. private static _GetDirectLoad;
  51159. private static _LoadData;
  51160. private static _GetFileInfo;
  51161. /**
  51162. * Gets a plugin that can load the given extension
  51163. * @param extension defines the extension to load
  51164. * @returns a plugin or null if none works
  51165. */
  51166. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  51167. /**
  51168. * Gets a boolean indicating that the given extension can be loaded
  51169. * @param extension defines the extension to load
  51170. * @returns true if the extension is supported
  51171. */
  51172. static IsPluginForExtensionAvailable(extension: string): boolean;
  51173. /**
  51174. * Adds a new plugin to the list of registered plugins
  51175. * @param plugin defines the plugin to add
  51176. */
  51177. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  51178. /**
  51179. * Import meshes into a scene
  51180. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51181. * @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)
  51182. * @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)
  51183. * @param scene the instance of BABYLON.Scene to append to
  51184. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  51185. * @param onProgress a callback with a progress event for each file being loaded
  51186. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51187. * @param pluginExtension the extension used to determine the plugin
  51188. * @returns The loaded plugin
  51189. */
  51190. 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>;
  51191. /**
  51192. * Import meshes into a scene
  51193. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51194. * @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)
  51195. * @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)
  51196. * @param scene the instance of BABYLON.Scene to append to
  51197. * @param onProgress a callback with a progress event for each file being loaded
  51198. * @param pluginExtension the extension used to determine the plugin
  51199. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  51200. */
  51201. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  51202. meshes: AbstractMesh[];
  51203. particleSystems: IParticleSystem[];
  51204. skeletons: Skeleton[];
  51205. animationGroups: AnimationGroup[];
  51206. }>;
  51207. /**
  51208. * Load a scene
  51209. * @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)
  51210. * @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)
  51211. * @param engine is the instance of BABYLON.Engine to use to create the scene
  51212. * @param onSuccess a callback with the scene when import succeeds
  51213. * @param onProgress a callback with a progress event for each file being loaded
  51214. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51215. * @param pluginExtension the extension used to determine the plugin
  51216. * @returns The loaded plugin
  51217. */
  51218. 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>;
  51219. /**
  51220. * Load a scene
  51221. * @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)
  51222. * @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)
  51223. * @param engine is the instance of BABYLON.Engine to use to create the scene
  51224. * @param onProgress a callback with a progress event for each file being loaded
  51225. * @param pluginExtension the extension used to determine the plugin
  51226. * @returns The loaded scene
  51227. */
  51228. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  51229. /**
  51230. * Append a scene
  51231. * @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)
  51232. * @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)
  51233. * @param scene is the instance of BABYLON.Scene to append to
  51234. * @param onSuccess a callback with the scene when import succeeds
  51235. * @param onProgress a callback with a progress event for each file being loaded
  51236. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51237. * @param pluginExtension the extension used to determine the plugin
  51238. * @returns The loaded plugin
  51239. */
  51240. 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>;
  51241. /**
  51242. * Append 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 scene is the instance of BABYLON.Scene to append to
  51246. * @param onProgress a callback with a progress event for each file being loaded
  51247. * @param pluginExtension the extension used to determine the plugin
  51248. * @returns The given scene
  51249. */
  51250. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  51251. /**
  51252. * Load a scene into an asset container
  51253. * @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)
  51254. * @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)
  51255. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51256. * @param onSuccess a callback with the scene when import succeeds
  51257. * @param onProgress a callback with a progress event for each file being loaded
  51258. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51259. * @param pluginExtension the extension used to determine the plugin
  51260. * @returns The loaded plugin
  51261. */
  51262. 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>;
  51263. /**
  51264. * Load a scene into an asset container
  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 (default: empty string)
  51267. * @param scene is the instance of Scene to append to
  51268. * @param onProgress a callback with a progress event for each file being loaded
  51269. * @param pluginExtension the extension used to determine the plugin
  51270. * @returns The loaded asset container
  51271. */
  51272. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  51273. /**
  51274. * Import animations from a file into a scene
  51275. * @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)
  51276. * @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)
  51277. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51278. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  51279. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  51280. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  51281. * @param onSuccess a callback with the scene when import succeeds
  51282. * @param onProgress a callback with a progress event for each file being loaded
  51283. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51284. * @param pluginExtension the extension used to determine the plugin
  51285. */
  51286. 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;
  51287. /**
  51288. * Import animations from a file into a scene
  51289. * @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)
  51290. * @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)
  51291. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51292. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  51293. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  51294. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  51295. * @param onSuccess a callback with the scene when import succeeds
  51296. * @param onProgress a callback with a progress event for each file being loaded
  51297. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51298. * @param pluginExtension the extension used to determine the plugin
  51299. * @returns the updated scene with imported animations
  51300. */
  51301. 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>;
  51302. }
  51303. }
  51304. declare module BABYLON {
  51305. /**
  51306. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  51307. */
  51308. export type MotionControllerHandedness = "none" | "left" | "right";
  51309. /**
  51310. * The type of components available in motion controllers.
  51311. * This is not the name of the component.
  51312. */
  51313. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  51314. /**
  51315. * The state of a controller component
  51316. */
  51317. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  51318. /**
  51319. * The schema of motion controller layout.
  51320. * No object will be initialized using this interface
  51321. * This is used just to define the profile.
  51322. */
  51323. export interface IMotionControllerLayout {
  51324. /**
  51325. * Path to load the assets. Usually relative to the base path
  51326. */
  51327. assetPath: string;
  51328. /**
  51329. * Available components (unsorted)
  51330. */
  51331. components: {
  51332. /**
  51333. * A map of component Ids
  51334. */
  51335. [componentId: string]: {
  51336. /**
  51337. * The type of input the component outputs
  51338. */
  51339. type: MotionControllerComponentType;
  51340. /**
  51341. * The indices of this component in the gamepad object
  51342. */
  51343. gamepadIndices: {
  51344. /**
  51345. * Index of button
  51346. */
  51347. button?: number;
  51348. /**
  51349. * If available, index of x-axis
  51350. */
  51351. xAxis?: number;
  51352. /**
  51353. * If available, index of y-axis
  51354. */
  51355. yAxis?: number;
  51356. };
  51357. /**
  51358. * The mesh's root node name
  51359. */
  51360. rootNodeName: string;
  51361. /**
  51362. * Animation definitions for this model
  51363. */
  51364. visualResponses: {
  51365. [stateKey: string]: {
  51366. /**
  51367. * What property will be animated
  51368. */
  51369. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  51370. /**
  51371. * What states influence this visual response
  51372. */
  51373. states: MotionControllerComponentStateType[];
  51374. /**
  51375. * Type of animation - movement or visibility
  51376. */
  51377. valueNodeProperty: "transform" | "visibility";
  51378. /**
  51379. * Base node name to move. Its position will be calculated according to the min and max nodes
  51380. */
  51381. valueNodeName?: string;
  51382. /**
  51383. * Minimum movement node
  51384. */
  51385. minNodeName?: string;
  51386. /**
  51387. * Max movement node
  51388. */
  51389. maxNodeName?: string;
  51390. };
  51391. };
  51392. /**
  51393. * If touch enabled, what is the name of node to display user feedback
  51394. */
  51395. touchPointNodeName?: string;
  51396. };
  51397. };
  51398. /**
  51399. * Is it xr standard mapping or not
  51400. */
  51401. gamepadMapping: "" | "xr-standard";
  51402. /**
  51403. * Base root node of this entire model
  51404. */
  51405. rootNodeName: string;
  51406. /**
  51407. * Defines the main button component id
  51408. */
  51409. selectComponentId: string;
  51410. }
  51411. /**
  51412. * A definition for the layout map in the input profile
  51413. */
  51414. export interface IMotionControllerLayoutMap {
  51415. /**
  51416. * Layouts with handedness type as a key
  51417. */
  51418. [handedness: string]: IMotionControllerLayout;
  51419. }
  51420. /**
  51421. * The XR Input profile schema
  51422. * Profiles can be found here:
  51423. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  51424. */
  51425. export interface IMotionControllerProfile {
  51426. /**
  51427. * fallback profiles for this profileId
  51428. */
  51429. fallbackProfileIds: string[];
  51430. /**
  51431. * The layout map, with handedness as key
  51432. */
  51433. layouts: IMotionControllerLayoutMap;
  51434. /**
  51435. * The id of this profile
  51436. * correlates to the profile(s) in the xrInput.profiles array
  51437. */
  51438. profileId: string;
  51439. }
  51440. /**
  51441. * A helper-interface for the 3 meshes needed for controller button animation
  51442. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  51443. */
  51444. export interface IMotionControllerButtonMeshMap {
  51445. /**
  51446. * the mesh that defines the pressed value mesh position.
  51447. * This is used to find the max-position of this button
  51448. */
  51449. pressedMesh: AbstractMesh;
  51450. /**
  51451. * the mesh that defines the unpressed value mesh position.
  51452. * This is used to find the min (or initial) position of this button
  51453. */
  51454. unpressedMesh: AbstractMesh;
  51455. /**
  51456. * The mesh that will be changed when value changes
  51457. */
  51458. valueMesh: AbstractMesh;
  51459. }
  51460. /**
  51461. * A helper-interface for the 3 meshes needed for controller axis animation.
  51462. * This will be expanded when touchpad animations are fully supported
  51463. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  51464. */
  51465. export interface IMotionControllerMeshMap {
  51466. /**
  51467. * the mesh that defines the maximum value mesh position.
  51468. */
  51469. maxMesh?: AbstractMesh;
  51470. /**
  51471. * the mesh that defines the minimum value mesh position.
  51472. */
  51473. minMesh?: AbstractMesh;
  51474. /**
  51475. * The mesh that will be changed when axis value changes
  51476. */
  51477. valueMesh?: AbstractMesh;
  51478. }
  51479. /**
  51480. * The elements needed for change-detection of the gamepad objects in motion controllers
  51481. */
  51482. export interface IMinimalMotionControllerObject {
  51483. /**
  51484. * Available axes of this controller
  51485. */
  51486. axes: number[];
  51487. /**
  51488. * An array of available buttons
  51489. */
  51490. buttons: Array<{
  51491. /**
  51492. * Value of the button/trigger
  51493. */
  51494. value: number;
  51495. /**
  51496. * If the button/trigger is currently touched
  51497. */
  51498. touched: boolean;
  51499. /**
  51500. * If the button/trigger is currently pressed
  51501. */
  51502. pressed: boolean;
  51503. }>;
  51504. /**
  51505. * EXPERIMENTAL haptic support.
  51506. */
  51507. hapticActuators?: Array<{
  51508. pulse: (value: number, duration: number) => Promise<boolean>;
  51509. }>;
  51510. }
  51511. /**
  51512. * An Abstract Motion controller
  51513. * This class receives an xrInput and a profile layout and uses those to initialize the components
  51514. * Each component has an observable to check for changes in value and state
  51515. */
  51516. export abstract class WebXRAbstractMotionController implements IDisposable {
  51517. protected scene: Scene;
  51518. protected layout: IMotionControllerLayout;
  51519. /**
  51520. * The gamepad object correlating to this controller
  51521. */
  51522. gamepadObject: IMinimalMotionControllerObject;
  51523. /**
  51524. * handedness (left/right/none) of this controller
  51525. */
  51526. handedness: MotionControllerHandedness;
  51527. private _initComponent;
  51528. private _modelReady;
  51529. /**
  51530. * A map of components (WebXRControllerComponent) in this motion controller
  51531. * Components have a ComponentType and can also have both button and axis definitions
  51532. */
  51533. readonly components: {
  51534. [id: string]: WebXRControllerComponent;
  51535. };
  51536. /**
  51537. * Disable the model's animation. Can be set at any time.
  51538. */
  51539. disableAnimation: boolean;
  51540. /**
  51541. * Observers registered here will be triggered when the model of this controller is done loading
  51542. */
  51543. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  51544. /**
  51545. * The profile id of this motion controller
  51546. */
  51547. abstract profileId: string;
  51548. /**
  51549. * The root mesh of the model. It is null if the model was not yet initialized
  51550. */
  51551. rootMesh: Nullable<AbstractMesh>;
  51552. /**
  51553. * constructs a new abstract motion controller
  51554. * @param scene the scene to which the model of the controller will be added
  51555. * @param layout The profile layout to load
  51556. * @param gamepadObject The gamepad object correlating to this controller
  51557. * @param handedness handedness (left/right/none) of this controller
  51558. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  51559. */
  51560. constructor(scene: Scene, layout: IMotionControllerLayout,
  51561. /**
  51562. * The gamepad object correlating to this controller
  51563. */
  51564. gamepadObject: IMinimalMotionControllerObject,
  51565. /**
  51566. * handedness (left/right/none) of this controller
  51567. */
  51568. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  51569. /**
  51570. * Dispose this controller, the model mesh and all its components
  51571. */
  51572. dispose(): void;
  51573. /**
  51574. * Returns all components of specific type
  51575. * @param type the type to search for
  51576. * @return an array of components with this type
  51577. */
  51578. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  51579. /**
  51580. * get a component based an its component id as defined in layout.components
  51581. * @param id the id of the component
  51582. * @returns the component correlates to the id or undefined if not found
  51583. */
  51584. getComponent(id: string): WebXRControllerComponent;
  51585. /**
  51586. * Get the list of components available in this motion controller
  51587. * @returns an array of strings correlating to available components
  51588. */
  51589. getComponentIds(): string[];
  51590. /**
  51591. * Get the first component of specific type
  51592. * @param type type of component to find
  51593. * @return a controller component or null if not found
  51594. */
  51595. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  51596. /**
  51597. * Get the main (Select) component of this controller as defined in the layout
  51598. * @returns the main component of this controller
  51599. */
  51600. getMainComponent(): WebXRControllerComponent;
  51601. /**
  51602. * Loads the model correlating to this controller
  51603. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  51604. * @returns A promise fulfilled with the result of the model loading
  51605. */
  51606. loadModel(): Promise<boolean>;
  51607. /**
  51608. * Update this model using the current XRFrame
  51609. * @param xrFrame the current xr frame to use and update the model
  51610. */
  51611. updateFromXRFrame(xrFrame: XRFrame): void;
  51612. /**
  51613. * Backwards compatibility due to a deeply-integrated typo
  51614. */
  51615. get handness(): XREye;
  51616. /**
  51617. * Pulse (vibrate) this controller
  51618. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  51619. * Consecutive calls to this function will cancel the last pulse call
  51620. *
  51621. * @param value the strength of the pulse in 0.0...1.0 range
  51622. * @param duration Duration of the pulse in milliseconds
  51623. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  51624. * @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
  51625. */
  51626. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  51627. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  51628. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  51629. /**
  51630. * Moves the axis on the controller mesh based on its current state
  51631. * @param axis the index of the axis
  51632. * @param axisValue the value of the axis which determines the meshes new position
  51633. * @hidden
  51634. */
  51635. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  51636. /**
  51637. * Update the model itself with the current frame data
  51638. * @param xrFrame the frame to use for updating the model mesh
  51639. */
  51640. protected updateModel(xrFrame: XRFrame): void;
  51641. /**
  51642. * Get the filename and path for this controller's model
  51643. * @returns a map of filename and path
  51644. */
  51645. protected abstract _getFilenameAndPath(): {
  51646. filename: string;
  51647. path: string;
  51648. };
  51649. /**
  51650. * This function is called before the mesh is loaded. It checks for loading constraints.
  51651. * For example, this function can check if the GLB loader is available
  51652. * If this function returns false, the generic controller will be loaded instead
  51653. * @returns Is the client ready to load the mesh
  51654. */
  51655. protected abstract _getModelLoadingConstraints(): boolean;
  51656. /**
  51657. * This function will be called after the model was successfully loaded and can be used
  51658. * for mesh transformations before it is available for the user
  51659. * @param meshes the loaded meshes
  51660. */
  51661. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  51662. /**
  51663. * Set the root mesh for this controller. Important for the WebXR controller class
  51664. * @param meshes the loaded meshes
  51665. */
  51666. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  51667. /**
  51668. * A function executed each frame that updates the mesh (if needed)
  51669. * @param xrFrame the current xrFrame
  51670. */
  51671. protected abstract _updateModel(xrFrame: XRFrame): void;
  51672. private _getGenericFilenameAndPath;
  51673. private _getGenericParentMesh;
  51674. }
  51675. }
  51676. declare module BABYLON {
  51677. /**
  51678. * A generic trigger-only motion controller for WebXR
  51679. */
  51680. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  51681. /**
  51682. * Static version of the profile id of this controller
  51683. */
  51684. static ProfileId: string;
  51685. profileId: string;
  51686. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  51687. protected _getFilenameAndPath(): {
  51688. filename: string;
  51689. path: string;
  51690. };
  51691. protected _getModelLoadingConstraints(): boolean;
  51692. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  51693. protected _setRootMesh(meshes: AbstractMesh[]): void;
  51694. protected _updateModel(): void;
  51695. }
  51696. }
  51697. declare module BABYLON {
  51698. /**
  51699. * Class containing static functions to help procedurally build meshes
  51700. */
  51701. export class SphereBuilder {
  51702. /**
  51703. * Creates a sphere mesh
  51704. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  51705. * * 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`)
  51706. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  51707. * * 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
  51708. * * 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)
  51709. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51710. * * 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
  51711. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51712. * @param name defines the name of the mesh
  51713. * @param options defines the options used to create the mesh
  51714. * @param scene defines the hosting scene
  51715. * @returns the sphere mesh
  51716. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  51717. */
  51718. static CreateSphere(name: string, options: {
  51719. segments?: number;
  51720. diameter?: number;
  51721. diameterX?: number;
  51722. diameterY?: number;
  51723. diameterZ?: number;
  51724. arc?: number;
  51725. slice?: number;
  51726. sideOrientation?: number;
  51727. frontUVs?: Vector4;
  51728. backUVs?: Vector4;
  51729. updatable?: boolean;
  51730. }, scene?: Nullable<Scene>): Mesh;
  51731. }
  51732. }
  51733. declare module BABYLON {
  51734. /**
  51735. * A profiled motion controller has its profile loaded from an online repository.
  51736. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  51737. */
  51738. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  51739. private _repositoryUrl;
  51740. private _buttonMeshMapping;
  51741. private _touchDots;
  51742. /**
  51743. * The profile ID of this controller. Will be populated when the controller initializes.
  51744. */
  51745. profileId: string;
  51746. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  51747. dispose(): void;
  51748. protected _getFilenameAndPath(): {
  51749. filename: string;
  51750. path: string;
  51751. };
  51752. protected _getModelLoadingConstraints(): boolean;
  51753. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  51754. protected _setRootMesh(meshes: AbstractMesh[]): void;
  51755. protected _updateModel(_xrFrame: XRFrame): void;
  51756. }
  51757. }
  51758. declare module BABYLON {
  51759. /**
  51760. * A construction function type to create a new controller based on an xrInput object
  51761. */
  51762. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  51763. /**
  51764. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  51765. *
  51766. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  51767. * it should be replaced with auto-loaded controllers.
  51768. *
  51769. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  51770. */
  51771. export class WebXRMotionControllerManager {
  51772. private static _AvailableControllers;
  51773. private static _Fallbacks;
  51774. private static _ProfileLoadingPromises;
  51775. private static _ProfilesList;
  51776. /**
  51777. * The base URL of the online controller repository. Can be changed at any time.
  51778. */
  51779. static BaseRepositoryUrl: string;
  51780. /**
  51781. * Which repository gets priority - local or online
  51782. */
  51783. static PrioritizeOnlineRepository: boolean;
  51784. /**
  51785. * Use the online repository, or use only locally-defined controllers
  51786. */
  51787. static UseOnlineRepository: boolean;
  51788. /**
  51789. * Clear the cache used for profile loading and reload when requested again
  51790. */
  51791. static ClearProfilesCache(): void;
  51792. /**
  51793. * Register the default fallbacks.
  51794. * This function is called automatically when this file is imported.
  51795. */
  51796. static DefaultFallbacks(): void;
  51797. /**
  51798. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  51799. * @param profileId the profile to which a fallback needs to be found
  51800. * @return an array with corresponding fallback profiles
  51801. */
  51802. static FindFallbackWithProfileId(profileId: string): string[];
  51803. /**
  51804. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  51805. * The order of search:
  51806. *
  51807. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  51808. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  51809. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  51810. * 4) return the generic trigger controller if none were found
  51811. *
  51812. * @param xrInput the xrInput to which a new controller is initialized
  51813. * @param scene the scene to which the model will be added
  51814. * @param forceProfile force a certain profile for this controller
  51815. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  51816. */
  51817. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  51818. /**
  51819. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  51820. *
  51821. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  51822. *
  51823. * @param type the profile type to register
  51824. * @param constructFunction the function to be called when loading this profile
  51825. */
  51826. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  51827. /**
  51828. * Register a fallback to a specific profile.
  51829. * @param profileId the profileId that will receive the fallbacks
  51830. * @param fallbacks A list of fallback profiles
  51831. */
  51832. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  51833. /**
  51834. * Will update the list of profiles available in the repository
  51835. * @return a promise that resolves to a map of profiles available online
  51836. */
  51837. static UpdateProfilesList(): Promise<{
  51838. [profile: string]: string;
  51839. }>;
  51840. private static _LoadProfileFromRepository;
  51841. private static _LoadProfilesFromAvailableControllers;
  51842. }
  51843. }
  51844. declare module BABYLON {
  51845. /**
  51846. * Configuration options for the WebXR controller creation
  51847. */
  51848. export interface IWebXRControllerOptions {
  51849. /**
  51850. * Should the controller mesh be animated when a user interacts with it
  51851. * The pressed buttons / thumbstick and touchpad animations will be disabled
  51852. */
  51853. disableMotionControllerAnimation?: boolean;
  51854. /**
  51855. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  51856. */
  51857. doNotLoadControllerMesh?: boolean;
  51858. /**
  51859. * Force a specific controller type for this controller.
  51860. * This can be used when creating your own profile or when testing different controllers
  51861. */
  51862. forceControllerProfile?: string;
  51863. /**
  51864. * Defines a rendering group ID for meshes that will be loaded.
  51865. * This is for the default controllers only.
  51866. */
  51867. renderingGroupId?: number;
  51868. }
  51869. /**
  51870. * Represents an XR controller
  51871. */
  51872. export class WebXRInputSource {
  51873. private _scene;
  51874. /** The underlying input source for the controller */
  51875. inputSource: XRInputSource;
  51876. private _options;
  51877. private _tmpVector;
  51878. private _uniqueId;
  51879. private _disposed;
  51880. /**
  51881. * 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
  51882. */
  51883. grip?: AbstractMesh;
  51884. /**
  51885. * If available, this is the gamepad object related to this controller.
  51886. * Using this object it is possible to get click events and trackpad changes of the
  51887. * webxr controller that is currently being used.
  51888. */
  51889. motionController?: WebXRAbstractMotionController;
  51890. /**
  51891. * Event that fires when the controller is removed/disposed.
  51892. * The object provided as event data is this controller, after associated assets were disposed.
  51893. * uniqueId is still available.
  51894. */
  51895. onDisposeObservable: Observable<WebXRInputSource>;
  51896. /**
  51897. * Will be triggered when the mesh associated with the motion controller is done loading.
  51898. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  51899. * A shortened version of controller -> motion controller -> on mesh loaded.
  51900. */
  51901. onMeshLoadedObservable: Observable<AbstractMesh>;
  51902. /**
  51903. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  51904. */
  51905. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  51906. /**
  51907. * Pointer which can be used to select objects or attach a visible laser to
  51908. */
  51909. pointer: AbstractMesh;
  51910. /**
  51911. * Creates the input source object
  51912. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  51913. * @param _scene the scene which the controller should be associated to
  51914. * @param inputSource the underlying input source for the controller
  51915. * @param _options options for this controller creation
  51916. */
  51917. constructor(_scene: Scene,
  51918. /** The underlying input source for the controller */
  51919. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  51920. /**
  51921. * Get this controllers unique id
  51922. */
  51923. get uniqueId(): string;
  51924. /**
  51925. * Disposes of the object
  51926. */
  51927. dispose(): void;
  51928. /**
  51929. * Gets a world space ray coming from the pointer or grip
  51930. * @param result the resulting ray
  51931. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  51932. */
  51933. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  51934. /**
  51935. * Updates the controller pose based on the given XRFrame
  51936. * @param xrFrame xr frame to update the pose with
  51937. * @param referenceSpace reference space to use
  51938. */
  51939. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  51940. }
  51941. }
  51942. declare module BABYLON {
  51943. /**
  51944. * The schema for initialization options of the XR Input class
  51945. */
  51946. export interface IWebXRInputOptions {
  51947. /**
  51948. * If set to true no model will be automatically loaded
  51949. */
  51950. doNotLoadControllerMeshes?: boolean;
  51951. /**
  51952. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  51953. * If not found, the xr input profile data will be used.
  51954. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  51955. */
  51956. forceInputProfile?: string;
  51957. /**
  51958. * Do not send a request to the controller repository to load the profile.
  51959. *
  51960. * Instead, use the controllers available in babylon itself.
  51961. */
  51962. disableOnlineControllerRepository?: boolean;
  51963. /**
  51964. * A custom URL for the controllers repository
  51965. */
  51966. customControllersRepositoryURL?: string;
  51967. /**
  51968. * Should the controller model's components not move according to the user input
  51969. */
  51970. disableControllerAnimation?: boolean;
  51971. /**
  51972. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  51973. */
  51974. controllerOptions?: IWebXRControllerOptions;
  51975. }
  51976. /**
  51977. * XR input used to track XR inputs such as controllers/rays
  51978. */
  51979. export class WebXRInput implements IDisposable {
  51980. /**
  51981. * the xr session manager for this session
  51982. */
  51983. xrSessionManager: WebXRSessionManager;
  51984. /**
  51985. * the WebXR camera for this session. Mainly used for teleportation
  51986. */
  51987. xrCamera: WebXRCamera;
  51988. private readonly options;
  51989. /**
  51990. * XR controllers being tracked
  51991. */
  51992. controllers: Array<WebXRInputSource>;
  51993. private _frameObserver;
  51994. private _sessionEndedObserver;
  51995. private _sessionInitObserver;
  51996. /**
  51997. * Event when a controller has been connected/added
  51998. */
  51999. onControllerAddedObservable: Observable<WebXRInputSource>;
  52000. /**
  52001. * Event when a controller has been removed/disconnected
  52002. */
  52003. onControllerRemovedObservable: Observable<WebXRInputSource>;
  52004. /**
  52005. * Initializes the WebXRInput
  52006. * @param xrSessionManager the xr session manager for this session
  52007. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  52008. * @param options = initialization options for this xr input
  52009. */
  52010. constructor(
  52011. /**
  52012. * the xr session manager for this session
  52013. */
  52014. xrSessionManager: WebXRSessionManager,
  52015. /**
  52016. * the WebXR camera for this session. Mainly used for teleportation
  52017. */
  52018. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  52019. private _onInputSourcesChange;
  52020. private _addAndRemoveControllers;
  52021. /**
  52022. * Disposes of the object
  52023. */
  52024. dispose(): void;
  52025. }
  52026. }
  52027. declare module BABYLON {
  52028. /**
  52029. * This is the base class for all WebXR features.
  52030. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  52031. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  52032. */
  52033. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  52034. protected _xrSessionManager: WebXRSessionManager;
  52035. private _attached;
  52036. private _removeOnDetach;
  52037. /**
  52038. * Is this feature disposed?
  52039. */
  52040. isDisposed: boolean;
  52041. /**
  52042. * Should auto-attach be disabled?
  52043. */
  52044. disableAutoAttach: boolean;
  52045. /**
  52046. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  52047. */
  52048. xrNativeFeatureName: string;
  52049. /**
  52050. * Construct a new (abstract) WebXR feature
  52051. * @param _xrSessionManager the xr session manager for this feature
  52052. */
  52053. constructor(_xrSessionManager: WebXRSessionManager);
  52054. /**
  52055. * Is this feature attached
  52056. */
  52057. get attached(): boolean;
  52058. /**
  52059. * attach this feature
  52060. *
  52061. * @param force should attachment be forced (even when already attached)
  52062. * @returns true if successful, false is failed or already attached
  52063. */
  52064. attach(force?: boolean): boolean;
  52065. /**
  52066. * detach this feature.
  52067. *
  52068. * @returns true if successful, false if failed or already detached
  52069. */
  52070. detach(): boolean;
  52071. /**
  52072. * Dispose this feature and all of the resources attached
  52073. */
  52074. dispose(): void;
  52075. /**
  52076. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  52077. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  52078. *
  52079. * @returns whether or not the feature is compatible in this environment
  52080. */
  52081. isCompatible(): boolean;
  52082. /**
  52083. * This is used to register callbacks that will automatically be removed when detach is called.
  52084. * @param observable the observable to which the observer will be attached
  52085. * @param callback the callback to register
  52086. */
  52087. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  52088. /**
  52089. * Code in this function will be executed on each xrFrame received from the browser.
  52090. * This function will not execute after the feature is detached.
  52091. * @param _xrFrame the current frame
  52092. */
  52093. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  52094. }
  52095. }
  52096. declare module BABYLON {
  52097. /**
  52098. * Renders a layer on top of an existing scene
  52099. */
  52100. export class UtilityLayerRenderer implements IDisposable {
  52101. /** the original scene that will be rendered on top of */
  52102. originalScene: Scene;
  52103. private _pointerCaptures;
  52104. private _lastPointerEvents;
  52105. private static _DefaultUtilityLayer;
  52106. private static _DefaultKeepDepthUtilityLayer;
  52107. private _sharedGizmoLight;
  52108. private _renderCamera;
  52109. /**
  52110. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  52111. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  52112. * @returns the camera that is used when rendering the utility layer
  52113. */
  52114. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  52115. /**
  52116. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  52117. * @param cam the camera that should be used when rendering the utility layer
  52118. */
  52119. setRenderCamera(cam: Nullable<Camera>): void;
  52120. /**
  52121. * @hidden
  52122. * Light which used by gizmos to get light shading
  52123. */
  52124. _getSharedGizmoLight(): HemisphericLight;
  52125. /**
  52126. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  52127. */
  52128. pickUtilitySceneFirst: boolean;
  52129. /**
  52130. * 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)
  52131. */
  52132. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  52133. /**
  52134. * 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)
  52135. */
  52136. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  52137. /**
  52138. * The scene that is rendered on top of the original scene
  52139. */
  52140. utilityLayerScene: Scene;
  52141. /**
  52142. * If the utility layer should automatically be rendered on top of existing scene
  52143. */
  52144. shouldRender: boolean;
  52145. /**
  52146. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  52147. */
  52148. onlyCheckPointerDownEvents: boolean;
  52149. /**
  52150. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  52151. */
  52152. processAllEvents: boolean;
  52153. /**
  52154. * Observable raised when the pointer move from the utility layer scene to the main scene
  52155. */
  52156. onPointerOutObservable: Observable<number>;
  52157. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  52158. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  52159. private _afterRenderObserver;
  52160. private _sceneDisposeObserver;
  52161. private _originalPointerObserver;
  52162. /**
  52163. * Instantiates a UtilityLayerRenderer
  52164. * @param originalScene the original scene that will be rendered on top of
  52165. * @param handleEvents boolean indicating if the utility layer should handle events
  52166. */
  52167. constructor(
  52168. /** the original scene that will be rendered on top of */
  52169. originalScene: Scene, handleEvents?: boolean);
  52170. private _notifyObservers;
  52171. /**
  52172. * Renders the utility layers scene on top of the original scene
  52173. */
  52174. render(): void;
  52175. /**
  52176. * Disposes of the renderer
  52177. */
  52178. dispose(): void;
  52179. private _updateCamera;
  52180. }
  52181. }
  52182. declare module BABYLON {
  52183. /**
  52184. * Options interface for the pointer selection module
  52185. */
  52186. export interface IWebXRControllerPointerSelectionOptions {
  52187. /**
  52188. * if provided, this scene will be used to render meshes.
  52189. */
  52190. customUtilityLayerScene?: Scene;
  52191. /**
  52192. * 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)
  52193. * If not disabled, the last picked point will be used to execute a pointer up event
  52194. * If disabled, pointer up event will be triggered right after the pointer down event.
  52195. * Used in screen and gaze target ray mode only
  52196. */
  52197. disablePointerUpOnTouchOut: boolean;
  52198. /**
  52199. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  52200. */
  52201. forceGazeMode: boolean;
  52202. /**
  52203. * 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
  52204. * to start a new countdown to the pointer down event.
  52205. * Defaults to 1.
  52206. */
  52207. gazeModePointerMovedFactor?: number;
  52208. /**
  52209. * Different button type to use instead of the main component
  52210. */
  52211. overrideButtonId?: string;
  52212. /**
  52213. * use this rendering group id for the meshes (optional)
  52214. */
  52215. renderingGroupId?: number;
  52216. /**
  52217. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  52218. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  52219. * 3000 means 3 seconds between pointing at something and selecting it
  52220. */
  52221. timeToSelect?: number;
  52222. /**
  52223. * Should meshes created here be added to a utility layer or the main scene
  52224. */
  52225. useUtilityLayer?: boolean;
  52226. /**
  52227. * Optional WebXR camera to be used for gaze selection
  52228. */
  52229. gazeCamera?: WebXRCamera;
  52230. /**
  52231. * the xr input to use with this pointer selection
  52232. */
  52233. xrInput: WebXRInput;
  52234. /**
  52235. * Should the scene pointerX and pointerY update be disabled
  52236. * This is required for fullscreen AR GUI, but might slow down other experiences.
  52237. * Disable in VR, if not needed.
  52238. * The first rig camera (left eye) will be used to calculate the projection
  52239. */
  52240. disableScenePointerVectorUpdate: boolean;
  52241. /**
  52242. * Enable pointer selection on all controllers instead of switching between them
  52243. */
  52244. enablePointerSelectionOnAllControllers?: boolean;
  52245. /**
  52246. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  52247. * If switch is enabled, it will still allow the user to switch between the different controllers
  52248. */
  52249. preferredHandedness?: XRHandedness;
  52250. /**
  52251. * Disable switching the pointer selection from one controller to the other.
  52252. * 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
  52253. */
  52254. disableSwitchOnClick?: boolean;
  52255. /**
  52256. * The maximum distance of the pointer selection feature. Defaults to 100.
  52257. */
  52258. maxPointerDistance?: number;
  52259. }
  52260. /**
  52261. * A module that will enable pointer selection for motion controllers of XR Input Sources
  52262. */
  52263. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  52264. private readonly _options;
  52265. private static _idCounter;
  52266. private _attachController;
  52267. private _controllers;
  52268. private _scene;
  52269. private _tmpVectorForPickCompare;
  52270. private _attachedController;
  52271. /**
  52272. * The module's name
  52273. */
  52274. static readonly Name: string;
  52275. /**
  52276. * The (Babylon) version of this module.
  52277. * This is an integer representing the implementation version.
  52278. * This number does not correspond to the WebXR specs version
  52279. */
  52280. static readonly Version: number;
  52281. /**
  52282. * Disable lighting on the laser pointer (so it will always be visible)
  52283. */
  52284. disablePointerLighting: boolean;
  52285. /**
  52286. * Disable lighting on the selection mesh (so it will always be visible)
  52287. */
  52288. disableSelectionMeshLighting: boolean;
  52289. /**
  52290. * Should the laser pointer be displayed
  52291. */
  52292. displayLaserPointer: boolean;
  52293. /**
  52294. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  52295. */
  52296. displaySelectionMesh: boolean;
  52297. /**
  52298. * This color will be set to the laser pointer when selection is triggered
  52299. */
  52300. laserPointerPickedColor: Color3;
  52301. /**
  52302. * Default color of the laser pointer
  52303. */
  52304. laserPointerDefaultColor: Color3;
  52305. /**
  52306. * default color of the selection ring
  52307. */
  52308. selectionMeshDefaultColor: Color3;
  52309. /**
  52310. * This color will be applied to the selection ring when selection is triggered
  52311. */
  52312. selectionMeshPickedColor: Color3;
  52313. /**
  52314. * Optional filter to be used for ray selection. This predicate shares behavior with
  52315. * scene.pointerMovePredicate which takes priority if it is also assigned.
  52316. */
  52317. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  52318. /**
  52319. * constructs a new background remover module
  52320. * @param _xrSessionManager the session manager for this module
  52321. * @param _options read-only options to be used in this module
  52322. */
  52323. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  52324. /**
  52325. * attach this feature
  52326. * Will usually be called by the features manager
  52327. *
  52328. * @returns true if successful.
  52329. */
  52330. attach(): boolean;
  52331. /**
  52332. * detach this feature.
  52333. * Will usually be called by the features manager
  52334. *
  52335. * @returns true if successful.
  52336. */
  52337. detach(): boolean;
  52338. /**
  52339. * Will get the mesh under a specific pointer.
  52340. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  52341. * @param controllerId the controllerId to check
  52342. * @returns The mesh under pointer or null if no mesh is under the pointer
  52343. */
  52344. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  52345. /**
  52346. * Get the xr controller that correlates to the pointer id in the pointer event
  52347. *
  52348. * @param id the pointer id to search for
  52349. * @returns the controller that correlates to this id or null if not found
  52350. */
  52351. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  52352. private _identityMatrix;
  52353. private _screenCoordinatesRef;
  52354. private _viewportRef;
  52355. protected _onXRFrame(_xrFrame: XRFrame): void;
  52356. private _attachGazeMode;
  52357. private _attachScreenRayMode;
  52358. private _attachTrackedPointerRayMode;
  52359. private _convertNormalToDirectionOfRay;
  52360. private _detachController;
  52361. private _generateNewMeshPair;
  52362. private _pickingMoved;
  52363. private _updatePointerDistance;
  52364. /** @hidden */
  52365. get lasterPointerDefaultColor(): Color3;
  52366. }
  52367. }
  52368. declare module BABYLON {
  52369. /**
  52370. * Button which can be used to enter a different mode of XR
  52371. */
  52372. export class WebXREnterExitUIButton {
  52373. /** button element */
  52374. element: HTMLElement;
  52375. /** XR initialization options for the button */
  52376. sessionMode: XRSessionMode;
  52377. /** Reference space type */
  52378. referenceSpaceType: XRReferenceSpaceType;
  52379. /**
  52380. * Creates a WebXREnterExitUIButton
  52381. * @param element button element
  52382. * @param sessionMode XR initialization session mode
  52383. * @param referenceSpaceType the type of reference space to be used
  52384. */
  52385. constructor(
  52386. /** button element */
  52387. element: HTMLElement,
  52388. /** XR initialization options for the button */
  52389. sessionMode: XRSessionMode,
  52390. /** Reference space type */
  52391. referenceSpaceType: XRReferenceSpaceType);
  52392. /**
  52393. * Extendable function which can be used to update the button's visuals when the state changes
  52394. * @param activeButton the current active button in the UI
  52395. */
  52396. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  52397. }
  52398. /**
  52399. * Options to create the webXR UI
  52400. */
  52401. export class WebXREnterExitUIOptions {
  52402. /**
  52403. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  52404. */
  52405. customButtons?: Array<WebXREnterExitUIButton>;
  52406. /**
  52407. * A reference space type to use when creating the default button.
  52408. * Default is local-floor
  52409. */
  52410. referenceSpaceType?: XRReferenceSpaceType;
  52411. /**
  52412. * Context to enter xr with
  52413. */
  52414. renderTarget?: Nullable<WebXRRenderTarget>;
  52415. /**
  52416. * A session mode to use when creating the default button.
  52417. * Default is immersive-vr
  52418. */
  52419. sessionMode?: XRSessionMode;
  52420. /**
  52421. * A list of optional features to init the session with
  52422. */
  52423. optionalFeatures?: string[];
  52424. /**
  52425. * A list of optional features to init the session with
  52426. */
  52427. requiredFeatures?: string[];
  52428. /**
  52429. * If defined, this function will be executed if the UI encounters an error when entering XR
  52430. */
  52431. onError?: (error: any) => void;
  52432. }
  52433. /**
  52434. * UI to allow the user to enter/exit XR mode
  52435. */
  52436. export class WebXREnterExitUI implements IDisposable {
  52437. private scene;
  52438. /** version of the options passed to this UI */
  52439. options: WebXREnterExitUIOptions;
  52440. private _activeButton;
  52441. private _buttons;
  52442. /**
  52443. * The HTML Div Element to which buttons are added.
  52444. */
  52445. readonly overlay: HTMLDivElement;
  52446. /**
  52447. * Fired every time the active button is changed.
  52448. *
  52449. * When xr is entered via a button that launches xr that button will be the callback parameter
  52450. *
  52451. * When exiting xr the callback parameter will be null)
  52452. */
  52453. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  52454. /**
  52455. *
  52456. * @param scene babylon scene object to use
  52457. * @param options (read-only) version of the options passed to this UI
  52458. */
  52459. private constructor();
  52460. /**
  52461. * Creates UI to allow the user to enter/exit XR mode
  52462. * @param scene the scene to add the ui to
  52463. * @param helper the xr experience helper to enter/exit xr with
  52464. * @param options options to configure the UI
  52465. * @returns the created ui
  52466. */
  52467. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  52468. /**
  52469. * Disposes of the XR UI component
  52470. */
  52471. dispose(): void;
  52472. private _updateButtons;
  52473. }
  52474. }
  52475. declare module BABYLON {
  52476. /**
  52477. * Class containing static functions to help procedurally build meshes
  52478. */
  52479. export class LinesBuilder {
  52480. /**
  52481. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52482. * * 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
  52483. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52484. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52485. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52486. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52487. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52488. * * 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
  52489. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52490. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52491. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52492. * @param name defines the name of the new line system
  52493. * @param options defines the options used to create the line system
  52494. * @param scene defines the hosting scene
  52495. * @returns a new line system mesh
  52496. */
  52497. static CreateLineSystem(name: string, options: {
  52498. lines: Vector3[][];
  52499. updatable?: boolean;
  52500. instance?: Nullable<LinesMesh>;
  52501. colors?: Nullable<Color4[][]>;
  52502. useVertexAlpha?: boolean;
  52503. }, scene: Nullable<Scene>): LinesMesh;
  52504. /**
  52505. * Creates a line mesh
  52506. * 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
  52507. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52508. * * The parameter `points` is an array successive Vector3
  52509. * * 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
  52510. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52511. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52512. * * When updating an instance, remember that only point positions can change, not the number of points
  52513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52514. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52515. * @param name defines the name of the new line system
  52516. * @param options defines the options used to create the line system
  52517. * @param scene defines the hosting scene
  52518. * @returns a new line mesh
  52519. */
  52520. static CreateLines(name: string, options: {
  52521. points: Vector3[];
  52522. updatable?: boolean;
  52523. instance?: Nullable<LinesMesh>;
  52524. colors?: Color4[];
  52525. useVertexAlpha?: boolean;
  52526. }, scene?: Nullable<Scene>): LinesMesh;
  52527. /**
  52528. * Creates a dashed line mesh
  52529. * * 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
  52530. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52531. * * The parameter `points` is an array successive Vector3
  52532. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52533. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52534. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52535. * * 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
  52536. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52537. * * When updating an instance, remember that only point positions can change, not the number of points
  52538. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52539. * @param name defines the name of the mesh
  52540. * @param options defines the options used to create the mesh
  52541. * @param scene defines the hosting scene
  52542. * @returns the dashed line mesh
  52543. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52544. */
  52545. static CreateDashedLines(name: string, options: {
  52546. points: Vector3[];
  52547. dashSize?: number;
  52548. gapSize?: number;
  52549. dashNb?: number;
  52550. updatable?: boolean;
  52551. instance?: LinesMesh;
  52552. useVertexAlpha?: boolean;
  52553. }, scene?: Nullable<Scene>): LinesMesh;
  52554. }
  52555. }
  52556. declare module BABYLON {
  52557. /**
  52558. * Construction options for a timer
  52559. */
  52560. export interface ITimerOptions<T> {
  52561. /**
  52562. * Time-to-end
  52563. */
  52564. timeout: number;
  52565. /**
  52566. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  52567. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  52568. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  52569. */
  52570. contextObservable: Observable<T>;
  52571. /**
  52572. * Optional parameters when adding an observer to the observable
  52573. */
  52574. observableParameters?: {
  52575. mask?: number;
  52576. insertFirst?: boolean;
  52577. scope?: any;
  52578. };
  52579. /**
  52580. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  52581. */
  52582. breakCondition?: (data?: ITimerData<T>) => boolean;
  52583. /**
  52584. * Will be triggered when the time condition has met
  52585. */
  52586. onEnded?: (data: ITimerData<any>) => void;
  52587. /**
  52588. * Will be triggered when the break condition has met (prematurely ended)
  52589. */
  52590. onAborted?: (data: ITimerData<any>) => void;
  52591. /**
  52592. * Optional function to execute on each tick (or count)
  52593. */
  52594. onTick?: (data: ITimerData<any>) => void;
  52595. }
  52596. /**
  52597. * An interface defining the data sent by the timer
  52598. */
  52599. export interface ITimerData<T> {
  52600. /**
  52601. * When did it start
  52602. */
  52603. startTime: number;
  52604. /**
  52605. * Time now
  52606. */
  52607. currentTime: number;
  52608. /**
  52609. * Time passed since started
  52610. */
  52611. deltaTime: number;
  52612. /**
  52613. * How much is completed, in [0.0...1.0].
  52614. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  52615. */
  52616. completeRate: number;
  52617. /**
  52618. * What the registered observable sent in the last count
  52619. */
  52620. payload: T;
  52621. }
  52622. /**
  52623. * The current state of the timer
  52624. */
  52625. export enum TimerState {
  52626. /**
  52627. * Timer initialized, not yet started
  52628. */
  52629. INIT = 0,
  52630. /**
  52631. * Timer started and counting
  52632. */
  52633. STARTED = 1,
  52634. /**
  52635. * Timer ended (whether aborted or time reached)
  52636. */
  52637. ENDED = 2
  52638. }
  52639. /**
  52640. * A simple version of the timer. Will take options and start the timer immediately after calling it
  52641. *
  52642. * @param options options with which to initialize this timer
  52643. */
  52644. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  52645. /**
  52646. * An advanced implementation of a timer class
  52647. */
  52648. export class AdvancedTimer<T = any> implements IDisposable {
  52649. /**
  52650. * Will notify each time the timer calculates the remaining time
  52651. */
  52652. onEachCountObservable: Observable<ITimerData<T>>;
  52653. /**
  52654. * Will trigger when the timer was aborted due to the break condition
  52655. */
  52656. onTimerAbortedObservable: Observable<ITimerData<T>>;
  52657. /**
  52658. * Will trigger when the timer ended successfully
  52659. */
  52660. onTimerEndedObservable: Observable<ITimerData<T>>;
  52661. /**
  52662. * Will trigger when the timer state has changed
  52663. */
  52664. onStateChangedObservable: Observable<TimerState>;
  52665. private _observer;
  52666. private _contextObservable;
  52667. private _observableParameters;
  52668. private _startTime;
  52669. private _timer;
  52670. private _state;
  52671. private _breakCondition;
  52672. private _timeToEnd;
  52673. private _breakOnNextTick;
  52674. /**
  52675. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  52676. * @param options construction options for this advanced timer
  52677. */
  52678. constructor(options: ITimerOptions<T>);
  52679. /**
  52680. * set a breaking condition for this timer. Default is to never break during count
  52681. * @param predicate the new break condition. Returns true to break, false otherwise
  52682. */
  52683. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  52684. /**
  52685. * Reset ALL associated observables in this advanced timer
  52686. */
  52687. clearObservables(): void;
  52688. /**
  52689. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  52690. *
  52691. * @param timeToEnd how much time to measure until timer ended
  52692. */
  52693. start(timeToEnd?: number): void;
  52694. /**
  52695. * Will force a stop on the next tick.
  52696. */
  52697. stop(): void;
  52698. /**
  52699. * Dispose this timer, clearing all resources
  52700. */
  52701. dispose(): void;
  52702. private _setState;
  52703. private _tick;
  52704. private _stop;
  52705. }
  52706. }
  52707. declare module BABYLON {
  52708. /**
  52709. * The options container for the teleportation module
  52710. */
  52711. export interface IWebXRTeleportationOptions {
  52712. /**
  52713. * if provided, this scene will be used to render meshes.
  52714. */
  52715. customUtilityLayerScene?: Scene;
  52716. /**
  52717. * Values to configure the default target mesh
  52718. */
  52719. defaultTargetMeshOptions?: {
  52720. /**
  52721. * Fill color of the teleportation area
  52722. */
  52723. teleportationFillColor?: string;
  52724. /**
  52725. * Border color for the teleportation area
  52726. */
  52727. teleportationBorderColor?: string;
  52728. /**
  52729. * Disable the mesh's animation sequence
  52730. */
  52731. disableAnimation?: boolean;
  52732. /**
  52733. * Disable lighting on the material or the ring and arrow
  52734. */
  52735. disableLighting?: boolean;
  52736. /**
  52737. * Override the default material of the torus and arrow
  52738. */
  52739. torusArrowMaterial?: Material;
  52740. };
  52741. /**
  52742. * A list of meshes to use as floor meshes.
  52743. * Meshes can be added and removed after initializing the feature using the
  52744. * addFloorMesh and removeFloorMesh functions
  52745. * If empty, rotation will still work
  52746. */
  52747. floorMeshes?: AbstractMesh[];
  52748. /**
  52749. * use this rendering group id for the meshes (optional)
  52750. */
  52751. renderingGroupId?: number;
  52752. /**
  52753. * Should teleportation move only to snap points
  52754. */
  52755. snapPointsOnly?: boolean;
  52756. /**
  52757. * An array of points to which the teleportation will snap to.
  52758. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  52759. */
  52760. snapPositions?: Vector3[];
  52761. /**
  52762. * How close should the teleportation ray be in order to snap to position.
  52763. * Default to 0.8 units (meters)
  52764. */
  52765. snapToPositionRadius?: number;
  52766. /**
  52767. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  52768. * If you want to support rotation, make sure your mesh has a direction indicator.
  52769. *
  52770. * When left untouched, the default mesh will be initialized.
  52771. */
  52772. teleportationTargetMesh?: AbstractMesh;
  52773. /**
  52774. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  52775. */
  52776. timeToTeleport?: number;
  52777. /**
  52778. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  52779. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  52780. */
  52781. useMainComponentOnly?: boolean;
  52782. /**
  52783. * Should meshes created here be added to a utility layer or the main scene
  52784. */
  52785. useUtilityLayer?: boolean;
  52786. /**
  52787. * Babylon XR Input class for controller
  52788. */
  52789. xrInput: WebXRInput;
  52790. /**
  52791. * Meshes that the teleportation ray cannot go through
  52792. */
  52793. pickBlockerMeshes?: AbstractMesh[];
  52794. }
  52795. /**
  52796. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  52797. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  52798. * the input of the attached controllers.
  52799. */
  52800. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  52801. private _options;
  52802. private _controllers;
  52803. private _currentTeleportationControllerId;
  52804. private _floorMeshes;
  52805. private _quadraticBezierCurve;
  52806. private _selectionFeature;
  52807. private _snapToPositions;
  52808. private _snappedToPoint;
  52809. private _teleportationRingMaterial?;
  52810. private _tmpRay;
  52811. private _tmpVector;
  52812. private _tmpQuaternion;
  52813. /**
  52814. * The module's name
  52815. */
  52816. static readonly Name: string;
  52817. /**
  52818. * The (Babylon) version of this module.
  52819. * This is an integer representing the implementation version.
  52820. * This number does not correspond to the webxr specs version
  52821. */
  52822. static readonly Version: number;
  52823. /**
  52824. * Is movement backwards enabled
  52825. */
  52826. backwardsMovementEnabled: boolean;
  52827. /**
  52828. * Distance to travel when moving backwards
  52829. */
  52830. backwardsTeleportationDistance: number;
  52831. /**
  52832. * The distance from the user to the inspection point in the direction of the controller
  52833. * A higher number will allow the user to move further
  52834. * defaults to 5 (meters, in xr units)
  52835. */
  52836. parabolicCheckRadius: number;
  52837. /**
  52838. * Should the module support parabolic ray on top of direct ray
  52839. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  52840. * Very helpful when moving between floors / different heights
  52841. */
  52842. parabolicRayEnabled: boolean;
  52843. /**
  52844. * How much rotation should be applied when rotating right and left
  52845. */
  52846. rotationAngle: number;
  52847. /**
  52848. * Is rotation enabled when moving forward?
  52849. * Disabling this feature will prevent the user from deciding the direction when teleporting
  52850. */
  52851. rotationEnabled: boolean;
  52852. /**
  52853. * constructs a new anchor system
  52854. * @param _xrSessionManager an instance of WebXRSessionManager
  52855. * @param _options configuration object for this feature
  52856. */
  52857. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  52858. /**
  52859. * Get the snapPointsOnly flag
  52860. */
  52861. get snapPointsOnly(): boolean;
  52862. /**
  52863. * Sets the snapPointsOnly flag
  52864. * @param snapToPoints should teleportation be exclusively to snap points
  52865. */
  52866. set snapPointsOnly(snapToPoints: boolean);
  52867. /**
  52868. * Add a new mesh to the floor meshes array
  52869. * @param mesh the mesh to use as floor mesh
  52870. */
  52871. addFloorMesh(mesh: AbstractMesh): void;
  52872. /**
  52873. * Add a new snap-to point to fix teleportation to this position
  52874. * @param newSnapPoint The new Snap-To point
  52875. */
  52876. addSnapPoint(newSnapPoint: Vector3): void;
  52877. attach(): boolean;
  52878. detach(): boolean;
  52879. dispose(): void;
  52880. /**
  52881. * Remove a mesh from the floor meshes array
  52882. * @param mesh the mesh to remove
  52883. */
  52884. removeFloorMesh(mesh: AbstractMesh): void;
  52885. /**
  52886. * Remove a mesh from the floor meshes array using its name
  52887. * @param name the mesh name to remove
  52888. */
  52889. removeFloorMeshByName(name: string): void;
  52890. /**
  52891. * 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
  52892. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  52893. * @returns was the point found and removed or not
  52894. */
  52895. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  52896. /**
  52897. * This function sets a selection feature that will be disabled when
  52898. * the forward ray is shown and will be reattached when hidden.
  52899. * This is used to remove the selection rays when moving.
  52900. * @param selectionFeature the feature to disable when forward movement is enabled
  52901. */
  52902. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  52903. protected _onXRFrame(_xrFrame: XRFrame): void;
  52904. private _attachController;
  52905. private _createDefaultTargetMesh;
  52906. private _detachController;
  52907. private _findClosestSnapPointWithRadius;
  52908. private _setTargetMeshPosition;
  52909. private _setTargetMeshVisibility;
  52910. private _showParabolicPath;
  52911. private _teleportForward;
  52912. }
  52913. }
  52914. declare module BABYLON {
  52915. /**
  52916. * Options for the default xr helper
  52917. */
  52918. export class WebXRDefaultExperienceOptions {
  52919. /**
  52920. * Enable or disable default UI to enter XR
  52921. */
  52922. disableDefaultUI?: boolean;
  52923. /**
  52924. * Should teleportation not initialize. defaults to false.
  52925. */
  52926. disableTeleportation?: boolean;
  52927. /**
  52928. * Floor meshes that will be used for teleport
  52929. */
  52930. floorMeshes?: Array<AbstractMesh>;
  52931. /**
  52932. * If set to true, the first frame will not be used to reset position
  52933. * The first frame is mainly used when copying transformation from the old camera
  52934. * Mainly used in AR
  52935. */
  52936. ignoreNativeCameraTransformation?: boolean;
  52937. /**
  52938. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  52939. */
  52940. inputOptions?: IWebXRInputOptions;
  52941. /**
  52942. * optional configuration for the output canvas
  52943. */
  52944. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  52945. /**
  52946. * optional UI options. This can be used among other to change session mode and reference space type
  52947. */
  52948. uiOptions?: WebXREnterExitUIOptions;
  52949. /**
  52950. * When loading teleportation and pointer select, use stable versions instead of latest.
  52951. */
  52952. useStablePlugins?: boolean;
  52953. /**
  52954. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  52955. */
  52956. renderingGroupId?: number;
  52957. /**
  52958. * A list of optional features to init the session with
  52959. * If set to true, all features we support will be added
  52960. */
  52961. optionalFeatures?: boolean | string[];
  52962. }
  52963. /**
  52964. * Default experience which provides a similar setup to the previous webVRExperience
  52965. */
  52966. export class WebXRDefaultExperience {
  52967. /**
  52968. * Base experience
  52969. */
  52970. baseExperience: WebXRExperienceHelper;
  52971. /**
  52972. * Enables ui for entering/exiting xr
  52973. */
  52974. enterExitUI: WebXREnterExitUI;
  52975. /**
  52976. * Input experience extension
  52977. */
  52978. input: WebXRInput;
  52979. /**
  52980. * Enables laser pointer and selection
  52981. */
  52982. pointerSelection: WebXRControllerPointerSelection;
  52983. /**
  52984. * Default target xr should render to
  52985. */
  52986. renderTarget: WebXRRenderTarget;
  52987. /**
  52988. * Enables teleportation
  52989. */
  52990. teleportation: WebXRMotionControllerTeleportation;
  52991. private constructor();
  52992. /**
  52993. * Creates the default xr experience
  52994. * @param scene scene
  52995. * @param options options for basic configuration
  52996. * @returns resulting WebXRDefaultExperience
  52997. */
  52998. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  52999. /**
  53000. * DIsposes of the experience helper
  53001. */
  53002. dispose(): void;
  53003. }
  53004. }
  53005. declare module BABYLON {
  53006. /**
  53007. * Options to modify the vr teleportation behavior.
  53008. */
  53009. export interface VRTeleportationOptions {
  53010. /**
  53011. * The name of the mesh which should be used as the teleportation floor. (default: null)
  53012. */
  53013. floorMeshName?: string;
  53014. /**
  53015. * A list of meshes to be used as the teleportation floor. (default: empty)
  53016. */
  53017. floorMeshes?: Mesh[];
  53018. /**
  53019. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  53020. */
  53021. teleportationMode?: number;
  53022. /**
  53023. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  53024. */
  53025. teleportationTime?: number;
  53026. /**
  53027. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  53028. */
  53029. teleportationSpeed?: number;
  53030. /**
  53031. * The easing function used in the animation or null for Linear. (default CircleEase)
  53032. */
  53033. easingFunction?: EasingFunction;
  53034. }
  53035. /**
  53036. * Options to modify the vr experience helper's behavior.
  53037. */
  53038. export interface VRExperienceHelperOptions extends WebVROptions {
  53039. /**
  53040. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  53041. */
  53042. createDeviceOrientationCamera?: boolean;
  53043. /**
  53044. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  53045. */
  53046. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  53047. /**
  53048. * Uses the main button on the controller to toggle the laser casted. (default: true)
  53049. */
  53050. laserToggle?: boolean;
  53051. /**
  53052. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  53053. */
  53054. floorMeshes?: Mesh[];
  53055. /**
  53056. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  53057. */
  53058. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  53059. /**
  53060. * Defines if WebXR should be used instead of WebVR (if available)
  53061. */
  53062. useXR?: boolean;
  53063. }
  53064. /**
  53065. * Event containing information after VR has been entered
  53066. */
  53067. export class OnAfterEnteringVRObservableEvent {
  53068. /**
  53069. * If entering vr was successful
  53070. */
  53071. success: boolean;
  53072. }
  53073. /**
  53074. * Helps to quickly add VR support to an existing scene.
  53075. * See https://doc.babylonjs.com/how_to/webvr_helper
  53076. */
  53077. export class VRExperienceHelper {
  53078. /** Options to modify the vr experience helper's behavior. */
  53079. webVROptions: VRExperienceHelperOptions;
  53080. private _scene;
  53081. private _position;
  53082. private _btnVR;
  53083. private _btnVRDisplayed;
  53084. private _webVRsupported;
  53085. private _webVRready;
  53086. private _webVRrequesting;
  53087. private _webVRpresenting;
  53088. private _hasEnteredVR;
  53089. private _fullscreenVRpresenting;
  53090. private _inputElement;
  53091. private _webVRCamera;
  53092. private _vrDeviceOrientationCamera;
  53093. private _deviceOrientationCamera;
  53094. private _existingCamera;
  53095. private _onKeyDown;
  53096. private _onVrDisplayPresentChange;
  53097. private _onVRDisplayChanged;
  53098. private _onVRRequestPresentStart;
  53099. private _onVRRequestPresentComplete;
  53100. /**
  53101. * 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)
  53102. */
  53103. enableGazeEvenWhenNoPointerLock: boolean;
  53104. /**
  53105. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  53106. */
  53107. exitVROnDoubleTap: boolean;
  53108. /**
  53109. * Observable raised right before entering VR.
  53110. */
  53111. onEnteringVRObservable: Observable<VRExperienceHelper>;
  53112. /**
  53113. * Observable raised when entering VR has completed.
  53114. */
  53115. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  53116. /**
  53117. * Observable raised when exiting VR.
  53118. */
  53119. onExitingVRObservable: Observable<VRExperienceHelper>;
  53120. /**
  53121. * Observable raised when controller mesh is loaded.
  53122. */
  53123. onControllerMeshLoadedObservable: Observable<WebVRController>;
  53124. /** Return this.onEnteringVRObservable
  53125. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  53126. */
  53127. get onEnteringVR(): Observable<VRExperienceHelper>;
  53128. /** Return this.onExitingVRObservable
  53129. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  53130. */
  53131. get onExitingVR(): Observable<VRExperienceHelper>;
  53132. /** Return this.onControllerMeshLoadedObservable
  53133. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  53134. */
  53135. get onControllerMeshLoaded(): Observable<WebVRController>;
  53136. private _rayLength;
  53137. private _useCustomVRButton;
  53138. private _teleportationRequested;
  53139. private _teleportActive;
  53140. private _floorMeshName;
  53141. private _floorMeshesCollection;
  53142. private _teleportationMode;
  53143. private _teleportationTime;
  53144. private _teleportationSpeed;
  53145. private _teleportationEasing;
  53146. private _rotationAllowed;
  53147. private _teleportBackwardsVector;
  53148. private _teleportationTarget;
  53149. private _isDefaultTeleportationTarget;
  53150. private _postProcessMove;
  53151. private _teleportationFillColor;
  53152. private _teleportationBorderColor;
  53153. private _rotationAngle;
  53154. private _haloCenter;
  53155. private _cameraGazer;
  53156. private _padSensibilityUp;
  53157. private _padSensibilityDown;
  53158. private _leftController;
  53159. private _rightController;
  53160. private _gazeColor;
  53161. private _laserColor;
  53162. private _pickedLaserColor;
  53163. private _pickedGazeColor;
  53164. /**
  53165. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  53166. */
  53167. onNewMeshSelected: Observable<AbstractMesh>;
  53168. /**
  53169. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  53170. * This observable will provide the mesh and the controller used to select the mesh
  53171. */
  53172. onMeshSelectedWithController: Observable<{
  53173. mesh: AbstractMesh;
  53174. controller: WebVRController;
  53175. }>;
  53176. /**
  53177. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  53178. */
  53179. onNewMeshPicked: Observable<PickingInfo>;
  53180. private _circleEase;
  53181. /**
  53182. * Observable raised before camera teleportation
  53183. */
  53184. onBeforeCameraTeleport: Observable<Vector3>;
  53185. /**
  53186. * Observable raised after camera teleportation
  53187. */
  53188. onAfterCameraTeleport: Observable<Vector3>;
  53189. /**
  53190. * Observable raised when current selected mesh gets unselected
  53191. */
  53192. onSelectedMeshUnselected: Observable<AbstractMesh>;
  53193. private _raySelectionPredicate;
  53194. /**
  53195. * To be optionaly changed by user to define custom ray selection
  53196. */
  53197. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  53198. /**
  53199. * To be optionaly changed by user to define custom selection logic (after ray selection)
  53200. */
  53201. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53202. /**
  53203. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  53204. */
  53205. teleportationEnabled: boolean;
  53206. private _defaultHeight;
  53207. private _teleportationInitialized;
  53208. private _interactionsEnabled;
  53209. private _interactionsRequested;
  53210. private _displayGaze;
  53211. private _displayLaserPointer;
  53212. /**
  53213. * The mesh used to display where the user is going to teleport.
  53214. */
  53215. get teleportationTarget(): Mesh;
  53216. /**
  53217. * Sets the mesh to be used to display where the user is going to teleport.
  53218. */
  53219. set teleportationTarget(value: Mesh);
  53220. /**
  53221. * 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
  53222. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  53223. * See https://doc.babylonjs.com/resources/baking_transformations
  53224. */
  53225. get gazeTrackerMesh(): Mesh;
  53226. set gazeTrackerMesh(value: Mesh);
  53227. /**
  53228. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  53229. */
  53230. updateGazeTrackerScale: boolean;
  53231. /**
  53232. * If the gaze trackers color should be updated when selecting meshes
  53233. */
  53234. updateGazeTrackerColor: boolean;
  53235. /**
  53236. * If the controller laser color should be updated when selecting meshes
  53237. */
  53238. updateControllerLaserColor: boolean;
  53239. /**
  53240. * The gaze tracking mesh corresponding to the left controller
  53241. */
  53242. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  53243. /**
  53244. * The gaze tracking mesh corresponding to the right controller
  53245. */
  53246. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  53247. /**
  53248. * If the ray of the gaze should be displayed.
  53249. */
  53250. get displayGaze(): boolean;
  53251. /**
  53252. * Sets if the ray of the gaze should be displayed.
  53253. */
  53254. set displayGaze(value: boolean);
  53255. /**
  53256. * If the ray of the LaserPointer should be displayed.
  53257. */
  53258. get displayLaserPointer(): boolean;
  53259. /**
  53260. * Sets if the ray of the LaserPointer should be displayed.
  53261. */
  53262. set displayLaserPointer(value: boolean);
  53263. /**
  53264. * The deviceOrientationCamera used as the camera when not in VR.
  53265. */
  53266. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  53267. /**
  53268. * Based on the current WebVR support, returns the current VR camera used.
  53269. */
  53270. get currentVRCamera(): Nullable<Camera>;
  53271. /**
  53272. * The webVRCamera which is used when in VR.
  53273. */
  53274. get webVRCamera(): WebVRFreeCamera;
  53275. /**
  53276. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  53277. */
  53278. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  53279. /**
  53280. * The html button that is used to trigger entering into VR.
  53281. */
  53282. get vrButton(): Nullable<HTMLButtonElement>;
  53283. private get _teleportationRequestInitiated();
  53284. /**
  53285. * Defines whether or not Pointer lock should be requested when switching to
  53286. * full screen.
  53287. */
  53288. requestPointerLockOnFullScreen: boolean;
  53289. /**
  53290. * If asking to force XR, this will be populated with the default xr experience
  53291. */
  53292. xr: WebXRDefaultExperience;
  53293. /**
  53294. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  53295. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  53296. */
  53297. xrTestDone: boolean;
  53298. /**
  53299. * Instantiates a VRExperienceHelper.
  53300. * Helps to quickly add VR support to an existing scene.
  53301. * @param scene The scene the VRExperienceHelper belongs to.
  53302. * @param webVROptions Options to modify the vr experience helper's behavior.
  53303. */
  53304. constructor(scene: Scene,
  53305. /** Options to modify the vr experience helper's behavior. */
  53306. webVROptions?: VRExperienceHelperOptions);
  53307. private completeVRInit;
  53308. private _onDefaultMeshLoaded;
  53309. private _onResize;
  53310. private _onFullscreenChange;
  53311. /**
  53312. * Gets a value indicating if we are currently in VR mode.
  53313. */
  53314. get isInVRMode(): boolean;
  53315. private onVrDisplayPresentChange;
  53316. private onVRDisplayChanged;
  53317. private moveButtonToBottomRight;
  53318. private displayVRButton;
  53319. private updateButtonVisibility;
  53320. private _cachedAngularSensibility;
  53321. /**
  53322. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  53323. * Otherwise, will use the fullscreen API.
  53324. */
  53325. enterVR(): void;
  53326. /**
  53327. * Attempt to exit VR, or fullscreen.
  53328. */
  53329. exitVR(): void;
  53330. /**
  53331. * The position of the vr experience helper.
  53332. */
  53333. get position(): Vector3;
  53334. /**
  53335. * Sets the position of the vr experience helper.
  53336. */
  53337. set position(value: Vector3);
  53338. /**
  53339. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  53340. */
  53341. enableInteractions(): void;
  53342. private get _noControllerIsActive();
  53343. private beforeRender;
  53344. private _isTeleportationFloor;
  53345. /**
  53346. * Adds a floor mesh to be used for teleportation.
  53347. * @param floorMesh the mesh to be used for teleportation.
  53348. */
  53349. addFloorMesh(floorMesh: Mesh): void;
  53350. /**
  53351. * Removes a floor mesh from being used for teleportation.
  53352. * @param floorMesh the mesh to be removed.
  53353. */
  53354. removeFloorMesh(floorMesh: Mesh): void;
  53355. /**
  53356. * Enables interactions and teleportation using the VR controllers and gaze.
  53357. * @param vrTeleportationOptions options to modify teleportation behavior.
  53358. */
  53359. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  53360. private _onNewGamepadConnected;
  53361. private _tryEnableInteractionOnController;
  53362. private _onNewGamepadDisconnected;
  53363. private _enableInteractionOnController;
  53364. private _checkTeleportWithRay;
  53365. private _checkRotate;
  53366. private _checkTeleportBackwards;
  53367. private _enableTeleportationOnController;
  53368. private _createTeleportationCircles;
  53369. private _displayTeleportationTarget;
  53370. private _hideTeleportationTarget;
  53371. private _rotateCamera;
  53372. private _moveTeleportationSelectorTo;
  53373. private _workingVector;
  53374. private _workingQuaternion;
  53375. private _workingMatrix;
  53376. /**
  53377. * Time Constant Teleportation Mode
  53378. */
  53379. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  53380. /**
  53381. * Speed Constant Teleportation Mode
  53382. */
  53383. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  53384. /**
  53385. * Teleports the users feet to the desired location
  53386. * @param location The location where the user's feet should be placed
  53387. */
  53388. teleportCamera(location: Vector3): void;
  53389. private _convertNormalToDirectionOfRay;
  53390. private _castRayAndSelectObject;
  53391. private _notifySelectedMeshUnselected;
  53392. /**
  53393. * Permanently set new colors for the laser pointer
  53394. * @param color the new laser color
  53395. * @param pickedColor the new laser color when picked mesh detected
  53396. */
  53397. setLaserColor(color: Color3, pickedColor?: Color3): void;
  53398. /**
  53399. * Set lighting enabled / disabled on the laser pointer of both controllers
  53400. * @param enabled should the lighting be enabled on the laser pointer
  53401. */
  53402. setLaserLightingState(enabled?: boolean): void;
  53403. /**
  53404. * Permanently set new colors for the gaze pointer
  53405. * @param color the new gaze color
  53406. * @param pickedColor the new gaze color when picked mesh detected
  53407. */
  53408. setGazeColor(color: Color3, pickedColor?: Color3): void;
  53409. /**
  53410. * Sets the color of the laser ray from the vr controllers.
  53411. * @param color new color for the ray.
  53412. */
  53413. changeLaserColor(color: Color3): void;
  53414. /**
  53415. * Sets the color of the ray from the vr headsets gaze.
  53416. * @param color new color for the ray.
  53417. */
  53418. changeGazeColor(color: Color3): void;
  53419. /**
  53420. * Exits VR and disposes of the vr experience helper
  53421. */
  53422. dispose(): void;
  53423. /**
  53424. * Gets the name of the VRExperienceHelper class
  53425. * @returns "VRExperienceHelper"
  53426. */
  53427. getClassName(): string;
  53428. }
  53429. }
  53430. declare module BABYLON {
  53431. /**
  53432. * Contains an array of blocks representing the octree
  53433. */
  53434. export interface IOctreeContainer<T> {
  53435. /**
  53436. * Blocks within the octree
  53437. */
  53438. blocks: Array<OctreeBlock<T>>;
  53439. }
  53440. /**
  53441. * Class used to store a cell in an octree
  53442. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53443. */
  53444. export class OctreeBlock<T> {
  53445. /**
  53446. * Gets the content of the current block
  53447. */
  53448. entries: T[];
  53449. /**
  53450. * Gets the list of block children
  53451. */
  53452. blocks: Array<OctreeBlock<T>>;
  53453. private _depth;
  53454. private _maxDepth;
  53455. private _capacity;
  53456. private _minPoint;
  53457. private _maxPoint;
  53458. private _boundingVectors;
  53459. private _creationFunc;
  53460. /**
  53461. * Creates a new block
  53462. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  53463. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  53464. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  53465. * @param depth defines the current depth of this block in the octree
  53466. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  53467. * @param creationFunc defines a callback to call when an element is added to the block
  53468. */
  53469. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  53470. /**
  53471. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  53472. */
  53473. get capacity(): number;
  53474. /**
  53475. * Gets the minimum vector (in world space) of the block's bounding box
  53476. */
  53477. get minPoint(): Vector3;
  53478. /**
  53479. * Gets the maximum vector (in world space) of the block's bounding box
  53480. */
  53481. get maxPoint(): Vector3;
  53482. /**
  53483. * Add a new element to this block
  53484. * @param entry defines the element to add
  53485. */
  53486. addEntry(entry: T): void;
  53487. /**
  53488. * Remove an element from this block
  53489. * @param entry defines the element to remove
  53490. */
  53491. removeEntry(entry: T): void;
  53492. /**
  53493. * Add an array of elements to this block
  53494. * @param entries defines the array of elements to add
  53495. */
  53496. addEntries(entries: T[]): void;
  53497. /**
  53498. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  53499. * @param frustumPlanes defines the frustum planes to test
  53500. * @param selection defines the array to store current content if selection is positive
  53501. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53502. */
  53503. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  53504. /**
  53505. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  53506. * @param sphereCenter defines the bounding sphere center
  53507. * @param sphereRadius defines the bounding sphere radius
  53508. * @param selection defines the array to store current content if selection is positive
  53509. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53510. */
  53511. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  53512. /**
  53513. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  53514. * @param ray defines the ray to test with
  53515. * @param selection defines the array to store current content if selection is positive
  53516. */
  53517. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  53518. /**
  53519. * Subdivide the content into child blocks (this block will then be empty)
  53520. */
  53521. createInnerBlocks(): void;
  53522. /**
  53523. * @hidden
  53524. */
  53525. 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;
  53526. }
  53527. }
  53528. declare module BABYLON {
  53529. /**
  53530. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  53531. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53532. */
  53533. export class Octree<T> {
  53534. /** 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.) */
  53535. maxDepth: number;
  53536. /**
  53537. * Blocks within the octree containing objects
  53538. */
  53539. blocks: Array<OctreeBlock<T>>;
  53540. /**
  53541. * Content stored in the octree
  53542. */
  53543. dynamicContent: T[];
  53544. private _maxBlockCapacity;
  53545. private _selectionContent;
  53546. private _creationFunc;
  53547. /**
  53548. * Creates a octree
  53549. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53550. * @param creationFunc function to be used to instatiate the octree
  53551. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  53552. * @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.)
  53553. */
  53554. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  53555. /** 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.) */
  53556. maxDepth?: number);
  53557. /**
  53558. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  53559. * @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);
  53560. * @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);
  53561. * @param entries meshes to be added to the octree blocks
  53562. */
  53563. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  53564. /**
  53565. * Adds a mesh to the octree
  53566. * @param entry Mesh to add to the octree
  53567. */
  53568. addMesh(entry: T): void;
  53569. /**
  53570. * Remove an element from the octree
  53571. * @param entry defines the element to remove
  53572. */
  53573. removeMesh(entry: T): void;
  53574. /**
  53575. * Selects an array of meshes within the frustum
  53576. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  53577. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  53578. * @returns array of meshes within the frustum
  53579. */
  53580. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  53581. /**
  53582. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  53583. * @param sphereCenter defines the bounding sphere center
  53584. * @param sphereRadius defines the bounding sphere radius
  53585. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53586. * @returns an array of objects that intersect the sphere
  53587. */
  53588. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  53589. /**
  53590. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  53591. * @param ray defines the ray to test with
  53592. * @returns array of intersected objects
  53593. */
  53594. intersectsRay(ray: Ray): SmartArray<T>;
  53595. /**
  53596. * Adds a mesh into the octree block if it intersects the block
  53597. */
  53598. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  53599. /**
  53600. * Adds a submesh into the octree block if it intersects the block
  53601. */
  53602. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  53603. }
  53604. }
  53605. declare module BABYLON {
  53606. interface Scene {
  53607. /**
  53608. * @hidden
  53609. * Backing Filed
  53610. */
  53611. _selectionOctree: Octree<AbstractMesh>;
  53612. /**
  53613. * Gets the octree used to boost mesh selection (picking)
  53614. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53615. */
  53616. selectionOctree: Octree<AbstractMesh>;
  53617. /**
  53618. * Creates or updates the octree used to boost selection (picking)
  53619. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53620. * @param maxCapacity defines the maximum capacity per leaf
  53621. * @param maxDepth defines the maximum depth of the octree
  53622. * @returns an octree of AbstractMesh
  53623. */
  53624. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  53625. }
  53626. interface AbstractMesh {
  53627. /**
  53628. * @hidden
  53629. * Backing Field
  53630. */
  53631. _submeshesOctree: Octree<SubMesh>;
  53632. /**
  53633. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  53634. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  53635. * @param maxCapacity defines the maximum size of each block (64 by default)
  53636. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  53637. * @returns the new octree
  53638. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  53639. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53640. */
  53641. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  53642. }
  53643. /**
  53644. * Defines the octree scene component responsible to manage any octrees
  53645. * in a given scene.
  53646. */
  53647. export class OctreeSceneComponent {
  53648. /**
  53649. * The component name help to identify the component in the list of scene components.
  53650. */
  53651. readonly name: string;
  53652. /**
  53653. * The scene the component belongs to.
  53654. */
  53655. scene: Scene;
  53656. /**
  53657. * Indicates if the meshes have been checked to make sure they are isEnabled()
  53658. */
  53659. readonly checksIsEnabled: boolean;
  53660. /**
  53661. * Creates a new instance of the component for the given scene
  53662. * @param scene Defines the scene to register the component in
  53663. */
  53664. constructor(scene: Scene);
  53665. /**
  53666. * Registers the component in a given scene
  53667. */
  53668. register(): void;
  53669. /**
  53670. * Return the list of active meshes
  53671. * @returns the list of active meshes
  53672. */
  53673. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  53674. /**
  53675. * Return the list of active sub meshes
  53676. * @param mesh The mesh to get the candidates sub meshes from
  53677. * @returns the list of active sub meshes
  53678. */
  53679. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  53680. private _tempRay;
  53681. /**
  53682. * Return the list of sub meshes intersecting with a given local ray
  53683. * @param mesh defines the mesh to find the submesh for
  53684. * @param localRay defines the ray in local space
  53685. * @returns the list of intersecting sub meshes
  53686. */
  53687. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  53688. /**
  53689. * Return the list of sub meshes colliding with a collider
  53690. * @param mesh defines the mesh to find the submesh for
  53691. * @param collider defines the collider to evaluate the collision against
  53692. * @returns the list of colliding sub meshes
  53693. */
  53694. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  53695. /**
  53696. * Rebuilds the elements related to this component in case of
  53697. * context lost for instance.
  53698. */
  53699. rebuild(): void;
  53700. /**
  53701. * Disposes the component and the associated ressources.
  53702. */
  53703. dispose(): void;
  53704. }
  53705. }
  53706. declare module BABYLON {
  53707. /**
  53708. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  53709. */
  53710. export class Gizmo implements IDisposable {
  53711. /** The utility layer the gizmo will be added to */
  53712. gizmoLayer: UtilityLayerRenderer;
  53713. /**
  53714. * The root mesh of the gizmo
  53715. */
  53716. _rootMesh: Mesh;
  53717. private _attachedMesh;
  53718. private _attachedNode;
  53719. /**
  53720. * Ratio for the scale of the gizmo (Default: 1)
  53721. */
  53722. protected _scaleRatio: number;
  53723. /**
  53724. * boolean updated by pointermove when a gizmo mesh is hovered
  53725. */
  53726. protected _isHovered: boolean;
  53727. /**
  53728. * Ratio for the scale of the gizmo (Default: 1)
  53729. */
  53730. set scaleRatio(value: number);
  53731. get scaleRatio(): number;
  53732. /**
  53733. * True when the mouse pointer is hovered a gizmo mesh
  53734. */
  53735. get isHovered(): boolean;
  53736. /**
  53737. * If a custom mesh has been set (Default: false)
  53738. */
  53739. protected _customMeshSet: boolean;
  53740. /**
  53741. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  53742. * * When set, interactions will be enabled
  53743. */
  53744. get attachedMesh(): Nullable<AbstractMesh>;
  53745. set attachedMesh(value: Nullable<AbstractMesh>);
  53746. /**
  53747. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  53748. * * When set, interactions will be enabled
  53749. */
  53750. get attachedNode(): Nullable<Node>;
  53751. set attachedNode(value: Nullable<Node>);
  53752. /**
  53753. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  53754. * @param mesh The mesh to replace the default mesh of the gizmo
  53755. */
  53756. setCustomMesh(mesh: Mesh): void;
  53757. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  53758. /**
  53759. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  53760. */
  53761. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53762. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53763. /**
  53764. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  53765. */
  53766. updateGizmoPositionToMatchAttachedMesh: boolean;
  53767. /**
  53768. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  53769. */
  53770. updateScale: boolean;
  53771. protected _interactionsEnabled: boolean;
  53772. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53773. private _beforeRenderObserver;
  53774. private _tempQuaternion;
  53775. private _tempVector;
  53776. private _tempVector2;
  53777. private _tempMatrix1;
  53778. private _tempMatrix2;
  53779. private _rightHandtoLeftHandMatrix;
  53780. /**
  53781. * Creates a gizmo
  53782. * @param gizmoLayer The utility layer the gizmo will be added to
  53783. */
  53784. constructor(
  53785. /** The utility layer the gizmo will be added to */
  53786. gizmoLayer?: UtilityLayerRenderer);
  53787. /**
  53788. * Updates the gizmo to match the attached mesh's position/rotation
  53789. */
  53790. protected _update(): void;
  53791. /**
  53792. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  53793. * @param value Node, TransformNode or mesh
  53794. */
  53795. protected _matrixChanged(): void;
  53796. /**
  53797. * Disposes of the gizmo
  53798. */
  53799. dispose(): void;
  53800. }
  53801. }
  53802. declare module BABYLON {
  53803. /**
  53804. * Single plane drag gizmo
  53805. */
  53806. export class PlaneDragGizmo extends Gizmo {
  53807. /**
  53808. * Drag behavior responsible for the gizmos dragging interactions
  53809. */
  53810. dragBehavior: PointerDragBehavior;
  53811. private _pointerObserver;
  53812. /**
  53813. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53814. */
  53815. snapDistance: number;
  53816. /**
  53817. * Event that fires each time the gizmo snaps to a new location.
  53818. * * snapDistance is the the change in distance
  53819. */
  53820. onSnapObservable: Observable<{
  53821. snapDistance: number;
  53822. }>;
  53823. private _plane;
  53824. private _coloredMaterial;
  53825. private _hoverMaterial;
  53826. private _isEnabled;
  53827. private _parent;
  53828. /** @hidden */
  53829. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  53830. /** @hidden */
  53831. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  53832. /**
  53833. * Creates a PlaneDragGizmo
  53834. * @param gizmoLayer The utility layer the gizmo will be added to
  53835. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  53836. * @param color The color of the gizmo
  53837. */
  53838. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  53839. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53840. /**
  53841. * If the gizmo is enabled
  53842. */
  53843. set isEnabled(value: boolean);
  53844. get isEnabled(): boolean;
  53845. /**
  53846. * Disposes of the gizmo
  53847. */
  53848. dispose(): void;
  53849. }
  53850. }
  53851. declare module BABYLON {
  53852. /**
  53853. * Gizmo that enables dragging a mesh along 3 axis
  53854. */
  53855. export class PositionGizmo extends Gizmo {
  53856. /**
  53857. * Internal gizmo used for interactions on the x axis
  53858. */
  53859. xGizmo: AxisDragGizmo;
  53860. /**
  53861. * Internal gizmo used for interactions on the y axis
  53862. */
  53863. yGizmo: AxisDragGizmo;
  53864. /**
  53865. * Internal gizmo used for interactions on the z axis
  53866. */
  53867. zGizmo: AxisDragGizmo;
  53868. /**
  53869. * Internal gizmo used for interactions on the yz plane
  53870. */
  53871. xPlaneGizmo: PlaneDragGizmo;
  53872. /**
  53873. * Internal gizmo used for interactions on the xz plane
  53874. */
  53875. yPlaneGizmo: PlaneDragGizmo;
  53876. /**
  53877. * Internal gizmo used for interactions on the xy plane
  53878. */
  53879. zPlaneGizmo: PlaneDragGizmo;
  53880. /**
  53881. * private variables
  53882. */
  53883. private _meshAttached;
  53884. private _nodeAttached;
  53885. private _snapDistance;
  53886. /** Fires an event when any of it's sub gizmos are dragged */
  53887. onDragStartObservable: Observable<unknown>;
  53888. /** Fires an event when any of it's sub gizmos are released from dragging */
  53889. onDragEndObservable: Observable<unknown>;
  53890. /**
  53891. * If set to true, planar drag is enabled
  53892. */
  53893. private _planarGizmoEnabled;
  53894. get attachedMesh(): Nullable<AbstractMesh>;
  53895. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53896. get attachedNode(): Nullable<Node>;
  53897. set attachedNode(node: Nullable<Node>);
  53898. /**
  53899. * True when the mouse pointer is hovering a gizmo mesh
  53900. */
  53901. get isHovered(): boolean;
  53902. /**
  53903. * Creates a PositionGizmo
  53904. * @param gizmoLayer The utility layer the gizmo will be added to
  53905. @param thickness display gizmo axis thickness
  53906. */
  53907. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  53908. /**
  53909. * If the planar drag gizmo is enabled
  53910. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  53911. */
  53912. set planarGizmoEnabled(value: boolean);
  53913. get planarGizmoEnabled(): boolean;
  53914. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53915. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53916. /**
  53917. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53918. */
  53919. set snapDistance(value: number);
  53920. get snapDistance(): number;
  53921. /**
  53922. * Ratio for the scale of the gizmo (Default: 1)
  53923. */
  53924. set scaleRatio(value: number);
  53925. get scaleRatio(): number;
  53926. /**
  53927. * Disposes of the gizmo
  53928. */
  53929. dispose(): void;
  53930. /**
  53931. * CustomMeshes are not supported by this gizmo
  53932. * @param mesh The mesh to replace the default mesh of the gizmo
  53933. */
  53934. setCustomMesh(mesh: Mesh): void;
  53935. }
  53936. }
  53937. declare module BABYLON {
  53938. /**
  53939. * Single axis drag gizmo
  53940. */
  53941. export class AxisDragGizmo extends Gizmo {
  53942. /**
  53943. * Drag behavior responsible for the gizmos dragging interactions
  53944. */
  53945. dragBehavior: PointerDragBehavior;
  53946. private _pointerObserver;
  53947. /**
  53948. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53949. */
  53950. snapDistance: number;
  53951. /**
  53952. * Event that fires each time the gizmo snaps to a new location.
  53953. * * snapDistance is the the change in distance
  53954. */
  53955. onSnapObservable: Observable<{
  53956. snapDistance: number;
  53957. }>;
  53958. private _isEnabled;
  53959. private _parent;
  53960. private _arrow;
  53961. private _coloredMaterial;
  53962. private _hoverMaterial;
  53963. /** @hidden */
  53964. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  53965. /** @hidden */
  53966. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  53967. /**
  53968. * Creates an AxisDragGizmo
  53969. * @param gizmoLayer The utility layer the gizmo will be added to
  53970. * @param dragAxis The axis which the gizmo will be able to drag on
  53971. * @param color The color of the gizmo
  53972. * @param thickness display gizmo axis thickness
  53973. */
  53974. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  53975. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53976. /**
  53977. * If the gizmo is enabled
  53978. */
  53979. set isEnabled(value: boolean);
  53980. get isEnabled(): boolean;
  53981. /**
  53982. * Disposes of the gizmo
  53983. */
  53984. dispose(): void;
  53985. }
  53986. }
  53987. declare module BABYLON.Debug {
  53988. /**
  53989. * The Axes viewer will show 3 axes in a specific point in space
  53990. */
  53991. export class AxesViewer {
  53992. private _xAxis;
  53993. private _yAxis;
  53994. private _zAxis;
  53995. private _scaleLinesFactor;
  53996. private _instanced;
  53997. /**
  53998. * Gets the hosting scene
  53999. */
  54000. scene: Nullable<Scene>;
  54001. /**
  54002. * Gets or sets a number used to scale line length
  54003. */
  54004. scaleLines: number;
  54005. /** Gets the node hierarchy used to render x-axis */
  54006. get xAxis(): TransformNode;
  54007. /** Gets the node hierarchy used to render y-axis */
  54008. get yAxis(): TransformNode;
  54009. /** Gets the node hierarchy used to render z-axis */
  54010. get zAxis(): TransformNode;
  54011. /**
  54012. * Creates a new AxesViewer
  54013. * @param scene defines the hosting scene
  54014. * @param scaleLines defines a number used to scale line length (1 by default)
  54015. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  54016. * @param xAxis defines the node hierarchy used to render the x-axis
  54017. * @param yAxis defines the node hierarchy used to render the y-axis
  54018. * @param zAxis defines the node hierarchy used to render the z-axis
  54019. */
  54020. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  54021. /**
  54022. * Force the viewer to update
  54023. * @param position defines the position of the viewer
  54024. * @param xaxis defines the x axis of the viewer
  54025. * @param yaxis defines the y axis of the viewer
  54026. * @param zaxis defines the z axis of the viewer
  54027. */
  54028. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  54029. /**
  54030. * Creates an instance of this axes viewer.
  54031. * @returns a new axes viewer with instanced meshes
  54032. */
  54033. createInstance(): AxesViewer;
  54034. /** Releases resources */
  54035. dispose(): void;
  54036. private static _SetRenderingGroupId;
  54037. }
  54038. }
  54039. declare module BABYLON.Debug {
  54040. /**
  54041. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  54042. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  54043. */
  54044. export class BoneAxesViewer extends AxesViewer {
  54045. /**
  54046. * Gets or sets the target mesh where to display the axes viewer
  54047. */
  54048. mesh: Nullable<Mesh>;
  54049. /**
  54050. * Gets or sets the target bone where to display the axes viewer
  54051. */
  54052. bone: Nullable<Bone>;
  54053. /** Gets current position */
  54054. pos: Vector3;
  54055. /** Gets direction of X axis */
  54056. xaxis: Vector3;
  54057. /** Gets direction of Y axis */
  54058. yaxis: Vector3;
  54059. /** Gets direction of Z axis */
  54060. zaxis: Vector3;
  54061. /**
  54062. * Creates a new BoneAxesViewer
  54063. * @param scene defines the hosting scene
  54064. * @param bone defines the target bone
  54065. * @param mesh defines the target mesh
  54066. * @param scaleLines defines a scaling factor for line length (1 by default)
  54067. */
  54068. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  54069. /**
  54070. * Force the viewer to update
  54071. */
  54072. update(): void;
  54073. /** Releases resources */
  54074. dispose(): void;
  54075. }
  54076. }
  54077. declare module BABYLON {
  54078. /**
  54079. * Interface used to define scene explorer extensibility option
  54080. */
  54081. export interface IExplorerExtensibilityOption {
  54082. /**
  54083. * Define the option label
  54084. */
  54085. label: string;
  54086. /**
  54087. * Defines the action to execute on click
  54088. */
  54089. action: (entity: any) => void;
  54090. }
  54091. /**
  54092. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  54093. */
  54094. export interface IExplorerExtensibilityGroup {
  54095. /**
  54096. * Defines a predicate to test if a given type mut be extended
  54097. */
  54098. predicate: (entity: any) => boolean;
  54099. /**
  54100. * Gets the list of options added to a type
  54101. */
  54102. entries: IExplorerExtensibilityOption[];
  54103. }
  54104. /**
  54105. * Interface used to define the options to use to create the Inspector
  54106. */
  54107. export interface IInspectorOptions {
  54108. /**
  54109. * Display in overlay mode (default: false)
  54110. */
  54111. overlay?: boolean;
  54112. /**
  54113. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  54114. */
  54115. globalRoot?: HTMLElement;
  54116. /**
  54117. * Display the Scene explorer
  54118. */
  54119. showExplorer?: boolean;
  54120. /**
  54121. * Display the property inspector
  54122. */
  54123. showInspector?: boolean;
  54124. /**
  54125. * Display in embed mode (both panes on the right)
  54126. */
  54127. embedMode?: boolean;
  54128. /**
  54129. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  54130. */
  54131. handleResize?: boolean;
  54132. /**
  54133. * Allow the panes to popup (default: true)
  54134. */
  54135. enablePopup?: boolean;
  54136. /**
  54137. * Allow the panes to be closed by users (default: true)
  54138. */
  54139. enableClose?: boolean;
  54140. /**
  54141. * Optional list of extensibility entries
  54142. */
  54143. explorerExtensibility?: IExplorerExtensibilityGroup[];
  54144. /**
  54145. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  54146. */
  54147. inspectorURL?: string;
  54148. /**
  54149. * Optional initial tab (default to DebugLayerTab.Properties)
  54150. */
  54151. initialTab?: DebugLayerTab;
  54152. }
  54153. interface Scene {
  54154. /**
  54155. * @hidden
  54156. * Backing field
  54157. */
  54158. _debugLayer: DebugLayer;
  54159. /**
  54160. * Gets the debug layer (aka Inspector) associated with the scene
  54161. * @see https://doc.babylonjs.com/features/playground_debuglayer
  54162. */
  54163. debugLayer: DebugLayer;
  54164. }
  54165. /**
  54166. * Enum of inspector action tab
  54167. */
  54168. export enum DebugLayerTab {
  54169. /**
  54170. * Properties tag (default)
  54171. */
  54172. Properties = 0,
  54173. /**
  54174. * Debug tab
  54175. */
  54176. Debug = 1,
  54177. /**
  54178. * Statistics tab
  54179. */
  54180. Statistics = 2,
  54181. /**
  54182. * Tools tab
  54183. */
  54184. Tools = 3,
  54185. /**
  54186. * Settings tab
  54187. */
  54188. Settings = 4
  54189. }
  54190. /**
  54191. * The debug layer (aka Inspector) is the go to tool in order to better understand
  54192. * what is happening in your scene
  54193. * @see https://doc.babylonjs.com/features/playground_debuglayer
  54194. */
  54195. export class DebugLayer {
  54196. /**
  54197. * Define the url to get the inspector script from.
  54198. * By default it uses the babylonjs CDN.
  54199. * @ignoreNaming
  54200. */
  54201. static InspectorURL: string;
  54202. private _scene;
  54203. private BJSINSPECTOR;
  54204. private _onPropertyChangedObservable?;
  54205. /**
  54206. * Observable triggered when a property is changed through the inspector.
  54207. */
  54208. get onPropertyChangedObservable(): any;
  54209. /**
  54210. * Instantiates a new debug layer.
  54211. * The debug layer (aka Inspector) is the go to tool in order to better understand
  54212. * what is happening in your scene
  54213. * @see https://doc.babylonjs.com/features/playground_debuglayer
  54214. * @param scene Defines the scene to inspect
  54215. */
  54216. constructor(scene: Scene);
  54217. /** Creates the inspector window. */
  54218. private _createInspector;
  54219. /**
  54220. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  54221. * @param entity defines the entity to select
  54222. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  54223. */
  54224. select(entity: any, lineContainerTitles?: string | string[]): void;
  54225. /** Get the inspector from bundle or global */
  54226. private _getGlobalInspector;
  54227. /**
  54228. * Get if the inspector is visible or not.
  54229. * @returns true if visible otherwise, false
  54230. */
  54231. isVisible(): boolean;
  54232. /**
  54233. * Hide the inspector and close its window.
  54234. */
  54235. hide(): void;
  54236. /**
  54237. * Update the scene in the inspector
  54238. */
  54239. setAsActiveScene(): void;
  54240. /**
  54241. * Launch the debugLayer.
  54242. * @param config Define the configuration of the inspector
  54243. * @return a promise fulfilled when the debug layer is visible
  54244. */
  54245. show(config?: IInspectorOptions): Promise<DebugLayer>;
  54246. }
  54247. }
  54248. declare module BABYLON {
  54249. /**
  54250. * Class containing static functions to help procedurally build meshes
  54251. */
  54252. export class BoxBuilder {
  54253. /**
  54254. * Creates a box mesh
  54255. * * The parameter `size` sets the size (float) of each box side (default 1)
  54256. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  54257. * * 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)
  54258. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54259. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54260. * * 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
  54261. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54262. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54263. * @param name defines the name of the mesh
  54264. * @param options defines the options used to create the mesh
  54265. * @param scene defines the hosting scene
  54266. * @returns the box mesh
  54267. */
  54268. static CreateBox(name: string, options: {
  54269. size?: number;
  54270. width?: number;
  54271. height?: number;
  54272. depth?: number;
  54273. faceUV?: Vector4[];
  54274. faceColors?: Color4[];
  54275. sideOrientation?: number;
  54276. frontUVs?: Vector4;
  54277. backUVs?: Vector4;
  54278. wrap?: boolean;
  54279. topBaseAt?: number;
  54280. bottomBaseAt?: number;
  54281. updatable?: boolean;
  54282. }, scene?: Nullable<Scene>): Mesh;
  54283. }
  54284. }
  54285. declare module BABYLON.Debug {
  54286. /**
  54287. * Used to show the physics impostor around the specific mesh
  54288. */
  54289. export class PhysicsViewer {
  54290. /** @hidden */
  54291. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  54292. /** @hidden */
  54293. protected _meshes: Array<Nullable<AbstractMesh>>;
  54294. /** @hidden */
  54295. protected _scene: Nullable<Scene>;
  54296. /** @hidden */
  54297. protected _numMeshes: number;
  54298. /** @hidden */
  54299. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  54300. private _renderFunction;
  54301. private _utilityLayer;
  54302. private _debugBoxMesh;
  54303. private _debugSphereMesh;
  54304. private _debugCylinderMesh;
  54305. private _debugMaterial;
  54306. private _debugMeshMeshes;
  54307. /**
  54308. * Creates a new PhysicsViewer
  54309. * @param scene defines the hosting scene
  54310. */
  54311. constructor(scene: Scene);
  54312. /** @hidden */
  54313. protected _updateDebugMeshes(): void;
  54314. /**
  54315. * Renders a specified physic impostor
  54316. * @param impostor defines the impostor to render
  54317. * @param targetMesh defines the mesh represented by the impostor
  54318. * @returns the new debug mesh used to render the impostor
  54319. */
  54320. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  54321. /**
  54322. * Hides a specified physic impostor
  54323. * @param impostor defines the impostor to hide
  54324. */
  54325. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  54326. private _getDebugMaterial;
  54327. private _getDebugBoxMesh;
  54328. private _getDebugSphereMesh;
  54329. private _getDebugCylinderMesh;
  54330. private _getDebugMeshMesh;
  54331. private _getDebugMesh;
  54332. /** Releases all resources */
  54333. dispose(): void;
  54334. }
  54335. }
  54336. declare module BABYLON {
  54337. /**
  54338. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  54339. * in order to better appreciate the issue one might have.
  54340. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  54341. */
  54342. export class RayHelper {
  54343. /**
  54344. * Defines the ray we are currently tryin to visualize.
  54345. */
  54346. ray: Nullable<Ray>;
  54347. private _renderPoints;
  54348. private _renderLine;
  54349. private _renderFunction;
  54350. private _scene;
  54351. private _onAfterRenderObserver;
  54352. private _onAfterStepObserver;
  54353. private _attachedToMesh;
  54354. private _meshSpaceDirection;
  54355. private _meshSpaceOrigin;
  54356. /**
  54357. * Helper function to create a colored helper in a scene in one line.
  54358. * @param ray Defines the ray we are currently tryin to visualize
  54359. * @param scene Defines the scene the ray is used in
  54360. * @param color Defines the color we want to see the ray in
  54361. * @returns The newly created ray helper.
  54362. */
  54363. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  54364. /**
  54365. * Instantiate a new ray helper.
  54366. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  54367. * in order to better appreciate the issue one might have.
  54368. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  54369. * @param ray Defines the ray we are currently tryin to visualize
  54370. */
  54371. constructor(ray: Ray);
  54372. /**
  54373. * Shows the ray we are willing to debug.
  54374. * @param scene Defines the scene the ray needs to be rendered in
  54375. * @param color Defines the color the ray needs to be rendered in
  54376. */
  54377. show(scene: Scene, color?: Color3): void;
  54378. /**
  54379. * Hides the ray we are debugging.
  54380. */
  54381. hide(): void;
  54382. private _render;
  54383. /**
  54384. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  54385. * @param mesh Defines the mesh we want the helper attached to
  54386. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  54387. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  54388. * @param length Defines the length of the ray
  54389. */
  54390. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  54391. /**
  54392. * Detach the ray helper from the mesh it has previously been attached to.
  54393. */
  54394. detachFromMesh(): void;
  54395. private _updateToMesh;
  54396. /**
  54397. * Dispose the helper and release its associated resources.
  54398. */
  54399. dispose(): void;
  54400. }
  54401. }
  54402. declare module BABYLON {
  54403. /**
  54404. * Defines the options associated with the creation of a SkeletonViewer.
  54405. */
  54406. export interface ISkeletonViewerOptions {
  54407. /** Should the system pause animations before building the Viewer? */
  54408. pauseAnimations: boolean;
  54409. /** Should the system return the skeleton to rest before building? */
  54410. returnToRest: boolean;
  54411. /** public Display Mode of the Viewer */
  54412. displayMode: number;
  54413. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  54414. displayOptions: ISkeletonViewerDisplayOptions;
  54415. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  54416. computeBonesUsingShaders: boolean;
  54417. /** Flag ignore non weighted bones */
  54418. useAllBones: boolean;
  54419. }
  54420. /**
  54421. * Defines how to display the various bone meshes for the viewer.
  54422. */
  54423. export interface ISkeletonViewerDisplayOptions {
  54424. /** How far down to start tapering the bone spurs */
  54425. midStep?: number;
  54426. /** How big is the midStep? */
  54427. midStepFactor?: number;
  54428. /** Base for the Sphere Size */
  54429. sphereBaseSize?: number;
  54430. /** The ratio of the sphere to the longest bone in units */
  54431. sphereScaleUnit?: number;
  54432. /** Ratio for the Sphere Size */
  54433. sphereFactor?: number;
  54434. /** Whether a spur should attach its far end to the child bone position */
  54435. spurFollowsChild?: boolean;
  54436. /** Whether to show local axes or not */
  54437. showLocalAxes?: boolean;
  54438. /** Length of each local axis */
  54439. localAxesSize?: number;
  54440. }
  54441. /**
  54442. * Defines the constructor options for the BoneWeight Shader.
  54443. */
  54444. export interface IBoneWeightShaderOptions {
  54445. /** Skeleton to Map */
  54446. skeleton: Skeleton;
  54447. /** Colors for Uninfluenced bones */
  54448. colorBase?: Color3;
  54449. /** Colors for 0.0-0.25 Weight bones */
  54450. colorZero?: Color3;
  54451. /** Color for 0.25-0.5 Weight Influence */
  54452. colorQuarter?: Color3;
  54453. /** Color for 0.5-0.75 Weight Influence */
  54454. colorHalf?: Color3;
  54455. /** Color for 0.75-1 Weight Influence */
  54456. colorFull?: Color3;
  54457. /** Color for Zero Weight Influence */
  54458. targetBoneIndex?: number;
  54459. }
  54460. /**
  54461. * Simple structure of the gradient steps for the Color Map.
  54462. */
  54463. export interface ISkeletonMapShaderColorMapKnot {
  54464. /** Color of the Knot */
  54465. color: Color3;
  54466. /** Location of the Knot */
  54467. location: number;
  54468. }
  54469. /**
  54470. * Defines the constructor options for the SkeletonMap Shader.
  54471. */
  54472. export interface ISkeletonMapShaderOptions {
  54473. /** Skeleton to Map */
  54474. skeleton: Skeleton;
  54475. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  54476. colorMap?: ISkeletonMapShaderColorMapKnot[];
  54477. }
  54478. }
  54479. declare module BABYLON {
  54480. /**
  54481. * Class containing static functions to help procedurally build meshes
  54482. */
  54483. export class RibbonBuilder {
  54484. /**
  54485. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54486. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54487. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54488. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54489. * * 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
  54490. * * 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
  54491. * * 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
  54492. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54493. * * 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
  54494. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54495. * * 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
  54496. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54497. * * 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
  54498. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54500. * @param name defines the name of the mesh
  54501. * @param options defines the options used to create the mesh
  54502. * @param scene defines the hosting scene
  54503. * @returns the ribbon mesh
  54504. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54505. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54506. */
  54507. static CreateRibbon(name: string, options: {
  54508. pathArray: Vector3[][];
  54509. closeArray?: boolean;
  54510. closePath?: boolean;
  54511. offset?: number;
  54512. updatable?: boolean;
  54513. sideOrientation?: number;
  54514. frontUVs?: Vector4;
  54515. backUVs?: Vector4;
  54516. instance?: Mesh;
  54517. invertUV?: boolean;
  54518. uvs?: Vector2[];
  54519. colors?: Color4[];
  54520. }, scene?: Nullable<Scene>): Mesh;
  54521. }
  54522. }
  54523. declare module BABYLON {
  54524. /**
  54525. * Class containing static functions to help procedurally build meshes
  54526. */
  54527. export class ShapeBuilder {
  54528. /**
  54529. * 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.
  54530. * * 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.
  54531. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54532. * * 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.
  54533. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  54534. * * 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
  54535. * * 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
  54536. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  54537. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54538. * * 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
  54539. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  54540. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54541. * @param name defines the name of the mesh
  54542. * @param options defines the options used to create the mesh
  54543. * @param scene defines the hosting scene
  54544. * @returns the extruded shape mesh
  54545. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54546. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54547. */
  54548. static ExtrudeShape(name: string, options: {
  54549. shape: Vector3[];
  54550. path: Vector3[];
  54551. scale?: number;
  54552. rotation?: number;
  54553. cap?: number;
  54554. updatable?: boolean;
  54555. sideOrientation?: number;
  54556. frontUVs?: Vector4;
  54557. backUVs?: Vector4;
  54558. instance?: Mesh;
  54559. invertUV?: boolean;
  54560. }, scene?: Nullable<Scene>): Mesh;
  54561. /**
  54562. * Creates an custom extruded shape mesh.
  54563. * The custom 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 `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
  54567. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  54568. * * 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
  54569. * * It must returns a float value that will be the scale value applied to the shape on each path point
  54570. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  54571. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  54572. * * 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
  54573. * * 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
  54574. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  54575. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54576. * * 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
  54577. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54578. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54579. * @param name defines the name of the mesh
  54580. * @param options defines the options used to create the mesh
  54581. * @param scene defines the hosting scene
  54582. * @returns the custom extruded shape mesh
  54583. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  54584. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54585. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54586. */
  54587. static ExtrudeShapeCustom(name: string, options: {
  54588. shape: Vector3[];
  54589. path: Vector3[];
  54590. scaleFunction?: any;
  54591. rotationFunction?: any;
  54592. ribbonCloseArray?: boolean;
  54593. ribbonClosePath?: boolean;
  54594. cap?: number;
  54595. updatable?: boolean;
  54596. sideOrientation?: number;
  54597. frontUVs?: Vector4;
  54598. backUVs?: Vector4;
  54599. instance?: Mesh;
  54600. invertUV?: boolean;
  54601. }, scene?: Nullable<Scene>): Mesh;
  54602. private static _ExtrudeShapeGeneric;
  54603. }
  54604. }
  54605. declare module BABYLON.Debug {
  54606. /**
  54607. * Class used to render a debug view of a given skeleton
  54608. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  54609. */
  54610. export class SkeletonViewer {
  54611. /** defines the skeleton to render */
  54612. skeleton: Skeleton;
  54613. /** defines the mesh attached to the skeleton */
  54614. mesh: AbstractMesh;
  54615. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  54616. autoUpdateBonesMatrices: boolean;
  54617. /** defines the rendering group id to use with the viewer */
  54618. renderingGroupId: number;
  54619. /** is the options for the viewer */
  54620. options: Partial<ISkeletonViewerOptions>;
  54621. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  54622. static readonly DISPLAY_LINES: number;
  54623. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  54624. static readonly DISPLAY_SPHERES: number;
  54625. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  54626. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  54627. /** public static method to create a BoneWeight Shader
  54628. * @param options The constructor options
  54629. * @param scene The scene that the shader is scoped to
  54630. * @returns The created ShaderMaterial
  54631. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  54632. */
  54633. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  54634. /** public static method to create a BoneWeight Shader
  54635. * @param options The constructor options
  54636. * @param scene The scene that the shader is scoped to
  54637. * @returns The created ShaderMaterial
  54638. */
  54639. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  54640. /** private static method to create a BoneWeight Shader
  54641. * @param size The size of the buffer to create (usually the bone count)
  54642. * @param colorMap The gradient data to generate
  54643. * @param scene The scene that the shader is scoped to
  54644. * @returns an Array of floats from the color gradient values
  54645. */
  54646. private static _CreateBoneMapColorBuffer;
  54647. /** If SkeletonViewer scene scope. */
  54648. private _scene;
  54649. /** Gets or sets the color used to render the skeleton */
  54650. color: Color3;
  54651. /** Array of the points of the skeleton fo the line view. */
  54652. private _debugLines;
  54653. /** The SkeletonViewers Mesh. */
  54654. private _debugMesh;
  54655. /** The local axes Meshes. */
  54656. private _localAxes;
  54657. /** If SkeletonViewer is enabled. */
  54658. private _isEnabled;
  54659. /** If SkeletonViewer is ready. */
  54660. private _ready;
  54661. /** SkeletonViewer render observable. */
  54662. private _obs;
  54663. /** The Utility Layer to render the gizmos in. */
  54664. private _utilityLayer;
  54665. private _boneIndices;
  54666. /** Gets the Scene. */
  54667. get scene(): Scene;
  54668. /** Gets the utilityLayer. */
  54669. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  54670. /** Checks Ready Status. */
  54671. get isReady(): Boolean;
  54672. /** Sets Ready Status. */
  54673. set ready(value: boolean);
  54674. /** Gets the debugMesh */
  54675. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  54676. /** Sets the debugMesh */
  54677. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  54678. /** Gets the displayMode */
  54679. get displayMode(): number;
  54680. /** Sets the displayMode */
  54681. set displayMode(value: number);
  54682. /**
  54683. * Creates a new SkeletonViewer
  54684. * @param skeleton defines the skeleton to render
  54685. * @param mesh defines the mesh attached to the skeleton
  54686. * @param scene defines the hosting scene
  54687. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  54688. * @param renderingGroupId defines the rendering group id to use with the viewer
  54689. * @param options All of the extra constructor options for the SkeletonViewer
  54690. */
  54691. constructor(
  54692. /** defines the skeleton to render */
  54693. skeleton: Skeleton,
  54694. /** defines the mesh attached to the skeleton */
  54695. mesh: AbstractMesh,
  54696. /** The Scene scope*/
  54697. scene: Scene,
  54698. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  54699. autoUpdateBonesMatrices?: boolean,
  54700. /** defines the rendering group id to use with the viewer */
  54701. renderingGroupId?: number,
  54702. /** is the options for the viewer */
  54703. options?: Partial<ISkeletonViewerOptions>);
  54704. /** The Dynamic bindings for the update functions */
  54705. private _bindObs;
  54706. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  54707. update(): void;
  54708. /** Gets or sets a boolean indicating if the viewer is enabled */
  54709. set isEnabled(value: boolean);
  54710. get isEnabled(): boolean;
  54711. private _getBonePosition;
  54712. private _getLinesForBonesWithLength;
  54713. private _getLinesForBonesNoLength;
  54714. /** function to revert the mesh and scene back to the initial state. */
  54715. private _revert;
  54716. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  54717. private _getAbsoluteBindPoseToRef;
  54718. /** function to build and bind sphere joint points and spur bone representations. */
  54719. private _buildSpheresAndSpurs;
  54720. private _buildLocalAxes;
  54721. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  54722. private _displayLinesUpdate;
  54723. /** Changes the displayMode of the skeleton viewer
  54724. * @param mode The displayMode numerical value
  54725. */
  54726. changeDisplayMode(mode: number): void;
  54727. /** Sets a display option of the skeleton viewer
  54728. *
  54729. * | Option | Type | Default | Description |
  54730. * | ---------------- | ------- | ------- | ----------- |
  54731. * | 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`. |
  54732. * | 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`. |
  54733. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  54734. * | 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`. |
  54735. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  54736. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  54737. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  54738. *
  54739. * @param option String of the option name
  54740. * @param value The numerical option value
  54741. */
  54742. changeDisplayOptions(option: string, value: number): void;
  54743. /** Release associated resources */
  54744. dispose(): void;
  54745. }
  54746. }
  54747. declare module BABYLON {
  54748. /**
  54749. * Enum for Device Types
  54750. */
  54751. export enum DeviceType {
  54752. /** Generic */
  54753. Generic = 0,
  54754. /** Keyboard */
  54755. Keyboard = 1,
  54756. /** Mouse */
  54757. Mouse = 2,
  54758. /** Touch Pointers */
  54759. Touch = 3,
  54760. /** PS4 Dual Shock */
  54761. DualShock = 4,
  54762. /** Xbox */
  54763. Xbox = 5,
  54764. /** Switch Controller */
  54765. Switch = 6
  54766. }
  54767. /**
  54768. * Enum for All Pointers (Touch/Mouse)
  54769. */
  54770. export enum PointerInput {
  54771. /** Horizontal Axis */
  54772. Horizontal = 0,
  54773. /** Vertical Axis */
  54774. Vertical = 1,
  54775. /** Left Click or Touch */
  54776. LeftClick = 2,
  54777. /** Middle Click */
  54778. MiddleClick = 3,
  54779. /** Right Click */
  54780. RightClick = 4,
  54781. /** Browser Back */
  54782. BrowserBack = 5,
  54783. /** Browser Forward */
  54784. BrowserForward = 6
  54785. }
  54786. /**
  54787. * Enum for Dual Shock Gamepad
  54788. */
  54789. export enum DualShockInput {
  54790. /** Cross */
  54791. Cross = 0,
  54792. /** Circle */
  54793. Circle = 1,
  54794. /** Square */
  54795. Square = 2,
  54796. /** Triangle */
  54797. Triangle = 3,
  54798. /** L1 */
  54799. L1 = 4,
  54800. /** R1 */
  54801. R1 = 5,
  54802. /** L2 */
  54803. L2 = 6,
  54804. /** R2 */
  54805. R2 = 7,
  54806. /** Share */
  54807. Share = 8,
  54808. /** Options */
  54809. Options = 9,
  54810. /** L3 */
  54811. L3 = 10,
  54812. /** R3 */
  54813. R3 = 11,
  54814. /** DPadUp */
  54815. DPadUp = 12,
  54816. /** DPadDown */
  54817. DPadDown = 13,
  54818. /** DPadLeft */
  54819. DPadLeft = 14,
  54820. /** DRight */
  54821. DPadRight = 15,
  54822. /** Home */
  54823. Home = 16,
  54824. /** TouchPad */
  54825. TouchPad = 17,
  54826. /** LStickXAxis */
  54827. LStickXAxis = 18,
  54828. /** LStickYAxis */
  54829. LStickYAxis = 19,
  54830. /** RStickXAxis */
  54831. RStickXAxis = 20,
  54832. /** RStickYAxis */
  54833. RStickYAxis = 21
  54834. }
  54835. /**
  54836. * Enum for Xbox Gamepad
  54837. */
  54838. export enum XboxInput {
  54839. /** A */
  54840. A = 0,
  54841. /** B */
  54842. B = 1,
  54843. /** X */
  54844. X = 2,
  54845. /** Y */
  54846. Y = 3,
  54847. /** LB */
  54848. LB = 4,
  54849. /** RB */
  54850. RB = 5,
  54851. /** LT */
  54852. LT = 6,
  54853. /** RT */
  54854. RT = 7,
  54855. /** Back */
  54856. Back = 8,
  54857. /** Start */
  54858. Start = 9,
  54859. /** LS */
  54860. LS = 10,
  54861. /** RS */
  54862. RS = 11,
  54863. /** DPadUp */
  54864. DPadUp = 12,
  54865. /** DPadDown */
  54866. DPadDown = 13,
  54867. /** DPadLeft */
  54868. DPadLeft = 14,
  54869. /** DRight */
  54870. DPadRight = 15,
  54871. /** Home */
  54872. Home = 16,
  54873. /** LStickXAxis */
  54874. LStickXAxis = 17,
  54875. /** LStickYAxis */
  54876. LStickYAxis = 18,
  54877. /** RStickXAxis */
  54878. RStickXAxis = 19,
  54879. /** RStickYAxis */
  54880. RStickYAxis = 20
  54881. }
  54882. /**
  54883. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  54884. */
  54885. export enum SwitchInput {
  54886. /** B */
  54887. B = 0,
  54888. /** A */
  54889. A = 1,
  54890. /** Y */
  54891. Y = 2,
  54892. /** X */
  54893. X = 3,
  54894. /** L */
  54895. L = 4,
  54896. /** R */
  54897. R = 5,
  54898. /** ZL */
  54899. ZL = 6,
  54900. /** ZR */
  54901. ZR = 7,
  54902. /** Minus */
  54903. Minus = 8,
  54904. /** Plus */
  54905. Plus = 9,
  54906. /** LS */
  54907. LS = 10,
  54908. /** RS */
  54909. RS = 11,
  54910. /** DPadUp */
  54911. DPadUp = 12,
  54912. /** DPadDown */
  54913. DPadDown = 13,
  54914. /** DPadLeft */
  54915. DPadLeft = 14,
  54916. /** DRight */
  54917. DPadRight = 15,
  54918. /** Home */
  54919. Home = 16,
  54920. /** Capture */
  54921. Capture = 17,
  54922. /** LStickXAxis */
  54923. LStickXAxis = 18,
  54924. /** LStickYAxis */
  54925. LStickYAxis = 19,
  54926. /** RStickXAxis */
  54927. RStickXAxis = 20,
  54928. /** RStickYAxis */
  54929. RStickYAxis = 21
  54930. }
  54931. }
  54932. declare module BABYLON {
  54933. /**
  54934. * This class will take all inputs from Keyboard, Pointer, and
  54935. * any Gamepads and provide a polling system that all devices
  54936. * will use. This class assumes that there will only be one
  54937. * pointer device and one keyboard.
  54938. */
  54939. export class DeviceInputSystem implements IDisposable {
  54940. /**
  54941. * Returns onDeviceConnected callback property
  54942. * @returns Callback with function to execute when a device is connected
  54943. */
  54944. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  54945. /**
  54946. * Sets callback function when a device is connected and executes against all connected devices
  54947. * @param callback Function to execute when a device is connected
  54948. */
  54949. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  54950. /**
  54951. * Callback to be triggered when a device is disconnected
  54952. */
  54953. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  54954. /**
  54955. * Callback to be triggered when event driven input is updated
  54956. */
  54957. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  54958. private _inputs;
  54959. private _gamepads;
  54960. private _keyboardActive;
  54961. private _pointerActive;
  54962. private _elementToAttachTo;
  54963. private _keyboardDownEvent;
  54964. private _keyboardUpEvent;
  54965. private _pointerMoveEvent;
  54966. private _pointerDownEvent;
  54967. private _pointerUpEvent;
  54968. private _gamepadConnectedEvent;
  54969. private _gamepadDisconnectedEvent;
  54970. private _onDeviceConnected;
  54971. private static _MAX_KEYCODES;
  54972. private static _MAX_POINTER_INPUTS;
  54973. private constructor();
  54974. /**
  54975. * Creates a new DeviceInputSystem instance
  54976. * @param engine Engine to pull input element from
  54977. * @returns The new instance
  54978. */
  54979. static Create(engine: Engine): DeviceInputSystem;
  54980. /**
  54981. * Checks for current device input value, given an id and input index
  54982. * @param deviceName Id of connected device
  54983. * @param inputIndex Index of device input
  54984. * @returns Current value of input
  54985. */
  54986. /**
  54987. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  54988. * @param deviceType Enum specifiying device type
  54989. * @param deviceSlot "Slot" or index that device is referenced in
  54990. * @param inputIndex Id of input to be checked
  54991. * @returns Current value of input
  54992. */
  54993. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  54994. /**
  54995. * Dispose of all the eventlisteners
  54996. */
  54997. dispose(): void;
  54998. /**
  54999. * Checks for existing connections to devices and register them, if necessary
  55000. * Currently handles gamepads and mouse
  55001. */
  55002. private _checkForConnectedDevices;
  55003. /**
  55004. * Add a gamepad to the DeviceInputSystem
  55005. * @param gamepad A single DOM Gamepad object
  55006. */
  55007. private _addGamePad;
  55008. /**
  55009. * Add pointer device to DeviceInputSystem
  55010. * @param deviceType Type of Pointer to add
  55011. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  55012. * @param currentX Current X at point of adding
  55013. * @param currentY Current Y at point of adding
  55014. */
  55015. private _addPointerDevice;
  55016. /**
  55017. * Add device and inputs to device array
  55018. * @param deviceType Enum specifiying device type
  55019. * @param deviceSlot "Slot" or index that device is referenced in
  55020. * @param numberOfInputs Number of input entries to create for given device
  55021. */
  55022. private _registerDevice;
  55023. /**
  55024. * Given a specific device name, remove that device from the device map
  55025. * @param deviceType Enum specifiying device type
  55026. * @param deviceSlot "Slot" or index that device is referenced in
  55027. */
  55028. private _unregisterDevice;
  55029. /**
  55030. * Handle all actions that come from keyboard interaction
  55031. */
  55032. private _handleKeyActions;
  55033. /**
  55034. * Handle all actions that come from pointer interaction
  55035. */
  55036. private _handlePointerActions;
  55037. /**
  55038. * Handle all actions that come from gamepad interaction
  55039. */
  55040. private _handleGamepadActions;
  55041. /**
  55042. * Update all non-event based devices with each frame
  55043. * @param deviceType Enum specifiying device type
  55044. * @param deviceSlot "Slot" or index that device is referenced in
  55045. * @param inputIndex Id of input to be checked
  55046. */
  55047. private _updateDevice;
  55048. /**
  55049. * Gets DeviceType from the device name
  55050. * @param deviceName Name of Device from DeviceInputSystem
  55051. * @returns DeviceType enum value
  55052. */
  55053. private _getGamepadDeviceType;
  55054. }
  55055. }
  55056. declare module BABYLON {
  55057. /**
  55058. * Type to handle enforcement of inputs
  55059. */
  55060. 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;
  55061. }
  55062. declare module BABYLON {
  55063. /**
  55064. * Class that handles all input for a specific device
  55065. */
  55066. export class DeviceSource<T extends DeviceType> {
  55067. /** Type of device */
  55068. readonly deviceType: DeviceType;
  55069. /** "Slot" or index that device is referenced in */
  55070. readonly deviceSlot: number;
  55071. /**
  55072. * Observable to handle device input changes per device
  55073. */
  55074. readonly onInputChangedObservable: Observable<{
  55075. inputIndex: DeviceInput<T>;
  55076. previousState: Nullable<number>;
  55077. currentState: Nullable<number>;
  55078. }>;
  55079. private readonly _deviceInputSystem;
  55080. /**
  55081. * Default Constructor
  55082. * @param deviceInputSystem Reference to DeviceInputSystem
  55083. * @param deviceType Type of device
  55084. * @param deviceSlot "Slot" or index that device is referenced in
  55085. */
  55086. constructor(deviceInputSystem: DeviceInputSystem,
  55087. /** Type of device */
  55088. deviceType: DeviceType,
  55089. /** "Slot" or index that device is referenced in */
  55090. deviceSlot?: number);
  55091. /**
  55092. * Get input for specific input
  55093. * @param inputIndex index of specific input on device
  55094. * @returns Input value from DeviceInputSystem
  55095. */
  55096. getInput(inputIndex: DeviceInput<T>): number;
  55097. }
  55098. /**
  55099. * Class to keep track of devices
  55100. */
  55101. export class DeviceSourceManager implements IDisposable {
  55102. /**
  55103. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  55104. */
  55105. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  55106. /**
  55107. * Observable to be triggered when after a device is disconnected
  55108. */
  55109. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  55110. private readonly _devices;
  55111. private readonly _firstDevice;
  55112. private readonly _deviceInputSystem;
  55113. /**
  55114. * Default Constructor
  55115. * @param engine engine to pull input element from
  55116. */
  55117. constructor(engine: Engine);
  55118. /**
  55119. * Gets a DeviceSource, given a type and slot
  55120. * @param deviceType Enum specifying device type
  55121. * @param deviceSlot "Slot" or index that device is referenced in
  55122. * @returns DeviceSource object
  55123. */
  55124. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  55125. /**
  55126. * Gets an array of DeviceSource objects for a given device type
  55127. * @param deviceType Enum specifying device type
  55128. * @returns Array of DeviceSource objects
  55129. */
  55130. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  55131. /**
  55132. * Returns a read-only list of all available devices
  55133. * @returns Read-only array with active devices
  55134. */
  55135. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  55136. /**
  55137. * Dispose of DeviceInputSystem and other parts
  55138. */
  55139. dispose(): void;
  55140. /**
  55141. * Function to add device name to device list
  55142. * @param deviceType Enum specifying device type
  55143. * @param deviceSlot "Slot" or index that device is referenced in
  55144. */
  55145. private _addDevice;
  55146. /**
  55147. * Function to remove device name to device list
  55148. * @param deviceType Enum specifying device type
  55149. * @param deviceSlot "Slot" or index that device is referenced in
  55150. */
  55151. private _removeDevice;
  55152. /**
  55153. * Updates array storing first connected device of each type
  55154. * @param type Type of Device
  55155. */
  55156. private _updateFirstDevices;
  55157. }
  55158. }
  55159. declare module BABYLON {
  55160. /**
  55161. * Options to create the null engine
  55162. */
  55163. export class NullEngineOptions {
  55164. /**
  55165. * Render width (Default: 512)
  55166. */
  55167. renderWidth: number;
  55168. /**
  55169. * Render height (Default: 256)
  55170. */
  55171. renderHeight: number;
  55172. /**
  55173. * Texture size (Default: 512)
  55174. */
  55175. textureSize: number;
  55176. /**
  55177. * If delta time between frames should be constant
  55178. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  55179. */
  55180. deterministicLockstep: boolean;
  55181. /**
  55182. * Maximum about of steps between frames (Default: 4)
  55183. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  55184. */
  55185. lockstepMaxSteps: number;
  55186. /**
  55187. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  55188. */
  55189. useHighPrecisionMatrix?: boolean;
  55190. }
  55191. /**
  55192. * The null engine class provides support for headless version of babylon.js.
  55193. * This can be used in server side scenario or for testing purposes
  55194. */
  55195. export class NullEngine extends Engine {
  55196. private _options;
  55197. /**
  55198. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  55199. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  55200. * @returns true if engine is in deterministic lock step mode
  55201. */
  55202. isDeterministicLockStep(): boolean;
  55203. /**
  55204. * Gets the max steps when engine is running in deterministic lock step
  55205. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  55206. * @returns the max steps
  55207. */
  55208. getLockstepMaxSteps(): number;
  55209. /**
  55210. * Gets the current hardware scaling level.
  55211. * By default the hardware scaling level is computed from the window device ratio.
  55212. * 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.
  55213. * @returns a number indicating the current hardware scaling level
  55214. */
  55215. getHardwareScalingLevel(): number;
  55216. constructor(options?: NullEngineOptions);
  55217. /**
  55218. * Creates a vertex buffer
  55219. * @param vertices the data for the vertex buffer
  55220. * @returns the new WebGL static buffer
  55221. */
  55222. createVertexBuffer(vertices: FloatArray): DataBuffer;
  55223. /**
  55224. * Creates a new index buffer
  55225. * @param indices defines the content of the index buffer
  55226. * @param updatable defines if the index buffer must be updatable
  55227. * @returns a new webGL buffer
  55228. */
  55229. createIndexBuffer(indices: IndicesArray): DataBuffer;
  55230. /**
  55231. * Clear the current render buffer or the current render target (if any is set up)
  55232. * @param color defines the color to use
  55233. * @param backBuffer defines if the back buffer must be cleared
  55234. * @param depth defines if the depth buffer must be cleared
  55235. * @param stencil defines if the stencil buffer must be cleared
  55236. */
  55237. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  55238. /**
  55239. * Gets the current render width
  55240. * @param useScreen defines if screen size must be used (or the current render target if any)
  55241. * @returns a number defining the current render width
  55242. */
  55243. getRenderWidth(useScreen?: boolean): number;
  55244. /**
  55245. * Gets the current render height
  55246. * @param useScreen defines if screen size must be used (or the current render target if any)
  55247. * @returns a number defining the current render height
  55248. */
  55249. getRenderHeight(useScreen?: boolean): number;
  55250. /**
  55251. * Set the WebGL's viewport
  55252. * @param viewport defines the viewport element to be used
  55253. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  55254. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  55255. */
  55256. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  55257. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  55258. /**
  55259. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  55260. * @param pipelineContext defines the pipeline context to use
  55261. * @param uniformsNames defines the list of uniform names
  55262. * @returns an array of webGL uniform locations
  55263. */
  55264. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  55265. /**
  55266. * Gets the lsit of active attributes for a given webGL program
  55267. * @param pipelineContext defines the pipeline context to use
  55268. * @param attributesNames defines the list of attribute names to get
  55269. * @returns an array of indices indicating the offset of each attribute
  55270. */
  55271. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  55272. /**
  55273. * Binds an effect to the webGL context
  55274. * @param effect defines the effect to bind
  55275. */
  55276. bindSamplers(effect: Effect): void;
  55277. /**
  55278. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  55279. * @param effect defines the effect to activate
  55280. */
  55281. enableEffect(effect: Effect): void;
  55282. /**
  55283. * Set various states to the webGL context
  55284. * @param culling defines backface culling state
  55285. * @param zOffset defines the value to apply to zOffset (0 by default)
  55286. * @param force defines if states must be applied even if cache is up to date
  55287. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  55288. */
  55289. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  55290. /**
  55291. * Set the value of an uniform to an array of int32
  55292. * @param uniform defines the webGL uniform location where to store the value
  55293. * @param array defines the array of int32 to store
  55294. * @returns true if value was set
  55295. */
  55296. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55297. /**
  55298. * Set the value of an uniform to an array of int32 (stored as vec2)
  55299. * @param uniform defines the webGL uniform location where to store the value
  55300. * @param array defines the array of int32 to store
  55301. * @returns true if value was set
  55302. */
  55303. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55304. /**
  55305. * Set the value of an uniform to an array of int32 (stored as vec3)
  55306. * @param uniform defines the webGL uniform location where to store the value
  55307. * @param array defines the array of int32 to store
  55308. * @returns true if value was set
  55309. */
  55310. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55311. /**
  55312. * Set the value of an uniform to an array of int32 (stored as vec4)
  55313. * @param uniform defines the webGL uniform location where to store the value
  55314. * @param array defines the array of int32 to store
  55315. * @returns true if value was set
  55316. */
  55317. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55318. /**
  55319. * Set the value of an uniform to an array of float32
  55320. * @param uniform defines the webGL uniform location where to store the value
  55321. * @param array defines the array of float32 to store
  55322. * @returns true if value was set
  55323. */
  55324. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55325. /**
  55326. * Set the value of an uniform to an array of float32 (stored as vec2)
  55327. * @param uniform defines the webGL uniform location where to store the value
  55328. * @param array defines the array of float32 to store
  55329. * @returns true if value was set
  55330. */
  55331. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55332. /**
  55333. * Set the value of an uniform to an array of float32 (stored as vec3)
  55334. * @param uniform defines the webGL uniform location where to store the value
  55335. * @param array defines the array of float32 to store
  55336. * @returns true if value was set
  55337. */
  55338. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55339. /**
  55340. * Set the value of an uniform to an array of float32 (stored as vec4)
  55341. * @param uniform defines the webGL uniform location where to store the value
  55342. * @param array defines the array of float32 to store
  55343. * @returns true if value was set
  55344. */
  55345. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55346. /**
  55347. * Set the value of an uniform to an array of number
  55348. * @param uniform defines the webGL uniform location where to store the value
  55349. * @param array defines the array of number to store
  55350. * @returns true if value was set
  55351. */
  55352. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  55353. /**
  55354. * Set the value of an uniform to an array of number (stored as vec2)
  55355. * @param uniform defines the webGL uniform location where to store the value
  55356. * @param array defines the array of number to store
  55357. * @returns true if value was set
  55358. */
  55359. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  55360. /**
  55361. * Set the value of an uniform to an array of number (stored as vec3)
  55362. * @param uniform defines the webGL uniform location where to store the value
  55363. * @param array defines the array of number to store
  55364. * @returns true if value was set
  55365. */
  55366. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  55367. /**
  55368. * Set the value of an uniform to an array of number (stored as vec4)
  55369. * @param uniform defines the webGL uniform location where to store the value
  55370. * @param array defines the array of number to store
  55371. * @returns true if value was set
  55372. */
  55373. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  55374. /**
  55375. * Set the value of an uniform to an array of float32 (stored as matrices)
  55376. * @param uniform defines the webGL uniform location where to store the value
  55377. * @param matrices defines the array of float32 to store
  55378. * @returns true if value was set
  55379. */
  55380. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  55381. /**
  55382. * Set the value of an uniform to a matrix (3x3)
  55383. * @param uniform defines the webGL uniform location where to store the value
  55384. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  55385. * @returns true if value was set
  55386. */
  55387. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55388. /**
  55389. * Set the value of an uniform to a matrix (2x2)
  55390. * @param uniform defines the webGL uniform location where to store the value
  55391. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  55392. * @returns true if value was set
  55393. */
  55394. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55395. /**
  55396. * Set the value of an uniform to a number (float)
  55397. * @param uniform defines the webGL uniform location where to store the value
  55398. * @param value defines the float number to store
  55399. * @returns true if value was set
  55400. */
  55401. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  55402. /**
  55403. * Set the value of an uniform to a vec2
  55404. * @param uniform defines the webGL uniform location where to store the value
  55405. * @param x defines the 1st component of the value
  55406. * @param y defines the 2nd component of the value
  55407. * @returns true if value was set
  55408. */
  55409. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  55410. /**
  55411. * Set the value of an uniform to a vec3
  55412. * @param uniform defines the webGL uniform location where to store the value
  55413. * @param x defines the 1st component of the value
  55414. * @param y defines the 2nd component of the value
  55415. * @param z defines the 3rd component of the value
  55416. * @returns true if value was set
  55417. */
  55418. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  55419. /**
  55420. * Set the value of an uniform to a boolean
  55421. * @param uniform defines the webGL uniform location where to store the value
  55422. * @param bool defines the boolean to store
  55423. * @returns true if value was set
  55424. */
  55425. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  55426. /**
  55427. * Set the value of an uniform to a vec4
  55428. * @param uniform defines the webGL uniform location where to store the value
  55429. * @param x defines the 1st component of the value
  55430. * @param y defines the 2nd component of the value
  55431. * @param z defines the 3rd component of the value
  55432. * @param w defines the 4th component of the value
  55433. * @returns true if value was set
  55434. */
  55435. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  55436. /**
  55437. * Sets the current alpha mode
  55438. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  55439. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  55440. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55441. */
  55442. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  55443. /**
  55444. * Bind webGl buffers directly to the webGL context
  55445. * @param vertexBuffers defines the vertex buffer to bind
  55446. * @param indexBuffer defines the index buffer to bind
  55447. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  55448. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  55449. * @param effect defines the effect associated with the vertex buffer
  55450. */
  55451. bindBuffers(vertexBuffers: {
  55452. [key: string]: VertexBuffer;
  55453. }, indexBuffer: DataBuffer, effect: Effect): void;
  55454. /**
  55455. * Force the entire cache to be cleared
  55456. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  55457. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  55458. */
  55459. wipeCaches(bruteForce?: boolean): void;
  55460. /**
  55461. * Send a draw order
  55462. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  55463. * @param indexStart defines the starting index
  55464. * @param indexCount defines the number of index to draw
  55465. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55466. */
  55467. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  55468. /**
  55469. * Draw a list of indexed primitives
  55470. * @param fillMode defines the primitive to use
  55471. * @param indexStart defines the starting index
  55472. * @param indexCount defines the number of index to draw
  55473. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55474. */
  55475. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  55476. /**
  55477. * Draw a list of unindexed primitives
  55478. * @param fillMode defines the primitive to use
  55479. * @param verticesStart defines the index of first vertex to draw
  55480. * @param verticesCount defines the count of vertices to draw
  55481. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55482. */
  55483. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  55484. /** @hidden */
  55485. _createTexture(): WebGLTexture;
  55486. /** @hidden */
  55487. _releaseTexture(texture: InternalTexture): void;
  55488. /**
  55489. * Usually called from Texture.ts.
  55490. * Passed information to create a WebGLTexture
  55491. * @param urlArg defines a value which contains one of the following:
  55492. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  55493. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  55494. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  55495. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  55496. * @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)
  55497. * @param scene needed for loading to the correct scene
  55498. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  55499. * @param onLoad optional callback to be called upon successful completion
  55500. * @param onError optional callback to be called upon failure
  55501. * @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
  55502. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  55503. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  55504. * @param forcedExtension defines the extension to use to pick the right loader
  55505. * @param mimeType defines an optional mime type
  55506. * @returns a InternalTexture for assignment back into BABYLON.Texture
  55507. */
  55508. 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;
  55509. /**
  55510. * Creates a new render target texture
  55511. * @param size defines the size of the texture
  55512. * @param options defines the options used to create the texture
  55513. * @returns a new render target texture stored in an InternalTexture
  55514. */
  55515. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  55516. /**
  55517. * Update the sampling mode of a given texture
  55518. * @param samplingMode defines the required sampling mode
  55519. * @param texture defines the texture to update
  55520. */
  55521. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  55522. /**
  55523. * Binds the frame buffer to the specified texture.
  55524. * @param texture The texture to render to or null for the default canvas
  55525. * @param faceIndex The face of the texture to render to in case of cube texture
  55526. * @param requiredWidth The width of the target to render to
  55527. * @param requiredHeight The height of the target to render to
  55528. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  55529. * @param lodLevel defines le lod level to bind to the frame buffer
  55530. */
  55531. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  55532. /**
  55533. * Unbind the current render target texture from the webGL context
  55534. * @param texture defines the render target texture to unbind
  55535. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  55536. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  55537. */
  55538. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  55539. /**
  55540. * Creates a dynamic vertex buffer
  55541. * @param vertices the data for the dynamic vertex buffer
  55542. * @returns the new WebGL dynamic buffer
  55543. */
  55544. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  55545. /**
  55546. * Update the content of a dynamic texture
  55547. * @param texture defines the texture to update
  55548. * @param canvas defines the canvas containing the source
  55549. * @param invertY defines if data must be stored with Y axis inverted
  55550. * @param premulAlpha defines if alpha is stored as premultiplied
  55551. * @param format defines the format of the data
  55552. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  55553. */
  55554. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  55555. /**
  55556. * Gets a boolean indicating if all created effects are ready
  55557. * @returns true if all effects are ready
  55558. */
  55559. areAllEffectsReady(): boolean;
  55560. /**
  55561. * @hidden
  55562. * Get the current error code of the webGL context
  55563. * @returns the error code
  55564. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  55565. */
  55566. getError(): number;
  55567. /** @hidden */
  55568. _getUnpackAlignement(): number;
  55569. /** @hidden */
  55570. _unpackFlipY(value: boolean): void;
  55571. /**
  55572. * Update a dynamic index buffer
  55573. * @param indexBuffer defines the target index buffer
  55574. * @param indices defines the data to update
  55575. * @param offset defines the offset in the target index buffer where update should start
  55576. */
  55577. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  55578. /**
  55579. * Updates a dynamic vertex buffer.
  55580. * @param vertexBuffer the vertex buffer to update
  55581. * @param vertices the data used to update the vertex buffer
  55582. * @param byteOffset the byte offset of the data (optional)
  55583. * @param byteLength the byte length of the data (optional)
  55584. */
  55585. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  55586. /** @hidden */
  55587. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  55588. /** @hidden */
  55589. _bindTexture(channel: number, texture: InternalTexture): void;
  55590. protected _deleteBuffer(buffer: WebGLBuffer): void;
  55591. /**
  55592. * 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
  55593. */
  55594. releaseEffects(): void;
  55595. displayLoadingUI(): void;
  55596. hideLoadingUI(): void;
  55597. /** @hidden */
  55598. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55599. /** @hidden */
  55600. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55601. /** @hidden */
  55602. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55603. /** @hidden */
  55604. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  55605. }
  55606. }
  55607. declare module BABYLON {
  55608. /**
  55609. * @hidden
  55610. **/
  55611. export class _TimeToken {
  55612. _startTimeQuery: Nullable<WebGLQuery>;
  55613. _endTimeQuery: Nullable<WebGLQuery>;
  55614. _timeElapsedQuery: Nullable<WebGLQuery>;
  55615. _timeElapsedQueryEnded: boolean;
  55616. }
  55617. }
  55618. declare module BABYLON {
  55619. /** @hidden */
  55620. export class _OcclusionDataStorage {
  55621. /** @hidden */
  55622. occlusionInternalRetryCounter: number;
  55623. /** @hidden */
  55624. isOcclusionQueryInProgress: boolean;
  55625. /** @hidden */
  55626. isOccluded: boolean;
  55627. /** @hidden */
  55628. occlusionRetryCount: number;
  55629. /** @hidden */
  55630. occlusionType: number;
  55631. /** @hidden */
  55632. occlusionQueryAlgorithmType: number;
  55633. }
  55634. interface Engine {
  55635. /**
  55636. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  55637. * @return the new query
  55638. */
  55639. createQuery(): WebGLQuery;
  55640. /**
  55641. * Delete and release a webGL query
  55642. * @param query defines the query to delete
  55643. * @return the current engine
  55644. */
  55645. deleteQuery(query: WebGLQuery): Engine;
  55646. /**
  55647. * Check if a given query has resolved and got its value
  55648. * @param query defines the query to check
  55649. * @returns true if the query got its value
  55650. */
  55651. isQueryResultAvailable(query: WebGLQuery): boolean;
  55652. /**
  55653. * Gets the value of a given query
  55654. * @param query defines the query to check
  55655. * @returns the value of the query
  55656. */
  55657. getQueryResult(query: WebGLQuery): number;
  55658. /**
  55659. * Initiates an occlusion query
  55660. * @param algorithmType defines the algorithm to use
  55661. * @param query defines the query to use
  55662. * @returns the current engine
  55663. * @see https://doc.babylonjs.com/features/occlusionquery
  55664. */
  55665. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  55666. /**
  55667. * Ends an occlusion query
  55668. * @see https://doc.babylonjs.com/features/occlusionquery
  55669. * @param algorithmType defines the algorithm to use
  55670. * @returns the current engine
  55671. */
  55672. endOcclusionQuery(algorithmType: number): Engine;
  55673. /**
  55674. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  55675. * Please note that only one query can be issued at a time
  55676. * @returns a time token used to track the time span
  55677. */
  55678. startTimeQuery(): Nullable<_TimeToken>;
  55679. /**
  55680. * Ends a time query
  55681. * @param token defines the token used to measure the time span
  55682. * @returns the time spent (in ns)
  55683. */
  55684. endTimeQuery(token: _TimeToken): int;
  55685. /** @hidden */
  55686. _currentNonTimestampToken: Nullable<_TimeToken>;
  55687. /** @hidden */
  55688. _createTimeQuery(): WebGLQuery;
  55689. /** @hidden */
  55690. _deleteTimeQuery(query: WebGLQuery): void;
  55691. /** @hidden */
  55692. _getGlAlgorithmType(algorithmType: number): number;
  55693. /** @hidden */
  55694. _getTimeQueryResult(query: WebGLQuery): any;
  55695. /** @hidden */
  55696. _getTimeQueryAvailability(query: WebGLQuery): any;
  55697. }
  55698. interface AbstractMesh {
  55699. /**
  55700. * Backing filed
  55701. * @hidden
  55702. */
  55703. __occlusionDataStorage: _OcclusionDataStorage;
  55704. /**
  55705. * Access property
  55706. * @hidden
  55707. */
  55708. _occlusionDataStorage: _OcclusionDataStorage;
  55709. /**
  55710. * 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.
  55711. * The default value is -1 which means don't break the query and wait till the result
  55712. * @see https://doc.babylonjs.com/features/occlusionquery
  55713. */
  55714. occlusionRetryCount: number;
  55715. /**
  55716. * 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:
  55717. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  55718. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  55719. * * 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.
  55720. * @see https://doc.babylonjs.com/features/occlusionquery
  55721. */
  55722. occlusionType: number;
  55723. /**
  55724. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  55725. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  55726. * * 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.
  55727. * @see https://doc.babylonjs.com/features/occlusionquery
  55728. */
  55729. occlusionQueryAlgorithmType: number;
  55730. /**
  55731. * 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
  55732. * @see https://doc.babylonjs.com/features/occlusionquery
  55733. */
  55734. isOccluded: boolean;
  55735. /**
  55736. * Flag to check the progress status of the query
  55737. * @see https://doc.babylonjs.com/features/occlusionquery
  55738. */
  55739. isOcclusionQueryInProgress: boolean;
  55740. }
  55741. }
  55742. declare module BABYLON {
  55743. /** @hidden */
  55744. export var _forceTransformFeedbackToBundle: boolean;
  55745. interface Engine {
  55746. /**
  55747. * Creates a webGL transform feedback object
  55748. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  55749. * @returns the webGL transform feedback object
  55750. */
  55751. createTransformFeedback(): WebGLTransformFeedback;
  55752. /**
  55753. * Delete a webGL transform feedback object
  55754. * @param value defines the webGL transform feedback object to delete
  55755. */
  55756. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  55757. /**
  55758. * Bind a webGL transform feedback object to the webgl context
  55759. * @param value defines the webGL transform feedback object to bind
  55760. */
  55761. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  55762. /**
  55763. * Begins a transform feedback operation
  55764. * @param usePoints defines if points or triangles must be used
  55765. */
  55766. beginTransformFeedback(usePoints: boolean): void;
  55767. /**
  55768. * Ends a transform feedback operation
  55769. */
  55770. endTransformFeedback(): void;
  55771. /**
  55772. * Specify the varyings to use with transform feedback
  55773. * @param program defines the associated webGL program
  55774. * @param value defines the list of strings representing the varying names
  55775. */
  55776. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  55777. /**
  55778. * Bind a webGL buffer for a transform feedback operation
  55779. * @param value defines the webGL buffer to bind
  55780. */
  55781. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  55782. }
  55783. }
  55784. declare module BABYLON {
  55785. /**
  55786. * Class used to define an additional view for the engine
  55787. * @see https://doc.babylonjs.com/how_to/multi_canvases
  55788. */
  55789. export class EngineView {
  55790. /** Defines the canvas where to render the view */
  55791. target: HTMLCanvasElement;
  55792. /** Defines an optional camera used to render the view (will use active camera else) */
  55793. camera?: Camera;
  55794. }
  55795. interface Engine {
  55796. /**
  55797. * Gets or sets the HTML element to use for attaching events
  55798. */
  55799. inputElement: Nullable<HTMLElement>;
  55800. /**
  55801. * Gets the current engine view
  55802. * @see https://doc.babylonjs.com/how_to/multi_canvases
  55803. */
  55804. activeView: Nullable<EngineView>;
  55805. /** Gets or sets the list of views */
  55806. views: EngineView[];
  55807. /**
  55808. * Register a new child canvas
  55809. * @param canvas defines the canvas to register
  55810. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  55811. * @returns the associated view
  55812. */
  55813. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  55814. /**
  55815. * Remove a registered child canvas
  55816. * @param canvas defines the canvas to remove
  55817. * @returns the current engine
  55818. */
  55819. unRegisterView(canvas: HTMLCanvasElement): Engine;
  55820. }
  55821. }
  55822. declare module BABYLON {
  55823. interface Engine {
  55824. /** @hidden */
  55825. _excludedCompressedTextures: string[];
  55826. /** @hidden */
  55827. _textureFormatInUse: string;
  55828. /**
  55829. * Gets the list of texture formats supported
  55830. */
  55831. readonly texturesSupported: Array<string>;
  55832. /**
  55833. * Gets the texture format in use
  55834. */
  55835. readonly textureFormatInUse: Nullable<string>;
  55836. /**
  55837. * Set the compressed texture extensions or file names to skip.
  55838. *
  55839. * @param skippedFiles defines the list of those texture files you want to skip
  55840. * Example: [".dds", ".env", "myfile.png"]
  55841. */
  55842. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  55843. /**
  55844. * Set the compressed texture format to use, based on the formats you have, and the formats
  55845. * supported by the hardware / browser.
  55846. *
  55847. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  55848. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  55849. * to API arguments needed to compressed textures. This puts the burden on the container
  55850. * generator to house the arcane code for determining these for current & future formats.
  55851. *
  55852. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  55853. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  55854. *
  55855. * Note: The result of this call is not taken into account when a texture is base64.
  55856. *
  55857. * @param formatsAvailable defines the list of those format families you have created
  55858. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  55859. *
  55860. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  55861. * @returns The extension selected.
  55862. */
  55863. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  55864. }
  55865. }
  55866. declare module BABYLON {
  55867. /** @hidden */
  55868. export var rgbdEncodePixelShader: {
  55869. name: string;
  55870. shader: string;
  55871. };
  55872. }
  55873. declare module BABYLON {
  55874. /**
  55875. * Raw texture data and descriptor sufficient for WebGL texture upload
  55876. */
  55877. export interface EnvironmentTextureInfo {
  55878. /**
  55879. * Version of the environment map
  55880. */
  55881. version: number;
  55882. /**
  55883. * Width of image
  55884. */
  55885. width: number;
  55886. /**
  55887. * Irradiance information stored in the file.
  55888. */
  55889. irradiance: any;
  55890. /**
  55891. * Specular information stored in the file.
  55892. */
  55893. specular: any;
  55894. }
  55895. /**
  55896. * Defines One Image in the file. It requires only the position in the file
  55897. * as well as the length.
  55898. */
  55899. interface BufferImageData {
  55900. /**
  55901. * Length of the image data.
  55902. */
  55903. length: number;
  55904. /**
  55905. * Position of the data from the null terminator delimiting the end of the JSON.
  55906. */
  55907. position: number;
  55908. }
  55909. /**
  55910. * Defines the specular data enclosed in the file.
  55911. * This corresponds to the version 1 of the data.
  55912. */
  55913. export interface EnvironmentTextureSpecularInfoV1 {
  55914. /**
  55915. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  55916. */
  55917. specularDataPosition?: number;
  55918. /**
  55919. * This contains all the images data needed to reconstruct the cubemap.
  55920. */
  55921. mipmaps: Array<BufferImageData>;
  55922. /**
  55923. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  55924. */
  55925. lodGenerationScale: number;
  55926. }
  55927. /**
  55928. * Sets of helpers addressing the serialization and deserialization of environment texture
  55929. * stored in a BabylonJS env file.
  55930. * Those files are usually stored as .env files.
  55931. */
  55932. export class EnvironmentTextureTools {
  55933. /**
  55934. * Magic number identifying the env file.
  55935. */
  55936. private static _MagicBytes;
  55937. /**
  55938. * Gets the environment info from an env file.
  55939. * @param data The array buffer containing the .env bytes.
  55940. * @returns the environment file info (the json header) if successfully parsed.
  55941. */
  55942. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  55943. /**
  55944. * Creates an environment texture from a loaded cube texture.
  55945. * @param texture defines the cube texture to convert in env file
  55946. * @return a promise containing the environment data if succesfull.
  55947. */
  55948. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  55949. /**
  55950. * Creates a JSON representation of the spherical data.
  55951. * @param texture defines the texture containing the polynomials
  55952. * @return the JSON representation of the spherical info
  55953. */
  55954. private static _CreateEnvTextureIrradiance;
  55955. /**
  55956. * Creates the ArrayBufferViews used for initializing environment texture image data.
  55957. * @param data the image data
  55958. * @param info parameters that determine what views will be created for accessing the underlying buffer
  55959. * @return the views described by info providing access to the underlying buffer
  55960. */
  55961. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  55962. /**
  55963. * Uploads the texture info contained in the env file to the GPU.
  55964. * @param texture defines the internal texture to upload to
  55965. * @param data defines the data to load
  55966. * @param info defines the texture info retrieved through the GetEnvInfo method
  55967. * @returns a promise
  55968. */
  55969. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  55970. private static _OnImageReadyAsync;
  55971. /**
  55972. * Uploads the levels of image data to the GPU.
  55973. * @param texture defines the internal texture to upload to
  55974. * @param imageData defines the array buffer views of image data [mipmap][face]
  55975. * @returns a promise
  55976. */
  55977. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  55978. /**
  55979. * Uploads spherical polynomials information to the texture.
  55980. * @param texture defines the texture we are trying to upload the information to
  55981. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  55982. */
  55983. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  55984. /** @hidden */
  55985. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  55986. }
  55987. }
  55988. declare module BABYLON {
  55989. /**
  55990. * Class used to inline functions in shader code
  55991. */
  55992. export class ShaderCodeInliner {
  55993. private static readonly _RegexpFindFunctionNameAndType;
  55994. private _sourceCode;
  55995. private _functionDescr;
  55996. private _numMaxIterations;
  55997. /** Gets or sets the token used to mark the functions to inline */
  55998. inlineToken: string;
  55999. /** Gets or sets the debug mode */
  56000. debug: boolean;
  56001. /** Gets the code after the inlining process */
  56002. get code(): string;
  56003. /**
  56004. * Initializes the inliner
  56005. * @param sourceCode shader code source to inline
  56006. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  56007. */
  56008. constructor(sourceCode: string, numMaxIterations?: number);
  56009. /**
  56010. * Start the processing of the shader code
  56011. */
  56012. processCode(): void;
  56013. private _collectFunctions;
  56014. private _processInlining;
  56015. private _extractBetweenMarkers;
  56016. private _skipWhitespaces;
  56017. private _removeComments;
  56018. private _replaceFunctionCallsByCode;
  56019. private _findBackward;
  56020. private _escapeRegExp;
  56021. private _replaceNames;
  56022. }
  56023. }
  56024. declare module BABYLON {
  56025. /**
  56026. * Container for accessors for natively-stored mesh data buffers.
  56027. */
  56028. class NativeDataBuffer extends DataBuffer {
  56029. /**
  56030. * Accessor value used to identify/retrieve a natively-stored index buffer.
  56031. */
  56032. nativeIndexBuffer?: any;
  56033. /**
  56034. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  56035. */
  56036. nativeVertexBuffer?: any;
  56037. }
  56038. /** @hidden */
  56039. class NativeTexture extends InternalTexture {
  56040. getInternalTexture(): InternalTexture;
  56041. getViewCount(): number;
  56042. }
  56043. /** @hidden */
  56044. export class NativeEngine extends Engine {
  56045. private readonly _native;
  56046. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  56047. private readonly INVALID_HANDLE;
  56048. private _boundBuffersVertexArray;
  56049. private _currentDepthTest;
  56050. getHardwareScalingLevel(): number;
  56051. constructor();
  56052. dispose(): void;
  56053. /**
  56054. * Can be used to override the current requestAnimationFrame requester.
  56055. * @hidden
  56056. */
  56057. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  56058. /**
  56059. * Override default engine behavior.
  56060. * @param color
  56061. * @param backBuffer
  56062. * @param depth
  56063. * @param stencil
  56064. */
  56065. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  56066. /**
  56067. * Gets host document
  56068. * @returns the host document object
  56069. */
  56070. getHostDocument(): Nullable<Document>;
  56071. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  56072. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  56073. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  56074. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  56075. [key: string]: VertexBuffer;
  56076. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  56077. bindBuffers(vertexBuffers: {
  56078. [key: string]: VertexBuffer;
  56079. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  56080. recordVertexArrayObject(vertexBuffers: {
  56081. [key: string]: VertexBuffer;
  56082. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  56083. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  56084. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  56085. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  56086. /**
  56087. * Draw a list of indexed primitives
  56088. * @param fillMode defines the primitive to use
  56089. * @param indexStart defines the starting index
  56090. * @param indexCount defines the number of index to draw
  56091. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56092. */
  56093. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  56094. /**
  56095. * Draw a list of unindexed primitives
  56096. * @param fillMode defines the primitive to use
  56097. * @param verticesStart defines the index of first vertex to draw
  56098. * @param verticesCount defines the count of vertices to draw
  56099. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56100. */
  56101. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  56102. createPipelineContext(): IPipelineContext;
  56103. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  56104. /** @hidden */
  56105. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  56106. /** @hidden */
  56107. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  56108. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  56109. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  56110. protected _setProgram(program: WebGLProgram): void;
  56111. _releaseEffect(effect: Effect): void;
  56112. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  56113. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  56114. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  56115. bindSamplers(effect: Effect): void;
  56116. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  56117. getRenderWidth(useScreen?: boolean): number;
  56118. getRenderHeight(useScreen?: boolean): number;
  56119. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  56120. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  56121. /**
  56122. * Set the z offset to apply to current rendering
  56123. * @param value defines the offset to apply
  56124. */
  56125. setZOffset(value: number): void;
  56126. /**
  56127. * Gets the current value of the zOffset
  56128. * @returns the current zOffset state
  56129. */
  56130. getZOffset(): number;
  56131. /**
  56132. * Enable or disable depth buffering
  56133. * @param enable defines the state to set
  56134. */
  56135. setDepthBuffer(enable: boolean): void;
  56136. /**
  56137. * Gets a boolean indicating if depth writing is enabled
  56138. * @returns the current depth writing state
  56139. */
  56140. getDepthWrite(): boolean;
  56141. setDepthFunctionToGreater(): void;
  56142. setDepthFunctionToGreaterOrEqual(): void;
  56143. setDepthFunctionToLess(): void;
  56144. setDepthFunctionToLessOrEqual(): void;
  56145. /**
  56146. * Enable or disable depth writing
  56147. * @param enable defines the state to set
  56148. */
  56149. setDepthWrite(enable: boolean): void;
  56150. /**
  56151. * Enable or disable color writing
  56152. * @param enable defines the state to set
  56153. */
  56154. setColorWrite(enable: boolean): void;
  56155. /**
  56156. * Gets a boolean indicating if color writing is enabled
  56157. * @returns the current color writing state
  56158. */
  56159. getColorWrite(): boolean;
  56160. /**
  56161. * Sets alpha constants used by some alpha blending modes
  56162. * @param r defines the red component
  56163. * @param g defines the green component
  56164. * @param b defines the blue component
  56165. * @param a defines the alpha component
  56166. */
  56167. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  56168. /**
  56169. * Sets the current alpha mode
  56170. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  56171. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  56172. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  56173. */
  56174. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  56175. /**
  56176. * Gets the current alpha mode
  56177. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  56178. * @returns the current alpha mode
  56179. */
  56180. getAlphaMode(): number;
  56181. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  56182. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56183. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56184. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56185. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56186. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56187. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56188. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56189. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56190. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  56191. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  56192. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  56193. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  56194. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  56195. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  56196. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  56197. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  56198. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  56199. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  56200. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  56201. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  56202. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  56203. wipeCaches(bruteForce?: boolean): void;
  56204. _createTexture(): WebGLTexture;
  56205. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  56206. /**
  56207. * Update the content of a dynamic texture
  56208. * @param texture defines the texture to update
  56209. * @param canvas defines the canvas containing the source
  56210. * @param invertY defines if data must be stored with Y axis inverted
  56211. * @param premulAlpha defines if alpha is stored as premultiplied
  56212. * @param format defines the format of the data
  56213. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  56214. */
  56215. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  56216. /**
  56217. * Usually called from Texture.ts.
  56218. * Passed information to create a WebGLTexture
  56219. * @param url defines a value which contains one of the following:
  56220. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  56221. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  56222. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  56223. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  56224. * @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)
  56225. * @param scene needed for loading to the correct scene
  56226. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  56227. * @param onLoad optional callback to be called upon successful completion
  56228. * @param onError optional callback to be called upon failure
  56229. * @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
  56230. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  56231. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  56232. * @param forcedExtension defines the extension to use to pick the right loader
  56233. * @param mimeType defines an optional mime type
  56234. * @param loaderOptions options to be passed to the loader
  56235. * @returns a InternalTexture for assignment back into BABYLON.Texture
  56236. */
  56237. 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;
  56238. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  56239. _releaseFramebufferObjects(texture: InternalTexture): void;
  56240. /**
  56241. * Creates a cube texture
  56242. * @param rootUrl defines the url where the files to load is located
  56243. * @param scene defines the current scene
  56244. * @param files defines the list of files to load (1 per face)
  56245. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  56246. * @param onLoad defines an optional callback raised when the texture is loaded
  56247. * @param onError defines an optional callback raised if there is an issue to load the texture
  56248. * @param format defines the format of the data
  56249. * @param forcedExtension defines the extension to use to pick the right loader
  56250. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  56251. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56252. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56253. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  56254. * @returns the cube texture as an InternalTexture
  56255. */
  56256. 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;
  56257. createRenderTargetTexture(size: number | {
  56258. width: number;
  56259. height: number;
  56260. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  56261. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  56262. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  56263. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  56264. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  56265. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  56266. /**
  56267. * Updates a dynamic vertex buffer.
  56268. * @param vertexBuffer the vertex buffer to update
  56269. * @param data the data used to update the vertex buffer
  56270. * @param byteOffset the byte offset of the data (optional)
  56271. * @param byteLength the byte length of the data (optional)
  56272. */
  56273. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  56274. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  56275. private _updateAnisotropicLevel;
  56276. private _getAddressMode;
  56277. /** @hidden */
  56278. _bindTexture(channel: number, texture: InternalTexture): void;
  56279. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  56280. releaseEffects(): void;
  56281. /** @hidden */
  56282. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56283. /** @hidden */
  56284. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56285. /** @hidden */
  56286. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56287. /** @hidden */
  56288. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  56289. private _getNativeSamplingMode;
  56290. private _getNativeTextureFormat;
  56291. private _getNativeAlphaMode;
  56292. private _getNativeAttribType;
  56293. }
  56294. }
  56295. declare module BABYLON {
  56296. /**
  56297. * Gather the list of clipboard event types as constants.
  56298. */
  56299. export class ClipboardEventTypes {
  56300. /**
  56301. * The clipboard event is fired when a copy command is active (pressed).
  56302. */
  56303. static readonly COPY: number;
  56304. /**
  56305. * The clipboard event is fired when a cut command is active (pressed).
  56306. */
  56307. static readonly CUT: number;
  56308. /**
  56309. * The clipboard event is fired when a paste command is active (pressed).
  56310. */
  56311. static readonly PASTE: number;
  56312. }
  56313. /**
  56314. * This class is used to store clipboard related info for the onClipboardObservable event.
  56315. */
  56316. export class ClipboardInfo {
  56317. /**
  56318. * Defines the type of event (BABYLON.ClipboardEventTypes)
  56319. */
  56320. type: number;
  56321. /**
  56322. * Defines the related dom event
  56323. */
  56324. event: ClipboardEvent;
  56325. /**
  56326. *Creates an instance of ClipboardInfo.
  56327. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  56328. * @param event Defines the related dom event
  56329. */
  56330. constructor(
  56331. /**
  56332. * Defines the type of event (BABYLON.ClipboardEventTypes)
  56333. */
  56334. type: number,
  56335. /**
  56336. * Defines the related dom event
  56337. */
  56338. event: ClipboardEvent);
  56339. /**
  56340. * Get the clipboard event's type from the keycode.
  56341. * @param keyCode Defines the keyCode for the current keyboard event.
  56342. * @return {number}
  56343. */
  56344. static GetTypeFromCharacter(keyCode: number): number;
  56345. }
  56346. }
  56347. declare module BABYLON {
  56348. /**
  56349. * Google Daydream controller
  56350. */
  56351. export class DaydreamController extends WebVRController {
  56352. /**
  56353. * Base Url for the controller model.
  56354. */
  56355. static MODEL_BASE_URL: string;
  56356. /**
  56357. * File name for the controller model.
  56358. */
  56359. static MODEL_FILENAME: string;
  56360. /**
  56361. * Gamepad Id prefix used to identify Daydream Controller.
  56362. */
  56363. static readonly GAMEPAD_ID_PREFIX: string;
  56364. /**
  56365. * Creates a new DaydreamController from a gamepad
  56366. * @param vrGamepad the gamepad that the controller should be created from
  56367. */
  56368. constructor(vrGamepad: any);
  56369. /**
  56370. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56371. * @param scene scene in which to add meshes
  56372. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56373. */
  56374. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56375. /**
  56376. * Called once for each button that changed state since the last frame
  56377. * @param buttonIdx Which button index changed
  56378. * @param state New state of the button
  56379. * @param changes Which properties on the state changed since last frame
  56380. */
  56381. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56382. }
  56383. }
  56384. declare module BABYLON {
  56385. /**
  56386. * Gear VR Controller
  56387. */
  56388. export class GearVRController extends WebVRController {
  56389. /**
  56390. * Base Url for the controller model.
  56391. */
  56392. static MODEL_BASE_URL: string;
  56393. /**
  56394. * File name for the controller model.
  56395. */
  56396. static MODEL_FILENAME: string;
  56397. /**
  56398. * Gamepad Id prefix used to identify this controller.
  56399. */
  56400. static readonly GAMEPAD_ID_PREFIX: string;
  56401. private readonly _buttonIndexToObservableNameMap;
  56402. /**
  56403. * Creates a new GearVRController from a gamepad
  56404. * @param vrGamepad the gamepad that the controller should be created from
  56405. */
  56406. constructor(vrGamepad: any);
  56407. /**
  56408. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56409. * @param scene scene in which to add meshes
  56410. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56411. */
  56412. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56413. /**
  56414. * Called once for each button that changed state since the last frame
  56415. * @param buttonIdx Which button index changed
  56416. * @param state New state of the button
  56417. * @param changes Which properties on the state changed since last frame
  56418. */
  56419. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56420. }
  56421. }
  56422. declare module BABYLON {
  56423. /**
  56424. * Generic Controller
  56425. */
  56426. export class GenericController extends WebVRController {
  56427. /**
  56428. * Base Url for the controller model.
  56429. */
  56430. static readonly MODEL_BASE_URL: string;
  56431. /**
  56432. * File name for the controller model.
  56433. */
  56434. static readonly MODEL_FILENAME: string;
  56435. /**
  56436. * Creates a new GenericController from a gamepad
  56437. * @param vrGamepad the gamepad that the controller should be created from
  56438. */
  56439. constructor(vrGamepad: any);
  56440. /**
  56441. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56442. * @param scene scene in which to add meshes
  56443. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56444. */
  56445. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56446. /**
  56447. * Called once for each button that changed state since the last frame
  56448. * @param buttonIdx Which button index changed
  56449. * @param state New state of the button
  56450. * @param changes Which properties on the state changed since last frame
  56451. */
  56452. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56453. }
  56454. }
  56455. declare module BABYLON {
  56456. /**
  56457. * Oculus Touch Controller
  56458. */
  56459. export class OculusTouchController extends WebVRController {
  56460. /**
  56461. * Base Url for the controller model.
  56462. */
  56463. static MODEL_BASE_URL: string;
  56464. /**
  56465. * File name for the left controller model.
  56466. */
  56467. static MODEL_LEFT_FILENAME: string;
  56468. /**
  56469. * File name for the right controller model.
  56470. */
  56471. static MODEL_RIGHT_FILENAME: string;
  56472. /**
  56473. * Base Url for the Quest controller model.
  56474. */
  56475. static QUEST_MODEL_BASE_URL: string;
  56476. /**
  56477. * @hidden
  56478. * If the controllers are running on a device that needs the updated Quest controller models
  56479. */
  56480. static _IsQuest: boolean;
  56481. /**
  56482. * Fired when the secondary trigger on this controller is modified
  56483. */
  56484. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  56485. /**
  56486. * Fired when the thumb rest on this controller is modified
  56487. */
  56488. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  56489. /**
  56490. * Creates a new OculusTouchController from a gamepad
  56491. * @param vrGamepad the gamepad that the controller should be created from
  56492. */
  56493. constructor(vrGamepad: any);
  56494. /**
  56495. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56496. * @param scene scene in which to add meshes
  56497. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56498. */
  56499. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56500. /**
  56501. * Fired when the A button on this controller is modified
  56502. */
  56503. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56504. /**
  56505. * Fired when the B button on this controller is modified
  56506. */
  56507. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56508. /**
  56509. * Fired when the X button on this controller is modified
  56510. */
  56511. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56512. /**
  56513. * Fired when the Y button on this controller is modified
  56514. */
  56515. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56516. /**
  56517. * Called once for each button that changed state since the last frame
  56518. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  56519. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  56520. * 2) secondary trigger (same)
  56521. * 3) A (right) X (left), touch, pressed = value
  56522. * 4) B / Y
  56523. * 5) thumb rest
  56524. * @param buttonIdx Which button index changed
  56525. * @param state New state of the button
  56526. * @param changes Which properties on the state changed since last frame
  56527. */
  56528. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56529. }
  56530. }
  56531. declare module BABYLON {
  56532. /**
  56533. * Vive Controller
  56534. */
  56535. export class ViveController extends WebVRController {
  56536. /**
  56537. * Base Url for the controller model.
  56538. */
  56539. static MODEL_BASE_URL: string;
  56540. /**
  56541. * File name for the controller model.
  56542. */
  56543. static MODEL_FILENAME: string;
  56544. /**
  56545. * Creates a new ViveController from a gamepad
  56546. * @param vrGamepad the gamepad that the controller should be created from
  56547. */
  56548. constructor(vrGamepad: any);
  56549. /**
  56550. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56551. * @param scene scene in which to add meshes
  56552. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56553. */
  56554. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56555. /**
  56556. * Fired when the left button on this controller is modified
  56557. */
  56558. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56559. /**
  56560. * Fired when the right button on this controller is modified
  56561. */
  56562. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56563. /**
  56564. * Fired when the menu button on this controller is modified
  56565. */
  56566. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56567. /**
  56568. * Called once for each button that changed state since the last frame
  56569. * Vive mapping:
  56570. * 0: touchpad
  56571. * 1: trigger
  56572. * 2: left AND right buttons
  56573. * 3: menu button
  56574. * @param buttonIdx Which button index changed
  56575. * @param state New state of the button
  56576. * @param changes Which properties on the state changed since last frame
  56577. */
  56578. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56579. }
  56580. }
  56581. declare module BABYLON {
  56582. /**
  56583. * Defines the WindowsMotionController object that the state of the windows motion controller
  56584. */
  56585. export class WindowsMotionController extends WebVRController {
  56586. /**
  56587. * The base url used to load the left and right controller models
  56588. */
  56589. static MODEL_BASE_URL: string;
  56590. /**
  56591. * The name of the left controller model file
  56592. */
  56593. static MODEL_LEFT_FILENAME: string;
  56594. /**
  56595. * The name of the right controller model file
  56596. */
  56597. static MODEL_RIGHT_FILENAME: string;
  56598. /**
  56599. * The controller name prefix for this controller type
  56600. */
  56601. static readonly GAMEPAD_ID_PREFIX: string;
  56602. /**
  56603. * The controller id pattern for this controller type
  56604. */
  56605. private static readonly GAMEPAD_ID_PATTERN;
  56606. private _loadedMeshInfo;
  56607. protected readonly _mapping: {
  56608. buttons: string[];
  56609. buttonMeshNames: {
  56610. trigger: string;
  56611. menu: string;
  56612. grip: string;
  56613. thumbstick: string;
  56614. trackpad: string;
  56615. };
  56616. buttonObservableNames: {
  56617. trigger: string;
  56618. menu: string;
  56619. grip: string;
  56620. thumbstick: string;
  56621. trackpad: string;
  56622. };
  56623. axisMeshNames: string[];
  56624. pointingPoseMeshName: string;
  56625. };
  56626. /**
  56627. * Fired when the trackpad on this controller is clicked
  56628. */
  56629. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  56630. /**
  56631. * Fired when the trackpad on this controller is modified
  56632. */
  56633. onTrackpadValuesChangedObservable: Observable<StickValues>;
  56634. /**
  56635. * The current x and y values of this controller's trackpad
  56636. */
  56637. trackpad: StickValues;
  56638. /**
  56639. * Creates a new WindowsMotionController from a gamepad
  56640. * @param vrGamepad the gamepad that the controller should be created from
  56641. */
  56642. constructor(vrGamepad: any);
  56643. /**
  56644. * Fired when the trigger on this controller is modified
  56645. */
  56646. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56647. /**
  56648. * Fired when the menu button on this controller is modified
  56649. */
  56650. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56651. /**
  56652. * Fired when the grip button on this controller is modified
  56653. */
  56654. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56655. /**
  56656. * Fired when the thumbstick button on this controller is modified
  56657. */
  56658. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56659. /**
  56660. * Fired when the touchpad button on this controller is modified
  56661. */
  56662. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56663. /**
  56664. * Fired when the touchpad values on this controller are modified
  56665. */
  56666. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  56667. protected _updateTrackpad(): void;
  56668. /**
  56669. * Called once per frame by the engine.
  56670. */
  56671. update(): void;
  56672. /**
  56673. * Called once for each button that changed state since the last frame
  56674. * @param buttonIdx Which button index changed
  56675. * @param state New state of the button
  56676. * @param changes Which properties on the state changed since last frame
  56677. */
  56678. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56679. /**
  56680. * Moves the buttons on the controller mesh based on their current state
  56681. * @param buttonName the name of the button to move
  56682. * @param buttonValue the value of the button which determines the buttons new position
  56683. */
  56684. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  56685. /**
  56686. * Moves the axis on the controller mesh based on its current state
  56687. * @param axis the index of the axis
  56688. * @param axisValue the value of the axis which determines the meshes new position
  56689. * @hidden
  56690. */
  56691. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  56692. /**
  56693. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56694. * @param scene scene in which to add meshes
  56695. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56696. */
  56697. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  56698. /**
  56699. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  56700. * can be transformed by button presses and axes values, based on this._mapping.
  56701. *
  56702. * @param scene scene in which the meshes exist
  56703. * @param meshes list of meshes that make up the controller model to process
  56704. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  56705. */
  56706. private processModel;
  56707. private createMeshInfo;
  56708. /**
  56709. * Gets the ray of the controller in the direction the controller is pointing
  56710. * @param length the length the resulting ray should be
  56711. * @returns a ray in the direction the controller is pointing
  56712. */
  56713. getForwardRay(length?: number): Ray;
  56714. /**
  56715. * Disposes of the controller
  56716. */
  56717. dispose(): void;
  56718. }
  56719. /**
  56720. * This class represents a new windows motion controller in XR.
  56721. */
  56722. export class XRWindowsMotionController extends WindowsMotionController {
  56723. /**
  56724. * Changing the original WIndowsMotionController mapping to fir the new mapping
  56725. */
  56726. protected readonly _mapping: {
  56727. buttons: string[];
  56728. buttonMeshNames: {
  56729. trigger: string;
  56730. menu: string;
  56731. grip: string;
  56732. thumbstick: string;
  56733. trackpad: string;
  56734. };
  56735. buttonObservableNames: {
  56736. trigger: string;
  56737. menu: string;
  56738. grip: string;
  56739. thumbstick: string;
  56740. trackpad: string;
  56741. };
  56742. axisMeshNames: string[];
  56743. pointingPoseMeshName: string;
  56744. };
  56745. /**
  56746. * Construct a new XR-Based windows motion controller
  56747. *
  56748. * @param gamepadInfo the gamepad object from the browser
  56749. */
  56750. constructor(gamepadInfo: any);
  56751. /**
  56752. * holds the thumbstick values (X,Y)
  56753. */
  56754. thumbstickValues: StickValues;
  56755. /**
  56756. * Fired when the thumbstick on this controller is clicked
  56757. */
  56758. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  56759. /**
  56760. * Fired when the thumbstick on this controller is modified
  56761. */
  56762. onThumbstickValuesChangedObservable: Observable<StickValues>;
  56763. /**
  56764. * Fired when the touchpad button on this controller is modified
  56765. */
  56766. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  56767. /**
  56768. * Fired when the touchpad values on this controller are modified
  56769. */
  56770. onTrackpadValuesChangedObservable: Observable<StickValues>;
  56771. /**
  56772. * Fired when the thumbstick button on this controller is modified
  56773. * here to prevent breaking changes
  56774. */
  56775. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56776. /**
  56777. * updating the thumbstick(!) and not the trackpad.
  56778. * This is named this way due to the difference between WebVR and XR and to avoid
  56779. * changing the parent class.
  56780. */
  56781. protected _updateTrackpad(): void;
  56782. /**
  56783. * Disposes the class with joy
  56784. */
  56785. dispose(): void;
  56786. }
  56787. }
  56788. declare module BABYLON {
  56789. /**
  56790. * Class containing static functions to help procedurally build meshes
  56791. */
  56792. export class PolyhedronBuilder {
  56793. /**
  56794. * Creates a polyhedron mesh
  56795. * * 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
  56796. * * The parameter `size` (positive float, default 1) sets the polygon size
  56797. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56798. * * 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`
  56799. * * 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
  56800. * * 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)`)
  56801. * * 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
  56802. * * 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
  56803. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56804. * * 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
  56805. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56806. * @param name defines the name of the mesh
  56807. * @param options defines the options used to create the mesh
  56808. * @param scene defines the hosting scene
  56809. * @returns the polyhedron mesh
  56810. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56811. */
  56812. static CreatePolyhedron(name: string, options: {
  56813. type?: number;
  56814. size?: number;
  56815. sizeX?: number;
  56816. sizeY?: number;
  56817. sizeZ?: number;
  56818. custom?: any;
  56819. faceUV?: Vector4[];
  56820. faceColors?: Color4[];
  56821. flat?: boolean;
  56822. updatable?: boolean;
  56823. sideOrientation?: number;
  56824. frontUVs?: Vector4;
  56825. backUVs?: Vector4;
  56826. }, scene?: Nullable<Scene>): Mesh;
  56827. }
  56828. }
  56829. declare module BABYLON {
  56830. /**
  56831. * Gizmo that enables scaling a mesh along 3 axis
  56832. */
  56833. export class ScaleGizmo extends Gizmo {
  56834. /**
  56835. * Internal gizmo used for interactions on the x axis
  56836. */
  56837. xGizmo: AxisScaleGizmo;
  56838. /**
  56839. * Internal gizmo used for interactions on the y axis
  56840. */
  56841. yGizmo: AxisScaleGizmo;
  56842. /**
  56843. * Internal gizmo used for interactions on the z axis
  56844. */
  56845. zGizmo: AxisScaleGizmo;
  56846. /**
  56847. * Internal gizmo used to scale all axis equally
  56848. */
  56849. uniformScaleGizmo: AxisScaleGizmo;
  56850. private _meshAttached;
  56851. private _nodeAttached;
  56852. private _snapDistance;
  56853. private _uniformScalingMesh;
  56854. private _octahedron;
  56855. private _sensitivity;
  56856. /** Fires an event when any of it's sub gizmos are dragged */
  56857. onDragStartObservable: Observable<unknown>;
  56858. /** Fires an event when any of it's sub gizmos are released from dragging */
  56859. onDragEndObservable: Observable<unknown>;
  56860. get attachedMesh(): Nullable<AbstractMesh>;
  56861. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56862. get attachedNode(): Nullable<Node>;
  56863. set attachedNode(node: Nullable<Node>);
  56864. /**
  56865. * True when the mouse pointer is hovering a gizmo mesh
  56866. */
  56867. get isHovered(): boolean;
  56868. /**
  56869. * Creates a ScaleGizmo
  56870. * @param gizmoLayer The utility layer the gizmo will be added to
  56871. * @param thickness display gizmo axis thickness
  56872. */
  56873. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  56874. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56875. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56876. /**
  56877. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56878. */
  56879. set snapDistance(value: number);
  56880. get snapDistance(): number;
  56881. /**
  56882. * Ratio for the scale of the gizmo (Default: 1)
  56883. */
  56884. set scaleRatio(value: number);
  56885. get scaleRatio(): number;
  56886. /**
  56887. * Sensitivity factor for dragging (Default: 1)
  56888. */
  56889. set sensitivity(value: number);
  56890. get sensitivity(): number;
  56891. /**
  56892. * Disposes of the gizmo
  56893. */
  56894. dispose(): void;
  56895. }
  56896. }
  56897. declare module BABYLON {
  56898. /**
  56899. * Single axis scale gizmo
  56900. */
  56901. export class AxisScaleGizmo extends Gizmo {
  56902. /**
  56903. * Drag behavior responsible for the gizmos dragging interactions
  56904. */
  56905. dragBehavior: PointerDragBehavior;
  56906. private _pointerObserver;
  56907. /**
  56908. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56909. */
  56910. snapDistance: number;
  56911. /**
  56912. * Event that fires each time the gizmo snaps to a new location.
  56913. * * snapDistance is the the change in distance
  56914. */
  56915. onSnapObservable: Observable<{
  56916. snapDistance: number;
  56917. }>;
  56918. /**
  56919. * If the scaling operation should be done on all axis (default: false)
  56920. */
  56921. uniformScaling: boolean;
  56922. /**
  56923. * Custom sensitivity value for the drag strength
  56924. */
  56925. sensitivity: number;
  56926. private _isEnabled;
  56927. private _parent;
  56928. private _arrow;
  56929. private _coloredMaterial;
  56930. private _hoverMaterial;
  56931. /**
  56932. * Creates an AxisScaleGizmo
  56933. * @param gizmoLayer The utility layer the gizmo will be added to
  56934. * @param dragAxis The axis which the gizmo will be able to scale on
  56935. * @param color The color of the gizmo
  56936. * @param thickness display gizmo axis thickness
  56937. */
  56938. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  56939. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56940. /**
  56941. * If the gizmo is enabled
  56942. */
  56943. set isEnabled(value: boolean);
  56944. get isEnabled(): boolean;
  56945. /**
  56946. * Disposes of the gizmo
  56947. */
  56948. dispose(): void;
  56949. /**
  56950. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  56951. * @param mesh The mesh to replace the default mesh of the gizmo
  56952. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  56953. */
  56954. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  56955. }
  56956. }
  56957. declare module BABYLON {
  56958. /**
  56959. * Bounding box gizmo
  56960. */
  56961. export class BoundingBoxGizmo extends Gizmo {
  56962. private _lineBoundingBox;
  56963. private _rotateSpheresParent;
  56964. private _scaleBoxesParent;
  56965. private _boundingDimensions;
  56966. private _renderObserver;
  56967. private _pointerObserver;
  56968. private _scaleDragSpeed;
  56969. private _tmpQuaternion;
  56970. private _tmpVector;
  56971. private _tmpRotationMatrix;
  56972. /**
  56973. * 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)
  56974. */
  56975. ignoreChildren: boolean;
  56976. /**
  56977. * 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)
  56978. */
  56979. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  56980. /**
  56981. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  56982. */
  56983. rotationSphereSize: number;
  56984. /**
  56985. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  56986. */
  56987. scaleBoxSize: number;
  56988. /**
  56989. * 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)
  56990. */
  56991. fixedDragMeshScreenSize: boolean;
  56992. /**
  56993. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  56994. */
  56995. fixedDragMeshScreenSizeDistanceFactor: number;
  56996. /**
  56997. * Fired when a rotation sphere or scale box is dragged
  56998. */
  56999. onDragStartObservable: Observable<{}>;
  57000. /**
  57001. * Fired when a scale box is dragged
  57002. */
  57003. onScaleBoxDragObservable: Observable<{}>;
  57004. /**
  57005. * Fired when a scale box drag is ended
  57006. */
  57007. onScaleBoxDragEndObservable: Observable<{}>;
  57008. /**
  57009. * Fired when a rotation sphere is dragged
  57010. */
  57011. onRotationSphereDragObservable: Observable<{}>;
  57012. /**
  57013. * Fired when a rotation sphere drag is ended
  57014. */
  57015. onRotationSphereDragEndObservable: Observable<{}>;
  57016. /**
  57017. * 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)
  57018. */
  57019. scalePivot: Nullable<Vector3>;
  57020. /**
  57021. * Mesh used as a pivot to rotate the attached node
  57022. */
  57023. private _anchorMesh;
  57024. private _existingMeshScale;
  57025. private _dragMesh;
  57026. private pointerDragBehavior;
  57027. private coloredMaterial;
  57028. private hoverColoredMaterial;
  57029. /**
  57030. * Sets the color of the bounding box gizmo
  57031. * @param color the color to set
  57032. */
  57033. setColor(color: Color3): void;
  57034. /**
  57035. * Creates an BoundingBoxGizmo
  57036. * @param gizmoLayer The utility layer the gizmo will be added to
  57037. * @param color The color of the gizmo
  57038. */
  57039. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  57040. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  57041. private _selectNode;
  57042. /**
  57043. * Updates the bounding box information for the Gizmo
  57044. */
  57045. updateBoundingBox(): void;
  57046. private _updateRotationSpheres;
  57047. private _updateScaleBoxes;
  57048. /**
  57049. * Enables rotation on the specified axis and disables rotation on the others
  57050. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  57051. */
  57052. setEnabledRotationAxis(axis: string): void;
  57053. /**
  57054. * Enables/disables scaling
  57055. * @param enable if scaling should be enabled
  57056. * @param homogeneousScaling defines if scaling should only be homogeneous
  57057. */
  57058. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  57059. private _updateDummy;
  57060. /**
  57061. * Enables a pointer drag behavior on the bounding box of the gizmo
  57062. */
  57063. enableDragBehavior(): void;
  57064. /**
  57065. * Disposes of the gizmo
  57066. */
  57067. dispose(): void;
  57068. /**
  57069. * 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)
  57070. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  57071. * @returns the bounding box mesh with the passed in mesh as a child
  57072. */
  57073. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  57074. /**
  57075. * CustomMeshes are not supported by this gizmo
  57076. * @param mesh The mesh to replace the default mesh of the gizmo
  57077. */
  57078. setCustomMesh(mesh: Mesh): void;
  57079. }
  57080. }
  57081. declare module BABYLON {
  57082. /**
  57083. * Single plane rotation gizmo
  57084. */
  57085. export class PlaneRotationGizmo extends Gizmo {
  57086. /**
  57087. * Drag behavior responsible for the gizmos dragging interactions
  57088. */
  57089. dragBehavior: PointerDragBehavior;
  57090. private _pointerObserver;
  57091. /**
  57092. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  57093. */
  57094. snapDistance: number;
  57095. /**
  57096. * Event that fires each time the gizmo snaps to a new location.
  57097. * * snapDistance is the the change in distance
  57098. */
  57099. onSnapObservable: Observable<{
  57100. snapDistance: number;
  57101. }>;
  57102. private _isEnabled;
  57103. private _parent;
  57104. /**
  57105. * Creates a PlaneRotationGizmo
  57106. * @param gizmoLayer The utility layer the gizmo will be added to
  57107. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  57108. * @param color The color of the gizmo
  57109. * @param tessellation Amount of tessellation to be used when creating rotation circles
  57110. * @param useEulerRotation Use and update Euler angle instead of quaternion
  57111. * @param thickness display gizmo axis thickness
  57112. */
  57113. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  57114. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57115. /**
  57116. * If the gizmo is enabled
  57117. */
  57118. set isEnabled(value: boolean);
  57119. get isEnabled(): boolean;
  57120. /**
  57121. * Disposes of the gizmo
  57122. */
  57123. dispose(): void;
  57124. }
  57125. }
  57126. declare module BABYLON {
  57127. /**
  57128. * Gizmo that enables rotating a mesh along 3 axis
  57129. */
  57130. export class RotationGizmo extends Gizmo {
  57131. /**
  57132. * Internal gizmo used for interactions on the x axis
  57133. */
  57134. xGizmo: PlaneRotationGizmo;
  57135. /**
  57136. * Internal gizmo used for interactions on the y axis
  57137. */
  57138. yGizmo: PlaneRotationGizmo;
  57139. /**
  57140. * Internal gizmo used for interactions on the z axis
  57141. */
  57142. zGizmo: PlaneRotationGizmo;
  57143. /** Fires an event when any of it's sub gizmos are dragged */
  57144. onDragStartObservable: Observable<unknown>;
  57145. /** Fires an event when any of it's sub gizmos are released from dragging */
  57146. onDragEndObservable: Observable<unknown>;
  57147. private _meshAttached;
  57148. private _nodeAttached;
  57149. get attachedMesh(): Nullable<AbstractMesh>;
  57150. set attachedMesh(mesh: Nullable<AbstractMesh>);
  57151. get attachedNode(): Nullable<Node>;
  57152. set attachedNode(node: Nullable<Node>);
  57153. protected _checkBillboardTransform(): void;
  57154. /**
  57155. * True when the mouse pointer is hovering a gizmo mesh
  57156. */
  57157. get isHovered(): boolean;
  57158. /**
  57159. * Creates a RotationGizmo
  57160. * @param gizmoLayer The utility layer the gizmo will be added to
  57161. * @param tessellation Amount of tessellation to be used when creating rotation circles
  57162. * @param useEulerRotation Use and update Euler angle instead of quaternion
  57163. * @param thickness display gizmo axis thickness
  57164. */
  57165. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  57166. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57167. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57168. /**
  57169. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57170. */
  57171. set snapDistance(value: number);
  57172. get snapDistance(): number;
  57173. /**
  57174. * Ratio for the scale of the gizmo (Default: 1)
  57175. */
  57176. set scaleRatio(value: number);
  57177. get scaleRatio(): number;
  57178. /**
  57179. * Disposes of the gizmo
  57180. */
  57181. dispose(): void;
  57182. /**
  57183. * CustomMeshes are not supported by this gizmo
  57184. * @param mesh The mesh to replace the default mesh of the gizmo
  57185. */
  57186. setCustomMesh(mesh: Mesh): void;
  57187. }
  57188. }
  57189. declare module BABYLON {
  57190. /**
  57191. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  57192. */
  57193. export class GizmoManager implements IDisposable {
  57194. private scene;
  57195. /**
  57196. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  57197. */
  57198. gizmos: {
  57199. positionGizmo: Nullable<PositionGizmo>;
  57200. rotationGizmo: Nullable<RotationGizmo>;
  57201. scaleGizmo: Nullable<ScaleGizmo>;
  57202. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  57203. };
  57204. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  57205. clearGizmoOnEmptyPointerEvent: boolean;
  57206. /** Fires an event when the manager is attached to a mesh */
  57207. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  57208. /** Fires an event when the manager is attached to a node */
  57209. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  57210. private _gizmosEnabled;
  57211. private _pointerObserver;
  57212. private _attachedMesh;
  57213. private _attachedNode;
  57214. private _boundingBoxColor;
  57215. private _defaultUtilityLayer;
  57216. private _defaultKeepDepthUtilityLayer;
  57217. private _thickness;
  57218. /**
  57219. * When bounding box gizmo is enabled, this can be used to track drag/end events
  57220. */
  57221. boundingBoxDragBehavior: SixDofDragBehavior;
  57222. /**
  57223. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  57224. */
  57225. attachableMeshes: Nullable<Array<AbstractMesh>>;
  57226. /**
  57227. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  57228. */
  57229. attachableNodes: Nullable<Array<Node>>;
  57230. /**
  57231. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  57232. */
  57233. usePointerToAttachGizmos: boolean;
  57234. /**
  57235. * Utility layer that the bounding box gizmo belongs to
  57236. */
  57237. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  57238. /**
  57239. * Utility layer that all gizmos besides bounding box belong to
  57240. */
  57241. get utilityLayer(): UtilityLayerRenderer;
  57242. /**
  57243. * True when the mouse pointer is hovering a gizmo mesh
  57244. */
  57245. get isHovered(): boolean;
  57246. /**
  57247. * Instatiates a gizmo manager
  57248. * @param scene the scene to overlay the gizmos on top of
  57249. * @param thickness display gizmo axis thickness
  57250. */
  57251. constructor(scene: Scene, thickness?: number);
  57252. /**
  57253. * Attaches a set of gizmos to the specified mesh
  57254. * @param mesh The mesh the gizmo's should be attached to
  57255. */
  57256. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  57257. /**
  57258. * Attaches a set of gizmos to the specified node
  57259. * @param node The node the gizmo's should be attached to
  57260. */
  57261. attachToNode(node: Nullable<Node>): void;
  57262. /**
  57263. * If the position gizmo is enabled
  57264. */
  57265. set positionGizmoEnabled(value: boolean);
  57266. get positionGizmoEnabled(): boolean;
  57267. /**
  57268. * If the rotation gizmo is enabled
  57269. */
  57270. set rotationGizmoEnabled(value: boolean);
  57271. get rotationGizmoEnabled(): boolean;
  57272. /**
  57273. * If the scale gizmo is enabled
  57274. */
  57275. set scaleGizmoEnabled(value: boolean);
  57276. get scaleGizmoEnabled(): boolean;
  57277. /**
  57278. * If the boundingBox gizmo is enabled
  57279. */
  57280. set boundingBoxGizmoEnabled(value: boolean);
  57281. get boundingBoxGizmoEnabled(): boolean;
  57282. /**
  57283. * Disposes of the gizmo manager
  57284. */
  57285. dispose(): void;
  57286. }
  57287. }
  57288. declare module BABYLON {
  57289. /**
  57290. * A directional light is defined by a direction (what a surprise!).
  57291. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  57292. * 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.
  57293. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57294. */
  57295. export class DirectionalLight extends ShadowLight {
  57296. private _shadowFrustumSize;
  57297. /**
  57298. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  57299. */
  57300. get shadowFrustumSize(): number;
  57301. /**
  57302. * Specifies a fix frustum size for the shadow generation.
  57303. */
  57304. set shadowFrustumSize(value: number);
  57305. private _shadowOrthoScale;
  57306. /**
  57307. * Gets the shadow projection scale against the optimal computed one.
  57308. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  57309. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  57310. */
  57311. get shadowOrthoScale(): number;
  57312. /**
  57313. * Sets the shadow projection scale against the optimal computed one.
  57314. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  57315. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  57316. */
  57317. set shadowOrthoScale(value: number);
  57318. /**
  57319. * Automatically compute the projection matrix to best fit (including all the casters)
  57320. * on each frame.
  57321. */
  57322. autoUpdateExtends: boolean;
  57323. /**
  57324. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  57325. * on each frame. autoUpdateExtends must be set to true for this to work
  57326. */
  57327. autoCalcShadowZBounds: boolean;
  57328. private _orthoLeft;
  57329. private _orthoRight;
  57330. private _orthoTop;
  57331. private _orthoBottom;
  57332. /**
  57333. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  57334. * The directional light is emitted from everywhere in the given direction.
  57335. * It can cast shadows.
  57336. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57337. * @param name The friendly name of the light
  57338. * @param direction The direction of the light
  57339. * @param scene The scene the light belongs to
  57340. */
  57341. constructor(name: string, direction: Vector3, scene: Scene);
  57342. /**
  57343. * Returns the string "DirectionalLight".
  57344. * @return The class name
  57345. */
  57346. getClassName(): string;
  57347. /**
  57348. * Returns the integer 1.
  57349. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57350. */
  57351. getTypeID(): number;
  57352. /**
  57353. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  57354. * Returns the DirectionalLight Shadow projection matrix.
  57355. */
  57356. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57357. /**
  57358. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  57359. * Returns the DirectionalLight Shadow projection matrix.
  57360. */
  57361. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  57362. /**
  57363. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  57364. * Returns the DirectionalLight Shadow projection matrix.
  57365. */
  57366. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57367. protected _buildUniformLayout(): void;
  57368. /**
  57369. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  57370. * @param effect The effect to update
  57371. * @param lightIndex The index of the light in the effect to update
  57372. * @returns The directional light
  57373. */
  57374. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  57375. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  57376. /**
  57377. * Gets the minZ used for shadow according to both the scene and the light.
  57378. *
  57379. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  57380. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  57381. * @param activeCamera The camera we are returning the min for
  57382. * @returns the depth min z
  57383. */
  57384. getDepthMinZ(activeCamera: Camera): number;
  57385. /**
  57386. * Gets the maxZ used for shadow according to both the scene and the light.
  57387. *
  57388. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  57389. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  57390. * @param activeCamera The camera we are returning the max for
  57391. * @returns the depth max z
  57392. */
  57393. getDepthMaxZ(activeCamera: Camera): number;
  57394. /**
  57395. * Prepares the list of defines specific to the light type.
  57396. * @param defines the list of defines
  57397. * @param lightIndex defines the index of the light for the effect
  57398. */
  57399. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57400. }
  57401. }
  57402. declare module BABYLON {
  57403. /**
  57404. * Class containing static functions to help procedurally build meshes
  57405. */
  57406. export class HemisphereBuilder {
  57407. /**
  57408. * Creates a hemisphere mesh
  57409. * @param name defines the name of the mesh
  57410. * @param options defines the options used to create the mesh
  57411. * @param scene defines the hosting scene
  57412. * @returns the hemisphere mesh
  57413. */
  57414. static CreateHemisphere(name: string, options: {
  57415. segments?: number;
  57416. diameter?: number;
  57417. sideOrientation?: number;
  57418. }, scene: any): Mesh;
  57419. }
  57420. }
  57421. declare module BABYLON {
  57422. /**
  57423. * A spot light is defined by a position, a direction, an angle, and an exponent.
  57424. * These values define a cone of light starting from the position, emitting toward the direction.
  57425. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  57426. * and the exponent defines the speed of the decay of the light with distance (reach).
  57427. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57428. */
  57429. export class SpotLight extends ShadowLight {
  57430. private _angle;
  57431. private _innerAngle;
  57432. private _cosHalfAngle;
  57433. private _lightAngleScale;
  57434. private _lightAngleOffset;
  57435. /**
  57436. * Gets the cone angle of the spot light in Radians.
  57437. */
  57438. get angle(): number;
  57439. /**
  57440. * Sets the cone angle of the spot light in Radians.
  57441. */
  57442. set angle(value: number);
  57443. /**
  57444. * Only used in gltf falloff mode, this defines the angle where
  57445. * the directional falloff will start before cutting at angle which could be seen
  57446. * as outer angle.
  57447. */
  57448. get innerAngle(): number;
  57449. /**
  57450. * Only used in gltf falloff mode, this defines the angle where
  57451. * the directional falloff will start before cutting at angle which could be seen
  57452. * as outer angle.
  57453. */
  57454. set innerAngle(value: number);
  57455. private _shadowAngleScale;
  57456. /**
  57457. * Allows scaling the angle of the light for shadow generation only.
  57458. */
  57459. get shadowAngleScale(): number;
  57460. /**
  57461. * Allows scaling the angle of the light for shadow generation only.
  57462. */
  57463. set shadowAngleScale(value: number);
  57464. /**
  57465. * The light decay speed with the distance from the emission spot.
  57466. */
  57467. exponent: number;
  57468. private _projectionTextureMatrix;
  57469. /**
  57470. * Allows reading the projecton texture
  57471. */
  57472. get projectionTextureMatrix(): Matrix;
  57473. protected _projectionTextureLightNear: number;
  57474. /**
  57475. * Gets the near clip of the Spotlight for texture projection.
  57476. */
  57477. get projectionTextureLightNear(): number;
  57478. /**
  57479. * Sets the near clip of the Spotlight for texture projection.
  57480. */
  57481. set projectionTextureLightNear(value: number);
  57482. protected _projectionTextureLightFar: number;
  57483. /**
  57484. * Gets the far clip of the Spotlight for texture projection.
  57485. */
  57486. get projectionTextureLightFar(): number;
  57487. /**
  57488. * Sets the far clip of the Spotlight for texture projection.
  57489. */
  57490. set projectionTextureLightFar(value: number);
  57491. protected _projectionTextureUpDirection: Vector3;
  57492. /**
  57493. * Gets the Up vector of the Spotlight for texture projection.
  57494. */
  57495. get projectionTextureUpDirection(): Vector3;
  57496. /**
  57497. * Sets the Up vector of the Spotlight for texture projection.
  57498. */
  57499. set projectionTextureUpDirection(value: Vector3);
  57500. private _projectionTexture;
  57501. /**
  57502. * Gets the projection texture of the light.
  57503. */
  57504. get projectionTexture(): Nullable<BaseTexture>;
  57505. /**
  57506. * Sets the projection texture of the light.
  57507. */
  57508. set projectionTexture(value: Nullable<BaseTexture>);
  57509. private _projectionTextureViewLightDirty;
  57510. private _projectionTextureProjectionLightDirty;
  57511. private _projectionTextureDirty;
  57512. private _projectionTextureViewTargetVector;
  57513. private _projectionTextureViewLightMatrix;
  57514. private _projectionTextureProjectionLightMatrix;
  57515. private _projectionTextureScalingMatrix;
  57516. /**
  57517. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  57518. * It can cast shadows.
  57519. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57520. * @param name The light friendly name
  57521. * @param position The position of the spot light in the scene
  57522. * @param direction The direction of the light in the scene
  57523. * @param angle The cone angle of the light in Radians
  57524. * @param exponent The light decay speed with the distance from the emission spot
  57525. * @param scene The scene the lights belongs to
  57526. */
  57527. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  57528. /**
  57529. * Returns the string "SpotLight".
  57530. * @returns the class name
  57531. */
  57532. getClassName(): string;
  57533. /**
  57534. * Returns the integer 2.
  57535. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57536. */
  57537. getTypeID(): number;
  57538. /**
  57539. * Overrides the direction setter to recompute the projection texture view light Matrix.
  57540. */
  57541. protected _setDirection(value: Vector3): void;
  57542. /**
  57543. * Overrides the position setter to recompute the projection texture view light Matrix.
  57544. */
  57545. protected _setPosition(value: Vector3): void;
  57546. /**
  57547. * 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.
  57548. * Returns the SpotLight.
  57549. */
  57550. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57551. protected _computeProjectionTextureViewLightMatrix(): void;
  57552. protected _computeProjectionTextureProjectionLightMatrix(): void;
  57553. /**
  57554. * Main function for light texture projection matrix computing.
  57555. */
  57556. protected _computeProjectionTextureMatrix(): void;
  57557. protected _buildUniformLayout(): void;
  57558. private _computeAngleValues;
  57559. /**
  57560. * Sets the passed Effect "effect" with the Light textures.
  57561. * @param effect The effect to update
  57562. * @param lightIndex The index of the light in the effect to update
  57563. * @returns The light
  57564. */
  57565. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  57566. /**
  57567. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  57568. * @param effect The effect to update
  57569. * @param lightIndex The index of the light in the effect to update
  57570. * @returns The spot light
  57571. */
  57572. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  57573. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  57574. /**
  57575. * Disposes the light and the associated resources.
  57576. */
  57577. dispose(): void;
  57578. /**
  57579. * Prepares the list of defines specific to the light type.
  57580. * @param defines the list of defines
  57581. * @param lightIndex defines the index of the light for the effect
  57582. */
  57583. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57584. }
  57585. }
  57586. declare module BABYLON {
  57587. /**
  57588. * Gizmo that enables viewing a light
  57589. */
  57590. export class LightGizmo extends Gizmo {
  57591. private _lightMesh;
  57592. private _material;
  57593. private _cachedPosition;
  57594. private _cachedForward;
  57595. private _attachedMeshParent;
  57596. private _pointerObserver;
  57597. /**
  57598. * Event that fires each time the gizmo is clicked
  57599. */
  57600. onClickedObservable: Observable<Light>;
  57601. /**
  57602. * Creates a LightGizmo
  57603. * @param gizmoLayer The utility layer the gizmo will be added to
  57604. */
  57605. constructor(gizmoLayer?: UtilityLayerRenderer);
  57606. private _light;
  57607. /**
  57608. * The light that the gizmo is attached to
  57609. */
  57610. set light(light: Nullable<Light>);
  57611. get light(): Nullable<Light>;
  57612. /**
  57613. * Gets the material used to render the light gizmo
  57614. */
  57615. get material(): StandardMaterial;
  57616. /**
  57617. * @hidden
  57618. * Updates the gizmo to match the attached mesh's position/rotation
  57619. */
  57620. protected _update(): void;
  57621. private static _Scale;
  57622. /**
  57623. * Creates the lines for a light mesh
  57624. */
  57625. private static _CreateLightLines;
  57626. /**
  57627. * Disposes of the light gizmo
  57628. */
  57629. dispose(): void;
  57630. private static _CreateHemisphericLightMesh;
  57631. private static _CreatePointLightMesh;
  57632. private static _CreateSpotLightMesh;
  57633. private static _CreateDirectionalLightMesh;
  57634. }
  57635. }
  57636. declare module BABYLON {
  57637. /**
  57638. * Gizmo that enables viewing a camera
  57639. */
  57640. export class CameraGizmo extends Gizmo {
  57641. private _cameraMesh;
  57642. private _cameraLinesMesh;
  57643. private _material;
  57644. private _pointerObserver;
  57645. /**
  57646. * Event that fires each time the gizmo is clicked
  57647. */
  57648. onClickedObservable: Observable<Camera>;
  57649. /**
  57650. * Creates a CameraGizmo
  57651. * @param gizmoLayer The utility layer the gizmo will be added to
  57652. */
  57653. constructor(gizmoLayer?: UtilityLayerRenderer);
  57654. private _camera;
  57655. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  57656. get displayFrustum(): boolean;
  57657. set displayFrustum(value: boolean);
  57658. /**
  57659. * The camera that the gizmo is attached to
  57660. */
  57661. set camera(camera: Nullable<Camera>);
  57662. get camera(): Nullable<Camera>;
  57663. /**
  57664. * Gets the material used to render the camera gizmo
  57665. */
  57666. get material(): StandardMaterial;
  57667. /**
  57668. * @hidden
  57669. * Updates the gizmo to match the attached mesh's position/rotation
  57670. */
  57671. protected _update(): void;
  57672. private static _Scale;
  57673. private _invProjection;
  57674. /**
  57675. * Disposes of the camera gizmo
  57676. */
  57677. dispose(): void;
  57678. private static _CreateCameraMesh;
  57679. private static _CreateCameraFrustum;
  57680. }
  57681. }
  57682. declare module BABYLON {
  57683. /** @hidden */
  57684. export var backgroundFragmentDeclaration: {
  57685. name: string;
  57686. shader: string;
  57687. };
  57688. }
  57689. declare module BABYLON {
  57690. /** @hidden */
  57691. export var backgroundUboDeclaration: {
  57692. name: string;
  57693. shader: string;
  57694. };
  57695. }
  57696. declare module BABYLON {
  57697. /** @hidden */
  57698. export var backgroundPixelShader: {
  57699. name: string;
  57700. shader: string;
  57701. };
  57702. }
  57703. declare module BABYLON {
  57704. /** @hidden */
  57705. export var backgroundVertexDeclaration: {
  57706. name: string;
  57707. shader: string;
  57708. };
  57709. }
  57710. declare module BABYLON {
  57711. /** @hidden */
  57712. export var backgroundVertexShader: {
  57713. name: string;
  57714. shader: string;
  57715. };
  57716. }
  57717. declare module BABYLON {
  57718. /**
  57719. * Background material used to create an efficient environement around your scene.
  57720. */
  57721. export class BackgroundMaterial extends PushMaterial {
  57722. /**
  57723. * Standard reflectance value at parallel view angle.
  57724. */
  57725. static StandardReflectance0: number;
  57726. /**
  57727. * Standard reflectance value at grazing angle.
  57728. */
  57729. static StandardReflectance90: number;
  57730. protected _primaryColor: Color3;
  57731. /**
  57732. * Key light Color (multiply against the environement texture)
  57733. */
  57734. primaryColor: Color3;
  57735. protected __perceptualColor: Nullable<Color3>;
  57736. /**
  57737. * Experimental Internal Use Only.
  57738. *
  57739. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  57740. * This acts as a helper to set the primary color to a more "human friendly" value.
  57741. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  57742. * output color as close as possible from the chosen value.
  57743. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  57744. * part of lighting setup.)
  57745. */
  57746. get _perceptualColor(): Nullable<Color3>;
  57747. set _perceptualColor(value: Nullable<Color3>);
  57748. protected _primaryColorShadowLevel: float;
  57749. /**
  57750. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  57751. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  57752. */
  57753. get primaryColorShadowLevel(): float;
  57754. set primaryColorShadowLevel(value: float);
  57755. protected _primaryColorHighlightLevel: float;
  57756. /**
  57757. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  57758. * The primary color is used at the level chosen to define what the white area would look.
  57759. */
  57760. get primaryColorHighlightLevel(): float;
  57761. set primaryColorHighlightLevel(value: float);
  57762. protected _reflectionTexture: Nullable<BaseTexture>;
  57763. /**
  57764. * Reflection Texture used in the material.
  57765. * Should be author in a specific way for the best result (refer to the documentation).
  57766. */
  57767. reflectionTexture: Nullable<BaseTexture>;
  57768. protected _reflectionBlur: float;
  57769. /**
  57770. * Reflection Texture level of blur.
  57771. *
  57772. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  57773. * texture twice.
  57774. */
  57775. reflectionBlur: float;
  57776. protected _diffuseTexture: Nullable<BaseTexture>;
  57777. /**
  57778. * Diffuse Texture used in the material.
  57779. * Should be author in a specific way for the best result (refer to the documentation).
  57780. */
  57781. diffuseTexture: Nullable<BaseTexture>;
  57782. protected _shadowLights: Nullable<IShadowLight[]>;
  57783. /**
  57784. * Specify the list of lights casting shadow on the material.
  57785. * All scene shadow lights will be included if null.
  57786. */
  57787. shadowLights: Nullable<IShadowLight[]>;
  57788. protected _shadowLevel: float;
  57789. /**
  57790. * Helps adjusting the shadow to a softer level if required.
  57791. * 0 means black shadows and 1 means no shadows.
  57792. */
  57793. shadowLevel: float;
  57794. protected _sceneCenter: Vector3;
  57795. /**
  57796. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  57797. * It is usually zero but might be interesting to modify according to your setup.
  57798. */
  57799. sceneCenter: Vector3;
  57800. protected _opacityFresnel: boolean;
  57801. /**
  57802. * This helps specifying that the material is falling off to the sky box at grazing angle.
  57803. * This helps ensuring a nice transition when the camera goes under the ground.
  57804. */
  57805. opacityFresnel: boolean;
  57806. protected _reflectionFresnel: boolean;
  57807. /**
  57808. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  57809. * This helps adding a mirror texture on the ground.
  57810. */
  57811. reflectionFresnel: boolean;
  57812. protected _reflectionFalloffDistance: number;
  57813. /**
  57814. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  57815. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  57816. */
  57817. reflectionFalloffDistance: number;
  57818. protected _reflectionAmount: number;
  57819. /**
  57820. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  57821. */
  57822. reflectionAmount: number;
  57823. protected _reflectionReflectance0: number;
  57824. /**
  57825. * This specifies the weight of the reflection at grazing angle.
  57826. */
  57827. reflectionReflectance0: number;
  57828. protected _reflectionReflectance90: number;
  57829. /**
  57830. * This specifies the weight of the reflection at a perpendicular point of view.
  57831. */
  57832. reflectionReflectance90: number;
  57833. /**
  57834. * Sets the reflection reflectance fresnel values according to the default standard
  57835. * empirically know to work well :-)
  57836. */
  57837. set reflectionStandardFresnelWeight(value: number);
  57838. protected _useRGBColor: boolean;
  57839. /**
  57840. * Helps to directly use the maps channels instead of their level.
  57841. */
  57842. useRGBColor: boolean;
  57843. protected _enableNoise: boolean;
  57844. /**
  57845. * This helps reducing the banding effect that could occur on the background.
  57846. */
  57847. enableNoise: boolean;
  57848. /**
  57849. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57850. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  57851. * Recommended to be keep at 1.0 except for special cases.
  57852. */
  57853. get fovMultiplier(): number;
  57854. set fovMultiplier(value: number);
  57855. private _fovMultiplier;
  57856. /**
  57857. * Enable the FOV adjustment feature controlled by fovMultiplier.
  57858. */
  57859. useEquirectangularFOV: boolean;
  57860. private _maxSimultaneousLights;
  57861. /**
  57862. * Number of Simultaneous lights allowed on the material.
  57863. */
  57864. maxSimultaneousLights: int;
  57865. private _shadowOnly;
  57866. /**
  57867. * Make the material only render shadows
  57868. */
  57869. shadowOnly: boolean;
  57870. /**
  57871. * Default configuration related to image processing available in the Background Material.
  57872. */
  57873. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57874. /**
  57875. * Keep track of the image processing observer to allow dispose and replace.
  57876. */
  57877. private _imageProcessingObserver;
  57878. /**
  57879. * Attaches a new image processing configuration to the PBR Material.
  57880. * @param configuration (if null the scene configuration will be use)
  57881. */
  57882. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57883. /**
  57884. * Gets the image processing configuration used either in this material.
  57885. */
  57886. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  57887. /**
  57888. * Sets the Default image processing configuration used either in the this material.
  57889. *
  57890. * If sets to null, the scene one is in use.
  57891. */
  57892. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  57893. /**
  57894. * Gets wether the color curves effect is enabled.
  57895. */
  57896. get cameraColorCurvesEnabled(): boolean;
  57897. /**
  57898. * Sets wether the color curves effect is enabled.
  57899. */
  57900. set cameraColorCurvesEnabled(value: boolean);
  57901. /**
  57902. * Gets wether the color grading effect is enabled.
  57903. */
  57904. get cameraColorGradingEnabled(): boolean;
  57905. /**
  57906. * Gets wether the color grading effect is enabled.
  57907. */
  57908. set cameraColorGradingEnabled(value: boolean);
  57909. /**
  57910. * Gets wether tonemapping is enabled or not.
  57911. */
  57912. get cameraToneMappingEnabled(): boolean;
  57913. /**
  57914. * Sets wether tonemapping is enabled or not
  57915. */
  57916. set cameraToneMappingEnabled(value: boolean);
  57917. /**
  57918. * The camera exposure used on this material.
  57919. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57920. * This corresponds to a photographic exposure.
  57921. */
  57922. get cameraExposure(): float;
  57923. /**
  57924. * The camera exposure used on this material.
  57925. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57926. * This corresponds to a photographic exposure.
  57927. */
  57928. set cameraExposure(value: float);
  57929. /**
  57930. * Gets The camera contrast used on this material.
  57931. */
  57932. get cameraContrast(): float;
  57933. /**
  57934. * Sets The camera contrast used on this material.
  57935. */
  57936. set cameraContrast(value: float);
  57937. /**
  57938. * Gets the Color Grading 2D Lookup Texture.
  57939. */
  57940. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  57941. /**
  57942. * Sets the Color Grading 2D Lookup Texture.
  57943. */
  57944. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  57945. /**
  57946. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57947. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57948. * 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;
  57949. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57950. */
  57951. get cameraColorCurves(): Nullable<ColorCurves>;
  57952. /**
  57953. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57954. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57955. * 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;
  57956. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57957. */
  57958. set cameraColorCurves(value: Nullable<ColorCurves>);
  57959. /**
  57960. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  57961. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  57962. */
  57963. switchToBGR: boolean;
  57964. private _renderTargets;
  57965. private _reflectionControls;
  57966. private _white;
  57967. private _primaryShadowColor;
  57968. private _primaryHighlightColor;
  57969. /**
  57970. * Instantiates a Background Material in the given scene
  57971. * @param name The friendly name of the material
  57972. * @param scene The scene to add the material to
  57973. */
  57974. constructor(name: string, scene: Scene);
  57975. /**
  57976. * Gets a boolean indicating that current material needs to register RTT
  57977. */
  57978. get hasRenderTargetTextures(): boolean;
  57979. /**
  57980. * The entire material has been created in order to prevent overdraw.
  57981. * @returns false
  57982. */
  57983. needAlphaTesting(): boolean;
  57984. /**
  57985. * The entire material has been created in order to prevent overdraw.
  57986. * @returns true if blending is enable
  57987. */
  57988. needAlphaBlending(): boolean;
  57989. /**
  57990. * Checks wether the material is ready to be rendered for a given mesh.
  57991. * @param mesh The mesh to render
  57992. * @param subMesh The submesh to check against
  57993. * @param useInstances Specify wether or not the material is used with instances
  57994. * @returns true if all the dependencies are ready (Textures, Effects...)
  57995. */
  57996. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57997. /**
  57998. * Compute the primary color according to the chosen perceptual color.
  57999. */
  58000. private _computePrimaryColorFromPerceptualColor;
  58001. /**
  58002. * Compute the highlights and shadow colors according to their chosen levels.
  58003. */
  58004. private _computePrimaryColors;
  58005. /**
  58006. * Build the uniform buffer used in the material.
  58007. */
  58008. buildUniformLayout(): void;
  58009. /**
  58010. * Unbind the material.
  58011. */
  58012. unbind(): void;
  58013. /**
  58014. * Bind only the world matrix to the material.
  58015. * @param world The world matrix to bind.
  58016. */
  58017. bindOnlyWorldMatrix(world: Matrix): void;
  58018. /**
  58019. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  58020. * @param world The world matrix to bind.
  58021. * @param subMesh The submesh to bind for.
  58022. */
  58023. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  58024. /**
  58025. * Checks to see if a texture is used in the material.
  58026. * @param texture - Base texture to use.
  58027. * @returns - Boolean specifying if a texture is used in the material.
  58028. */
  58029. hasTexture(texture: BaseTexture): boolean;
  58030. /**
  58031. * Dispose the material.
  58032. * @param forceDisposeEffect Force disposal of the associated effect.
  58033. * @param forceDisposeTextures Force disposal of the associated textures.
  58034. */
  58035. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  58036. /**
  58037. * Clones the material.
  58038. * @param name The cloned name.
  58039. * @returns The cloned material.
  58040. */
  58041. clone(name: string): BackgroundMaterial;
  58042. /**
  58043. * Serializes the current material to its JSON representation.
  58044. * @returns The JSON representation.
  58045. */
  58046. serialize(): any;
  58047. /**
  58048. * Gets the class name of the material
  58049. * @returns "BackgroundMaterial"
  58050. */
  58051. getClassName(): string;
  58052. /**
  58053. * Parse a JSON input to create back a background material.
  58054. * @param source The JSON data to parse
  58055. * @param scene The scene to create the parsed material in
  58056. * @param rootUrl The root url of the assets the material depends upon
  58057. * @returns the instantiated BackgroundMaterial.
  58058. */
  58059. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  58060. }
  58061. }
  58062. declare module BABYLON {
  58063. /**
  58064. * Represents the different options available during the creation of
  58065. * a Environment helper.
  58066. *
  58067. * This can control the default ground, skybox and image processing setup of your scene.
  58068. */
  58069. export interface IEnvironmentHelperOptions {
  58070. /**
  58071. * Specifies whether or not to create a ground.
  58072. * True by default.
  58073. */
  58074. createGround: boolean;
  58075. /**
  58076. * Specifies the ground size.
  58077. * 15 by default.
  58078. */
  58079. groundSize: number;
  58080. /**
  58081. * The texture used on the ground for the main color.
  58082. * Comes from the BabylonJS CDN by default.
  58083. *
  58084. * Remarks: Can be either a texture or a url.
  58085. */
  58086. groundTexture: string | BaseTexture;
  58087. /**
  58088. * The color mixed in the ground texture by default.
  58089. * BabylonJS clearColor by default.
  58090. */
  58091. groundColor: Color3;
  58092. /**
  58093. * Specifies the ground opacity.
  58094. * 1 by default.
  58095. */
  58096. groundOpacity: number;
  58097. /**
  58098. * Enables the ground to receive shadows.
  58099. * True by default.
  58100. */
  58101. enableGroundShadow: boolean;
  58102. /**
  58103. * Helps preventing the shadow to be fully black on the ground.
  58104. * 0.5 by default.
  58105. */
  58106. groundShadowLevel: number;
  58107. /**
  58108. * Creates a mirror texture attach to the ground.
  58109. * false by default.
  58110. */
  58111. enableGroundMirror: boolean;
  58112. /**
  58113. * Specifies the ground mirror size ratio.
  58114. * 0.3 by default as the default kernel is 64.
  58115. */
  58116. groundMirrorSizeRatio: number;
  58117. /**
  58118. * Specifies the ground mirror blur kernel size.
  58119. * 64 by default.
  58120. */
  58121. groundMirrorBlurKernel: number;
  58122. /**
  58123. * Specifies the ground mirror visibility amount.
  58124. * 1 by default
  58125. */
  58126. groundMirrorAmount: number;
  58127. /**
  58128. * Specifies the ground mirror reflectance weight.
  58129. * This uses the standard weight of the background material to setup the fresnel effect
  58130. * of the mirror.
  58131. * 1 by default.
  58132. */
  58133. groundMirrorFresnelWeight: number;
  58134. /**
  58135. * Specifies the ground mirror Falloff distance.
  58136. * This can helps reducing the size of the reflection.
  58137. * 0 by Default.
  58138. */
  58139. groundMirrorFallOffDistance: number;
  58140. /**
  58141. * Specifies the ground mirror texture type.
  58142. * Unsigned Int by Default.
  58143. */
  58144. groundMirrorTextureType: number;
  58145. /**
  58146. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  58147. * the shown objects.
  58148. */
  58149. groundYBias: number;
  58150. /**
  58151. * Specifies whether or not to create a skybox.
  58152. * True by default.
  58153. */
  58154. createSkybox: boolean;
  58155. /**
  58156. * Specifies the skybox size.
  58157. * 20 by default.
  58158. */
  58159. skyboxSize: number;
  58160. /**
  58161. * The texture used on the skybox for the main color.
  58162. * Comes from the BabylonJS CDN by default.
  58163. *
  58164. * Remarks: Can be either a texture or a url.
  58165. */
  58166. skyboxTexture: string | BaseTexture;
  58167. /**
  58168. * The color mixed in the skybox texture by default.
  58169. * BabylonJS clearColor by default.
  58170. */
  58171. skyboxColor: Color3;
  58172. /**
  58173. * The background rotation around the Y axis of the scene.
  58174. * This helps aligning the key lights of your scene with the background.
  58175. * 0 by default.
  58176. */
  58177. backgroundYRotation: number;
  58178. /**
  58179. * Compute automatically the size of the elements to best fit with the scene.
  58180. */
  58181. sizeAuto: boolean;
  58182. /**
  58183. * Default position of the rootMesh if autoSize is not true.
  58184. */
  58185. rootPosition: Vector3;
  58186. /**
  58187. * Sets up the image processing in the scene.
  58188. * true by default.
  58189. */
  58190. setupImageProcessing: boolean;
  58191. /**
  58192. * The texture used as your environment texture in the scene.
  58193. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  58194. *
  58195. * Remarks: Can be either a texture or a url.
  58196. */
  58197. environmentTexture: string | BaseTexture;
  58198. /**
  58199. * The value of the exposure to apply to the scene.
  58200. * 0.6 by default if setupImageProcessing is true.
  58201. */
  58202. cameraExposure: number;
  58203. /**
  58204. * The value of the contrast to apply to the scene.
  58205. * 1.6 by default if setupImageProcessing is true.
  58206. */
  58207. cameraContrast: number;
  58208. /**
  58209. * Specifies whether or not tonemapping should be enabled in the scene.
  58210. * true by default if setupImageProcessing is true.
  58211. */
  58212. toneMappingEnabled: boolean;
  58213. }
  58214. /**
  58215. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  58216. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  58217. * It also helps with the default setup of your imageProcessing configuration.
  58218. */
  58219. export class EnvironmentHelper {
  58220. /**
  58221. * Default ground texture URL.
  58222. */
  58223. private static _groundTextureCDNUrl;
  58224. /**
  58225. * Default skybox texture URL.
  58226. */
  58227. private static _skyboxTextureCDNUrl;
  58228. /**
  58229. * Default environment texture URL.
  58230. */
  58231. private static _environmentTextureCDNUrl;
  58232. /**
  58233. * Creates the default options for the helper.
  58234. */
  58235. private static _getDefaultOptions;
  58236. private _rootMesh;
  58237. /**
  58238. * Gets the root mesh created by the helper.
  58239. */
  58240. get rootMesh(): Mesh;
  58241. private _skybox;
  58242. /**
  58243. * Gets the skybox created by the helper.
  58244. */
  58245. get skybox(): Nullable<Mesh>;
  58246. private _skyboxTexture;
  58247. /**
  58248. * Gets the skybox texture created by the helper.
  58249. */
  58250. get skyboxTexture(): Nullable<BaseTexture>;
  58251. private _skyboxMaterial;
  58252. /**
  58253. * Gets the skybox material created by the helper.
  58254. */
  58255. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  58256. private _ground;
  58257. /**
  58258. * Gets the ground mesh created by the helper.
  58259. */
  58260. get ground(): Nullable<Mesh>;
  58261. private _groundTexture;
  58262. /**
  58263. * Gets the ground texture created by the helper.
  58264. */
  58265. get groundTexture(): Nullable<BaseTexture>;
  58266. private _groundMirror;
  58267. /**
  58268. * Gets the ground mirror created by the helper.
  58269. */
  58270. get groundMirror(): Nullable<MirrorTexture>;
  58271. /**
  58272. * Gets the ground mirror render list to helps pushing the meshes
  58273. * you wish in the ground reflection.
  58274. */
  58275. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  58276. private _groundMaterial;
  58277. /**
  58278. * Gets the ground material created by the helper.
  58279. */
  58280. get groundMaterial(): Nullable<BackgroundMaterial>;
  58281. /**
  58282. * Stores the creation options.
  58283. */
  58284. private readonly _scene;
  58285. private _options;
  58286. /**
  58287. * This observable will be notified with any error during the creation of the environment,
  58288. * mainly texture creation errors.
  58289. */
  58290. onErrorObservable: Observable<{
  58291. message?: string;
  58292. exception?: any;
  58293. }>;
  58294. /**
  58295. * constructor
  58296. * @param options Defines the options we want to customize the helper
  58297. * @param scene The scene to add the material to
  58298. */
  58299. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  58300. /**
  58301. * Updates the background according to the new options
  58302. * @param options
  58303. */
  58304. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  58305. /**
  58306. * Sets the primary color of all the available elements.
  58307. * @param color the main color to affect to the ground and the background
  58308. */
  58309. setMainColor(color: Color3): void;
  58310. /**
  58311. * Setup the image processing according to the specified options.
  58312. */
  58313. private _setupImageProcessing;
  58314. /**
  58315. * Setup the environment texture according to the specified options.
  58316. */
  58317. private _setupEnvironmentTexture;
  58318. /**
  58319. * Setup the background according to the specified options.
  58320. */
  58321. private _setupBackground;
  58322. /**
  58323. * Get the scene sizes according to the setup.
  58324. */
  58325. private _getSceneSize;
  58326. /**
  58327. * Setup the ground according to the specified options.
  58328. */
  58329. private _setupGround;
  58330. /**
  58331. * Setup the ground material according to the specified options.
  58332. */
  58333. private _setupGroundMaterial;
  58334. /**
  58335. * Setup the ground diffuse texture according to the specified options.
  58336. */
  58337. private _setupGroundDiffuseTexture;
  58338. /**
  58339. * Setup the ground mirror texture according to the specified options.
  58340. */
  58341. private _setupGroundMirrorTexture;
  58342. /**
  58343. * Setup the ground to receive the mirror texture.
  58344. */
  58345. private _setupMirrorInGroundMaterial;
  58346. /**
  58347. * Setup the skybox according to the specified options.
  58348. */
  58349. private _setupSkybox;
  58350. /**
  58351. * Setup the skybox material according to the specified options.
  58352. */
  58353. private _setupSkyboxMaterial;
  58354. /**
  58355. * Setup the skybox reflection texture according to the specified options.
  58356. */
  58357. private _setupSkyboxReflectionTexture;
  58358. private _errorHandler;
  58359. /**
  58360. * Dispose all the elements created by the Helper.
  58361. */
  58362. dispose(): void;
  58363. }
  58364. }
  58365. declare module BABYLON {
  58366. /**
  58367. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  58368. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  58369. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  58370. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58371. */
  58372. export abstract class TextureDome<T extends Texture> extends TransformNode {
  58373. protected onError: Nullable<(message?: string, exception?: any) => void>;
  58374. /**
  58375. * Define the source as a Monoscopic panoramic 360/180.
  58376. */
  58377. static readonly MODE_MONOSCOPIC: number;
  58378. /**
  58379. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  58380. */
  58381. static readonly MODE_TOPBOTTOM: number;
  58382. /**
  58383. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  58384. */
  58385. static readonly MODE_SIDEBYSIDE: number;
  58386. private _halfDome;
  58387. private _crossEye;
  58388. protected _useDirectMapping: boolean;
  58389. /**
  58390. * The texture being displayed on the sphere
  58391. */
  58392. protected _texture: T;
  58393. /**
  58394. * Gets the texture being displayed on the sphere
  58395. */
  58396. get texture(): T;
  58397. /**
  58398. * Sets the texture being displayed on the sphere
  58399. */
  58400. set texture(newTexture: T);
  58401. /**
  58402. * The skybox material
  58403. */
  58404. protected _material: BackgroundMaterial;
  58405. /**
  58406. * The surface used for the dome
  58407. */
  58408. protected _mesh: Mesh;
  58409. /**
  58410. * Gets the mesh used for the dome.
  58411. */
  58412. get mesh(): Mesh;
  58413. /**
  58414. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  58415. */
  58416. private _halfDomeMask;
  58417. /**
  58418. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  58419. * Also see the options.resolution property.
  58420. */
  58421. get fovMultiplier(): number;
  58422. set fovMultiplier(value: number);
  58423. protected _textureMode: number;
  58424. /**
  58425. * Gets or set the current texture mode for the texture. It can be:
  58426. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58427. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58428. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58429. */
  58430. get textureMode(): number;
  58431. /**
  58432. * Sets the current texture mode for the texture. It can be:
  58433. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58434. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58435. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58436. */
  58437. set textureMode(value: number);
  58438. /**
  58439. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  58440. */
  58441. get halfDome(): boolean;
  58442. /**
  58443. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  58444. */
  58445. set halfDome(enabled: boolean);
  58446. /**
  58447. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  58448. */
  58449. set crossEye(enabled: boolean);
  58450. /**
  58451. * Is it a cross-eye texture?
  58452. */
  58453. get crossEye(): boolean;
  58454. /**
  58455. * The background material of this dome.
  58456. */
  58457. get material(): BackgroundMaterial;
  58458. /**
  58459. * Oberserver used in Stereoscopic VR Mode.
  58460. */
  58461. private _onBeforeCameraRenderObserver;
  58462. /**
  58463. * Observable raised when an error occured while loading the 360 image
  58464. */
  58465. onLoadErrorObservable: Observable<string>;
  58466. /**
  58467. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  58468. * @param name Element's name, child elements will append suffixes for their own names.
  58469. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  58470. * @param options An object containing optional or exposed sub element properties
  58471. */
  58472. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  58473. resolution?: number;
  58474. clickToPlay?: boolean;
  58475. autoPlay?: boolean;
  58476. loop?: boolean;
  58477. size?: number;
  58478. poster?: string;
  58479. faceForward?: boolean;
  58480. useDirectMapping?: boolean;
  58481. halfDomeMode?: boolean;
  58482. crossEyeMode?: boolean;
  58483. generateMipMaps?: boolean;
  58484. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  58485. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  58486. protected _changeTextureMode(value: number): void;
  58487. /**
  58488. * Releases resources associated with this node.
  58489. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  58490. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  58491. */
  58492. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  58493. }
  58494. }
  58495. declare module BABYLON {
  58496. /**
  58497. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  58498. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  58499. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  58500. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58501. */
  58502. export class PhotoDome extends TextureDome<Texture> {
  58503. /**
  58504. * Define the image as a Monoscopic panoramic 360 image.
  58505. */
  58506. static readonly MODE_MONOSCOPIC: number;
  58507. /**
  58508. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  58509. */
  58510. static readonly MODE_TOPBOTTOM: number;
  58511. /**
  58512. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  58513. */
  58514. static readonly MODE_SIDEBYSIDE: number;
  58515. /**
  58516. * Gets or sets the texture being displayed on the sphere
  58517. */
  58518. get photoTexture(): Texture;
  58519. /**
  58520. * sets the texture being displayed on the sphere
  58521. */
  58522. set photoTexture(value: Texture);
  58523. /**
  58524. * Gets the current video mode for the video. It can be:
  58525. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58526. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58527. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58528. */
  58529. get imageMode(): number;
  58530. /**
  58531. * Sets the current video mode for the video. It can be:
  58532. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58533. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58534. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58535. */
  58536. set imageMode(value: number);
  58537. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  58538. }
  58539. }
  58540. declare module BABYLON {
  58541. /**
  58542. * Direct draw surface info
  58543. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  58544. */
  58545. export interface DDSInfo {
  58546. /**
  58547. * Width of the texture
  58548. */
  58549. width: number;
  58550. /**
  58551. * Width of the texture
  58552. */
  58553. height: number;
  58554. /**
  58555. * Number of Mipmaps for the texture
  58556. * @see https://en.wikipedia.org/wiki/Mipmap
  58557. */
  58558. mipmapCount: number;
  58559. /**
  58560. * If the textures format is a known fourCC format
  58561. * @see https://www.fourcc.org/
  58562. */
  58563. isFourCC: boolean;
  58564. /**
  58565. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  58566. */
  58567. isRGB: boolean;
  58568. /**
  58569. * If the texture is a lumincance format
  58570. */
  58571. isLuminance: boolean;
  58572. /**
  58573. * If this is a cube texture
  58574. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  58575. */
  58576. isCube: boolean;
  58577. /**
  58578. * If the texture is a compressed format eg. FOURCC_DXT1
  58579. */
  58580. isCompressed: boolean;
  58581. /**
  58582. * The dxgiFormat of the texture
  58583. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  58584. */
  58585. dxgiFormat: number;
  58586. /**
  58587. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  58588. */
  58589. textureType: number;
  58590. /**
  58591. * Sphericle polynomial created for the dds texture
  58592. */
  58593. sphericalPolynomial?: SphericalPolynomial;
  58594. }
  58595. /**
  58596. * Class used to provide DDS decompression tools
  58597. */
  58598. export class DDSTools {
  58599. /**
  58600. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  58601. */
  58602. static StoreLODInAlphaChannel: boolean;
  58603. /**
  58604. * Gets DDS information from an array buffer
  58605. * @param data defines the array buffer view to read data from
  58606. * @returns the DDS information
  58607. */
  58608. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  58609. private static _FloatView;
  58610. private static _Int32View;
  58611. private static _ToHalfFloat;
  58612. private static _FromHalfFloat;
  58613. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  58614. private static _GetHalfFloatRGBAArrayBuffer;
  58615. private static _GetFloatRGBAArrayBuffer;
  58616. private static _GetFloatAsUIntRGBAArrayBuffer;
  58617. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  58618. private static _GetRGBAArrayBuffer;
  58619. private static _ExtractLongWordOrder;
  58620. private static _GetRGBArrayBuffer;
  58621. private static _GetLuminanceArrayBuffer;
  58622. /**
  58623. * Uploads DDS Levels to a Babylon Texture
  58624. * @hidden
  58625. */
  58626. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  58627. }
  58628. interface ThinEngine {
  58629. /**
  58630. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  58631. * @param rootUrl defines the url where the file to load is located
  58632. * @param scene defines the current scene
  58633. * @param lodScale defines scale to apply to the mip map selection
  58634. * @param lodOffset defines offset to apply to the mip map selection
  58635. * @param onLoad defines an optional callback raised when the texture is loaded
  58636. * @param onError defines an optional callback raised if there is an issue to load the texture
  58637. * @param format defines the format of the data
  58638. * @param forcedExtension defines the extension to use to pick the right loader
  58639. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  58640. * @returns the cube texture as an InternalTexture
  58641. */
  58642. 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;
  58643. }
  58644. }
  58645. declare module BABYLON {
  58646. /**
  58647. * Implementation of the DDS Texture Loader.
  58648. * @hidden
  58649. */
  58650. export class _DDSTextureLoader implements IInternalTextureLoader {
  58651. /**
  58652. * Defines wether the loader supports cascade loading the different faces.
  58653. */
  58654. readonly supportCascades: boolean;
  58655. /**
  58656. * This returns if the loader support the current file information.
  58657. * @param extension defines the file extension of the file being loaded
  58658. * @returns true if the loader can load the specified file
  58659. */
  58660. canLoad(extension: string): boolean;
  58661. /**
  58662. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58663. * @param data contains the texture data
  58664. * @param texture defines the BabylonJS internal texture
  58665. * @param createPolynomials will be true if polynomials have been requested
  58666. * @param onLoad defines the callback to trigger once the texture is ready
  58667. * @param onError defines the callback to trigger in case of error
  58668. */
  58669. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58670. /**
  58671. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58672. * @param data contains the texture data
  58673. * @param texture defines the BabylonJS internal texture
  58674. * @param callback defines the method to call once ready to upload
  58675. */
  58676. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58677. }
  58678. }
  58679. declare module BABYLON {
  58680. /**
  58681. * Implementation of the ENV Texture Loader.
  58682. * @hidden
  58683. */
  58684. export class _ENVTextureLoader 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(data: 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. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  58716. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  58717. */
  58718. export class KhronosTextureContainer {
  58719. /** contents of the KTX container file */
  58720. data: ArrayBufferView;
  58721. private static HEADER_LEN;
  58722. private static COMPRESSED_2D;
  58723. private static COMPRESSED_3D;
  58724. private static TEX_2D;
  58725. private static TEX_3D;
  58726. /**
  58727. * Gets the openGL type
  58728. */
  58729. glType: number;
  58730. /**
  58731. * Gets the openGL type size
  58732. */
  58733. glTypeSize: number;
  58734. /**
  58735. * Gets the openGL format
  58736. */
  58737. glFormat: number;
  58738. /**
  58739. * Gets the openGL internal format
  58740. */
  58741. glInternalFormat: number;
  58742. /**
  58743. * Gets the base internal format
  58744. */
  58745. glBaseInternalFormat: number;
  58746. /**
  58747. * Gets image width in pixel
  58748. */
  58749. pixelWidth: number;
  58750. /**
  58751. * Gets image height in pixel
  58752. */
  58753. pixelHeight: number;
  58754. /**
  58755. * Gets image depth in pixels
  58756. */
  58757. pixelDepth: number;
  58758. /**
  58759. * Gets the number of array elements
  58760. */
  58761. numberOfArrayElements: number;
  58762. /**
  58763. * Gets the number of faces
  58764. */
  58765. numberOfFaces: number;
  58766. /**
  58767. * Gets the number of mipmap levels
  58768. */
  58769. numberOfMipmapLevels: number;
  58770. /**
  58771. * Gets the bytes of key value data
  58772. */
  58773. bytesOfKeyValueData: number;
  58774. /**
  58775. * Gets the load type
  58776. */
  58777. loadType: number;
  58778. /**
  58779. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  58780. */
  58781. isInvalid: boolean;
  58782. /**
  58783. * Creates a new KhronosTextureContainer
  58784. * @param data contents of the KTX container file
  58785. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  58786. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  58787. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  58788. */
  58789. constructor(
  58790. /** contents of the KTX container file */
  58791. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  58792. /**
  58793. * Uploads KTX content to a Babylon Texture.
  58794. * It is assumed that the texture has already been created & is currently bound
  58795. * @hidden
  58796. */
  58797. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  58798. private _upload2DCompressedLevels;
  58799. /**
  58800. * Checks if the given data starts with a KTX file identifier.
  58801. * @param data the data to check
  58802. * @returns true if the data is a KTX file or false otherwise
  58803. */
  58804. static IsValid(data: ArrayBufferView): boolean;
  58805. }
  58806. }
  58807. declare module BABYLON {
  58808. /**
  58809. * Helper class to push actions to a pool of workers.
  58810. */
  58811. export class WorkerPool implements IDisposable {
  58812. private _workerInfos;
  58813. private _pendingActions;
  58814. /**
  58815. * Constructor
  58816. * @param workers Array of workers to use for actions
  58817. */
  58818. constructor(workers: Array<Worker>);
  58819. /**
  58820. * Terminates all workers and clears any pending actions.
  58821. */
  58822. dispose(): void;
  58823. /**
  58824. * Pushes an action to the worker pool. If all the workers are active, the action will be
  58825. * pended until a worker has completed its action.
  58826. * @param action The action to perform. Call onComplete when the action is complete.
  58827. */
  58828. push(action: (worker: Worker, onComplete: () => void) => void): void;
  58829. private _execute;
  58830. }
  58831. }
  58832. declare module BABYLON {
  58833. /**
  58834. * Class for loading KTX2 files
  58835. */
  58836. export class KhronosTextureContainer2 {
  58837. private static _WorkerPoolPromise?;
  58838. private static _Initialized;
  58839. private static _Ktx2Decoder;
  58840. /**
  58841. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  58842. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  58843. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  58844. * Urls you can change:
  58845. * URLConfig.jsDecoderModule
  58846. * URLConfig.wasmUASTCToASTC
  58847. * URLConfig.wasmUASTCToBC7
  58848. * URLConfig.wasmUASTCToRGBA_UNORM
  58849. * URLConfig.wasmUASTCToRGBA_SRGB
  58850. * URLConfig.jsMSCTranscoder
  58851. * URLConfig.wasmMSCTranscoder
  58852. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  58853. */
  58854. static URLConfig: {
  58855. jsDecoderModule: string;
  58856. wasmUASTCToASTC: null;
  58857. wasmUASTCToBC7: null;
  58858. wasmUASTCToRGBA_UNORM: null;
  58859. wasmUASTCToRGBA_SRGB: null;
  58860. jsMSCTranscoder: null;
  58861. wasmMSCTranscoder: null;
  58862. };
  58863. /**
  58864. * Default number of workers used to handle data decoding
  58865. */
  58866. static DefaultNumWorkers: number;
  58867. private static GetDefaultNumWorkers;
  58868. private _engine;
  58869. private static _CreateWorkerPool;
  58870. /**
  58871. * Constructor
  58872. * @param engine The engine to use
  58873. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  58874. */
  58875. constructor(engine: ThinEngine, numWorkers?: number);
  58876. /** @hidden */
  58877. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  58878. /**
  58879. * Stop all async operations and release resources.
  58880. */
  58881. dispose(): void;
  58882. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  58883. /**
  58884. * Checks if the given data starts with a KTX2 file identifier.
  58885. * @param data the data to check
  58886. * @returns true if the data is a KTX2 file or false otherwise
  58887. */
  58888. static IsValid(data: ArrayBufferView): boolean;
  58889. }
  58890. }
  58891. declare module BABYLON {
  58892. /**
  58893. * Implementation of the KTX Texture Loader.
  58894. * @hidden
  58895. */
  58896. export class _KTXTextureLoader implements IInternalTextureLoader {
  58897. /**
  58898. * Defines wether the loader supports cascade loading the different faces.
  58899. */
  58900. readonly supportCascades: boolean;
  58901. /**
  58902. * This returns if the loader support the current file information.
  58903. * @param extension defines the file extension of the file being loaded
  58904. * @param mimeType defines the optional mime type of the file being loaded
  58905. * @returns true if the loader can load the specified file
  58906. */
  58907. canLoad(extension: string, mimeType?: string): boolean;
  58908. /**
  58909. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58910. * @param data contains the texture data
  58911. * @param texture defines the BabylonJS internal texture
  58912. * @param createPolynomials will be true if polynomials have been requested
  58913. * @param onLoad defines the callback to trigger once the texture is ready
  58914. * @param onError defines the callback to trigger in case of error
  58915. */
  58916. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58917. /**
  58918. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58919. * @param data contains the texture data
  58920. * @param texture defines the BabylonJS internal texture
  58921. * @param callback defines the method to call once ready to upload
  58922. */
  58923. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  58924. }
  58925. }
  58926. declare module BABYLON {
  58927. /** @hidden */
  58928. export var _forceSceneHelpersToBundle: boolean;
  58929. interface Scene {
  58930. /**
  58931. * Creates a default light for the scene.
  58932. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  58933. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  58934. */
  58935. createDefaultLight(replace?: boolean): void;
  58936. /**
  58937. * Creates a default camera for the scene.
  58938. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  58939. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58940. * @param replace has default false, when true replaces the active camera in the scene
  58941. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  58942. */
  58943. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58944. /**
  58945. * Creates a default camera and a default light.
  58946. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  58947. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58948. * @param replace has the default false, when true replaces the active camera/light in the scene
  58949. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  58950. */
  58951. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58952. /**
  58953. * Creates a new sky box
  58954. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  58955. * @param environmentTexture defines the texture to use as environment texture
  58956. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  58957. * @param scale defines the overall scale of the skybox
  58958. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  58959. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  58960. * @returns a new mesh holding the sky box
  58961. */
  58962. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  58963. /**
  58964. * Creates a new environment
  58965. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  58966. * @param options defines the options you can use to configure the environment
  58967. * @returns the new EnvironmentHelper
  58968. */
  58969. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  58970. /**
  58971. * Creates a new VREXperienceHelper
  58972. * @see https://doc.babylonjs.com/how_to/webvr_helper
  58973. * @param webVROptions defines the options used to create the new VREXperienceHelper
  58974. * @returns a new VREXperienceHelper
  58975. */
  58976. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  58977. /**
  58978. * Creates a new WebXRDefaultExperience
  58979. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  58980. * @param options experience options
  58981. * @returns a promise for a new WebXRDefaultExperience
  58982. */
  58983. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  58984. }
  58985. }
  58986. declare module BABYLON {
  58987. /**
  58988. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  58989. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  58990. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  58991. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58992. */
  58993. export class VideoDome extends TextureDome<VideoTexture> {
  58994. /**
  58995. * Define the video source as a Monoscopic panoramic 360 video.
  58996. */
  58997. static readonly MODE_MONOSCOPIC: number;
  58998. /**
  58999. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  59000. */
  59001. static readonly MODE_TOPBOTTOM: number;
  59002. /**
  59003. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  59004. */
  59005. static readonly MODE_SIDEBYSIDE: number;
  59006. /**
  59007. * Get the video texture associated with this video dome
  59008. */
  59009. get videoTexture(): VideoTexture;
  59010. /**
  59011. * Get the video mode of this dome
  59012. */
  59013. get videoMode(): number;
  59014. /**
  59015. * Set the video mode of this dome.
  59016. * @see textureMode
  59017. */
  59018. set videoMode(value: number);
  59019. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  59020. }
  59021. }
  59022. declare module BABYLON {
  59023. /**
  59024. * This class can be used to get instrumentation data from a Babylon engine
  59025. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59026. */
  59027. export class EngineInstrumentation implements IDisposable {
  59028. /**
  59029. * Define the instrumented engine.
  59030. */
  59031. engine: Engine;
  59032. private _captureGPUFrameTime;
  59033. private _gpuFrameTimeToken;
  59034. private _gpuFrameTime;
  59035. private _captureShaderCompilationTime;
  59036. private _shaderCompilationTime;
  59037. private _onBeginFrameObserver;
  59038. private _onEndFrameObserver;
  59039. private _onBeforeShaderCompilationObserver;
  59040. private _onAfterShaderCompilationObserver;
  59041. /**
  59042. * Gets the perf counter used for GPU frame time
  59043. */
  59044. get gpuFrameTimeCounter(): PerfCounter;
  59045. /**
  59046. * Gets the GPU frame time capture status
  59047. */
  59048. get captureGPUFrameTime(): boolean;
  59049. /**
  59050. * Enable or disable the GPU frame time capture
  59051. */
  59052. set captureGPUFrameTime(value: boolean);
  59053. /**
  59054. * Gets the perf counter used for shader compilation time
  59055. */
  59056. get shaderCompilationTimeCounter(): PerfCounter;
  59057. /**
  59058. * Gets the shader compilation time capture status
  59059. */
  59060. get captureShaderCompilationTime(): boolean;
  59061. /**
  59062. * Enable or disable the shader compilation time capture
  59063. */
  59064. set captureShaderCompilationTime(value: boolean);
  59065. /**
  59066. * Instantiates a new engine instrumentation.
  59067. * This class can be used to get instrumentation data from a Babylon engine
  59068. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59069. * @param engine Defines the engine to instrument
  59070. */
  59071. constructor(
  59072. /**
  59073. * Define the instrumented engine.
  59074. */
  59075. engine: Engine);
  59076. /**
  59077. * Dispose and release associated resources.
  59078. */
  59079. dispose(): void;
  59080. }
  59081. }
  59082. declare module BABYLON {
  59083. /**
  59084. * This class can be used to get instrumentation data from a Babylon engine
  59085. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59086. */
  59087. export class SceneInstrumentation implements IDisposable {
  59088. /**
  59089. * Defines the scene to instrument
  59090. */
  59091. scene: Scene;
  59092. private _captureActiveMeshesEvaluationTime;
  59093. private _activeMeshesEvaluationTime;
  59094. private _captureRenderTargetsRenderTime;
  59095. private _renderTargetsRenderTime;
  59096. private _captureFrameTime;
  59097. private _frameTime;
  59098. private _captureRenderTime;
  59099. private _renderTime;
  59100. private _captureInterFrameTime;
  59101. private _interFrameTime;
  59102. private _captureParticlesRenderTime;
  59103. private _particlesRenderTime;
  59104. private _captureSpritesRenderTime;
  59105. private _spritesRenderTime;
  59106. private _capturePhysicsTime;
  59107. private _physicsTime;
  59108. private _captureAnimationsTime;
  59109. private _animationsTime;
  59110. private _captureCameraRenderTime;
  59111. private _cameraRenderTime;
  59112. private _onBeforeActiveMeshesEvaluationObserver;
  59113. private _onAfterActiveMeshesEvaluationObserver;
  59114. private _onBeforeRenderTargetsRenderObserver;
  59115. private _onAfterRenderTargetsRenderObserver;
  59116. private _onAfterRenderObserver;
  59117. private _onBeforeDrawPhaseObserver;
  59118. private _onAfterDrawPhaseObserver;
  59119. private _onBeforeAnimationsObserver;
  59120. private _onBeforeParticlesRenderingObserver;
  59121. private _onAfterParticlesRenderingObserver;
  59122. private _onBeforeSpritesRenderingObserver;
  59123. private _onAfterSpritesRenderingObserver;
  59124. private _onBeforePhysicsObserver;
  59125. private _onAfterPhysicsObserver;
  59126. private _onAfterAnimationsObserver;
  59127. private _onBeforeCameraRenderObserver;
  59128. private _onAfterCameraRenderObserver;
  59129. /**
  59130. * Gets the perf counter used for active meshes evaluation time
  59131. */
  59132. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  59133. /**
  59134. * Gets the active meshes evaluation time capture status
  59135. */
  59136. get captureActiveMeshesEvaluationTime(): boolean;
  59137. /**
  59138. * Enable or disable the active meshes evaluation time capture
  59139. */
  59140. set captureActiveMeshesEvaluationTime(value: boolean);
  59141. /**
  59142. * Gets the perf counter used for render targets render time
  59143. */
  59144. get renderTargetsRenderTimeCounter(): PerfCounter;
  59145. /**
  59146. * Gets the render targets render time capture status
  59147. */
  59148. get captureRenderTargetsRenderTime(): boolean;
  59149. /**
  59150. * Enable or disable the render targets render time capture
  59151. */
  59152. set captureRenderTargetsRenderTime(value: boolean);
  59153. /**
  59154. * Gets the perf counter used for particles render time
  59155. */
  59156. get particlesRenderTimeCounter(): PerfCounter;
  59157. /**
  59158. * Gets the particles render time capture status
  59159. */
  59160. get captureParticlesRenderTime(): boolean;
  59161. /**
  59162. * Enable or disable the particles render time capture
  59163. */
  59164. set captureParticlesRenderTime(value: boolean);
  59165. /**
  59166. * Gets the perf counter used for sprites render time
  59167. */
  59168. get spritesRenderTimeCounter(): PerfCounter;
  59169. /**
  59170. * Gets the sprites render time capture status
  59171. */
  59172. get captureSpritesRenderTime(): boolean;
  59173. /**
  59174. * Enable or disable the sprites render time capture
  59175. */
  59176. set captureSpritesRenderTime(value: boolean);
  59177. /**
  59178. * Gets the perf counter used for physics time
  59179. */
  59180. get physicsTimeCounter(): PerfCounter;
  59181. /**
  59182. * Gets the physics time capture status
  59183. */
  59184. get capturePhysicsTime(): boolean;
  59185. /**
  59186. * Enable or disable the physics time capture
  59187. */
  59188. set capturePhysicsTime(value: boolean);
  59189. /**
  59190. * Gets the perf counter used for animations time
  59191. */
  59192. get animationsTimeCounter(): PerfCounter;
  59193. /**
  59194. * Gets the animations time capture status
  59195. */
  59196. get captureAnimationsTime(): boolean;
  59197. /**
  59198. * Enable or disable the animations time capture
  59199. */
  59200. set captureAnimationsTime(value: boolean);
  59201. /**
  59202. * Gets the perf counter used for frame time capture
  59203. */
  59204. get frameTimeCounter(): PerfCounter;
  59205. /**
  59206. * Gets the frame time capture status
  59207. */
  59208. get captureFrameTime(): boolean;
  59209. /**
  59210. * Enable or disable the frame time capture
  59211. */
  59212. set captureFrameTime(value: boolean);
  59213. /**
  59214. * Gets the perf counter used for inter-frames time capture
  59215. */
  59216. get interFrameTimeCounter(): PerfCounter;
  59217. /**
  59218. * Gets the inter-frames time capture status
  59219. */
  59220. get captureInterFrameTime(): boolean;
  59221. /**
  59222. * Enable or disable the inter-frames time capture
  59223. */
  59224. set captureInterFrameTime(value: boolean);
  59225. /**
  59226. * Gets the perf counter used for render time capture
  59227. */
  59228. get renderTimeCounter(): PerfCounter;
  59229. /**
  59230. * Gets the render time capture status
  59231. */
  59232. get captureRenderTime(): boolean;
  59233. /**
  59234. * Enable or disable the render time capture
  59235. */
  59236. set captureRenderTime(value: boolean);
  59237. /**
  59238. * Gets the perf counter used for camera render time capture
  59239. */
  59240. get cameraRenderTimeCounter(): PerfCounter;
  59241. /**
  59242. * Gets the camera render time capture status
  59243. */
  59244. get captureCameraRenderTime(): boolean;
  59245. /**
  59246. * Enable or disable the camera render time capture
  59247. */
  59248. set captureCameraRenderTime(value: boolean);
  59249. /**
  59250. * Gets the perf counter used for draw calls
  59251. */
  59252. get drawCallsCounter(): PerfCounter;
  59253. /**
  59254. * Instantiates a new scene instrumentation.
  59255. * This class can be used to get instrumentation data from a Babylon engine
  59256. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59257. * @param scene Defines the scene to instrument
  59258. */
  59259. constructor(
  59260. /**
  59261. * Defines the scene to instrument
  59262. */
  59263. scene: Scene);
  59264. /**
  59265. * Dispose and release associated resources.
  59266. */
  59267. dispose(): void;
  59268. }
  59269. }
  59270. declare module BABYLON {
  59271. /** @hidden */
  59272. export var glowMapGenerationPixelShader: {
  59273. name: string;
  59274. shader: string;
  59275. };
  59276. }
  59277. declare module BABYLON {
  59278. /** @hidden */
  59279. export var glowMapGenerationVertexShader: {
  59280. name: string;
  59281. shader: string;
  59282. };
  59283. }
  59284. declare module BABYLON {
  59285. /**
  59286. * Effect layer options. This helps customizing the behaviour
  59287. * of the effect layer.
  59288. */
  59289. export interface IEffectLayerOptions {
  59290. /**
  59291. * Multiplication factor apply to the canvas size to compute the render target size
  59292. * used to generated the objects (the smaller the faster).
  59293. */
  59294. mainTextureRatio: number;
  59295. /**
  59296. * Enforces a fixed size texture to ensure effect stability across devices.
  59297. */
  59298. mainTextureFixedSize?: number;
  59299. /**
  59300. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  59301. */
  59302. alphaBlendingMode: number;
  59303. /**
  59304. * The camera attached to the layer.
  59305. */
  59306. camera: Nullable<Camera>;
  59307. /**
  59308. * The rendering group to draw the layer in.
  59309. */
  59310. renderingGroupId: number;
  59311. }
  59312. /**
  59313. * The effect layer Helps adding post process effect blended with the main pass.
  59314. *
  59315. * This can be for instance use to generate glow or higlight effects on the scene.
  59316. *
  59317. * The effect layer class can not be used directly and is intented to inherited from to be
  59318. * customized per effects.
  59319. */
  59320. export abstract class EffectLayer {
  59321. private _vertexBuffers;
  59322. private _indexBuffer;
  59323. private _cachedDefines;
  59324. private _effectLayerMapGenerationEffect;
  59325. private _effectLayerOptions;
  59326. private _mergeEffect;
  59327. protected _scene: Scene;
  59328. protected _engine: Engine;
  59329. protected _maxSize: number;
  59330. protected _mainTextureDesiredSize: ISize;
  59331. protected _mainTexture: RenderTargetTexture;
  59332. protected _shouldRender: boolean;
  59333. protected _postProcesses: PostProcess[];
  59334. protected _textures: BaseTexture[];
  59335. protected _emissiveTextureAndColor: {
  59336. texture: Nullable<BaseTexture>;
  59337. color: Color4;
  59338. };
  59339. /**
  59340. * The name of the layer
  59341. */
  59342. name: string;
  59343. /**
  59344. * The clear color of the texture used to generate the glow map.
  59345. */
  59346. neutralColor: Color4;
  59347. /**
  59348. * Specifies whether the highlight layer is enabled or not.
  59349. */
  59350. isEnabled: boolean;
  59351. /**
  59352. * Gets the camera attached to the layer.
  59353. */
  59354. get camera(): Nullable<Camera>;
  59355. /**
  59356. * Gets the rendering group id the layer should render in.
  59357. */
  59358. get renderingGroupId(): number;
  59359. set renderingGroupId(renderingGroupId: number);
  59360. /**
  59361. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  59362. */
  59363. disableBoundingBoxesFromEffectLayer: boolean;
  59364. /**
  59365. * An event triggered when the effect layer has been disposed.
  59366. */
  59367. onDisposeObservable: Observable<EffectLayer>;
  59368. /**
  59369. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  59370. */
  59371. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  59372. /**
  59373. * An event triggered when the generated texture is being merged in the scene.
  59374. */
  59375. onBeforeComposeObservable: Observable<EffectLayer>;
  59376. /**
  59377. * An event triggered when the mesh is rendered into the effect render target.
  59378. */
  59379. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  59380. /**
  59381. * An event triggered after the mesh has been rendered into the effect render target.
  59382. */
  59383. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  59384. /**
  59385. * An event triggered when the generated texture has been merged in the scene.
  59386. */
  59387. onAfterComposeObservable: Observable<EffectLayer>;
  59388. /**
  59389. * An event triggered when the efffect layer changes its size.
  59390. */
  59391. onSizeChangedObservable: Observable<EffectLayer>;
  59392. /** @hidden */
  59393. static _SceneComponentInitialization: (scene: Scene) => void;
  59394. /**
  59395. * Instantiates a new effect Layer and references it in the scene.
  59396. * @param name The name of the layer
  59397. * @param scene The scene to use the layer in
  59398. */
  59399. constructor(
  59400. /** The Friendly of the effect in the scene */
  59401. name: string, scene: Scene);
  59402. /**
  59403. * Get the effect name of the layer.
  59404. * @return The effect name
  59405. */
  59406. abstract getEffectName(): string;
  59407. /**
  59408. * Checks for the readiness of the element composing the layer.
  59409. * @param subMesh the mesh to check for
  59410. * @param useInstances specify whether or not to use instances to render the mesh
  59411. * @return true if ready otherwise, false
  59412. */
  59413. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59414. /**
  59415. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59416. * @returns true if the effect requires stencil during the main canvas render pass.
  59417. */
  59418. abstract needStencil(): boolean;
  59419. /**
  59420. * Create the merge effect. This is the shader use to blit the information back
  59421. * to the main canvas at the end of the scene rendering.
  59422. * @returns The effect containing the shader used to merge the effect on the main canvas
  59423. */
  59424. protected abstract _createMergeEffect(): Effect;
  59425. /**
  59426. * Creates the render target textures and post processes used in the effect layer.
  59427. */
  59428. protected abstract _createTextureAndPostProcesses(): void;
  59429. /**
  59430. * Implementation specific of rendering the generating effect on the main canvas.
  59431. * @param effect The effect used to render through
  59432. */
  59433. protected abstract _internalRender(effect: Effect): void;
  59434. /**
  59435. * Sets the required values for both the emissive texture and and the main color.
  59436. */
  59437. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59438. /**
  59439. * Free any resources and references associated to a mesh.
  59440. * Internal use
  59441. * @param mesh The mesh to free.
  59442. */
  59443. abstract _disposeMesh(mesh: Mesh): void;
  59444. /**
  59445. * Serializes this layer (Glow or Highlight for example)
  59446. * @returns a serialized layer object
  59447. */
  59448. abstract serialize?(): any;
  59449. /**
  59450. * Initializes the effect layer with the required options.
  59451. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  59452. */
  59453. protected _init(options: Partial<IEffectLayerOptions>): void;
  59454. /**
  59455. * Generates the index buffer of the full screen quad blending to the main canvas.
  59456. */
  59457. private _generateIndexBuffer;
  59458. /**
  59459. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  59460. */
  59461. private _generateVertexBuffer;
  59462. /**
  59463. * Sets the main texture desired size which is the closest power of two
  59464. * of the engine canvas size.
  59465. */
  59466. private _setMainTextureSize;
  59467. /**
  59468. * Creates the main texture for the effect layer.
  59469. */
  59470. protected _createMainTexture(): void;
  59471. /**
  59472. * Adds specific effects defines.
  59473. * @param defines The defines to add specifics to.
  59474. */
  59475. protected _addCustomEffectDefines(defines: string[]): void;
  59476. /**
  59477. * Checks for the readiness of the element composing the layer.
  59478. * @param subMesh the mesh to check for
  59479. * @param useInstances specify whether or not to use instances to render the mesh
  59480. * @param emissiveTexture the associated emissive texture used to generate the glow
  59481. * @return true if ready otherwise, false
  59482. */
  59483. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  59484. /**
  59485. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  59486. */
  59487. render(): void;
  59488. /**
  59489. * Determine if a given mesh will be used in the current effect.
  59490. * @param mesh mesh to test
  59491. * @returns true if the mesh will be used
  59492. */
  59493. hasMesh(mesh: AbstractMesh): boolean;
  59494. /**
  59495. * Returns true if the layer contains information to display, otherwise false.
  59496. * @returns true if the glow layer should be rendered
  59497. */
  59498. shouldRender(): boolean;
  59499. /**
  59500. * Returns true if the mesh should render, otherwise false.
  59501. * @param mesh The mesh to render
  59502. * @returns true if it should render otherwise false
  59503. */
  59504. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  59505. /**
  59506. * Returns true if the mesh can be rendered, otherwise false.
  59507. * @param mesh The mesh to render
  59508. * @param material The material used on the mesh
  59509. * @returns true if it can be rendered otherwise false
  59510. */
  59511. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59512. /**
  59513. * Returns true if the mesh should render, otherwise false.
  59514. * @param mesh The mesh to render
  59515. * @returns true if it should render otherwise false
  59516. */
  59517. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  59518. /**
  59519. * Renders the submesh passed in parameter to the generation map.
  59520. */
  59521. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  59522. /**
  59523. * Defines whether the current material of the mesh should be use to render the effect.
  59524. * @param mesh defines the current mesh to render
  59525. */
  59526. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59527. /**
  59528. * Rebuild the required buffers.
  59529. * @hidden Internal use only.
  59530. */
  59531. _rebuild(): void;
  59532. /**
  59533. * Dispose only the render target textures and post process.
  59534. */
  59535. private _disposeTextureAndPostProcesses;
  59536. /**
  59537. * Dispose the highlight layer and free resources.
  59538. */
  59539. dispose(): void;
  59540. /**
  59541. * Gets the class name of the effect layer
  59542. * @returns the string with the class name of the effect layer
  59543. */
  59544. getClassName(): string;
  59545. /**
  59546. * Creates an effect layer from parsed effect layer data
  59547. * @param parsedEffectLayer defines effect layer data
  59548. * @param scene defines the current scene
  59549. * @param rootUrl defines the root URL containing the effect layer information
  59550. * @returns a parsed effect Layer
  59551. */
  59552. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  59553. }
  59554. }
  59555. declare module BABYLON {
  59556. interface AbstractScene {
  59557. /**
  59558. * The list of effect layers (highlights/glow) added to the scene
  59559. * @see https://doc.babylonjs.com/how_to/highlight_layer
  59560. * @see https://doc.babylonjs.com/how_to/glow_layer
  59561. */
  59562. effectLayers: Array<EffectLayer>;
  59563. /**
  59564. * Removes the given effect layer from this scene.
  59565. * @param toRemove defines the effect layer to remove
  59566. * @returns the index of the removed effect layer
  59567. */
  59568. removeEffectLayer(toRemove: EffectLayer): number;
  59569. /**
  59570. * Adds the given effect layer to this scene
  59571. * @param newEffectLayer defines the effect layer to add
  59572. */
  59573. addEffectLayer(newEffectLayer: EffectLayer): void;
  59574. }
  59575. /**
  59576. * Defines the layer scene component responsible to manage any effect layers
  59577. * in a given scene.
  59578. */
  59579. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  59580. /**
  59581. * The component name helpfull to identify the component in the list of scene components.
  59582. */
  59583. readonly name: string;
  59584. /**
  59585. * The scene the component belongs to.
  59586. */
  59587. scene: Scene;
  59588. private _engine;
  59589. private _renderEffects;
  59590. private _needStencil;
  59591. private _previousStencilState;
  59592. /**
  59593. * Creates a new instance of the component for the given scene
  59594. * @param scene Defines the scene to register the component in
  59595. */
  59596. constructor(scene: Scene);
  59597. /**
  59598. * Registers the component in a given scene
  59599. */
  59600. register(): void;
  59601. /**
  59602. * Rebuilds the elements related to this component in case of
  59603. * context lost for instance.
  59604. */
  59605. rebuild(): void;
  59606. /**
  59607. * Serializes the component data to the specified json object
  59608. * @param serializationObject The object to serialize to
  59609. */
  59610. serialize(serializationObject: any): void;
  59611. /**
  59612. * Adds all the elements from the container to the scene
  59613. * @param container the container holding the elements
  59614. */
  59615. addFromContainer(container: AbstractScene): void;
  59616. /**
  59617. * Removes all the elements in the container from the scene
  59618. * @param container contains the elements to remove
  59619. * @param dispose if the removed element should be disposed (default: false)
  59620. */
  59621. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59622. /**
  59623. * Disposes the component and the associated ressources.
  59624. */
  59625. dispose(): void;
  59626. private _isReadyForMesh;
  59627. private _renderMainTexture;
  59628. private _setStencil;
  59629. private _setStencilBack;
  59630. private _draw;
  59631. private _drawCamera;
  59632. private _drawRenderingGroup;
  59633. }
  59634. }
  59635. declare module BABYLON {
  59636. /** @hidden */
  59637. export var glowMapMergePixelShader: {
  59638. name: string;
  59639. shader: string;
  59640. };
  59641. }
  59642. declare module BABYLON {
  59643. /** @hidden */
  59644. export var glowMapMergeVertexShader: {
  59645. name: string;
  59646. shader: string;
  59647. };
  59648. }
  59649. declare module BABYLON {
  59650. interface AbstractScene {
  59651. /**
  59652. * Return a the first highlight layer of the scene with a given name.
  59653. * @param name The name of the highlight layer to look for.
  59654. * @return The highlight layer if found otherwise null.
  59655. */
  59656. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  59657. }
  59658. /**
  59659. * Glow layer options. This helps customizing the behaviour
  59660. * of the glow layer.
  59661. */
  59662. export interface IGlowLayerOptions {
  59663. /**
  59664. * Multiplication factor apply to the canvas size to compute the render target size
  59665. * used to generated the glowing objects (the smaller the faster).
  59666. */
  59667. mainTextureRatio: number;
  59668. /**
  59669. * Enforces a fixed size texture to ensure resize independant blur.
  59670. */
  59671. mainTextureFixedSize?: number;
  59672. /**
  59673. * How big is the kernel of the blur texture.
  59674. */
  59675. blurKernelSize: number;
  59676. /**
  59677. * The camera attached to the layer.
  59678. */
  59679. camera: Nullable<Camera>;
  59680. /**
  59681. * Enable MSAA by chosing the number of samples.
  59682. */
  59683. mainTextureSamples?: number;
  59684. /**
  59685. * The rendering group to draw the layer in.
  59686. */
  59687. renderingGroupId: number;
  59688. }
  59689. /**
  59690. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  59691. *
  59692. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  59693. *
  59694. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  59695. */
  59696. export class GlowLayer extends EffectLayer {
  59697. /**
  59698. * Effect Name of the layer.
  59699. */
  59700. static readonly EffectName: string;
  59701. /**
  59702. * The default blur kernel size used for the glow.
  59703. */
  59704. static DefaultBlurKernelSize: number;
  59705. /**
  59706. * The default texture size ratio used for the glow.
  59707. */
  59708. static DefaultTextureRatio: number;
  59709. /**
  59710. * Sets the kernel size of the blur.
  59711. */
  59712. set blurKernelSize(value: number);
  59713. /**
  59714. * Gets the kernel size of the blur.
  59715. */
  59716. get blurKernelSize(): number;
  59717. /**
  59718. * Sets the glow intensity.
  59719. */
  59720. set intensity(value: number);
  59721. /**
  59722. * Gets the glow intensity.
  59723. */
  59724. get intensity(): number;
  59725. private _options;
  59726. private _intensity;
  59727. private _horizontalBlurPostprocess1;
  59728. private _verticalBlurPostprocess1;
  59729. private _horizontalBlurPostprocess2;
  59730. private _verticalBlurPostprocess2;
  59731. private _blurTexture1;
  59732. private _blurTexture2;
  59733. private _postProcesses1;
  59734. private _postProcesses2;
  59735. private _includedOnlyMeshes;
  59736. private _excludedMeshes;
  59737. private _meshesUsingTheirOwnMaterials;
  59738. /**
  59739. * Callback used to let the user override the color selection on a per mesh basis
  59740. */
  59741. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  59742. /**
  59743. * Callback used to let the user override the texture selection on a per mesh basis
  59744. */
  59745. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  59746. /**
  59747. * Instantiates a new glow Layer and references it to the scene.
  59748. * @param name The name of the layer
  59749. * @param scene The scene to use the layer in
  59750. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  59751. */
  59752. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  59753. /**
  59754. * Get the effect name of the layer.
  59755. * @return The effect name
  59756. */
  59757. getEffectName(): string;
  59758. /**
  59759. * Create the merge effect. This is the shader use to blit the information back
  59760. * to the main canvas at the end of the scene rendering.
  59761. */
  59762. protected _createMergeEffect(): Effect;
  59763. /**
  59764. * Creates the render target textures and post processes used in the glow layer.
  59765. */
  59766. protected _createTextureAndPostProcesses(): void;
  59767. /**
  59768. * Checks for the readiness of the element composing the layer.
  59769. * @param subMesh the mesh to check for
  59770. * @param useInstances specify wether or not to use instances to render the mesh
  59771. * @param emissiveTexture the associated emissive texture used to generate the glow
  59772. * @return true if ready otherwise, false
  59773. */
  59774. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59775. /**
  59776. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59777. */
  59778. needStencil(): boolean;
  59779. /**
  59780. * Returns true if the mesh can be rendered, otherwise false.
  59781. * @param mesh The mesh to render
  59782. * @param material The material used on the mesh
  59783. * @returns true if it can be rendered otherwise false
  59784. */
  59785. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59786. /**
  59787. * Implementation specific of rendering the generating effect on the main canvas.
  59788. * @param effect The effect used to render through
  59789. */
  59790. protected _internalRender(effect: Effect): void;
  59791. /**
  59792. * Sets the required values for both the emissive texture and and the main color.
  59793. */
  59794. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59795. /**
  59796. * Returns true if the mesh should render, otherwise false.
  59797. * @param mesh The mesh to render
  59798. * @returns true if it should render otherwise false
  59799. */
  59800. protected _shouldRenderMesh(mesh: Mesh): boolean;
  59801. /**
  59802. * Adds specific effects defines.
  59803. * @param defines The defines to add specifics to.
  59804. */
  59805. protected _addCustomEffectDefines(defines: string[]): void;
  59806. /**
  59807. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  59808. * @param mesh The mesh to exclude from the glow layer
  59809. */
  59810. addExcludedMesh(mesh: Mesh): void;
  59811. /**
  59812. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  59813. * @param mesh The mesh to remove
  59814. */
  59815. removeExcludedMesh(mesh: Mesh): void;
  59816. /**
  59817. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  59818. * @param mesh The mesh to include in the glow layer
  59819. */
  59820. addIncludedOnlyMesh(mesh: Mesh): void;
  59821. /**
  59822. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  59823. * @param mesh The mesh to remove
  59824. */
  59825. removeIncludedOnlyMesh(mesh: Mesh): void;
  59826. /**
  59827. * Determine if a given mesh will be used in the glow layer
  59828. * @param mesh The mesh to test
  59829. * @returns true if the mesh will be highlighted by the current glow layer
  59830. */
  59831. hasMesh(mesh: AbstractMesh): boolean;
  59832. /**
  59833. * Defines whether the current material of the mesh should be use to render the effect.
  59834. * @param mesh defines the current mesh to render
  59835. */
  59836. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59837. /**
  59838. * Add a mesh to be rendered through its own material and not with emissive only.
  59839. * @param mesh The mesh for which we need to use its material
  59840. */
  59841. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  59842. /**
  59843. * Remove a mesh from being rendered through its own material and not with emissive only.
  59844. * @param mesh The mesh for which we need to not use its material
  59845. */
  59846. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  59847. /**
  59848. * Free any resources and references associated to a mesh.
  59849. * Internal use
  59850. * @param mesh The mesh to free.
  59851. * @hidden
  59852. */
  59853. _disposeMesh(mesh: Mesh): void;
  59854. /**
  59855. * Gets the class name of the effect layer
  59856. * @returns the string with the class name of the effect layer
  59857. */
  59858. getClassName(): string;
  59859. /**
  59860. * Serializes this glow layer
  59861. * @returns a serialized glow layer object
  59862. */
  59863. serialize(): any;
  59864. /**
  59865. * Creates a Glow Layer from parsed glow layer data
  59866. * @param parsedGlowLayer defines glow layer data
  59867. * @param scene defines the current scene
  59868. * @param rootUrl defines the root URL containing the glow layer information
  59869. * @returns a parsed Glow Layer
  59870. */
  59871. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  59872. }
  59873. }
  59874. declare module BABYLON {
  59875. /** @hidden */
  59876. export var glowBlurPostProcessPixelShader: {
  59877. name: string;
  59878. shader: string;
  59879. };
  59880. }
  59881. declare module BABYLON {
  59882. interface AbstractScene {
  59883. /**
  59884. * Return a the first highlight layer of the scene with a given name.
  59885. * @param name The name of the highlight layer to look for.
  59886. * @return The highlight layer if found otherwise null.
  59887. */
  59888. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  59889. }
  59890. /**
  59891. * Highlight layer options. This helps customizing the behaviour
  59892. * of the highlight layer.
  59893. */
  59894. export interface IHighlightLayerOptions {
  59895. /**
  59896. * Multiplication factor apply to the canvas size to compute the render target size
  59897. * used to generated the glowing objects (the smaller the faster).
  59898. */
  59899. mainTextureRatio: number;
  59900. /**
  59901. * Enforces a fixed size texture to ensure resize independant blur.
  59902. */
  59903. mainTextureFixedSize?: number;
  59904. /**
  59905. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  59906. * of the picture to blur (the smaller the faster).
  59907. */
  59908. blurTextureSizeRatio: number;
  59909. /**
  59910. * How big in texel of the blur texture is the vertical blur.
  59911. */
  59912. blurVerticalSize: number;
  59913. /**
  59914. * How big in texel of the blur texture is the horizontal blur.
  59915. */
  59916. blurHorizontalSize: number;
  59917. /**
  59918. * Alpha blending mode used to apply the blur. Default is combine.
  59919. */
  59920. alphaBlendingMode: number;
  59921. /**
  59922. * The camera attached to the layer.
  59923. */
  59924. camera: Nullable<Camera>;
  59925. /**
  59926. * Should we display highlight as a solid stroke?
  59927. */
  59928. isStroke?: boolean;
  59929. /**
  59930. * The rendering group to draw the layer in.
  59931. */
  59932. renderingGroupId: number;
  59933. }
  59934. /**
  59935. * The highlight layer Helps adding a glow effect around a mesh.
  59936. *
  59937. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  59938. * glowy meshes to your scene.
  59939. *
  59940. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  59941. */
  59942. export class HighlightLayer extends EffectLayer {
  59943. name: string;
  59944. /**
  59945. * Effect Name of the highlight layer.
  59946. */
  59947. static readonly EffectName: string;
  59948. /**
  59949. * The neutral color used during the preparation of the glow effect.
  59950. * This is black by default as the blend operation is a blend operation.
  59951. */
  59952. static NeutralColor: Color4;
  59953. /**
  59954. * Stencil value used for glowing meshes.
  59955. */
  59956. static GlowingMeshStencilReference: number;
  59957. /**
  59958. * Stencil value used for the other meshes in the scene.
  59959. */
  59960. static NormalMeshStencilReference: number;
  59961. /**
  59962. * Specifies whether or not the inner glow is ACTIVE in the layer.
  59963. */
  59964. innerGlow: boolean;
  59965. /**
  59966. * Specifies whether or not the outer glow is ACTIVE in the layer.
  59967. */
  59968. outerGlow: boolean;
  59969. /**
  59970. * Specifies the horizontal size of the blur.
  59971. */
  59972. set blurHorizontalSize(value: number);
  59973. /**
  59974. * Specifies the vertical size of the blur.
  59975. */
  59976. set blurVerticalSize(value: number);
  59977. /**
  59978. * Gets the horizontal size of the blur.
  59979. */
  59980. get blurHorizontalSize(): number;
  59981. /**
  59982. * Gets the vertical size of the blur.
  59983. */
  59984. get blurVerticalSize(): number;
  59985. /**
  59986. * An event triggered when the highlight layer is being blurred.
  59987. */
  59988. onBeforeBlurObservable: Observable<HighlightLayer>;
  59989. /**
  59990. * An event triggered when the highlight layer has been blurred.
  59991. */
  59992. onAfterBlurObservable: Observable<HighlightLayer>;
  59993. private _instanceGlowingMeshStencilReference;
  59994. private _options;
  59995. private _downSamplePostprocess;
  59996. private _horizontalBlurPostprocess;
  59997. private _verticalBlurPostprocess;
  59998. private _blurTexture;
  59999. private _meshes;
  60000. private _excludedMeshes;
  60001. /**
  60002. * Instantiates a new highlight Layer and references it to the scene..
  60003. * @param name The name of the layer
  60004. * @param scene The scene to use the layer in
  60005. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  60006. */
  60007. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  60008. /**
  60009. * Get the effect name of the layer.
  60010. * @return The effect name
  60011. */
  60012. getEffectName(): string;
  60013. /**
  60014. * Create the merge effect. This is the shader use to blit the information back
  60015. * to the main canvas at the end of the scene rendering.
  60016. */
  60017. protected _createMergeEffect(): Effect;
  60018. /**
  60019. * Creates the render target textures and post processes used in the highlight layer.
  60020. */
  60021. protected _createTextureAndPostProcesses(): void;
  60022. /**
  60023. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  60024. */
  60025. needStencil(): boolean;
  60026. /**
  60027. * Checks for the readiness of the element composing the layer.
  60028. * @param subMesh the mesh to check for
  60029. * @param useInstances specify wether or not to use instances to render the mesh
  60030. * @param emissiveTexture the associated emissive texture used to generate the glow
  60031. * @return true if ready otherwise, false
  60032. */
  60033. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60034. /**
  60035. * Implementation specific of rendering the generating effect on the main canvas.
  60036. * @param effect The effect used to render through
  60037. */
  60038. protected _internalRender(effect: Effect): void;
  60039. /**
  60040. * Returns true if the layer contains information to display, otherwise false.
  60041. */
  60042. shouldRender(): boolean;
  60043. /**
  60044. * Returns true if the mesh should render, otherwise false.
  60045. * @param mesh The mesh to render
  60046. * @returns true if it should render otherwise false
  60047. */
  60048. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60049. /**
  60050. * Returns true if the mesh can be rendered, otherwise false.
  60051. * @param mesh The mesh to render
  60052. * @param material The material used on the mesh
  60053. * @returns true if it can be rendered otherwise false
  60054. */
  60055. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60056. /**
  60057. * Adds specific effects defines.
  60058. * @param defines The defines to add specifics to.
  60059. */
  60060. protected _addCustomEffectDefines(defines: string[]): void;
  60061. /**
  60062. * Sets the required values for both the emissive texture and and the main color.
  60063. */
  60064. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60065. /**
  60066. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  60067. * @param mesh The mesh to exclude from the highlight layer
  60068. */
  60069. addExcludedMesh(mesh: Mesh): void;
  60070. /**
  60071. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  60072. * @param mesh The mesh to highlight
  60073. */
  60074. removeExcludedMesh(mesh: Mesh): void;
  60075. /**
  60076. * Determine if a given mesh will be highlighted by the current HighlightLayer
  60077. * @param mesh mesh to test
  60078. * @returns true if the mesh will be highlighted by the current HighlightLayer
  60079. */
  60080. hasMesh(mesh: AbstractMesh): boolean;
  60081. /**
  60082. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  60083. * @param mesh The mesh to highlight
  60084. * @param color The color of the highlight
  60085. * @param glowEmissiveOnly Extract the glow from the emissive texture
  60086. */
  60087. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  60088. /**
  60089. * Remove a mesh from the highlight layer in order to make it stop glowing.
  60090. * @param mesh The mesh to highlight
  60091. */
  60092. removeMesh(mesh: Mesh): void;
  60093. /**
  60094. * Remove all the meshes currently referenced in the highlight layer
  60095. */
  60096. removeAllMeshes(): void;
  60097. /**
  60098. * Force the stencil to the normal expected value for none glowing parts
  60099. */
  60100. private _defaultStencilReference;
  60101. /**
  60102. * Free any resources and references associated to a mesh.
  60103. * Internal use
  60104. * @param mesh The mesh to free.
  60105. * @hidden
  60106. */
  60107. _disposeMesh(mesh: Mesh): void;
  60108. /**
  60109. * Dispose the highlight layer and free resources.
  60110. */
  60111. dispose(): void;
  60112. /**
  60113. * Gets the class name of the effect layer
  60114. * @returns the string with the class name of the effect layer
  60115. */
  60116. getClassName(): string;
  60117. /**
  60118. * Serializes this Highlight layer
  60119. * @returns a serialized Highlight layer object
  60120. */
  60121. serialize(): any;
  60122. /**
  60123. * Creates a Highlight layer from parsed Highlight layer data
  60124. * @param parsedHightlightLayer defines the Highlight layer data
  60125. * @param scene defines the current scene
  60126. * @param rootUrl defines the root URL containing the Highlight layer information
  60127. * @returns a parsed Highlight layer
  60128. */
  60129. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  60130. }
  60131. }
  60132. declare module BABYLON {
  60133. interface AbstractScene {
  60134. /**
  60135. * The list of layers (background and foreground) of the scene
  60136. */
  60137. layers: Array<Layer>;
  60138. }
  60139. /**
  60140. * Defines the layer scene component responsible to manage any layers
  60141. * in a given scene.
  60142. */
  60143. export class LayerSceneComponent implements ISceneComponent {
  60144. /**
  60145. * The component name helpfull to identify the component in the list of scene components.
  60146. */
  60147. readonly name: string;
  60148. /**
  60149. * The scene the component belongs to.
  60150. */
  60151. scene: Scene;
  60152. private _engine;
  60153. /**
  60154. * Creates a new instance of the component for the given scene
  60155. * @param scene Defines the scene to register the component in
  60156. */
  60157. constructor(scene: Scene);
  60158. /**
  60159. * Registers the component in a given scene
  60160. */
  60161. register(): void;
  60162. /**
  60163. * Rebuilds the elements related to this component in case of
  60164. * context lost for instance.
  60165. */
  60166. rebuild(): void;
  60167. /**
  60168. * Disposes the component and the associated ressources.
  60169. */
  60170. dispose(): void;
  60171. private _draw;
  60172. private _drawCameraPredicate;
  60173. private _drawCameraBackground;
  60174. private _drawCameraForeground;
  60175. private _drawRenderTargetPredicate;
  60176. private _drawRenderTargetBackground;
  60177. private _drawRenderTargetForeground;
  60178. /**
  60179. * Adds all the elements from the container to the scene
  60180. * @param container the container holding the elements
  60181. */
  60182. addFromContainer(container: AbstractScene): void;
  60183. /**
  60184. * Removes all the elements in the container from the scene
  60185. * @param container contains the elements to remove
  60186. * @param dispose if the removed element should be disposed (default: false)
  60187. */
  60188. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60189. }
  60190. }
  60191. declare module BABYLON {
  60192. /** @hidden */
  60193. export var layerPixelShader: {
  60194. name: string;
  60195. shader: string;
  60196. };
  60197. }
  60198. declare module BABYLON {
  60199. /** @hidden */
  60200. export var layerVertexShader: {
  60201. name: string;
  60202. shader: string;
  60203. };
  60204. }
  60205. declare module BABYLON {
  60206. /**
  60207. * This represents a full screen 2d layer.
  60208. * This can be useful to display a picture in the background of your scene for instance.
  60209. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60210. */
  60211. export class Layer {
  60212. /**
  60213. * Define the name of the layer.
  60214. */
  60215. name: string;
  60216. /**
  60217. * Define the texture the layer should display.
  60218. */
  60219. texture: Nullable<Texture>;
  60220. /**
  60221. * Is the layer in background or foreground.
  60222. */
  60223. isBackground: boolean;
  60224. /**
  60225. * Define the color of the layer (instead of texture).
  60226. */
  60227. color: Color4;
  60228. /**
  60229. * Define the scale of the layer in order to zoom in out of the texture.
  60230. */
  60231. scale: Vector2;
  60232. /**
  60233. * Define an offset for the layer in order to shift the texture.
  60234. */
  60235. offset: Vector2;
  60236. /**
  60237. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  60238. */
  60239. alphaBlendingMode: number;
  60240. /**
  60241. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  60242. * Alpha test will not mix with the background color in case of transparency.
  60243. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  60244. */
  60245. alphaTest: boolean;
  60246. /**
  60247. * Define a mask to restrict the layer to only some of the scene cameras.
  60248. */
  60249. layerMask: number;
  60250. /**
  60251. * Define the list of render target the layer is visible into.
  60252. */
  60253. renderTargetTextures: RenderTargetTexture[];
  60254. /**
  60255. * Define if the layer is only used in renderTarget or if it also
  60256. * renders in the main frame buffer of the canvas.
  60257. */
  60258. renderOnlyInRenderTargetTextures: boolean;
  60259. private _scene;
  60260. private _vertexBuffers;
  60261. private _indexBuffer;
  60262. private _effect;
  60263. private _previousDefines;
  60264. /**
  60265. * An event triggered when the layer is disposed.
  60266. */
  60267. onDisposeObservable: Observable<Layer>;
  60268. private _onDisposeObserver;
  60269. /**
  60270. * Back compatibility with callback before the onDisposeObservable existed.
  60271. * The set callback will be triggered when the layer has been disposed.
  60272. */
  60273. set onDispose(callback: () => void);
  60274. /**
  60275. * An event triggered before rendering the scene
  60276. */
  60277. onBeforeRenderObservable: Observable<Layer>;
  60278. private _onBeforeRenderObserver;
  60279. /**
  60280. * Back compatibility with callback before the onBeforeRenderObservable existed.
  60281. * The set callback will be triggered just before rendering the layer.
  60282. */
  60283. set onBeforeRender(callback: () => void);
  60284. /**
  60285. * An event triggered after rendering the scene
  60286. */
  60287. onAfterRenderObservable: Observable<Layer>;
  60288. private _onAfterRenderObserver;
  60289. /**
  60290. * Back compatibility with callback before the onAfterRenderObservable existed.
  60291. * The set callback will be triggered just after rendering the layer.
  60292. */
  60293. set onAfterRender(callback: () => void);
  60294. /**
  60295. * Instantiates a new layer.
  60296. * This represents a full screen 2d layer.
  60297. * This can be useful to display a picture in the background of your scene for instance.
  60298. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60299. * @param name Define the name of the layer in the scene
  60300. * @param imgUrl Define the url of the texture to display in the layer
  60301. * @param scene Define the scene the layer belongs to
  60302. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  60303. * @param color Defines a color for the layer
  60304. */
  60305. constructor(
  60306. /**
  60307. * Define the name of the layer.
  60308. */
  60309. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  60310. private _createIndexBuffer;
  60311. /** @hidden */
  60312. _rebuild(): void;
  60313. /**
  60314. * Renders the layer in the scene.
  60315. */
  60316. render(): void;
  60317. /**
  60318. * Disposes and releases the associated ressources.
  60319. */
  60320. dispose(): void;
  60321. }
  60322. }
  60323. declare module BABYLON {
  60324. /** @hidden */
  60325. export var lensFlarePixelShader: {
  60326. name: string;
  60327. shader: string;
  60328. };
  60329. }
  60330. declare module BABYLON {
  60331. /** @hidden */
  60332. export var lensFlareVertexShader: {
  60333. name: string;
  60334. shader: string;
  60335. };
  60336. }
  60337. declare module BABYLON {
  60338. /**
  60339. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60340. * It is usually composed of several `lensFlare`.
  60341. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60342. */
  60343. export class LensFlareSystem {
  60344. /**
  60345. * Define the name of the lens flare system
  60346. */
  60347. name: string;
  60348. /**
  60349. * List of lens flares used in this system.
  60350. */
  60351. lensFlares: LensFlare[];
  60352. /**
  60353. * Define a limit from the border the lens flare can be visible.
  60354. */
  60355. borderLimit: number;
  60356. /**
  60357. * Define a viewport border we do not want to see the lens flare in.
  60358. */
  60359. viewportBorder: number;
  60360. /**
  60361. * Define a predicate which could limit the list of meshes able to occlude the effect.
  60362. */
  60363. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  60364. /**
  60365. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  60366. */
  60367. layerMask: number;
  60368. /**
  60369. * Define the id of the lens flare system in the scene.
  60370. * (equal to name by default)
  60371. */
  60372. id: string;
  60373. private _scene;
  60374. private _emitter;
  60375. private _vertexBuffers;
  60376. private _indexBuffer;
  60377. private _effect;
  60378. private _positionX;
  60379. private _positionY;
  60380. private _isEnabled;
  60381. /** @hidden */
  60382. static _SceneComponentInitialization: (scene: Scene) => void;
  60383. /**
  60384. * Instantiates a lens flare system.
  60385. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60386. * It is usually composed of several `lensFlare`.
  60387. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60388. * @param name Define the name of the lens flare system in the scene
  60389. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  60390. * @param scene Define the scene the lens flare system belongs to
  60391. */
  60392. constructor(
  60393. /**
  60394. * Define the name of the lens flare system
  60395. */
  60396. name: string, emitter: any, scene: Scene);
  60397. /**
  60398. * Define if the lens flare system is enabled.
  60399. */
  60400. get isEnabled(): boolean;
  60401. set isEnabled(value: boolean);
  60402. /**
  60403. * Get the scene the effects belongs to.
  60404. * @returns the scene holding the lens flare system
  60405. */
  60406. getScene(): Scene;
  60407. /**
  60408. * Get the emitter of the lens flare system.
  60409. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60410. * @returns the emitter of the lens flare system
  60411. */
  60412. getEmitter(): any;
  60413. /**
  60414. * Set the emitter of the lens flare system.
  60415. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60416. * @param newEmitter Define the new emitter of the system
  60417. */
  60418. setEmitter(newEmitter: any): void;
  60419. /**
  60420. * Get the lens flare system emitter position.
  60421. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  60422. * @returns the position
  60423. */
  60424. getEmitterPosition(): Vector3;
  60425. /**
  60426. * @hidden
  60427. */
  60428. computeEffectivePosition(globalViewport: Viewport): boolean;
  60429. /** @hidden */
  60430. _isVisible(): boolean;
  60431. /**
  60432. * @hidden
  60433. */
  60434. render(): boolean;
  60435. /**
  60436. * Dispose and release the lens flare with its associated resources.
  60437. */
  60438. dispose(): void;
  60439. /**
  60440. * Parse a lens flare system from a JSON repressentation
  60441. * @param parsedLensFlareSystem Define the JSON to parse
  60442. * @param scene Define the scene the parsed system should be instantiated in
  60443. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  60444. * @returns the parsed system
  60445. */
  60446. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  60447. /**
  60448. * Serialize the current Lens Flare System into a JSON representation.
  60449. * @returns the serialized JSON
  60450. */
  60451. serialize(): any;
  60452. }
  60453. }
  60454. declare module BABYLON {
  60455. /**
  60456. * This represents one of the lens effect in a `lensFlareSystem`.
  60457. * It controls one of the indiviual texture used in the effect.
  60458. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60459. */
  60460. export class LensFlare {
  60461. /**
  60462. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60463. */
  60464. size: number;
  60465. /**
  60466. * 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.
  60467. */
  60468. position: number;
  60469. /**
  60470. * Define the lens color.
  60471. */
  60472. color: Color3;
  60473. /**
  60474. * Define the lens texture.
  60475. */
  60476. texture: Nullable<Texture>;
  60477. /**
  60478. * Define the alpha mode to render this particular lens.
  60479. */
  60480. alphaMode: number;
  60481. private _system;
  60482. /**
  60483. * Creates a new Lens Flare.
  60484. * This represents one of the lens effect in a `lensFlareSystem`.
  60485. * It controls one of the indiviual texture used in the effect.
  60486. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60487. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  60488. * @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.
  60489. * @param color Define the lens color
  60490. * @param imgUrl Define the lens texture url
  60491. * @param system Define the `lensFlareSystem` this flare is part of
  60492. * @returns The newly created Lens Flare
  60493. */
  60494. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  60495. /**
  60496. * Instantiates a new Lens Flare.
  60497. * This represents one of the lens effect in a `lensFlareSystem`.
  60498. * It controls one of the indiviual texture used in the effect.
  60499. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60500. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  60501. * @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.
  60502. * @param color Define the lens color
  60503. * @param imgUrl Define the lens texture url
  60504. * @param system Define the `lensFlareSystem` this flare is part of
  60505. */
  60506. constructor(
  60507. /**
  60508. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60509. */
  60510. size: number,
  60511. /**
  60512. * 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.
  60513. */
  60514. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  60515. /**
  60516. * Dispose and release the lens flare with its associated resources.
  60517. */
  60518. dispose(): void;
  60519. }
  60520. }
  60521. declare module BABYLON {
  60522. interface AbstractScene {
  60523. /**
  60524. * The list of lens flare system added to the scene
  60525. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60526. */
  60527. lensFlareSystems: Array<LensFlareSystem>;
  60528. /**
  60529. * Removes the given lens flare system from this scene.
  60530. * @param toRemove The lens flare system to remove
  60531. * @returns The index of the removed lens flare system
  60532. */
  60533. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  60534. /**
  60535. * Adds the given lens flare system to this scene
  60536. * @param newLensFlareSystem The lens flare system to add
  60537. */
  60538. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  60539. /**
  60540. * Gets a lens flare system using its name
  60541. * @param name defines the name to look for
  60542. * @returns the lens flare system or null if not found
  60543. */
  60544. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  60545. /**
  60546. * Gets a lens flare system using its id
  60547. * @param id defines the id to look for
  60548. * @returns the lens flare system or null if not found
  60549. */
  60550. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  60551. }
  60552. /**
  60553. * Defines the lens flare scene component responsible to manage any lens flares
  60554. * in a given scene.
  60555. */
  60556. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  60557. /**
  60558. * The component name helpfull to identify the component in the list of scene components.
  60559. */
  60560. readonly name: string;
  60561. /**
  60562. * The scene the component belongs to.
  60563. */
  60564. scene: Scene;
  60565. /**
  60566. * Creates a new instance of the component for the given scene
  60567. * @param scene Defines the scene to register the component in
  60568. */
  60569. constructor(scene: Scene);
  60570. /**
  60571. * Registers the component in a given scene
  60572. */
  60573. register(): void;
  60574. /**
  60575. * Rebuilds the elements related to this component in case of
  60576. * context lost for instance.
  60577. */
  60578. rebuild(): void;
  60579. /**
  60580. * Adds all the elements from the container to the scene
  60581. * @param container the container holding the elements
  60582. */
  60583. addFromContainer(container: AbstractScene): void;
  60584. /**
  60585. * Removes all the elements in the container from the scene
  60586. * @param container contains the elements to remove
  60587. * @param dispose if the removed element should be disposed (default: false)
  60588. */
  60589. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60590. /**
  60591. * Serializes the component data to the specified json object
  60592. * @param serializationObject The object to serialize to
  60593. */
  60594. serialize(serializationObject: any): void;
  60595. /**
  60596. * Disposes the component and the associated ressources.
  60597. */
  60598. dispose(): void;
  60599. private _draw;
  60600. }
  60601. }
  60602. declare module BABYLON {
  60603. /** @hidden */
  60604. export var depthPixelShader: {
  60605. name: string;
  60606. shader: string;
  60607. };
  60608. }
  60609. declare module BABYLON {
  60610. /** @hidden */
  60611. export var depthVertexShader: {
  60612. name: string;
  60613. shader: string;
  60614. };
  60615. }
  60616. declare module BABYLON {
  60617. /**
  60618. * This represents a depth renderer in Babylon.
  60619. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60620. */
  60621. export class DepthRenderer {
  60622. private _scene;
  60623. private _depthMap;
  60624. private _effect;
  60625. private readonly _storeNonLinearDepth;
  60626. private readonly _clearColor;
  60627. /** Get if the depth renderer is using packed depth or not */
  60628. readonly isPacked: boolean;
  60629. private _cachedDefines;
  60630. private _camera;
  60631. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  60632. enabled: boolean;
  60633. /**
  60634. * Specifiess that the depth renderer will only be used within
  60635. * the camera it is created for.
  60636. * This can help forcing its rendering during the camera processing.
  60637. */
  60638. useOnlyInActiveCamera: boolean;
  60639. /** @hidden */
  60640. static _SceneComponentInitialization: (scene: Scene) => void;
  60641. /**
  60642. * Instantiates a depth renderer
  60643. * @param scene The scene the renderer belongs to
  60644. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60645. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60646. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60647. */
  60648. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  60649. /**
  60650. * Creates the depth rendering effect and checks if the effect is ready.
  60651. * @param subMesh The submesh to be used to render the depth map of
  60652. * @param useInstances If multiple world instances should be used
  60653. * @returns if the depth renderer is ready to render the depth map
  60654. */
  60655. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60656. /**
  60657. * Gets the texture which the depth map will be written to.
  60658. * @returns The depth map texture
  60659. */
  60660. getDepthMap(): RenderTargetTexture;
  60661. /**
  60662. * Disposes of the depth renderer.
  60663. */
  60664. dispose(): void;
  60665. }
  60666. }
  60667. declare module BABYLON {
  60668. /** @hidden */
  60669. export var minmaxReduxPixelShader: {
  60670. name: string;
  60671. shader: string;
  60672. };
  60673. }
  60674. declare module BABYLON {
  60675. /**
  60676. * This class computes a min/max reduction from a texture: it means it computes the minimum
  60677. * and maximum values from all values of the texture.
  60678. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  60679. * The source values are read from the red channel of the texture.
  60680. */
  60681. export class MinMaxReducer {
  60682. /**
  60683. * Observable triggered when the computation has been performed
  60684. */
  60685. onAfterReductionPerformed: Observable<{
  60686. min: number;
  60687. max: number;
  60688. }>;
  60689. protected _camera: Camera;
  60690. protected _sourceTexture: Nullable<RenderTargetTexture>;
  60691. protected _reductionSteps: Nullable<Array<PostProcess>>;
  60692. protected _postProcessManager: PostProcessManager;
  60693. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  60694. protected _forceFullscreenViewport: boolean;
  60695. /**
  60696. * Creates a min/max reducer
  60697. * @param camera The camera to use for the post processes
  60698. */
  60699. constructor(camera: Camera);
  60700. /**
  60701. * Gets the texture used to read the values from.
  60702. */
  60703. get sourceTexture(): Nullable<RenderTargetTexture>;
  60704. /**
  60705. * Sets the source texture to read the values from.
  60706. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  60707. * because in such textures '1' value must not be taken into account to compute the maximum
  60708. * as this value is used to clear the texture.
  60709. * Note that the computation is not activated by calling this function, you must call activate() for that!
  60710. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  60711. * @param depthRedux Indicates if the texture is a depth texture or not
  60712. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  60713. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  60714. */
  60715. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60716. /**
  60717. * Defines the refresh rate of the computation.
  60718. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  60719. */
  60720. get refreshRate(): number;
  60721. set refreshRate(value: number);
  60722. protected _activated: boolean;
  60723. /**
  60724. * Gets the activation status of the reducer
  60725. */
  60726. get activated(): boolean;
  60727. /**
  60728. * Activates the reduction computation.
  60729. * When activated, the observers registered in onAfterReductionPerformed are
  60730. * called after the compuation is performed
  60731. */
  60732. activate(): void;
  60733. /**
  60734. * Deactivates the reduction computation.
  60735. */
  60736. deactivate(): void;
  60737. /**
  60738. * Disposes the min/max reducer
  60739. * @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.
  60740. */
  60741. dispose(disposeAll?: boolean): void;
  60742. }
  60743. }
  60744. declare module BABYLON {
  60745. /**
  60746. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  60747. */
  60748. export class DepthReducer extends MinMaxReducer {
  60749. private _depthRenderer;
  60750. private _depthRendererId;
  60751. /**
  60752. * Gets the depth renderer used for the computation.
  60753. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  60754. */
  60755. get depthRenderer(): Nullable<DepthRenderer>;
  60756. /**
  60757. * Creates a depth reducer
  60758. * @param camera The camera used to render the depth texture
  60759. */
  60760. constructor(camera: Camera);
  60761. /**
  60762. * Sets the depth renderer to use to generate the depth map
  60763. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  60764. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  60765. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  60766. */
  60767. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  60768. /** @hidden */
  60769. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60770. /**
  60771. * Activates the reduction computation.
  60772. * When activated, the observers registered in onAfterReductionPerformed are
  60773. * called after the compuation is performed
  60774. */
  60775. activate(): void;
  60776. /**
  60777. * Deactivates the reduction computation.
  60778. */
  60779. deactivate(): void;
  60780. /**
  60781. * Disposes the depth reducer
  60782. * @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.
  60783. */
  60784. dispose(disposeAll?: boolean): void;
  60785. }
  60786. }
  60787. declare module BABYLON {
  60788. /**
  60789. * A CSM implementation allowing casting shadows on large scenes.
  60790. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  60791. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  60792. */
  60793. export class CascadedShadowGenerator extends ShadowGenerator {
  60794. private static readonly frustumCornersNDCSpace;
  60795. /**
  60796. * Name of the CSM class
  60797. */
  60798. static CLASSNAME: string;
  60799. /**
  60800. * Defines the default number of cascades used by the CSM.
  60801. */
  60802. static readonly DEFAULT_CASCADES_COUNT: number;
  60803. /**
  60804. * Defines the minimum number of cascades used by the CSM.
  60805. */
  60806. static readonly MIN_CASCADES_COUNT: number;
  60807. /**
  60808. * Defines the maximum number of cascades used by the CSM.
  60809. */
  60810. static readonly MAX_CASCADES_COUNT: number;
  60811. protected _validateFilter(filter: number): number;
  60812. /**
  60813. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  60814. */
  60815. penumbraDarkness: number;
  60816. private _numCascades;
  60817. /**
  60818. * Gets or set the number of cascades used by the CSM.
  60819. */
  60820. get numCascades(): number;
  60821. set numCascades(value: number);
  60822. /**
  60823. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  60824. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  60825. */
  60826. stabilizeCascades: boolean;
  60827. private _freezeShadowCastersBoundingInfo;
  60828. private _freezeShadowCastersBoundingInfoObservable;
  60829. /**
  60830. * Enables or disables the shadow casters bounding info computation.
  60831. * If your shadow casters don't move, you can disable this feature.
  60832. * If it is enabled, the bounding box computation is done every frame.
  60833. */
  60834. get freezeShadowCastersBoundingInfo(): boolean;
  60835. set freezeShadowCastersBoundingInfo(freeze: boolean);
  60836. private _scbiMin;
  60837. private _scbiMax;
  60838. protected _computeShadowCastersBoundingInfo(): void;
  60839. protected _shadowCastersBoundingInfo: BoundingInfo;
  60840. /**
  60841. * Gets or sets the shadow casters bounding info.
  60842. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  60843. * so that the system won't overwrite the bounds you provide
  60844. */
  60845. get shadowCastersBoundingInfo(): BoundingInfo;
  60846. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  60847. protected _breaksAreDirty: boolean;
  60848. protected _minDistance: number;
  60849. protected _maxDistance: number;
  60850. /**
  60851. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  60852. *
  60853. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  60854. * If you don't know these values, simply leave them to their defaults and don't call this function.
  60855. * @param min minimal distance for the breaks (default to 0.)
  60856. * @param max maximal distance for the breaks (default to 1.)
  60857. */
  60858. setMinMaxDistance(min: number, max: number): void;
  60859. /** Gets the minimal distance used in the cascade break computation */
  60860. get minDistance(): number;
  60861. /** Gets the maximal distance used in the cascade break computation */
  60862. get maxDistance(): number;
  60863. /**
  60864. * Gets the class name of that object
  60865. * @returns "CascadedShadowGenerator"
  60866. */
  60867. getClassName(): string;
  60868. private _cascadeMinExtents;
  60869. private _cascadeMaxExtents;
  60870. /**
  60871. * Gets a cascade minimum extents
  60872. * @param cascadeIndex index of the cascade
  60873. * @returns the minimum cascade extents
  60874. */
  60875. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  60876. /**
  60877. * Gets a cascade maximum extents
  60878. * @param cascadeIndex index of the cascade
  60879. * @returns the maximum cascade extents
  60880. */
  60881. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  60882. private _cascades;
  60883. private _currentLayer;
  60884. private _viewSpaceFrustumsZ;
  60885. private _viewMatrices;
  60886. private _projectionMatrices;
  60887. private _transformMatrices;
  60888. private _transformMatricesAsArray;
  60889. private _frustumLengths;
  60890. private _lightSizeUVCorrection;
  60891. private _depthCorrection;
  60892. private _frustumCornersWorldSpace;
  60893. private _frustumCenter;
  60894. private _shadowCameraPos;
  60895. private _shadowMaxZ;
  60896. /**
  60897. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  60898. * It defaults to camera.maxZ
  60899. */
  60900. get shadowMaxZ(): number;
  60901. /**
  60902. * Sets the shadow max z distance.
  60903. */
  60904. set shadowMaxZ(value: number);
  60905. protected _debug: boolean;
  60906. /**
  60907. * Gets or sets the debug flag.
  60908. * When enabled, the cascades are materialized by different colors on the screen.
  60909. */
  60910. get debug(): boolean;
  60911. set debug(dbg: boolean);
  60912. private _depthClamp;
  60913. /**
  60914. * Gets or sets the depth clamping value.
  60915. *
  60916. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  60917. * to account for the shadow casters far away.
  60918. *
  60919. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  60920. */
  60921. get depthClamp(): boolean;
  60922. set depthClamp(value: boolean);
  60923. private _cascadeBlendPercentage;
  60924. /**
  60925. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  60926. * It defaults to 0.1 (10% blending).
  60927. */
  60928. get cascadeBlendPercentage(): number;
  60929. set cascadeBlendPercentage(value: number);
  60930. private _lambda;
  60931. /**
  60932. * Gets or set the lambda parameter.
  60933. * This parameter is used to split the camera frustum and create the cascades.
  60934. * 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.
  60935. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  60936. */
  60937. get lambda(): number;
  60938. set lambda(value: number);
  60939. /**
  60940. * Gets the view matrix corresponding to a given cascade
  60941. * @param cascadeNum cascade to retrieve the view matrix from
  60942. * @returns the cascade view matrix
  60943. */
  60944. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  60945. /**
  60946. * Gets the projection matrix corresponding to a given cascade
  60947. * @param cascadeNum cascade to retrieve the projection matrix from
  60948. * @returns the cascade projection matrix
  60949. */
  60950. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  60951. /**
  60952. * Gets the transformation matrix corresponding to a given cascade
  60953. * @param cascadeNum cascade to retrieve the transformation matrix from
  60954. * @returns the cascade transformation matrix
  60955. */
  60956. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  60957. private _depthRenderer;
  60958. /**
  60959. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  60960. *
  60961. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  60962. *
  60963. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  60964. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  60965. * @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
  60966. */
  60967. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  60968. private _depthReducer;
  60969. private _autoCalcDepthBounds;
  60970. /**
  60971. * Gets or sets the autoCalcDepthBounds property.
  60972. *
  60973. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  60974. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  60975. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  60976. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  60977. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  60978. */
  60979. get autoCalcDepthBounds(): boolean;
  60980. set autoCalcDepthBounds(value: boolean);
  60981. /**
  60982. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  60983. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  60984. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  60985. * for setting the refresh rate on the renderer yourself!
  60986. */
  60987. get autoCalcDepthBoundsRefreshRate(): number;
  60988. set autoCalcDepthBoundsRefreshRate(value: number);
  60989. /**
  60990. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  60991. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  60992. * you change the camera near/far planes!
  60993. */
  60994. splitFrustum(): void;
  60995. private _splitFrustum;
  60996. private _computeMatrices;
  60997. private _computeFrustumInWorldSpace;
  60998. private _computeCascadeFrustum;
  60999. /**
  61000. * Support test.
  61001. */
  61002. static get IsSupported(): boolean;
  61003. /** @hidden */
  61004. static _SceneComponentInitialization: (scene: Scene) => void;
  61005. /**
  61006. * Creates a Cascaded Shadow Generator object.
  61007. * A ShadowGenerator is the required tool to use the shadows.
  61008. * Each directional light casting shadows needs to use its own ShadowGenerator.
  61009. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61010. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  61011. * @param light The directional light object generating the shadows.
  61012. * @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.
  61013. */
  61014. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  61015. protected _initializeGenerator(): void;
  61016. protected _createTargetRenderTexture(): void;
  61017. protected _initializeShadowMap(): void;
  61018. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  61019. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  61020. /**
  61021. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  61022. * @param defines Defines of the material we want to update
  61023. * @param lightIndex Index of the light in the enabled light list of the material
  61024. */
  61025. prepareDefines(defines: any, lightIndex: number): void;
  61026. /**
  61027. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  61028. * defined in the generator but impacting the effect).
  61029. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  61030. * @param effect The effect we are binfing the information for
  61031. */
  61032. bindShadowLight(lightIndex: string, effect: Effect): void;
  61033. /**
  61034. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  61035. * (eq to view projection * shadow projection matrices)
  61036. * @returns The transform matrix used to create the shadow map
  61037. */
  61038. getTransformMatrix(): Matrix;
  61039. /**
  61040. * Disposes the ShadowGenerator.
  61041. * Returns nothing.
  61042. */
  61043. dispose(): void;
  61044. /**
  61045. * Serializes the shadow generator setup to a json object.
  61046. * @returns The serialized JSON object
  61047. */
  61048. serialize(): any;
  61049. /**
  61050. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  61051. * @param parsedShadowGenerator The JSON object to parse
  61052. * @param scene The scene to create the shadow map for
  61053. * @returns The parsed shadow generator
  61054. */
  61055. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  61056. }
  61057. }
  61058. declare module BABYLON {
  61059. /**
  61060. * Defines the shadow generator component responsible to manage any shadow generators
  61061. * in a given scene.
  61062. */
  61063. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  61064. /**
  61065. * The component name helpfull to identify the component in the list of scene components.
  61066. */
  61067. readonly name: string;
  61068. /**
  61069. * The scene the component belongs to.
  61070. */
  61071. scene: Scene;
  61072. /**
  61073. * Creates a new instance of the component for the given scene
  61074. * @param scene Defines the scene to register the component in
  61075. */
  61076. constructor(scene: Scene);
  61077. /**
  61078. * Registers the component in a given scene
  61079. */
  61080. register(): void;
  61081. /**
  61082. * Rebuilds the elements related to this component in case of
  61083. * context lost for instance.
  61084. */
  61085. rebuild(): void;
  61086. /**
  61087. * Serializes the component data to the specified json object
  61088. * @param serializationObject The object to serialize to
  61089. */
  61090. serialize(serializationObject: any): void;
  61091. /**
  61092. * Adds all the elements from the container to the scene
  61093. * @param container the container holding the elements
  61094. */
  61095. addFromContainer(container: AbstractScene): void;
  61096. /**
  61097. * Removes all the elements in the container from the scene
  61098. * @param container contains the elements to remove
  61099. * @param dispose if the removed element should be disposed (default: false)
  61100. */
  61101. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61102. /**
  61103. * Rebuilds the elements related to this component in case of
  61104. * context lost for instance.
  61105. */
  61106. dispose(): void;
  61107. private _gatherRenderTargets;
  61108. }
  61109. }
  61110. declare module BABYLON {
  61111. /**
  61112. * A point light is a light defined by an unique point in world space.
  61113. * The light is emitted in every direction from this point.
  61114. * A good example of a point light is a standard light bulb.
  61115. * Documentation: https://doc.babylonjs.com/babylon101/lights
  61116. */
  61117. export class PointLight extends ShadowLight {
  61118. private _shadowAngle;
  61119. /**
  61120. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61121. * This specifies what angle the shadow will use to be created.
  61122. *
  61123. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61124. */
  61125. get shadowAngle(): number;
  61126. /**
  61127. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61128. * This specifies what angle the shadow will use to be created.
  61129. *
  61130. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61131. */
  61132. set shadowAngle(value: number);
  61133. /**
  61134. * Gets the direction if it has been set.
  61135. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61136. */
  61137. get direction(): Vector3;
  61138. /**
  61139. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61140. */
  61141. set direction(value: Vector3);
  61142. /**
  61143. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  61144. * A PointLight emits the light in every direction.
  61145. * It can cast shadows.
  61146. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  61147. * ```javascript
  61148. * var pointLight = new PointLight("pl", camera.position, scene);
  61149. * ```
  61150. * Documentation : https://doc.babylonjs.com/babylon101/lights
  61151. * @param name The light friendly name
  61152. * @param position The position of the point light in the scene
  61153. * @param scene The scene the lights belongs to
  61154. */
  61155. constructor(name: string, position: Vector3, scene: Scene);
  61156. /**
  61157. * Returns the string "PointLight"
  61158. * @returns the class name
  61159. */
  61160. getClassName(): string;
  61161. /**
  61162. * Returns the integer 0.
  61163. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  61164. */
  61165. getTypeID(): number;
  61166. /**
  61167. * Specifies wether or not the shadowmap should be a cube texture.
  61168. * @returns true if the shadowmap needs to be a cube texture.
  61169. */
  61170. needCube(): boolean;
  61171. /**
  61172. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  61173. * @param faceIndex The index of the face we are computed the direction to generate shadow
  61174. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  61175. */
  61176. getShadowDirection(faceIndex?: number): Vector3;
  61177. /**
  61178. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  61179. * - fov = PI / 2
  61180. * - aspect ratio : 1.0
  61181. * - z-near and far equal to the active camera minZ and maxZ.
  61182. * Returns the PointLight.
  61183. */
  61184. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61185. protected _buildUniformLayout(): void;
  61186. /**
  61187. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  61188. * @param effect The effect to update
  61189. * @param lightIndex The index of the light in the effect to update
  61190. * @returns The point light
  61191. */
  61192. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  61193. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  61194. /**
  61195. * Prepares the list of defines specific to the light type.
  61196. * @param defines the list of defines
  61197. * @param lightIndex defines the index of the light for the effect
  61198. */
  61199. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  61200. }
  61201. }
  61202. declare module BABYLON {
  61203. /**
  61204. * Header information of HDR texture files.
  61205. */
  61206. export interface HDRInfo {
  61207. /**
  61208. * The height of the texture in pixels.
  61209. */
  61210. height: number;
  61211. /**
  61212. * The width of the texture in pixels.
  61213. */
  61214. width: number;
  61215. /**
  61216. * The index of the beginning of the data in the binary file.
  61217. */
  61218. dataPosition: number;
  61219. }
  61220. /**
  61221. * This groups tools to convert HDR texture to native colors array.
  61222. */
  61223. export class HDRTools {
  61224. private static Ldexp;
  61225. private static Rgbe2float;
  61226. private static readStringLine;
  61227. /**
  61228. * Reads header information from an RGBE texture stored in a native array.
  61229. * More information on this format are available here:
  61230. * https://en.wikipedia.org/wiki/RGBE_image_format
  61231. *
  61232. * @param uint8array The binary file stored in native array.
  61233. * @return The header information.
  61234. */
  61235. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  61236. /**
  61237. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  61238. * This RGBE texture needs to store the information as a panorama.
  61239. *
  61240. * More information on this format are available here:
  61241. * https://en.wikipedia.org/wiki/RGBE_image_format
  61242. *
  61243. * @param buffer The binary file stored in an array buffer.
  61244. * @param size The expected size of the extracted cubemap.
  61245. * @return The Cube Map information.
  61246. */
  61247. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  61248. /**
  61249. * Returns the pixels data extracted from an RGBE texture.
  61250. * This pixels will be stored left to right up to down in the R G B order in one array.
  61251. *
  61252. * More information on this format are available here:
  61253. * https://en.wikipedia.org/wiki/RGBE_image_format
  61254. *
  61255. * @param uint8array The binary file stored in an array buffer.
  61256. * @param hdrInfo The header information of the file.
  61257. * @return The pixels data in RGB right to left up to down order.
  61258. */
  61259. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  61260. private static RGBE_ReadPixels_RLE;
  61261. private static RGBE_ReadPixels_NOT_RLE;
  61262. }
  61263. }
  61264. declare module BABYLON {
  61265. /**
  61266. * Effect Render Options
  61267. */
  61268. export interface IEffectRendererOptions {
  61269. /**
  61270. * Defines the vertices positions.
  61271. */
  61272. positions?: number[];
  61273. /**
  61274. * Defines the indices.
  61275. */
  61276. indices?: number[];
  61277. }
  61278. /**
  61279. * Helper class to render one or more effects.
  61280. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  61281. */
  61282. export class EffectRenderer {
  61283. private engine;
  61284. private static _DefaultOptions;
  61285. private _vertexBuffers;
  61286. private _indexBuffer;
  61287. private _fullscreenViewport;
  61288. /**
  61289. * Creates an effect renderer
  61290. * @param engine the engine to use for rendering
  61291. * @param options defines the options of the effect renderer
  61292. */
  61293. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  61294. /**
  61295. * Sets the current viewport in normalized coordinates 0-1
  61296. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  61297. */
  61298. setViewport(viewport?: Viewport): void;
  61299. /**
  61300. * Binds the embedded attributes buffer to the effect.
  61301. * @param effect Defines the effect to bind the attributes for
  61302. */
  61303. bindBuffers(effect: Effect): void;
  61304. /**
  61305. * Sets the current effect wrapper to use during draw.
  61306. * The effect needs to be ready before calling this api.
  61307. * This also sets the default full screen position attribute.
  61308. * @param effectWrapper Defines the effect to draw with
  61309. */
  61310. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  61311. /**
  61312. * Restores engine states
  61313. */
  61314. restoreStates(): void;
  61315. /**
  61316. * Draws a full screen quad.
  61317. */
  61318. draw(): void;
  61319. private isRenderTargetTexture;
  61320. /**
  61321. * renders one or more effects to a specified texture
  61322. * @param effectWrapper the effect to renderer
  61323. * @param outputTexture texture to draw to, if null it will render to the screen.
  61324. */
  61325. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  61326. /**
  61327. * Disposes of the effect renderer
  61328. */
  61329. dispose(): void;
  61330. }
  61331. /**
  61332. * Options to create an EffectWrapper
  61333. */
  61334. interface EffectWrapperCreationOptions {
  61335. /**
  61336. * Engine to use to create the effect
  61337. */
  61338. engine: ThinEngine;
  61339. /**
  61340. * Fragment shader for the effect
  61341. */
  61342. fragmentShader: string;
  61343. /**
  61344. * Use the shader store instead of direct source code
  61345. */
  61346. useShaderStore?: boolean;
  61347. /**
  61348. * Vertex shader for the effect
  61349. */
  61350. vertexShader?: string;
  61351. /**
  61352. * Attributes to use in the shader
  61353. */
  61354. attributeNames?: Array<string>;
  61355. /**
  61356. * Uniforms to use in the shader
  61357. */
  61358. uniformNames?: Array<string>;
  61359. /**
  61360. * Texture sampler names to use in the shader
  61361. */
  61362. samplerNames?: Array<string>;
  61363. /**
  61364. * Defines to use in the shader
  61365. */
  61366. defines?: Array<string>;
  61367. /**
  61368. * Callback when effect is compiled
  61369. */
  61370. onCompiled?: Nullable<(effect: Effect) => void>;
  61371. /**
  61372. * The friendly name of the effect displayed in Spector.
  61373. */
  61374. name?: string;
  61375. }
  61376. /**
  61377. * Wraps an effect to be used for rendering
  61378. */
  61379. export class EffectWrapper {
  61380. /**
  61381. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61382. */
  61383. onApplyObservable: Observable<{}>;
  61384. /**
  61385. * The underlying effect
  61386. */
  61387. effect: Effect;
  61388. /**
  61389. * Creates an effect to be renderer
  61390. * @param creationOptions options to create the effect
  61391. */
  61392. constructor(creationOptions: EffectWrapperCreationOptions);
  61393. /**
  61394. * Disposes of the effect wrapper
  61395. */
  61396. dispose(): void;
  61397. }
  61398. }
  61399. declare module BABYLON {
  61400. /** @hidden */
  61401. export var hdrFilteringVertexShader: {
  61402. name: string;
  61403. shader: string;
  61404. };
  61405. }
  61406. declare module BABYLON {
  61407. /** @hidden */
  61408. export var hdrFilteringPixelShader: {
  61409. name: string;
  61410. shader: string;
  61411. };
  61412. }
  61413. declare module BABYLON {
  61414. /**
  61415. * Options for texture filtering
  61416. */
  61417. interface IHDRFilteringOptions {
  61418. /**
  61419. * Scales pixel intensity for the input HDR map.
  61420. */
  61421. hdrScale?: number;
  61422. /**
  61423. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  61424. */
  61425. quality?: number;
  61426. }
  61427. /**
  61428. * Filters HDR maps to get correct renderings of PBR reflections
  61429. */
  61430. export class HDRFiltering {
  61431. private _engine;
  61432. private _effectRenderer;
  61433. private _effectWrapper;
  61434. private _lodGenerationOffset;
  61435. private _lodGenerationScale;
  61436. /**
  61437. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  61438. * you care about baking speed.
  61439. */
  61440. quality: number;
  61441. /**
  61442. * Scales pixel intensity for the input HDR map.
  61443. */
  61444. hdrScale: number;
  61445. /**
  61446. * Instantiates HDR filter for reflection maps
  61447. *
  61448. * @param engine Thin engine
  61449. * @param options Options
  61450. */
  61451. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  61452. private _createRenderTarget;
  61453. private _prefilterInternal;
  61454. private _createEffect;
  61455. /**
  61456. * Get a value indicating if the filter is ready to be used
  61457. * @param texture Texture to filter
  61458. * @returns true if the filter is ready
  61459. */
  61460. isReady(texture: BaseTexture): boolean;
  61461. /**
  61462. * Prefilters a cube texture to have mipmap levels representing roughness values.
  61463. * Prefiltering will be invoked at the end of next rendering pass.
  61464. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  61465. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  61466. * @param texture Texture to filter
  61467. * @param onFinished Callback when filtering is done
  61468. * @return Promise called when prefiltering is done
  61469. */
  61470. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  61471. }
  61472. }
  61473. declare module BABYLON {
  61474. /**
  61475. * This represents a texture coming from an HDR input.
  61476. *
  61477. * The only supported format is currently panorama picture stored in RGBE format.
  61478. * Example of such files can be found on HDRLib: http://hdrlib.com/
  61479. */
  61480. export class HDRCubeTexture extends BaseTexture {
  61481. private static _facesMapping;
  61482. private _generateHarmonics;
  61483. private _noMipmap;
  61484. private _prefilterOnLoad;
  61485. private _textureMatrix;
  61486. private _size;
  61487. private _onLoad;
  61488. private _onError;
  61489. /**
  61490. * The texture URL.
  61491. */
  61492. url: string;
  61493. protected _isBlocking: boolean;
  61494. /**
  61495. * Sets wether or not the texture is blocking during loading.
  61496. */
  61497. set isBlocking(value: boolean);
  61498. /**
  61499. * Gets wether or not the texture is blocking during loading.
  61500. */
  61501. get isBlocking(): boolean;
  61502. protected _rotationY: number;
  61503. /**
  61504. * Sets texture matrix rotation angle around Y axis in radians.
  61505. */
  61506. set rotationY(value: number);
  61507. /**
  61508. * Gets texture matrix rotation angle around Y axis radians.
  61509. */
  61510. get rotationY(): number;
  61511. /**
  61512. * Gets or sets the center of the bounding box associated with the cube texture
  61513. * It must define where the camera used to render the texture was set
  61514. */
  61515. boundingBoxPosition: Vector3;
  61516. private _boundingBoxSize;
  61517. /**
  61518. * Gets or sets the size of the bounding box associated with the cube texture
  61519. * When defined, the cubemap will switch to local mode
  61520. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  61521. * @example https://www.babylonjs-playground.com/#RNASML
  61522. */
  61523. set boundingBoxSize(value: Vector3);
  61524. get boundingBoxSize(): Vector3;
  61525. /**
  61526. * Instantiates an HDRTexture from the following parameters.
  61527. *
  61528. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  61529. * @param sceneOrEngine The scene or engine the texture will be used in
  61530. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61531. * @param noMipmap Forces to not generate the mipmap if true
  61532. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  61533. * @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)
  61534. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  61535. */
  61536. 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>);
  61537. /**
  61538. * Get the current class name of the texture useful for serialization or dynamic coding.
  61539. * @returns "HDRCubeTexture"
  61540. */
  61541. getClassName(): string;
  61542. /**
  61543. * Occurs when the file is raw .hdr file.
  61544. */
  61545. private loadTexture;
  61546. clone(): HDRCubeTexture;
  61547. delayLoad(): void;
  61548. /**
  61549. * Get the texture reflection matrix used to rotate/transform the reflection.
  61550. * @returns the reflection matrix
  61551. */
  61552. getReflectionTextureMatrix(): Matrix;
  61553. /**
  61554. * Set the texture reflection matrix used to rotate/transform the reflection.
  61555. * @param value Define the reflection matrix to set
  61556. */
  61557. setReflectionTextureMatrix(value: Matrix): void;
  61558. /**
  61559. * Parses a JSON representation of an HDR Texture in order to create the texture
  61560. * @param parsedTexture Define the JSON representation
  61561. * @param scene Define the scene the texture should be created in
  61562. * @param rootUrl Define the root url in case we need to load relative dependencies
  61563. * @returns the newly created texture after parsing
  61564. */
  61565. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  61566. serialize(): any;
  61567. }
  61568. }
  61569. declare module BABYLON {
  61570. /**
  61571. * Class used to control physics engine
  61572. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  61573. */
  61574. export class PhysicsEngine implements IPhysicsEngine {
  61575. private _physicsPlugin;
  61576. /**
  61577. * Global value used to control the smallest number supported by the simulation
  61578. */
  61579. static Epsilon: number;
  61580. private _impostors;
  61581. private _joints;
  61582. private _subTimeStep;
  61583. /**
  61584. * Gets the gravity vector used by the simulation
  61585. */
  61586. gravity: Vector3;
  61587. /**
  61588. * Factory used to create the default physics plugin.
  61589. * @returns The default physics plugin
  61590. */
  61591. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  61592. /**
  61593. * Creates a new Physics Engine
  61594. * @param gravity defines the gravity vector used by the simulation
  61595. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  61596. */
  61597. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  61598. /**
  61599. * Sets the gravity vector used by the simulation
  61600. * @param gravity defines the gravity vector to use
  61601. */
  61602. setGravity(gravity: Vector3): void;
  61603. /**
  61604. * Set the time step of the physics engine.
  61605. * Default is 1/60.
  61606. * To slow it down, enter 1/600 for example.
  61607. * To speed it up, 1/30
  61608. * @param newTimeStep defines the new timestep to apply to this world.
  61609. */
  61610. setTimeStep(newTimeStep?: number): void;
  61611. /**
  61612. * Get the time step of the physics engine.
  61613. * @returns the current time step
  61614. */
  61615. getTimeStep(): number;
  61616. /**
  61617. * Set the sub time step of the physics engine.
  61618. * Default is 0 meaning there is no sub steps
  61619. * To increase physics resolution precision, set a small value (like 1 ms)
  61620. * @param subTimeStep defines the new sub timestep used for physics resolution.
  61621. */
  61622. setSubTimeStep(subTimeStep?: number): void;
  61623. /**
  61624. * Get the sub time step of the physics engine.
  61625. * @returns the current sub time step
  61626. */
  61627. getSubTimeStep(): number;
  61628. /**
  61629. * Release all resources
  61630. */
  61631. dispose(): void;
  61632. /**
  61633. * Gets the name of the current physics plugin
  61634. * @returns the name of the plugin
  61635. */
  61636. getPhysicsPluginName(): string;
  61637. /**
  61638. * Adding a new impostor for the impostor tracking.
  61639. * This will be done by the impostor itself.
  61640. * @param impostor the impostor to add
  61641. */
  61642. addImpostor(impostor: PhysicsImpostor): void;
  61643. /**
  61644. * Remove an impostor from the engine.
  61645. * This impostor and its mesh will not longer be updated by the physics engine.
  61646. * @param impostor the impostor to remove
  61647. */
  61648. removeImpostor(impostor: PhysicsImpostor): void;
  61649. /**
  61650. * Add a joint to the physics engine
  61651. * @param mainImpostor defines the main impostor to which the joint is added.
  61652. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  61653. * @param joint defines the joint that will connect both impostors.
  61654. */
  61655. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61656. /**
  61657. * Removes a joint from the simulation
  61658. * @param mainImpostor defines the impostor used with the joint
  61659. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  61660. * @param joint defines the joint to remove
  61661. */
  61662. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61663. /**
  61664. * Called by the scene. No need to call it.
  61665. * @param delta defines the timespam between frames
  61666. */
  61667. _step(delta: number): void;
  61668. /**
  61669. * Gets the current plugin used to run the simulation
  61670. * @returns current plugin
  61671. */
  61672. getPhysicsPlugin(): IPhysicsEnginePlugin;
  61673. /**
  61674. * Gets the list of physic impostors
  61675. * @returns an array of PhysicsImpostor
  61676. */
  61677. getImpostors(): Array<PhysicsImpostor>;
  61678. /**
  61679. * Gets the impostor for a physics enabled object
  61680. * @param object defines the object impersonated by the impostor
  61681. * @returns the PhysicsImpostor or null if not found
  61682. */
  61683. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  61684. /**
  61685. * Gets the impostor for a physics body object
  61686. * @param body defines physics body used by the impostor
  61687. * @returns the PhysicsImpostor or null if not found
  61688. */
  61689. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  61690. /**
  61691. * Does a raycast in the physics world
  61692. * @param from when should the ray start?
  61693. * @param to when should the ray end?
  61694. * @returns PhysicsRaycastResult
  61695. */
  61696. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61697. }
  61698. }
  61699. declare module BABYLON {
  61700. /** @hidden */
  61701. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  61702. private _useDeltaForWorldStep;
  61703. world: any;
  61704. name: string;
  61705. private _physicsMaterials;
  61706. private _fixedTimeStep;
  61707. private _cannonRaycastResult;
  61708. private _raycastResult;
  61709. private _physicsBodysToRemoveAfterStep;
  61710. private _firstFrame;
  61711. BJSCANNON: any;
  61712. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  61713. setGravity(gravity: Vector3): void;
  61714. setTimeStep(timeStep: number): void;
  61715. getTimeStep(): number;
  61716. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61717. private _removeMarkedPhysicsBodiesFromWorld;
  61718. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61719. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61720. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61721. private _processChildMeshes;
  61722. removePhysicsBody(impostor: PhysicsImpostor): void;
  61723. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61724. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61725. private _addMaterial;
  61726. private _checkWithEpsilon;
  61727. private _createShape;
  61728. private _createHeightmap;
  61729. private _minus90X;
  61730. private _plus90X;
  61731. private _tmpPosition;
  61732. private _tmpDeltaPosition;
  61733. private _tmpUnityRotation;
  61734. private _updatePhysicsBodyTransformation;
  61735. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61736. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61737. isSupported(): boolean;
  61738. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61739. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61740. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61741. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61742. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61743. getBodyMass(impostor: PhysicsImpostor): number;
  61744. getBodyFriction(impostor: PhysicsImpostor): number;
  61745. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61746. getBodyRestitution(impostor: PhysicsImpostor): number;
  61747. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61748. sleepBody(impostor: PhysicsImpostor): void;
  61749. wakeUpBody(impostor: PhysicsImpostor): void;
  61750. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  61751. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  61752. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  61753. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61754. getRadius(impostor: PhysicsImpostor): number;
  61755. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61756. dispose(): void;
  61757. private _extendNamespace;
  61758. /**
  61759. * Does a raycast in the physics world
  61760. * @param from when should the ray start?
  61761. * @param to when should the ray end?
  61762. * @returns PhysicsRaycastResult
  61763. */
  61764. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61765. }
  61766. }
  61767. declare module BABYLON {
  61768. /** @hidden */
  61769. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  61770. private _useDeltaForWorldStep;
  61771. world: any;
  61772. name: string;
  61773. BJSOIMO: any;
  61774. private _raycastResult;
  61775. private _fixedTimeStep;
  61776. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  61777. setGravity(gravity: Vector3): void;
  61778. setTimeStep(timeStep: number): void;
  61779. getTimeStep(): number;
  61780. private _tmpImpostorsArray;
  61781. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61782. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61783. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61784. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61785. private _tmpPositionVector;
  61786. removePhysicsBody(impostor: PhysicsImpostor): void;
  61787. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61788. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61789. isSupported(): boolean;
  61790. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61791. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61792. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61793. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61794. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61795. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61796. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61797. getBodyMass(impostor: PhysicsImpostor): number;
  61798. getBodyFriction(impostor: PhysicsImpostor): number;
  61799. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61800. getBodyRestitution(impostor: PhysicsImpostor): number;
  61801. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61802. sleepBody(impostor: PhysicsImpostor): void;
  61803. wakeUpBody(impostor: PhysicsImpostor): void;
  61804. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  61805. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  61806. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  61807. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61808. getRadius(impostor: PhysicsImpostor): number;
  61809. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61810. dispose(): void;
  61811. /**
  61812. * Does a raycast in the physics world
  61813. * @param from when should the ray start?
  61814. * @param to when should the ray end?
  61815. * @returns PhysicsRaycastResult
  61816. */
  61817. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61818. }
  61819. }
  61820. declare module BABYLON {
  61821. /**
  61822. * AmmoJS Physics plugin
  61823. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  61824. * @see https://github.com/kripken/ammo.js/
  61825. */
  61826. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  61827. private _useDeltaForWorldStep;
  61828. /**
  61829. * Reference to the Ammo library
  61830. */
  61831. bjsAMMO: any;
  61832. /**
  61833. * Created ammoJS world which physics bodies are added to
  61834. */
  61835. world: any;
  61836. /**
  61837. * Name of the plugin
  61838. */
  61839. name: string;
  61840. private _timeStep;
  61841. private _fixedTimeStep;
  61842. private _maxSteps;
  61843. private _tmpQuaternion;
  61844. private _tmpAmmoTransform;
  61845. private _tmpAmmoQuaternion;
  61846. private _tmpAmmoConcreteContactResultCallback;
  61847. private _collisionConfiguration;
  61848. private _dispatcher;
  61849. private _overlappingPairCache;
  61850. private _solver;
  61851. private _softBodySolver;
  61852. private _tmpAmmoVectorA;
  61853. private _tmpAmmoVectorB;
  61854. private _tmpAmmoVectorC;
  61855. private _tmpAmmoVectorD;
  61856. private _tmpContactCallbackResult;
  61857. private _tmpAmmoVectorRCA;
  61858. private _tmpAmmoVectorRCB;
  61859. private _raycastResult;
  61860. private _tmpContactPoint;
  61861. private static readonly DISABLE_COLLISION_FLAG;
  61862. private static readonly KINEMATIC_FLAG;
  61863. private static readonly DISABLE_DEACTIVATION_FLAG;
  61864. /**
  61865. * Initializes the ammoJS plugin
  61866. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  61867. * @param ammoInjection can be used to inject your own ammo reference
  61868. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  61869. */
  61870. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  61871. /**
  61872. * Sets the gravity of the physics world (m/(s^2))
  61873. * @param gravity Gravity to set
  61874. */
  61875. setGravity(gravity: Vector3): void;
  61876. /**
  61877. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  61878. * @param timeStep timestep to use in seconds
  61879. */
  61880. setTimeStep(timeStep: number): void;
  61881. /**
  61882. * 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)
  61883. * @param fixedTimeStep fixedTimeStep to use in seconds
  61884. */
  61885. setFixedTimeStep(fixedTimeStep: number): void;
  61886. /**
  61887. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  61888. * @param maxSteps the maximum number of steps by the physics engine per frame
  61889. */
  61890. setMaxSteps(maxSteps: number): void;
  61891. /**
  61892. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  61893. * @returns the current timestep in seconds
  61894. */
  61895. getTimeStep(): number;
  61896. /**
  61897. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  61898. */
  61899. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  61900. private _isImpostorInContact;
  61901. private _isImpostorPairInContact;
  61902. private _stepSimulation;
  61903. /**
  61904. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  61905. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  61906. * After the step the babylon meshes are set to the position of the physics imposters
  61907. * @param delta amount of time to step forward
  61908. * @param impostors array of imposters to update before/after the step
  61909. */
  61910. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61911. /**
  61912. * Update babylon mesh to match physics world object
  61913. * @param impostor imposter to match
  61914. */
  61915. private _afterSoftStep;
  61916. /**
  61917. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61918. * @param impostor imposter to match
  61919. */
  61920. private _ropeStep;
  61921. /**
  61922. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61923. * @param impostor imposter to match
  61924. */
  61925. private _softbodyOrClothStep;
  61926. private _tmpMatrix;
  61927. /**
  61928. * Applies an impulse on the imposter
  61929. * @param impostor imposter to apply impulse to
  61930. * @param force amount of force to be applied to the imposter
  61931. * @param contactPoint the location to apply the impulse on the imposter
  61932. */
  61933. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61934. /**
  61935. * Applies a force on the imposter
  61936. * @param impostor imposter to apply force
  61937. * @param force amount of force to be applied to the imposter
  61938. * @param contactPoint the location to apply the force on the imposter
  61939. */
  61940. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61941. /**
  61942. * Creates a physics body using the plugin
  61943. * @param impostor the imposter to create the physics body on
  61944. */
  61945. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61946. /**
  61947. * Removes the physics body from the imposter and disposes of the body's memory
  61948. * @param impostor imposter to remove the physics body from
  61949. */
  61950. removePhysicsBody(impostor: PhysicsImpostor): void;
  61951. /**
  61952. * Generates a joint
  61953. * @param impostorJoint the imposter joint to create the joint with
  61954. */
  61955. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61956. /**
  61957. * Removes a joint
  61958. * @param impostorJoint the imposter joint to remove the joint from
  61959. */
  61960. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61961. private _addMeshVerts;
  61962. /**
  61963. * Initialise the soft body vertices to match its object's (mesh) vertices
  61964. * Softbody vertices (nodes) are in world space and to match this
  61965. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  61966. * @param impostor to create the softbody for
  61967. */
  61968. private _softVertexData;
  61969. /**
  61970. * Create an impostor's soft body
  61971. * @param impostor to create the softbody for
  61972. */
  61973. private _createSoftbody;
  61974. /**
  61975. * Create cloth for an impostor
  61976. * @param impostor to create the softbody for
  61977. */
  61978. private _createCloth;
  61979. /**
  61980. * Create rope for an impostor
  61981. * @param impostor to create the softbody for
  61982. */
  61983. private _createRope;
  61984. /**
  61985. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  61986. * @param impostor to create the custom physics shape for
  61987. */
  61988. private _createCustom;
  61989. private _addHullVerts;
  61990. private _createShape;
  61991. /**
  61992. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  61993. * @param impostor imposter containing the physics body and babylon object
  61994. */
  61995. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61996. /**
  61997. * Sets the babylon object's position/rotation from the physics body's position/rotation
  61998. * @param impostor imposter containing the physics body and babylon object
  61999. * @param newPosition new position
  62000. * @param newRotation new rotation
  62001. */
  62002. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62003. /**
  62004. * If this plugin is supported
  62005. * @returns true if its supported
  62006. */
  62007. isSupported(): boolean;
  62008. /**
  62009. * Sets the linear velocity of the physics body
  62010. * @param impostor imposter to set the velocity on
  62011. * @param velocity velocity to set
  62012. */
  62013. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62014. /**
  62015. * Sets the angular velocity of the physics body
  62016. * @param impostor imposter to set the velocity on
  62017. * @param velocity velocity to set
  62018. */
  62019. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62020. /**
  62021. * gets the linear velocity
  62022. * @param impostor imposter to get linear velocity from
  62023. * @returns linear velocity
  62024. */
  62025. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62026. /**
  62027. * gets the angular velocity
  62028. * @param impostor imposter to get angular velocity from
  62029. * @returns angular velocity
  62030. */
  62031. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62032. /**
  62033. * Sets the mass of physics body
  62034. * @param impostor imposter to set the mass on
  62035. * @param mass mass to set
  62036. */
  62037. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62038. /**
  62039. * Gets the mass of the physics body
  62040. * @param impostor imposter to get the mass from
  62041. * @returns mass
  62042. */
  62043. getBodyMass(impostor: PhysicsImpostor): number;
  62044. /**
  62045. * Gets friction of the impostor
  62046. * @param impostor impostor to get friction from
  62047. * @returns friction value
  62048. */
  62049. getBodyFriction(impostor: PhysicsImpostor): number;
  62050. /**
  62051. * Sets friction of the impostor
  62052. * @param impostor impostor to set friction on
  62053. * @param friction friction value
  62054. */
  62055. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62056. /**
  62057. * Gets restitution of the impostor
  62058. * @param impostor impostor to get restitution from
  62059. * @returns restitution value
  62060. */
  62061. getBodyRestitution(impostor: PhysicsImpostor): number;
  62062. /**
  62063. * Sets resitution of the impostor
  62064. * @param impostor impostor to set resitution on
  62065. * @param restitution resitution value
  62066. */
  62067. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62068. /**
  62069. * Gets pressure inside the impostor
  62070. * @param impostor impostor to get pressure from
  62071. * @returns pressure value
  62072. */
  62073. getBodyPressure(impostor: PhysicsImpostor): number;
  62074. /**
  62075. * Sets pressure inside a soft body impostor
  62076. * Cloth and rope must remain 0 pressure
  62077. * @param impostor impostor to set pressure on
  62078. * @param pressure pressure value
  62079. */
  62080. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  62081. /**
  62082. * Gets stiffness of the impostor
  62083. * @param impostor impostor to get stiffness from
  62084. * @returns pressure value
  62085. */
  62086. getBodyStiffness(impostor: PhysicsImpostor): number;
  62087. /**
  62088. * Sets stiffness of the impostor
  62089. * @param impostor impostor to set stiffness on
  62090. * @param stiffness stiffness value from 0 to 1
  62091. */
  62092. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  62093. /**
  62094. * Gets velocityIterations of the impostor
  62095. * @param impostor impostor to get velocity iterations from
  62096. * @returns velocityIterations value
  62097. */
  62098. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  62099. /**
  62100. * Sets velocityIterations of the impostor
  62101. * @param impostor impostor to set velocity iterations on
  62102. * @param velocityIterations velocityIterations value
  62103. */
  62104. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  62105. /**
  62106. * Gets positionIterations of the impostor
  62107. * @param impostor impostor to get position iterations from
  62108. * @returns positionIterations value
  62109. */
  62110. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  62111. /**
  62112. * Sets positionIterations of the impostor
  62113. * @param impostor impostor to set position on
  62114. * @param positionIterations positionIterations value
  62115. */
  62116. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  62117. /**
  62118. * Append an anchor to a cloth object
  62119. * @param impostor is the cloth impostor to add anchor to
  62120. * @param otherImpostor is the rigid impostor to anchor to
  62121. * @param width ratio across width from 0 to 1
  62122. * @param height ratio up height from 0 to 1
  62123. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  62124. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62125. */
  62126. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62127. /**
  62128. * Append an hook to a rope object
  62129. * @param impostor is the rope impostor to add hook to
  62130. * @param otherImpostor is the rigid impostor to hook to
  62131. * @param length ratio along the rope from 0 to 1
  62132. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  62133. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62134. */
  62135. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62136. /**
  62137. * Sleeps the physics body and stops it from being active
  62138. * @param impostor impostor to sleep
  62139. */
  62140. sleepBody(impostor: PhysicsImpostor): void;
  62141. /**
  62142. * Activates the physics body
  62143. * @param impostor impostor to activate
  62144. */
  62145. wakeUpBody(impostor: PhysicsImpostor): void;
  62146. /**
  62147. * Updates the distance parameters of the joint
  62148. * @param joint joint to update
  62149. * @param maxDistance maximum distance of the joint
  62150. * @param minDistance minimum distance of the joint
  62151. */
  62152. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62153. /**
  62154. * Sets a motor on the joint
  62155. * @param joint joint to set motor on
  62156. * @param speed speed of the motor
  62157. * @param maxForce maximum force of the motor
  62158. * @param motorIndex index of the motor
  62159. */
  62160. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62161. /**
  62162. * Sets the motors limit
  62163. * @param joint joint to set limit on
  62164. * @param upperLimit upper limit
  62165. * @param lowerLimit lower limit
  62166. */
  62167. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62168. /**
  62169. * Syncs the position and rotation of a mesh with the impostor
  62170. * @param mesh mesh to sync
  62171. * @param impostor impostor to update the mesh with
  62172. */
  62173. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62174. /**
  62175. * Gets the radius of the impostor
  62176. * @param impostor impostor to get radius from
  62177. * @returns the radius
  62178. */
  62179. getRadius(impostor: PhysicsImpostor): number;
  62180. /**
  62181. * Gets the box size of the impostor
  62182. * @param impostor impostor to get box size from
  62183. * @param result the resulting box size
  62184. */
  62185. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62186. /**
  62187. * Disposes of the impostor
  62188. */
  62189. dispose(): void;
  62190. /**
  62191. * Does a raycast in the physics world
  62192. * @param from when should the ray start?
  62193. * @param to when should the ray end?
  62194. * @returns PhysicsRaycastResult
  62195. */
  62196. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62197. }
  62198. }
  62199. declare module BABYLON {
  62200. interface AbstractScene {
  62201. /**
  62202. * The list of reflection probes added to the scene
  62203. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62204. */
  62205. reflectionProbes: Array<ReflectionProbe>;
  62206. /**
  62207. * Removes the given reflection probe from this scene.
  62208. * @param toRemove The reflection probe to remove
  62209. * @returns The index of the removed reflection probe
  62210. */
  62211. removeReflectionProbe(toRemove: ReflectionProbe): number;
  62212. /**
  62213. * Adds the given reflection probe to this scene.
  62214. * @param newReflectionProbe The reflection probe to add
  62215. */
  62216. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  62217. }
  62218. /**
  62219. * Class used to generate realtime reflection / refraction cube textures
  62220. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62221. */
  62222. export class ReflectionProbe {
  62223. /** defines the name of the probe */
  62224. name: string;
  62225. private _scene;
  62226. private _renderTargetTexture;
  62227. private _projectionMatrix;
  62228. private _viewMatrix;
  62229. private _target;
  62230. private _add;
  62231. private _attachedMesh;
  62232. private _invertYAxis;
  62233. /** Gets or sets probe position (center of the cube map) */
  62234. position: Vector3;
  62235. /**
  62236. * Creates a new reflection probe
  62237. * @param name defines the name of the probe
  62238. * @param size defines the texture resolution (for each face)
  62239. * @param scene defines the hosting scene
  62240. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  62241. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  62242. */
  62243. constructor(
  62244. /** defines the name of the probe */
  62245. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  62246. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  62247. get samples(): number;
  62248. set samples(value: number);
  62249. /** Gets or sets the refresh rate to use (on every frame by default) */
  62250. get refreshRate(): number;
  62251. set refreshRate(value: number);
  62252. /**
  62253. * Gets the hosting scene
  62254. * @returns a Scene
  62255. */
  62256. getScene(): Scene;
  62257. /** Gets the internal CubeTexture used to render to */
  62258. get cubeTexture(): RenderTargetTexture;
  62259. /** Gets the list of meshes to render */
  62260. get renderList(): Nullable<AbstractMesh[]>;
  62261. /**
  62262. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  62263. * @param mesh defines the mesh to attach to
  62264. */
  62265. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  62266. /**
  62267. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  62268. * @param renderingGroupId The rendering group id corresponding to its index
  62269. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  62270. */
  62271. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  62272. /**
  62273. * Clean all associated resources
  62274. */
  62275. dispose(): void;
  62276. /**
  62277. * Converts the reflection probe information to a readable string for debug purpose.
  62278. * @param fullDetails Supports for multiple levels of logging within scene loading
  62279. * @returns the human readable reflection probe info
  62280. */
  62281. toString(fullDetails?: boolean): string;
  62282. /**
  62283. * Get the class name of the relfection probe.
  62284. * @returns "ReflectionProbe"
  62285. */
  62286. getClassName(): string;
  62287. /**
  62288. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  62289. * @returns The JSON representation of the texture
  62290. */
  62291. serialize(): any;
  62292. /**
  62293. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  62294. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  62295. * @param scene Define the scene the parsed reflection probe should be instantiated in
  62296. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  62297. * @returns The parsed reflection probe if successful
  62298. */
  62299. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  62300. }
  62301. }
  62302. declare module BABYLON {
  62303. /** @hidden */
  62304. export var _BabylonLoaderRegistered: boolean;
  62305. /**
  62306. * Helps setting up some configuration for the babylon file loader.
  62307. */
  62308. export class BabylonFileLoaderConfiguration {
  62309. /**
  62310. * The loader does not allow injecting custom physix engine into the plugins.
  62311. * Unfortunately in ES6, we need to manually inject them into the plugin.
  62312. * So you could set this variable to your engine import to make it work.
  62313. */
  62314. static LoaderInjectedPhysicsEngine: any;
  62315. }
  62316. }
  62317. declare module BABYLON {
  62318. /**
  62319. * The Physically based simple base material of BJS.
  62320. *
  62321. * This enables better naming and convention enforcements on top of the pbrMaterial.
  62322. * It is used as the base class for both the specGloss and metalRough conventions.
  62323. */
  62324. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  62325. /**
  62326. * Number of Simultaneous lights allowed on the material.
  62327. */
  62328. maxSimultaneousLights: number;
  62329. /**
  62330. * If sets to true, disables all the lights affecting the material.
  62331. */
  62332. disableLighting: boolean;
  62333. /**
  62334. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  62335. */
  62336. environmentTexture: BaseTexture;
  62337. /**
  62338. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  62339. */
  62340. invertNormalMapX: boolean;
  62341. /**
  62342. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  62343. */
  62344. invertNormalMapY: boolean;
  62345. /**
  62346. * Normal map used in the model.
  62347. */
  62348. normalTexture: BaseTexture;
  62349. /**
  62350. * Emissivie color used to self-illuminate the model.
  62351. */
  62352. emissiveColor: Color3;
  62353. /**
  62354. * Emissivie texture used to self-illuminate the model.
  62355. */
  62356. emissiveTexture: BaseTexture;
  62357. /**
  62358. * Occlusion Channel Strenght.
  62359. */
  62360. occlusionStrength: number;
  62361. /**
  62362. * Occlusion Texture of the material (adding extra occlusion effects).
  62363. */
  62364. occlusionTexture: BaseTexture;
  62365. /**
  62366. * Defines the alpha limits in alpha test mode.
  62367. */
  62368. alphaCutOff: number;
  62369. /**
  62370. * Gets the current double sided mode.
  62371. */
  62372. get doubleSided(): boolean;
  62373. /**
  62374. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  62375. */
  62376. set doubleSided(value: boolean);
  62377. /**
  62378. * Stores the pre-calculated light information of a mesh in a texture.
  62379. */
  62380. lightmapTexture: BaseTexture;
  62381. /**
  62382. * If true, the light map contains occlusion information instead of lighting info.
  62383. */
  62384. useLightmapAsShadowmap: boolean;
  62385. /**
  62386. * Instantiates a new PBRMaterial instance.
  62387. *
  62388. * @param name The material name
  62389. * @param scene The scene the material will be use in.
  62390. */
  62391. constructor(name: string, scene: Scene);
  62392. getClassName(): string;
  62393. }
  62394. }
  62395. declare module BABYLON {
  62396. /**
  62397. * The PBR material of BJS following the metal roughness convention.
  62398. *
  62399. * This fits to the PBR convention in the GLTF definition:
  62400. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  62401. */
  62402. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  62403. /**
  62404. * The base color has two different interpretations depending on the value of metalness.
  62405. * When the material is a metal, the base color is the specific measured reflectance value
  62406. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  62407. * of the material.
  62408. */
  62409. baseColor: Color3;
  62410. /**
  62411. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  62412. * well as opacity information in the alpha channel.
  62413. */
  62414. baseTexture: BaseTexture;
  62415. /**
  62416. * Specifies the metallic scalar value of the material.
  62417. * Can also be used to scale the metalness values of the metallic texture.
  62418. */
  62419. metallic: number;
  62420. /**
  62421. * Specifies the roughness scalar value of the material.
  62422. * Can also be used to scale the roughness values of the metallic texture.
  62423. */
  62424. roughness: number;
  62425. /**
  62426. * Texture containing both the metallic value in the B channel and the
  62427. * roughness value in the G channel to keep better precision.
  62428. */
  62429. metallicRoughnessTexture: BaseTexture;
  62430. /**
  62431. * Instantiates a new PBRMetalRoughnessMaterial instance.
  62432. *
  62433. * @param name The material name
  62434. * @param scene The scene the material will be use in.
  62435. */
  62436. constructor(name: string, scene: Scene);
  62437. /**
  62438. * Return the currrent class name of the material.
  62439. */
  62440. getClassName(): string;
  62441. /**
  62442. * Makes a duplicate of the current material.
  62443. * @param name - name to use for the new material.
  62444. */
  62445. clone(name: string): PBRMetallicRoughnessMaterial;
  62446. /**
  62447. * Serialize the material to a parsable JSON object.
  62448. */
  62449. serialize(): any;
  62450. /**
  62451. * Parses a JSON object correponding to the serialize function.
  62452. */
  62453. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  62454. }
  62455. }
  62456. declare module BABYLON {
  62457. /**
  62458. * The PBR material of BJS following the specular glossiness convention.
  62459. *
  62460. * This fits to the PBR convention in the GLTF definition:
  62461. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  62462. */
  62463. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  62464. /**
  62465. * Specifies the diffuse color of the material.
  62466. */
  62467. diffuseColor: Color3;
  62468. /**
  62469. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  62470. * channel.
  62471. */
  62472. diffuseTexture: BaseTexture;
  62473. /**
  62474. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  62475. */
  62476. specularColor: Color3;
  62477. /**
  62478. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  62479. */
  62480. glossiness: number;
  62481. /**
  62482. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  62483. */
  62484. specularGlossinessTexture: BaseTexture;
  62485. /**
  62486. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  62487. *
  62488. * @param name The material name
  62489. * @param scene The scene the material will be use in.
  62490. */
  62491. constructor(name: string, scene: Scene);
  62492. /**
  62493. * Return the currrent class name of the material.
  62494. */
  62495. getClassName(): string;
  62496. /**
  62497. * Makes a duplicate of the current material.
  62498. * @param name - name to use for the new material.
  62499. */
  62500. clone(name: string): PBRSpecularGlossinessMaterial;
  62501. /**
  62502. * Serialize the material to a parsable JSON object.
  62503. */
  62504. serialize(): any;
  62505. /**
  62506. * Parses a JSON object correponding to the serialize function.
  62507. */
  62508. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  62509. }
  62510. }
  62511. declare module BABYLON {
  62512. /**
  62513. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  62514. * It can help converting any input color in a desired output one. This can then be used to create effects
  62515. * from sepia, black and white to sixties or futuristic rendering...
  62516. *
  62517. * The only supported format is currently 3dl.
  62518. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  62519. */
  62520. export class ColorGradingTexture extends BaseTexture {
  62521. /**
  62522. * The texture URL.
  62523. */
  62524. url: string;
  62525. /**
  62526. * Empty line regex stored for GC.
  62527. */
  62528. private static _noneEmptyLineRegex;
  62529. private _textureMatrix;
  62530. private _onLoad;
  62531. /**
  62532. * Instantiates a ColorGradingTexture from the following parameters.
  62533. *
  62534. * @param url The location of the color gradind data (currently only supporting 3dl)
  62535. * @param sceneOrEngine The scene or engine the texture will be used in
  62536. * @param onLoad defines a callback triggered when the texture has been loaded
  62537. */
  62538. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  62539. /**
  62540. * Fires the onload event from the constructor if requested.
  62541. */
  62542. private _triggerOnLoad;
  62543. /**
  62544. * Returns the texture matrix used in most of the material.
  62545. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  62546. */
  62547. getTextureMatrix(): Matrix;
  62548. /**
  62549. * Occurs when the file being loaded is a .3dl LUT file.
  62550. */
  62551. private load3dlTexture;
  62552. /**
  62553. * Starts the loading process of the texture.
  62554. */
  62555. private loadTexture;
  62556. /**
  62557. * Clones the color gradind texture.
  62558. */
  62559. clone(): ColorGradingTexture;
  62560. /**
  62561. * Called during delayed load for textures.
  62562. */
  62563. delayLoad(): void;
  62564. /**
  62565. * Parses a color grading texture serialized by Babylon.
  62566. * @param parsedTexture The texture information being parsedTexture
  62567. * @param scene The scene to load the texture in
  62568. * @param rootUrl The root url of the data assets to load
  62569. * @return A color gradind texture
  62570. */
  62571. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  62572. /**
  62573. * Serializes the LUT texture to json format.
  62574. */
  62575. serialize(): any;
  62576. }
  62577. }
  62578. declare module BABYLON {
  62579. /**
  62580. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  62581. */
  62582. export class EquiRectangularCubeTexture extends BaseTexture {
  62583. /** The six faces of the cube. */
  62584. private static _FacesMapping;
  62585. private _noMipmap;
  62586. private _onLoad;
  62587. private _onError;
  62588. /** The size of the cubemap. */
  62589. private _size;
  62590. /** The buffer of the image. */
  62591. private _buffer;
  62592. /** The width of the input image. */
  62593. private _width;
  62594. /** The height of the input image. */
  62595. private _height;
  62596. /** The URL to the image. */
  62597. url: string;
  62598. /**
  62599. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  62600. * @param url The location of the image
  62601. * @param scene The scene the texture will be used in
  62602. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  62603. * @param noMipmap Forces to not generate the mipmap if true
  62604. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  62605. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  62606. * @param onLoad — defines a callback called when texture is loaded
  62607. * @param onError — defines a callback called if there is an error
  62608. */
  62609. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  62610. /**
  62611. * Load the image data, by putting the image on a canvas and extracting its buffer.
  62612. */
  62613. private loadImage;
  62614. /**
  62615. * Convert the image buffer into a cubemap and create a CubeTexture.
  62616. */
  62617. private loadTexture;
  62618. /**
  62619. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  62620. * @param buffer The ArrayBuffer that should be converted.
  62621. * @returns The buffer as Float32Array.
  62622. */
  62623. private getFloat32ArrayFromArrayBuffer;
  62624. /**
  62625. * Get the current class name of the texture useful for serialization or dynamic coding.
  62626. * @returns "EquiRectangularCubeTexture"
  62627. */
  62628. getClassName(): string;
  62629. /**
  62630. * Create a clone of the current EquiRectangularCubeTexture and return it.
  62631. * @returns A clone of the current EquiRectangularCubeTexture.
  62632. */
  62633. clone(): EquiRectangularCubeTexture;
  62634. }
  62635. }
  62636. declare module BABYLON {
  62637. /**
  62638. * Defines the options related to the creation of an HtmlElementTexture
  62639. */
  62640. export interface IHtmlElementTextureOptions {
  62641. /**
  62642. * Defines wether mip maps should be created or not.
  62643. */
  62644. generateMipMaps?: boolean;
  62645. /**
  62646. * Defines the sampling mode of the texture.
  62647. */
  62648. samplingMode?: number;
  62649. /**
  62650. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  62651. */
  62652. engine: Nullable<ThinEngine>;
  62653. /**
  62654. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  62655. */
  62656. scene: Nullable<Scene>;
  62657. }
  62658. /**
  62659. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  62660. * To be as efficient as possible depending on your constraints nothing aside the first upload
  62661. * is automatically managed.
  62662. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  62663. * in your application.
  62664. *
  62665. * As the update is not automatic, you need to call them manually.
  62666. */
  62667. export class HtmlElementTexture extends BaseTexture {
  62668. /**
  62669. * The texture URL.
  62670. */
  62671. element: HTMLVideoElement | HTMLCanvasElement;
  62672. private static readonly DefaultOptions;
  62673. private _textureMatrix;
  62674. private _isVideo;
  62675. private _generateMipMaps;
  62676. private _samplingMode;
  62677. /**
  62678. * Instantiates a HtmlElementTexture from the following parameters.
  62679. *
  62680. * @param name Defines the name of the texture
  62681. * @param element Defines the video or canvas the texture is filled with
  62682. * @param options Defines the other none mandatory texture creation options
  62683. */
  62684. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  62685. private _createInternalTexture;
  62686. /**
  62687. * Returns the texture matrix used in most of the material.
  62688. */
  62689. getTextureMatrix(): Matrix;
  62690. /**
  62691. * Updates the content of the texture.
  62692. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  62693. */
  62694. update(invertY?: Nullable<boolean>): void;
  62695. }
  62696. }
  62697. declare module BABYLON {
  62698. /**
  62699. * Based on jsTGALoader - Javascript loader for TGA file
  62700. * By Vincent Thibault
  62701. * @see http://blog.robrowser.com/javascript-tga-loader.html
  62702. */
  62703. export class TGATools {
  62704. private static _TYPE_INDEXED;
  62705. private static _TYPE_RGB;
  62706. private static _TYPE_GREY;
  62707. private static _TYPE_RLE_INDEXED;
  62708. private static _TYPE_RLE_RGB;
  62709. private static _TYPE_RLE_GREY;
  62710. private static _ORIGIN_MASK;
  62711. private static _ORIGIN_SHIFT;
  62712. private static _ORIGIN_BL;
  62713. private static _ORIGIN_BR;
  62714. private static _ORIGIN_UL;
  62715. private static _ORIGIN_UR;
  62716. /**
  62717. * Gets the header of a TGA file
  62718. * @param data defines the TGA data
  62719. * @returns the header
  62720. */
  62721. static GetTGAHeader(data: Uint8Array): any;
  62722. /**
  62723. * Uploads TGA content to a Babylon Texture
  62724. * @hidden
  62725. */
  62726. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  62727. /** @hidden */
  62728. 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;
  62729. /** @hidden */
  62730. 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;
  62731. /** @hidden */
  62732. 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;
  62733. /** @hidden */
  62734. 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;
  62735. /** @hidden */
  62736. 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;
  62737. /** @hidden */
  62738. 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;
  62739. }
  62740. }
  62741. declare module BABYLON {
  62742. /**
  62743. * Implementation of the TGA Texture Loader.
  62744. * @hidden
  62745. */
  62746. export class _TGATextureLoader implements IInternalTextureLoader {
  62747. /**
  62748. * Defines wether the loader supports cascade loading the different faces.
  62749. */
  62750. readonly supportCascades: boolean;
  62751. /**
  62752. * This returns if the loader support the current file information.
  62753. * @param extension defines the file extension of the file being loaded
  62754. * @returns true if the loader can load the specified file
  62755. */
  62756. canLoad(extension: string): boolean;
  62757. /**
  62758. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62759. * @param data contains the texture data
  62760. * @param texture defines the BabylonJS internal texture
  62761. * @param createPolynomials will be true if polynomials have been requested
  62762. * @param onLoad defines the callback to trigger once the texture is ready
  62763. * @param onError defines the callback to trigger in case of error
  62764. */
  62765. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62766. /**
  62767. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62768. * @param data contains the texture data
  62769. * @param texture defines the BabylonJS internal texture
  62770. * @param callback defines the method to call once ready to upload
  62771. */
  62772. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62773. }
  62774. }
  62775. declare module BABYLON {
  62776. /**
  62777. * Info about the .basis files
  62778. */
  62779. class BasisFileInfo {
  62780. /**
  62781. * If the file has alpha
  62782. */
  62783. hasAlpha: boolean;
  62784. /**
  62785. * Info about each image of the basis file
  62786. */
  62787. images: Array<{
  62788. levels: Array<{
  62789. width: number;
  62790. height: number;
  62791. transcodedPixels: ArrayBufferView;
  62792. }>;
  62793. }>;
  62794. }
  62795. /**
  62796. * Result of transcoding a basis file
  62797. */
  62798. class TranscodeResult {
  62799. /**
  62800. * Info about the .basis file
  62801. */
  62802. fileInfo: BasisFileInfo;
  62803. /**
  62804. * Format to use when loading the file
  62805. */
  62806. format: number;
  62807. }
  62808. /**
  62809. * Configuration options for the Basis transcoder
  62810. */
  62811. export class BasisTranscodeConfiguration {
  62812. /**
  62813. * Supported compression formats used to determine the supported output format of the transcoder
  62814. */
  62815. supportedCompressionFormats?: {
  62816. /**
  62817. * etc1 compression format
  62818. */
  62819. etc1?: boolean;
  62820. /**
  62821. * s3tc compression format
  62822. */
  62823. s3tc?: boolean;
  62824. /**
  62825. * pvrtc compression format
  62826. */
  62827. pvrtc?: boolean;
  62828. /**
  62829. * etc2 compression format
  62830. */
  62831. etc2?: boolean;
  62832. };
  62833. /**
  62834. * If mipmap levels should be loaded for transcoded images (Default: true)
  62835. */
  62836. loadMipmapLevels?: boolean;
  62837. /**
  62838. * Index of a single image to load (Default: all images)
  62839. */
  62840. loadSingleImage?: number;
  62841. }
  62842. /**
  62843. * Used to load .Basis files
  62844. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  62845. */
  62846. export class BasisTools {
  62847. private static _IgnoreSupportedFormats;
  62848. /**
  62849. * URL to use when loading the basis transcoder
  62850. */
  62851. static JSModuleURL: string;
  62852. /**
  62853. * URL to use when loading the wasm module for the transcoder
  62854. */
  62855. static WasmModuleURL: string;
  62856. /**
  62857. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  62858. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  62859. * @returns internal format corresponding to the Basis format
  62860. */
  62861. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  62862. private static _WorkerPromise;
  62863. private static _Worker;
  62864. private static _actionId;
  62865. private static _CreateWorkerAsync;
  62866. /**
  62867. * Transcodes a loaded image file to compressed pixel data
  62868. * @param data image data to transcode
  62869. * @param config configuration options for the transcoding
  62870. * @returns a promise resulting in the transcoded image
  62871. */
  62872. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  62873. /**
  62874. * Loads a texture from the transcode result
  62875. * @param texture texture load to
  62876. * @param transcodeResult the result of transcoding the basis file to load from
  62877. */
  62878. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  62879. }
  62880. }
  62881. declare module BABYLON {
  62882. /**
  62883. * Loader for .basis file format
  62884. */
  62885. export class _BasisTextureLoader implements IInternalTextureLoader {
  62886. /**
  62887. * Defines whether the loader supports cascade loading the different faces.
  62888. */
  62889. readonly supportCascades: boolean;
  62890. /**
  62891. * This returns if the loader support the current file information.
  62892. * @param extension defines the file extension of the file being loaded
  62893. * @returns true if the loader can load the specified file
  62894. */
  62895. canLoad(extension: string): boolean;
  62896. /**
  62897. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62898. * @param data contains the texture data
  62899. * @param texture defines the BabylonJS internal texture
  62900. * @param createPolynomials will be true if polynomials have been requested
  62901. * @param onLoad defines the callback to trigger once the texture is ready
  62902. * @param onError defines the callback to trigger in case of error
  62903. */
  62904. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62905. /**
  62906. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62907. * @param data contains the texture data
  62908. * @param texture defines the BabylonJS internal texture
  62909. * @param callback defines the method to call once ready to upload
  62910. */
  62911. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62912. }
  62913. }
  62914. declare module BABYLON {
  62915. /**
  62916. * Defines the basic options interface of a TexturePacker Frame
  62917. */
  62918. export interface ITexturePackerFrame {
  62919. /**
  62920. * The frame ID
  62921. */
  62922. id: number;
  62923. /**
  62924. * The frames Scale
  62925. */
  62926. scale: Vector2;
  62927. /**
  62928. * The Frames offset
  62929. */
  62930. offset: Vector2;
  62931. }
  62932. /**
  62933. * This is a support class for frame Data on texture packer sets.
  62934. */
  62935. export class TexturePackerFrame implements ITexturePackerFrame {
  62936. /**
  62937. * The frame ID
  62938. */
  62939. id: number;
  62940. /**
  62941. * The frames Scale
  62942. */
  62943. scale: Vector2;
  62944. /**
  62945. * The Frames offset
  62946. */
  62947. offset: Vector2;
  62948. /**
  62949. * Initializes a texture package frame.
  62950. * @param id The numerical frame identifier
  62951. * @param scale Scalar Vector2 for UV frame
  62952. * @param offset Vector2 for the frame position in UV units.
  62953. * @returns TexturePackerFrame
  62954. */
  62955. constructor(id: number, scale: Vector2, offset: Vector2);
  62956. }
  62957. }
  62958. declare module BABYLON {
  62959. /**
  62960. * Defines the basic options interface of a TexturePacker
  62961. */
  62962. export interface ITexturePackerOptions {
  62963. /**
  62964. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  62965. */
  62966. map?: string[];
  62967. /**
  62968. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  62969. */
  62970. uvsIn?: string;
  62971. /**
  62972. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  62973. */
  62974. uvsOut?: string;
  62975. /**
  62976. * number representing the layout style. Defaults to LAYOUT_STRIP
  62977. */
  62978. layout?: number;
  62979. /**
  62980. * number of columns if using custom column count layout(2). This defaults to 4.
  62981. */
  62982. colnum?: number;
  62983. /**
  62984. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  62985. */
  62986. updateInputMeshes?: boolean;
  62987. /**
  62988. * boolean flag to dispose all the source textures. Defaults to true.
  62989. */
  62990. disposeSources?: boolean;
  62991. /**
  62992. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  62993. */
  62994. fillBlanks?: boolean;
  62995. /**
  62996. * string value representing the context fill style color. Defaults to 'black'.
  62997. */
  62998. customFillColor?: string;
  62999. /**
  63000. * Width and Height Value of each Frame in the TexturePacker Sets
  63001. */
  63002. frameSize?: number;
  63003. /**
  63004. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  63005. */
  63006. paddingRatio?: number;
  63007. /**
  63008. * Number that declares the fill method for the padding gutter.
  63009. */
  63010. paddingMode?: number;
  63011. /**
  63012. * If in SUBUV_COLOR padding mode what color to use.
  63013. */
  63014. paddingColor?: Color3 | Color4;
  63015. }
  63016. /**
  63017. * Defines the basic interface of a TexturePacker JSON File
  63018. */
  63019. export interface ITexturePackerJSON {
  63020. /**
  63021. * The frame ID
  63022. */
  63023. name: string;
  63024. /**
  63025. * The base64 channel data
  63026. */
  63027. sets: any;
  63028. /**
  63029. * The options of the Packer
  63030. */
  63031. options: ITexturePackerOptions;
  63032. /**
  63033. * The frame data of the Packer
  63034. */
  63035. frames: Array<number>;
  63036. }
  63037. /**
  63038. * This is a support class that generates a series of packed texture sets.
  63039. * @see https://doc.babylonjs.com/babylon101/materials
  63040. */
  63041. export class TexturePacker {
  63042. /** Packer Layout Constant 0 */
  63043. static readonly LAYOUT_STRIP: number;
  63044. /** Packer Layout Constant 1 */
  63045. static readonly LAYOUT_POWER2: number;
  63046. /** Packer Layout Constant 2 */
  63047. static readonly LAYOUT_COLNUM: number;
  63048. /** Packer Layout Constant 0 */
  63049. static readonly SUBUV_WRAP: number;
  63050. /** Packer Layout Constant 1 */
  63051. static readonly SUBUV_EXTEND: number;
  63052. /** Packer Layout Constant 2 */
  63053. static readonly SUBUV_COLOR: number;
  63054. /** The Name of the Texture Package */
  63055. name: string;
  63056. /** The scene scope of the TexturePacker */
  63057. scene: Scene;
  63058. /** The Meshes to target */
  63059. meshes: AbstractMesh[];
  63060. /** Arguments passed with the Constructor */
  63061. options: ITexturePackerOptions;
  63062. /** The promise that is started upon initialization */
  63063. promise: Nullable<Promise<TexturePacker | string>>;
  63064. /** The Container object for the channel sets that are generated */
  63065. sets: object;
  63066. /** The Container array for the frames that are generated */
  63067. frames: TexturePackerFrame[];
  63068. /** The expected number of textures the system is parsing. */
  63069. private _expecting;
  63070. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  63071. private _paddingValue;
  63072. /**
  63073. * Initializes a texture package series from an array of meshes or a single mesh.
  63074. * @param name The name of the package
  63075. * @param meshes The target meshes to compose the package from
  63076. * @param options The arguments that texture packer should follow while building.
  63077. * @param scene The scene which the textures are scoped to.
  63078. * @returns TexturePacker
  63079. */
  63080. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  63081. /**
  63082. * Starts the package process
  63083. * @param resolve The promises resolution function
  63084. * @returns TexturePacker
  63085. */
  63086. private _createFrames;
  63087. /**
  63088. * Calculates the Size of the Channel Sets
  63089. * @returns Vector2
  63090. */
  63091. private _calculateSize;
  63092. /**
  63093. * Calculates the UV data for the frames.
  63094. * @param baseSize the base frameSize
  63095. * @param padding the base frame padding
  63096. * @param dtSize size of the Dynamic Texture for that channel
  63097. * @param dtUnits is 1/dtSize
  63098. * @param update flag to update the input meshes
  63099. */
  63100. private _calculateMeshUVFrames;
  63101. /**
  63102. * Calculates the frames Offset.
  63103. * @param index of the frame
  63104. * @returns Vector2
  63105. */
  63106. private _getFrameOffset;
  63107. /**
  63108. * Updates a Mesh to the frame data
  63109. * @param mesh that is the target
  63110. * @param frameID or the frame index
  63111. */
  63112. private _updateMeshUV;
  63113. /**
  63114. * Updates a Meshes materials to use the texture packer channels
  63115. * @param m is the mesh to target
  63116. * @param force all channels on the packer to be set.
  63117. */
  63118. private _updateTextureReferences;
  63119. /**
  63120. * Public method to set a Mesh to a frame
  63121. * @param m that is the target
  63122. * @param frameID or the frame index
  63123. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  63124. */
  63125. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  63126. /**
  63127. * Starts the async promise to compile the texture packer.
  63128. * @returns Promise<void>
  63129. */
  63130. processAsync(): Promise<void>;
  63131. /**
  63132. * Disposes all textures associated with this packer
  63133. */
  63134. dispose(): void;
  63135. /**
  63136. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  63137. * @param imageType is the image type to use.
  63138. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  63139. */
  63140. download(imageType?: string, quality?: number): void;
  63141. /**
  63142. * Public method to load a texturePacker JSON file.
  63143. * @param data of the JSON file in string format.
  63144. */
  63145. updateFromJSON(data: string): void;
  63146. }
  63147. }
  63148. declare module BABYLON {
  63149. /**
  63150. * 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.
  63151. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63152. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63153. */
  63154. export class CustomProceduralTexture extends ProceduralTexture {
  63155. private _animate;
  63156. private _time;
  63157. private _config;
  63158. private _texturePath;
  63159. /**
  63160. * Instantiates a new Custom Procedural Texture.
  63161. * 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.
  63162. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63163. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63164. * @param name Define the name of the texture
  63165. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  63166. * @param size Define the size of the texture to create
  63167. * @param scene Define the scene the texture belongs to
  63168. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  63169. * @param generateMipMaps Define if the texture should creates mip maps or not
  63170. */
  63171. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63172. private _loadJson;
  63173. /**
  63174. * Is the texture ready to be used ? (rendered at least once)
  63175. * @returns true if ready, otherwise, false.
  63176. */
  63177. isReady(): boolean;
  63178. /**
  63179. * Render the texture to its associated render target.
  63180. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  63181. */
  63182. render(useCameraPostProcess?: boolean): void;
  63183. /**
  63184. * Update the list of dependant textures samplers in the shader.
  63185. */
  63186. updateTextures(): void;
  63187. /**
  63188. * Update the uniform values of the procedural texture in the shader.
  63189. */
  63190. updateShaderUniforms(): void;
  63191. /**
  63192. * Define if the texture animates or not.
  63193. */
  63194. get animate(): boolean;
  63195. set animate(value: boolean);
  63196. }
  63197. }
  63198. declare module BABYLON {
  63199. /** @hidden */
  63200. export var noisePixelShader: {
  63201. name: string;
  63202. shader: string;
  63203. };
  63204. }
  63205. declare module BABYLON {
  63206. /**
  63207. * Class used to generate noise procedural textures
  63208. */
  63209. export class NoiseProceduralTexture extends ProceduralTexture {
  63210. /** Gets or sets the start time (default is 0) */
  63211. time: number;
  63212. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  63213. brightness: number;
  63214. /** Defines the number of octaves to process */
  63215. octaves: number;
  63216. /** Defines the level of persistence (0.8 by default) */
  63217. persistence: number;
  63218. /** Gets or sets animation speed factor (default is 1) */
  63219. animationSpeedFactor: number;
  63220. /**
  63221. * Creates a new NoiseProceduralTexture
  63222. * @param name defines the name fo the texture
  63223. * @param size defines the size of the texture (default is 256)
  63224. * @param scene defines the hosting scene
  63225. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  63226. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  63227. */
  63228. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63229. private _updateShaderUniforms;
  63230. protected _getDefines(): string;
  63231. /** Generate the current state of the procedural texture */
  63232. render(useCameraPostProcess?: boolean): void;
  63233. /**
  63234. * Serializes this noise procedural texture
  63235. * @returns a serialized noise procedural texture object
  63236. */
  63237. serialize(): any;
  63238. /**
  63239. * Clone the texture.
  63240. * @returns the cloned texture
  63241. */
  63242. clone(): NoiseProceduralTexture;
  63243. /**
  63244. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  63245. * @param parsedTexture defines parsed texture data
  63246. * @param scene defines the current scene
  63247. * @param rootUrl defines the root URL containing noise procedural texture information
  63248. * @returns a parsed NoiseProceduralTexture
  63249. */
  63250. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  63251. }
  63252. }
  63253. declare module BABYLON {
  63254. /**
  63255. * Raw cube texture where the raw buffers are passed in
  63256. */
  63257. export class RawCubeTexture extends CubeTexture {
  63258. /**
  63259. * Creates a cube texture where the raw buffers are passed in.
  63260. * @param scene defines the scene the texture is attached to
  63261. * @param data defines the array of data to use to create each face
  63262. * @param size defines the size of the textures
  63263. * @param format defines the format of the data
  63264. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  63265. * @param generateMipMaps defines if the engine should generate the mip levels
  63266. * @param invertY defines if data must be stored with Y axis inverted
  63267. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  63268. * @param compression defines the compression used (null by default)
  63269. */
  63270. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  63271. /**
  63272. * Updates the raw cube texture.
  63273. * @param data defines the data to store
  63274. * @param format defines the data format
  63275. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63276. * @param invertY defines if data must be stored with Y axis inverted
  63277. * @param compression defines the compression used (null by default)
  63278. * @param level defines which level of the texture to update
  63279. */
  63280. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  63281. /**
  63282. * Updates a raw cube texture with RGBD encoded data.
  63283. * @param data defines the array of data [mipmap][face] to use to create each face
  63284. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  63285. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  63286. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  63287. * @returns a promsie that resolves when the operation is complete
  63288. */
  63289. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  63290. /**
  63291. * Clones the raw cube texture.
  63292. * @return a new cube texture
  63293. */
  63294. clone(): CubeTexture;
  63295. /** @hidden */
  63296. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  63297. }
  63298. }
  63299. declare module BABYLON {
  63300. /**
  63301. * Class used to store 2D array textures containing user data
  63302. */
  63303. export class RawTexture2DArray extends Texture {
  63304. /** Gets or sets the texture format to use */
  63305. format: number;
  63306. /**
  63307. * Create a new RawTexture2DArray
  63308. * @param data defines the data of the texture
  63309. * @param width defines the width of the texture
  63310. * @param height defines the height of the texture
  63311. * @param depth defines the number of layers of the texture
  63312. * @param format defines the texture format to use
  63313. * @param scene defines the hosting scene
  63314. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63315. * @param invertY defines if texture must be stored with Y axis inverted
  63316. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63317. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63318. */
  63319. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63320. /** Gets or sets the texture format to use */
  63321. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63322. /**
  63323. * Update the texture with new data
  63324. * @param data defines the data to store in the texture
  63325. */
  63326. update(data: ArrayBufferView): void;
  63327. }
  63328. }
  63329. declare module BABYLON {
  63330. /**
  63331. * Class used to store 3D textures containing user data
  63332. */
  63333. export class RawTexture3D extends Texture {
  63334. /** Gets or sets the texture format to use */
  63335. format: number;
  63336. /**
  63337. * Create a new RawTexture3D
  63338. * @param data defines the data of the texture
  63339. * @param width defines the width of the texture
  63340. * @param height defines the height of the texture
  63341. * @param depth defines the depth of the texture
  63342. * @param format defines the texture format to use
  63343. * @param scene defines the hosting scene
  63344. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63345. * @param invertY defines if texture must be stored with Y axis inverted
  63346. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63347. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63348. */
  63349. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63350. /** Gets or sets the texture format to use */
  63351. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63352. /**
  63353. * Update the texture with new data
  63354. * @param data defines the data to store in the texture
  63355. */
  63356. update(data: ArrayBufferView): void;
  63357. }
  63358. }
  63359. declare module BABYLON {
  63360. /**
  63361. * Creates a refraction texture used by refraction channel of the standard material.
  63362. * It is like a mirror but to see through a material.
  63363. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63364. */
  63365. export class RefractionTexture extends RenderTargetTexture {
  63366. /**
  63367. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  63368. * 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.
  63369. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63370. */
  63371. refractionPlane: Plane;
  63372. /**
  63373. * Define how deep under the surface we should see.
  63374. */
  63375. depth: number;
  63376. /**
  63377. * Creates a refraction texture used by refraction channel of the standard material.
  63378. * It is like a mirror but to see through a material.
  63379. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63380. * @param name Define the texture name
  63381. * @param size Define the size of the underlying texture
  63382. * @param scene Define the scene the refraction belongs to
  63383. * @param generateMipMaps Define if we need to generate mips level for the refraction
  63384. */
  63385. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  63386. /**
  63387. * Clone the refraction texture.
  63388. * @returns the cloned texture
  63389. */
  63390. clone(): RefractionTexture;
  63391. /**
  63392. * Serialize the texture to a JSON representation you could use in Parse later on
  63393. * @returns the serialized JSON representation
  63394. */
  63395. serialize(): any;
  63396. }
  63397. }
  63398. declare module BABYLON {
  63399. /**
  63400. * Block used to add support for vertex skinning (bones)
  63401. */
  63402. export class BonesBlock extends NodeMaterialBlock {
  63403. /**
  63404. * Creates a new BonesBlock
  63405. * @param name defines the block name
  63406. */
  63407. constructor(name: string);
  63408. /**
  63409. * Initialize the block and prepare the context for build
  63410. * @param state defines the state that will be used for the build
  63411. */
  63412. initialize(state: NodeMaterialBuildState): void;
  63413. /**
  63414. * Gets the current class name
  63415. * @returns the class name
  63416. */
  63417. getClassName(): string;
  63418. /**
  63419. * Gets the matrix indices input component
  63420. */
  63421. get matricesIndices(): NodeMaterialConnectionPoint;
  63422. /**
  63423. * Gets the matrix weights input component
  63424. */
  63425. get matricesWeights(): NodeMaterialConnectionPoint;
  63426. /**
  63427. * Gets the extra matrix indices input component
  63428. */
  63429. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  63430. /**
  63431. * Gets the extra matrix weights input component
  63432. */
  63433. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  63434. /**
  63435. * Gets the world input component
  63436. */
  63437. get world(): NodeMaterialConnectionPoint;
  63438. /**
  63439. * Gets the output component
  63440. */
  63441. get output(): NodeMaterialConnectionPoint;
  63442. autoConfigure(material: NodeMaterial): void;
  63443. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  63444. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63445. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63446. protected _buildBlock(state: NodeMaterialBuildState): this;
  63447. }
  63448. }
  63449. declare module BABYLON {
  63450. /**
  63451. * Block used to add support for instances
  63452. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  63453. */
  63454. export class InstancesBlock extends NodeMaterialBlock {
  63455. /**
  63456. * Creates a new InstancesBlock
  63457. * @param name defines the block name
  63458. */
  63459. constructor(name: string);
  63460. /**
  63461. * Gets the current class name
  63462. * @returns the class name
  63463. */
  63464. getClassName(): string;
  63465. /**
  63466. * Gets the first world row input component
  63467. */
  63468. get world0(): NodeMaterialConnectionPoint;
  63469. /**
  63470. * Gets the second world row input component
  63471. */
  63472. get world1(): NodeMaterialConnectionPoint;
  63473. /**
  63474. * Gets the third world row input component
  63475. */
  63476. get world2(): NodeMaterialConnectionPoint;
  63477. /**
  63478. * Gets the forth world row input component
  63479. */
  63480. get world3(): NodeMaterialConnectionPoint;
  63481. /**
  63482. * Gets the world input component
  63483. */
  63484. get world(): NodeMaterialConnectionPoint;
  63485. /**
  63486. * Gets the output component
  63487. */
  63488. get output(): NodeMaterialConnectionPoint;
  63489. /**
  63490. * Gets the isntanceID component
  63491. */
  63492. get instanceID(): NodeMaterialConnectionPoint;
  63493. autoConfigure(material: NodeMaterial): void;
  63494. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  63495. protected _buildBlock(state: NodeMaterialBuildState): this;
  63496. }
  63497. }
  63498. declare module BABYLON {
  63499. /**
  63500. * Block used to add morph targets support to vertex shader
  63501. */
  63502. export class MorphTargetsBlock extends NodeMaterialBlock {
  63503. private _repeatableContentAnchor;
  63504. /**
  63505. * Create a new MorphTargetsBlock
  63506. * @param name defines the block name
  63507. */
  63508. constructor(name: string);
  63509. /**
  63510. * Gets the current class name
  63511. * @returns the class name
  63512. */
  63513. getClassName(): string;
  63514. /**
  63515. * Gets the position input component
  63516. */
  63517. get position(): NodeMaterialConnectionPoint;
  63518. /**
  63519. * Gets the normal input component
  63520. */
  63521. get normal(): NodeMaterialConnectionPoint;
  63522. /**
  63523. * Gets the tangent input component
  63524. */
  63525. get tangent(): NodeMaterialConnectionPoint;
  63526. /**
  63527. * Gets the tangent input component
  63528. */
  63529. get uv(): NodeMaterialConnectionPoint;
  63530. /**
  63531. * Gets the position output component
  63532. */
  63533. get positionOutput(): NodeMaterialConnectionPoint;
  63534. /**
  63535. * Gets the normal output component
  63536. */
  63537. get normalOutput(): NodeMaterialConnectionPoint;
  63538. /**
  63539. * Gets the tangent output component
  63540. */
  63541. get tangentOutput(): NodeMaterialConnectionPoint;
  63542. /**
  63543. * Gets the tangent output component
  63544. */
  63545. get uvOutput(): NodeMaterialConnectionPoint;
  63546. initialize(state: NodeMaterialBuildState): void;
  63547. autoConfigure(material: NodeMaterial): void;
  63548. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63549. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63550. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  63551. protected _buildBlock(state: NodeMaterialBuildState): this;
  63552. }
  63553. }
  63554. declare module BABYLON {
  63555. /**
  63556. * Block used to get data information from a light
  63557. */
  63558. export class LightInformationBlock extends NodeMaterialBlock {
  63559. private _lightDataUniformName;
  63560. private _lightColorUniformName;
  63561. private _lightTypeDefineName;
  63562. /**
  63563. * Gets or sets the light associated with this block
  63564. */
  63565. light: Nullable<Light>;
  63566. /**
  63567. * Creates a new LightInformationBlock
  63568. * @param name defines the block name
  63569. */
  63570. constructor(name: string);
  63571. /**
  63572. * Gets the current class name
  63573. * @returns the class name
  63574. */
  63575. getClassName(): string;
  63576. /**
  63577. * Gets the world position input component
  63578. */
  63579. get worldPosition(): NodeMaterialConnectionPoint;
  63580. /**
  63581. * Gets the direction output component
  63582. */
  63583. get direction(): NodeMaterialConnectionPoint;
  63584. /**
  63585. * Gets the direction output component
  63586. */
  63587. get color(): NodeMaterialConnectionPoint;
  63588. /**
  63589. * Gets the direction output component
  63590. */
  63591. get intensity(): NodeMaterialConnectionPoint;
  63592. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63593. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63594. protected _buildBlock(state: NodeMaterialBuildState): this;
  63595. serialize(): any;
  63596. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63597. }
  63598. }
  63599. declare module BABYLON {
  63600. /**
  63601. * Block used to add image processing support to fragment shader
  63602. */
  63603. export class ImageProcessingBlock extends NodeMaterialBlock {
  63604. /**
  63605. * Create a new ImageProcessingBlock
  63606. * @param name defines the block name
  63607. */
  63608. constructor(name: string);
  63609. /**
  63610. * Gets the current class name
  63611. * @returns the class name
  63612. */
  63613. getClassName(): string;
  63614. /**
  63615. * Gets the color input component
  63616. */
  63617. get color(): NodeMaterialConnectionPoint;
  63618. /**
  63619. * Gets the output component
  63620. */
  63621. get output(): NodeMaterialConnectionPoint;
  63622. /**
  63623. * Initialize the block and prepare the context for build
  63624. * @param state defines the state that will be used for the build
  63625. */
  63626. initialize(state: NodeMaterialBuildState): void;
  63627. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  63628. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63629. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63630. protected _buildBlock(state: NodeMaterialBuildState): this;
  63631. }
  63632. }
  63633. declare module BABYLON {
  63634. /**
  63635. * Block used to pertub normals based on a normal map
  63636. */
  63637. export class PerturbNormalBlock extends NodeMaterialBlock {
  63638. private _tangentSpaceParameterName;
  63639. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  63640. invertX: boolean;
  63641. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  63642. invertY: boolean;
  63643. /**
  63644. * Create a new PerturbNormalBlock
  63645. * @param name defines the block name
  63646. */
  63647. constructor(name: string);
  63648. /**
  63649. * Gets the current class name
  63650. * @returns the class name
  63651. */
  63652. getClassName(): string;
  63653. /**
  63654. * Gets the world position input component
  63655. */
  63656. get worldPosition(): NodeMaterialConnectionPoint;
  63657. /**
  63658. * Gets the world normal input component
  63659. */
  63660. get worldNormal(): NodeMaterialConnectionPoint;
  63661. /**
  63662. * Gets the world tangent input component
  63663. */
  63664. get worldTangent(): NodeMaterialConnectionPoint;
  63665. /**
  63666. * Gets the uv input component
  63667. */
  63668. get uv(): NodeMaterialConnectionPoint;
  63669. /**
  63670. * Gets the normal map color input component
  63671. */
  63672. get normalMapColor(): NodeMaterialConnectionPoint;
  63673. /**
  63674. * Gets the strength input component
  63675. */
  63676. get strength(): NodeMaterialConnectionPoint;
  63677. /**
  63678. * Gets the output component
  63679. */
  63680. get output(): NodeMaterialConnectionPoint;
  63681. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63682. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63683. autoConfigure(material: NodeMaterial): void;
  63684. protected _buildBlock(state: NodeMaterialBuildState): this;
  63685. protected _dumpPropertiesCode(): string;
  63686. serialize(): any;
  63687. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63688. }
  63689. }
  63690. declare module BABYLON {
  63691. /**
  63692. * Block used to discard a pixel if a value is smaller than a cutoff
  63693. */
  63694. export class DiscardBlock extends NodeMaterialBlock {
  63695. /**
  63696. * Create a new DiscardBlock
  63697. * @param name defines the block name
  63698. */
  63699. constructor(name: string);
  63700. /**
  63701. * Gets the current class name
  63702. * @returns the class name
  63703. */
  63704. getClassName(): string;
  63705. /**
  63706. * Gets the color input component
  63707. */
  63708. get value(): NodeMaterialConnectionPoint;
  63709. /**
  63710. * Gets the cutoff input component
  63711. */
  63712. get cutoff(): NodeMaterialConnectionPoint;
  63713. protected _buildBlock(state: NodeMaterialBuildState): this;
  63714. }
  63715. }
  63716. declare module BABYLON {
  63717. /**
  63718. * Block used to test if the fragment shader is front facing
  63719. */
  63720. export class FrontFacingBlock extends NodeMaterialBlock {
  63721. /**
  63722. * Creates a new FrontFacingBlock
  63723. * @param name defines the block name
  63724. */
  63725. constructor(name: string);
  63726. /**
  63727. * Gets the current class name
  63728. * @returns the class name
  63729. */
  63730. getClassName(): string;
  63731. /**
  63732. * Gets the output component
  63733. */
  63734. get output(): NodeMaterialConnectionPoint;
  63735. protected _buildBlock(state: NodeMaterialBuildState): this;
  63736. }
  63737. }
  63738. declare module BABYLON {
  63739. /**
  63740. * Block used to get the derivative value on x and y of a given input
  63741. */
  63742. export class DerivativeBlock extends NodeMaterialBlock {
  63743. /**
  63744. * Create a new DerivativeBlock
  63745. * @param name defines the block name
  63746. */
  63747. constructor(name: string);
  63748. /**
  63749. * Gets the current class name
  63750. * @returns the class name
  63751. */
  63752. getClassName(): string;
  63753. /**
  63754. * Gets the input component
  63755. */
  63756. get input(): NodeMaterialConnectionPoint;
  63757. /**
  63758. * Gets the derivative output on x
  63759. */
  63760. get dx(): NodeMaterialConnectionPoint;
  63761. /**
  63762. * Gets the derivative output on y
  63763. */
  63764. get dy(): NodeMaterialConnectionPoint;
  63765. protected _buildBlock(state: NodeMaterialBuildState): this;
  63766. }
  63767. }
  63768. declare module BABYLON {
  63769. /**
  63770. * Block used to make gl_FragCoord available
  63771. */
  63772. export class FragCoordBlock extends NodeMaterialBlock {
  63773. /**
  63774. * Creates a new FragCoordBlock
  63775. * @param name defines the block name
  63776. */
  63777. constructor(name: string);
  63778. /**
  63779. * Gets the current class name
  63780. * @returns the class name
  63781. */
  63782. getClassName(): string;
  63783. /**
  63784. * Gets the xy component
  63785. */
  63786. get xy(): NodeMaterialConnectionPoint;
  63787. /**
  63788. * Gets the xyz component
  63789. */
  63790. get xyz(): NodeMaterialConnectionPoint;
  63791. /**
  63792. * Gets the xyzw component
  63793. */
  63794. get xyzw(): NodeMaterialConnectionPoint;
  63795. /**
  63796. * Gets the x component
  63797. */
  63798. get x(): NodeMaterialConnectionPoint;
  63799. /**
  63800. * Gets the y component
  63801. */
  63802. get y(): NodeMaterialConnectionPoint;
  63803. /**
  63804. * Gets the z component
  63805. */
  63806. get z(): NodeMaterialConnectionPoint;
  63807. /**
  63808. * Gets the w component
  63809. */
  63810. get output(): NodeMaterialConnectionPoint;
  63811. protected writeOutputs(state: NodeMaterialBuildState): string;
  63812. protected _buildBlock(state: NodeMaterialBuildState): this;
  63813. }
  63814. }
  63815. declare module BABYLON {
  63816. /**
  63817. * Block used to get the screen sizes
  63818. */
  63819. export class ScreenSizeBlock extends NodeMaterialBlock {
  63820. private _varName;
  63821. private _scene;
  63822. /**
  63823. * Creates a new ScreenSizeBlock
  63824. * @param name defines the block name
  63825. */
  63826. constructor(name: string);
  63827. /**
  63828. * Gets the current class name
  63829. * @returns the class name
  63830. */
  63831. getClassName(): string;
  63832. /**
  63833. * Gets the xy component
  63834. */
  63835. get xy(): NodeMaterialConnectionPoint;
  63836. /**
  63837. * Gets the x component
  63838. */
  63839. get x(): NodeMaterialConnectionPoint;
  63840. /**
  63841. * Gets the y component
  63842. */
  63843. get y(): NodeMaterialConnectionPoint;
  63844. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63845. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  63846. protected _buildBlock(state: NodeMaterialBuildState): this;
  63847. }
  63848. }
  63849. declare module BABYLON {
  63850. /**
  63851. * Block used to add support for scene fog
  63852. */
  63853. export class FogBlock extends NodeMaterialBlock {
  63854. private _fogDistanceName;
  63855. private _fogParameters;
  63856. /**
  63857. * Create a new FogBlock
  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 world position input component
  63868. */
  63869. get worldPosition(): NodeMaterialConnectionPoint;
  63870. /**
  63871. * Gets the view input component
  63872. */
  63873. get view(): NodeMaterialConnectionPoint;
  63874. /**
  63875. * Gets the color input component
  63876. */
  63877. get input(): NodeMaterialConnectionPoint;
  63878. /**
  63879. * Gets the fog color input component
  63880. */
  63881. get fogColor(): NodeMaterialConnectionPoint;
  63882. /**
  63883. * Gets the output component
  63884. */
  63885. get output(): NodeMaterialConnectionPoint;
  63886. autoConfigure(material: NodeMaterial): void;
  63887. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63888. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63889. protected _buildBlock(state: NodeMaterialBuildState): this;
  63890. }
  63891. }
  63892. declare module BABYLON {
  63893. /**
  63894. * Block used to add light in the fragment shader
  63895. */
  63896. export class LightBlock extends NodeMaterialBlock {
  63897. private _lightId;
  63898. /**
  63899. * Gets or sets the light associated with this block
  63900. */
  63901. light: Nullable<Light>;
  63902. /**
  63903. * Create a new LightBlock
  63904. * @param name defines the block name
  63905. */
  63906. constructor(name: string);
  63907. /**
  63908. * Gets the current class name
  63909. * @returns the class name
  63910. */
  63911. getClassName(): string;
  63912. /**
  63913. * Gets the world position input component
  63914. */
  63915. get worldPosition(): NodeMaterialConnectionPoint;
  63916. /**
  63917. * Gets the world normal input component
  63918. */
  63919. get worldNormal(): NodeMaterialConnectionPoint;
  63920. /**
  63921. * Gets the camera (or eye) position component
  63922. */
  63923. get cameraPosition(): NodeMaterialConnectionPoint;
  63924. /**
  63925. * Gets the glossiness component
  63926. */
  63927. get glossiness(): NodeMaterialConnectionPoint;
  63928. /**
  63929. * Gets the glossinness power component
  63930. */
  63931. get glossPower(): NodeMaterialConnectionPoint;
  63932. /**
  63933. * Gets the diffuse color component
  63934. */
  63935. get diffuseColor(): NodeMaterialConnectionPoint;
  63936. /**
  63937. * Gets the specular color component
  63938. */
  63939. get specularColor(): NodeMaterialConnectionPoint;
  63940. /**
  63941. * Gets the view matrix component
  63942. */
  63943. get view(): NodeMaterialConnectionPoint;
  63944. /**
  63945. * Gets the diffuse output component
  63946. */
  63947. get diffuseOutput(): NodeMaterialConnectionPoint;
  63948. /**
  63949. * Gets the specular output component
  63950. */
  63951. get specularOutput(): NodeMaterialConnectionPoint;
  63952. /**
  63953. * Gets the shadow output component
  63954. */
  63955. get shadow(): NodeMaterialConnectionPoint;
  63956. autoConfigure(material: NodeMaterial): void;
  63957. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63958. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  63959. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63960. private _injectVertexCode;
  63961. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63962. serialize(): any;
  63963. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63964. }
  63965. }
  63966. declare module BABYLON {
  63967. /**
  63968. * Block used to read a reflection texture from a sampler
  63969. */
  63970. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  63971. /**
  63972. * Create a new ReflectionTextureBlock
  63973. * @param name defines the block name
  63974. */
  63975. constructor(name: string);
  63976. /**
  63977. * Gets the current class name
  63978. * @returns the class name
  63979. */
  63980. getClassName(): string;
  63981. /**
  63982. * Gets the world position input component
  63983. */
  63984. get position(): NodeMaterialConnectionPoint;
  63985. /**
  63986. * Gets the world position input component
  63987. */
  63988. get worldPosition(): NodeMaterialConnectionPoint;
  63989. /**
  63990. * Gets the world normal input component
  63991. */
  63992. get worldNormal(): NodeMaterialConnectionPoint;
  63993. /**
  63994. * Gets the world input component
  63995. */
  63996. get world(): NodeMaterialConnectionPoint;
  63997. /**
  63998. * Gets the camera (or eye) position component
  63999. */
  64000. get cameraPosition(): NodeMaterialConnectionPoint;
  64001. /**
  64002. * Gets the view input component
  64003. */
  64004. get view(): NodeMaterialConnectionPoint;
  64005. /**
  64006. * Gets the rgb output component
  64007. */
  64008. get rgb(): NodeMaterialConnectionPoint;
  64009. /**
  64010. * Gets the rgba output component
  64011. */
  64012. get rgba(): NodeMaterialConnectionPoint;
  64013. /**
  64014. * Gets the r output component
  64015. */
  64016. get r(): NodeMaterialConnectionPoint;
  64017. /**
  64018. * Gets the g output component
  64019. */
  64020. get g(): NodeMaterialConnectionPoint;
  64021. /**
  64022. * Gets the b output component
  64023. */
  64024. get b(): NodeMaterialConnectionPoint;
  64025. /**
  64026. * Gets the a output component
  64027. */
  64028. get a(): NodeMaterialConnectionPoint;
  64029. autoConfigure(material: NodeMaterial): void;
  64030. protected _buildBlock(state: NodeMaterialBuildState): this;
  64031. }
  64032. }
  64033. declare module BABYLON {
  64034. /**
  64035. * Block used to add 2 vectors
  64036. */
  64037. export class AddBlock extends NodeMaterialBlock {
  64038. /**
  64039. * Creates a new AddBlock
  64040. * @param name defines the block name
  64041. */
  64042. constructor(name: string);
  64043. /**
  64044. * Gets the current class name
  64045. * @returns the class name
  64046. */
  64047. getClassName(): string;
  64048. /**
  64049. * Gets the left operand input component
  64050. */
  64051. get left(): NodeMaterialConnectionPoint;
  64052. /**
  64053. * Gets the right operand input component
  64054. */
  64055. get right(): NodeMaterialConnectionPoint;
  64056. /**
  64057. * Gets the output component
  64058. */
  64059. get output(): NodeMaterialConnectionPoint;
  64060. protected _buildBlock(state: NodeMaterialBuildState): this;
  64061. }
  64062. }
  64063. declare module BABYLON {
  64064. /**
  64065. * Block used to scale a vector by a float
  64066. */
  64067. export class ScaleBlock extends NodeMaterialBlock {
  64068. /**
  64069. * Creates a new ScaleBlock
  64070. * @param name defines the block name
  64071. */
  64072. constructor(name: string);
  64073. /**
  64074. * Gets the current class name
  64075. * @returns the class name
  64076. */
  64077. getClassName(): string;
  64078. /**
  64079. * Gets the input component
  64080. */
  64081. get input(): NodeMaterialConnectionPoint;
  64082. /**
  64083. * Gets the factor input component
  64084. */
  64085. get factor(): NodeMaterialConnectionPoint;
  64086. /**
  64087. * Gets the output component
  64088. */
  64089. get output(): NodeMaterialConnectionPoint;
  64090. protected _buildBlock(state: NodeMaterialBuildState): this;
  64091. }
  64092. }
  64093. declare module BABYLON {
  64094. /**
  64095. * Block used to clamp a float
  64096. */
  64097. export class ClampBlock extends NodeMaterialBlock {
  64098. /** Gets or sets the minimum range */
  64099. minimum: number;
  64100. /** Gets or sets the maximum range */
  64101. maximum: number;
  64102. /**
  64103. * Creates a new ClampBlock
  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 value input component
  64114. */
  64115. get value(): NodeMaterialConnectionPoint;
  64116. /**
  64117. * Gets the output component
  64118. */
  64119. get output(): NodeMaterialConnectionPoint;
  64120. protected _buildBlock(state: NodeMaterialBuildState): this;
  64121. protected _dumpPropertiesCode(): string;
  64122. serialize(): any;
  64123. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64124. }
  64125. }
  64126. declare module BABYLON {
  64127. /**
  64128. * Block used to apply a cross product between 2 vectors
  64129. */
  64130. export class CrossBlock extends NodeMaterialBlock {
  64131. /**
  64132. * Creates a new CrossBlock
  64133. * @param name defines the block name
  64134. */
  64135. constructor(name: string);
  64136. /**
  64137. * Gets the current class name
  64138. * @returns the class name
  64139. */
  64140. getClassName(): string;
  64141. /**
  64142. * Gets the left operand input component
  64143. */
  64144. get left(): NodeMaterialConnectionPoint;
  64145. /**
  64146. * Gets the right operand input component
  64147. */
  64148. get right(): NodeMaterialConnectionPoint;
  64149. /**
  64150. * Gets the output component
  64151. */
  64152. get output(): NodeMaterialConnectionPoint;
  64153. protected _buildBlock(state: NodeMaterialBuildState): this;
  64154. }
  64155. }
  64156. declare module BABYLON {
  64157. /**
  64158. * Block used to apply a dot product between 2 vectors
  64159. */
  64160. export class DotBlock extends NodeMaterialBlock {
  64161. /**
  64162. * Creates a new DotBlock
  64163. * @param name defines the block name
  64164. */
  64165. constructor(name: string);
  64166. /**
  64167. * Gets the current class name
  64168. * @returns the class name
  64169. */
  64170. getClassName(): string;
  64171. /**
  64172. * Gets the left operand input component
  64173. */
  64174. get left(): NodeMaterialConnectionPoint;
  64175. /**
  64176. * Gets the right operand input component
  64177. */
  64178. get right(): NodeMaterialConnectionPoint;
  64179. /**
  64180. * Gets the output component
  64181. */
  64182. get output(): NodeMaterialConnectionPoint;
  64183. protected _buildBlock(state: NodeMaterialBuildState): this;
  64184. }
  64185. }
  64186. declare module BABYLON {
  64187. /**
  64188. * Block used to normalize a vector
  64189. */
  64190. export class NormalizeBlock extends NodeMaterialBlock {
  64191. /**
  64192. * Creates a new NormalizeBlock
  64193. * @param name defines the block name
  64194. */
  64195. constructor(name: string);
  64196. /**
  64197. * Gets the current class name
  64198. * @returns the class name
  64199. */
  64200. getClassName(): string;
  64201. /**
  64202. * Gets the input component
  64203. */
  64204. get input(): NodeMaterialConnectionPoint;
  64205. /**
  64206. * Gets the output component
  64207. */
  64208. get output(): NodeMaterialConnectionPoint;
  64209. protected _buildBlock(state: NodeMaterialBuildState): this;
  64210. }
  64211. }
  64212. declare module BABYLON {
  64213. /**
  64214. * Block used to create a Color3/4 out of individual inputs (one for each component)
  64215. */
  64216. export class ColorMergerBlock extends NodeMaterialBlock {
  64217. /**
  64218. * Create a new ColorMergerBlock
  64219. * @param name defines the block name
  64220. */
  64221. constructor(name: string);
  64222. /**
  64223. * Gets the current class name
  64224. * @returns the class name
  64225. */
  64226. getClassName(): string;
  64227. /**
  64228. * Gets the rgb component (input)
  64229. */
  64230. get rgbIn(): NodeMaterialConnectionPoint;
  64231. /**
  64232. * Gets the r component (input)
  64233. */
  64234. get r(): NodeMaterialConnectionPoint;
  64235. /**
  64236. * Gets the g component (input)
  64237. */
  64238. get g(): NodeMaterialConnectionPoint;
  64239. /**
  64240. * Gets the b component (input)
  64241. */
  64242. get b(): NodeMaterialConnectionPoint;
  64243. /**
  64244. * Gets the a component (input)
  64245. */
  64246. get a(): NodeMaterialConnectionPoint;
  64247. /**
  64248. * Gets the rgba component (output)
  64249. */
  64250. get rgba(): NodeMaterialConnectionPoint;
  64251. /**
  64252. * Gets the rgb component (output)
  64253. */
  64254. get rgbOut(): NodeMaterialConnectionPoint;
  64255. /**
  64256. * Gets the rgb component (output)
  64257. * @deprecated Please use rgbOut instead.
  64258. */
  64259. get rgb(): NodeMaterialConnectionPoint;
  64260. protected _buildBlock(state: NodeMaterialBuildState): this;
  64261. }
  64262. }
  64263. declare module BABYLON {
  64264. /**
  64265. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  64266. */
  64267. export class VectorSplitterBlock extends NodeMaterialBlock {
  64268. /**
  64269. * Create a new VectorSplitterBlock
  64270. * @param name defines the block name
  64271. */
  64272. constructor(name: string);
  64273. /**
  64274. * Gets the current class name
  64275. * @returns the class name
  64276. */
  64277. getClassName(): string;
  64278. /**
  64279. * Gets the xyzw component (input)
  64280. */
  64281. get xyzw(): NodeMaterialConnectionPoint;
  64282. /**
  64283. * Gets the xyz component (input)
  64284. */
  64285. get xyzIn(): NodeMaterialConnectionPoint;
  64286. /**
  64287. * Gets the xy component (input)
  64288. */
  64289. get xyIn(): NodeMaterialConnectionPoint;
  64290. /**
  64291. * Gets the xyz component (output)
  64292. */
  64293. get xyzOut(): NodeMaterialConnectionPoint;
  64294. /**
  64295. * Gets the xy component (output)
  64296. */
  64297. get xyOut(): NodeMaterialConnectionPoint;
  64298. /**
  64299. * Gets the x component (output)
  64300. */
  64301. get x(): NodeMaterialConnectionPoint;
  64302. /**
  64303. * Gets the y component (output)
  64304. */
  64305. get y(): NodeMaterialConnectionPoint;
  64306. /**
  64307. * Gets the z component (output)
  64308. */
  64309. get z(): NodeMaterialConnectionPoint;
  64310. /**
  64311. * Gets the w component (output)
  64312. */
  64313. get w(): NodeMaterialConnectionPoint;
  64314. protected _inputRename(name: string): string;
  64315. protected _outputRename(name: string): string;
  64316. protected _buildBlock(state: NodeMaterialBuildState): this;
  64317. }
  64318. }
  64319. declare module BABYLON {
  64320. /**
  64321. * Block used to lerp between 2 values
  64322. */
  64323. export class LerpBlock extends NodeMaterialBlock {
  64324. /**
  64325. * Creates a new LerpBlock
  64326. * @param name defines the block name
  64327. */
  64328. constructor(name: string);
  64329. /**
  64330. * Gets the current class name
  64331. * @returns the class name
  64332. */
  64333. getClassName(): string;
  64334. /**
  64335. * Gets the left operand input component
  64336. */
  64337. get left(): NodeMaterialConnectionPoint;
  64338. /**
  64339. * Gets the right operand input component
  64340. */
  64341. get right(): NodeMaterialConnectionPoint;
  64342. /**
  64343. * Gets the gradient operand input component
  64344. */
  64345. get gradient(): NodeMaterialConnectionPoint;
  64346. /**
  64347. * Gets the output component
  64348. */
  64349. get output(): NodeMaterialConnectionPoint;
  64350. protected _buildBlock(state: NodeMaterialBuildState): this;
  64351. }
  64352. }
  64353. declare module BABYLON {
  64354. /**
  64355. * Block used to divide 2 vectors
  64356. */
  64357. export class DivideBlock extends NodeMaterialBlock {
  64358. /**
  64359. * Creates a new DivideBlock
  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 output component
  64378. */
  64379. get output(): NodeMaterialConnectionPoint;
  64380. protected _buildBlock(state: NodeMaterialBuildState): this;
  64381. }
  64382. }
  64383. declare module BABYLON {
  64384. /**
  64385. * Block used to subtract 2 vectors
  64386. */
  64387. export class SubtractBlock extends NodeMaterialBlock {
  64388. /**
  64389. * Creates a new SubtractBlock
  64390. * @param name defines the block name
  64391. */
  64392. constructor(name: string);
  64393. /**
  64394. * Gets the current class name
  64395. * @returns the class name
  64396. */
  64397. getClassName(): string;
  64398. /**
  64399. * Gets the left operand input component
  64400. */
  64401. get left(): NodeMaterialConnectionPoint;
  64402. /**
  64403. * Gets the right operand input component
  64404. */
  64405. get right(): NodeMaterialConnectionPoint;
  64406. /**
  64407. * Gets the output component
  64408. */
  64409. get output(): NodeMaterialConnectionPoint;
  64410. protected _buildBlock(state: NodeMaterialBuildState): this;
  64411. }
  64412. }
  64413. declare module BABYLON {
  64414. /**
  64415. * Block used to step a value
  64416. */
  64417. export class StepBlock extends NodeMaterialBlock {
  64418. /**
  64419. * Creates a new StepBlock
  64420. * @param name defines the block name
  64421. */
  64422. constructor(name: string);
  64423. /**
  64424. * Gets the current class name
  64425. * @returns the class name
  64426. */
  64427. getClassName(): string;
  64428. /**
  64429. * Gets the value operand input component
  64430. */
  64431. get value(): NodeMaterialConnectionPoint;
  64432. /**
  64433. * Gets the edge operand input component
  64434. */
  64435. get edge(): NodeMaterialConnectionPoint;
  64436. /**
  64437. * Gets the output component
  64438. */
  64439. get output(): NodeMaterialConnectionPoint;
  64440. protected _buildBlock(state: NodeMaterialBuildState): this;
  64441. }
  64442. }
  64443. declare module BABYLON {
  64444. /**
  64445. * Block used to get the opposite (1 - x) of a value
  64446. */
  64447. export class OneMinusBlock extends NodeMaterialBlock {
  64448. /**
  64449. * Creates a new OneMinusBlock
  64450. * @param name defines the block name
  64451. */
  64452. constructor(name: string);
  64453. /**
  64454. * Gets the current class name
  64455. * @returns the class name
  64456. */
  64457. getClassName(): string;
  64458. /**
  64459. * Gets the input component
  64460. */
  64461. get input(): NodeMaterialConnectionPoint;
  64462. /**
  64463. * Gets the output component
  64464. */
  64465. get output(): NodeMaterialConnectionPoint;
  64466. protected _buildBlock(state: NodeMaterialBuildState): this;
  64467. }
  64468. }
  64469. declare module BABYLON {
  64470. /**
  64471. * Block used to get the view direction
  64472. */
  64473. export class ViewDirectionBlock extends NodeMaterialBlock {
  64474. /**
  64475. * Creates a new ViewDirectionBlock
  64476. * @param name defines the block name
  64477. */
  64478. constructor(name: string);
  64479. /**
  64480. * Gets the current class name
  64481. * @returns the class name
  64482. */
  64483. getClassName(): string;
  64484. /**
  64485. * Gets the world position component
  64486. */
  64487. get worldPosition(): NodeMaterialConnectionPoint;
  64488. /**
  64489. * Gets the camera position component
  64490. */
  64491. get cameraPosition(): NodeMaterialConnectionPoint;
  64492. /**
  64493. * Gets the output component
  64494. */
  64495. get output(): NodeMaterialConnectionPoint;
  64496. autoConfigure(material: NodeMaterial): void;
  64497. protected _buildBlock(state: NodeMaterialBuildState): this;
  64498. }
  64499. }
  64500. declare module BABYLON {
  64501. /**
  64502. * Block used to compute fresnel value
  64503. */
  64504. export class FresnelBlock extends NodeMaterialBlock {
  64505. /**
  64506. * Create a new FresnelBlock
  64507. * @param name defines the block name
  64508. */
  64509. constructor(name: string);
  64510. /**
  64511. * Gets the current class name
  64512. * @returns the class name
  64513. */
  64514. getClassName(): string;
  64515. /**
  64516. * Gets the world normal input component
  64517. */
  64518. get worldNormal(): NodeMaterialConnectionPoint;
  64519. /**
  64520. * Gets the view direction input component
  64521. */
  64522. get viewDirection(): NodeMaterialConnectionPoint;
  64523. /**
  64524. * Gets the bias input component
  64525. */
  64526. get bias(): NodeMaterialConnectionPoint;
  64527. /**
  64528. * Gets the camera (or eye) position component
  64529. */
  64530. get power(): NodeMaterialConnectionPoint;
  64531. /**
  64532. * Gets the fresnel output component
  64533. */
  64534. get fresnel(): NodeMaterialConnectionPoint;
  64535. autoConfigure(material: NodeMaterial): void;
  64536. protected _buildBlock(state: NodeMaterialBuildState): this;
  64537. }
  64538. }
  64539. declare module BABYLON {
  64540. /**
  64541. * Block used to get the max of 2 values
  64542. */
  64543. export class MaxBlock extends NodeMaterialBlock {
  64544. /**
  64545. * Creates a new MaxBlock
  64546. * @param name defines the block name
  64547. */
  64548. constructor(name: string);
  64549. /**
  64550. * Gets the current class name
  64551. * @returns the class name
  64552. */
  64553. getClassName(): string;
  64554. /**
  64555. * Gets the left operand input component
  64556. */
  64557. get left(): NodeMaterialConnectionPoint;
  64558. /**
  64559. * Gets the right operand input component
  64560. */
  64561. get right(): NodeMaterialConnectionPoint;
  64562. /**
  64563. * Gets the output component
  64564. */
  64565. get output(): NodeMaterialConnectionPoint;
  64566. protected _buildBlock(state: NodeMaterialBuildState): this;
  64567. }
  64568. }
  64569. declare module BABYLON {
  64570. /**
  64571. * Block used to get the min of 2 values
  64572. */
  64573. export class MinBlock extends NodeMaterialBlock {
  64574. /**
  64575. * Creates a new MinBlock
  64576. * @param name defines the block name
  64577. */
  64578. constructor(name: string);
  64579. /**
  64580. * Gets the current class name
  64581. * @returns the class name
  64582. */
  64583. getClassName(): string;
  64584. /**
  64585. * Gets the left operand input component
  64586. */
  64587. get left(): NodeMaterialConnectionPoint;
  64588. /**
  64589. * Gets the right operand input component
  64590. */
  64591. get right(): NodeMaterialConnectionPoint;
  64592. /**
  64593. * Gets the output component
  64594. */
  64595. get output(): NodeMaterialConnectionPoint;
  64596. protected _buildBlock(state: NodeMaterialBuildState): this;
  64597. }
  64598. }
  64599. declare module BABYLON {
  64600. /**
  64601. * Block used to get the distance between 2 values
  64602. */
  64603. export class DistanceBlock extends NodeMaterialBlock {
  64604. /**
  64605. * Creates a new DistanceBlock
  64606. * @param name defines the block name
  64607. */
  64608. constructor(name: string);
  64609. /**
  64610. * Gets the current class name
  64611. * @returns the class name
  64612. */
  64613. getClassName(): string;
  64614. /**
  64615. * Gets the left operand input component
  64616. */
  64617. get left(): NodeMaterialConnectionPoint;
  64618. /**
  64619. * Gets the right operand input component
  64620. */
  64621. get right(): NodeMaterialConnectionPoint;
  64622. /**
  64623. * Gets the output component
  64624. */
  64625. get output(): NodeMaterialConnectionPoint;
  64626. protected _buildBlock(state: NodeMaterialBuildState): this;
  64627. }
  64628. }
  64629. declare module BABYLON {
  64630. /**
  64631. * Block used to get the length of a vector
  64632. */
  64633. export class LengthBlock extends NodeMaterialBlock {
  64634. /**
  64635. * Creates a new LengthBlock
  64636. * @param name defines the block name
  64637. */
  64638. constructor(name: string);
  64639. /**
  64640. * Gets the current class name
  64641. * @returns the class name
  64642. */
  64643. getClassName(): string;
  64644. /**
  64645. * Gets the value input component
  64646. */
  64647. get value(): NodeMaterialConnectionPoint;
  64648. /**
  64649. * Gets the output component
  64650. */
  64651. get output(): NodeMaterialConnectionPoint;
  64652. protected _buildBlock(state: NodeMaterialBuildState): this;
  64653. }
  64654. }
  64655. declare module BABYLON {
  64656. /**
  64657. * Block used to get negative version of a value (i.e. x * -1)
  64658. */
  64659. export class NegateBlock extends NodeMaterialBlock {
  64660. /**
  64661. * Creates a new NegateBlock
  64662. * @param name defines the block name
  64663. */
  64664. constructor(name: string);
  64665. /**
  64666. * Gets the current class name
  64667. * @returns the class name
  64668. */
  64669. getClassName(): string;
  64670. /**
  64671. * Gets the value input component
  64672. */
  64673. get value(): NodeMaterialConnectionPoint;
  64674. /**
  64675. * Gets the output component
  64676. */
  64677. get output(): NodeMaterialConnectionPoint;
  64678. protected _buildBlock(state: NodeMaterialBuildState): this;
  64679. }
  64680. }
  64681. declare module BABYLON {
  64682. /**
  64683. * Block used to get the value of the first parameter raised to the power of the second
  64684. */
  64685. export class PowBlock extends NodeMaterialBlock {
  64686. /**
  64687. * Creates a new PowBlock
  64688. * @param name defines the block name
  64689. */
  64690. constructor(name: string);
  64691. /**
  64692. * Gets the current class name
  64693. * @returns the class name
  64694. */
  64695. getClassName(): string;
  64696. /**
  64697. * Gets the value operand input component
  64698. */
  64699. get value(): NodeMaterialConnectionPoint;
  64700. /**
  64701. * Gets the power operand input component
  64702. */
  64703. get power(): NodeMaterialConnectionPoint;
  64704. /**
  64705. * Gets the output component
  64706. */
  64707. get output(): NodeMaterialConnectionPoint;
  64708. protected _buildBlock(state: NodeMaterialBuildState): this;
  64709. }
  64710. }
  64711. declare module BABYLON {
  64712. /**
  64713. * Block used to get a random number
  64714. */
  64715. export class RandomNumberBlock extends NodeMaterialBlock {
  64716. /**
  64717. * Creates a new RandomNumberBlock
  64718. * @param name defines the block name
  64719. */
  64720. constructor(name: string);
  64721. /**
  64722. * Gets the current class name
  64723. * @returns the class name
  64724. */
  64725. getClassName(): string;
  64726. /**
  64727. * Gets the seed input component
  64728. */
  64729. get seed(): NodeMaterialConnectionPoint;
  64730. /**
  64731. * Gets the output component
  64732. */
  64733. get output(): NodeMaterialConnectionPoint;
  64734. protected _buildBlock(state: NodeMaterialBuildState): this;
  64735. }
  64736. }
  64737. declare module BABYLON {
  64738. /**
  64739. * Block used to compute arc tangent of 2 values
  64740. */
  64741. export class ArcTan2Block extends NodeMaterialBlock {
  64742. /**
  64743. * Creates a new ArcTan2Block
  64744. * @param name defines the block name
  64745. */
  64746. constructor(name: string);
  64747. /**
  64748. * Gets the current class name
  64749. * @returns the class name
  64750. */
  64751. getClassName(): string;
  64752. /**
  64753. * Gets the x operand input component
  64754. */
  64755. get x(): NodeMaterialConnectionPoint;
  64756. /**
  64757. * Gets the y operand input component
  64758. */
  64759. get y(): NodeMaterialConnectionPoint;
  64760. /**
  64761. * Gets the output component
  64762. */
  64763. get output(): NodeMaterialConnectionPoint;
  64764. protected _buildBlock(state: NodeMaterialBuildState): this;
  64765. }
  64766. }
  64767. declare module BABYLON {
  64768. /**
  64769. * Block used to smooth step a value
  64770. */
  64771. export class SmoothStepBlock extends NodeMaterialBlock {
  64772. /**
  64773. * Creates a new SmoothStepBlock
  64774. * @param name defines the block name
  64775. */
  64776. constructor(name: string);
  64777. /**
  64778. * Gets the current class name
  64779. * @returns the class name
  64780. */
  64781. getClassName(): string;
  64782. /**
  64783. * Gets the value operand input component
  64784. */
  64785. get value(): NodeMaterialConnectionPoint;
  64786. /**
  64787. * Gets the first edge operand input component
  64788. */
  64789. get edge0(): NodeMaterialConnectionPoint;
  64790. /**
  64791. * Gets the second edge operand input component
  64792. */
  64793. get edge1(): 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 get the reciprocal (1 / x) of a value
  64804. */
  64805. export class ReciprocalBlock extends NodeMaterialBlock {
  64806. /**
  64807. * Creates a new ReciprocalBlock
  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 input component
  64818. */
  64819. get input(): NodeMaterialConnectionPoint;
  64820. /**
  64821. * Gets the output component
  64822. */
  64823. get output(): NodeMaterialConnectionPoint;
  64824. protected _buildBlock(state: NodeMaterialBuildState): this;
  64825. }
  64826. }
  64827. declare module BABYLON {
  64828. /**
  64829. * Block used to replace a color by another one
  64830. */
  64831. export class ReplaceColorBlock extends NodeMaterialBlock {
  64832. /**
  64833. * Creates a new ReplaceColorBlock
  64834. * @param name defines the block name
  64835. */
  64836. constructor(name: string);
  64837. /**
  64838. * Gets the current class name
  64839. * @returns the class name
  64840. */
  64841. getClassName(): string;
  64842. /**
  64843. * Gets the value input component
  64844. */
  64845. get value(): NodeMaterialConnectionPoint;
  64846. /**
  64847. * Gets the reference input component
  64848. */
  64849. get reference(): NodeMaterialConnectionPoint;
  64850. /**
  64851. * Gets the distance input component
  64852. */
  64853. get distance(): NodeMaterialConnectionPoint;
  64854. /**
  64855. * Gets the replacement input component
  64856. */
  64857. get replacement(): NodeMaterialConnectionPoint;
  64858. /**
  64859. * Gets the output component
  64860. */
  64861. get output(): NodeMaterialConnectionPoint;
  64862. protected _buildBlock(state: NodeMaterialBuildState): this;
  64863. }
  64864. }
  64865. declare module BABYLON {
  64866. /**
  64867. * Block used to posterize a value
  64868. * @see https://en.wikipedia.org/wiki/Posterization
  64869. */
  64870. export class PosterizeBlock extends NodeMaterialBlock {
  64871. /**
  64872. * Creates a new PosterizeBlock
  64873. * @param name defines the block name
  64874. */
  64875. constructor(name: string);
  64876. /**
  64877. * Gets the current class name
  64878. * @returns the class name
  64879. */
  64880. getClassName(): string;
  64881. /**
  64882. * Gets the value input component
  64883. */
  64884. get value(): NodeMaterialConnectionPoint;
  64885. /**
  64886. * Gets the steps input component
  64887. */
  64888. get steps(): NodeMaterialConnectionPoint;
  64889. /**
  64890. * Gets the output component
  64891. */
  64892. get output(): NodeMaterialConnectionPoint;
  64893. protected _buildBlock(state: NodeMaterialBuildState): this;
  64894. }
  64895. }
  64896. declare module BABYLON {
  64897. /**
  64898. * Operations supported by the Wave block
  64899. */
  64900. export enum WaveBlockKind {
  64901. /** SawTooth */
  64902. SawTooth = 0,
  64903. /** Square */
  64904. Square = 1,
  64905. /** Triangle */
  64906. Triangle = 2
  64907. }
  64908. /**
  64909. * Block used to apply wave operation to floats
  64910. */
  64911. export class WaveBlock extends NodeMaterialBlock {
  64912. /**
  64913. * Gets or sets the kibnd of wave to be applied by the block
  64914. */
  64915. kind: WaveBlockKind;
  64916. /**
  64917. * Creates a new WaveBlock
  64918. * @param name defines the block name
  64919. */
  64920. constructor(name: string);
  64921. /**
  64922. * Gets the current class name
  64923. * @returns the class name
  64924. */
  64925. getClassName(): string;
  64926. /**
  64927. * Gets the input component
  64928. */
  64929. get input(): NodeMaterialConnectionPoint;
  64930. /**
  64931. * Gets the output component
  64932. */
  64933. get output(): NodeMaterialConnectionPoint;
  64934. protected _buildBlock(state: NodeMaterialBuildState): this;
  64935. serialize(): any;
  64936. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64937. }
  64938. }
  64939. declare module BABYLON {
  64940. /**
  64941. * Class used to store a color step for the GradientBlock
  64942. */
  64943. export class GradientBlockColorStep {
  64944. private _step;
  64945. /**
  64946. * Gets value indicating which step this color is associated with (between 0 and 1)
  64947. */
  64948. get step(): number;
  64949. /**
  64950. * Sets a value indicating which step this color is associated with (between 0 and 1)
  64951. */
  64952. set step(val: number);
  64953. private _color;
  64954. /**
  64955. * Gets the color associated with this step
  64956. */
  64957. get color(): Color3;
  64958. /**
  64959. * Sets the color associated with this step
  64960. */
  64961. set color(val: Color3);
  64962. /**
  64963. * Creates a new GradientBlockColorStep
  64964. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  64965. * @param color defines the color associated with this step
  64966. */
  64967. constructor(step: number, color: Color3);
  64968. }
  64969. /**
  64970. * Block used to return a color from a gradient based on an input value between 0 and 1
  64971. */
  64972. export class GradientBlock extends NodeMaterialBlock {
  64973. /**
  64974. * Gets or sets the list of color steps
  64975. */
  64976. colorSteps: GradientBlockColorStep[];
  64977. /** Gets an observable raised when the value is changed */
  64978. onValueChangedObservable: Observable<GradientBlock>;
  64979. /** calls observable when the value is changed*/
  64980. colorStepsUpdated(): void;
  64981. /**
  64982. * Creates a new GradientBlock
  64983. * @param name defines the block name
  64984. */
  64985. constructor(name: string);
  64986. /**
  64987. * Gets the current class name
  64988. * @returns the class name
  64989. */
  64990. getClassName(): string;
  64991. /**
  64992. * Gets the gradient input component
  64993. */
  64994. get gradient(): NodeMaterialConnectionPoint;
  64995. /**
  64996. * Gets the output component
  64997. */
  64998. get output(): NodeMaterialConnectionPoint;
  64999. private _writeColorConstant;
  65000. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65001. serialize(): any;
  65002. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65003. protected _dumpPropertiesCode(): string;
  65004. }
  65005. }
  65006. declare module BABYLON {
  65007. /**
  65008. * Block used to normalize lerp between 2 values
  65009. */
  65010. export class NLerpBlock extends NodeMaterialBlock {
  65011. /**
  65012. * Creates a new NLerpBlock
  65013. * @param name defines the block name
  65014. */
  65015. constructor(name: string);
  65016. /**
  65017. * Gets the current class name
  65018. * @returns the class name
  65019. */
  65020. getClassName(): string;
  65021. /**
  65022. * Gets the left operand input component
  65023. */
  65024. get left(): NodeMaterialConnectionPoint;
  65025. /**
  65026. * Gets the right operand input component
  65027. */
  65028. get right(): NodeMaterialConnectionPoint;
  65029. /**
  65030. * Gets the gradient operand input component
  65031. */
  65032. get gradient(): NodeMaterialConnectionPoint;
  65033. /**
  65034. * Gets the output component
  65035. */
  65036. get output(): NodeMaterialConnectionPoint;
  65037. protected _buildBlock(state: NodeMaterialBuildState): this;
  65038. }
  65039. }
  65040. declare module BABYLON {
  65041. /**
  65042. * block used to Generate a Worley Noise 3D Noise Pattern
  65043. */
  65044. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  65045. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65046. manhattanDistance: boolean;
  65047. /**
  65048. * Creates a new WorleyNoise3DBlock
  65049. * @param name defines the block name
  65050. */
  65051. constructor(name: string);
  65052. /**
  65053. * Gets the current class name
  65054. * @returns the class name
  65055. */
  65056. getClassName(): string;
  65057. /**
  65058. * Gets the seed input component
  65059. */
  65060. get seed(): NodeMaterialConnectionPoint;
  65061. /**
  65062. * Gets the jitter input component
  65063. */
  65064. get jitter(): NodeMaterialConnectionPoint;
  65065. /**
  65066. * Gets the output component
  65067. */
  65068. get output(): NodeMaterialConnectionPoint;
  65069. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65070. /**
  65071. * Exposes the properties to the UI?
  65072. */
  65073. protected _dumpPropertiesCode(): string;
  65074. /**
  65075. * Exposes the properties to the Seralize?
  65076. */
  65077. serialize(): any;
  65078. /**
  65079. * Exposes the properties to the deseralize?
  65080. */
  65081. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65082. }
  65083. }
  65084. declare module BABYLON {
  65085. /**
  65086. * block used to Generate a Simplex Perlin 3d Noise Pattern
  65087. */
  65088. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  65089. /**
  65090. * Creates a new SimplexPerlin3DBlock
  65091. * @param name defines the block name
  65092. */
  65093. constructor(name: string);
  65094. /**
  65095. * Gets the current class name
  65096. * @returns the class name
  65097. */
  65098. getClassName(): string;
  65099. /**
  65100. * Gets the seed operand input component
  65101. */
  65102. get seed(): NodeMaterialConnectionPoint;
  65103. /**
  65104. * Gets the output component
  65105. */
  65106. get output(): NodeMaterialConnectionPoint;
  65107. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65108. }
  65109. }
  65110. declare module BABYLON {
  65111. /**
  65112. * Block used to blend normals
  65113. */
  65114. export class NormalBlendBlock extends NodeMaterialBlock {
  65115. /**
  65116. * Creates a new NormalBlendBlock
  65117. * @param name defines the block name
  65118. */
  65119. constructor(name: string);
  65120. /**
  65121. * Gets the current class name
  65122. * @returns the class name
  65123. */
  65124. getClassName(): string;
  65125. /**
  65126. * Gets the first input component
  65127. */
  65128. get normalMap0(): NodeMaterialConnectionPoint;
  65129. /**
  65130. * Gets the second input component
  65131. */
  65132. get normalMap1(): NodeMaterialConnectionPoint;
  65133. /**
  65134. * Gets the output component
  65135. */
  65136. get output(): NodeMaterialConnectionPoint;
  65137. protected _buildBlock(state: NodeMaterialBuildState): this;
  65138. }
  65139. }
  65140. declare module BABYLON {
  65141. /**
  65142. * Block used to rotate a 2d vector by a given angle
  65143. */
  65144. export class Rotate2dBlock extends NodeMaterialBlock {
  65145. /**
  65146. * Creates a new Rotate2dBlock
  65147. * @param name defines the block name
  65148. */
  65149. constructor(name: string);
  65150. /**
  65151. * Gets the current class name
  65152. * @returns the class name
  65153. */
  65154. getClassName(): string;
  65155. /**
  65156. * Gets the input vector
  65157. */
  65158. get input(): NodeMaterialConnectionPoint;
  65159. /**
  65160. * Gets the input angle
  65161. */
  65162. get angle(): NodeMaterialConnectionPoint;
  65163. /**
  65164. * Gets the output component
  65165. */
  65166. get output(): NodeMaterialConnectionPoint;
  65167. autoConfigure(material: NodeMaterial): void;
  65168. protected _buildBlock(state: NodeMaterialBuildState): this;
  65169. }
  65170. }
  65171. declare module BABYLON {
  65172. /**
  65173. * Block used to get the reflected vector from a direction and a normal
  65174. */
  65175. export class ReflectBlock extends NodeMaterialBlock {
  65176. /**
  65177. * Creates a new ReflectBlock
  65178. * @param name defines the block name
  65179. */
  65180. constructor(name: string);
  65181. /**
  65182. * Gets the current class name
  65183. * @returns the class name
  65184. */
  65185. getClassName(): string;
  65186. /**
  65187. * Gets the incident component
  65188. */
  65189. get incident(): NodeMaterialConnectionPoint;
  65190. /**
  65191. * Gets the normal component
  65192. */
  65193. get normal(): NodeMaterialConnectionPoint;
  65194. /**
  65195. * Gets the output component
  65196. */
  65197. get output(): NodeMaterialConnectionPoint;
  65198. protected _buildBlock(state: NodeMaterialBuildState): this;
  65199. }
  65200. }
  65201. declare module BABYLON {
  65202. /**
  65203. * Block used to get the refracted vector from a direction and a normal
  65204. */
  65205. export class RefractBlock extends NodeMaterialBlock {
  65206. /**
  65207. * Creates a new RefractBlock
  65208. * @param name defines the block name
  65209. */
  65210. constructor(name: string);
  65211. /**
  65212. * Gets the current class name
  65213. * @returns the class name
  65214. */
  65215. getClassName(): string;
  65216. /**
  65217. * Gets the incident component
  65218. */
  65219. get incident(): NodeMaterialConnectionPoint;
  65220. /**
  65221. * Gets the normal component
  65222. */
  65223. get normal(): NodeMaterialConnectionPoint;
  65224. /**
  65225. * Gets the index of refraction component
  65226. */
  65227. get ior(): 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 desaturate a color
  65238. */
  65239. export class DesaturateBlock extends NodeMaterialBlock {
  65240. /**
  65241. * Creates a new DesaturateBlock
  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 color operand input component
  65252. */
  65253. get color(): NodeMaterialConnectionPoint;
  65254. /**
  65255. * Gets the level operand input component
  65256. */
  65257. get level(): NodeMaterialConnectionPoint;
  65258. /**
  65259. * Gets the output component
  65260. */
  65261. get output(): NodeMaterialConnectionPoint;
  65262. protected _buildBlock(state: NodeMaterialBuildState): this;
  65263. }
  65264. }
  65265. declare module BABYLON {
  65266. /**
  65267. * Block used to implement the ambient occlusion module of the PBR material
  65268. */
  65269. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  65270. /**
  65271. * Create a new AmbientOcclusionBlock
  65272. * @param name defines the block name
  65273. */
  65274. constructor(name: string);
  65275. /**
  65276. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  65277. */
  65278. useAmbientInGrayScale: boolean;
  65279. /**
  65280. * Initialize the block and prepare the context for build
  65281. * @param state defines the state that will be used for the build
  65282. */
  65283. initialize(state: NodeMaterialBuildState): void;
  65284. /**
  65285. * Gets the current class name
  65286. * @returns the class name
  65287. */
  65288. getClassName(): string;
  65289. /**
  65290. * Gets the texture input component
  65291. */
  65292. get texture(): NodeMaterialConnectionPoint;
  65293. /**
  65294. * Gets the texture intensity component
  65295. */
  65296. get intensity(): NodeMaterialConnectionPoint;
  65297. /**
  65298. * Gets the direct light intensity input component
  65299. */
  65300. get directLightIntensity(): NodeMaterialConnectionPoint;
  65301. /**
  65302. * Gets the ambient occlusion object output component
  65303. */
  65304. get ambientOcc(): NodeMaterialConnectionPoint;
  65305. /**
  65306. * Gets the main code of the block (fragment side)
  65307. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  65308. * @returns the shader code
  65309. */
  65310. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  65311. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65312. protected _buildBlock(state: NodeMaterialBuildState): this;
  65313. protected _dumpPropertiesCode(): string;
  65314. serialize(): any;
  65315. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65316. }
  65317. }
  65318. declare module BABYLON {
  65319. /**
  65320. * Block used to implement the reflection module of the PBR material
  65321. */
  65322. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  65323. /** @hidden */
  65324. _defineLODReflectionAlpha: string;
  65325. /** @hidden */
  65326. _defineLinearSpecularReflection: string;
  65327. private _vEnvironmentIrradianceName;
  65328. /** @hidden */
  65329. _vReflectionMicrosurfaceInfosName: string;
  65330. /** @hidden */
  65331. _vReflectionInfosName: string;
  65332. /** @hidden */
  65333. _vReflectionFilteringInfoName: string;
  65334. private _scene;
  65335. /**
  65336. * The three properties below are set by the main PBR block prior to calling methods of this class.
  65337. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65338. * It's less burden on the user side in the editor part.
  65339. */
  65340. /** @hidden */
  65341. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65342. /** @hidden */
  65343. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65344. /** @hidden */
  65345. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  65346. /**
  65347. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  65348. * diffuse part of the IBL.
  65349. */
  65350. useSphericalHarmonics: boolean;
  65351. /**
  65352. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  65353. */
  65354. forceIrradianceInFragment: boolean;
  65355. /**
  65356. * Create a new ReflectionBlock
  65357. * @param name defines the block name
  65358. */
  65359. constructor(name: string);
  65360. /**
  65361. * Gets the current class name
  65362. * @returns the class name
  65363. */
  65364. getClassName(): string;
  65365. /**
  65366. * Gets the position input component
  65367. */
  65368. get position(): NodeMaterialConnectionPoint;
  65369. /**
  65370. * Gets the world position input component
  65371. */
  65372. get worldPosition(): NodeMaterialConnectionPoint;
  65373. /**
  65374. * Gets the world normal input component
  65375. */
  65376. get worldNormal(): NodeMaterialConnectionPoint;
  65377. /**
  65378. * Gets the world input component
  65379. */
  65380. get world(): NodeMaterialConnectionPoint;
  65381. /**
  65382. * Gets the camera (or eye) position component
  65383. */
  65384. get cameraPosition(): NodeMaterialConnectionPoint;
  65385. /**
  65386. * Gets the view input component
  65387. */
  65388. get view(): NodeMaterialConnectionPoint;
  65389. /**
  65390. * Gets the color input component
  65391. */
  65392. get color(): NodeMaterialConnectionPoint;
  65393. /**
  65394. * Gets the reflection object output component
  65395. */
  65396. get reflection(): NodeMaterialConnectionPoint;
  65397. /**
  65398. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  65399. */
  65400. get hasTexture(): boolean;
  65401. /**
  65402. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  65403. */
  65404. get reflectionColor(): string;
  65405. protected _getTexture(): Nullable<BaseTexture>;
  65406. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65407. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65408. /**
  65409. * Gets the code to inject in the vertex shader
  65410. * @param state current state of the node material building
  65411. * @returns the shader code
  65412. */
  65413. handleVertexSide(state: NodeMaterialBuildState): string;
  65414. /**
  65415. * Gets the main code of the block (fragment side)
  65416. * @param state current state of the node material building
  65417. * @param normalVarName name of the existing variable corresponding to the normal
  65418. * @returns the shader code
  65419. */
  65420. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  65421. protected _buildBlock(state: NodeMaterialBuildState): this;
  65422. protected _dumpPropertiesCode(): string;
  65423. serialize(): any;
  65424. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65425. }
  65426. }
  65427. declare module BABYLON {
  65428. /**
  65429. * Block used to implement the sheen module of the PBR material
  65430. */
  65431. export class SheenBlock extends NodeMaterialBlock {
  65432. /**
  65433. * Create a new SheenBlock
  65434. * @param name defines the block name
  65435. */
  65436. constructor(name: string);
  65437. /**
  65438. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  65439. * It allows the strength of the sheen effect to not depend on the base color of the material,
  65440. * making it easier to setup and tweak the effect
  65441. */
  65442. albedoScaling: boolean;
  65443. /**
  65444. * Defines if the sheen is linked to the sheen color.
  65445. */
  65446. linkSheenWithAlbedo: boolean;
  65447. /**
  65448. * Initialize the block and prepare the context for build
  65449. * @param state defines the state that will be used for the build
  65450. */
  65451. initialize(state: NodeMaterialBuildState): void;
  65452. /**
  65453. * Gets the current class name
  65454. * @returns the class name
  65455. */
  65456. getClassName(): string;
  65457. /**
  65458. * Gets the intensity input component
  65459. */
  65460. get intensity(): NodeMaterialConnectionPoint;
  65461. /**
  65462. * Gets the color input component
  65463. */
  65464. get color(): NodeMaterialConnectionPoint;
  65465. /**
  65466. * Gets the roughness input component
  65467. */
  65468. get roughness(): NodeMaterialConnectionPoint;
  65469. /**
  65470. * Gets the sheen object output component
  65471. */
  65472. get sheen(): NodeMaterialConnectionPoint;
  65473. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65474. /**
  65475. * Gets the main code of the block (fragment side)
  65476. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65477. * @returns the shader code
  65478. */
  65479. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  65480. protected _buildBlock(state: NodeMaterialBuildState): this;
  65481. protected _dumpPropertiesCode(): string;
  65482. serialize(): any;
  65483. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65484. }
  65485. }
  65486. declare module BABYLON {
  65487. /**
  65488. * Block used to implement the reflectivity module of the PBR material
  65489. */
  65490. export class ReflectivityBlock extends NodeMaterialBlock {
  65491. private _metallicReflectanceColor;
  65492. private _metallicF0Factor;
  65493. /** @hidden */
  65494. _vMetallicReflectanceFactorsName: string;
  65495. /**
  65496. * The property below is set by the main PBR block prior to calling methods of this class.
  65497. */
  65498. /** @hidden */
  65499. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  65500. /**
  65501. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  65502. */
  65503. useAmbientOcclusionFromMetallicTextureRed: boolean;
  65504. /**
  65505. * Specifies if the metallic texture contains the metallness information in its blue channel.
  65506. */
  65507. useMetallnessFromMetallicTextureBlue: boolean;
  65508. /**
  65509. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  65510. */
  65511. useRoughnessFromMetallicTextureAlpha: boolean;
  65512. /**
  65513. * Specifies if the metallic texture contains the roughness information in its green channel.
  65514. */
  65515. useRoughnessFromMetallicTextureGreen: boolean;
  65516. /**
  65517. * Create a new ReflectivityBlock
  65518. * @param name defines the block name
  65519. */
  65520. constructor(name: string);
  65521. /**
  65522. * Initialize the block and prepare the context for build
  65523. * @param state defines the state that will be used for the build
  65524. */
  65525. initialize(state: NodeMaterialBuildState): void;
  65526. /**
  65527. * Gets the current class name
  65528. * @returns the class name
  65529. */
  65530. getClassName(): string;
  65531. /**
  65532. * Gets the metallic input component
  65533. */
  65534. get metallic(): NodeMaterialConnectionPoint;
  65535. /**
  65536. * Gets the roughness input component
  65537. */
  65538. get roughness(): NodeMaterialConnectionPoint;
  65539. /**
  65540. * Gets the texture input component
  65541. */
  65542. get texture(): NodeMaterialConnectionPoint;
  65543. /**
  65544. * Gets the reflectivity object output component
  65545. */
  65546. get reflectivity(): NodeMaterialConnectionPoint;
  65547. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65548. /**
  65549. * Gets the main code of the block (fragment side)
  65550. * @param state current state of the node material building
  65551. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  65552. * @returns the shader code
  65553. */
  65554. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  65555. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65556. protected _buildBlock(state: NodeMaterialBuildState): this;
  65557. protected _dumpPropertiesCode(): string;
  65558. serialize(): any;
  65559. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65560. }
  65561. }
  65562. declare module BABYLON {
  65563. /**
  65564. * Block used to implement the anisotropy module of the PBR material
  65565. */
  65566. export class AnisotropyBlock extends NodeMaterialBlock {
  65567. /**
  65568. * The two properties below are set by the main PBR block prior to calling methods of this class.
  65569. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65570. * It's less burden on the user side in the editor part.
  65571. */
  65572. /** @hidden */
  65573. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65574. /** @hidden */
  65575. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65576. /**
  65577. * Create a new AnisotropyBlock
  65578. * @param name defines the block name
  65579. */
  65580. constructor(name: string);
  65581. /**
  65582. * Initialize the block and prepare the context for build
  65583. * @param state defines the state that will be used for the build
  65584. */
  65585. initialize(state: NodeMaterialBuildState): void;
  65586. /**
  65587. * Gets the current class name
  65588. * @returns the class name
  65589. */
  65590. getClassName(): string;
  65591. /**
  65592. * Gets the intensity input component
  65593. */
  65594. get intensity(): NodeMaterialConnectionPoint;
  65595. /**
  65596. * Gets the direction input component
  65597. */
  65598. get direction(): NodeMaterialConnectionPoint;
  65599. /**
  65600. * Gets the texture input component
  65601. */
  65602. get texture(): NodeMaterialConnectionPoint;
  65603. /**
  65604. * Gets the uv input component
  65605. */
  65606. get uv(): NodeMaterialConnectionPoint;
  65607. /**
  65608. * Gets the worldTangent input component
  65609. */
  65610. get worldTangent(): NodeMaterialConnectionPoint;
  65611. /**
  65612. * Gets the anisotropy object output component
  65613. */
  65614. get anisotropy(): NodeMaterialConnectionPoint;
  65615. private _generateTBNSpace;
  65616. /**
  65617. * Gets the main code of the block (fragment side)
  65618. * @param state current state of the node material building
  65619. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  65620. * @returns the shader code
  65621. */
  65622. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  65623. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65624. protected _buildBlock(state: NodeMaterialBuildState): this;
  65625. }
  65626. }
  65627. declare module BABYLON {
  65628. /**
  65629. * Block used to implement the clear coat module of the PBR material
  65630. */
  65631. export class ClearCoatBlock extends NodeMaterialBlock {
  65632. private _scene;
  65633. /**
  65634. * Create a new ClearCoatBlock
  65635. * @param name defines the block name
  65636. */
  65637. constructor(name: string);
  65638. /**
  65639. * Initialize the block and prepare the context for build
  65640. * @param state defines the state that will be used for the build
  65641. */
  65642. initialize(state: NodeMaterialBuildState): void;
  65643. /**
  65644. * Gets the current class name
  65645. * @returns the class name
  65646. */
  65647. getClassName(): string;
  65648. /**
  65649. * Gets the intensity input component
  65650. */
  65651. get intensity(): NodeMaterialConnectionPoint;
  65652. /**
  65653. * Gets the roughness input component
  65654. */
  65655. get roughness(): NodeMaterialConnectionPoint;
  65656. /**
  65657. * Gets the ior input component
  65658. */
  65659. get ior(): NodeMaterialConnectionPoint;
  65660. /**
  65661. * Gets the texture input component
  65662. */
  65663. get texture(): NodeMaterialConnectionPoint;
  65664. /**
  65665. * Gets the bump texture input component
  65666. */
  65667. get bumpTexture(): NodeMaterialConnectionPoint;
  65668. /**
  65669. * Gets the uv input component
  65670. */
  65671. get uv(): NodeMaterialConnectionPoint;
  65672. /**
  65673. * Gets the tint color input component
  65674. */
  65675. get tintColor(): NodeMaterialConnectionPoint;
  65676. /**
  65677. * Gets the tint "at distance" input component
  65678. */
  65679. get tintAtDistance(): NodeMaterialConnectionPoint;
  65680. /**
  65681. * Gets the tint thickness input component
  65682. */
  65683. get tintThickness(): NodeMaterialConnectionPoint;
  65684. /**
  65685. * Gets the world tangent input component
  65686. */
  65687. get worldTangent(): NodeMaterialConnectionPoint;
  65688. /**
  65689. * Gets the clear coat object output component
  65690. */
  65691. get clearcoat(): NodeMaterialConnectionPoint;
  65692. autoConfigure(material: NodeMaterial): void;
  65693. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65694. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65695. private _generateTBNSpace;
  65696. /**
  65697. * Gets the main code of the block (fragment side)
  65698. * @param state current state of the node material building
  65699. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  65700. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65701. * @param worldPosVarName name of the variable holding the world position
  65702. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  65703. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  65704. * @param worldNormalVarName name of the variable holding the world normal
  65705. * @returns the shader code
  65706. */
  65707. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  65708. protected _buildBlock(state: NodeMaterialBuildState): this;
  65709. }
  65710. }
  65711. declare module BABYLON {
  65712. /**
  65713. * Block used to implement the sub surface module of the PBR material
  65714. */
  65715. export class SubSurfaceBlock extends NodeMaterialBlock {
  65716. /**
  65717. * Create a new SubSurfaceBlock
  65718. * @param name defines the block name
  65719. */
  65720. constructor(name: string);
  65721. /**
  65722. * Stores the intensity of the different subsurface effects in the thickness texture.
  65723. * * the green channel is the translucency intensity.
  65724. * * the blue channel is the scattering intensity.
  65725. * * the alpha channel is the refraction intensity.
  65726. */
  65727. useMaskFromThicknessTexture: boolean;
  65728. /**
  65729. * Initialize the block and prepare the context for build
  65730. * @param state defines the state that will be used for the build
  65731. */
  65732. initialize(state: NodeMaterialBuildState): void;
  65733. /**
  65734. * Gets the current class name
  65735. * @returns the class name
  65736. */
  65737. getClassName(): string;
  65738. /**
  65739. * Gets the min thickness input component
  65740. */
  65741. get minThickness(): NodeMaterialConnectionPoint;
  65742. /**
  65743. * Gets the max thickness input component
  65744. */
  65745. get maxThickness(): NodeMaterialConnectionPoint;
  65746. /**
  65747. * Gets the thickness texture component
  65748. */
  65749. get thicknessTexture(): NodeMaterialConnectionPoint;
  65750. /**
  65751. * Gets the tint color input component
  65752. */
  65753. get tintColor(): NodeMaterialConnectionPoint;
  65754. /**
  65755. * Gets the translucency intensity input component
  65756. */
  65757. get translucencyIntensity(): NodeMaterialConnectionPoint;
  65758. /**
  65759. * Gets the translucency diffusion distance input component
  65760. */
  65761. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  65762. /**
  65763. * Gets the refraction object parameters
  65764. */
  65765. get refraction(): NodeMaterialConnectionPoint;
  65766. /**
  65767. * Gets the sub surface object output component
  65768. */
  65769. get subsurface(): NodeMaterialConnectionPoint;
  65770. autoConfigure(material: NodeMaterial): void;
  65771. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65772. /**
  65773. * Gets the main code of the block (fragment side)
  65774. * @param state current state of the node material building
  65775. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  65776. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65777. * @param worldPosVarName name of the variable holding the world position
  65778. * @returns the shader code
  65779. */
  65780. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  65781. protected _buildBlock(state: NodeMaterialBuildState): this;
  65782. }
  65783. }
  65784. declare module BABYLON {
  65785. /**
  65786. * Block used to implement the PBR metallic/roughness model
  65787. */
  65788. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  65789. /**
  65790. * Gets or sets the light associated with this block
  65791. */
  65792. light: Nullable<Light>;
  65793. private _lightId;
  65794. private _scene;
  65795. private _environmentBRDFTexture;
  65796. private _environmentBrdfSamplerName;
  65797. private _vNormalWName;
  65798. private _invertNormalName;
  65799. /**
  65800. * Create a new ReflectionBlock
  65801. * @param name defines the block name
  65802. */
  65803. constructor(name: string);
  65804. /**
  65805. * Intensity of the direct lights e.g. the four lights available in your scene.
  65806. * This impacts both the direct diffuse and specular highlights.
  65807. */
  65808. directIntensity: number;
  65809. /**
  65810. * Intensity of the environment e.g. how much the environment will light the object
  65811. * either through harmonics for rough material or through the refelction for shiny ones.
  65812. */
  65813. environmentIntensity: number;
  65814. /**
  65815. * This is a special control allowing the reduction of the specular highlights coming from the
  65816. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  65817. */
  65818. specularIntensity: number;
  65819. /**
  65820. * Defines the falloff type used in this material.
  65821. * It by default is Physical.
  65822. */
  65823. lightFalloff: number;
  65824. /**
  65825. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  65826. */
  65827. useAlphaFromAlbedoTexture: boolean;
  65828. /**
  65829. * Specifies that alpha test should be used
  65830. */
  65831. useAlphaTest: boolean;
  65832. /**
  65833. * Defines the alpha limits in alpha test mode.
  65834. */
  65835. alphaTestCutoff: number;
  65836. /**
  65837. * Specifies that alpha blending should be used
  65838. */
  65839. useAlphaBlending: boolean;
  65840. /**
  65841. * Defines if the alpha value should be determined via the rgb values.
  65842. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  65843. */
  65844. opacityRGB: boolean;
  65845. /**
  65846. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  65847. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  65848. */
  65849. useRadianceOverAlpha: boolean;
  65850. /**
  65851. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  65852. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  65853. */
  65854. useSpecularOverAlpha: boolean;
  65855. /**
  65856. * Enables specular anti aliasing in the PBR shader.
  65857. * It will both interacts on the Geometry for analytical and IBL lighting.
  65858. * It also prefilter the roughness map based on the bump values.
  65859. */
  65860. enableSpecularAntiAliasing: boolean;
  65861. /**
  65862. * Enables realtime filtering on the texture.
  65863. */
  65864. realTimeFiltering: boolean;
  65865. /**
  65866. * Quality switch for realtime filtering
  65867. */
  65868. realTimeFilteringQuality: number;
  65869. /**
  65870. * Defines if the material uses energy conservation.
  65871. */
  65872. useEnergyConservation: boolean;
  65873. /**
  65874. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  65875. * too much the area relying on ambient texture to define their ambient occlusion.
  65876. */
  65877. useRadianceOcclusion: boolean;
  65878. /**
  65879. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  65880. * makes the reflect vector face the model (under horizon).
  65881. */
  65882. useHorizonOcclusion: boolean;
  65883. /**
  65884. * If set to true, no lighting calculations will be applied.
  65885. */
  65886. unlit: boolean;
  65887. /**
  65888. * Force normal to face away from face.
  65889. */
  65890. forceNormalForward: boolean;
  65891. /**
  65892. * Defines the material debug mode.
  65893. * It helps seeing only some components of the material while troubleshooting.
  65894. */
  65895. debugMode: number;
  65896. /**
  65897. * Specify from where on screen the debug mode should start.
  65898. * The value goes from -1 (full screen) to 1 (not visible)
  65899. * It helps with side by side comparison against the final render
  65900. * This defaults to 0
  65901. */
  65902. debugLimit: number;
  65903. /**
  65904. * As the default viewing range might not be enough (if the ambient is really small for instance)
  65905. * You can use the factor to better multiply the final value.
  65906. */
  65907. debugFactor: number;
  65908. /**
  65909. * Initialize the block and prepare the context for build
  65910. * @param state defines the state that will be used for the build
  65911. */
  65912. initialize(state: NodeMaterialBuildState): void;
  65913. /**
  65914. * Gets the current class name
  65915. * @returns the class name
  65916. */
  65917. getClassName(): string;
  65918. /**
  65919. * Gets the world position input component
  65920. */
  65921. get worldPosition(): NodeMaterialConnectionPoint;
  65922. /**
  65923. * Gets the world normal input component
  65924. */
  65925. get worldNormal(): NodeMaterialConnectionPoint;
  65926. /**
  65927. * Gets the perturbed normal input component
  65928. */
  65929. get perturbedNormal(): NodeMaterialConnectionPoint;
  65930. /**
  65931. * Gets the camera position input component
  65932. */
  65933. get cameraPosition(): NodeMaterialConnectionPoint;
  65934. /**
  65935. * Gets the base color input component
  65936. */
  65937. get baseColor(): NodeMaterialConnectionPoint;
  65938. /**
  65939. * Gets the opacity texture input component
  65940. */
  65941. get opacityTexture(): NodeMaterialConnectionPoint;
  65942. /**
  65943. * Gets the ambient color input component
  65944. */
  65945. get ambientColor(): NodeMaterialConnectionPoint;
  65946. /**
  65947. * Gets the reflectivity object parameters
  65948. */
  65949. get reflectivity(): NodeMaterialConnectionPoint;
  65950. /**
  65951. * Gets the ambient occlusion object parameters
  65952. */
  65953. get ambientOcc(): NodeMaterialConnectionPoint;
  65954. /**
  65955. * Gets the reflection object parameters
  65956. */
  65957. get reflection(): NodeMaterialConnectionPoint;
  65958. /**
  65959. * Gets the sheen object parameters
  65960. */
  65961. get sheen(): NodeMaterialConnectionPoint;
  65962. /**
  65963. * Gets the clear coat object parameters
  65964. */
  65965. get clearcoat(): NodeMaterialConnectionPoint;
  65966. /**
  65967. * Gets the sub surface object parameters
  65968. */
  65969. get subsurface(): NodeMaterialConnectionPoint;
  65970. /**
  65971. * Gets the anisotropy object parameters
  65972. */
  65973. get anisotropy(): NodeMaterialConnectionPoint;
  65974. /**
  65975. * Gets the view matrix parameter
  65976. */
  65977. get view(): NodeMaterialConnectionPoint;
  65978. /**
  65979. * Gets the ambient output component
  65980. */
  65981. get ambient(): NodeMaterialConnectionPoint;
  65982. /**
  65983. * Gets the diffuse output component
  65984. */
  65985. get diffuse(): NodeMaterialConnectionPoint;
  65986. /**
  65987. * Gets the specular output component
  65988. */
  65989. get specular(): NodeMaterialConnectionPoint;
  65990. /**
  65991. * Gets the sheen output component
  65992. */
  65993. get sheenDir(): NodeMaterialConnectionPoint;
  65994. /**
  65995. * Gets the clear coat output component
  65996. */
  65997. get clearcoatDir(): NodeMaterialConnectionPoint;
  65998. /**
  65999. * Gets the indirect diffuse output component
  66000. */
  66001. get diffuseIndirect(): NodeMaterialConnectionPoint;
  66002. /**
  66003. * Gets the indirect specular output component
  66004. */
  66005. get specularIndirect(): NodeMaterialConnectionPoint;
  66006. /**
  66007. * Gets the indirect sheen output component
  66008. */
  66009. get sheenIndirect(): NodeMaterialConnectionPoint;
  66010. /**
  66011. * Gets the indirect clear coat output component
  66012. */
  66013. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  66014. /**
  66015. * Gets the refraction output component
  66016. */
  66017. get refraction(): NodeMaterialConnectionPoint;
  66018. /**
  66019. * Gets the global lighting output component
  66020. */
  66021. get lighting(): NodeMaterialConnectionPoint;
  66022. /**
  66023. * Gets the shadow output component
  66024. */
  66025. get shadow(): NodeMaterialConnectionPoint;
  66026. /**
  66027. * Gets the alpha output component
  66028. */
  66029. get alpha(): NodeMaterialConnectionPoint;
  66030. autoConfigure(material: NodeMaterial): void;
  66031. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66032. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  66033. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66034. private _injectVertexCode;
  66035. /**
  66036. * Gets the code corresponding to the albedo/opacity module
  66037. * @returns the shader code
  66038. */
  66039. getAlbedoOpacityCode(): string;
  66040. protected _buildBlock(state: NodeMaterialBuildState): this;
  66041. protected _dumpPropertiesCode(): string;
  66042. serialize(): any;
  66043. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66044. }
  66045. }
  66046. declare module BABYLON {
  66047. /**
  66048. * Block used to compute value of one parameter modulo another
  66049. */
  66050. export class ModBlock extends NodeMaterialBlock {
  66051. /**
  66052. * Creates a new ModBlock
  66053. * @param name defines the block name
  66054. */
  66055. constructor(name: string);
  66056. /**
  66057. * Gets the current class name
  66058. * @returns the class name
  66059. */
  66060. getClassName(): string;
  66061. /**
  66062. * Gets the left operand input component
  66063. */
  66064. get left(): NodeMaterialConnectionPoint;
  66065. /**
  66066. * Gets the right operand input component
  66067. */
  66068. get right(): NodeMaterialConnectionPoint;
  66069. /**
  66070. * Gets the output component
  66071. */
  66072. get output(): NodeMaterialConnectionPoint;
  66073. protected _buildBlock(state: NodeMaterialBuildState): this;
  66074. }
  66075. }
  66076. declare module BABYLON {
  66077. /**
  66078. * Configuration for Draco compression
  66079. */
  66080. export interface IDracoCompressionConfiguration {
  66081. /**
  66082. * Configuration for the decoder.
  66083. */
  66084. decoder: {
  66085. /**
  66086. * The url to the WebAssembly module.
  66087. */
  66088. wasmUrl?: string;
  66089. /**
  66090. * The url to the WebAssembly binary.
  66091. */
  66092. wasmBinaryUrl?: string;
  66093. /**
  66094. * The url to the fallback JavaScript module.
  66095. */
  66096. fallbackUrl?: string;
  66097. };
  66098. }
  66099. /**
  66100. * Draco compression (https://google.github.io/draco/)
  66101. *
  66102. * This class wraps the Draco module.
  66103. *
  66104. * **Encoder**
  66105. *
  66106. * The encoder is not currently implemented.
  66107. *
  66108. * **Decoder**
  66109. *
  66110. * 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.
  66111. *
  66112. * To update the configuration, use the following code:
  66113. * ```javascript
  66114. * DracoCompression.Configuration = {
  66115. * decoder: {
  66116. * wasmUrl: "<url to the WebAssembly library>",
  66117. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  66118. * fallbackUrl: "<url to the fallback JavaScript library>",
  66119. * }
  66120. * };
  66121. * ```
  66122. *
  66123. * 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.
  66124. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  66125. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  66126. *
  66127. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  66128. * ```javascript
  66129. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  66130. * ```
  66131. *
  66132. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  66133. */
  66134. export class DracoCompression implements IDisposable {
  66135. private _workerPoolPromise?;
  66136. private _decoderModulePromise?;
  66137. /**
  66138. * The configuration. Defaults to the following urls:
  66139. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  66140. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  66141. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  66142. */
  66143. static Configuration: IDracoCompressionConfiguration;
  66144. /**
  66145. * Returns true if the decoder configuration is available.
  66146. */
  66147. static get DecoderAvailable(): boolean;
  66148. /**
  66149. * Default number of workers to create when creating the draco compression object.
  66150. */
  66151. static DefaultNumWorkers: number;
  66152. private static GetDefaultNumWorkers;
  66153. private static _Default;
  66154. /**
  66155. * Default instance for the draco compression object.
  66156. */
  66157. static get Default(): DracoCompression;
  66158. /**
  66159. * Constructor
  66160. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  66161. */
  66162. constructor(numWorkers?: number);
  66163. /**
  66164. * Stop all async operations and release resources.
  66165. */
  66166. dispose(): void;
  66167. /**
  66168. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  66169. * @returns a promise that resolves when ready
  66170. */
  66171. whenReadyAsync(): Promise<void>;
  66172. /**
  66173. * Decode Draco compressed mesh data to vertex data.
  66174. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  66175. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  66176. * @returns A promise that resolves with the decoded vertex data
  66177. */
  66178. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  66179. [kind: string]: number;
  66180. }): Promise<VertexData>;
  66181. }
  66182. }
  66183. declare module BABYLON {
  66184. /**
  66185. * Class for building Constructive Solid Geometry
  66186. */
  66187. export class CSG {
  66188. private polygons;
  66189. /**
  66190. * The world matrix
  66191. */
  66192. matrix: Matrix;
  66193. /**
  66194. * Stores the position
  66195. */
  66196. position: Vector3;
  66197. /**
  66198. * Stores the rotation
  66199. */
  66200. rotation: Vector3;
  66201. /**
  66202. * Stores the rotation quaternion
  66203. */
  66204. rotationQuaternion: Nullable<Quaternion>;
  66205. /**
  66206. * Stores the scaling vector
  66207. */
  66208. scaling: Vector3;
  66209. /**
  66210. * Convert the Mesh to CSG
  66211. * @param mesh The Mesh to convert to CSG
  66212. * @returns A new CSG from the Mesh
  66213. */
  66214. static FromMesh(mesh: Mesh): CSG;
  66215. /**
  66216. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  66217. * @param polygons Polygons used to construct a CSG solid
  66218. */
  66219. private static FromPolygons;
  66220. /**
  66221. * Clones, or makes a deep copy, of the CSG
  66222. * @returns A new CSG
  66223. */
  66224. clone(): CSG;
  66225. /**
  66226. * Unions this CSG with another CSG
  66227. * @param csg The CSG to union against this CSG
  66228. * @returns The unioned CSG
  66229. */
  66230. union(csg: CSG): CSG;
  66231. /**
  66232. * Unions this CSG with another CSG in place
  66233. * @param csg The CSG to union against this CSG
  66234. */
  66235. unionInPlace(csg: CSG): void;
  66236. /**
  66237. * Subtracts this CSG with another CSG
  66238. * @param csg The CSG to subtract against this CSG
  66239. * @returns A new CSG
  66240. */
  66241. subtract(csg: CSG): CSG;
  66242. /**
  66243. * Subtracts this CSG with another CSG in place
  66244. * @param csg The CSG to subtact against this CSG
  66245. */
  66246. subtractInPlace(csg: CSG): void;
  66247. /**
  66248. * Intersect this CSG with another CSG
  66249. * @param csg The CSG to intersect against this CSG
  66250. * @returns A new CSG
  66251. */
  66252. intersect(csg: CSG): CSG;
  66253. /**
  66254. * Intersects this CSG with another CSG in place
  66255. * @param csg The CSG to intersect against this CSG
  66256. */
  66257. intersectInPlace(csg: CSG): void;
  66258. /**
  66259. * Return a new CSG solid with solid and empty space switched. This solid is
  66260. * not modified.
  66261. * @returns A new CSG solid with solid and empty space switched
  66262. */
  66263. inverse(): CSG;
  66264. /**
  66265. * Inverses the CSG in place
  66266. */
  66267. inverseInPlace(): void;
  66268. /**
  66269. * This is used to keep meshes transformations so they can be restored
  66270. * when we build back a Babylon Mesh
  66271. * NB : All CSG operations are performed in world coordinates
  66272. * @param csg The CSG to copy the transform attributes from
  66273. * @returns This CSG
  66274. */
  66275. copyTransformAttributes(csg: CSG): CSG;
  66276. /**
  66277. * Build Raw mesh from CSG
  66278. * Coordinates here are in world space
  66279. * @param name The name of the mesh geometry
  66280. * @param scene The Scene
  66281. * @param keepSubMeshes Specifies if the submeshes should be kept
  66282. * @returns A new Mesh
  66283. */
  66284. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66285. /**
  66286. * Build Mesh from CSG taking material and transforms into account
  66287. * @param name The name of the Mesh
  66288. * @param material The material of the Mesh
  66289. * @param scene The Scene
  66290. * @param keepSubMeshes Specifies if submeshes should be kept
  66291. * @returns The new Mesh
  66292. */
  66293. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66294. }
  66295. }
  66296. declare module BABYLON {
  66297. /**
  66298. * Class used to create a trail following a mesh
  66299. */
  66300. export class TrailMesh extends Mesh {
  66301. private _generator;
  66302. private _autoStart;
  66303. private _running;
  66304. private _diameter;
  66305. private _length;
  66306. private _sectionPolygonPointsCount;
  66307. private _sectionVectors;
  66308. private _sectionNormalVectors;
  66309. private _beforeRenderObserver;
  66310. /**
  66311. * @constructor
  66312. * @param name The value used by scene.getMeshByName() to do a lookup.
  66313. * @param generator The mesh or transform node to generate a trail.
  66314. * @param scene The scene to add this mesh to.
  66315. * @param diameter Diameter of trailing mesh. Default is 1.
  66316. * @param length Length of trailing mesh. Default is 60.
  66317. * @param autoStart Automatically start trailing mesh. Default true.
  66318. */
  66319. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  66320. /**
  66321. * "TrailMesh"
  66322. * @returns "TrailMesh"
  66323. */
  66324. getClassName(): string;
  66325. private _createMesh;
  66326. /**
  66327. * Start trailing mesh.
  66328. */
  66329. start(): void;
  66330. /**
  66331. * Stop trailing mesh.
  66332. */
  66333. stop(): void;
  66334. /**
  66335. * Update trailing mesh geometry.
  66336. */
  66337. update(): void;
  66338. /**
  66339. * Returns a new TrailMesh object.
  66340. * @param name is a string, the name given to the new mesh
  66341. * @param newGenerator use new generator object for cloned trail mesh
  66342. * @returns a new mesh
  66343. */
  66344. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  66345. /**
  66346. * Serializes this trail mesh
  66347. * @param serializationObject object to write serialization to
  66348. */
  66349. serialize(serializationObject: any): void;
  66350. /**
  66351. * Parses a serialized trail mesh
  66352. * @param parsedMesh the serialized mesh
  66353. * @param scene the scene to create the trail mesh in
  66354. * @returns the created trail mesh
  66355. */
  66356. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  66357. }
  66358. }
  66359. declare module BABYLON {
  66360. /**
  66361. * Class containing static functions to help procedurally build meshes
  66362. */
  66363. export class TiledBoxBuilder {
  66364. /**
  66365. * Creates a box mesh
  66366. * 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)
  66367. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66368. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66369. * * 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
  66370. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66371. * @param name defines the name of the mesh
  66372. * @param options defines the options used to create the mesh
  66373. * @param scene defines the hosting scene
  66374. * @returns the box mesh
  66375. */
  66376. static CreateTiledBox(name: string, options: {
  66377. pattern?: number;
  66378. width?: number;
  66379. height?: number;
  66380. depth?: number;
  66381. tileSize?: number;
  66382. tileWidth?: number;
  66383. tileHeight?: number;
  66384. alignHorizontal?: number;
  66385. alignVertical?: number;
  66386. faceUV?: Vector4[];
  66387. faceColors?: Color4[];
  66388. sideOrientation?: number;
  66389. updatable?: boolean;
  66390. }, scene?: Nullable<Scene>): Mesh;
  66391. }
  66392. }
  66393. declare module BABYLON {
  66394. /**
  66395. * Class containing static functions to help procedurally build meshes
  66396. */
  66397. export class TorusKnotBuilder {
  66398. /**
  66399. * Creates a torus knot mesh
  66400. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66401. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66402. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66403. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66404. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66405. * * 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
  66406. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66407. * @param name defines the name of the mesh
  66408. * @param options defines the options used to create the mesh
  66409. * @param scene defines the hosting scene
  66410. * @returns the torus knot mesh
  66411. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66412. */
  66413. static CreateTorusKnot(name: string, options: {
  66414. radius?: number;
  66415. tube?: number;
  66416. radialSegments?: number;
  66417. tubularSegments?: number;
  66418. p?: number;
  66419. q?: number;
  66420. updatable?: boolean;
  66421. sideOrientation?: number;
  66422. frontUVs?: Vector4;
  66423. backUVs?: Vector4;
  66424. }, scene: any): Mesh;
  66425. }
  66426. }
  66427. declare module BABYLON {
  66428. /**
  66429. * Polygon
  66430. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  66431. */
  66432. export class Polygon {
  66433. /**
  66434. * Creates a rectangle
  66435. * @param xmin bottom X coord
  66436. * @param ymin bottom Y coord
  66437. * @param xmax top X coord
  66438. * @param ymax top Y coord
  66439. * @returns points that make the resulting rectation
  66440. */
  66441. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  66442. /**
  66443. * Creates a circle
  66444. * @param radius radius of circle
  66445. * @param cx scale in x
  66446. * @param cy scale in y
  66447. * @param numberOfSides number of sides that make up the circle
  66448. * @returns points that make the resulting circle
  66449. */
  66450. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  66451. /**
  66452. * Creates a polygon from input string
  66453. * @param input Input polygon data
  66454. * @returns the parsed points
  66455. */
  66456. static Parse(input: string): Vector2[];
  66457. /**
  66458. * Starts building a polygon from x and y coordinates
  66459. * @param x x coordinate
  66460. * @param y y coordinate
  66461. * @returns the started path2
  66462. */
  66463. static StartingAt(x: number, y: number): Path2;
  66464. }
  66465. /**
  66466. * Builds a polygon
  66467. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  66468. */
  66469. export class PolygonMeshBuilder {
  66470. private _points;
  66471. private _outlinepoints;
  66472. private _holes;
  66473. private _name;
  66474. private _scene;
  66475. private _epoints;
  66476. private _eholes;
  66477. private _addToepoint;
  66478. /**
  66479. * Babylon reference to the earcut plugin.
  66480. */
  66481. bjsEarcut: any;
  66482. /**
  66483. * Creates a PolygonMeshBuilder
  66484. * @param name name of the builder
  66485. * @param contours Path of the polygon
  66486. * @param scene scene to add to when creating the mesh
  66487. * @param earcutInjection can be used to inject your own earcut reference
  66488. */
  66489. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  66490. /**
  66491. * Adds a whole within the polygon
  66492. * @param hole Array of points defining the hole
  66493. * @returns this
  66494. */
  66495. addHole(hole: Vector2[]): PolygonMeshBuilder;
  66496. /**
  66497. * Creates the polygon
  66498. * @param updatable If the mesh should be updatable
  66499. * @param depth The depth of the mesh created
  66500. * @returns the created mesh
  66501. */
  66502. build(updatable?: boolean, depth?: number): Mesh;
  66503. /**
  66504. * Creates the polygon
  66505. * @param depth The depth of the mesh created
  66506. * @returns the created VertexData
  66507. */
  66508. buildVertexData(depth?: number): VertexData;
  66509. /**
  66510. * Adds a side to the polygon
  66511. * @param positions points that make the polygon
  66512. * @param normals normals of the polygon
  66513. * @param uvs uvs of the polygon
  66514. * @param indices indices of the polygon
  66515. * @param bounds bounds of the polygon
  66516. * @param points points of the polygon
  66517. * @param depth depth of the polygon
  66518. * @param flip flip of the polygon
  66519. */
  66520. private addSide;
  66521. }
  66522. }
  66523. declare module BABYLON {
  66524. /**
  66525. * Class containing static functions to help procedurally build meshes
  66526. */
  66527. export class PolygonBuilder {
  66528. /**
  66529. * Creates a polygon mesh
  66530. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66531. * * 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
  66532. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66533. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66534. * * 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)
  66535. * * Remember you can only change the shape positions, not their number when updating a polygon
  66536. * @param name defines the name of the mesh
  66537. * @param options defines the options used to create the mesh
  66538. * @param scene defines the hosting scene
  66539. * @param earcutInjection can be used to inject your own earcut reference
  66540. * @returns the polygon mesh
  66541. */
  66542. static CreatePolygon(name: string, options: {
  66543. shape: Vector3[];
  66544. holes?: Vector3[][];
  66545. depth?: number;
  66546. faceUV?: Vector4[];
  66547. faceColors?: Color4[];
  66548. updatable?: boolean;
  66549. sideOrientation?: number;
  66550. frontUVs?: Vector4;
  66551. backUVs?: Vector4;
  66552. wrap?: boolean;
  66553. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66554. /**
  66555. * Creates an extruded polygon mesh, with depth in the Y direction.
  66556. * * 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)
  66557. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66558. * @param name defines the name of the mesh
  66559. * @param options defines the options used to create the mesh
  66560. * @param scene defines the hosting scene
  66561. * @param earcutInjection can be used to inject your own earcut reference
  66562. * @returns the polygon mesh
  66563. */
  66564. static ExtrudePolygon(name: string, options: {
  66565. shape: Vector3[];
  66566. holes?: Vector3[][];
  66567. depth?: number;
  66568. faceUV?: Vector4[];
  66569. faceColors?: Color4[];
  66570. updatable?: boolean;
  66571. sideOrientation?: number;
  66572. frontUVs?: Vector4;
  66573. backUVs?: Vector4;
  66574. wrap?: boolean;
  66575. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66576. }
  66577. }
  66578. declare module BABYLON {
  66579. /**
  66580. * Class containing static functions to help procedurally build meshes
  66581. */
  66582. export class LatheBuilder {
  66583. /**
  66584. * Creates lathe mesh.
  66585. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66586. * * 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
  66587. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66588. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66589. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66590. * * 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
  66591. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66592. * * 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
  66593. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66594. * * 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
  66595. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66596. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66597. * @param name defines the name of the mesh
  66598. * @param options defines the options used to create the mesh
  66599. * @param scene defines the hosting scene
  66600. * @returns the lathe mesh
  66601. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66602. */
  66603. static CreateLathe(name: string, options: {
  66604. shape: Vector3[];
  66605. radius?: number;
  66606. tessellation?: number;
  66607. clip?: number;
  66608. arc?: number;
  66609. closed?: boolean;
  66610. updatable?: boolean;
  66611. sideOrientation?: number;
  66612. frontUVs?: Vector4;
  66613. backUVs?: Vector4;
  66614. cap?: number;
  66615. invertUV?: boolean;
  66616. }, scene?: Nullable<Scene>): Mesh;
  66617. }
  66618. }
  66619. declare module BABYLON {
  66620. /**
  66621. * Class containing static functions to help procedurally build meshes
  66622. */
  66623. export class TiledPlaneBuilder {
  66624. /**
  66625. * Creates a tiled plane mesh
  66626. * * The parameter `pattern` will, depending on value, do nothing or
  66627. * * * flip (reflect about central vertical) alternate tiles across and up
  66628. * * * flip every tile on alternate rows
  66629. * * * rotate (180 degs) alternate tiles across and up
  66630. * * * rotate every tile on alternate rows
  66631. * * * flip and rotate alternate tiles across and up
  66632. * * * flip and rotate every tile on alternate rows
  66633. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  66634. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  66635. * * 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
  66636. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66637. * * 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)
  66638. * * 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)
  66639. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  66640. * @param name defines the name of the mesh
  66641. * @param options defines the options used to create the mesh
  66642. * @param scene defines the hosting scene
  66643. * @returns the box mesh
  66644. */
  66645. static CreateTiledPlane(name: string, options: {
  66646. pattern?: number;
  66647. tileSize?: number;
  66648. tileWidth?: number;
  66649. tileHeight?: number;
  66650. size?: number;
  66651. width?: number;
  66652. height?: number;
  66653. alignHorizontal?: number;
  66654. alignVertical?: number;
  66655. sideOrientation?: number;
  66656. frontUVs?: Vector4;
  66657. backUVs?: Vector4;
  66658. updatable?: boolean;
  66659. }, scene?: Nullable<Scene>): Mesh;
  66660. }
  66661. }
  66662. declare module BABYLON {
  66663. /**
  66664. * Class containing static functions to help procedurally build meshes
  66665. */
  66666. export class TubeBuilder {
  66667. /**
  66668. * Creates a tube mesh.
  66669. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66670. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  66671. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  66672. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  66673. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  66674. * * 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)
  66675. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  66676. * * 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
  66677. * * 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
  66678. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66679. * * 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
  66680. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66682. * @param name defines the name of the mesh
  66683. * @param options defines the options used to create the mesh
  66684. * @param scene defines the hosting scene
  66685. * @returns the tube mesh
  66686. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66687. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  66688. */
  66689. static CreateTube(name: string, options: {
  66690. path: Vector3[];
  66691. radius?: number;
  66692. tessellation?: number;
  66693. radiusFunction?: {
  66694. (i: number, distance: number): number;
  66695. };
  66696. cap?: number;
  66697. arc?: number;
  66698. updatable?: boolean;
  66699. sideOrientation?: number;
  66700. frontUVs?: Vector4;
  66701. backUVs?: Vector4;
  66702. instance?: Mesh;
  66703. invertUV?: boolean;
  66704. }, scene?: Nullable<Scene>): Mesh;
  66705. }
  66706. }
  66707. declare module BABYLON {
  66708. /**
  66709. * Class containing static functions to help procedurally build meshes
  66710. */
  66711. export class IcoSphereBuilder {
  66712. /**
  66713. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  66714. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  66715. * * 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`)
  66716. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  66717. * * 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
  66718. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66719. * * 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
  66720. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66721. * @param name defines the name of the mesh
  66722. * @param options defines the options used to create the mesh
  66723. * @param scene defines the hosting scene
  66724. * @returns the icosahedron mesh
  66725. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  66726. */
  66727. static CreateIcoSphere(name: string, options: {
  66728. radius?: number;
  66729. radiusX?: number;
  66730. radiusY?: number;
  66731. radiusZ?: number;
  66732. flat?: boolean;
  66733. subdivisions?: number;
  66734. sideOrientation?: number;
  66735. frontUVs?: Vector4;
  66736. backUVs?: Vector4;
  66737. updatable?: 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 DecalBuilder {
  66746. /**
  66747. * Creates a decal mesh.
  66748. * 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
  66749. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  66750. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  66751. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  66752. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  66753. * @param name defines the name of the mesh
  66754. * @param sourceMesh defines the mesh where the decal must be applied
  66755. * @param options defines the options used to create the mesh
  66756. * @param scene defines the hosting scene
  66757. * @returns the decal mesh
  66758. * @see https://doc.babylonjs.com/how_to/decals
  66759. */
  66760. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  66761. position?: Vector3;
  66762. normal?: Vector3;
  66763. size?: Vector3;
  66764. angle?: number;
  66765. }): Mesh;
  66766. }
  66767. }
  66768. declare module BABYLON {
  66769. /**
  66770. * Class containing static functions to help procedurally build meshes
  66771. */
  66772. export class MeshBuilder {
  66773. /**
  66774. * Creates a box mesh
  66775. * * The parameter `size` sets the size (float) of each box side (default 1)
  66776. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  66777. * * 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)
  66778. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66779. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66780. * * 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
  66781. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66782. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  66783. * @param name defines the name of the mesh
  66784. * @param options defines the options used to create the mesh
  66785. * @param scene defines the hosting scene
  66786. * @returns the box mesh
  66787. */
  66788. static CreateBox(name: string, options: {
  66789. size?: number;
  66790. width?: number;
  66791. height?: number;
  66792. depth?: number;
  66793. faceUV?: Vector4[];
  66794. faceColors?: Color4[];
  66795. sideOrientation?: number;
  66796. frontUVs?: Vector4;
  66797. backUVs?: Vector4;
  66798. wrap?: boolean;
  66799. topBaseAt?: number;
  66800. bottomBaseAt?: number;
  66801. updatable?: boolean;
  66802. }, scene?: Nullable<Scene>): Mesh;
  66803. /**
  66804. * Creates a tiled box mesh
  66805. * * faceTiles sets the pattern, tile size and number of tiles for a face
  66806. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66807. * @param name defines the name of the mesh
  66808. * @param options defines the options used to create the mesh
  66809. * @param scene defines the hosting scene
  66810. * @returns the tiled box mesh
  66811. */
  66812. static CreateTiledBox(name: string, options: {
  66813. pattern?: number;
  66814. size?: number;
  66815. width?: number;
  66816. height?: number;
  66817. depth: number;
  66818. tileSize?: number;
  66819. tileWidth?: number;
  66820. tileHeight?: number;
  66821. faceUV?: Vector4[];
  66822. faceColors?: Color4[];
  66823. alignHorizontal?: number;
  66824. alignVertical?: number;
  66825. sideOrientation?: number;
  66826. updatable?: boolean;
  66827. }, scene?: Nullable<Scene>): Mesh;
  66828. /**
  66829. * Creates a sphere mesh
  66830. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  66831. * * 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`)
  66832. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  66833. * * 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
  66834. * * 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)
  66835. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66836. * * 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
  66837. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66838. * @param name defines the name of the mesh
  66839. * @param options defines the options used to create the mesh
  66840. * @param scene defines the hosting scene
  66841. * @returns the sphere mesh
  66842. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  66843. */
  66844. static CreateSphere(name: string, options: {
  66845. segments?: number;
  66846. diameter?: number;
  66847. diameterX?: number;
  66848. diameterY?: number;
  66849. diameterZ?: number;
  66850. arc?: number;
  66851. slice?: number;
  66852. sideOrientation?: number;
  66853. frontUVs?: Vector4;
  66854. backUVs?: Vector4;
  66855. updatable?: boolean;
  66856. }, scene?: Nullable<Scene>): Mesh;
  66857. /**
  66858. * Creates a plane polygonal mesh. By default, this is a disc
  66859. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  66860. * * 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
  66861. * * 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
  66862. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66863. * * 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
  66864. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66865. * @param name defines the name of the mesh
  66866. * @param options defines the options used to create the mesh
  66867. * @param scene defines the hosting scene
  66868. * @returns the plane polygonal mesh
  66869. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  66870. */
  66871. static CreateDisc(name: string, options: {
  66872. radius?: number;
  66873. tessellation?: number;
  66874. arc?: number;
  66875. updatable?: boolean;
  66876. sideOrientation?: number;
  66877. frontUVs?: Vector4;
  66878. backUVs?: Vector4;
  66879. }, scene?: Nullable<Scene>): Mesh;
  66880. /**
  66881. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  66882. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  66883. * * 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`)
  66884. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  66885. * * 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
  66886. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66887. * * 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
  66888. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66889. * @param name defines the name of the mesh
  66890. * @param options defines the options used to create the mesh
  66891. * @param scene defines the hosting scene
  66892. * @returns the icosahedron mesh
  66893. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  66894. */
  66895. static CreateIcoSphere(name: string, options: {
  66896. radius?: number;
  66897. radiusX?: number;
  66898. radiusY?: number;
  66899. radiusZ?: number;
  66900. flat?: boolean;
  66901. subdivisions?: number;
  66902. sideOrientation?: number;
  66903. frontUVs?: Vector4;
  66904. backUVs?: Vector4;
  66905. updatable?: boolean;
  66906. }, scene?: Nullable<Scene>): Mesh;
  66907. /**
  66908. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66909. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  66910. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  66911. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  66912. * * 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
  66913. * * 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
  66914. * * 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
  66915. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66916. * * 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
  66917. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66918. * * 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
  66919. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  66920. * * 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
  66921. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  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 ribbon mesh
  66927. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  66928. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66929. */
  66930. static CreateRibbon(name: string, options: {
  66931. pathArray: Vector3[][];
  66932. closeArray?: boolean;
  66933. closePath?: boolean;
  66934. offset?: number;
  66935. updatable?: boolean;
  66936. sideOrientation?: number;
  66937. frontUVs?: Vector4;
  66938. backUVs?: Vector4;
  66939. instance?: Mesh;
  66940. invertUV?: boolean;
  66941. uvs?: Vector2[];
  66942. colors?: Color4[];
  66943. }, scene?: Nullable<Scene>): Mesh;
  66944. /**
  66945. * Creates a cylinder or a cone mesh
  66946. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  66947. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  66948. * * 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.
  66949. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  66950. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  66951. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  66952. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  66953. * * 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).
  66954. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  66955. * * 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).
  66956. * * 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
  66957. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  66958. * * 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
  66959. * * 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.
  66960. * * If `enclose` is false, a ring surface is one element.
  66961. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  66962. * * 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
  66963. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66964. * * 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
  66965. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66966. * @param name defines the name of the mesh
  66967. * @param options defines the options used to create the mesh
  66968. * @param scene defines the hosting scene
  66969. * @returns the cylinder mesh
  66970. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  66971. */
  66972. static CreateCylinder(name: string, options: {
  66973. height?: number;
  66974. diameterTop?: number;
  66975. diameterBottom?: number;
  66976. diameter?: number;
  66977. tessellation?: number;
  66978. subdivisions?: number;
  66979. arc?: number;
  66980. faceColors?: Color4[];
  66981. faceUV?: Vector4[];
  66982. updatable?: boolean;
  66983. hasRings?: boolean;
  66984. enclose?: boolean;
  66985. cap?: number;
  66986. sideOrientation?: number;
  66987. frontUVs?: Vector4;
  66988. backUVs?: Vector4;
  66989. }, scene?: Nullable<Scene>): Mesh;
  66990. /**
  66991. * Creates a torus mesh
  66992. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  66993. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  66994. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  66995. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66996. * * 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
  66997. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66998. * @param name defines the name of the mesh
  66999. * @param options defines the options used to create the mesh
  67000. * @param scene defines the hosting scene
  67001. * @returns the torus mesh
  67002. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  67003. */
  67004. static CreateTorus(name: string, options: {
  67005. diameter?: number;
  67006. thickness?: number;
  67007. tessellation?: number;
  67008. updatable?: boolean;
  67009. sideOrientation?: number;
  67010. frontUVs?: Vector4;
  67011. backUVs?: Vector4;
  67012. }, scene?: Nullable<Scene>): Mesh;
  67013. /**
  67014. * Creates a torus knot mesh
  67015. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  67016. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  67017. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  67018. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  67019. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67020. * * 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
  67021. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67022. * @param name defines the name of the mesh
  67023. * @param options defines the options used to create the mesh
  67024. * @param scene defines the hosting scene
  67025. * @returns the torus knot mesh
  67026. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  67027. */
  67028. static CreateTorusKnot(name: string, options: {
  67029. radius?: number;
  67030. tube?: number;
  67031. radialSegments?: number;
  67032. tubularSegments?: number;
  67033. p?: number;
  67034. q?: number;
  67035. updatable?: boolean;
  67036. sideOrientation?: number;
  67037. frontUVs?: Vector4;
  67038. backUVs?: Vector4;
  67039. }, scene?: Nullable<Scene>): Mesh;
  67040. /**
  67041. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  67042. * * 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
  67043. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  67044. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  67045. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  67046. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  67047. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  67048. * * 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
  67049. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  67050. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67051. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  67052. * @param name defines the name of the new line system
  67053. * @param options defines the options used to create the line system
  67054. * @param scene defines the hosting scene
  67055. * @returns a new line system mesh
  67056. */
  67057. static CreateLineSystem(name: string, options: {
  67058. lines: Vector3[][];
  67059. updatable?: boolean;
  67060. instance?: Nullable<LinesMesh>;
  67061. colors?: Nullable<Color4[][]>;
  67062. useVertexAlpha?: boolean;
  67063. }, scene: Nullable<Scene>): LinesMesh;
  67064. /**
  67065. * Creates a line mesh
  67066. * 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
  67067. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  67068. * * The parameter `points` is an array successive Vector3
  67069. * * 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
  67070. * * The optional parameter `colors` is an array of successive Color4, one per line point
  67071. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  67072. * * When updating an instance, remember that only point positions can change, not the number of points
  67073. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67074. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  67075. * @param name defines the name of the new line system
  67076. * @param options defines the options used to create the line system
  67077. * @param scene defines the hosting scene
  67078. * @returns a new line mesh
  67079. */
  67080. static CreateLines(name: string, options: {
  67081. points: Vector3[];
  67082. updatable?: boolean;
  67083. instance?: Nullable<LinesMesh>;
  67084. colors?: Color4[];
  67085. useVertexAlpha?: boolean;
  67086. }, scene?: Nullable<Scene>): LinesMesh;
  67087. /**
  67088. * Creates a dashed line mesh
  67089. * * 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
  67090. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  67091. * * The parameter `points` is an array successive Vector3
  67092. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  67093. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  67094. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  67095. * * 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
  67096. * * When updating an instance, remember that only point positions can change, not the number of points
  67097. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67098. * @param name defines the name of the mesh
  67099. * @param options defines the options used to create the mesh
  67100. * @param scene defines the hosting scene
  67101. * @returns the dashed line mesh
  67102. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  67103. */
  67104. static CreateDashedLines(name: string, options: {
  67105. points: Vector3[];
  67106. dashSize?: number;
  67107. gapSize?: number;
  67108. dashNb?: number;
  67109. updatable?: boolean;
  67110. instance?: LinesMesh;
  67111. }, scene?: Nullable<Scene>): LinesMesh;
  67112. /**
  67113. * 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.
  67114. * * 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.
  67115. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  67116. * * 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.
  67117. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  67118. * * 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
  67119. * * 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
  67120. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  67121. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67122. * * 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
  67123. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  67124. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67125. * @param name defines the name of the mesh
  67126. * @param options defines the options used to create the mesh
  67127. * @param scene defines the hosting scene
  67128. * @returns the extruded shape mesh
  67129. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67130. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  67131. */
  67132. static ExtrudeShape(name: string, options: {
  67133. shape: Vector3[];
  67134. path: Vector3[];
  67135. scale?: number;
  67136. rotation?: number;
  67137. cap?: number;
  67138. updatable?: boolean;
  67139. sideOrientation?: number;
  67140. frontUVs?: Vector4;
  67141. backUVs?: Vector4;
  67142. instance?: Mesh;
  67143. invertUV?: boolean;
  67144. }, scene?: Nullable<Scene>): Mesh;
  67145. /**
  67146. * Creates an custom extruded shape mesh.
  67147. * The custom 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 `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
  67151. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  67152. * * 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
  67153. * * It must returns a float value that will be the scale value applied to the shape on each path point
  67154. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  67155. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  67156. * * 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
  67157. * * 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
  67158. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  67159. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67160. * * 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
  67161. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67162. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67163. * @param name defines the name of the mesh
  67164. * @param options defines the options used to create the mesh
  67165. * @param scene defines the hosting scene
  67166. * @returns the custom extruded shape mesh
  67167. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  67168. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67169. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  67170. */
  67171. static ExtrudeShapeCustom(name: string, options: {
  67172. shape: Vector3[];
  67173. path: Vector3[];
  67174. scaleFunction?: any;
  67175. rotationFunction?: any;
  67176. ribbonCloseArray?: boolean;
  67177. ribbonClosePath?: boolean;
  67178. cap?: number;
  67179. updatable?: boolean;
  67180. sideOrientation?: number;
  67181. frontUVs?: Vector4;
  67182. backUVs?: Vector4;
  67183. instance?: Mesh;
  67184. invertUV?: boolean;
  67185. }, scene?: Nullable<Scene>): Mesh;
  67186. /**
  67187. * Creates lathe mesh.
  67188. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  67189. * * 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
  67190. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  67191. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  67192. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  67193. * * 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
  67194. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  67195. * * 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
  67196. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67197. * * 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
  67198. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67199. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67200. * @param name defines the name of the mesh
  67201. * @param options defines the options used to create the mesh
  67202. * @param scene defines the hosting scene
  67203. * @returns the lathe mesh
  67204. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  67205. */
  67206. static CreateLathe(name: string, options: {
  67207. shape: Vector3[];
  67208. radius?: number;
  67209. tessellation?: number;
  67210. clip?: number;
  67211. arc?: number;
  67212. closed?: boolean;
  67213. updatable?: boolean;
  67214. sideOrientation?: number;
  67215. frontUVs?: Vector4;
  67216. backUVs?: Vector4;
  67217. cap?: number;
  67218. invertUV?: boolean;
  67219. }, scene?: Nullable<Scene>): Mesh;
  67220. /**
  67221. * Creates a tiled plane mesh
  67222. * * You can set a limited pattern arrangement with the tiles
  67223. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67224. * * 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
  67225. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67226. * @param name defines the name of the mesh
  67227. * @param options defines the options used to create the mesh
  67228. * @param scene defines the hosting scene
  67229. * @returns the plane mesh
  67230. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  67231. */
  67232. static CreateTiledPlane(name: string, options: {
  67233. pattern?: number;
  67234. tileSize?: number;
  67235. tileWidth?: number;
  67236. tileHeight?: number;
  67237. size?: number;
  67238. width?: number;
  67239. height?: number;
  67240. alignHorizontal?: number;
  67241. alignVertical?: number;
  67242. sideOrientation?: number;
  67243. frontUVs?: Vector4;
  67244. backUVs?: Vector4;
  67245. updatable?: boolean;
  67246. }, scene?: Nullable<Scene>): Mesh;
  67247. /**
  67248. * Creates a plane mesh
  67249. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  67250. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  67251. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  67252. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67253. * * 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
  67254. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67255. * @param name defines the name of the mesh
  67256. * @param options defines the options used to create the mesh
  67257. * @param scene defines the hosting scene
  67258. * @returns the plane mesh
  67259. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  67260. */
  67261. static CreatePlane(name: string, options: {
  67262. size?: number;
  67263. width?: number;
  67264. height?: number;
  67265. sideOrientation?: number;
  67266. frontUVs?: Vector4;
  67267. backUVs?: Vector4;
  67268. updatable?: boolean;
  67269. sourcePlane?: Plane;
  67270. }, scene?: Nullable<Scene>): Mesh;
  67271. /**
  67272. * Creates a ground mesh
  67273. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  67274. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  67275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67276. * @param name defines the name of the mesh
  67277. * @param options defines the options used to create the mesh
  67278. * @param scene defines the hosting scene
  67279. * @returns the ground mesh
  67280. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  67281. */
  67282. static CreateGround(name: string, options: {
  67283. width?: number;
  67284. height?: number;
  67285. subdivisions?: number;
  67286. subdivisionsX?: number;
  67287. subdivisionsY?: number;
  67288. updatable?: boolean;
  67289. }, scene?: Nullable<Scene>): Mesh;
  67290. /**
  67291. * Creates a tiled ground mesh
  67292. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  67293. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  67294. * * 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
  67295. * * 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
  67296. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67297. * @param name defines the name of the mesh
  67298. * @param options defines the options used to create the mesh
  67299. * @param scene defines the hosting scene
  67300. * @returns the tiled ground mesh
  67301. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  67302. */
  67303. static CreateTiledGround(name: string, options: {
  67304. xmin: number;
  67305. zmin: number;
  67306. xmax: number;
  67307. zmax: number;
  67308. subdivisions?: {
  67309. w: number;
  67310. h: number;
  67311. };
  67312. precision?: {
  67313. w: number;
  67314. h: number;
  67315. };
  67316. updatable?: boolean;
  67317. }, scene?: Nullable<Scene>): Mesh;
  67318. /**
  67319. * Creates a ground mesh from a height map
  67320. * * The parameter `url` sets the URL of the height map image resource.
  67321. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  67322. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  67323. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  67324. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  67325. * * 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.
  67326. * * 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).
  67327. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  67328. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67329. * @param name defines the name of the mesh
  67330. * @param url defines the url to the height map
  67331. * @param options defines the options used to create the mesh
  67332. * @param scene defines the hosting scene
  67333. * @returns the ground mesh
  67334. * @see https://doc.babylonjs.com/babylon101/height_map
  67335. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  67336. */
  67337. static CreateGroundFromHeightMap(name: string, url: string, options: {
  67338. width?: number;
  67339. height?: number;
  67340. subdivisions?: number;
  67341. minHeight?: number;
  67342. maxHeight?: number;
  67343. colorFilter?: Color3;
  67344. alphaFilter?: number;
  67345. updatable?: boolean;
  67346. onReady?: (mesh: GroundMesh) => void;
  67347. }, scene?: Nullable<Scene>): GroundMesh;
  67348. /**
  67349. * Creates a polygon mesh
  67350. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  67351. * * 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
  67352. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67353. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67354. * * 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)
  67355. * * Remember you can only change the shape positions, not their number when updating a polygon
  67356. * @param name defines the name of the mesh
  67357. * @param options defines the options used to create the mesh
  67358. * @param scene defines the hosting scene
  67359. * @param earcutInjection can be used to inject your own earcut reference
  67360. * @returns the polygon mesh
  67361. */
  67362. static CreatePolygon(name: string, options: {
  67363. shape: Vector3[];
  67364. holes?: Vector3[][];
  67365. depth?: number;
  67366. faceUV?: Vector4[];
  67367. faceColors?: Color4[];
  67368. updatable?: boolean;
  67369. sideOrientation?: number;
  67370. frontUVs?: Vector4;
  67371. backUVs?: Vector4;
  67372. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67373. /**
  67374. * Creates an extruded polygon mesh, with depth in the Y direction.
  67375. * * 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)
  67376. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67377. * @param name defines the name of the mesh
  67378. * @param options defines the options used to create the mesh
  67379. * @param scene defines the hosting scene
  67380. * @param earcutInjection can be used to inject your own earcut reference
  67381. * @returns the polygon mesh
  67382. */
  67383. static ExtrudePolygon(name: string, options: {
  67384. shape: Vector3[];
  67385. holes?: Vector3[][];
  67386. depth?: number;
  67387. faceUV?: Vector4[];
  67388. faceColors?: Color4[];
  67389. updatable?: boolean;
  67390. sideOrientation?: number;
  67391. frontUVs?: Vector4;
  67392. backUVs?: Vector4;
  67393. wrap?: boolean;
  67394. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67395. /**
  67396. * Creates a tube mesh.
  67397. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67398. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67399. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67400. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67401. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67402. * * 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)
  67403. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  67404. * * 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
  67405. * * 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
  67406. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67407. * * 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
  67408. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67409. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67410. * @param name defines the name of the mesh
  67411. * @param options defines the options used to create the mesh
  67412. * @param scene defines the hosting scene
  67413. * @returns the tube mesh
  67414. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67415. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  67416. */
  67417. static CreateTube(name: string, options: {
  67418. path: Vector3[];
  67419. radius?: number;
  67420. tessellation?: number;
  67421. radiusFunction?: {
  67422. (i: number, distance: number): number;
  67423. };
  67424. cap?: number;
  67425. arc?: number;
  67426. updatable?: boolean;
  67427. sideOrientation?: number;
  67428. frontUVs?: Vector4;
  67429. backUVs?: Vector4;
  67430. instance?: Mesh;
  67431. invertUV?: boolean;
  67432. }, scene?: Nullable<Scene>): Mesh;
  67433. /**
  67434. * Creates a polyhedron mesh
  67435. * * 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
  67436. * * The parameter `size` (positive float, default 1) sets the polygon size
  67437. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  67438. * * 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`
  67439. * * 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
  67440. * * 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)`)
  67441. * * 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
  67442. * * 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
  67443. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67444. * * 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
  67445. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67446. * @param name defines the name of the mesh
  67447. * @param options defines the options used to create the mesh
  67448. * @param scene defines the hosting scene
  67449. * @returns the polyhedron mesh
  67450. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  67451. */
  67452. static CreatePolyhedron(name: string, options: {
  67453. type?: number;
  67454. size?: number;
  67455. sizeX?: number;
  67456. sizeY?: number;
  67457. sizeZ?: number;
  67458. custom?: any;
  67459. faceUV?: Vector4[];
  67460. faceColors?: Color4[];
  67461. flat?: boolean;
  67462. updatable?: boolean;
  67463. sideOrientation?: number;
  67464. frontUVs?: Vector4;
  67465. backUVs?: Vector4;
  67466. }, scene?: Nullable<Scene>): Mesh;
  67467. /**
  67468. * Creates a decal mesh.
  67469. * 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
  67470. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  67471. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67472. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67473. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67474. * @param name defines the name of the mesh
  67475. * @param sourceMesh defines the mesh where the decal must be applied
  67476. * @param options defines the options used to create the mesh
  67477. * @param scene defines the hosting scene
  67478. * @returns the decal mesh
  67479. * @see https://doc.babylonjs.com/how_to/decals
  67480. */
  67481. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  67482. position?: Vector3;
  67483. normal?: Vector3;
  67484. size?: Vector3;
  67485. angle?: number;
  67486. }): Mesh;
  67487. /**
  67488. * Creates a Capsule Mesh
  67489. * @param name defines the name of the mesh.
  67490. * @param options the constructors options used to shape the mesh.
  67491. * @param scene defines the scene the mesh is scoped to.
  67492. * @returns the capsule mesh
  67493. * @see https://doc.babylonjs.com/how_to/capsule_shape
  67494. */
  67495. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  67496. }
  67497. }
  67498. declare module BABYLON {
  67499. /**
  67500. * A simplifier interface for future simplification implementations
  67501. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67502. */
  67503. export interface ISimplifier {
  67504. /**
  67505. * Simplification of a given mesh according to the given settings.
  67506. * Since this requires computation, it is assumed that the function runs async.
  67507. * @param settings The settings of the simplification, including quality and distance
  67508. * @param successCallback A callback that will be called after the mesh was simplified.
  67509. * @param errorCallback in case of an error, this callback will be called. optional.
  67510. */
  67511. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  67512. }
  67513. /**
  67514. * Expected simplification settings.
  67515. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  67516. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67517. */
  67518. export interface ISimplificationSettings {
  67519. /**
  67520. * Gets or sets the expected quality
  67521. */
  67522. quality: number;
  67523. /**
  67524. * Gets or sets the distance when this optimized version should be used
  67525. */
  67526. distance: number;
  67527. /**
  67528. * Gets an already optimized mesh
  67529. */
  67530. optimizeMesh?: boolean;
  67531. }
  67532. /**
  67533. * Class used to specify simplification options
  67534. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67535. */
  67536. export class SimplificationSettings implements ISimplificationSettings {
  67537. /** expected quality */
  67538. quality: number;
  67539. /** distance when this optimized version should be used */
  67540. distance: number;
  67541. /** already optimized mesh */
  67542. optimizeMesh?: boolean | undefined;
  67543. /**
  67544. * Creates a SimplificationSettings
  67545. * @param quality expected quality
  67546. * @param distance distance when this optimized version should be used
  67547. * @param optimizeMesh already optimized mesh
  67548. */
  67549. constructor(
  67550. /** expected quality */
  67551. quality: number,
  67552. /** distance when this optimized version should be used */
  67553. distance: number,
  67554. /** already optimized mesh */
  67555. optimizeMesh?: boolean | undefined);
  67556. }
  67557. /**
  67558. * Interface used to define a simplification task
  67559. */
  67560. export interface ISimplificationTask {
  67561. /**
  67562. * Array of settings
  67563. */
  67564. settings: Array<ISimplificationSettings>;
  67565. /**
  67566. * Simplification type
  67567. */
  67568. simplificationType: SimplificationType;
  67569. /**
  67570. * Mesh to simplify
  67571. */
  67572. mesh: Mesh;
  67573. /**
  67574. * Callback called on success
  67575. */
  67576. successCallback?: () => void;
  67577. /**
  67578. * Defines if parallel processing can be used
  67579. */
  67580. parallelProcessing: boolean;
  67581. }
  67582. /**
  67583. * Queue used to order the simplification tasks
  67584. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67585. */
  67586. export class SimplificationQueue {
  67587. private _simplificationArray;
  67588. /**
  67589. * Gets a boolean indicating that the process is still running
  67590. */
  67591. running: boolean;
  67592. /**
  67593. * Creates a new queue
  67594. */
  67595. constructor();
  67596. /**
  67597. * Adds a new simplification task
  67598. * @param task defines a task to add
  67599. */
  67600. addTask(task: ISimplificationTask): void;
  67601. /**
  67602. * Execute next task
  67603. */
  67604. executeNext(): void;
  67605. /**
  67606. * Execute a simplification task
  67607. * @param task defines the task to run
  67608. */
  67609. runSimplification(task: ISimplificationTask): void;
  67610. private getSimplifier;
  67611. }
  67612. /**
  67613. * The implemented types of simplification
  67614. * At the moment only Quadratic Error Decimation is implemented
  67615. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67616. */
  67617. export enum SimplificationType {
  67618. /** Quadratic error decimation */
  67619. QUADRATIC = 0
  67620. }
  67621. /**
  67622. * An implementation of the Quadratic Error simplification algorithm.
  67623. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  67624. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  67625. * @author RaananW
  67626. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67627. */
  67628. export class QuadraticErrorSimplification implements ISimplifier {
  67629. private _mesh;
  67630. private triangles;
  67631. private vertices;
  67632. private references;
  67633. private _reconstructedMesh;
  67634. /** Gets or sets the number pf sync interations */
  67635. syncIterations: number;
  67636. /** Gets or sets the aggressiveness of the simplifier */
  67637. aggressiveness: number;
  67638. /** Gets or sets the number of allowed iterations for decimation */
  67639. decimationIterations: number;
  67640. /** Gets or sets the espilon to use for bounding box computation */
  67641. boundingBoxEpsilon: number;
  67642. /**
  67643. * Creates a new QuadraticErrorSimplification
  67644. * @param _mesh defines the target mesh
  67645. */
  67646. constructor(_mesh: Mesh);
  67647. /**
  67648. * Simplification of a given mesh according to the given settings.
  67649. * Since this requires computation, it is assumed that the function runs async.
  67650. * @param settings The settings of the simplification, including quality and distance
  67651. * @param successCallback A callback that will be called after the mesh was simplified.
  67652. */
  67653. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  67654. private runDecimation;
  67655. private initWithMesh;
  67656. private init;
  67657. private reconstructMesh;
  67658. private initDecimatedMesh;
  67659. private isFlipped;
  67660. private updateTriangles;
  67661. private identifyBorder;
  67662. private updateMesh;
  67663. private vertexError;
  67664. private calculateError;
  67665. }
  67666. }
  67667. declare module BABYLON {
  67668. interface Scene {
  67669. /** @hidden (Backing field) */
  67670. _simplificationQueue: SimplificationQueue;
  67671. /**
  67672. * Gets or sets the simplification queue attached to the scene
  67673. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67674. */
  67675. simplificationQueue: SimplificationQueue;
  67676. }
  67677. interface Mesh {
  67678. /**
  67679. * Simplify the mesh according to the given array of settings.
  67680. * Function will return immediately and will simplify async
  67681. * @param settings a collection of simplification settings
  67682. * @param parallelProcessing should all levels calculate parallel or one after the other
  67683. * @param simplificationType the type of simplification to run
  67684. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  67685. * @returns the current mesh
  67686. */
  67687. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  67688. }
  67689. /**
  67690. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  67691. * created in a scene
  67692. */
  67693. export class SimplicationQueueSceneComponent implements ISceneComponent {
  67694. /**
  67695. * The component name helpfull to identify the component in the list of scene components.
  67696. */
  67697. readonly name: string;
  67698. /**
  67699. * The scene the component belongs to.
  67700. */
  67701. scene: Scene;
  67702. /**
  67703. * Creates a new instance of the component for the given scene
  67704. * @param scene Defines the scene to register the component in
  67705. */
  67706. constructor(scene: Scene);
  67707. /**
  67708. * Registers the component in a given scene
  67709. */
  67710. register(): void;
  67711. /**
  67712. * Rebuilds the elements related to this component in case of
  67713. * context lost for instance.
  67714. */
  67715. rebuild(): void;
  67716. /**
  67717. * Disposes the component and the associated ressources
  67718. */
  67719. dispose(): void;
  67720. private _beforeCameraUpdate;
  67721. }
  67722. }
  67723. declare module BABYLON {
  67724. interface Mesh {
  67725. /**
  67726. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  67727. */
  67728. thinInstanceEnablePicking: boolean;
  67729. /**
  67730. * Creates a new thin instance
  67731. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  67732. * @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
  67733. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  67734. */
  67735. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  67736. /**
  67737. * Adds the transformation (matrix) of the current mesh as a thin instance
  67738. * @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
  67739. * @returns the thin instance index number
  67740. */
  67741. thinInstanceAddSelf(refresh: boolean): number;
  67742. /**
  67743. * Registers a custom attribute to be used with thin instances
  67744. * @param kind name of the attribute
  67745. * @param stride size in floats of the attribute
  67746. */
  67747. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  67748. /**
  67749. * Sets the matrix of a thin instance
  67750. * @param index index of the thin instance
  67751. * @param matrix matrix to set
  67752. * @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
  67753. */
  67754. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  67755. /**
  67756. * Sets the value of a custom attribute for a thin instance
  67757. * @param kind name of the attribute
  67758. * @param index index of the thin instance
  67759. * @param value value to set
  67760. * @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
  67761. */
  67762. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  67763. /**
  67764. * 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.
  67765. */
  67766. thinInstanceCount: number;
  67767. /**
  67768. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  67769. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  67770. * @param buffer buffer to set
  67771. * @param stride size in floats of each value of the buffer
  67772. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  67773. */
  67774. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  67775. /**
  67776. * Gets the list of world matrices
  67777. * @return an array containing all the world matrices from the thin instances
  67778. */
  67779. thinInstanceGetWorldMatrices(): Matrix[];
  67780. /**
  67781. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  67782. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  67783. */
  67784. thinInstanceBufferUpdated(kind: string): void;
  67785. /**
  67786. * Applies a partial update to a buffer directly on the GPU
  67787. * 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
  67788. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  67789. * @param data the data to set in the GPU buffer
  67790. * @param offset the offset in the GPU buffer where to update the data
  67791. */
  67792. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  67793. /**
  67794. * Refreshes the bounding info, taking into account all the thin instances defined
  67795. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  67796. */
  67797. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  67798. /** @hidden */
  67799. _thinInstanceInitializeUserStorage(): void;
  67800. /** @hidden */
  67801. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  67802. /** @hidden */
  67803. _userThinInstanceBuffersStorage: {
  67804. data: {
  67805. [key: string]: Float32Array;
  67806. };
  67807. sizes: {
  67808. [key: string]: number;
  67809. };
  67810. vertexBuffers: {
  67811. [key: string]: Nullable<VertexBuffer>;
  67812. };
  67813. strides: {
  67814. [key: string]: number;
  67815. };
  67816. };
  67817. }
  67818. }
  67819. declare module BABYLON {
  67820. /**
  67821. * Navigation plugin interface to add navigation constrained by a navigation mesh
  67822. */
  67823. export interface INavigationEnginePlugin {
  67824. /**
  67825. * plugin name
  67826. */
  67827. name: string;
  67828. /**
  67829. * Creates a navigation mesh
  67830. * @param meshes array of all the geometry used to compute the navigatio mesh
  67831. * @param parameters bunch of parameters used to filter geometry
  67832. */
  67833. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  67834. /**
  67835. * Create a navigation mesh debug mesh
  67836. * @param scene is where the mesh will be added
  67837. * @returns debug display mesh
  67838. */
  67839. createDebugNavMesh(scene: Scene): Mesh;
  67840. /**
  67841. * Get a navigation mesh constrained position, closest to the parameter position
  67842. * @param position world position
  67843. * @returns the closest point to position constrained by the navigation mesh
  67844. */
  67845. getClosestPoint(position: Vector3): Vector3;
  67846. /**
  67847. * Get a navigation mesh constrained position, closest to the parameter position
  67848. * @param position world position
  67849. * @param result output the closest point to position constrained by the navigation mesh
  67850. */
  67851. getClosestPointToRef(position: Vector3, result: Vector3): void;
  67852. /**
  67853. * Get a navigation mesh constrained position, within a particular radius
  67854. * @param position world position
  67855. * @param maxRadius the maximum distance to the constrained world position
  67856. * @returns the closest point to position constrained by the navigation mesh
  67857. */
  67858. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  67859. /**
  67860. * Get a navigation mesh constrained position, within a particular radius
  67861. * @param position world position
  67862. * @param maxRadius the maximum distance to the constrained world position
  67863. * @param result output the closest point to position constrained by the navigation mesh
  67864. */
  67865. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67866. /**
  67867. * Compute the final position from a segment made of destination-position
  67868. * @param position world position
  67869. * @param destination world position
  67870. * @returns the resulting point along the navmesh
  67871. */
  67872. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67873. /**
  67874. * Compute the final position from a segment made of destination-position
  67875. * @param position world position
  67876. * @param destination world position
  67877. * @param result output the resulting point along the navmesh
  67878. */
  67879. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67880. /**
  67881. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67882. * @param start world position
  67883. * @param end world position
  67884. * @returns array containing world position composing the path
  67885. */
  67886. computePath(start: Vector3, end: Vector3): Vector3[];
  67887. /**
  67888. * If this plugin is supported
  67889. * @returns true if plugin is supported
  67890. */
  67891. isSupported(): boolean;
  67892. /**
  67893. * Create a new Crowd so you can add agents
  67894. * @param maxAgents the maximum agent count in the crowd
  67895. * @param maxAgentRadius the maximum radius an agent can have
  67896. * @param scene to attach the crowd to
  67897. * @returns the crowd you can add agents to
  67898. */
  67899. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67900. /**
  67901. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67902. * The queries will try to find a solution within those bounds
  67903. * default is (1,1,1)
  67904. * @param extent x,y,z value that define the extent around the queries point of reference
  67905. */
  67906. setDefaultQueryExtent(extent: Vector3): void;
  67907. /**
  67908. * Get the Bounding box extent specified by setDefaultQueryExtent
  67909. * @returns the box extent values
  67910. */
  67911. getDefaultQueryExtent(): Vector3;
  67912. /**
  67913. * build the navmesh from a previously saved state using getNavmeshData
  67914. * @param data the Uint8Array returned by getNavmeshData
  67915. */
  67916. buildFromNavmeshData(data: Uint8Array): void;
  67917. /**
  67918. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67919. * @returns data the Uint8Array that can be saved and reused
  67920. */
  67921. getNavmeshData(): Uint8Array;
  67922. /**
  67923. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67924. * @param result output the box extent values
  67925. */
  67926. getDefaultQueryExtentToRef(result: Vector3): void;
  67927. /**
  67928. * Release all resources
  67929. */
  67930. dispose(): void;
  67931. }
  67932. /**
  67933. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  67934. */
  67935. export interface ICrowd {
  67936. /**
  67937. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67938. * You can attach anything to that node. The node position is updated in the scene update tick.
  67939. * @param pos world position that will be constrained by the navigation mesh
  67940. * @param parameters agent parameters
  67941. * @param transform hooked to the agent that will be update by the scene
  67942. * @returns agent index
  67943. */
  67944. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67945. /**
  67946. * Returns the agent position in world space
  67947. * @param index agent index returned by addAgent
  67948. * @returns world space position
  67949. */
  67950. getAgentPosition(index: number): Vector3;
  67951. /**
  67952. * Gets the agent position result in world space
  67953. * @param index agent index returned by addAgent
  67954. * @param result output world space position
  67955. */
  67956. getAgentPositionToRef(index: number, result: Vector3): void;
  67957. /**
  67958. * Gets the agent velocity in world space
  67959. * @param index agent index returned by addAgent
  67960. * @returns world space velocity
  67961. */
  67962. getAgentVelocity(index: number): Vector3;
  67963. /**
  67964. * Gets the agent velocity result in world space
  67965. * @param index agent index returned by addAgent
  67966. * @param result output world space velocity
  67967. */
  67968. getAgentVelocityToRef(index: number, result: Vector3): void;
  67969. /**
  67970. * Gets the agent next target point on the path
  67971. * @param index agent index returned by addAgent
  67972. * @returns world space position
  67973. */
  67974. getAgentNextTargetPath(index: number): Vector3;
  67975. /**
  67976. * Gets the agent state
  67977. * @param index agent index returned by addAgent
  67978. * @returns agent state
  67979. */
  67980. getAgentState(index: number): number;
  67981. /**
  67982. * returns true if the agent in over an off mesh link connection
  67983. * @param index agent index returned by addAgent
  67984. * @returns true if over an off mesh link connection
  67985. */
  67986. overOffmeshConnection(index: number): boolean;
  67987. /**
  67988. * Gets the agent next target point on the path
  67989. * @param index agent index returned by addAgent
  67990. * @param result output world space position
  67991. */
  67992. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  67993. /**
  67994. * remove a particular agent previously created
  67995. * @param index agent index returned by addAgent
  67996. */
  67997. removeAgent(index: number): void;
  67998. /**
  67999. * get the list of all agents attached to this crowd
  68000. * @returns list of agent indices
  68001. */
  68002. getAgents(): number[];
  68003. /**
  68004. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68005. * @param deltaTime in seconds
  68006. */
  68007. update(deltaTime: number): void;
  68008. /**
  68009. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68010. * @param index agent index returned by addAgent
  68011. * @param destination targeted world position
  68012. */
  68013. agentGoto(index: number, destination: Vector3): void;
  68014. /**
  68015. * Teleport the agent to a new position
  68016. * @param index agent index returned by addAgent
  68017. * @param destination targeted world position
  68018. */
  68019. agentTeleport(index: number, destination: Vector3): void;
  68020. /**
  68021. * Update agent parameters
  68022. * @param index agent index returned by addAgent
  68023. * @param parameters agent parameters
  68024. */
  68025. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68026. /**
  68027. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68028. * The queries will try to find a solution within those bounds
  68029. * default is (1,1,1)
  68030. * @param extent x,y,z value that define the extent around the queries point of reference
  68031. */
  68032. setDefaultQueryExtent(extent: Vector3): void;
  68033. /**
  68034. * Get the Bounding box extent specified by setDefaultQueryExtent
  68035. * @returns the box extent values
  68036. */
  68037. getDefaultQueryExtent(): Vector3;
  68038. /**
  68039. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68040. * @param result output the box extent values
  68041. */
  68042. getDefaultQueryExtentToRef(result: Vector3): void;
  68043. /**
  68044. * Release all resources
  68045. */
  68046. dispose(): void;
  68047. }
  68048. /**
  68049. * Configures an agent
  68050. */
  68051. export interface IAgentParameters {
  68052. /**
  68053. * Agent radius. [Limit: >= 0]
  68054. */
  68055. radius: number;
  68056. /**
  68057. * Agent height. [Limit: > 0]
  68058. */
  68059. height: number;
  68060. /**
  68061. * Maximum allowed acceleration. [Limit: >= 0]
  68062. */
  68063. maxAcceleration: number;
  68064. /**
  68065. * Maximum allowed speed. [Limit: >= 0]
  68066. */
  68067. maxSpeed: number;
  68068. /**
  68069. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  68070. */
  68071. collisionQueryRange: number;
  68072. /**
  68073. * The path visibility optimization range. [Limit: > 0]
  68074. */
  68075. pathOptimizationRange: number;
  68076. /**
  68077. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  68078. */
  68079. separationWeight: number;
  68080. }
  68081. /**
  68082. * Configures the navigation mesh creation
  68083. */
  68084. export interface INavMeshParameters {
  68085. /**
  68086. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  68087. */
  68088. cs: number;
  68089. /**
  68090. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  68091. */
  68092. ch: number;
  68093. /**
  68094. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  68095. */
  68096. walkableSlopeAngle: number;
  68097. /**
  68098. * Minimum floor to 'ceiling' height that will still allow the floor area to
  68099. * be considered walkable. [Limit: >= 3] [Units: vx]
  68100. */
  68101. walkableHeight: number;
  68102. /**
  68103. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  68104. */
  68105. walkableClimb: number;
  68106. /**
  68107. * The distance to erode/shrink the walkable area of the heightfield away from
  68108. * obstructions. [Limit: >=0] [Units: vx]
  68109. */
  68110. walkableRadius: number;
  68111. /**
  68112. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  68113. */
  68114. maxEdgeLen: number;
  68115. /**
  68116. * The maximum distance a simplfied contour's border edges should deviate
  68117. * the original raw contour. [Limit: >=0] [Units: vx]
  68118. */
  68119. maxSimplificationError: number;
  68120. /**
  68121. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  68122. */
  68123. minRegionArea: number;
  68124. /**
  68125. * Any regions with a span count smaller than this value will, if possible,
  68126. * be merged with larger regions. [Limit: >=0] [Units: vx]
  68127. */
  68128. mergeRegionArea: number;
  68129. /**
  68130. * The maximum number of vertices allowed for polygons generated during the
  68131. * contour to polygon conversion process. [Limit: >= 3]
  68132. */
  68133. maxVertsPerPoly: number;
  68134. /**
  68135. * Sets the sampling distance to use when generating the detail mesh.
  68136. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  68137. */
  68138. detailSampleDist: number;
  68139. /**
  68140. * The maximum distance the detail mesh surface should deviate from heightfield
  68141. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  68142. */
  68143. detailSampleMaxError: number;
  68144. }
  68145. }
  68146. declare module BABYLON {
  68147. /**
  68148. * RecastJS navigation plugin
  68149. */
  68150. export class RecastJSPlugin implements INavigationEnginePlugin {
  68151. /**
  68152. * Reference to the Recast library
  68153. */
  68154. bjsRECAST: any;
  68155. /**
  68156. * plugin name
  68157. */
  68158. name: string;
  68159. /**
  68160. * the first navmesh created. We might extend this to support multiple navmeshes
  68161. */
  68162. navMesh: any;
  68163. /**
  68164. * Initializes the recastJS plugin
  68165. * @param recastInjection can be used to inject your own recast reference
  68166. */
  68167. constructor(recastInjection?: any);
  68168. /**
  68169. * Creates a navigation mesh
  68170. * @param meshes array of all the geometry used to compute the navigatio mesh
  68171. * @param parameters bunch of parameters used to filter geometry
  68172. */
  68173. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  68174. /**
  68175. * Create a navigation mesh debug mesh
  68176. * @param scene is where the mesh will be added
  68177. * @returns debug display mesh
  68178. */
  68179. createDebugNavMesh(scene: Scene): Mesh;
  68180. /**
  68181. * Get a navigation mesh constrained position, closest to the parameter position
  68182. * @param position world position
  68183. * @returns the closest point to position constrained by the navigation mesh
  68184. */
  68185. getClosestPoint(position: Vector3): Vector3;
  68186. /**
  68187. * Get a navigation mesh constrained position, closest to the parameter position
  68188. * @param position world position
  68189. * @param result output the closest point to position constrained by the navigation mesh
  68190. */
  68191. getClosestPointToRef(position: Vector3, result: Vector3): void;
  68192. /**
  68193. * Get a navigation mesh constrained position, within a particular radius
  68194. * @param position world position
  68195. * @param maxRadius the maximum distance to the constrained world position
  68196. * @returns the closest point to position constrained by the navigation mesh
  68197. */
  68198. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  68199. /**
  68200. * Get a navigation mesh constrained position, within a particular radius
  68201. * @param position world position
  68202. * @param maxRadius the maximum distance to the constrained world position
  68203. * @param result output the closest point to position constrained by the navigation mesh
  68204. */
  68205. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  68206. /**
  68207. * Compute the final position from a segment made of destination-position
  68208. * @param position world position
  68209. * @param destination world position
  68210. * @returns the resulting point along the navmesh
  68211. */
  68212. moveAlong(position: Vector3, destination: Vector3): Vector3;
  68213. /**
  68214. * Compute the final position from a segment made of destination-position
  68215. * @param position world position
  68216. * @param destination world position
  68217. * @param result output the resulting point along the navmesh
  68218. */
  68219. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  68220. /**
  68221. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  68222. * @param start world position
  68223. * @param end world position
  68224. * @returns array containing world position composing the path
  68225. */
  68226. computePath(start: Vector3, end: Vector3): Vector3[];
  68227. /**
  68228. * Create a new Crowd so you can add agents
  68229. * @param maxAgents the maximum agent count in the crowd
  68230. * @param maxAgentRadius the maximum radius an agent can have
  68231. * @param scene to attach the crowd to
  68232. * @returns the crowd you can add agents to
  68233. */
  68234. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  68235. /**
  68236. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68237. * The queries will try to find a solution within those bounds
  68238. * default is (1,1,1)
  68239. * @param extent x,y,z value that define the extent around the queries point of reference
  68240. */
  68241. setDefaultQueryExtent(extent: Vector3): void;
  68242. /**
  68243. * Get the Bounding box extent specified by setDefaultQueryExtent
  68244. * @returns the box extent values
  68245. */
  68246. getDefaultQueryExtent(): Vector3;
  68247. /**
  68248. * build the navmesh from a previously saved state using getNavmeshData
  68249. * @param data the Uint8Array returned by getNavmeshData
  68250. */
  68251. buildFromNavmeshData(data: Uint8Array): void;
  68252. /**
  68253. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  68254. * @returns data the Uint8Array that can be saved and reused
  68255. */
  68256. getNavmeshData(): Uint8Array;
  68257. /**
  68258. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68259. * @param result output the box extent values
  68260. */
  68261. getDefaultQueryExtentToRef(result: Vector3): void;
  68262. /**
  68263. * Disposes
  68264. */
  68265. dispose(): void;
  68266. /**
  68267. * If this plugin is supported
  68268. * @returns true if plugin is supported
  68269. */
  68270. isSupported(): boolean;
  68271. }
  68272. /**
  68273. * Recast detour crowd implementation
  68274. */
  68275. export class RecastJSCrowd implements ICrowd {
  68276. /**
  68277. * Recast/detour plugin
  68278. */
  68279. bjsRECASTPlugin: RecastJSPlugin;
  68280. /**
  68281. * Link to the detour crowd
  68282. */
  68283. recastCrowd: any;
  68284. /**
  68285. * One transform per agent
  68286. */
  68287. transforms: TransformNode[];
  68288. /**
  68289. * All agents created
  68290. */
  68291. agents: number[];
  68292. /**
  68293. * Link to the scene is kept to unregister the crowd from the scene
  68294. */
  68295. private _scene;
  68296. /**
  68297. * Observer for crowd updates
  68298. */
  68299. private _onBeforeAnimationsObserver;
  68300. /**
  68301. * Constructor
  68302. * @param plugin recastJS plugin
  68303. * @param maxAgents the maximum agent count in the crowd
  68304. * @param maxAgentRadius the maximum radius an agent can have
  68305. * @param scene to attach the crowd to
  68306. * @returns the crowd you can add agents to
  68307. */
  68308. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  68309. /**
  68310. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  68311. * You can attach anything to that node. The node position is updated in the scene update tick.
  68312. * @param pos world position that will be constrained by the navigation mesh
  68313. * @param parameters agent parameters
  68314. * @param transform hooked to the agent that will be update by the scene
  68315. * @returns agent index
  68316. */
  68317. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  68318. /**
  68319. * Returns the agent position in world space
  68320. * @param index agent index returned by addAgent
  68321. * @returns world space position
  68322. */
  68323. getAgentPosition(index: number): Vector3;
  68324. /**
  68325. * Returns the agent position result in world space
  68326. * @param index agent index returned by addAgent
  68327. * @param result output world space position
  68328. */
  68329. getAgentPositionToRef(index: number, result: Vector3): void;
  68330. /**
  68331. * Returns the agent velocity in world space
  68332. * @param index agent index returned by addAgent
  68333. * @returns world space velocity
  68334. */
  68335. getAgentVelocity(index: number): Vector3;
  68336. /**
  68337. * Returns the agent velocity result in world space
  68338. * @param index agent index returned by addAgent
  68339. * @param result output world space velocity
  68340. */
  68341. getAgentVelocityToRef(index: number, result: Vector3): void;
  68342. /**
  68343. * Returns the agent next target point on the path
  68344. * @param index agent index returned by addAgent
  68345. * @returns world space position
  68346. */
  68347. getAgentNextTargetPath(index: number): Vector3;
  68348. /**
  68349. * Returns the agent next target point on the path
  68350. * @param index agent index returned by addAgent
  68351. * @param result output world space position
  68352. */
  68353. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  68354. /**
  68355. * Gets the agent state
  68356. * @param index agent index returned by addAgent
  68357. * @returns agent state
  68358. */
  68359. getAgentState(index: number): number;
  68360. /**
  68361. * returns true if the agent in over an off mesh link connection
  68362. * @param index agent index returned by addAgent
  68363. * @returns true if over an off mesh link connection
  68364. */
  68365. overOffmeshConnection(index: number): boolean;
  68366. /**
  68367. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68368. * @param index agent index returned by addAgent
  68369. * @param destination targeted world position
  68370. */
  68371. agentGoto(index: number, destination: Vector3): void;
  68372. /**
  68373. * Teleport the agent to a new position
  68374. * @param index agent index returned by addAgent
  68375. * @param destination targeted world position
  68376. */
  68377. agentTeleport(index: number, destination: Vector3): void;
  68378. /**
  68379. * Update agent parameters
  68380. * @param index agent index returned by addAgent
  68381. * @param parameters agent parameters
  68382. */
  68383. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68384. /**
  68385. * remove a particular agent previously created
  68386. * @param index agent index returned by addAgent
  68387. */
  68388. removeAgent(index: number): void;
  68389. /**
  68390. * get the list of all agents attached to this crowd
  68391. * @returns list of agent indices
  68392. */
  68393. getAgents(): number[];
  68394. /**
  68395. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68396. * @param deltaTime in seconds
  68397. */
  68398. update(deltaTime: number): void;
  68399. /**
  68400. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68401. * The queries will try to find a solution within those bounds
  68402. * default is (1,1,1)
  68403. * @param extent x,y,z value that define the extent around the queries point of reference
  68404. */
  68405. setDefaultQueryExtent(extent: Vector3): void;
  68406. /**
  68407. * Get the Bounding box extent specified by setDefaultQueryExtent
  68408. * @returns the box extent values
  68409. */
  68410. getDefaultQueryExtent(): Vector3;
  68411. /**
  68412. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68413. * @param result output the box extent values
  68414. */
  68415. getDefaultQueryExtentToRef(result: Vector3): void;
  68416. /**
  68417. * Release all resources
  68418. */
  68419. dispose(): void;
  68420. }
  68421. }
  68422. declare module BABYLON {
  68423. /**
  68424. * Class used to enable access to IndexedDB
  68425. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  68426. */
  68427. export class Database implements IOfflineProvider {
  68428. private _callbackManifestChecked;
  68429. private _currentSceneUrl;
  68430. private _db;
  68431. private _enableSceneOffline;
  68432. private _enableTexturesOffline;
  68433. private _manifestVersionFound;
  68434. private _mustUpdateRessources;
  68435. private _hasReachedQuota;
  68436. private _isSupported;
  68437. private _idbFactory;
  68438. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  68439. private static IsUASupportingBlobStorage;
  68440. /**
  68441. * Gets a boolean indicating if Database storate is enabled (off by default)
  68442. */
  68443. static IDBStorageEnabled: boolean;
  68444. /**
  68445. * Gets a boolean indicating if scene must be saved in the database
  68446. */
  68447. get enableSceneOffline(): boolean;
  68448. /**
  68449. * Gets a boolean indicating if textures must be saved in the database
  68450. */
  68451. get enableTexturesOffline(): boolean;
  68452. /**
  68453. * Creates a new Database
  68454. * @param urlToScene defines the url to load the scene
  68455. * @param callbackManifestChecked defines the callback to use when manifest is checked
  68456. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  68457. */
  68458. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  68459. private static _ParseURL;
  68460. private static _ReturnFullUrlLocation;
  68461. private _checkManifestFile;
  68462. /**
  68463. * Open the database and make it available
  68464. * @param successCallback defines the callback to call on success
  68465. * @param errorCallback defines the callback to call on error
  68466. */
  68467. open(successCallback: () => void, errorCallback: () => void): void;
  68468. /**
  68469. * Loads an image from the database
  68470. * @param url defines the url to load from
  68471. * @param image defines the target DOM image
  68472. */
  68473. loadImage(url: string, image: HTMLImageElement): void;
  68474. private _loadImageFromDBAsync;
  68475. private _saveImageIntoDBAsync;
  68476. private _checkVersionFromDB;
  68477. private _loadVersionFromDBAsync;
  68478. private _saveVersionIntoDBAsync;
  68479. /**
  68480. * Loads a file from database
  68481. * @param url defines the URL to load from
  68482. * @param sceneLoaded defines a callback to call on success
  68483. * @param progressCallBack defines a callback to call when progress changed
  68484. * @param errorCallback defines a callback to call on error
  68485. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  68486. */
  68487. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  68488. private _loadFileAsync;
  68489. private _saveFileAsync;
  68490. /**
  68491. * Validates if xhr data is correct
  68492. * @param xhr defines the request to validate
  68493. * @param dataType defines the expected data type
  68494. * @returns true if data is correct
  68495. */
  68496. private static _ValidateXHRData;
  68497. }
  68498. }
  68499. declare module BABYLON {
  68500. /** @hidden */
  68501. export var gpuUpdateParticlesPixelShader: {
  68502. name: string;
  68503. shader: string;
  68504. };
  68505. }
  68506. declare module BABYLON {
  68507. /** @hidden */
  68508. export var gpuUpdateParticlesVertexShader: {
  68509. name: string;
  68510. shader: string;
  68511. };
  68512. }
  68513. declare module BABYLON {
  68514. /** @hidden */
  68515. export var clipPlaneFragmentDeclaration2: {
  68516. name: string;
  68517. shader: string;
  68518. };
  68519. }
  68520. declare module BABYLON {
  68521. /** @hidden */
  68522. export var gpuRenderParticlesPixelShader: {
  68523. name: string;
  68524. shader: string;
  68525. };
  68526. }
  68527. declare module BABYLON {
  68528. /** @hidden */
  68529. export var clipPlaneVertexDeclaration2: {
  68530. name: string;
  68531. shader: string;
  68532. };
  68533. }
  68534. declare module BABYLON {
  68535. /** @hidden */
  68536. export var gpuRenderParticlesVertexShader: {
  68537. name: string;
  68538. shader: string;
  68539. };
  68540. }
  68541. declare module BABYLON {
  68542. /**
  68543. * This represents a GPU particle system in Babylon
  68544. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  68545. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  68546. */
  68547. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  68548. /**
  68549. * The layer mask we are rendering the particles through.
  68550. */
  68551. layerMask: number;
  68552. private _capacity;
  68553. private _activeCount;
  68554. private _currentActiveCount;
  68555. private _accumulatedCount;
  68556. private _renderEffect;
  68557. private _updateEffect;
  68558. private _buffer0;
  68559. private _buffer1;
  68560. private _spriteBuffer;
  68561. private _updateVAO;
  68562. private _renderVAO;
  68563. private _targetIndex;
  68564. private _sourceBuffer;
  68565. private _targetBuffer;
  68566. private _currentRenderId;
  68567. private _started;
  68568. private _stopped;
  68569. private _timeDelta;
  68570. private _randomTexture;
  68571. private _randomTexture2;
  68572. private _attributesStrideSize;
  68573. private _updateEffectOptions;
  68574. private _randomTextureSize;
  68575. private _actualFrame;
  68576. private _customEffect;
  68577. private readonly _rawTextureWidth;
  68578. /**
  68579. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  68580. */
  68581. static get IsSupported(): boolean;
  68582. /**
  68583. * An event triggered when the system is disposed.
  68584. */
  68585. onDisposeObservable: Observable<IParticleSystem>;
  68586. /**
  68587. * An event triggered when the system is stopped
  68588. */
  68589. onStoppedObservable: Observable<IParticleSystem>;
  68590. /**
  68591. * Gets the maximum number of particles active at the same time.
  68592. * @returns The max number of active particles.
  68593. */
  68594. getCapacity(): number;
  68595. /**
  68596. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  68597. * to override the particles.
  68598. */
  68599. forceDepthWrite: boolean;
  68600. /**
  68601. * Gets or set the number of active particles
  68602. */
  68603. get activeParticleCount(): number;
  68604. set activeParticleCount(value: number);
  68605. private _preWarmDone;
  68606. /**
  68607. * Specifies if the particles are updated in emitter local space or world space.
  68608. */
  68609. isLocal: boolean;
  68610. /** Gets or sets a matrix to use to compute projection */
  68611. defaultProjectionMatrix: Matrix;
  68612. /**
  68613. * Is this system ready to be used/rendered
  68614. * @return true if the system is ready
  68615. */
  68616. isReady(): boolean;
  68617. /**
  68618. * Gets if the system has been started. (Note: this will still be true after stop is called)
  68619. * @returns True if it has been started, otherwise false.
  68620. */
  68621. isStarted(): boolean;
  68622. /**
  68623. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  68624. * @returns True if it has been stopped, otherwise false.
  68625. */
  68626. isStopped(): boolean;
  68627. /**
  68628. * Gets a boolean indicating that the system is stopping
  68629. * @returns true if the system is currently stopping
  68630. */
  68631. isStopping(): boolean;
  68632. /**
  68633. * Gets the number of particles active at the same time.
  68634. * @returns The number of active particles.
  68635. */
  68636. getActiveCount(): number;
  68637. /**
  68638. * Starts the particle system and begins to emit
  68639. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  68640. */
  68641. start(delay?: number): void;
  68642. /**
  68643. * Stops the particle system.
  68644. */
  68645. stop(): void;
  68646. /**
  68647. * Remove all active particles
  68648. */
  68649. reset(): void;
  68650. /**
  68651. * Returns the string "GPUParticleSystem"
  68652. * @returns a string containing the class name
  68653. */
  68654. getClassName(): string;
  68655. /**
  68656. * Gets the custom effect used to render the particles
  68657. * @param blendMode Blend mode for which the effect should be retrieved
  68658. * @returns The effect
  68659. */
  68660. getCustomEffect(blendMode?: number): Nullable<Effect>;
  68661. /**
  68662. * Sets the custom effect used to render the particles
  68663. * @param effect The effect to set
  68664. * @param blendMode Blend mode for which the effect should be set
  68665. */
  68666. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  68667. /** @hidden */
  68668. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  68669. /**
  68670. * Observable that will be called just before the particles are drawn
  68671. */
  68672. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  68673. /**
  68674. * Gets the name of the particle vertex shader
  68675. */
  68676. get vertexShaderName(): string;
  68677. private _colorGradientsTexture;
  68678. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  68679. /**
  68680. * Adds a new color gradient
  68681. * @param gradient defines the gradient to use (between 0 and 1)
  68682. * @param color1 defines the color to affect to the specified gradient
  68683. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  68684. * @returns the current particle system
  68685. */
  68686. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  68687. private _refreshColorGradient;
  68688. /** Force the system to rebuild all gradients that need to be resync */
  68689. forceRefreshGradients(): void;
  68690. /**
  68691. * Remove a specific color gradient
  68692. * @param gradient defines the gradient to remove
  68693. * @returns the current particle system
  68694. */
  68695. removeColorGradient(gradient: number): GPUParticleSystem;
  68696. private _angularSpeedGradientsTexture;
  68697. private _sizeGradientsTexture;
  68698. private _velocityGradientsTexture;
  68699. private _limitVelocityGradientsTexture;
  68700. private _dragGradientsTexture;
  68701. private _addFactorGradient;
  68702. /**
  68703. * Adds a new size gradient
  68704. * @param gradient defines the gradient to use (between 0 and 1)
  68705. * @param factor defines the size factor to affect to the specified gradient
  68706. * @returns the current particle system
  68707. */
  68708. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  68709. /**
  68710. * Remove a specific size gradient
  68711. * @param gradient defines the gradient to remove
  68712. * @returns the current particle system
  68713. */
  68714. removeSizeGradient(gradient: number): GPUParticleSystem;
  68715. private _refreshFactorGradient;
  68716. /**
  68717. * Adds a new angular speed gradient
  68718. * @param gradient defines the gradient to use (between 0 and 1)
  68719. * @param factor defines the angular speed to affect to the specified gradient
  68720. * @returns the current particle system
  68721. */
  68722. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  68723. /**
  68724. * Remove a specific angular speed gradient
  68725. * @param gradient defines the gradient to remove
  68726. * @returns the current particle system
  68727. */
  68728. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  68729. /**
  68730. * Adds a new velocity gradient
  68731. * @param gradient defines the gradient to use (between 0 and 1)
  68732. * @param factor defines the velocity to affect to the specified gradient
  68733. * @returns the current particle system
  68734. */
  68735. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  68736. /**
  68737. * Remove a specific velocity gradient
  68738. * @param gradient defines the gradient to remove
  68739. * @returns the current particle system
  68740. */
  68741. removeVelocityGradient(gradient: number): GPUParticleSystem;
  68742. /**
  68743. * Adds a new limit velocity gradient
  68744. * @param gradient defines the gradient to use (between 0 and 1)
  68745. * @param factor defines the limit velocity value to affect to the specified gradient
  68746. * @returns the current particle system
  68747. */
  68748. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  68749. /**
  68750. * Remove a specific limit velocity gradient
  68751. * @param gradient defines the gradient to remove
  68752. * @returns the current particle system
  68753. */
  68754. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  68755. /**
  68756. * Adds a new drag gradient
  68757. * @param gradient defines the gradient to use (between 0 and 1)
  68758. * @param factor defines the drag value to affect to the specified gradient
  68759. * @returns the current particle system
  68760. */
  68761. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  68762. /**
  68763. * Remove a specific drag gradient
  68764. * @param gradient defines the gradient to remove
  68765. * @returns the current particle system
  68766. */
  68767. removeDragGradient(gradient: number): GPUParticleSystem;
  68768. /**
  68769. * Not supported by GPUParticleSystem
  68770. * @param gradient defines the gradient to use (between 0 and 1)
  68771. * @param factor defines the emit rate value to affect to the specified gradient
  68772. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68773. * @returns the current particle system
  68774. */
  68775. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68776. /**
  68777. * Not supported by GPUParticleSystem
  68778. * @param gradient defines the gradient to remove
  68779. * @returns the current particle system
  68780. */
  68781. removeEmitRateGradient(gradient: number): IParticleSystem;
  68782. /**
  68783. * Not supported by GPUParticleSystem
  68784. * @param gradient defines the gradient to use (between 0 and 1)
  68785. * @param factor defines the start size value to affect to the specified gradient
  68786. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68787. * @returns the current particle system
  68788. */
  68789. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68790. /**
  68791. * Not supported by GPUParticleSystem
  68792. * @param gradient defines the gradient to remove
  68793. * @returns the current particle system
  68794. */
  68795. removeStartSizeGradient(gradient: number): IParticleSystem;
  68796. /**
  68797. * Not supported by GPUParticleSystem
  68798. * @param gradient defines the gradient to use (between 0 and 1)
  68799. * @param min defines the color remap minimal range
  68800. * @param max defines the color remap maximal range
  68801. * @returns the current particle system
  68802. */
  68803. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  68804. /**
  68805. * Not supported by GPUParticleSystem
  68806. * @param gradient defines the gradient to remove
  68807. * @returns the current particle system
  68808. */
  68809. removeColorRemapGradient(): IParticleSystem;
  68810. /**
  68811. * Not supported by GPUParticleSystem
  68812. * @param gradient defines the gradient to use (between 0 and 1)
  68813. * @param min defines the alpha remap minimal range
  68814. * @param max defines the alpha remap maximal range
  68815. * @returns the current particle system
  68816. */
  68817. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  68818. /**
  68819. * Not supported by GPUParticleSystem
  68820. * @param gradient defines the gradient to remove
  68821. * @returns the current particle system
  68822. */
  68823. removeAlphaRemapGradient(): IParticleSystem;
  68824. /**
  68825. * Not supported by GPUParticleSystem
  68826. * @param gradient defines the gradient to use (between 0 and 1)
  68827. * @param color defines the color to affect to the specified gradient
  68828. * @returns the current particle system
  68829. */
  68830. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  68831. /**
  68832. * Not supported by GPUParticleSystem
  68833. * @param gradient defines the gradient to remove
  68834. * @returns the current particle system
  68835. */
  68836. removeRampGradient(): IParticleSystem;
  68837. /**
  68838. * Not supported by GPUParticleSystem
  68839. * @returns the list of ramp gradients
  68840. */
  68841. getRampGradients(): Nullable<Array<Color3Gradient>>;
  68842. /**
  68843. * Not supported by GPUParticleSystem
  68844. * Gets or sets a boolean indicating that ramp gradients must be used
  68845. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  68846. */
  68847. get useRampGradients(): boolean;
  68848. set useRampGradients(value: boolean);
  68849. /**
  68850. * Not supported by GPUParticleSystem
  68851. * @param gradient defines the gradient to use (between 0 and 1)
  68852. * @param factor defines the life time factor to affect to the specified gradient
  68853. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68854. * @returns the current particle system
  68855. */
  68856. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68857. /**
  68858. * Not supported by GPUParticleSystem
  68859. * @param gradient defines the gradient to remove
  68860. * @returns the current particle system
  68861. */
  68862. removeLifeTimeGradient(gradient: number): IParticleSystem;
  68863. /**
  68864. * Instantiates a GPU particle system.
  68865. * 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.
  68866. * @param name The name of the particle system
  68867. * @param options The options used to create the system
  68868. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  68869. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  68870. * @param customEffect a custom effect used to change the way particles are rendered by default
  68871. */
  68872. constructor(name: string, options: Partial<{
  68873. capacity: number;
  68874. randomTextureSize: number;
  68875. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  68876. protected _reset(): void;
  68877. private _createUpdateVAO;
  68878. private _createRenderVAO;
  68879. private _initialize;
  68880. /** @hidden */
  68881. _recreateUpdateEffect(): void;
  68882. private _getEffect;
  68883. /**
  68884. * Fill the defines array according to the current settings of the particle system
  68885. * @param defines Array to be updated
  68886. * @param blendMode blend mode to take into account when updating the array
  68887. */
  68888. fillDefines(defines: Array<string>, blendMode?: number): void;
  68889. /**
  68890. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  68891. * @param uniforms Uniforms array to fill
  68892. * @param attributes Attributes array to fill
  68893. * @param samplers Samplers array to fill
  68894. */
  68895. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  68896. /** @hidden */
  68897. _recreateRenderEffect(): Effect;
  68898. /**
  68899. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  68900. * @param preWarm defines if we are in the pre-warmimg phase
  68901. */
  68902. animate(preWarm?: boolean): void;
  68903. private _createFactorGradientTexture;
  68904. private _createSizeGradientTexture;
  68905. private _createAngularSpeedGradientTexture;
  68906. private _createVelocityGradientTexture;
  68907. private _createLimitVelocityGradientTexture;
  68908. private _createDragGradientTexture;
  68909. private _createColorGradientTexture;
  68910. /**
  68911. * Renders the particle system in its current state
  68912. * @param preWarm defines if the system should only update the particles but not render them
  68913. * @returns the current number of particles
  68914. */
  68915. render(preWarm?: boolean): number;
  68916. /**
  68917. * Rebuilds the particle system
  68918. */
  68919. rebuild(): void;
  68920. private _releaseBuffers;
  68921. private _releaseVAOs;
  68922. /**
  68923. * Disposes the particle system and free the associated resources
  68924. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  68925. */
  68926. dispose(disposeTexture?: boolean): void;
  68927. /**
  68928. * Clones the particle system.
  68929. * @param name The name of the cloned object
  68930. * @param newEmitter The new emitter to use
  68931. * @returns the cloned particle system
  68932. */
  68933. clone(name: string, newEmitter: any): GPUParticleSystem;
  68934. /**
  68935. * Serializes the particle system to a JSON object
  68936. * @param serializeTexture defines if the texture must be serialized as well
  68937. * @returns the JSON object
  68938. */
  68939. serialize(serializeTexture?: boolean): any;
  68940. /**
  68941. * Parses a JSON object to create a GPU particle system.
  68942. * @param parsedParticleSystem The JSON object to parse
  68943. * @param sceneOrEngine The scene or the engine to create the particle system in
  68944. * @param rootUrl The root url to use to load external dependencies like texture
  68945. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  68946. * @returns the parsed GPU particle system
  68947. */
  68948. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  68949. }
  68950. }
  68951. declare module BABYLON {
  68952. /**
  68953. * Represents a set of particle systems working together to create a specific effect
  68954. */
  68955. export class ParticleSystemSet implements IDisposable {
  68956. /**
  68957. * Gets or sets base Assets URL
  68958. */
  68959. static BaseAssetsUrl: string;
  68960. private _emitterCreationOptions;
  68961. private _emitterNode;
  68962. /**
  68963. * Gets the particle system list
  68964. */
  68965. systems: IParticleSystem[];
  68966. /**
  68967. * Gets the emitter node used with this set
  68968. */
  68969. get emitterNode(): Nullable<TransformNode>;
  68970. /**
  68971. * Creates a new emitter mesh as a sphere
  68972. * @param options defines the options used to create the sphere
  68973. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  68974. * @param scene defines the hosting scene
  68975. */
  68976. setEmitterAsSphere(options: {
  68977. diameter: number;
  68978. segments: number;
  68979. color: Color3;
  68980. }, renderingGroupId: number, scene: Scene): void;
  68981. /**
  68982. * Starts all particle systems of the set
  68983. * @param emitter defines an optional mesh to use as emitter for the particle systems
  68984. */
  68985. start(emitter?: AbstractMesh): void;
  68986. /**
  68987. * Release all associated resources
  68988. */
  68989. dispose(): void;
  68990. /**
  68991. * Serialize the set into a JSON compatible object
  68992. * @param serializeTexture defines if the texture must be serialized as well
  68993. * @returns a JSON compatible representation of the set
  68994. */
  68995. serialize(serializeTexture?: boolean): any;
  68996. /**
  68997. * Parse a new ParticleSystemSet from a serialized source
  68998. * @param data defines a JSON compatible representation of the set
  68999. * @param scene defines the hosting scene
  69000. * @param gpu defines if we want GPU particles or CPU particles
  69001. * @returns a new ParticleSystemSet
  69002. */
  69003. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  69004. }
  69005. }
  69006. declare module BABYLON {
  69007. /**
  69008. * This class is made for on one-liner static method to help creating particle system set.
  69009. */
  69010. export class ParticleHelper {
  69011. /**
  69012. * Gets or sets base Assets URL
  69013. */
  69014. static BaseAssetsUrl: string;
  69015. /** Define the Url to load snippets */
  69016. static SnippetUrl: string;
  69017. /**
  69018. * Create a default particle system that you can tweak
  69019. * @param emitter defines the emitter to use
  69020. * @param capacity defines the system capacity (default is 500 particles)
  69021. * @param scene defines the hosting scene
  69022. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  69023. * @returns the new Particle system
  69024. */
  69025. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  69026. /**
  69027. * This is the main static method (one-liner) of this helper to create different particle systems
  69028. * @param type This string represents the type to the particle system to create
  69029. * @param scene The scene where the particle system should live
  69030. * @param gpu If the system will use gpu
  69031. * @returns the ParticleSystemSet created
  69032. */
  69033. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  69034. /**
  69035. * Static function used to export a particle system to a ParticleSystemSet variable.
  69036. * Please note that the emitter shape is not exported
  69037. * @param systems defines the particle systems to export
  69038. * @returns the created particle system set
  69039. */
  69040. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  69041. /**
  69042. * Creates a particle system from a snippet saved in a remote file
  69043. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  69044. * @param url defines the url to load from
  69045. * @param scene defines the hosting scene
  69046. * @param gpu If the system will use gpu
  69047. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69048. * @returns a promise that will resolve to the new particle system
  69049. */
  69050. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  69051. /**
  69052. * Creates a particle system from a snippet saved by the particle system editor
  69053. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  69054. * @param scene defines the hosting scene
  69055. * @param gpu If the system will use gpu
  69056. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69057. * @returns a promise that will resolve to the new particle system
  69058. */
  69059. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  69060. }
  69061. }
  69062. declare module BABYLON {
  69063. interface Engine {
  69064. /**
  69065. * Create an effect to use with particle systems.
  69066. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  69067. * the particle system for which you want to create a custom effect in the last parameter
  69068. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  69069. * @param uniformsNames defines a list of attribute names
  69070. * @param samplers defines an array of string used to represent textures
  69071. * @param defines defines the string containing the defines to use to compile the shaders
  69072. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  69073. * @param onCompiled defines a function to call when the effect creation is successful
  69074. * @param onError defines a function to call when the effect creation has failed
  69075. * @param particleSystem the particle system you want to create the effect for
  69076. * @returns the new Effect
  69077. */
  69078. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  69079. }
  69080. interface Mesh {
  69081. /**
  69082. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  69083. * @returns an array of IParticleSystem
  69084. */
  69085. getEmittedParticleSystems(): IParticleSystem[];
  69086. /**
  69087. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  69088. * @returns an array of IParticleSystem
  69089. */
  69090. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  69091. }
  69092. }
  69093. declare module BABYLON {
  69094. /** Defines the 4 color options */
  69095. export enum PointColor {
  69096. /** color value */
  69097. Color = 2,
  69098. /** uv value */
  69099. UV = 1,
  69100. /** random value */
  69101. Random = 0,
  69102. /** stated value */
  69103. Stated = 3
  69104. }
  69105. /**
  69106. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  69107. * 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.
  69108. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  69109. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  69110. *
  69111. * Full documentation here : TO BE ENTERED
  69112. */
  69113. export class PointsCloudSystem implements IDisposable {
  69114. /**
  69115. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  69116. * Example : var p = SPS.particles[i];
  69117. */
  69118. particles: CloudPoint[];
  69119. /**
  69120. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  69121. */
  69122. nbParticles: number;
  69123. /**
  69124. * This a counter for your own usage. It's not set by any SPS functions.
  69125. */
  69126. counter: number;
  69127. /**
  69128. * The PCS name. This name is also given to the underlying mesh.
  69129. */
  69130. name: string;
  69131. /**
  69132. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  69133. */
  69134. mesh: Mesh;
  69135. /**
  69136. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  69137. * Please read :
  69138. */
  69139. vars: any;
  69140. /**
  69141. * @hidden
  69142. */
  69143. _size: number;
  69144. private _scene;
  69145. private _promises;
  69146. private _positions;
  69147. private _indices;
  69148. private _normals;
  69149. private _colors;
  69150. private _uvs;
  69151. private _indices32;
  69152. private _positions32;
  69153. private _colors32;
  69154. private _uvs32;
  69155. private _updatable;
  69156. private _isVisibilityBoxLocked;
  69157. private _alwaysVisible;
  69158. private _groups;
  69159. private _groupCounter;
  69160. private _computeParticleColor;
  69161. private _computeParticleTexture;
  69162. private _computeParticleRotation;
  69163. private _computeBoundingBox;
  69164. private _isReady;
  69165. /**
  69166. * Creates a PCS (Points Cloud System) object
  69167. * @param name (String) is the PCS name, this will be the underlying mesh name
  69168. * @param pointSize (number) is the size for each point
  69169. * @param scene (Scene) is the scene in which the PCS is added
  69170. * @param options defines the options of the PCS e.g.
  69171. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  69172. */
  69173. constructor(name: string, pointSize: number, scene: Scene, options?: {
  69174. updatable?: boolean;
  69175. });
  69176. /**
  69177. * Builds the PCS underlying mesh. Returns a standard Mesh.
  69178. * If no points were added to the PCS, the returned mesh is just a single point.
  69179. * @returns a promise for the created mesh
  69180. */
  69181. buildMeshAsync(): Promise<Mesh>;
  69182. /**
  69183. * @hidden
  69184. */
  69185. private _buildMesh;
  69186. private _addParticle;
  69187. private _randomUnitVector;
  69188. private _getColorIndicesForCoord;
  69189. private _setPointsColorOrUV;
  69190. private _colorFromTexture;
  69191. private _calculateDensity;
  69192. /**
  69193. * Adds points to the PCS in random positions within a unit sphere
  69194. * @param nb (positive integer) the number of particles to be created from this model
  69195. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  69196. * @returns the number of groups in the system
  69197. */
  69198. addPoints(nb: number, pointFunction?: any): number;
  69199. /**
  69200. * Adds points to the PCS from the surface of the model shape
  69201. * @param mesh is any Mesh object that will be used as a surface model for the points
  69202. * @param nb (positive integer) the number of particles to be created from this model
  69203. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  69204. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  69205. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  69206. * @returns the number of groups in the system
  69207. */
  69208. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  69209. /**
  69210. * Adds points to the PCS inside the model shape
  69211. * @param mesh is any Mesh object that will be used as a surface model for the points
  69212. * @param nb (positive integer) the number of particles to be created from this model
  69213. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  69214. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  69215. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  69216. * @returns the number of groups in the system
  69217. */
  69218. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  69219. /**
  69220. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  69221. * This method calls `updateParticle()` for each particle of the SPS.
  69222. * For an animated SPS, it is usually called within the render loop.
  69223. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  69224. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  69225. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  69226. * @returns the PCS.
  69227. */
  69228. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  69229. /**
  69230. * Disposes the PCS.
  69231. */
  69232. dispose(): void;
  69233. /**
  69234. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  69235. * doc :
  69236. * @returns the PCS.
  69237. */
  69238. refreshVisibleSize(): PointsCloudSystem;
  69239. /**
  69240. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  69241. * @param size the size (float) of the visibility box
  69242. * note : this doesn't lock the PCS mesh bounding box.
  69243. * doc :
  69244. */
  69245. setVisibilityBox(size: number): void;
  69246. /**
  69247. * Gets whether the PCS is always visible or not
  69248. * doc :
  69249. */
  69250. get isAlwaysVisible(): boolean;
  69251. /**
  69252. * Sets the PCS as always visible or not
  69253. * doc :
  69254. */
  69255. set isAlwaysVisible(val: boolean);
  69256. /**
  69257. * Tells to `setParticles()` to compute the particle rotations or not
  69258. * Default value : false. The PCS is faster when it's set to false
  69259. * Note : particle rotations are only applied to parent particles
  69260. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  69261. */
  69262. set computeParticleRotation(val: boolean);
  69263. /**
  69264. * Tells to `setParticles()` to compute the particle colors or not.
  69265. * Default value : true. The PCS is faster when it's set to false.
  69266. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  69267. */
  69268. set computeParticleColor(val: boolean);
  69269. set computeParticleTexture(val: boolean);
  69270. /**
  69271. * Gets if `setParticles()` computes the particle colors or not.
  69272. * Default value : false. The PCS is faster when it's set to false.
  69273. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  69274. */
  69275. get computeParticleColor(): boolean;
  69276. /**
  69277. * Gets if `setParticles()` computes the particle textures or not.
  69278. * Default value : false. The PCS is faster when it's set to false.
  69279. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  69280. */
  69281. get computeParticleTexture(): boolean;
  69282. /**
  69283. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  69284. */
  69285. set computeBoundingBox(val: boolean);
  69286. /**
  69287. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  69288. */
  69289. get computeBoundingBox(): boolean;
  69290. /**
  69291. * This function does nothing. It may be overwritten to set all the particle first values.
  69292. * The PCS doesn't call this function, you may have to call it by your own.
  69293. * doc :
  69294. */
  69295. initParticles(): void;
  69296. /**
  69297. * This function does nothing. It may be overwritten to recycle a particle
  69298. * The PCS doesn't call this function, you can to call it
  69299. * doc :
  69300. * @param particle The particle to recycle
  69301. * @returns the recycled particle
  69302. */
  69303. recycleParticle(particle: CloudPoint): CloudPoint;
  69304. /**
  69305. * Updates a particle : this function should be overwritten by the user.
  69306. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  69307. * doc :
  69308. * @example : just set a particle position or velocity and recycle conditions
  69309. * @param particle The particle to update
  69310. * @returns the updated particle
  69311. */
  69312. updateParticle(particle: CloudPoint): CloudPoint;
  69313. /**
  69314. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  69315. * This does nothing and may be overwritten by the user.
  69316. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  69317. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  69318. * @param update the boolean update value actually passed to setParticles()
  69319. */
  69320. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  69321. /**
  69322. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  69323. * This will be passed three parameters.
  69324. * This does nothing and may be overwritten by the user.
  69325. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  69326. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  69327. * @param update the boolean update value actually passed to setParticles()
  69328. */
  69329. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  69330. }
  69331. }
  69332. declare module BABYLON {
  69333. /**
  69334. * Represents one particle of a points cloud system.
  69335. */
  69336. export class CloudPoint {
  69337. /**
  69338. * particle global index
  69339. */
  69340. idx: number;
  69341. /**
  69342. * The color of the particle
  69343. */
  69344. color: Nullable<Color4>;
  69345. /**
  69346. * The world space position of the particle.
  69347. */
  69348. position: Vector3;
  69349. /**
  69350. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  69351. */
  69352. rotation: Vector3;
  69353. /**
  69354. * The world space rotation quaternion of the particle.
  69355. */
  69356. rotationQuaternion: Nullable<Quaternion>;
  69357. /**
  69358. * The uv of the particle.
  69359. */
  69360. uv: Nullable<Vector2>;
  69361. /**
  69362. * The current speed of the particle.
  69363. */
  69364. velocity: Vector3;
  69365. /**
  69366. * The pivot point in the particle local space.
  69367. */
  69368. pivot: Vector3;
  69369. /**
  69370. * Must the particle be translated from its pivot point in its local space ?
  69371. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  69372. * Default : false
  69373. */
  69374. translateFromPivot: boolean;
  69375. /**
  69376. * Index of this particle in the global "positions" array (Internal use)
  69377. * @hidden
  69378. */
  69379. _pos: number;
  69380. /**
  69381. * @hidden Index of this particle in the global "indices" array (Internal use)
  69382. */
  69383. _ind: number;
  69384. /**
  69385. * Group this particle belongs to
  69386. */
  69387. _group: PointsGroup;
  69388. /**
  69389. * Group id of this particle
  69390. */
  69391. groupId: number;
  69392. /**
  69393. * Index of the particle in its group id (Internal use)
  69394. */
  69395. idxInGroup: number;
  69396. /**
  69397. * @hidden Particle BoundingInfo object (Internal use)
  69398. */
  69399. _boundingInfo: BoundingInfo;
  69400. /**
  69401. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  69402. */
  69403. _pcs: PointsCloudSystem;
  69404. /**
  69405. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  69406. */
  69407. _stillInvisible: boolean;
  69408. /**
  69409. * @hidden Last computed particle rotation matrix
  69410. */
  69411. _rotationMatrix: number[];
  69412. /**
  69413. * Parent particle Id, if any.
  69414. * Default null.
  69415. */
  69416. parentId: Nullable<number>;
  69417. /**
  69418. * @hidden Internal global position in the PCS.
  69419. */
  69420. _globalPosition: Vector3;
  69421. /**
  69422. * Creates a Point Cloud object.
  69423. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  69424. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  69425. * @param group (PointsGroup) is the group the particle belongs to
  69426. * @param groupId (integer) is the group identifier in the PCS.
  69427. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  69428. * @param pcs defines the PCS it is associated to
  69429. */
  69430. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  69431. /**
  69432. * get point size
  69433. */
  69434. get size(): Vector3;
  69435. /**
  69436. * Set point size
  69437. */
  69438. set size(scale: Vector3);
  69439. /**
  69440. * Legacy support, changed quaternion to rotationQuaternion
  69441. */
  69442. get quaternion(): Nullable<Quaternion>;
  69443. /**
  69444. * Legacy support, changed quaternion to rotationQuaternion
  69445. */
  69446. set quaternion(q: Nullable<Quaternion>);
  69447. /**
  69448. * Returns a boolean. True if the particle intersects a mesh, else false
  69449. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  69450. * @param target is the object (point or mesh) what the intersection is computed against
  69451. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  69452. * @returns true if it intersects
  69453. */
  69454. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  69455. /**
  69456. * get the rotation matrix of the particle
  69457. * @hidden
  69458. */
  69459. getRotationMatrix(m: Matrix): void;
  69460. }
  69461. /**
  69462. * Represents a group of points in a points cloud system
  69463. * * PCS internal tool, don't use it manually.
  69464. */
  69465. export class PointsGroup {
  69466. /**
  69467. * The group id
  69468. * @hidden
  69469. */
  69470. groupID: number;
  69471. /**
  69472. * image data for group (internal use)
  69473. * @hidden
  69474. */
  69475. _groupImageData: Nullable<ArrayBufferView>;
  69476. /**
  69477. * Image Width (internal use)
  69478. * @hidden
  69479. */
  69480. _groupImgWidth: number;
  69481. /**
  69482. * Image Height (internal use)
  69483. * @hidden
  69484. */
  69485. _groupImgHeight: number;
  69486. /**
  69487. * Custom position function (internal use)
  69488. * @hidden
  69489. */
  69490. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  69491. /**
  69492. * density per facet for surface points
  69493. * @hidden
  69494. */
  69495. _groupDensity: number[];
  69496. /**
  69497. * Only when points are colored by texture carries pointer to texture list array
  69498. * @hidden
  69499. */
  69500. _textureNb: number;
  69501. /**
  69502. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  69503. * PCS internal tool, don't use it manually.
  69504. * @hidden
  69505. */
  69506. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  69507. }
  69508. }
  69509. declare module BABYLON {
  69510. interface Scene {
  69511. /** @hidden (Backing field) */
  69512. _physicsEngine: Nullable<IPhysicsEngine>;
  69513. /** @hidden */
  69514. _physicsTimeAccumulator: number;
  69515. /**
  69516. * Gets the current physics engine
  69517. * @returns a IPhysicsEngine or null if none attached
  69518. */
  69519. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  69520. /**
  69521. * Enables physics to the current scene
  69522. * @param gravity defines the scene's gravity for the physics engine
  69523. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  69524. * @return a boolean indicating if the physics engine was initialized
  69525. */
  69526. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  69527. /**
  69528. * Disables and disposes the physics engine associated with the scene
  69529. */
  69530. disablePhysicsEngine(): void;
  69531. /**
  69532. * Gets a boolean indicating if there is an active physics engine
  69533. * @returns a boolean indicating if there is an active physics engine
  69534. */
  69535. isPhysicsEnabled(): boolean;
  69536. /**
  69537. * Deletes a physics compound impostor
  69538. * @param compound defines the compound to delete
  69539. */
  69540. deleteCompoundImpostor(compound: any): void;
  69541. /**
  69542. * An event triggered when physic simulation is about to be run
  69543. */
  69544. onBeforePhysicsObservable: Observable<Scene>;
  69545. /**
  69546. * An event triggered when physic simulation has been done
  69547. */
  69548. onAfterPhysicsObservable: Observable<Scene>;
  69549. }
  69550. interface AbstractMesh {
  69551. /** @hidden */
  69552. _physicsImpostor: Nullable<PhysicsImpostor>;
  69553. /**
  69554. * Gets or sets impostor used for physic simulation
  69555. * @see https://doc.babylonjs.com/features/physics_engine
  69556. */
  69557. physicsImpostor: Nullable<PhysicsImpostor>;
  69558. /**
  69559. * Gets the current physics impostor
  69560. * @see https://doc.babylonjs.com/features/physics_engine
  69561. * @returns a physics impostor or null
  69562. */
  69563. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  69564. /** Apply a physic impulse to the mesh
  69565. * @param force defines the force to apply
  69566. * @param contactPoint defines where to apply the force
  69567. * @returns the current mesh
  69568. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  69569. */
  69570. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  69571. /**
  69572. * Creates a physic joint between two meshes
  69573. * @param otherMesh defines the other mesh to use
  69574. * @param pivot1 defines the pivot to use on this mesh
  69575. * @param pivot2 defines the pivot to use on the other mesh
  69576. * @param options defines additional options (can be plugin dependent)
  69577. * @returns the current mesh
  69578. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  69579. */
  69580. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  69581. /** @hidden */
  69582. _disposePhysicsObserver: Nullable<Observer<Node>>;
  69583. }
  69584. /**
  69585. * Defines the physics engine scene component responsible to manage a physics engine
  69586. */
  69587. export class PhysicsEngineSceneComponent implements ISceneComponent {
  69588. /**
  69589. * The component name helpful to identify the component in the list of scene components.
  69590. */
  69591. readonly name: string;
  69592. /**
  69593. * The scene the component belongs to.
  69594. */
  69595. scene: Scene;
  69596. /**
  69597. * Creates a new instance of the component for the given scene
  69598. * @param scene Defines the scene to register the component in
  69599. */
  69600. constructor(scene: Scene);
  69601. /**
  69602. * Registers the component in a given scene
  69603. */
  69604. register(): void;
  69605. /**
  69606. * Rebuilds the elements related to this component in case of
  69607. * context lost for instance.
  69608. */
  69609. rebuild(): void;
  69610. /**
  69611. * Disposes the component and the associated ressources
  69612. */
  69613. dispose(): void;
  69614. }
  69615. }
  69616. declare module BABYLON {
  69617. /**
  69618. * A helper for physics simulations
  69619. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69620. */
  69621. export class PhysicsHelper {
  69622. private _scene;
  69623. private _physicsEngine;
  69624. /**
  69625. * Initializes the Physics helper
  69626. * @param scene Babylon.js scene
  69627. */
  69628. constructor(scene: Scene);
  69629. /**
  69630. * Applies a radial explosion impulse
  69631. * @param origin the origin of the explosion
  69632. * @param radiusOrEventOptions the radius or the options of radial explosion
  69633. * @param strength the explosion strength
  69634. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69635. * @returns A physics radial explosion event, or null
  69636. */
  69637. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  69638. /**
  69639. * Applies a radial explosion force
  69640. * @param origin the origin of the explosion
  69641. * @param radiusOrEventOptions the radius or the options of radial explosion
  69642. * @param strength the explosion strength
  69643. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69644. * @returns A physics radial explosion event, or null
  69645. */
  69646. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  69647. /**
  69648. * Creates a gravitational field
  69649. * @param origin the origin of the explosion
  69650. * @param radiusOrEventOptions the radius or the options of radial explosion
  69651. * @param strength the explosion strength
  69652. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69653. * @returns A physics gravitational field event, or null
  69654. */
  69655. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  69656. /**
  69657. * Creates a physics updraft event
  69658. * @param origin the origin of the updraft
  69659. * @param radiusOrEventOptions the radius or the options of the updraft
  69660. * @param strength the strength of the updraft
  69661. * @param height the height of the updraft
  69662. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  69663. * @returns A physics updraft event, or null
  69664. */
  69665. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  69666. /**
  69667. * Creates a physics vortex event
  69668. * @param origin the of the vortex
  69669. * @param radiusOrEventOptions the radius or the options of the vortex
  69670. * @param strength the strength of the vortex
  69671. * @param height the height of the vortex
  69672. * @returns a Physics vortex event, or null
  69673. * A physics vortex event or null
  69674. */
  69675. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  69676. }
  69677. /**
  69678. * Represents a physics radial explosion event
  69679. */
  69680. class PhysicsRadialExplosionEvent {
  69681. private _scene;
  69682. private _options;
  69683. private _sphere;
  69684. private _dataFetched;
  69685. /**
  69686. * Initializes a radial explosioin event
  69687. * @param _scene BabylonJS scene
  69688. * @param _options The options for the vortex event
  69689. */
  69690. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  69691. /**
  69692. * Returns the data related to the radial explosion event (sphere).
  69693. * @returns The radial explosion event data
  69694. */
  69695. getData(): PhysicsRadialExplosionEventData;
  69696. /**
  69697. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  69698. * @param impostor A physics imposter
  69699. * @param origin the origin of the explosion
  69700. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  69701. */
  69702. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  69703. /**
  69704. * Triggers affecterd impostors callbacks
  69705. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  69706. */
  69707. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  69708. /**
  69709. * Disposes the sphere.
  69710. * @param force Specifies if the sphere should be disposed by force
  69711. */
  69712. dispose(force?: boolean): void;
  69713. /*** Helpers ***/
  69714. private _prepareSphere;
  69715. private _intersectsWithSphere;
  69716. }
  69717. /**
  69718. * Represents a gravitational field event
  69719. */
  69720. class PhysicsGravitationalFieldEvent {
  69721. private _physicsHelper;
  69722. private _scene;
  69723. private _origin;
  69724. private _options;
  69725. private _tickCallback;
  69726. private _sphere;
  69727. private _dataFetched;
  69728. /**
  69729. * Initializes the physics gravitational field event
  69730. * @param _physicsHelper A physics helper
  69731. * @param _scene BabylonJS scene
  69732. * @param _origin The origin position of the gravitational field event
  69733. * @param _options The options for the vortex event
  69734. */
  69735. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  69736. /**
  69737. * Returns the data related to the gravitational field event (sphere).
  69738. * @returns A gravitational field event
  69739. */
  69740. getData(): PhysicsGravitationalFieldEventData;
  69741. /**
  69742. * Enables the gravitational field.
  69743. */
  69744. enable(): void;
  69745. /**
  69746. * Disables the gravitational field.
  69747. */
  69748. disable(): void;
  69749. /**
  69750. * Disposes the sphere.
  69751. * @param force The force to dispose from the gravitational field event
  69752. */
  69753. dispose(force?: boolean): void;
  69754. private _tick;
  69755. }
  69756. /**
  69757. * Represents a physics updraft event
  69758. */
  69759. class PhysicsUpdraftEvent {
  69760. private _scene;
  69761. private _origin;
  69762. private _options;
  69763. private _physicsEngine;
  69764. private _originTop;
  69765. private _originDirection;
  69766. private _tickCallback;
  69767. private _cylinder;
  69768. private _cylinderPosition;
  69769. private _dataFetched;
  69770. /**
  69771. * Initializes the physics updraft event
  69772. * @param _scene BabylonJS scene
  69773. * @param _origin The origin position of the updraft
  69774. * @param _options The options for the updraft event
  69775. */
  69776. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  69777. /**
  69778. * Returns the data related to the updraft event (cylinder).
  69779. * @returns A physics updraft event
  69780. */
  69781. getData(): PhysicsUpdraftEventData;
  69782. /**
  69783. * Enables the updraft.
  69784. */
  69785. enable(): void;
  69786. /**
  69787. * Disables the updraft.
  69788. */
  69789. disable(): void;
  69790. /**
  69791. * Disposes the cylinder.
  69792. * @param force Specifies if the updraft should be disposed by force
  69793. */
  69794. dispose(force?: boolean): void;
  69795. private getImpostorHitData;
  69796. private _tick;
  69797. /*** Helpers ***/
  69798. private _prepareCylinder;
  69799. private _intersectsWithCylinder;
  69800. }
  69801. /**
  69802. * Represents a physics vortex event
  69803. */
  69804. class PhysicsVortexEvent {
  69805. private _scene;
  69806. private _origin;
  69807. private _options;
  69808. private _physicsEngine;
  69809. private _originTop;
  69810. private _tickCallback;
  69811. private _cylinder;
  69812. private _cylinderPosition;
  69813. private _dataFetched;
  69814. /**
  69815. * Initializes the physics vortex event
  69816. * @param _scene The BabylonJS scene
  69817. * @param _origin The origin position of the vortex
  69818. * @param _options The options for the vortex event
  69819. */
  69820. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  69821. /**
  69822. * Returns the data related to the vortex event (cylinder).
  69823. * @returns The physics vortex event data
  69824. */
  69825. getData(): PhysicsVortexEventData;
  69826. /**
  69827. * Enables the vortex.
  69828. */
  69829. enable(): void;
  69830. /**
  69831. * Disables the cortex.
  69832. */
  69833. disable(): void;
  69834. /**
  69835. * Disposes the sphere.
  69836. * @param force
  69837. */
  69838. dispose(force?: boolean): void;
  69839. private getImpostorHitData;
  69840. private _tick;
  69841. /*** Helpers ***/
  69842. private _prepareCylinder;
  69843. private _intersectsWithCylinder;
  69844. }
  69845. /**
  69846. * Options fot the radial explosion event
  69847. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69848. */
  69849. export class PhysicsRadialExplosionEventOptions {
  69850. /**
  69851. * The radius of the sphere for the radial explosion.
  69852. */
  69853. radius: number;
  69854. /**
  69855. * The strenth of the explosion.
  69856. */
  69857. strength: number;
  69858. /**
  69859. * The strenght of the force in correspondence to the distance of the affected object
  69860. */
  69861. falloff: PhysicsRadialImpulseFalloff;
  69862. /**
  69863. * Sphere options for the radial explosion.
  69864. */
  69865. sphere: {
  69866. segments: number;
  69867. diameter: number;
  69868. };
  69869. /**
  69870. * Sphere options for the radial explosion.
  69871. */
  69872. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  69873. }
  69874. /**
  69875. * Options fot the updraft event
  69876. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69877. */
  69878. export class PhysicsUpdraftEventOptions {
  69879. /**
  69880. * The radius of the cylinder for the vortex
  69881. */
  69882. radius: number;
  69883. /**
  69884. * The strenth of the updraft.
  69885. */
  69886. strength: number;
  69887. /**
  69888. * The height of the cylinder for the updraft.
  69889. */
  69890. height: number;
  69891. /**
  69892. * The mode for the the updraft.
  69893. */
  69894. updraftMode: PhysicsUpdraftMode;
  69895. }
  69896. /**
  69897. * Options fot the vortex event
  69898. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69899. */
  69900. export class PhysicsVortexEventOptions {
  69901. /**
  69902. * The radius of the cylinder for the vortex
  69903. */
  69904. radius: number;
  69905. /**
  69906. * The strenth of the vortex.
  69907. */
  69908. strength: number;
  69909. /**
  69910. * The height of the cylinder for the vortex.
  69911. */
  69912. height: number;
  69913. /**
  69914. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  69915. */
  69916. centripetalForceThreshold: number;
  69917. /**
  69918. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  69919. */
  69920. centripetalForceMultiplier: number;
  69921. /**
  69922. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  69923. */
  69924. centrifugalForceMultiplier: number;
  69925. /**
  69926. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  69927. */
  69928. updraftForceMultiplier: number;
  69929. }
  69930. /**
  69931. * The strenght of the force in correspondence to the distance of the affected object
  69932. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69933. */
  69934. export enum PhysicsRadialImpulseFalloff {
  69935. /** Defines that impulse is constant in strength across it's whole radius */
  69936. Constant = 0,
  69937. /** Defines that impulse gets weaker if it's further from the origin */
  69938. Linear = 1
  69939. }
  69940. /**
  69941. * The strength of the force in correspondence to the distance of the affected object
  69942. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69943. */
  69944. export enum PhysicsUpdraftMode {
  69945. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  69946. Center = 0,
  69947. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  69948. Perpendicular = 1
  69949. }
  69950. /**
  69951. * Interface for a physics hit data
  69952. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69953. */
  69954. export interface PhysicsHitData {
  69955. /**
  69956. * The force applied at the contact point
  69957. */
  69958. force: Vector3;
  69959. /**
  69960. * The contact point
  69961. */
  69962. contactPoint: Vector3;
  69963. /**
  69964. * The distance from the origin to the contact point
  69965. */
  69966. distanceFromOrigin: number;
  69967. }
  69968. /**
  69969. * Interface for radial explosion event data
  69970. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69971. */
  69972. export interface PhysicsRadialExplosionEventData {
  69973. /**
  69974. * A sphere used for the radial explosion event
  69975. */
  69976. sphere: Mesh;
  69977. }
  69978. /**
  69979. * Interface for gravitational field event data
  69980. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69981. */
  69982. export interface PhysicsGravitationalFieldEventData {
  69983. /**
  69984. * A sphere mesh used for the gravitational field event
  69985. */
  69986. sphere: Mesh;
  69987. }
  69988. /**
  69989. * Interface for updraft event data
  69990. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69991. */
  69992. export interface PhysicsUpdraftEventData {
  69993. /**
  69994. * A cylinder used for the updraft event
  69995. */
  69996. cylinder: Mesh;
  69997. }
  69998. /**
  69999. * Interface for vortex event data
  70000. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70001. */
  70002. export interface PhysicsVortexEventData {
  70003. /**
  70004. * A cylinder used for the vortex event
  70005. */
  70006. cylinder: Mesh;
  70007. }
  70008. /**
  70009. * Interface for an affected physics impostor
  70010. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70011. */
  70012. export interface PhysicsAffectedImpostorWithData {
  70013. /**
  70014. * The impostor affected by the effect
  70015. */
  70016. impostor: PhysicsImpostor;
  70017. /**
  70018. * The data about the hit/horce from the explosion
  70019. */
  70020. hitData: PhysicsHitData;
  70021. }
  70022. }
  70023. declare module BABYLON {
  70024. /** @hidden */
  70025. export var blackAndWhitePixelShader: {
  70026. name: string;
  70027. shader: string;
  70028. };
  70029. }
  70030. declare module BABYLON {
  70031. /**
  70032. * Post process used to render in black and white
  70033. */
  70034. export class BlackAndWhitePostProcess extends PostProcess {
  70035. /**
  70036. * Linear about to convert he result to black and white (default: 1)
  70037. */
  70038. degree: number;
  70039. /**
  70040. * Gets a string identifying the name of the class
  70041. * @returns "BlackAndWhitePostProcess" string
  70042. */
  70043. getClassName(): string;
  70044. /**
  70045. * Creates a black and white post process
  70046. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  70047. * @param name The name of the effect.
  70048. * @param options The required width/height ratio to downsize to before computing the render pass.
  70049. * @param camera The camera to apply the render pass to.
  70050. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70051. * @param engine The engine which the post process will be applied. (default: current engine)
  70052. * @param reusable If the post process can be reused on the same frame. (default: false)
  70053. */
  70054. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70055. /** @hidden */
  70056. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  70057. }
  70058. }
  70059. declare module BABYLON {
  70060. /**
  70061. * This represents a set of one or more post processes in Babylon.
  70062. * A post process can be used to apply a shader to a texture after it is rendered.
  70063. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70064. */
  70065. export class PostProcessRenderEffect {
  70066. private _postProcesses;
  70067. private _getPostProcesses;
  70068. private _singleInstance;
  70069. private _cameras;
  70070. private _indicesForCamera;
  70071. /**
  70072. * Name of the effect
  70073. * @hidden
  70074. */
  70075. _name: string;
  70076. /**
  70077. * Instantiates a post process render effect.
  70078. * A post process can be used to apply a shader to a texture after it is rendered.
  70079. * @param engine The engine the effect is tied to
  70080. * @param name The name of the effect
  70081. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  70082. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  70083. */
  70084. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  70085. /**
  70086. * Checks if all the post processes in the effect are supported.
  70087. */
  70088. get isSupported(): boolean;
  70089. /**
  70090. * Updates the current state of the effect
  70091. * @hidden
  70092. */
  70093. _update(): void;
  70094. /**
  70095. * Attaches the effect on cameras
  70096. * @param cameras The camera to attach to.
  70097. * @hidden
  70098. */
  70099. _attachCameras(cameras: Camera): void;
  70100. /**
  70101. * Attaches the effect on cameras
  70102. * @param cameras The camera to attach to.
  70103. * @hidden
  70104. */
  70105. _attachCameras(cameras: Camera[]): void;
  70106. /**
  70107. * Detaches the effect on cameras
  70108. * @param cameras The camera to detatch from.
  70109. * @hidden
  70110. */
  70111. _detachCameras(cameras: Camera): void;
  70112. /**
  70113. * Detatches the effect on cameras
  70114. * @param cameras The camera to detatch from.
  70115. * @hidden
  70116. */
  70117. _detachCameras(cameras: Camera[]): void;
  70118. /**
  70119. * Enables the effect on given cameras
  70120. * @param cameras The camera to enable.
  70121. * @hidden
  70122. */
  70123. _enable(cameras: Camera): void;
  70124. /**
  70125. * Enables the effect on given cameras
  70126. * @param cameras The camera to enable.
  70127. * @hidden
  70128. */
  70129. _enable(cameras: Nullable<Camera[]>): void;
  70130. /**
  70131. * Disables the effect on the given cameras
  70132. * @param cameras The camera to disable.
  70133. * @hidden
  70134. */
  70135. _disable(cameras: Camera): void;
  70136. /**
  70137. * Disables the effect on the given cameras
  70138. * @param cameras The camera to disable.
  70139. * @hidden
  70140. */
  70141. _disable(cameras: Nullable<Camera[]>): void;
  70142. /**
  70143. * Gets a list of the post processes contained in the effect.
  70144. * @param camera The camera to get the post processes on.
  70145. * @returns The list of the post processes in the effect.
  70146. */
  70147. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  70148. }
  70149. }
  70150. declare module BABYLON {
  70151. /** @hidden */
  70152. export var extractHighlightsPixelShader: {
  70153. name: string;
  70154. shader: string;
  70155. };
  70156. }
  70157. declare module BABYLON {
  70158. /**
  70159. * 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.
  70160. */
  70161. export class ExtractHighlightsPostProcess extends PostProcess {
  70162. /**
  70163. * The luminance threshold, pixels below this value will be set to black.
  70164. */
  70165. threshold: number;
  70166. /** @hidden */
  70167. _exposure: number;
  70168. /**
  70169. * Post process which has the input texture to be used when performing highlight extraction
  70170. * @hidden
  70171. */
  70172. _inputPostProcess: Nullable<PostProcess>;
  70173. /**
  70174. * Gets a string identifying the name of the class
  70175. * @returns "ExtractHighlightsPostProcess" string
  70176. */
  70177. getClassName(): string;
  70178. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70179. }
  70180. }
  70181. declare module BABYLON {
  70182. /** @hidden */
  70183. export var bloomMergePixelShader: {
  70184. name: string;
  70185. shader: string;
  70186. };
  70187. }
  70188. declare module BABYLON {
  70189. /**
  70190. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  70191. */
  70192. export class BloomMergePostProcess extends PostProcess {
  70193. /** Weight of the bloom to be added to the original input. */
  70194. weight: number;
  70195. /**
  70196. * Gets a string identifying the name of the class
  70197. * @returns "BloomMergePostProcess" string
  70198. */
  70199. getClassName(): string;
  70200. /**
  70201. * Creates a new instance of @see BloomMergePostProcess
  70202. * @param name The name of the effect.
  70203. * @param originalFromInput Post process which's input will be used for the merge.
  70204. * @param blurred Blurred highlights post process which's output will be used.
  70205. * @param weight Weight of the bloom to be added to the original input.
  70206. * @param options The required width/height ratio to downsize to before computing the render pass.
  70207. * @param camera The camera to apply the render pass to.
  70208. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70209. * @param engine The engine which the post process will be applied. (default: current engine)
  70210. * @param reusable If the post process can be reused on the same frame. (default: false)
  70211. * @param textureType Type of textures used when performing the post process. (default: 0)
  70212. * @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)
  70213. */
  70214. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  70215. /** Weight of the bloom to be added to the original input. */
  70216. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70217. }
  70218. }
  70219. declare module BABYLON {
  70220. /**
  70221. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  70222. */
  70223. export class BloomEffect extends PostProcessRenderEffect {
  70224. private bloomScale;
  70225. /**
  70226. * @hidden Internal
  70227. */
  70228. _effects: Array<PostProcess>;
  70229. /**
  70230. * @hidden Internal
  70231. */
  70232. _downscale: ExtractHighlightsPostProcess;
  70233. private _blurX;
  70234. private _blurY;
  70235. private _merge;
  70236. /**
  70237. * The luminance threshold to find bright areas of the image to bloom.
  70238. */
  70239. get threshold(): number;
  70240. set threshold(value: number);
  70241. /**
  70242. * The strength of the bloom.
  70243. */
  70244. get weight(): number;
  70245. set weight(value: number);
  70246. /**
  70247. * Specifies the size of the bloom blur kernel, relative to the final output size
  70248. */
  70249. get kernel(): number;
  70250. set kernel(value: number);
  70251. /**
  70252. * Creates a new instance of @see BloomEffect
  70253. * @param scene The scene the effect belongs to.
  70254. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  70255. * @param bloomKernel The size of the kernel to be used when applying the blur.
  70256. * @param bloomWeight The the strength of bloom.
  70257. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  70258. * @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)
  70259. */
  70260. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  70261. /**
  70262. * Disposes each of the internal effects for a given camera.
  70263. * @param camera The camera to dispose the effect on.
  70264. */
  70265. disposeEffects(camera: Camera): void;
  70266. /**
  70267. * @hidden Internal
  70268. */
  70269. _updateEffects(): void;
  70270. /**
  70271. * Internal
  70272. * @returns if all the contained post processes are ready.
  70273. * @hidden
  70274. */
  70275. _isReady(): boolean;
  70276. }
  70277. }
  70278. declare module BABYLON {
  70279. /** @hidden */
  70280. export var chromaticAberrationPixelShader: {
  70281. name: string;
  70282. shader: string;
  70283. };
  70284. }
  70285. declare module BABYLON {
  70286. /**
  70287. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  70288. */
  70289. export class ChromaticAberrationPostProcess extends PostProcess {
  70290. /**
  70291. * The amount of seperation of rgb channels (default: 30)
  70292. */
  70293. aberrationAmount: number;
  70294. /**
  70295. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  70296. */
  70297. radialIntensity: number;
  70298. /**
  70299. * 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))
  70300. */
  70301. direction: Vector2;
  70302. /**
  70303. * 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))
  70304. */
  70305. centerPosition: Vector2;
  70306. /** The width of the screen to apply the effect on */
  70307. screenWidth: number;
  70308. /** The height of the screen to apply the effect on */
  70309. screenHeight: number;
  70310. /**
  70311. * Gets a string identifying the name of the class
  70312. * @returns "ChromaticAberrationPostProcess" string
  70313. */
  70314. getClassName(): string;
  70315. /**
  70316. * Creates a new instance ChromaticAberrationPostProcess
  70317. * @param name The name of the effect.
  70318. * @param screenWidth The width of the screen to apply the effect on.
  70319. * @param screenHeight The height of the screen to apply the effect on.
  70320. * @param options The required width/height ratio to downsize to before computing the render pass.
  70321. * @param camera The camera to apply the render pass to.
  70322. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70323. * @param engine The engine which the post process will be applied. (default: current engine)
  70324. * @param reusable If the post process can be reused on the same frame. (default: false)
  70325. * @param textureType Type of textures used when performing the post process. (default: 0)
  70326. * @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)
  70327. */
  70328. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70329. /** @hidden */
  70330. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  70331. }
  70332. }
  70333. declare module BABYLON {
  70334. /** @hidden */
  70335. export var circleOfConfusionPixelShader: {
  70336. name: string;
  70337. shader: string;
  70338. };
  70339. }
  70340. declare module BABYLON {
  70341. /**
  70342. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  70343. */
  70344. export class CircleOfConfusionPostProcess extends PostProcess {
  70345. /**
  70346. * 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.
  70347. */
  70348. lensSize: number;
  70349. /**
  70350. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  70351. */
  70352. fStop: number;
  70353. /**
  70354. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  70355. */
  70356. focusDistance: number;
  70357. /**
  70358. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  70359. */
  70360. focalLength: number;
  70361. /**
  70362. * Gets a string identifying the name of the class
  70363. * @returns "CircleOfConfusionPostProcess" string
  70364. */
  70365. getClassName(): string;
  70366. private _depthTexture;
  70367. /**
  70368. * Creates a new instance CircleOfConfusionPostProcess
  70369. * @param name The name of the effect.
  70370. * @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.
  70371. * @param options The required width/height ratio to downsize to before computing the render pass.
  70372. * @param camera The camera to apply the render pass to.
  70373. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70374. * @param engine The engine which the post process will be applied. (default: current engine)
  70375. * @param reusable If the post process can be reused on the same frame. (default: false)
  70376. * @param textureType Type of textures used when performing the post process. (default: 0)
  70377. * @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)
  70378. */
  70379. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70380. /**
  70381. * 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.
  70382. */
  70383. set depthTexture(value: RenderTargetTexture);
  70384. }
  70385. }
  70386. declare module BABYLON {
  70387. /** @hidden */
  70388. export var colorCorrectionPixelShader: {
  70389. name: string;
  70390. shader: string;
  70391. };
  70392. }
  70393. declare module BABYLON {
  70394. /**
  70395. *
  70396. * This post-process allows the modification of rendered colors by using
  70397. * a 'look-up table' (LUT). This effect is also called Color Grading.
  70398. *
  70399. * The object needs to be provided an url to a texture containing the color
  70400. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  70401. * Use an image editing software to tweak the LUT to match your needs.
  70402. *
  70403. * For an example of a color LUT, see here:
  70404. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  70405. * For explanations on color grading, see here:
  70406. * @see http://udn.epicgames.com/Three/ColorGrading.html
  70407. *
  70408. */
  70409. export class ColorCorrectionPostProcess extends PostProcess {
  70410. private _colorTableTexture;
  70411. /**
  70412. * Gets the color table url used to create the LUT texture
  70413. */
  70414. colorTableUrl: string;
  70415. /**
  70416. * Gets a string identifying the name of the class
  70417. * @returns "ColorCorrectionPostProcess" string
  70418. */
  70419. getClassName(): string;
  70420. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70421. /** @hidden */
  70422. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  70423. }
  70424. }
  70425. declare module BABYLON {
  70426. /** @hidden */
  70427. export var convolutionPixelShader: {
  70428. name: string;
  70429. shader: string;
  70430. };
  70431. }
  70432. declare module BABYLON {
  70433. /**
  70434. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  70435. * input texture to perform effects such as edge detection or sharpening
  70436. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70437. */
  70438. export class ConvolutionPostProcess extends PostProcess {
  70439. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  70440. kernel: number[];
  70441. /**
  70442. * Gets a string identifying the name of the class
  70443. * @returns "ConvolutionPostProcess" string
  70444. */
  70445. getClassName(): string;
  70446. /**
  70447. * Creates a new instance ConvolutionPostProcess
  70448. * @param name The name of the effect.
  70449. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  70450. * @param options The required width/height ratio to downsize to before computing the render pass.
  70451. * @param camera The camera to apply the render pass to.
  70452. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70453. * @param engine The engine which the post process will be applied. (default: current engine)
  70454. * @param reusable If the post process can be reused on the same frame. (default: false)
  70455. * @param textureType Type of textures used when performing the post process. (default: 0)
  70456. */
  70457. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70458. /** @hidden */
  70459. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  70460. /**
  70461. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70462. */
  70463. static EdgeDetect0Kernel: number[];
  70464. /**
  70465. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70466. */
  70467. static EdgeDetect1Kernel: number[];
  70468. /**
  70469. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70470. */
  70471. static EdgeDetect2Kernel: number[];
  70472. /**
  70473. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70474. */
  70475. static SharpenKernel: number[];
  70476. /**
  70477. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70478. */
  70479. static EmbossKernel: number[];
  70480. /**
  70481. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70482. */
  70483. static GaussianKernel: number[];
  70484. }
  70485. }
  70486. declare module BABYLON {
  70487. /**
  70488. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  70489. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  70490. * based on samples that have a large difference in distance than the center pixel.
  70491. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  70492. */
  70493. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  70494. /**
  70495. * The direction the blur should be applied
  70496. */
  70497. direction: Vector2;
  70498. /**
  70499. * Gets a string identifying the name of the class
  70500. * @returns "DepthOfFieldBlurPostProcess" string
  70501. */
  70502. getClassName(): string;
  70503. /**
  70504. * Creates a new instance CircleOfConfusionPostProcess
  70505. * @param name The name of the effect.
  70506. * @param scene The scene the effect belongs to.
  70507. * @param direction The direction the blur should be applied.
  70508. * @param kernel The size of the kernel used to blur.
  70509. * @param options The required width/height ratio to downsize to before computing the render pass.
  70510. * @param camera The camera to apply the render pass to.
  70511. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  70512. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  70513. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70514. * @param engine The engine which the post process will be applied. (default: current engine)
  70515. * @param reusable If the post process can be reused on the same frame. (default: false)
  70516. * @param textureType Type of textures used when performing the post process. (default: 0)
  70517. * @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)
  70518. */
  70519. 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);
  70520. }
  70521. }
  70522. declare module BABYLON {
  70523. /** @hidden */
  70524. export var depthOfFieldMergePixelShader: {
  70525. name: string;
  70526. shader: string;
  70527. };
  70528. }
  70529. declare module BABYLON {
  70530. /**
  70531. * Options to be set when merging outputs from the default pipeline.
  70532. */
  70533. export class DepthOfFieldMergePostProcessOptions {
  70534. /**
  70535. * The original image to merge on top of
  70536. */
  70537. originalFromInput: PostProcess;
  70538. /**
  70539. * Parameters to perform the merge of the depth of field effect
  70540. */
  70541. depthOfField?: {
  70542. circleOfConfusion: PostProcess;
  70543. blurSteps: Array<PostProcess>;
  70544. };
  70545. /**
  70546. * Parameters to perform the merge of bloom effect
  70547. */
  70548. bloom?: {
  70549. blurred: PostProcess;
  70550. weight: number;
  70551. };
  70552. }
  70553. /**
  70554. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  70555. */
  70556. export class DepthOfFieldMergePostProcess extends PostProcess {
  70557. private blurSteps;
  70558. /**
  70559. * Gets a string identifying the name of the class
  70560. * @returns "DepthOfFieldMergePostProcess" string
  70561. */
  70562. getClassName(): string;
  70563. /**
  70564. * Creates a new instance of DepthOfFieldMergePostProcess
  70565. * @param name The name of the effect.
  70566. * @param originalFromInput Post process which's input will be used for the merge.
  70567. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  70568. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  70569. * @param options The required width/height ratio to downsize to before computing the render pass.
  70570. * @param camera The camera to apply the render pass to.
  70571. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70572. * @param engine The engine which the post process will be applied. (default: current engine)
  70573. * @param reusable If the post process can be reused on the same frame. (default: false)
  70574. * @param textureType Type of textures used when performing the post process. (default: 0)
  70575. * @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)
  70576. */
  70577. 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);
  70578. /**
  70579. * Updates the effect with the current post process compile time values and recompiles the shader.
  70580. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  70581. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  70582. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  70583. * @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
  70584. * @param onCompiled Called when the shader has been compiled.
  70585. * @param onError Called if there is an error when compiling a shader.
  70586. */
  70587. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  70588. }
  70589. }
  70590. declare module BABYLON {
  70591. /**
  70592. * Specifies the level of max blur that should be applied when using the depth of field effect
  70593. */
  70594. export enum DepthOfFieldEffectBlurLevel {
  70595. /**
  70596. * Subtle blur
  70597. */
  70598. Low = 0,
  70599. /**
  70600. * Medium blur
  70601. */
  70602. Medium = 1,
  70603. /**
  70604. * Large blur
  70605. */
  70606. High = 2
  70607. }
  70608. /**
  70609. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  70610. */
  70611. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  70612. private _circleOfConfusion;
  70613. /**
  70614. * @hidden Internal, blurs from high to low
  70615. */
  70616. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  70617. private _depthOfFieldBlurY;
  70618. private _dofMerge;
  70619. /**
  70620. * @hidden Internal post processes in depth of field effect
  70621. */
  70622. _effects: Array<PostProcess>;
  70623. /**
  70624. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  70625. */
  70626. set focalLength(value: number);
  70627. get focalLength(): number;
  70628. /**
  70629. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  70630. */
  70631. set fStop(value: number);
  70632. get fStop(): number;
  70633. /**
  70634. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  70635. */
  70636. set focusDistance(value: number);
  70637. get focusDistance(): number;
  70638. /**
  70639. * 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.
  70640. */
  70641. set lensSize(value: number);
  70642. get lensSize(): number;
  70643. /**
  70644. * Creates a new instance DepthOfFieldEffect
  70645. * @param scene The scene the effect belongs to.
  70646. * @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.
  70647. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  70648. * @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)
  70649. */
  70650. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  70651. /**
  70652. * Get the current class name of the current effet
  70653. * @returns "DepthOfFieldEffect"
  70654. */
  70655. getClassName(): string;
  70656. /**
  70657. * 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.
  70658. */
  70659. set depthTexture(value: RenderTargetTexture);
  70660. /**
  70661. * Disposes each of the internal effects for a given camera.
  70662. * @param camera The camera to dispose the effect on.
  70663. */
  70664. disposeEffects(camera: Camera): void;
  70665. /**
  70666. * @hidden Internal
  70667. */
  70668. _updateEffects(): void;
  70669. /**
  70670. * Internal
  70671. * @returns if all the contained post processes are ready.
  70672. * @hidden
  70673. */
  70674. _isReady(): boolean;
  70675. }
  70676. }
  70677. declare module BABYLON {
  70678. /** @hidden */
  70679. export var displayPassPixelShader: {
  70680. name: string;
  70681. shader: string;
  70682. };
  70683. }
  70684. declare module BABYLON {
  70685. /**
  70686. * DisplayPassPostProcess which produces an output the same as it's input
  70687. */
  70688. export class DisplayPassPostProcess extends PostProcess {
  70689. /**
  70690. * Gets a string identifying the name of the class
  70691. * @returns "DisplayPassPostProcess" string
  70692. */
  70693. getClassName(): string;
  70694. /**
  70695. * Creates the DisplayPassPostProcess
  70696. * @param name The name of the effect.
  70697. * @param options The required width/height ratio to downsize to before computing the render pass.
  70698. * @param camera The camera to apply the render pass to.
  70699. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70700. * @param engine The engine which the post process will be applied. (default: current engine)
  70701. * @param reusable If the post process can be reused on the same frame. (default: false)
  70702. */
  70703. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70704. /** @hidden */
  70705. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  70706. }
  70707. }
  70708. declare module BABYLON {
  70709. /** @hidden */
  70710. export var filterPixelShader: {
  70711. name: string;
  70712. shader: string;
  70713. };
  70714. }
  70715. declare module BABYLON {
  70716. /**
  70717. * Applies a kernel filter to the image
  70718. */
  70719. export class FilterPostProcess extends PostProcess {
  70720. /** The matrix to be applied to the image */
  70721. kernelMatrix: Matrix;
  70722. /**
  70723. * Gets a string identifying the name of the class
  70724. * @returns "FilterPostProcess" string
  70725. */
  70726. getClassName(): string;
  70727. /**
  70728. *
  70729. * @param name The name of the effect.
  70730. * @param kernelMatrix The matrix to be applied to the image
  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, kernelMatrix: Matrix, 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<FilterPostProcess>;
  70740. }
  70741. }
  70742. declare module BABYLON {
  70743. /** @hidden */
  70744. export var fxaaPixelShader: {
  70745. name: string;
  70746. shader: string;
  70747. };
  70748. }
  70749. declare module BABYLON {
  70750. /** @hidden */
  70751. export var fxaaVertexShader: {
  70752. name: string;
  70753. shader: string;
  70754. };
  70755. }
  70756. declare module BABYLON {
  70757. /**
  70758. * Fxaa post process
  70759. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  70760. */
  70761. export class FxaaPostProcess extends PostProcess {
  70762. /**
  70763. * Gets a string identifying the name of the class
  70764. * @returns "FxaaPostProcess" string
  70765. */
  70766. getClassName(): string;
  70767. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70768. private _getDefines;
  70769. /** @hidden */
  70770. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  70771. }
  70772. }
  70773. declare module BABYLON {
  70774. /** @hidden */
  70775. export var grainPixelShader: {
  70776. name: string;
  70777. shader: string;
  70778. };
  70779. }
  70780. declare module BABYLON {
  70781. /**
  70782. * The GrainPostProcess adds noise to the image at mid luminance levels
  70783. */
  70784. export class GrainPostProcess extends PostProcess {
  70785. /**
  70786. * The intensity of the grain added (default: 30)
  70787. */
  70788. intensity: number;
  70789. /**
  70790. * If the grain should be randomized on every frame
  70791. */
  70792. animated: boolean;
  70793. /**
  70794. * Gets a string identifying the name of the class
  70795. * @returns "GrainPostProcess" string
  70796. */
  70797. getClassName(): string;
  70798. /**
  70799. * Creates a new instance of @see GrainPostProcess
  70800. * @param name The name of the effect.
  70801. * @param options The required width/height ratio to downsize to before computing the render pass.
  70802. * @param camera The camera to apply the render pass to.
  70803. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70804. * @param engine The engine which the post process will be applied. (default: current engine)
  70805. * @param reusable If the post process can be reused on the same frame. (default: false)
  70806. * @param textureType Type of textures used when performing the post process. (default: 0)
  70807. * @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)
  70808. */
  70809. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70810. /** @hidden */
  70811. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  70812. }
  70813. }
  70814. declare module BABYLON {
  70815. /** @hidden */
  70816. export var highlightsPixelShader: {
  70817. name: string;
  70818. shader: string;
  70819. };
  70820. }
  70821. declare module BABYLON {
  70822. /**
  70823. * Extracts highlights from the image
  70824. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70825. */
  70826. export class HighlightsPostProcess extends PostProcess {
  70827. /**
  70828. * Gets a string identifying the name of the class
  70829. * @returns "HighlightsPostProcess" string
  70830. */
  70831. getClassName(): string;
  70832. /**
  70833. * Extracts highlights from the image
  70834. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70835. * @param name The name of the effect.
  70836. * @param options The required width/height ratio to downsize to before computing the render pass.
  70837. * @param camera The camera to apply the render pass to.
  70838. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70839. * @param engine The engine which the post process will be applied. (default: current engine)
  70840. * @param reusable If the post process can be reused on the same frame. (default: false)
  70841. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  70842. */
  70843. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70844. }
  70845. }
  70846. declare module BABYLON {
  70847. /**
  70848. * Contains all parameters needed for the prepass to perform
  70849. * motion blur
  70850. */
  70851. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  70852. /**
  70853. * Is motion blur enabled
  70854. */
  70855. enabled: boolean;
  70856. /**
  70857. * Name of the configuration
  70858. */
  70859. name: string;
  70860. /**
  70861. * Textures that should be present in the MRT for this effect to work
  70862. */
  70863. readonly texturesRequired: number[];
  70864. }
  70865. }
  70866. declare module BABYLON {
  70867. interface Scene {
  70868. /** @hidden (Backing field) */
  70869. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70870. /**
  70871. * Gets or Sets the current geometry buffer associated to the scene.
  70872. */
  70873. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70874. /**
  70875. * Enables a GeometryBufferRender and associates it with the scene
  70876. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  70877. * @returns the GeometryBufferRenderer
  70878. */
  70879. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  70880. /**
  70881. * Disables the GeometryBufferRender associated with the scene
  70882. */
  70883. disableGeometryBufferRenderer(): void;
  70884. }
  70885. /**
  70886. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  70887. * in several rendering techniques.
  70888. */
  70889. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  70890. /**
  70891. * The component name helpful to identify the component in the list of scene components.
  70892. */
  70893. readonly name: string;
  70894. /**
  70895. * The scene the component belongs to.
  70896. */
  70897. scene: Scene;
  70898. /**
  70899. * Creates a new instance of the component for the given scene
  70900. * @param scene Defines the scene to register the component in
  70901. */
  70902. constructor(scene: Scene);
  70903. /**
  70904. * Registers the component in a given scene
  70905. */
  70906. register(): void;
  70907. /**
  70908. * Rebuilds the elements related to this component in case of
  70909. * context lost for instance.
  70910. */
  70911. rebuild(): void;
  70912. /**
  70913. * Disposes the component and the associated ressources
  70914. */
  70915. dispose(): void;
  70916. private _gatherRenderTargets;
  70917. }
  70918. }
  70919. declare module BABYLON {
  70920. /** @hidden */
  70921. export var motionBlurPixelShader: {
  70922. name: string;
  70923. shader: string;
  70924. };
  70925. }
  70926. declare module BABYLON {
  70927. /**
  70928. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  70929. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  70930. * As an example, all you have to do is to create the post-process:
  70931. * var mb = new BABYLON.MotionBlurPostProcess(
  70932. * 'mb', // The name of the effect.
  70933. * scene, // The scene containing the objects to blur according to their velocity.
  70934. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  70935. * camera // The camera to apply the render pass to.
  70936. * );
  70937. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  70938. */
  70939. export class MotionBlurPostProcess extends PostProcess {
  70940. /**
  70941. * Defines how much the image is blurred by the movement. Default value is equal to 1
  70942. */
  70943. motionStrength: number;
  70944. /**
  70945. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  70946. */
  70947. get motionBlurSamples(): number;
  70948. /**
  70949. * Sets the number of iterations to be used for motion blur quality
  70950. */
  70951. set motionBlurSamples(samples: number);
  70952. private _motionBlurSamples;
  70953. private _forceGeometryBuffer;
  70954. private _geometryBufferRenderer;
  70955. private _prePassRenderer;
  70956. /**
  70957. * Gets a string identifying the name of the class
  70958. * @returns "MotionBlurPostProcess" string
  70959. */
  70960. getClassName(): string;
  70961. /**
  70962. * Creates a new instance MotionBlurPostProcess
  70963. * @param name The name of the effect.
  70964. * @param scene The scene containing the objects to blur according to their velocity.
  70965. * @param options The required width/height ratio to downsize to before computing the render pass.
  70966. * @param camera The camera to apply the render pass to.
  70967. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70968. * @param engine The engine which the post process will be applied. (default: current engine)
  70969. * @param reusable If the post process can be reused on the same frame. (default: false)
  70970. * @param textureType Type of textures used when performing the post process. (default: 0)
  70971. * @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)
  70972. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  70973. */
  70974. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  70975. /**
  70976. * Excludes the given skinned mesh from computing bones velocities.
  70977. * 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.
  70978. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  70979. */
  70980. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70981. /**
  70982. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  70983. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  70984. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  70985. */
  70986. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70987. /**
  70988. * Disposes the post process.
  70989. * @param camera The camera to dispose the post process on.
  70990. */
  70991. dispose(camera?: Camera): void;
  70992. /** @hidden */
  70993. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  70994. }
  70995. }
  70996. declare module BABYLON {
  70997. /** @hidden */
  70998. export var refractionPixelShader: {
  70999. name: string;
  71000. shader: string;
  71001. };
  71002. }
  71003. declare module BABYLON {
  71004. /**
  71005. * Post process which applies a refractin texture
  71006. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  71007. */
  71008. export class RefractionPostProcess extends PostProcess {
  71009. private _refTexture;
  71010. private _ownRefractionTexture;
  71011. /** the base color of the refraction (used to taint the rendering) */
  71012. color: Color3;
  71013. /** simulated refraction depth */
  71014. depth: number;
  71015. /** the coefficient of the base color (0 to remove base color tainting) */
  71016. colorLevel: number;
  71017. /** Gets the url used to load the refraction texture */
  71018. refractionTextureUrl: string;
  71019. /**
  71020. * Gets or sets the refraction texture
  71021. * Please note that you are responsible for disposing the texture if you set it manually
  71022. */
  71023. get refractionTexture(): Texture;
  71024. set refractionTexture(value: Texture);
  71025. /**
  71026. * Gets a string identifying the name of the class
  71027. * @returns "RefractionPostProcess" string
  71028. */
  71029. getClassName(): string;
  71030. /**
  71031. * Initializes the RefractionPostProcess
  71032. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  71033. * @param name The name of the effect.
  71034. * @param refractionTextureUrl Url of the refraction texture to use
  71035. * @param color the base color of the refraction (used to taint the rendering)
  71036. * @param depth simulated refraction depth
  71037. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  71038. * @param camera The camera to apply the render pass to.
  71039. * @param options The required width/height ratio to downsize to before computing the render pass.
  71040. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71041. * @param engine The engine which the post process will be applied. (default: current engine)
  71042. * @param reusable If the post process can be reused on the same frame. (default: false)
  71043. */
  71044. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71045. /**
  71046. * Disposes of the post process
  71047. * @param camera Camera to dispose post process on
  71048. */
  71049. dispose(camera: Camera): void;
  71050. /** @hidden */
  71051. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  71052. }
  71053. }
  71054. declare module BABYLON {
  71055. /** @hidden */
  71056. export var sharpenPixelShader: {
  71057. name: string;
  71058. shader: string;
  71059. };
  71060. }
  71061. declare module BABYLON {
  71062. /**
  71063. * The SharpenPostProcess applies a sharpen kernel to every pixel
  71064. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  71065. */
  71066. export class SharpenPostProcess extends PostProcess {
  71067. /**
  71068. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  71069. */
  71070. colorAmount: number;
  71071. /**
  71072. * How much sharpness should be applied (default: 0.3)
  71073. */
  71074. edgeAmount: number;
  71075. /**
  71076. * Gets a string identifying the name of the class
  71077. * @returns "SharpenPostProcess" string
  71078. */
  71079. getClassName(): string;
  71080. /**
  71081. * Creates a new instance ConvolutionPostProcess
  71082. * @param name The name of the effect.
  71083. * @param options The required width/height ratio to downsize to before computing the render pass.
  71084. * @param camera The camera to apply the render pass to.
  71085. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71086. * @param engine The engine which the post process will be applied. (default: current engine)
  71087. * @param reusable If the post process can be reused on the same frame. (default: false)
  71088. * @param textureType Type of textures used when performing the post process. (default: 0)
  71089. * @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)
  71090. */
  71091. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71092. /** @hidden */
  71093. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  71094. }
  71095. }
  71096. declare module BABYLON {
  71097. /**
  71098. * PostProcessRenderPipeline
  71099. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71100. */
  71101. export class PostProcessRenderPipeline {
  71102. private engine;
  71103. private _renderEffects;
  71104. private _renderEffectsForIsolatedPass;
  71105. /**
  71106. * List of inspectable custom properties (used by the Inspector)
  71107. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  71108. */
  71109. inspectableCustomProperties: IInspectable[];
  71110. /**
  71111. * @hidden
  71112. */
  71113. protected _cameras: Camera[];
  71114. /** @hidden */
  71115. _name: string;
  71116. /**
  71117. * Gets pipeline name
  71118. */
  71119. get name(): string;
  71120. /** Gets the list of attached cameras */
  71121. get cameras(): Camera[];
  71122. /**
  71123. * Initializes a PostProcessRenderPipeline
  71124. * @param engine engine to add the pipeline to
  71125. * @param name name of the pipeline
  71126. */
  71127. constructor(engine: Engine, name: string);
  71128. /**
  71129. * Gets the class name
  71130. * @returns "PostProcessRenderPipeline"
  71131. */
  71132. getClassName(): string;
  71133. /**
  71134. * If all the render effects in the pipeline are supported
  71135. */
  71136. get isSupported(): boolean;
  71137. /**
  71138. * Adds an effect to the pipeline
  71139. * @param renderEffect the effect to add
  71140. */
  71141. addEffect(renderEffect: PostProcessRenderEffect): void;
  71142. /** @hidden */
  71143. _rebuild(): void;
  71144. /** @hidden */
  71145. _enableEffect(renderEffectName: string, cameras: Camera): void;
  71146. /** @hidden */
  71147. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  71148. /** @hidden */
  71149. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  71150. /** @hidden */
  71151. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  71152. /** @hidden */
  71153. _attachCameras(cameras: Camera, unique: boolean): void;
  71154. /** @hidden */
  71155. _attachCameras(cameras: Camera[], unique: boolean): void;
  71156. /** @hidden */
  71157. _detachCameras(cameras: Camera): void;
  71158. /** @hidden */
  71159. _detachCameras(cameras: Nullable<Camera[]>): void;
  71160. /** @hidden */
  71161. _update(): void;
  71162. /** @hidden */
  71163. _reset(): void;
  71164. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  71165. /**
  71166. * Sets the required values to the prepass renderer.
  71167. * @param prePassRenderer defines the prepass renderer to setup.
  71168. * @returns true if the pre pass is needed.
  71169. */
  71170. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  71171. /**
  71172. * Disposes of the pipeline
  71173. */
  71174. dispose(): void;
  71175. }
  71176. }
  71177. declare module BABYLON {
  71178. /**
  71179. * PostProcessRenderPipelineManager class
  71180. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71181. */
  71182. export class PostProcessRenderPipelineManager {
  71183. private _renderPipelines;
  71184. /**
  71185. * Initializes a PostProcessRenderPipelineManager
  71186. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71187. */
  71188. constructor();
  71189. /**
  71190. * Gets the list of supported render pipelines
  71191. */
  71192. get supportedPipelines(): PostProcessRenderPipeline[];
  71193. /**
  71194. * Adds a pipeline to the manager
  71195. * @param renderPipeline The pipeline to add
  71196. */
  71197. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  71198. /**
  71199. * Attaches a camera to the pipeline
  71200. * @param renderPipelineName The name of the pipeline to attach to
  71201. * @param cameras the camera to attach
  71202. * @param unique if the camera can be attached multiple times to the pipeline
  71203. */
  71204. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  71205. /**
  71206. * Detaches a camera from the pipeline
  71207. * @param renderPipelineName The name of the pipeline to detach from
  71208. * @param cameras the camera to detach
  71209. */
  71210. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  71211. /**
  71212. * Enables an effect by name on a pipeline
  71213. * @param renderPipelineName the name of the pipeline to enable the effect in
  71214. * @param renderEffectName the name of the effect to enable
  71215. * @param cameras the cameras that the effect should be enabled on
  71216. */
  71217. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  71218. /**
  71219. * Disables an effect by name on a pipeline
  71220. * @param renderPipelineName the name of the pipeline to disable the effect in
  71221. * @param renderEffectName the name of the effect to disable
  71222. * @param cameras the cameras that the effect should be disabled on
  71223. */
  71224. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  71225. /**
  71226. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  71227. */
  71228. update(): void;
  71229. /** @hidden */
  71230. _rebuild(): void;
  71231. /**
  71232. * Disposes of the manager and pipelines
  71233. */
  71234. dispose(): void;
  71235. }
  71236. }
  71237. declare module BABYLON {
  71238. interface Scene {
  71239. /** @hidden (Backing field) */
  71240. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  71241. /**
  71242. * Gets the postprocess render pipeline manager
  71243. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71244. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  71245. */
  71246. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  71247. }
  71248. /**
  71249. * Defines the Render Pipeline scene component responsible to rendering pipelines
  71250. */
  71251. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  71252. /**
  71253. * The component name helpfull to identify the component in the list of scene components.
  71254. */
  71255. readonly name: string;
  71256. /**
  71257. * The scene the component belongs to.
  71258. */
  71259. scene: Scene;
  71260. /**
  71261. * Creates a new instance of the component for the given scene
  71262. * @param scene Defines the scene to register the component in
  71263. */
  71264. constructor(scene: Scene);
  71265. /**
  71266. * Registers the component in a given scene
  71267. */
  71268. register(): void;
  71269. /**
  71270. * Rebuilds the elements related to this component in case of
  71271. * context lost for instance.
  71272. */
  71273. rebuild(): void;
  71274. /**
  71275. * Disposes the component and the associated ressources
  71276. */
  71277. dispose(): void;
  71278. private _gatherRenderTargets;
  71279. }
  71280. }
  71281. declare module BABYLON {
  71282. /**
  71283. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  71284. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  71285. */
  71286. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71287. private _scene;
  71288. private _camerasToBeAttached;
  71289. /**
  71290. * ID of the sharpen post process,
  71291. */
  71292. private readonly SharpenPostProcessId;
  71293. /**
  71294. * @ignore
  71295. * ID of the image processing post process;
  71296. */
  71297. readonly ImageProcessingPostProcessId: string;
  71298. /**
  71299. * @ignore
  71300. * ID of the Fast Approximate Anti-Aliasing post process;
  71301. */
  71302. readonly FxaaPostProcessId: string;
  71303. /**
  71304. * ID of the chromatic aberration post process,
  71305. */
  71306. private readonly ChromaticAberrationPostProcessId;
  71307. /**
  71308. * ID of the grain post process
  71309. */
  71310. private readonly GrainPostProcessId;
  71311. /**
  71312. * Sharpen post process which will apply a sharpen convolution to enhance edges
  71313. */
  71314. sharpen: SharpenPostProcess;
  71315. private _sharpenEffect;
  71316. private bloom;
  71317. /**
  71318. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  71319. */
  71320. depthOfField: DepthOfFieldEffect;
  71321. /**
  71322. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71323. */
  71324. fxaa: FxaaPostProcess;
  71325. /**
  71326. * Image post processing pass used to perform operations such as tone mapping or color grading.
  71327. */
  71328. imageProcessing: ImageProcessingPostProcess;
  71329. /**
  71330. * Chromatic aberration post process which will shift rgb colors in the image
  71331. */
  71332. chromaticAberration: ChromaticAberrationPostProcess;
  71333. private _chromaticAberrationEffect;
  71334. /**
  71335. * Grain post process which add noise to the image
  71336. */
  71337. grain: GrainPostProcess;
  71338. private _grainEffect;
  71339. /**
  71340. * Glow post process which adds a glow to emissive areas of the image
  71341. */
  71342. private _glowLayer;
  71343. /**
  71344. * Animations which can be used to tweak settings over a period of time
  71345. */
  71346. animations: Animation[];
  71347. private _imageProcessingConfigurationObserver;
  71348. private _sharpenEnabled;
  71349. private _bloomEnabled;
  71350. private _depthOfFieldEnabled;
  71351. private _depthOfFieldBlurLevel;
  71352. private _fxaaEnabled;
  71353. private _imageProcessingEnabled;
  71354. private _defaultPipelineTextureType;
  71355. private _bloomScale;
  71356. private _chromaticAberrationEnabled;
  71357. private _grainEnabled;
  71358. private _buildAllowed;
  71359. /**
  71360. * Gets active scene
  71361. */
  71362. get scene(): Scene;
  71363. /**
  71364. * Enable or disable the sharpen process from the pipeline
  71365. */
  71366. set sharpenEnabled(enabled: boolean);
  71367. get sharpenEnabled(): boolean;
  71368. private _resizeObserver;
  71369. private _hardwareScaleLevel;
  71370. private _bloomKernel;
  71371. /**
  71372. * Specifies the size of the bloom blur kernel, relative to the final output size
  71373. */
  71374. get bloomKernel(): number;
  71375. set bloomKernel(value: number);
  71376. /**
  71377. * Specifies the weight of the bloom in the final rendering
  71378. */
  71379. private _bloomWeight;
  71380. /**
  71381. * Specifies the luma threshold for the area that will be blurred by the bloom
  71382. */
  71383. private _bloomThreshold;
  71384. private _hdr;
  71385. /**
  71386. * The strength of the bloom.
  71387. */
  71388. set bloomWeight(value: number);
  71389. get bloomWeight(): number;
  71390. /**
  71391. * The strength of the bloom.
  71392. */
  71393. set bloomThreshold(value: number);
  71394. get bloomThreshold(): number;
  71395. /**
  71396. * The scale of the bloom, lower value will provide better performance.
  71397. */
  71398. set bloomScale(value: number);
  71399. get bloomScale(): number;
  71400. /**
  71401. * Enable or disable the bloom from the pipeline
  71402. */
  71403. set bloomEnabled(enabled: boolean);
  71404. get bloomEnabled(): boolean;
  71405. private _rebuildBloom;
  71406. /**
  71407. * If the depth of field is enabled.
  71408. */
  71409. get depthOfFieldEnabled(): boolean;
  71410. set depthOfFieldEnabled(enabled: boolean);
  71411. /**
  71412. * Blur level of the depth of field effect. (Higher blur will effect performance)
  71413. */
  71414. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  71415. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  71416. /**
  71417. * If the anti aliasing is enabled.
  71418. */
  71419. set fxaaEnabled(enabled: boolean);
  71420. get fxaaEnabled(): boolean;
  71421. private _samples;
  71422. /**
  71423. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  71424. */
  71425. set samples(sampleCount: number);
  71426. get samples(): number;
  71427. /**
  71428. * If image processing is enabled.
  71429. */
  71430. set imageProcessingEnabled(enabled: boolean);
  71431. get imageProcessingEnabled(): boolean;
  71432. /**
  71433. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  71434. */
  71435. set glowLayerEnabled(enabled: boolean);
  71436. get glowLayerEnabled(): boolean;
  71437. /**
  71438. * Gets the glow layer (or null if not defined)
  71439. */
  71440. get glowLayer(): Nullable<GlowLayer>;
  71441. /**
  71442. * Enable or disable the chromaticAberration process from the pipeline
  71443. */
  71444. set chromaticAberrationEnabled(enabled: boolean);
  71445. get chromaticAberrationEnabled(): boolean;
  71446. /**
  71447. * Enable or disable the grain process from the pipeline
  71448. */
  71449. set grainEnabled(enabled: boolean);
  71450. get grainEnabled(): boolean;
  71451. /**
  71452. * @constructor
  71453. * @param name - The rendering pipeline name (default: "")
  71454. * @param hdr - If high dynamic range textures should be used (default: true)
  71455. * @param scene - The scene linked to this pipeline (default: the last created scene)
  71456. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  71457. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  71458. */
  71459. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  71460. /**
  71461. * Get the class name
  71462. * @returns "DefaultRenderingPipeline"
  71463. */
  71464. getClassName(): string;
  71465. /**
  71466. * Force the compilation of the entire pipeline.
  71467. */
  71468. prepare(): void;
  71469. private _hasCleared;
  71470. private _prevPostProcess;
  71471. private _prevPrevPostProcess;
  71472. private _setAutoClearAndTextureSharing;
  71473. private _depthOfFieldSceneObserver;
  71474. private _buildPipeline;
  71475. private _disposePostProcesses;
  71476. /**
  71477. * Adds a camera to the pipeline
  71478. * @param camera the camera to be added
  71479. */
  71480. addCamera(camera: Camera): void;
  71481. /**
  71482. * Removes a camera from the pipeline
  71483. * @param camera the camera to remove
  71484. */
  71485. removeCamera(camera: Camera): void;
  71486. /**
  71487. * Dispose of the pipeline and stop all post processes
  71488. */
  71489. dispose(): void;
  71490. /**
  71491. * Serialize the rendering pipeline (Used when exporting)
  71492. * @returns the serialized object
  71493. */
  71494. serialize(): any;
  71495. /**
  71496. * Parse the serialized pipeline
  71497. * @param source Source pipeline.
  71498. * @param scene The scene to load the pipeline to.
  71499. * @param rootUrl The URL of the serialized pipeline.
  71500. * @returns An instantiated pipeline from the serialized object.
  71501. */
  71502. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  71503. }
  71504. }
  71505. declare module BABYLON {
  71506. /** @hidden */
  71507. export var lensHighlightsPixelShader: {
  71508. name: string;
  71509. shader: string;
  71510. };
  71511. }
  71512. declare module BABYLON {
  71513. /** @hidden */
  71514. export var depthOfFieldPixelShader: {
  71515. name: string;
  71516. shader: string;
  71517. };
  71518. }
  71519. declare module BABYLON {
  71520. /**
  71521. * BABYLON.JS Chromatic Aberration GLSL Shader
  71522. * Author: Olivier Guyot
  71523. * Separates very slightly R, G and B colors on the edges of the screen
  71524. * Inspired by Francois Tarlier & Martins Upitis
  71525. */
  71526. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  71527. /**
  71528. * @ignore
  71529. * The chromatic aberration PostProcess id in the pipeline
  71530. */
  71531. LensChromaticAberrationEffect: string;
  71532. /**
  71533. * @ignore
  71534. * The highlights enhancing PostProcess id in the pipeline
  71535. */
  71536. HighlightsEnhancingEffect: string;
  71537. /**
  71538. * @ignore
  71539. * The depth-of-field PostProcess id in the pipeline
  71540. */
  71541. LensDepthOfFieldEffect: string;
  71542. private _scene;
  71543. private _depthTexture;
  71544. private _grainTexture;
  71545. private _chromaticAberrationPostProcess;
  71546. private _highlightsPostProcess;
  71547. private _depthOfFieldPostProcess;
  71548. private _edgeBlur;
  71549. private _grainAmount;
  71550. private _chromaticAberration;
  71551. private _distortion;
  71552. private _highlightsGain;
  71553. private _highlightsThreshold;
  71554. private _dofDistance;
  71555. private _dofAperture;
  71556. private _dofDarken;
  71557. private _dofPentagon;
  71558. private _blurNoise;
  71559. /**
  71560. * @constructor
  71561. *
  71562. * Effect parameters are as follow:
  71563. * {
  71564. * chromatic_aberration: number; // from 0 to x (1 for realism)
  71565. * edge_blur: number; // from 0 to x (1 for realism)
  71566. * distortion: number; // from 0 to x (1 for realism)
  71567. * grain_amount: number; // from 0 to 1
  71568. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  71569. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  71570. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  71571. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  71572. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  71573. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  71574. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  71575. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  71576. * }
  71577. * Note: if an effect parameter is unset, effect is disabled
  71578. *
  71579. * @param name The rendering pipeline name
  71580. * @param parameters - An object containing all parameters (see above)
  71581. * @param scene The scene linked to this pipeline
  71582. * @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)
  71583. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71584. */
  71585. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  71586. /**
  71587. * Get the class name
  71588. * @returns "LensRenderingPipeline"
  71589. */
  71590. getClassName(): string;
  71591. /**
  71592. * Gets associated scene
  71593. */
  71594. get scene(): Scene;
  71595. /**
  71596. * Gets or sets the edge blur
  71597. */
  71598. get edgeBlur(): number;
  71599. set edgeBlur(value: number);
  71600. /**
  71601. * Gets or sets the grain amount
  71602. */
  71603. get grainAmount(): number;
  71604. set grainAmount(value: number);
  71605. /**
  71606. * Gets or sets the chromatic aberration amount
  71607. */
  71608. get chromaticAberration(): number;
  71609. set chromaticAberration(value: number);
  71610. /**
  71611. * Gets or sets the depth of field aperture
  71612. */
  71613. get dofAperture(): number;
  71614. set dofAperture(value: number);
  71615. /**
  71616. * Gets or sets the edge distortion
  71617. */
  71618. get edgeDistortion(): number;
  71619. set edgeDistortion(value: number);
  71620. /**
  71621. * Gets or sets the depth of field distortion
  71622. */
  71623. get dofDistortion(): number;
  71624. set dofDistortion(value: number);
  71625. /**
  71626. * Gets or sets the darken out of focus amount
  71627. */
  71628. get darkenOutOfFocus(): number;
  71629. set darkenOutOfFocus(value: number);
  71630. /**
  71631. * Gets or sets a boolean indicating if blur noise is enabled
  71632. */
  71633. get blurNoise(): boolean;
  71634. set blurNoise(value: boolean);
  71635. /**
  71636. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  71637. */
  71638. get pentagonBokeh(): boolean;
  71639. set pentagonBokeh(value: boolean);
  71640. /**
  71641. * Gets or sets the highlight grain amount
  71642. */
  71643. get highlightsGain(): number;
  71644. set highlightsGain(value: number);
  71645. /**
  71646. * Gets or sets the highlight threshold
  71647. */
  71648. get highlightsThreshold(): number;
  71649. set highlightsThreshold(value: number);
  71650. /**
  71651. * Sets the amount of blur at the edges
  71652. * @param amount blur amount
  71653. */
  71654. setEdgeBlur(amount: number): void;
  71655. /**
  71656. * Sets edge blur to 0
  71657. */
  71658. disableEdgeBlur(): void;
  71659. /**
  71660. * Sets the amout of grain
  71661. * @param amount Amount of grain
  71662. */
  71663. setGrainAmount(amount: number): void;
  71664. /**
  71665. * Set grain amount to 0
  71666. */
  71667. disableGrain(): void;
  71668. /**
  71669. * Sets the chromatic aberration amount
  71670. * @param amount amount of chromatic aberration
  71671. */
  71672. setChromaticAberration(amount: number): void;
  71673. /**
  71674. * Sets chromatic aberration amount to 0
  71675. */
  71676. disableChromaticAberration(): void;
  71677. /**
  71678. * Sets the EdgeDistortion amount
  71679. * @param amount amount of EdgeDistortion
  71680. */
  71681. setEdgeDistortion(amount: number): void;
  71682. /**
  71683. * Sets edge distortion to 0
  71684. */
  71685. disableEdgeDistortion(): void;
  71686. /**
  71687. * Sets the FocusDistance amount
  71688. * @param amount amount of FocusDistance
  71689. */
  71690. setFocusDistance(amount: number): void;
  71691. /**
  71692. * Disables depth of field
  71693. */
  71694. disableDepthOfField(): void;
  71695. /**
  71696. * Sets the Aperture amount
  71697. * @param amount amount of Aperture
  71698. */
  71699. setAperture(amount: number): void;
  71700. /**
  71701. * Sets the DarkenOutOfFocus amount
  71702. * @param amount amount of DarkenOutOfFocus
  71703. */
  71704. setDarkenOutOfFocus(amount: number): void;
  71705. private _pentagonBokehIsEnabled;
  71706. /**
  71707. * Creates a pentagon bokeh effect
  71708. */
  71709. enablePentagonBokeh(): void;
  71710. /**
  71711. * Disables the pentagon bokeh effect
  71712. */
  71713. disablePentagonBokeh(): void;
  71714. /**
  71715. * Enables noise blur
  71716. */
  71717. enableNoiseBlur(): void;
  71718. /**
  71719. * Disables noise blur
  71720. */
  71721. disableNoiseBlur(): void;
  71722. /**
  71723. * Sets the HighlightsGain amount
  71724. * @param amount amount of HighlightsGain
  71725. */
  71726. setHighlightsGain(amount: number): void;
  71727. /**
  71728. * Sets the HighlightsThreshold amount
  71729. * @param amount amount of HighlightsThreshold
  71730. */
  71731. setHighlightsThreshold(amount: number): void;
  71732. /**
  71733. * Disables highlights
  71734. */
  71735. disableHighlights(): void;
  71736. /**
  71737. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  71738. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  71739. */
  71740. dispose(disableDepthRender?: boolean): void;
  71741. private _createChromaticAberrationPostProcess;
  71742. private _createHighlightsPostProcess;
  71743. private _createDepthOfFieldPostProcess;
  71744. private _createGrainTexture;
  71745. }
  71746. }
  71747. declare module BABYLON {
  71748. /**
  71749. * Contains all parameters needed for the prepass to perform
  71750. * screen space subsurface scattering
  71751. */
  71752. export class SSAO2Configuration implements PrePassEffectConfiguration {
  71753. /**
  71754. * Is subsurface enabled
  71755. */
  71756. enabled: boolean;
  71757. /**
  71758. * Name of the configuration
  71759. */
  71760. name: string;
  71761. /**
  71762. * Textures that should be present in the MRT for this effect to work
  71763. */
  71764. readonly texturesRequired: number[];
  71765. }
  71766. }
  71767. declare module BABYLON {
  71768. /** @hidden */
  71769. export var ssao2PixelShader: {
  71770. name: string;
  71771. shader: string;
  71772. };
  71773. }
  71774. declare module BABYLON {
  71775. /** @hidden */
  71776. export var ssaoCombinePixelShader: {
  71777. name: string;
  71778. shader: string;
  71779. };
  71780. }
  71781. declare module BABYLON {
  71782. /**
  71783. * Render pipeline to produce ssao effect
  71784. */
  71785. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  71786. /**
  71787. * @ignore
  71788. * The PassPostProcess id in the pipeline that contains the original scene color
  71789. */
  71790. SSAOOriginalSceneColorEffect: string;
  71791. /**
  71792. * @ignore
  71793. * The SSAO PostProcess id in the pipeline
  71794. */
  71795. SSAORenderEffect: string;
  71796. /**
  71797. * @ignore
  71798. * The horizontal blur PostProcess id in the pipeline
  71799. */
  71800. SSAOBlurHRenderEffect: string;
  71801. /**
  71802. * @ignore
  71803. * The vertical blur PostProcess id in the pipeline
  71804. */
  71805. SSAOBlurVRenderEffect: string;
  71806. /**
  71807. * @ignore
  71808. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71809. */
  71810. SSAOCombineRenderEffect: string;
  71811. /**
  71812. * The output strength of the SSAO post-process. Default value is 1.0.
  71813. */
  71814. totalStrength: number;
  71815. /**
  71816. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  71817. */
  71818. maxZ: number;
  71819. /**
  71820. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  71821. */
  71822. minZAspect: number;
  71823. private _samples;
  71824. /**
  71825. * Number of samples used for the SSAO calculations. Default value is 8
  71826. */
  71827. set samples(n: number);
  71828. get samples(): number;
  71829. private _textureSamples;
  71830. /**
  71831. * Number of samples to use for antialiasing
  71832. */
  71833. set textureSamples(n: number);
  71834. get textureSamples(): number;
  71835. /**
  71836. * Force rendering the geometry through geometry buffer
  71837. */
  71838. private _forceGeometryBuffer;
  71839. /**
  71840. * Ratio object used for SSAO ratio and blur ratio
  71841. */
  71842. private _ratio;
  71843. /**
  71844. * Dynamically generated sphere sampler.
  71845. */
  71846. private _sampleSphere;
  71847. /**
  71848. * Blur filter offsets
  71849. */
  71850. private _samplerOffsets;
  71851. private _expensiveBlur;
  71852. /**
  71853. * If bilateral blur should be used
  71854. */
  71855. set expensiveBlur(b: boolean);
  71856. get expensiveBlur(): boolean;
  71857. /**
  71858. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  71859. */
  71860. radius: number;
  71861. /**
  71862. * The base color of the SSAO post-process
  71863. * The final result is "base + ssao" between [0, 1]
  71864. */
  71865. base: number;
  71866. /**
  71867. * Support test.
  71868. */
  71869. static get IsSupported(): boolean;
  71870. private _scene;
  71871. private _randomTexture;
  71872. private _originalColorPostProcess;
  71873. private _ssaoPostProcess;
  71874. private _blurHPostProcess;
  71875. private _blurVPostProcess;
  71876. private _ssaoCombinePostProcess;
  71877. private _prePassRenderer;
  71878. /**
  71879. * Gets active scene
  71880. */
  71881. get scene(): Scene;
  71882. /**
  71883. * @constructor
  71884. * @param name The rendering pipeline name
  71885. * @param scene The scene linked to this pipeline
  71886. * @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 }
  71887. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71888. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  71889. */
  71890. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  71891. /**
  71892. * Get the class name
  71893. * @returns "SSAO2RenderingPipeline"
  71894. */
  71895. getClassName(): string;
  71896. /**
  71897. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71898. */
  71899. dispose(disableGeometryBufferRenderer?: boolean): void;
  71900. private _createBlurPostProcess;
  71901. /** @hidden */
  71902. _rebuild(): void;
  71903. private _bits;
  71904. private _radicalInverse_VdC;
  71905. private _hammersley;
  71906. private _hemisphereSample_uniform;
  71907. private _generateHemisphere;
  71908. private _getDefinesForSSAO;
  71909. private _createSSAOPostProcess;
  71910. private _createSSAOCombinePostProcess;
  71911. private _createRandomTexture;
  71912. /**
  71913. * Serialize the rendering pipeline (Used when exporting)
  71914. * @returns the serialized object
  71915. */
  71916. serialize(): any;
  71917. /**
  71918. * Parse the serialized pipeline
  71919. * @param source Source pipeline.
  71920. * @param scene The scene to load the pipeline to.
  71921. * @param rootUrl The URL of the serialized pipeline.
  71922. * @returns An instantiated pipeline from the serialized object.
  71923. */
  71924. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  71925. }
  71926. }
  71927. declare module BABYLON {
  71928. /** @hidden */
  71929. export var ssaoPixelShader: {
  71930. name: string;
  71931. shader: string;
  71932. };
  71933. }
  71934. declare module BABYLON {
  71935. /**
  71936. * Render pipeline to produce ssao effect
  71937. */
  71938. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  71939. /**
  71940. * @ignore
  71941. * The PassPostProcess id in the pipeline that contains the original scene color
  71942. */
  71943. SSAOOriginalSceneColorEffect: string;
  71944. /**
  71945. * @ignore
  71946. * The SSAO PostProcess id in the pipeline
  71947. */
  71948. SSAORenderEffect: string;
  71949. /**
  71950. * @ignore
  71951. * The horizontal blur PostProcess id in the pipeline
  71952. */
  71953. SSAOBlurHRenderEffect: string;
  71954. /**
  71955. * @ignore
  71956. * The vertical blur PostProcess id in the pipeline
  71957. */
  71958. SSAOBlurVRenderEffect: string;
  71959. /**
  71960. * @ignore
  71961. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71962. */
  71963. SSAOCombineRenderEffect: string;
  71964. /**
  71965. * The output strength of the SSAO post-process. Default value is 1.0.
  71966. */
  71967. totalStrength: number;
  71968. /**
  71969. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  71970. */
  71971. radius: number;
  71972. /**
  71973. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  71974. * Must not be equal to fallOff and superior to fallOff.
  71975. * Default value is 0.0075
  71976. */
  71977. area: number;
  71978. /**
  71979. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  71980. * Must not be equal to area and inferior to area.
  71981. * Default value is 0.000001
  71982. */
  71983. fallOff: number;
  71984. /**
  71985. * The base color of the SSAO post-process
  71986. * The final result is "base + ssao" between [0, 1]
  71987. */
  71988. base: number;
  71989. private _scene;
  71990. private _depthTexture;
  71991. private _randomTexture;
  71992. private _originalColorPostProcess;
  71993. private _ssaoPostProcess;
  71994. private _blurHPostProcess;
  71995. private _blurVPostProcess;
  71996. private _ssaoCombinePostProcess;
  71997. private _firstUpdate;
  71998. /**
  71999. * Gets active scene
  72000. */
  72001. get scene(): Scene;
  72002. /**
  72003. * @constructor
  72004. * @param name - The rendering pipeline name
  72005. * @param scene - The scene linked to this pipeline
  72006. * @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 }
  72007. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  72008. */
  72009. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  72010. /**
  72011. * Get the class name
  72012. * @returns "SSAORenderingPipeline"
  72013. */
  72014. getClassName(): string;
  72015. /**
  72016. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  72017. */
  72018. dispose(disableDepthRender?: boolean): void;
  72019. private _createBlurPostProcess;
  72020. /** @hidden */
  72021. _rebuild(): void;
  72022. private _createSSAOPostProcess;
  72023. private _createSSAOCombinePostProcess;
  72024. private _createRandomTexture;
  72025. }
  72026. }
  72027. declare module BABYLON {
  72028. /**
  72029. * Contains all parameters needed for the prepass to perform
  72030. * screen space reflections
  72031. */
  72032. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  72033. /**
  72034. * Is ssr enabled
  72035. */
  72036. enabled: boolean;
  72037. /**
  72038. * Name of the configuration
  72039. */
  72040. name: string;
  72041. /**
  72042. * Textures that should be present in the MRT for this effect to work
  72043. */
  72044. readonly texturesRequired: number[];
  72045. }
  72046. }
  72047. declare module BABYLON {
  72048. /** @hidden */
  72049. export var screenSpaceReflectionPixelShader: {
  72050. name: string;
  72051. shader: string;
  72052. };
  72053. }
  72054. declare module BABYLON {
  72055. /**
  72056. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  72057. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  72058. */
  72059. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  72060. /**
  72061. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  72062. */
  72063. threshold: number;
  72064. /**
  72065. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  72066. */
  72067. strength: number;
  72068. /**
  72069. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  72070. */
  72071. reflectionSpecularFalloffExponent: number;
  72072. /**
  72073. * 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]
  72074. */
  72075. step: number;
  72076. /**
  72077. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  72078. */
  72079. roughnessFactor: number;
  72080. private _forceGeometryBuffer;
  72081. private _geometryBufferRenderer;
  72082. private _prePassRenderer;
  72083. private _enableSmoothReflections;
  72084. private _reflectionSamples;
  72085. private _smoothSteps;
  72086. /**
  72087. * Gets a string identifying the name of the class
  72088. * @returns "ScreenSpaceReflectionPostProcess" string
  72089. */
  72090. getClassName(): string;
  72091. /**
  72092. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  72093. * @param name The name of the effect.
  72094. * @param scene The scene containing the objects to calculate reflections.
  72095. * @param options The required width/height ratio to downsize to before computing the render pass.
  72096. * @param camera The camera to apply the render pass to.
  72097. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72098. * @param engine The engine which the post process will be applied. (default: current engine)
  72099. * @param reusable If the post process can be reused on the same frame. (default: false)
  72100. * @param textureType Type of textures used when performing the post process. (default: 0)
  72101. * @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)
  72102. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  72103. */
  72104. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  72105. /**
  72106. * Gets wether or not smoothing reflections is enabled.
  72107. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  72108. */
  72109. get enableSmoothReflections(): boolean;
  72110. /**
  72111. * Sets wether or not smoothing reflections is enabled.
  72112. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  72113. */
  72114. set enableSmoothReflections(enabled: boolean);
  72115. /**
  72116. * Gets the number of samples taken while computing reflections. More samples count is high,
  72117. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  72118. */
  72119. get reflectionSamples(): number;
  72120. /**
  72121. * Sets the number of samples taken while computing reflections. More samples count is high,
  72122. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  72123. */
  72124. set reflectionSamples(samples: number);
  72125. /**
  72126. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  72127. * more the post-process will require GPU power and can generate a drop in FPS.
  72128. * Default value (5.0) work pretty well in all cases but can be adjusted.
  72129. */
  72130. get smoothSteps(): number;
  72131. set smoothSteps(steps: number);
  72132. private _updateEffectDefines;
  72133. /** @hidden */
  72134. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  72135. }
  72136. }
  72137. declare module BABYLON {
  72138. /** @hidden */
  72139. export var standardPixelShader: {
  72140. name: string;
  72141. shader: string;
  72142. };
  72143. }
  72144. declare module BABYLON {
  72145. /**
  72146. * Standard rendering pipeline
  72147. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  72148. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  72149. */
  72150. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  72151. /**
  72152. * Public members
  72153. */
  72154. /**
  72155. * Post-process which contains the original scene color before the pipeline applies all the effects
  72156. */
  72157. originalPostProcess: Nullable<PostProcess>;
  72158. /**
  72159. * Post-process used to down scale an image x4
  72160. */
  72161. downSampleX4PostProcess: Nullable<PostProcess>;
  72162. /**
  72163. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  72164. */
  72165. brightPassPostProcess: Nullable<PostProcess>;
  72166. /**
  72167. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  72168. */
  72169. blurHPostProcesses: PostProcess[];
  72170. /**
  72171. * Post-process array storing all the vertical blur post-processes used by the pipeline
  72172. */
  72173. blurVPostProcesses: PostProcess[];
  72174. /**
  72175. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  72176. */
  72177. textureAdderPostProcess: Nullable<PostProcess>;
  72178. /**
  72179. * Post-process used to create volumetric lighting effect
  72180. */
  72181. volumetricLightPostProcess: Nullable<PostProcess>;
  72182. /**
  72183. * Post-process used to smooth the previous volumetric light post-process on the X axis
  72184. */
  72185. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  72186. /**
  72187. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  72188. */
  72189. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  72190. /**
  72191. * Post-process used to merge the volumetric light effect and the real scene color
  72192. */
  72193. volumetricLightMergePostProces: Nullable<PostProcess>;
  72194. /**
  72195. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  72196. */
  72197. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  72198. /**
  72199. * Base post-process used to calculate the average luminance of the final image for HDR
  72200. */
  72201. luminancePostProcess: Nullable<PostProcess>;
  72202. /**
  72203. * Post-processes used to create down sample post-processes in order to get
  72204. * the average luminance of the final image for HDR
  72205. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  72206. */
  72207. luminanceDownSamplePostProcesses: PostProcess[];
  72208. /**
  72209. * Post-process used to create a HDR effect (light adaptation)
  72210. */
  72211. hdrPostProcess: Nullable<PostProcess>;
  72212. /**
  72213. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  72214. */
  72215. textureAdderFinalPostProcess: Nullable<PostProcess>;
  72216. /**
  72217. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  72218. */
  72219. lensFlareFinalPostProcess: Nullable<PostProcess>;
  72220. /**
  72221. * Post-process used to merge the final HDR post-process and the real scene color
  72222. */
  72223. hdrFinalPostProcess: Nullable<PostProcess>;
  72224. /**
  72225. * Post-process used to create a lens flare effect
  72226. */
  72227. lensFlarePostProcess: Nullable<PostProcess>;
  72228. /**
  72229. * Post-process that merges the result of the lens flare post-process and the real scene color
  72230. */
  72231. lensFlareComposePostProcess: Nullable<PostProcess>;
  72232. /**
  72233. * Post-process used to create a motion blur effect
  72234. */
  72235. motionBlurPostProcess: Nullable<PostProcess>;
  72236. /**
  72237. * Post-process used to create a depth of field effect
  72238. */
  72239. depthOfFieldPostProcess: Nullable<PostProcess>;
  72240. /**
  72241. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  72242. */
  72243. fxaaPostProcess: Nullable<FxaaPostProcess>;
  72244. /**
  72245. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  72246. */
  72247. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  72248. /**
  72249. * Represents the brightness threshold in order to configure the illuminated surfaces
  72250. */
  72251. brightThreshold: number;
  72252. /**
  72253. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  72254. */
  72255. blurWidth: number;
  72256. /**
  72257. * Sets if the blur for highlighted surfaces must be only horizontal
  72258. */
  72259. horizontalBlur: boolean;
  72260. /**
  72261. * Gets the overall exposure used by the pipeline
  72262. */
  72263. get exposure(): number;
  72264. /**
  72265. * Sets the overall exposure used by the pipeline
  72266. */
  72267. set exposure(value: number);
  72268. /**
  72269. * Texture used typically to simulate "dirty" on camera lens
  72270. */
  72271. lensTexture: Nullable<Texture>;
  72272. /**
  72273. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  72274. */
  72275. volumetricLightCoefficient: number;
  72276. /**
  72277. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  72278. */
  72279. volumetricLightPower: number;
  72280. /**
  72281. * Used the set the blur intensity to smooth the volumetric lights
  72282. */
  72283. volumetricLightBlurScale: number;
  72284. /**
  72285. * Light (spot or directional) used to generate the volumetric lights rays
  72286. * The source light must have a shadow generate so the pipeline can get its
  72287. * depth map
  72288. */
  72289. sourceLight: Nullable<SpotLight | DirectionalLight>;
  72290. /**
  72291. * For eye adaptation, represents the minimum luminance the eye can see
  72292. */
  72293. hdrMinimumLuminance: number;
  72294. /**
  72295. * For eye adaptation, represents the decrease luminance speed
  72296. */
  72297. hdrDecreaseRate: number;
  72298. /**
  72299. * For eye adaptation, represents the increase luminance speed
  72300. */
  72301. hdrIncreaseRate: number;
  72302. /**
  72303. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  72304. */
  72305. get hdrAutoExposure(): boolean;
  72306. /**
  72307. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  72308. */
  72309. set hdrAutoExposure(value: boolean);
  72310. /**
  72311. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  72312. */
  72313. lensColorTexture: Nullable<Texture>;
  72314. /**
  72315. * The overall strengh for the lens flare effect
  72316. */
  72317. lensFlareStrength: number;
  72318. /**
  72319. * Dispersion coefficient for lens flare ghosts
  72320. */
  72321. lensFlareGhostDispersal: number;
  72322. /**
  72323. * Main lens flare halo width
  72324. */
  72325. lensFlareHaloWidth: number;
  72326. /**
  72327. * Based on the lens distortion effect, defines how much the lens flare result
  72328. * is distorted
  72329. */
  72330. lensFlareDistortionStrength: number;
  72331. /**
  72332. * Configures the blur intensity used for for lens flare (halo)
  72333. */
  72334. lensFlareBlurWidth: number;
  72335. /**
  72336. * Lens star texture must be used to simulate rays on the flares and is available
  72337. * in the documentation
  72338. */
  72339. lensStarTexture: Nullable<Texture>;
  72340. /**
  72341. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  72342. * flare effect by taking account of the dirt texture
  72343. */
  72344. lensFlareDirtTexture: Nullable<Texture>;
  72345. /**
  72346. * Represents the focal length for the depth of field effect
  72347. */
  72348. depthOfFieldDistance: number;
  72349. /**
  72350. * Represents the blur intensity for the blurred part of the depth of field effect
  72351. */
  72352. depthOfFieldBlurWidth: number;
  72353. /**
  72354. * Gets how much the image is blurred by the movement while using the motion blur post-process
  72355. */
  72356. get motionStrength(): number;
  72357. /**
  72358. * Sets how much the image is blurred by the movement while using the motion blur post-process
  72359. */
  72360. set motionStrength(strength: number);
  72361. /**
  72362. * Gets wether or not the motion blur post-process is object based or screen based.
  72363. */
  72364. get objectBasedMotionBlur(): boolean;
  72365. /**
  72366. * Sets wether or not the motion blur post-process should be object based or screen based
  72367. */
  72368. set objectBasedMotionBlur(value: boolean);
  72369. /**
  72370. * List of animations for the pipeline (IAnimatable implementation)
  72371. */
  72372. animations: Animation[];
  72373. /**
  72374. * Private members
  72375. */
  72376. private _scene;
  72377. private _currentDepthOfFieldSource;
  72378. private _basePostProcess;
  72379. private _fixedExposure;
  72380. private _currentExposure;
  72381. private _hdrAutoExposure;
  72382. private _hdrCurrentLuminance;
  72383. private _motionStrength;
  72384. private _isObjectBasedMotionBlur;
  72385. private _floatTextureType;
  72386. private _camerasToBeAttached;
  72387. private _ratio;
  72388. private _bloomEnabled;
  72389. private _depthOfFieldEnabled;
  72390. private _vlsEnabled;
  72391. private _lensFlareEnabled;
  72392. private _hdrEnabled;
  72393. private _motionBlurEnabled;
  72394. private _fxaaEnabled;
  72395. private _screenSpaceReflectionsEnabled;
  72396. private _motionBlurSamples;
  72397. private _volumetricLightStepsCount;
  72398. private _samples;
  72399. /**
  72400. * @ignore
  72401. * Specifies if the bloom pipeline is enabled
  72402. */
  72403. get BloomEnabled(): boolean;
  72404. set BloomEnabled(enabled: boolean);
  72405. /**
  72406. * @ignore
  72407. * Specifies if the depth of field pipeline is enabed
  72408. */
  72409. get DepthOfFieldEnabled(): boolean;
  72410. set DepthOfFieldEnabled(enabled: boolean);
  72411. /**
  72412. * @ignore
  72413. * Specifies if the lens flare pipeline is enabed
  72414. */
  72415. get LensFlareEnabled(): boolean;
  72416. set LensFlareEnabled(enabled: boolean);
  72417. /**
  72418. * @ignore
  72419. * Specifies if the HDR pipeline is enabled
  72420. */
  72421. get HDREnabled(): boolean;
  72422. set HDREnabled(enabled: boolean);
  72423. /**
  72424. * @ignore
  72425. * Specifies if the volumetric lights scattering effect is enabled
  72426. */
  72427. get VLSEnabled(): boolean;
  72428. set VLSEnabled(enabled: boolean);
  72429. /**
  72430. * @ignore
  72431. * Specifies if the motion blur effect is enabled
  72432. */
  72433. get MotionBlurEnabled(): boolean;
  72434. set MotionBlurEnabled(enabled: boolean);
  72435. /**
  72436. * Specifies if anti-aliasing is enabled
  72437. */
  72438. get fxaaEnabled(): boolean;
  72439. set fxaaEnabled(enabled: boolean);
  72440. /**
  72441. * Specifies if screen space reflections are enabled.
  72442. */
  72443. get screenSpaceReflectionsEnabled(): boolean;
  72444. set screenSpaceReflectionsEnabled(enabled: boolean);
  72445. /**
  72446. * Specifies the number of steps used to calculate the volumetric lights
  72447. * Typically in interval [50, 200]
  72448. */
  72449. get volumetricLightStepsCount(): number;
  72450. set volumetricLightStepsCount(count: number);
  72451. /**
  72452. * Specifies the number of samples used for the motion blur effect
  72453. * Typically in interval [16, 64]
  72454. */
  72455. get motionBlurSamples(): number;
  72456. set motionBlurSamples(samples: number);
  72457. /**
  72458. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  72459. */
  72460. get samples(): number;
  72461. set samples(sampleCount: number);
  72462. /**
  72463. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  72464. * @constructor
  72465. * @param name The rendering pipeline name
  72466. * @param scene The scene linked to this pipeline
  72467. * @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)
  72468. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  72469. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72470. */
  72471. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  72472. private _buildPipeline;
  72473. private _createDownSampleX4PostProcess;
  72474. private _createBrightPassPostProcess;
  72475. private _createBlurPostProcesses;
  72476. private _createTextureAdderPostProcess;
  72477. private _createVolumetricLightPostProcess;
  72478. private _createLuminancePostProcesses;
  72479. private _createHdrPostProcess;
  72480. private _createLensFlarePostProcess;
  72481. private _createDepthOfFieldPostProcess;
  72482. private _createMotionBlurPostProcess;
  72483. private _getDepthTexture;
  72484. private _disposePostProcesses;
  72485. /**
  72486. * Dispose of the pipeline and stop all post processes
  72487. */
  72488. dispose(): void;
  72489. /**
  72490. * Serialize the rendering pipeline (Used when exporting)
  72491. * @returns the serialized object
  72492. */
  72493. serialize(): any;
  72494. /**
  72495. * Parse the serialized pipeline
  72496. * @param source Source pipeline.
  72497. * @param scene The scene to load the pipeline to.
  72498. * @param rootUrl The URL of the serialized pipeline.
  72499. * @returns An instantiated pipeline from the serialized object.
  72500. */
  72501. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  72502. /**
  72503. * Luminance steps
  72504. */
  72505. static LuminanceSteps: number;
  72506. }
  72507. }
  72508. declare module BABYLON {
  72509. /** @hidden */
  72510. export var stereoscopicInterlacePixelShader: {
  72511. name: string;
  72512. shader: string;
  72513. };
  72514. }
  72515. declare module BABYLON {
  72516. /**
  72517. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  72518. */
  72519. export class StereoscopicInterlacePostProcessI extends PostProcess {
  72520. private _stepSize;
  72521. private _passedProcess;
  72522. /**
  72523. * Gets a string identifying the name of the class
  72524. * @returns "StereoscopicInterlacePostProcessI" string
  72525. */
  72526. getClassName(): string;
  72527. /**
  72528. * Initializes a StereoscopicInterlacePostProcessI
  72529. * @param name The name of the effect.
  72530. * @param rigCameras The rig cameras to be appled to the post process
  72531. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  72532. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  72533. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72534. * @param engine The engine which the post process will be applied. (default: current engine)
  72535. * @param reusable If the post process can be reused on the same frame. (default: false)
  72536. */
  72537. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72538. }
  72539. /**
  72540. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  72541. */
  72542. export class StereoscopicInterlacePostProcess extends PostProcess {
  72543. private _stepSize;
  72544. private _passedProcess;
  72545. /**
  72546. * Gets a string identifying the name of the class
  72547. * @returns "StereoscopicInterlacePostProcess" string
  72548. */
  72549. getClassName(): string;
  72550. /**
  72551. * Initializes a StereoscopicInterlacePostProcess
  72552. * @param name The name of the effect.
  72553. * @param rigCameras The rig cameras to be appled to the post process
  72554. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  72555. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72556. * @param engine The engine which the post process will be applied. (default: current engine)
  72557. * @param reusable If the post process can be reused on the same frame. (default: false)
  72558. */
  72559. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72560. }
  72561. }
  72562. declare module BABYLON {
  72563. /** @hidden */
  72564. export var tonemapPixelShader: {
  72565. name: string;
  72566. shader: string;
  72567. };
  72568. }
  72569. declare module BABYLON {
  72570. /** Defines operator used for tonemapping */
  72571. export enum TonemappingOperator {
  72572. /** Hable */
  72573. Hable = 0,
  72574. /** Reinhard */
  72575. Reinhard = 1,
  72576. /** HejiDawson */
  72577. HejiDawson = 2,
  72578. /** Photographic */
  72579. Photographic = 3
  72580. }
  72581. /**
  72582. * Defines a post process to apply tone mapping
  72583. */
  72584. export class TonemapPostProcess extends PostProcess {
  72585. private _operator;
  72586. /** Defines the required exposure adjustement */
  72587. exposureAdjustment: number;
  72588. /**
  72589. * Gets a string identifying the name of the class
  72590. * @returns "TonemapPostProcess" string
  72591. */
  72592. getClassName(): string;
  72593. /**
  72594. * Creates a new TonemapPostProcess
  72595. * @param name defines the name of the postprocess
  72596. * @param _operator defines the operator to use
  72597. * @param exposureAdjustment defines the required exposure adjustement
  72598. * @param camera defines the camera to use (can be null)
  72599. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  72600. * @param engine defines the hosting engine (can be ignore if camera is set)
  72601. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72602. */
  72603. constructor(name: string, _operator: TonemappingOperator,
  72604. /** Defines the required exposure adjustement */
  72605. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  72606. }
  72607. }
  72608. declare module BABYLON {
  72609. /** @hidden */
  72610. export var volumetricLightScatteringPixelShader: {
  72611. name: string;
  72612. shader: string;
  72613. };
  72614. }
  72615. declare module BABYLON {
  72616. /** @hidden */
  72617. export var volumetricLightScatteringPassVertexShader: {
  72618. name: string;
  72619. shader: string;
  72620. };
  72621. }
  72622. declare module BABYLON {
  72623. /** @hidden */
  72624. export var volumetricLightScatteringPassPixelShader: {
  72625. name: string;
  72626. shader: string;
  72627. };
  72628. }
  72629. declare module BABYLON {
  72630. /**
  72631. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  72632. */
  72633. export class VolumetricLightScatteringPostProcess extends PostProcess {
  72634. private _volumetricLightScatteringPass;
  72635. private _volumetricLightScatteringRTT;
  72636. private _viewPort;
  72637. private _screenCoordinates;
  72638. private _cachedDefines;
  72639. /**
  72640. * If not undefined, the mesh position is computed from the attached node position
  72641. */
  72642. attachedNode: {
  72643. position: Vector3;
  72644. };
  72645. /**
  72646. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  72647. */
  72648. customMeshPosition: Vector3;
  72649. /**
  72650. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  72651. */
  72652. useCustomMeshPosition: boolean;
  72653. /**
  72654. * If the post-process should inverse the light scattering direction
  72655. */
  72656. invert: boolean;
  72657. /**
  72658. * The internal mesh used by the post-process
  72659. */
  72660. mesh: Mesh;
  72661. /**
  72662. * @hidden
  72663. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  72664. */
  72665. get useDiffuseColor(): boolean;
  72666. set useDiffuseColor(useDiffuseColor: boolean);
  72667. /**
  72668. * Array containing the excluded meshes not rendered in the internal pass
  72669. */
  72670. excludedMeshes: AbstractMesh[];
  72671. /**
  72672. * Controls the overall intensity of the post-process
  72673. */
  72674. exposure: number;
  72675. /**
  72676. * Dissipates each sample's contribution in range [0, 1]
  72677. */
  72678. decay: number;
  72679. /**
  72680. * Controls the overall intensity of each sample
  72681. */
  72682. weight: number;
  72683. /**
  72684. * Controls the density of each sample
  72685. */
  72686. density: number;
  72687. /**
  72688. * @constructor
  72689. * @param name The post-process name
  72690. * @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)
  72691. * @param camera The camera that the post-process will be attached to
  72692. * @param mesh The mesh used to create the light scattering
  72693. * @param samples The post-process quality, default 100
  72694. * @param samplingModeThe post-process filtering mode
  72695. * @param engine The babylon engine
  72696. * @param reusable If the post-process is reusable
  72697. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  72698. */
  72699. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  72700. /**
  72701. * Returns the string "VolumetricLightScatteringPostProcess"
  72702. * @returns "VolumetricLightScatteringPostProcess"
  72703. */
  72704. getClassName(): string;
  72705. private _isReady;
  72706. /**
  72707. * Sets the new light position for light scattering effect
  72708. * @param position The new custom light position
  72709. */
  72710. setCustomMeshPosition(position: Vector3): void;
  72711. /**
  72712. * Returns the light position for light scattering effect
  72713. * @return Vector3 The custom light position
  72714. */
  72715. getCustomMeshPosition(): Vector3;
  72716. /**
  72717. * Disposes the internal assets and detaches the post-process from the camera
  72718. */
  72719. dispose(camera: Camera): void;
  72720. /**
  72721. * Returns the render target texture used by the post-process
  72722. * @return the render target texture used by the post-process
  72723. */
  72724. getPass(): RenderTargetTexture;
  72725. private _meshExcluded;
  72726. private _createPass;
  72727. private _updateMeshScreenCoordinates;
  72728. /**
  72729. * Creates a default mesh for the Volumeric Light Scattering post-process
  72730. * @param name The mesh name
  72731. * @param scene The scene where to create the mesh
  72732. * @return the default mesh
  72733. */
  72734. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  72735. }
  72736. }
  72737. declare module BABYLON {
  72738. /** @hidden */
  72739. export var screenSpaceCurvaturePixelShader: {
  72740. name: string;
  72741. shader: string;
  72742. };
  72743. }
  72744. declare module BABYLON {
  72745. /**
  72746. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  72747. */
  72748. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  72749. /**
  72750. * Defines how much ridge the curvature effect displays.
  72751. */
  72752. ridge: number;
  72753. /**
  72754. * Defines how much valley the curvature effect displays.
  72755. */
  72756. valley: number;
  72757. private _geometryBufferRenderer;
  72758. /**
  72759. * Gets a string identifying the name of the class
  72760. * @returns "ScreenSpaceCurvaturePostProcess" string
  72761. */
  72762. getClassName(): string;
  72763. /**
  72764. * Creates a new instance ScreenSpaceCurvaturePostProcess
  72765. * @param name The name of the effect.
  72766. * @param scene The scene containing the objects to blur according to their velocity.
  72767. * @param options The required width/height ratio to downsize to before computing the render pass.
  72768. * @param camera The camera to apply the render pass to.
  72769. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72770. * @param engine The engine which the post process will be applied. (default: current engine)
  72771. * @param reusable If the post process can be reused on the same frame. (default: false)
  72772. * @param textureType Type of textures used when performing the post process. (default: 0)
  72773. * @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)
  72774. */
  72775. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72776. /**
  72777. * Support test.
  72778. */
  72779. static get IsSupported(): boolean;
  72780. /** @hidden */
  72781. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  72782. }
  72783. }
  72784. declare module BABYLON {
  72785. interface Scene {
  72786. /** @hidden (Backing field) */
  72787. _boundingBoxRenderer: BoundingBoxRenderer;
  72788. /** @hidden (Backing field) */
  72789. _forceShowBoundingBoxes: boolean;
  72790. /**
  72791. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  72792. */
  72793. forceShowBoundingBoxes: boolean;
  72794. /**
  72795. * Gets the bounding box renderer associated with the scene
  72796. * @returns a BoundingBoxRenderer
  72797. */
  72798. getBoundingBoxRenderer(): BoundingBoxRenderer;
  72799. }
  72800. interface AbstractMesh {
  72801. /** @hidden (Backing field) */
  72802. _showBoundingBox: boolean;
  72803. /**
  72804. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  72805. */
  72806. showBoundingBox: boolean;
  72807. }
  72808. /**
  72809. * Component responsible of rendering the bounding box of the meshes in a scene.
  72810. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  72811. */
  72812. export class BoundingBoxRenderer implements ISceneComponent {
  72813. /**
  72814. * The component name helpfull to identify the component in the list of scene components.
  72815. */
  72816. readonly name: string;
  72817. /**
  72818. * The scene the component belongs to.
  72819. */
  72820. scene: Scene;
  72821. /**
  72822. * Color of the bounding box lines placed in front of an object
  72823. */
  72824. frontColor: Color3;
  72825. /**
  72826. * Color of the bounding box lines placed behind an object
  72827. */
  72828. backColor: Color3;
  72829. /**
  72830. * Defines if the renderer should show the back lines or not
  72831. */
  72832. showBackLines: boolean;
  72833. /**
  72834. * Observable raised before rendering a bounding box
  72835. */
  72836. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  72837. /**
  72838. * Observable raised after rendering a bounding box
  72839. */
  72840. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  72841. /**
  72842. * Observable raised after resources are created
  72843. */
  72844. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  72845. /**
  72846. * When false, no bounding boxes will be rendered
  72847. */
  72848. enabled: boolean;
  72849. /**
  72850. * @hidden
  72851. */
  72852. renderList: SmartArray<BoundingBox>;
  72853. private _colorShader;
  72854. private _vertexBuffers;
  72855. private _indexBuffer;
  72856. private _fillIndexBuffer;
  72857. private _fillIndexData;
  72858. /**
  72859. * Instantiates a new bounding box renderer in a scene.
  72860. * @param scene the scene the renderer renders in
  72861. */
  72862. constructor(scene: Scene);
  72863. /**
  72864. * Registers the component in a given scene
  72865. */
  72866. register(): void;
  72867. private _evaluateSubMesh;
  72868. private _preActiveMesh;
  72869. private _prepareResources;
  72870. private _createIndexBuffer;
  72871. /**
  72872. * Rebuilds the elements related to this component in case of
  72873. * context lost for instance.
  72874. */
  72875. rebuild(): void;
  72876. /**
  72877. * @hidden
  72878. */
  72879. reset(): void;
  72880. /**
  72881. * Render the bounding boxes of a specific rendering group
  72882. * @param renderingGroupId defines the rendering group to render
  72883. */
  72884. render(renderingGroupId: number): void;
  72885. /**
  72886. * In case of occlusion queries, we can render the occlusion bounding box through this method
  72887. * @param mesh Define the mesh to render the occlusion bounding box for
  72888. */
  72889. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  72890. /**
  72891. * Dispose and release the resources attached to this renderer.
  72892. */
  72893. dispose(): void;
  72894. }
  72895. }
  72896. declare module BABYLON {
  72897. interface Scene {
  72898. /** @hidden (Backing field) */
  72899. _depthRenderer: {
  72900. [id: string]: DepthRenderer;
  72901. };
  72902. /**
  72903. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  72904. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  72905. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  72906. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  72907. * @returns the created depth renderer
  72908. */
  72909. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  72910. /**
  72911. * Disables a depth renderer for a given camera
  72912. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  72913. */
  72914. disableDepthRenderer(camera?: Nullable<Camera>): void;
  72915. }
  72916. /**
  72917. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  72918. * in several rendering techniques.
  72919. */
  72920. export class DepthRendererSceneComponent implements ISceneComponent {
  72921. /**
  72922. * The component name helpfull to identify the component in the list of scene components.
  72923. */
  72924. readonly name: string;
  72925. /**
  72926. * The scene the component belongs to.
  72927. */
  72928. scene: Scene;
  72929. /**
  72930. * Creates a new instance of the component for the given scene
  72931. * @param scene Defines the scene to register the component in
  72932. */
  72933. constructor(scene: Scene);
  72934. /**
  72935. * Registers the component in a given scene
  72936. */
  72937. register(): void;
  72938. /**
  72939. * Rebuilds the elements related to this component in case of
  72940. * context lost for instance.
  72941. */
  72942. rebuild(): void;
  72943. /**
  72944. * Disposes the component and the associated ressources
  72945. */
  72946. dispose(): void;
  72947. private _gatherRenderTargets;
  72948. private _gatherActiveCameraRenderTargets;
  72949. }
  72950. }
  72951. declare module BABYLON {
  72952. interface AbstractScene {
  72953. /** @hidden (Backing field) */
  72954. _prePassRenderer: Nullable<PrePassRenderer>;
  72955. /**
  72956. * Gets or Sets the current prepass renderer associated to the scene.
  72957. */
  72958. prePassRenderer: Nullable<PrePassRenderer>;
  72959. /**
  72960. * Enables the prepass and associates it with the scene
  72961. * @returns the PrePassRenderer
  72962. */
  72963. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  72964. /**
  72965. * Disables the prepass associated with the scene
  72966. */
  72967. disablePrePassRenderer(): void;
  72968. }
  72969. /**
  72970. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  72971. * in several rendering techniques.
  72972. */
  72973. export class PrePassRendererSceneComponent implements ISceneComponent {
  72974. /**
  72975. * The component name helpful to identify the component in the list of scene components.
  72976. */
  72977. readonly name: string;
  72978. /**
  72979. * The scene the component belongs to.
  72980. */
  72981. scene: Scene;
  72982. /**
  72983. * Creates a new instance of the component for the given scene
  72984. * @param scene Defines the scene to register the component in
  72985. */
  72986. constructor(scene: Scene);
  72987. /**
  72988. * Registers the component in a given scene
  72989. */
  72990. register(): void;
  72991. private _beforeCameraDraw;
  72992. private _afterCameraDraw;
  72993. private _beforeClearStage;
  72994. /**
  72995. * Rebuilds the elements related to this component in case of
  72996. * context lost for instance.
  72997. */
  72998. rebuild(): void;
  72999. /**
  73000. * Disposes the component and the associated ressources
  73001. */
  73002. dispose(): void;
  73003. }
  73004. }
  73005. declare module BABYLON {
  73006. /** @hidden */
  73007. export var fibonacci: {
  73008. name: string;
  73009. shader: string;
  73010. };
  73011. }
  73012. declare module BABYLON {
  73013. /** @hidden */
  73014. export var diffusionProfile: {
  73015. name: string;
  73016. shader: string;
  73017. };
  73018. }
  73019. declare module BABYLON {
  73020. /** @hidden */
  73021. export var subSurfaceScatteringPixelShader: {
  73022. name: string;
  73023. shader: string;
  73024. };
  73025. }
  73026. declare module BABYLON {
  73027. /**
  73028. * Sub surface scattering post process
  73029. */
  73030. export class SubSurfaceScatteringPostProcess extends PostProcess {
  73031. /**
  73032. * Gets a string identifying the name of the class
  73033. * @returns "SubSurfaceScatteringPostProcess" string
  73034. */
  73035. getClassName(): string;
  73036. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73037. }
  73038. }
  73039. declare module BABYLON {
  73040. /**
  73041. * Contains all parameters needed for the prepass to perform
  73042. * screen space subsurface scattering
  73043. */
  73044. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  73045. /** @hidden */
  73046. static _SceneComponentInitialization: (scene: Scene) => void;
  73047. private _ssDiffusionS;
  73048. private _ssFilterRadii;
  73049. private _ssDiffusionD;
  73050. /**
  73051. * Post process to attach for screen space subsurface scattering
  73052. */
  73053. postProcess: SubSurfaceScatteringPostProcess;
  73054. /**
  73055. * Diffusion profile color for subsurface scattering
  73056. */
  73057. get ssDiffusionS(): number[];
  73058. /**
  73059. * Diffusion profile max color channel value for subsurface scattering
  73060. */
  73061. get ssDiffusionD(): number[];
  73062. /**
  73063. * Diffusion profile filter radius for subsurface scattering
  73064. */
  73065. get ssFilterRadii(): number[];
  73066. /**
  73067. * Is subsurface enabled
  73068. */
  73069. enabled: boolean;
  73070. /**
  73071. * Name of the configuration
  73072. */
  73073. name: string;
  73074. /**
  73075. * Diffusion profile colors for subsurface scattering
  73076. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  73077. * See ...
  73078. * Note that you can only store up to 5 of them
  73079. */
  73080. ssDiffusionProfileColors: Color3[];
  73081. /**
  73082. * Defines the ratio real world => scene units.
  73083. * Used for subsurface scattering
  73084. */
  73085. metersPerUnit: number;
  73086. /**
  73087. * Textures that should be present in the MRT for this effect to work
  73088. */
  73089. readonly texturesRequired: number[];
  73090. private _scene;
  73091. /**
  73092. * Builds a subsurface configuration object
  73093. * @param scene The scene
  73094. */
  73095. constructor(scene: Scene);
  73096. /**
  73097. * Adds a new diffusion profile.
  73098. * Useful for more realistic subsurface scattering on diverse materials.
  73099. * @param color The color of the diffusion profile. Should be the average color of the material.
  73100. * @return The index of the diffusion profile for the material subsurface configuration
  73101. */
  73102. addDiffusionProfile(color: Color3): number;
  73103. /**
  73104. * Creates the sss post process
  73105. * @return The created post process
  73106. */
  73107. createPostProcess(): SubSurfaceScatteringPostProcess;
  73108. /**
  73109. * Deletes all diffusion profiles.
  73110. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  73111. */
  73112. clearAllDiffusionProfiles(): void;
  73113. /**
  73114. * Disposes this object
  73115. */
  73116. dispose(): void;
  73117. /**
  73118. * @hidden
  73119. * https://zero-radiance.github.io/post/sampling-diffusion/
  73120. *
  73121. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  73122. * ------------------------------------------------------------------------------------
  73123. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  73124. * PDF[r, phi, s] = r * R[r, phi, s]
  73125. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  73126. * ------------------------------------------------------------------------------------
  73127. * We importance sample the color channel with the widest scattering distance.
  73128. */
  73129. getDiffusionProfileParameters(color: Color3): number;
  73130. /**
  73131. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  73132. * 'u' is the random number (the value of the CDF): [0, 1).
  73133. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  73134. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  73135. */
  73136. private _sampleBurleyDiffusionProfile;
  73137. }
  73138. }
  73139. declare module BABYLON {
  73140. interface AbstractScene {
  73141. /** @hidden (Backing field) */
  73142. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  73143. /**
  73144. * Gets or Sets the current prepass renderer associated to the scene.
  73145. */
  73146. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  73147. /**
  73148. * Enables the subsurface effect for prepass
  73149. * @returns the SubSurfaceConfiguration
  73150. */
  73151. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  73152. /**
  73153. * Disables the subsurface effect for prepass
  73154. */
  73155. disableSubSurfaceForPrePass(): void;
  73156. }
  73157. /**
  73158. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73159. * in several rendering techniques.
  73160. */
  73161. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  73162. /**
  73163. * The component name helpful to identify the component in the list of scene components.
  73164. */
  73165. readonly name: string;
  73166. /**
  73167. * The scene the component belongs to.
  73168. */
  73169. scene: Scene;
  73170. /**
  73171. * Creates a new instance of the component for the given scene
  73172. * @param scene Defines the scene to register the component in
  73173. */
  73174. constructor(scene: Scene);
  73175. /**
  73176. * Registers the component in a given scene
  73177. */
  73178. register(): void;
  73179. /**
  73180. * Serializes the component data to the specified json object
  73181. * @param serializationObject The object to serialize to
  73182. */
  73183. serialize(serializationObject: any): void;
  73184. /**
  73185. * Adds all the elements from the container to the scene
  73186. * @param container the container holding the elements
  73187. */
  73188. addFromContainer(container: AbstractScene): void;
  73189. /**
  73190. * Removes all the elements in the container from the scene
  73191. * @param container contains the elements to remove
  73192. * @param dispose if the removed element should be disposed (default: false)
  73193. */
  73194. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  73195. /**
  73196. * Rebuilds the elements related to this component in case of
  73197. * context lost for instance.
  73198. */
  73199. rebuild(): void;
  73200. /**
  73201. * Disposes the component and the associated ressources
  73202. */
  73203. dispose(): void;
  73204. }
  73205. }
  73206. declare module BABYLON {
  73207. /** @hidden */
  73208. export var outlinePixelShader: {
  73209. name: string;
  73210. shader: string;
  73211. };
  73212. }
  73213. declare module BABYLON {
  73214. /** @hidden */
  73215. export var outlineVertexShader: {
  73216. name: string;
  73217. shader: string;
  73218. };
  73219. }
  73220. declare module BABYLON {
  73221. interface Scene {
  73222. /** @hidden */
  73223. _outlineRenderer: OutlineRenderer;
  73224. /**
  73225. * Gets the outline renderer associated with the scene
  73226. * @returns a OutlineRenderer
  73227. */
  73228. getOutlineRenderer(): OutlineRenderer;
  73229. }
  73230. interface AbstractMesh {
  73231. /** @hidden (Backing field) */
  73232. _renderOutline: boolean;
  73233. /**
  73234. * Gets or sets a boolean indicating if the outline must be rendered as well
  73235. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  73236. */
  73237. renderOutline: boolean;
  73238. /** @hidden (Backing field) */
  73239. _renderOverlay: boolean;
  73240. /**
  73241. * Gets or sets a boolean indicating if the overlay must be rendered as well
  73242. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  73243. */
  73244. renderOverlay: boolean;
  73245. }
  73246. /**
  73247. * This class is responsible to draw bothe outline/overlay of meshes.
  73248. * It should not be used directly but through the available method on mesh.
  73249. */
  73250. export class OutlineRenderer implements ISceneComponent {
  73251. /**
  73252. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  73253. */
  73254. private static _StencilReference;
  73255. /**
  73256. * The name of the component. Each component must have a unique name.
  73257. */
  73258. name: string;
  73259. /**
  73260. * The scene the component belongs to.
  73261. */
  73262. scene: Scene;
  73263. /**
  73264. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  73265. */
  73266. zOffset: number;
  73267. private _engine;
  73268. private _effect;
  73269. private _cachedDefines;
  73270. private _savedDepthWrite;
  73271. /**
  73272. * Instantiates a new outline renderer. (There could be only one per scene).
  73273. * @param scene Defines the scene it belongs to
  73274. */
  73275. constructor(scene: Scene);
  73276. /**
  73277. * Register the component to one instance of a scene.
  73278. */
  73279. register(): void;
  73280. /**
  73281. * Rebuilds the elements related to this component in case of
  73282. * context lost for instance.
  73283. */
  73284. rebuild(): void;
  73285. /**
  73286. * Disposes the component and the associated ressources.
  73287. */
  73288. dispose(): void;
  73289. /**
  73290. * Renders the outline in the canvas.
  73291. * @param subMesh Defines the sumesh to render
  73292. * @param batch Defines the batch of meshes in case of instances
  73293. * @param useOverlay Defines if the rendering is for the overlay or the outline
  73294. */
  73295. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  73296. /**
  73297. * Returns whether or not the outline renderer is ready for a given submesh.
  73298. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  73299. * @param subMesh Defines the submesh to check readyness for
  73300. * @param useInstances Defines wheter wee are trying to render instances or not
  73301. * @returns true if ready otherwise false
  73302. */
  73303. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73304. private _beforeRenderingMesh;
  73305. private _afterRenderingMesh;
  73306. }
  73307. }
  73308. declare module BABYLON {
  73309. /**
  73310. * Defines the basic options interface of a Sprite Frame Source Size.
  73311. */
  73312. export interface ISpriteJSONSpriteSourceSize {
  73313. /**
  73314. * number of the original width of the Frame
  73315. */
  73316. w: number;
  73317. /**
  73318. * number of the original height of the Frame
  73319. */
  73320. h: number;
  73321. }
  73322. /**
  73323. * Defines the basic options interface of a Sprite Frame Data.
  73324. */
  73325. export interface ISpriteJSONSpriteFrameData {
  73326. /**
  73327. * number of the x offset of the Frame
  73328. */
  73329. x: number;
  73330. /**
  73331. * number of the y offset of the Frame
  73332. */
  73333. y: number;
  73334. /**
  73335. * number of the width of the Frame
  73336. */
  73337. w: number;
  73338. /**
  73339. * number of the height of the Frame
  73340. */
  73341. h: number;
  73342. }
  73343. /**
  73344. * Defines the basic options interface of a JSON Sprite.
  73345. */
  73346. export interface ISpriteJSONSprite {
  73347. /**
  73348. * string name of the Frame
  73349. */
  73350. filename: string;
  73351. /**
  73352. * ISpriteJSONSpriteFrame basic object of the frame data
  73353. */
  73354. frame: ISpriteJSONSpriteFrameData;
  73355. /**
  73356. * boolean to flag is the frame was rotated.
  73357. */
  73358. rotated: boolean;
  73359. /**
  73360. * boolean to flag is the frame was trimmed.
  73361. */
  73362. trimmed: boolean;
  73363. /**
  73364. * ISpriteJSONSpriteFrame basic object of the source data
  73365. */
  73366. spriteSourceSize: ISpriteJSONSpriteFrameData;
  73367. /**
  73368. * ISpriteJSONSpriteFrame basic object of the source data
  73369. */
  73370. sourceSize: ISpriteJSONSpriteSourceSize;
  73371. }
  73372. /**
  73373. * Defines the basic options interface of a JSON atlas.
  73374. */
  73375. export interface ISpriteJSONAtlas {
  73376. /**
  73377. * Array of objects that contain the frame data.
  73378. */
  73379. frames: Array<ISpriteJSONSprite>;
  73380. /**
  73381. * object basic object containing the sprite meta data.
  73382. */
  73383. meta?: object;
  73384. }
  73385. }
  73386. declare module BABYLON {
  73387. /** @hidden */
  73388. export var spriteMapPixelShader: {
  73389. name: string;
  73390. shader: string;
  73391. };
  73392. }
  73393. declare module BABYLON {
  73394. /** @hidden */
  73395. export var spriteMapVertexShader: {
  73396. name: string;
  73397. shader: string;
  73398. };
  73399. }
  73400. declare module BABYLON {
  73401. /**
  73402. * Defines the basic options interface of a SpriteMap
  73403. */
  73404. export interface ISpriteMapOptions {
  73405. /**
  73406. * Vector2 of the number of cells in the grid.
  73407. */
  73408. stageSize?: Vector2;
  73409. /**
  73410. * Vector2 of the size of the output plane in World Units.
  73411. */
  73412. outputSize?: Vector2;
  73413. /**
  73414. * Vector3 of the position of the output plane in World Units.
  73415. */
  73416. outputPosition?: Vector3;
  73417. /**
  73418. * Vector3 of the rotation of the output plane.
  73419. */
  73420. outputRotation?: Vector3;
  73421. /**
  73422. * number of layers that the system will reserve in resources.
  73423. */
  73424. layerCount?: number;
  73425. /**
  73426. * number of max animation frames a single cell will reserve in resources.
  73427. */
  73428. maxAnimationFrames?: number;
  73429. /**
  73430. * number cell index of the base tile when the system compiles.
  73431. */
  73432. baseTile?: number;
  73433. /**
  73434. * boolean flip the sprite after its been repositioned by the framing data.
  73435. */
  73436. flipU?: boolean;
  73437. /**
  73438. * Vector3 scalar of the global RGB values of the SpriteMap.
  73439. */
  73440. colorMultiply?: Vector3;
  73441. }
  73442. /**
  73443. * Defines the IDisposable interface in order to be cleanable from resources.
  73444. */
  73445. export interface ISpriteMap extends IDisposable {
  73446. /**
  73447. * String name of the SpriteMap.
  73448. */
  73449. name: string;
  73450. /**
  73451. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  73452. */
  73453. atlasJSON: ISpriteJSONAtlas;
  73454. /**
  73455. * Texture of the SpriteMap.
  73456. */
  73457. spriteSheet: Texture;
  73458. /**
  73459. * The parameters to initialize the SpriteMap with.
  73460. */
  73461. options: ISpriteMapOptions;
  73462. }
  73463. /**
  73464. * Class used to manage a grid restricted sprite deployment on an Output plane.
  73465. */
  73466. export class SpriteMap implements ISpriteMap {
  73467. /** The Name of the spriteMap */
  73468. name: string;
  73469. /** The JSON file with the frame and meta data */
  73470. atlasJSON: ISpriteJSONAtlas;
  73471. /** The systems Sprite Sheet Texture */
  73472. spriteSheet: Texture;
  73473. /** Arguments passed with the Constructor */
  73474. options: ISpriteMapOptions;
  73475. /** Public Sprite Storage array, parsed from atlasJSON */
  73476. sprites: Array<ISpriteJSONSprite>;
  73477. /** Returns the Number of Sprites in the System */
  73478. get spriteCount(): number;
  73479. /** Returns the Position of Output Plane*/
  73480. get position(): Vector3;
  73481. /** Returns the Position of Output Plane*/
  73482. set position(v: Vector3);
  73483. /** Returns the Rotation of Output Plane*/
  73484. get rotation(): Vector3;
  73485. /** Returns the Rotation of Output Plane*/
  73486. set rotation(v: Vector3);
  73487. /** Sets the AnimationMap*/
  73488. get animationMap(): RawTexture;
  73489. /** Sets the AnimationMap*/
  73490. set animationMap(v: RawTexture);
  73491. /** Scene that the SpriteMap was created in */
  73492. private _scene;
  73493. /** Texture Buffer of Float32 that holds tile frame data*/
  73494. private _frameMap;
  73495. /** Texture Buffers of Float32 that holds tileMap data*/
  73496. private _tileMaps;
  73497. /** Texture Buffer of Float32 that holds Animation Data*/
  73498. private _animationMap;
  73499. /** Custom ShaderMaterial Central to the System*/
  73500. private _material;
  73501. /** Custom ShaderMaterial Central to the System*/
  73502. private _output;
  73503. /** Systems Time Ticker*/
  73504. private _time;
  73505. /**
  73506. * Creates a new SpriteMap
  73507. * @param name defines the SpriteMaps Name
  73508. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  73509. * @param spriteSheet is the Texture that the Sprites are on.
  73510. * @param options a basic deployment configuration
  73511. * @param scene The Scene that the map is deployed on
  73512. */
  73513. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  73514. /**
  73515. * Returns tileID location
  73516. * @returns Vector2 the cell position ID
  73517. */
  73518. getTileID(): Vector2;
  73519. /**
  73520. * Gets the UV location of the mouse over the SpriteMap.
  73521. * @returns Vector2 the UV position of the mouse interaction
  73522. */
  73523. getMousePosition(): Vector2;
  73524. /**
  73525. * Creates the "frame" texture Buffer
  73526. * -------------------------------------
  73527. * Structure of frames
  73528. * "filename": "Falling-Water-2.png",
  73529. * "frame": {"x":69,"y":103,"w":24,"h":32},
  73530. * "rotated": true,
  73531. * "trimmed": true,
  73532. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  73533. * "sourceSize": {"w":32,"h":32}
  73534. * @returns RawTexture of the frameMap
  73535. */
  73536. private _createFrameBuffer;
  73537. /**
  73538. * Creates the tileMap texture Buffer
  73539. * @param buffer normally and array of numbers, or a false to generate from scratch
  73540. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  73541. * @returns RawTexture of the tileMap
  73542. */
  73543. private _createTileBuffer;
  73544. /**
  73545. * Modifies the data of the tileMaps
  73546. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  73547. * @param pos is the iVector2 Coordinates of the Tile
  73548. * @param tile The SpriteIndex of the new Tile
  73549. */
  73550. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  73551. /**
  73552. * Creates the animationMap texture Buffer
  73553. * @param buffer normally and array of numbers, or a false to generate from scratch
  73554. * @returns RawTexture of the animationMap
  73555. */
  73556. private _createTileAnimationBuffer;
  73557. /**
  73558. * Modifies the data of the animationMap
  73559. * @param cellID is the Index of the Sprite
  73560. * @param _frame is the target Animation frame
  73561. * @param toCell is the Target Index of the next frame of the animation
  73562. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  73563. * @param speed is a global scalar of the time variable on the map.
  73564. */
  73565. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  73566. /**
  73567. * Exports the .tilemaps file
  73568. */
  73569. saveTileMaps(): void;
  73570. /**
  73571. * Imports the .tilemaps file
  73572. * @param url of the .tilemaps file
  73573. */
  73574. loadTileMaps(url: string): void;
  73575. /**
  73576. * Release associated resources
  73577. */
  73578. dispose(): void;
  73579. }
  73580. }
  73581. declare module BABYLON {
  73582. /**
  73583. * Class used to manage multiple sprites of different sizes on the same spritesheet
  73584. * @see https://doc.babylonjs.com/babylon101/sprites
  73585. */
  73586. export class SpritePackedManager extends SpriteManager {
  73587. /** defines the packed manager's name */
  73588. name: string;
  73589. /**
  73590. * Creates a new sprite manager from a packed sprite sheet
  73591. * @param name defines the manager's name
  73592. * @param imgUrl defines the sprite sheet url
  73593. * @param capacity defines the maximum allowed number of sprites
  73594. * @param scene defines the hosting scene
  73595. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  73596. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  73597. * @param samplingMode defines the smapling mode to use with spritesheet
  73598. * @param fromPacked set to true; do not alter
  73599. */
  73600. constructor(
  73601. /** defines the packed manager's name */
  73602. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  73603. }
  73604. }
  73605. declare module BABYLON {
  73606. /**
  73607. * Defines the list of states available for a task inside a AssetsManager
  73608. */
  73609. export enum AssetTaskState {
  73610. /**
  73611. * Initialization
  73612. */
  73613. INIT = 0,
  73614. /**
  73615. * Running
  73616. */
  73617. RUNNING = 1,
  73618. /**
  73619. * Done
  73620. */
  73621. DONE = 2,
  73622. /**
  73623. * Error
  73624. */
  73625. ERROR = 3
  73626. }
  73627. /**
  73628. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  73629. */
  73630. export abstract class AbstractAssetTask {
  73631. /**
  73632. * Task name
  73633. */ name: string;
  73634. /**
  73635. * Callback called when the task is successful
  73636. */
  73637. onSuccess: (task: any) => void;
  73638. /**
  73639. * Callback called when the task is not successful
  73640. */
  73641. onError: (task: any, message?: string, exception?: any) => void;
  73642. /**
  73643. * Creates a new AssetsManager
  73644. * @param name defines the name of the task
  73645. */
  73646. constructor(
  73647. /**
  73648. * Task name
  73649. */ name: string);
  73650. private _isCompleted;
  73651. private _taskState;
  73652. private _errorObject;
  73653. /**
  73654. * Get if the task is completed
  73655. */
  73656. get isCompleted(): boolean;
  73657. /**
  73658. * Gets the current state of the task
  73659. */
  73660. get taskState(): AssetTaskState;
  73661. /**
  73662. * Gets the current error object (if task is in error)
  73663. */
  73664. get errorObject(): {
  73665. message?: string;
  73666. exception?: any;
  73667. };
  73668. /**
  73669. * Internal only
  73670. * @hidden
  73671. */
  73672. _setErrorObject(message?: string, exception?: any): void;
  73673. /**
  73674. * Execute the current task
  73675. * @param scene defines the scene where you want your assets to be loaded
  73676. * @param onSuccess is a callback called when the task is successfully executed
  73677. * @param onError is a callback called if an error occurs
  73678. */
  73679. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73680. /**
  73681. * Execute the current task
  73682. * @param scene defines the scene where you want your assets to be loaded
  73683. * @param onSuccess is a callback called when the task is successfully executed
  73684. * @param onError is a callback called if an error occurs
  73685. */
  73686. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73687. /**
  73688. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  73689. * This can be used with failed tasks that have the reason for failure fixed.
  73690. */
  73691. reset(): void;
  73692. private onErrorCallback;
  73693. private onDoneCallback;
  73694. }
  73695. /**
  73696. * Define the interface used by progress events raised during assets loading
  73697. */
  73698. export interface IAssetsProgressEvent {
  73699. /**
  73700. * Defines the number of remaining tasks to process
  73701. */
  73702. remainingCount: number;
  73703. /**
  73704. * Defines the total number of tasks
  73705. */
  73706. totalCount: number;
  73707. /**
  73708. * Defines the task that was just processed
  73709. */
  73710. task: AbstractAssetTask;
  73711. }
  73712. /**
  73713. * Class used to share progress information about assets loading
  73714. */
  73715. export class AssetsProgressEvent implements IAssetsProgressEvent {
  73716. /**
  73717. * Defines the number of remaining tasks to process
  73718. */
  73719. remainingCount: number;
  73720. /**
  73721. * Defines the total number of tasks
  73722. */
  73723. totalCount: number;
  73724. /**
  73725. * Defines the task that was just processed
  73726. */
  73727. task: AbstractAssetTask;
  73728. /**
  73729. * Creates a AssetsProgressEvent
  73730. * @param remainingCount defines the number of remaining tasks to process
  73731. * @param totalCount defines the total number of tasks
  73732. * @param task defines the task that was just processed
  73733. */
  73734. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  73735. }
  73736. /**
  73737. * Define a task used by AssetsManager to load assets into a container
  73738. */
  73739. export class ContainerAssetTask extends AbstractAssetTask {
  73740. /**
  73741. * Defines the name of the task
  73742. */
  73743. name: string;
  73744. /**
  73745. * Defines the list of mesh's names you want to load
  73746. */
  73747. meshesNames: any;
  73748. /**
  73749. * Defines the root url to use as a base to load your meshes and associated resources
  73750. */
  73751. rootUrl: string;
  73752. /**
  73753. * Defines the filename or File of the scene to load from
  73754. */
  73755. sceneFilename: string | File;
  73756. /**
  73757. * Get the loaded asset container
  73758. */
  73759. loadedContainer: AssetContainer;
  73760. /**
  73761. * Gets the list of loaded meshes
  73762. */
  73763. loadedMeshes: Array<AbstractMesh>;
  73764. /**
  73765. * Gets the list of loaded particle systems
  73766. */
  73767. loadedParticleSystems: Array<IParticleSystem>;
  73768. /**
  73769. * Gets the list of loaded skeletons
  73770. */
  73771. loadedSkeletons: Array<Skeleton>;
  73772. /**
  73773. * Gets the list of loaded animation groups
  73774. */
  73775. loadedAnimationGroups: Array<AnimationGroup>;
  73776. /**
  73777. * Callback called when the task is successful
  73778. */
  73779. onSuccess: (task: ContainerAssetTask) => void;
  73780. /**
  73781. * Callback called when the task is successful
  73782. */
  73783. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  73784. /**
  73785. * Creates a new ContainerAssetTask
  73786. * @param name defines the name of the task
  73787. * @param meshesNames defines the list of mesh's names you want to load
  73788. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  73789. * @param sceneFilename defines the filename or File of the scene to load from
  73790. */
  73791. constructor(
  73792. /**
  73793. * Defines the name of the task
  73794. */
  73795. name: string,
  73796. /**
  73797. * Defines the list of mesh's names you want to load
  73798. */
  73799. meshesNames: any,
  73800. /**
  73801. * Defines the root url to use as a base to load your meshes and associated resources
  73802. */
  73803. rootUrl: string,
  73804. /**
  73805. * Defines the filename or File of the scene to load from
  73806. */
  73807. sceneFilename: string | File);
  73808. /**
  73809. * Execute the current task
  73810. * @param scene defines the scene where you want your assets to be loaded
  73811. * @param onSuccess is a callback called when the task is successfully executed
  73812. * @param onError is a callback called if an error occurs
  73813. */
  73814. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73815. }
  73816. /**
  73817. * Define a task used by AssetsManager to load meshes
  73818. */
  73819. export class MeshAssetTask extends AbstractAssetTask {
  73820. /**
  73821. * Defines the name of the task
  73822. */
  73823. name: string;
  73824. /**
  73825. * Defines the list of mesh's names you want to load
  73826. */
  73827. meshesNames: any;
  73828. /**
  73829. * Defines the root url to use as a base to load your meshes and associated resources
  73830. */
  73831. rootUrl: string;
  73832. /**
  73833. * Defines the filename or File of the scene to load from
  73834. */
  73835. sceneFilename: string | File;
  73836. /**
  73837. * Gets the list of loaded meshes
  73838. */
  73839. loadedMeshes: Array<AbstractMesh>;
  73840. /**
  73841. * Gets the list of loaded particle systems
  73842. */
  73843. loadedParticleSystems: Array<IParticleSystem>;
  73844. /**
  73845. * Gets the list of loaded skeletons
  73846. */
  73847. loadedSkeletons: Array<Skeleton>;
  73848. /**
  73849. * Gets the list of loaded animation groups
  73850. */
  73851. loadedAnimationGroups: Array<AnimationGroup>;
  73852. /**
  73853. * Callback called when the task is successful
  73854. */
  73855. onSuccess: (task: MeshAssetTask) => void;
  73856. /**
  73857. * Callback called when the task is successful
  73858. */
  73859. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  73860. /**
  73861. * Creates a new MeshAssetTask
  73862. * @param name defines the name of the task
  73863. * @param meshesNames defines the list of mesh's names you want to load
  73864. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  73865. * @param sceneFilename defines the filename or File of the scene to load from
  73866. */
  73867. constructor(
  73868. /**
  73869. * Defines the name of the task
  73870. */
  73871. name: string,
  73872. /**
  73873. * Defines the list of mesh's names you want to load
  73874. */
  73875. meshesNames: any,
  73876. /**
  73877. * Defines the root url to use as a base to load your meshes and associated resources
  73878. */
  73879. rootUrl: string,
  73880. /**
  73881. * Defines the filename or File of the scene to load from
  73882. */
  73883. sceneFilename: string | File);
  73884. /**
  73885. * Execute the current task
  73886. * @param scene defines the scene where you want your assets to be loaded
  73887. * @param onSuccess is a callback called when the task is successfully executed
  73888. * @param onError is a callback called if an error occurs
  73889. */
  73890. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73891. }
  73892. /**
  73893. * Define a task used by AssetsManager to load text content
  73894. */
  73895. export class TextFileAssetTask extends AbstractAssetTask {
  73896. /**
  73897. * Defines the name of the task
  73898. */
  73899. name: string;
  73900. /**
  73901. * Defines the location of the file to load
  73902. */
  73903. url: string;
  73904. /**
  73905. * Gets the loaded text string
  73906. */
  73907. text: string;
  73908. /**
  73909. * Callback called when the task is successful
  73910. */
  73911. onSuccess: (task: TextFileAssetTask) => void;
  73912. /**
  73913. * Callback called when the task is successful
  73914. */
  73915. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  73916. /**
  73917. * Creates a new TextFileAssetTask object
  73918. * @param name defines the name of the task
  73919. * @param url defines the location of the file to load
  73920. */
  73921. constructor(
  73922. /**
  73923. * Defines the name of the task
  73924. */
  73925. name: string,
  73926. /**
  73927. * Defines the location of the file to load
  73928. */
  73929. url: string);
  73930. /**
  73931. * Execute the current task
  73932. * @param scene defines the scene where you want your assets to be loaded
  73933. * @param onSuccess is a callback called when the task is successfully executed
  73934. * @param onError is a callback called if an error occurs
  73935. */
  73936. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73937. }
  73938. /**
  73939. * Define a task used by AssetsManager to load binary data
  73940. */
  73941. export class BinaryFileAssetTask extends AbstractAssetTask {
  73942. /**
  73943. * Defines the name of the task
  73944. */
  73945. name: string;
  73946. /**
  73947. * Defines the location of the file to load
  73948. */
  73949. url: string;
  73950. /**
  73951. * Gets the lodaded data (as an array buffer)
  73952. */
  73953. data: ArrayBuffer;
  73954. /**
  73955. * Callback called when the task is successful
  73956. */
  73957. onSuccess: (task: BinaryFileAssetTask) => void;
  73958. /**
  73959. * Callback called when the task is successful
  73960. */
  73961. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  73962. /**
  73963. * Creates a new BinaryFileAssetTask object
  73964. * @param name defines the name of the new task
  73965. * @param url defines the location of the file to load
  73966. */
  73967. constructor(
  73968. /**
  73969. * Defines the name of the task
  73970. */
  73971. name: string,
  73972. /**
  73973. * Defines the location of the file to load
  73974. */
  73975. url: string);
  73976. /**
  73977. * Execute the current task
  73978. * @param scene defines the scene where you want your assets to be loaded
  73979. * @param onSuccess is a callback called when the task is successfully executed
  73980. * @param onError is a callback called if an error occurs
  73981. */
  73982. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73983. }
  73984. /**
  73985. * Define a task used by AssetsManager to load images
  73986. */
  73987. export class ImageAssetTask extends AbstractAssetTask {
  73988. /**
  73989. * Defines the name of the task
  73990. */
  73991. name: string;
  73992. /**
  73993. * Defines the location of the image to load
  73994. */
  73995. url: string;
  73996. /**
  73997. * Gets the loaded images
  73998. */
  73999. image: HTMLImageElement;
  74000. /**
  74001. * Callback called when the task is successful
  74002. */
  74003. onSuccess: (task: ImageAssetTask) => void;
  74004. /**
  74005. * Callback called when the task is successful
  74006. */
  74007. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  74008. /**
  74009. * Creates a new ImageAssetTask
  74010. * @param name defines the name of the task
  74011. * @param url defines the location of the image to load
  74012. */
  74013. constructor(
  74014. /**
  74015. * Defines the name of the task
  74016. */
  74017. name: string,
  74018. /**
  74019. * Defines the location of the image to load
  74020. */
  74021. url: string);
  74022. /**
  74023. * Execute the current task
  74024. * @param scene defines the scene where you want your assets to be loaded
  74025. * @param onSuccess is a callback called when the task is successfully executed
  74026. * @param onError is a callback called if an error occurs
  74027. */
  74028. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74029. }
  74030. /**
  74031. * Defines the interface used by texture loading tasks
  74032. */
  74033. export interface ITextureAssetTask<TEX extends BaseTexture> {
  74034. /**
  74035. * Gets the loaded texture
  74036. */
  74037. texture: TEX;
  74038. }
  74039. /**
  74040. * Define a task used by AssetsManager to load 2D textures
  74041. */
  74042. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  74043. /**
  74044. * Defines the name of the task
  74045. */
  74046. name: string;
  74047. /**
  74048. * Defines the location of the file to load
  74049. */
  74050. url: string;
  74051. /**
  74052. * Defines if mipmap should not be generated (default is false)
  74053. */
  74054. noMipmap?: boolean | undefined;
  74055. /**
  74056. * Defines if texture must be inverted on Y axis (default is true)
  74057. */
  74058. invertY: boolean;
  74059. /**
  74060. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74061. */
  74062. samplingMode: number;
  74063. /**
  74064. * Gets the loaded texture
  74065. */
  74066. texture: Texture;
  74067. /**
  74068. * Callback called when the task is successful
  74069. */
  74070. onSuccess: (task: TextureAssetTask) => void;
  74071. /**
  74072. * Callback called when the task is successful
  74073. */
  74074. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  74075. /**
  74076. * Creates a new TextureAssetTask object
  74077. * @param name defines the name of the task
  74078. * @param url defines the location of the file to load
  74079. * @param noMipmap defines if mipmap should not be generated (default is false)
  74080. * @param invertY defines if texture must be inverted on Y axis (default is true)
  74081. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74082. */
  74083. constructor(
  74084. /**
  74085. * Defines the name of the task
  74086. */
  74087. name: string,
  74088. /**
  74089. * Defines the location of the file to load
  74090. */
  74091. url: string,
  74092. /**
  74093. * Defines if mipmap should not be generated (default is false)
  74094. */
  74095. noMipmap?: boolean | undefined,
  74096. /**
  74097. * Defines if texture must be inverted on Y axis (default is true)
  74098. */
  74099. invertY?: boolean,
  74100. /**
  74101. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74102. */
  74103. samplingMode?: number);
  74104. /**
  74105. * Execute the current task
  74106. * @param scene defines the scene where you want your assets to be loaded
  74107. * @param onSuccess is a callback called when the task is successfully executed
  74108. * @param onError is a callback called if an error occurs
  74109. */
  74110. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74111. }
  74112. /**
  74113. * Define a task used by AssetsManager to load cube textures
  74114. */
  74115. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  74116. /**
  74117. * Defines the name of the task
  74118. */
  74119. name: string;
  74120. /**
  74121. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74122. */
  74123. url: string;
  74124. /**
  74125. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74126. */
  74127. extensions?: string[] | undefined;
  74128. /**
  74129. * Defines if mipmaps should not be generated (default is false)
  74130. */
  74131. noMipmap?: boolean | undefined;
  74132. /**
  74133. * Defines the explicit list of files (undefined by default)
  74134. */
  74135. files?: string[] | undefined;
  74136. /**
  74137. * Gets the loaded texture
  74138. */
  74139. texture: CubeTexture;
  74140. /**
  74141. * Callback called when the task is successful
  74142. */
  74143. onSuccess: (task: CubeTextureAssetTask) => void;
  74144. /**
  74145. * Callback called when the task is successful
  74146. */
  74147. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  74148. /**
  74149. * Creates a new CubeTextureAssetTask
  74150. * @param name defines the name of the task
  74151. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74152. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74153. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74154. * @param files defines the explicit list of files (undefined by default)
  74155. */
  74156. constructor(
  74157. /**
  74158. * Defines the name of the task
  74159. */
  74160. name: string,
  74161. /**
  74162. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74163. */
  74164. url: string,
  74165. /**
  74166. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74167. */
  74168. extensions?: string[] | undefined,
  74169. /**
  74170. * Defines if mipmaps should not be generated (default is false)
  74171. */
  74172. noMipmap?: boolean | undefined,
  74173. /**
  74174. * Defines the explicit list of files (undefined by default)
  74175. */
  74176. files?: string[] | undefined);
  74177. /**
  74178. * Execute the current task
  74179. * @param scene defines the scene where you want your assets to be loaded
  74180. * @param onSuccess is a callback called when the task is successfully executed
  74181. * @param onError is a callback called if an error occurs
  74182. */
  74183. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74184. }
  74185. /**
  74186. * Define a task used by AssetsManager to load HDR cube textures
  74187. */
  74188. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  74189. /**
  74190. * Defines the name of the task
  74191. */
  74192. name: string;
  74193. /**
  74194. * Defines the location of the file to load
  74195. */
  74196. url: string;
  74197. /**
  74198. * Defines the desired size (the more it increases the longer the generation will be)
  74199. */
  74200. size: number;
  74201. /**
  74202. * Defines if mipmaps should not be generated (default is false)
  74203. */
  74204. noMipmap: boolean;
  74205. /**
  74206. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74207. */
  74208. generateHarmonics: boolean;
  74209. /**
  74210. * 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)
  74211. */
  74212. gammaSpace: boolean;
  74213. /**
  74214. * Internal Use Only
  74215. */
  74216. reserved: boolean;
  74217. /**
  74218. * Gets the loaded texture
  74219. */
  74220. texture: HDRCubeTexture;
  74221. /**
  74222. * Callback called when the task is successful
  74223. */
  74224. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  74225. /**
  74226. * Callback called when the task is successful
  74227. */
  74228. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  74229. /**
  74230. * Creates a new HDRCubeTextureAssetTask object
  74231. * @param name defines the name of the task
  74232. * @param url defines the location of the file to load
  74233. * @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.
  74234. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74235. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74236. * @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)
  74237. * @param reserved Internal use only
  74238. */
  74239. constructor(
  74240. /**
  74241. * Defines the name of the task
  74242. */
  74243. name: string,
  74244. /**
  74245. * Defines the location of the file to load
  74246. */
  74247. url: string,
  74248. /**
  74249. * Defines the desired size (the more it increases the longer the generation will be)
  74250. */
  74251. size: number,
  74252. /**
  74253. * Defines if mipmaps should not be generated (default is false)
  74254. */
  74255. noMipmap?: boolean,
  74256. /**
  74257. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74258. */
  74259. generateHarmonics?: boolean,
  74260. /**
  74261. * 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)
  74262. */
  74263. gammaSpace?: boolean,
  74264. /**
  74265. * Internal Use Only
  74266. */
  74267. reserved?: boolean);
  74268. /**
  74269. * Execute the current task
  74270. * @param scene defines the scene where you want your assets to be loaded
  74271. * @param onSuccess is a callback called when the task is successfully executed
  74272. * @param onError is a callback called if an error occurs
  74273. */
  74274. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74275. }
  74276. /**
  74277. * Define a task used by AssetsManager to load Equirectangular cube textures
  74278. */
  74279. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  74280. /**
  74281. * Defines the name of the task
  74282. */
  74283. name: string;
  74284. /**
  74285. * Defines the location of the file to load
  74286. */
  74287. url: string;
  74288. /**
  74289. * Defines the desired size (the more it increases the longer the generation will be)
  74290. */
  74291. size: number;
  74292. /**
  74293. * Defines if mipmaps should not be generated (default is false)
  74294. */
  74295. noMipmap: boolean;
  74296. /**
  74297. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  74298. * but the standard material would require them in Gamma space) (default is true)
  74299. */
  74300. gammaSpace: boolean;
  74301. /**
  74302. * Gets the loaded texture
  74303. */
  74304. texture: EquiRectangularCubeTexture;
  74305. /**
  74306. * Callback called when the task is successful
  74307. */
  74308. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  74309. /**
  74310. * Callback called when the task is successful
  74311. */
  74312. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  74313. /**
  74314. * Creates a new EquiRectangularCubeTextureAssetTask object
  74315. * @param name defines the name of the task
  74316. * @param url defines the location of the file to load
  74317. * @param size defines the desired size (the more it increases the longer the generation will be)
  74318. * If the size is omitted this implies you are using a preprocessed cubemap.
  74319. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74320. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  74321. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  74322. * (default is true)
  74323. */
  74324. constructor(
  74325. /**
  74326. * Defines the name of the task
  74327. */
  74328. name: string,
  74329. /**
  74330. * Defines the location of the file to load
  74331. */
  74332. url: string,
  74333. /**
  74334. * Defines the desired size (the more it increases the longer the generation will be)
  74335. */
  74336. size: number,
  74337. /**
  74338. * Defines if mipmaps should not be generated (default is false)
  74339. */
  74340. noMipmap?: boolean,
  74341. /**
  74342. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  74343. * but the standard material would require them in Gamma space) (default is true)
  74344. */
  74345. gammaSpace?: boolean);
  74346. /**
  74347. * Execute the current task
  74348. * @param scene defines the scene where you want your assets to be loaded
  74349. * @param onSuccess is a callback called when the task is successfully executed
  74350. * @param onError is a callback called if an error occurs
  74351. */
  74352. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74353. }
  74354. /**
  74355. * This class can be used to easily import assets into a scene
  74356. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  74357. */
  74358. export class AssetsManager {
  74359. private _scene;
  74360. private _isLoading;
  74361. protected _tasks: AbstractAssetTask[];
  74362. protected _waitingTasksCount: number;
  74363. protected _totalTasksCount: number;
  74364. /**
  74365. * Callback called when all tasks are processed
  74366. */
  74367. onFinish: (tasks: AbstractAssetTask[]) => void;
  74368. /**
  74369. * Callback called when a task is successful
  74370. */
  74371. onTaskSuccess: (task: AbstractAssetTask) => void;
  74372. /**
  74373. * Callback called when a task had an error
  74374. */
  74375. onTaskError: (task: AbstractAssetTask) => void;
  74376. /**
  74377. * Callback called when a task is done (whatever the result is)
  74378. */
  74379. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  74380. /**
  74381. * Observable called when all tasks are processed
  74382. */
  74383. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  74384. /**
  74385. * Observable called when a task had an error
  74386. */
  74387. onTaskErrorObservable: Observable<AbstractAssetTask>;
  74388. /**
  74389. * Observable called when all tasks were executed
  74390. */
  74391. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  74392. /**
  74393. * Observable called when a task is done (whatever the result is)
  74394. */
  74395. onProgressObservable: Observable<IAssetsProgressEvent>;
  74396. /**
  74397. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  74398. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  74399. */
  74400. useDefaultLoadingScreen: boolean;
  74401. /**
  74402. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  74403. * when all assets have been downloaded.
  74404. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  74405. */
  74406. autoHideLoadingUI: boolean;
  74407. /**
  74408. * Creates a new AssetsManager
  74409. * @param scene defines the scene to work on
  74410. */
  74411. constructor(scene: Scene);
  74412. /**
  74413. * Add a ContainerAssetTask to the list of active tasks
  74414. * @param taskName defines the name of the new task
  74415. * @param meshesNames defines the name of meshes to load
  74416. * @param rootUrl defines the root url to use to locate files
  74417. * @param sceneFilename defines the filename of the scene file
  74418. * @returns a new ContainerAssetTask object
  74419. */
  74420. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  74421. /**
  74422. * Add a MeshAssetTask to the list of active tasks
  74423. * @param taskName defines the name of the new task
  74424. * @param meshesNames defines the name of meshes to load
  74425. * @param rootUrl defines the root url to use to locate files
  74426. * @param sceneFilename defines the filename of the scene file
  74427. * @returns a new MeshAssetTask object
  74428. */
  74429. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  74430. /**
  74431. * Add a TextFileAssetTask to the list of active tasks
  74432. * @param taskName defines the name of the new task
  74433. * @param url defines the url of the file to load
  74434. * @returns a new TextFileAssetTask object
  74435. */
  74436. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  74437. /**
  74438. * Add a BinaryFileAssetTask to the list of active tasks
  74439. * @param taskName defines the name of the new task
  74440. * @param url defines the url of the file to load
  74441. * @returns a new BinaryFileAssetTask object
  74442. */
  74443. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  74444. /**
  74445. * Add a ImageAssetTask to the list of active tasks
  74446. * @param taskName defines the name of the new task
  74447. * @param url defines the url of the file to load
  74448. * @returns a new ImageAssetTask object
  74449. */
  74450. addImageTask(taskName: string, url: string): ImageAssetTask;
  74451. /**
  74452. * Add a TextureAssetTask to the list of active tasks
  74453. * @param taskName defines the name of the new task
  74454. * @param url defines the url of the file to load
  74455. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74456. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  74457. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  74458. * @returns a new TextureAssetTask object
  74459. */
  74460. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  74461. /**
  74462. * Add a CubeTextureAssetTask to the list of active tasks
  74463. * @param taskName defines the name of the new task
  74464. * @param url defines the url of the file to load
  74465. * @param extensions defines the extension to use to load the cube map (can be null)
  74466. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74467. * @param files defines the list of files to load (can be null)
  74468. * @returns a new CubeTextureAssetTask object
  74469. */
  74470. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  74471. /**
  74472. *
  74473. * Add a HDRCubeTextureAssetTask to the list of active tasks
  74474. * @param taskName defines the name of the new task
  74475. * @param url defines the url of the file to load
  74476. * @param size defines the size you want for the cubemap (can be null)
  74477. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74478. * @param generateHarmonics defines if you want to automatically generate (true by default)
  74479. * @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)
  74480. * @param reserved Internal use only
  74481. * @returns a new HDRCubeTextureAssetTask object
  74482. */
  74483. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  74484. /**
  74485. *
  74486. * Add a EquiRectangularCubeTextureAssetTask 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 size defines the size you want for the cubemap (can be null)
  74490. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74491. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  74492. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  74493. * @returns a new EquiRectangularCubeTextureAssetTask object
  74494. */
  74495. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  74496. /**
  74497. * Remove a task from the assets manager.
  74498. * @param task the task to remove
  74499. */
  74500. removeTask(task: AbstractAssetTask): void;
  74501. private _decreaseWaitingTasksCount;
  74502. private _runTask;
  74503. /**
  74504. * Reset the AssetsManager and remove all tasks
  74505. * @return the current instance of the AssetsManager
  74506. */
  74507. reset(): AssetsManager;
  74508. /**
  74509. * Start the loading process
  74510. * @return the current instance of the AssetsManager
  74511. */
  74512. load(): AssetsManager;
  74513. /**
  74514. * Start the loading process as an async operation
  74515. * @return a promise returning the list of failed tasks
  74516. */
  74517. loadAsync(): Promise<void>;
  74518. }
  74519. }
  74520. declare module BABYLON {
  74521. /**
  74522. * Wrapper class for promise with external resolve and reject.
  74523. */
  74524. export class Deferred<T> {
  74525. /**
  74526. * The promise associated with this deferred object.
  74527. */
  74528. readonly promise: Promise<T>;
  74529. private _resolve;
  74530. private _reject;
  74531. /**
  74532. * The resolve method of the promise associated with this deferred object.
  74533. */
  74534. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  74535. /**
  74536. * The reject method of the promise associated with this deferred object.
  74537. */
  74538. get reject(): (reason?: any) => void;
  74539. /**
  74540. * Constructor for this deferred object.
  74541. */
  74542. constructor();
  74543. }
  74544. }
  74545. declare module BABYLON {
  74546. /**
  74547. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  74548. */
  74549. export class MeshExploder {
  74550. private _centerMesh;
  74551. private _meshes;
  74552. private _meshesOrigins;
  74553. private _toCenterVectors;
  74554. private _scaledDirection;
  74555. private _newPosition;
  74556. private _centerPosition;
  74557. /**
  74558. * Explodes meshes from a center mesh.
  74559. * @param meshes The meshes to explode.
  74560. * @param centerMesh The mesh to be center of explosion.
  74561. */
  74562. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  74563. private _setCenterMesh;
  74564. /**
  74565. * Get class name
  74566. * @returns "MeshExploder"
  74567. */
  74568. getClassName(): string;
  74569. /**
  74570. * "Exploded meshes"
  74571. * @returns Array of meshes with the centerMesh at index 0.
  74572. */
  74573. getMeshes(): Array<Mesh>;
  74574. /**
  74575. * Explodes meshes giving a specific direction
  74576. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  74577. */
  74578. explode(direction?: number): void;
  74579. }
  74580. }
  74581. declare module BABYLON {
  74582. /**
  74583. * Class used to help managing file picking and drag'n'drop
  74584. */
  74585. export class FilesInput {
  74586. /**
  74587. * List of files ready to be loaded
  74588. */
  74589. static get FilesToLoad(): {
  74590. [key: string]: File;
  74591. };
  74592. /**
  74593. * Callback called when a file is processed
  74594. */
  74595. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  74596. private _engine;
  74597. private _currentScene;
  74598. private _sceneLoadedCallback;
  74599. private _progressCallback;
  74600. private _additionalRenderLoopLogicCallback;
  74601. private _textureLoadingCallback;
  74602. private _startingProcessingFilesCallback;
  74603. private _onReloadCallback;
  74604. private _errorCallback;
  74605. private _elementToMonitor;
  74606. private _sceneFileToLoad;
  74607. private _filesToLoad;
  74608. /**
  74609. * Creates a new FilesInput
  74610. * @param engine defines the rendering engine
  74611. * @param scene defines the hosting scene
  74612. * @param sceneLoadedCallback callback called when scene is loaded
  74613. * @param progressCallback callback called to track progress
  74614. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  74615. * @param textureLoadingCallback callback called when a texture is loading
  74616. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  74617. * @param onReloadCallback callback called when a reload is requested
  74618. * @param errorCallback callback call if an error occurs
  74619. */
  74620. 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>);
  74621. private _dragEnterHandler;
  74622. private _dragOverHandler;
  74623. private _dropHandler;
  74624. /**
  74625. * Calls this function to listen to drag'n'drop events on a specific DOM element
  74626. * @param elementToMonitor defines the DOM element to track
  74627. */
  74628. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  74629. /** Gets the current list of files to load */
  74630. get filesToLoad(): File[];
  74631. /**
  74632. * Release all associated resources
  74633. */
  74634. dispose(): void;
  74635. private renderFunction;
  74636. private drag;
  74637. private drop;
  74638. private _traverseFolder;
  74639. private _processFiles;
  74640. /**
  74641. * Load files from a drop event
  74642. * @param event defines the drop event to use as source
  74643. */
  74644. loadFiles(event: any): void;
  74645. private _processReload;
  74646. /**
  74647. * Reload the current scene from the loaded files
  74648. */
  74649. reload(): void;
  74650. }
  74651. }
  74652. declare module BABYLON {
  74653. /**
  74654. * Defines the root class used to create scene optimization to use with SceneOptimizer
  74655. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74656. */
  74657. export class SceneOptimization {
  74658. /**
  74659. * Defines the priority of this optimization (0 by default which means first in the list)
  74660. */
  74661. priority: number;
  74662. /**
  74663. * Gets a string describing the action executed by the current optimization
  74664. * @returns description string
  74665. */
  74666. getDescription(): string;
  74667. /**
  74668. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74669. * @param scene defines the current scene where to apply this optimization
  74670. * @param optimizer defines the current optimizer
  74671. * @returns true if everything that can be done was applied
  74672. */
  74673. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74674. /**
  74675. * Creates the SceneOptimization object
  74676. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74677. * @param desc defines the description associated with the optimization
  74678. */
  74679. constructor(
  74680. /**
  74681. * Defines the priority of this optimization (0 by default which means first in the list)
  74682. */
  74683. priority?: number);
  74684. }
  74685. /**
  74686. * Defines an optimization used to reduce the size of render target textures
  74687. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74688. */
  74689. export class TextureOptimization extends SceneOptimization {
  74690. /**
  74691. * Defines the priority of this optimization (0 by default which means first in the list)
  74692. */
  74693. priority: number;
  74694. /**
  74695. * 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
  74696. */
  74697. maximumSize: number;
  74698. /**
  74699. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74700. */
  74701. step: number;
  74702. /**
  74703. * Gets a string describing the action executed by the current optimization
  74704. * @returns description string
  74705. */
  74706. getDescription(): string;
  74707. /**
  74708. * Creates the TextureOptimization object
  74709. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74710. * @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
  74711. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  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. * 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
  74720. */
  74721. maximumSize?: number,
  74722. /**
  74723. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74724. */
  74725. step?: number);
  74726. /**
  74727. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74728. * @param scene defines the current scene where to apply this optimization
  74729. * @param optimizer defines the current optimizer
  74730. * @returns true if everything that can be done was applied
  74731. */
  74732. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74733. }
  74734. /**
  74735. * Defines an optimization used to increase or decrease the rendering resolution
  74736. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74737. */
  74738. export class HardwareScalingOptimization extends SceneOptimization {
  74739. /**
  74740. * Defines the priority of this optimization (0 by default which means first in the list)
  74741. */
  74742. priority: number;
  74743. /**
  74744. * Defines the maximum scale to use (2 by default)
  74745. */
  74746. maximumScale: number;
  74747. /**
  74748. * Defines the step to use between two passes (0.5 by default)
  74749. */
  74750. step: number;
  74751. private _currentScale;
  74752. private _directionOffset;
  74753. /**
  74754. * Gets a string describing the action executed by the current optimization
  74755. * @return description string
  74756. */
  74757. getDescription(): string;
  74758. /**
  74759. * Creates the HardwareScalingOptimization object
  74760. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74761. * @param maximumScale defines the maximum scale to use (2 by default)
  74762. * @param step defines the step to use between two passes (0.5 by default)
  74763. */
  74764. constructor(
  74765. /**
  74766. * Defines the priority of this optimization (0 by default which means first in the list)
  74767. */
  74768. priority?: number,
  74769. /**
  74770. * Defines the maximum scale to use (2 by default)
  74771. */
  74772. maximumScale?: number,
  74773. /**
  74774. * Defines the step to use between two passes (0.5 by default)
  74775. */
  74776. step?: number);
  74777. /**
  74778. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74779. * @param scene defines the current scene where to apply this optimization
  74780. * @param optimizer defines the current optimizer
  74781. * @returns true if everything that can be done was applied
  74782. */
  74783. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74784. }
  74785. /**
  74786. * Defines an optimization used to remove shadows
  74787. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74788. */
  74789. export class ShadowsOptimization extends SceneOptimization {
  74790. /**
  74791. * Gets a string describing the action executed by the current optimization
  74792. * @return description string
  74793. */
  74794. getDescription(): string;
  74795. /**
  74796. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74797. * @param scene defines the current scene where to apply this optimization
  74798. * @param optimizer defines the current optimizer
  74799. * @returns true if everything that can be done was applied
  74800. */
  74801. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74802. }
  74803. /**
  74804. * Defines an optimization used to turn post-processes off
  74805. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74806. */
  74807. export class PostProcessesOptimization extends SceneOptimization {
  74808. /**
  74809. * Gets a string describing the action executed by the current optimization
  74810. * @return description string
  74811. */
  74812. getDescription(): string;
  74813. /**
  74814. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74815. * @param scene defines the current scene where to apply this optimization
  74816. * @param optimizer defines the current optimizer
  74817. * @returns true if everything that can be done was applied
  74818. */
  74819. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74820. }
  74821. /**
  74822. * Defines an optimization used to turn lens flares off
  74823. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74824. */
  74825. export class LensFlaresOptimization extends SceneOptimization {
  74826. /**
  74827. * Gets a string describing the action executed by the current optimization
  74828. * @return description string
  74829. */
  74830. getDescription(): string;
  74831. /**
  74832. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74833. * @param scene defines the current scene where to apply this optimization
  74834. * @param optimizer defines the current optimizer
  74835. * @returns true if everything that can be done was applied
  74836. */
  74837. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74838. }
  74839. /**
  74840. * Defines an optimization based on user defined callback.
  74841. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74842. */
  74843. export class CustomOptimization extends SceneOptimization {
  74844. /**
  74845. * Callback called to apply the custom optimization.
  74846. */
  74847. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  74848. /**
  74849. * Callback called to get custom description
  74850. */
  74851. onGetDescription: () => string;
  74852. /**
  74853. * Gets a string describing the action executed by the current optimization
  74854. * @returns description string
  74855. */
  74856. getDescription(): string;
  74857. /**
  74858. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74859. * @param scene defines the current scene where to apply this optimization
  74860. * @param optimizer defines the current optimizer
  74861. * @returns true if everything that can be done was applied
  74862. */
  74863. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74864. }
  74865. /**
  74866. * Defines an optimization used to turn particles off
  74867. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74868. */
  74869. export class ParticlesOptimization extends SceneOptimization {
  74870. /**
  74871. * Gets a string describing the action executed by the current optimization
  74872. * @return description string
  74873. */
  74874. getDescription(): string;
  74875. /**
  74876. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74877. * @param scene defines the current scene where to apply this optimization
  74878. * @param optimizer defines the current optimizer
  74879. * @returns true if everything that can be done was applied
  74880. */
  74881. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74882. }
  74883. /**
  74884. * Defines an optimization used to turn render targets off
  74885. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74886. */
  74887. export class RenderTargetsOptimization extends SceneOptimization {
  74888. /**
  74889. * Gets a string describing the action executed by the current optimization
  74890. * @return description string
  74891. */
  74892. getDescription(): string;
  74893. /**
  74894. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74895. * @param scene defines the current scene where to apply this optimization
  74896. * @param optimizer defines the current optimizer
  74897. * @returns true if everything that can be done was applied
  74898. */
  74899. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74900. }
  74901. /**
  74902. * Defines an optimization used to merge meshes with compatible materials
  74903. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74904. */
  74905. export class MergeMeshesOptimization extends SceneOptimization {
  74906. private static _UpdateSelectionTree;
  74907. /**
  74908. * Gets or sets a boolean which defines if optimization octree has to be updated
  74909. */
  74910. static get UpdateSelectionTree(): boolean;
  74911. /**
  74912. * Gets or sets a boolean which defines if optimization octree has to be updated
  74913. */
  74914. static set UpdateSelectionTree(value: boolean);
  74915. /**
  74916. * Gets a string describing the action executed by the current optimization
  74917. * @return description string
  74918. */
  74919. getDescription(): string;
  74920. private _canBeMerged;
  74921. /**
  74922. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74923. * @param scene defines the current scene where to apply this optimization
  74924. * @param optimizer defines the current optimizer
  74925. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  74926. * @returns true if everything that can be done was applied
  74927. */
  74928. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  74929. }
  74930. /**
  74931. * Defines a list of options used by SceneOptimizer
  74932. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74933. */
  74934. export class SceneOptimizerOptions {
  74935. /**
  74936. * Defines the target frame rate to reach (60 by default)
  74937. */
  74938. targetFrameRate: number;
  74939. /**
  74940. * Defines the interval between two checkes (2000ms by default)
  74941. */
  74942. trackerDuration: number;
  74943. /**
  74944. * Gets the list of optimizations to apply
  74945. */
  74946. optimizations: SceneOptimization[];
  74947. /**
  74948. * Creates a new list of options used by SceneOptimizer
  74949. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  74950. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  74951. */
  74952. constructor(
  74953. /**
  74954. * Defines the target frame rate to reach (60 by default)
  74955. */
  74956. targetFrameRate?: number,
  74957. /**
  74958. * Defines the interval between two checkes (2000ms by default)
  74959. */
  74960. trackerDuration?: number);
  74961. /**
  74962. * Add a new optimization
  74963. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  74964. * @returns the current SceneOptimizerOptions
  74965. */
  74966. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  74967. /**
  74968. * Add a new custom optimization
  74969. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  74970. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  74971. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74972. * @returns the current SceneOptimizerOptions
  74973. */
  74974. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  74975. /**
  74976. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  74977. * @param targetFrameRate defines the target frame rate (60 by default)
  74978. * @returns a SceneOptimizerOptions object
  74979. */
  74980. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74981. /**
  74982. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  74983. * @param targetFrameRate defines the target frame rate (60 by default)
  74984. * @returns a SceneOptimizerOptions object
  74985. */
  74986. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74987. /**
  74988. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  74989. * @param targetFrameRate defines the target frame rate (60 by default)
  74990. * @returns a SceneOptimizerOptions object
  74991. */
  74992. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74993. }
  74994. /**
  74995. * Class used to run optimizations in order to reach a target frame rate
  74996. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74997. */
  74998. export class SceneOptimizer implements IDisposable {
  74999. private _isRunning;
  75000. private _options;
  75001. private _scene;
  75002. private _currentPriorityLevel;
  75003. private _targetFrameRate;
  75004. private _trackerDuration;
  75005. private _currentFrameRate;
  75006. private _sceneDisposeObserver;
  75007. private _improvementMode;
  75008. /**
  75009. * Defines an observable called when the optimizer reaches the target frame rate
  75010. */
  75011. onSuccessObservable: Observable<SceneOptimizer>;
  75012. /**
  75013. * Defines an observable called when the optimizer enables an optimization
  75014. */
  75015. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  75016. /**
  75017. * Defines an observable called when the optimizer is not able to reach the target frame rate
  75018. */
  75019. onFailureObservable: Observable<SceneOptimizer>;
  75020. /**
  75021. * Gets a boolean indicating if the optimizer is in improvement mode
  75022. */
  75023. get isInImprovementMode(): boolean;
  75024. /**
  75025. * Gets the current priority level (0 at start)
  75026. */
  75027. get currentPriorityLevel(): number;
  75028. /**
  75029. * Gets the current frame rate checked by the SceneOptimizer
  75030. */
  75031. get currentFrameRate(): number;
  75032. /**
  75033. * Gets or sets the current target frame rate (60 by default)
  75034. */
  75035. get targetFrameRate(): number;
  75036. /**
  75037. * Gets or sets the current target frame rate (60 by default)
  75038. */
  75039. set targetFrameRate(value: number);
  75040. /**
  75041. * Gets or sets the current interval between two checks (every 2000ms by default)
  75042. */
  75043. get trackerDuration(): number;
  75044. /**
  75045. * Gets or sets the current interval between two checks (every 2000ms by default)
  75046. */
  75047. set trackerDuration(value: number);
  75048. /**
  75049. * Gets the list of active optimizations
  75050. */
  75051. get optimizations(): SceneOptimization[];
  75052. /**
  75053. * Creates a new SceneOptimizer
  75054. * @param scene defines the scene to work on
  75055. * @param options defines the options to use with the SceneOptimizer
  75056. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  75057. * @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)
  75058. */
  75059. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  75060. /**
  75061. * Stops the current optimizer
  75062. */
  75063. stop(): void;
  75064. /**
  75065. * Reset the optimizer to initial step (current priority level = 0)
  75066. */
  75067. reset(): void;
  75068. /**
  75069. * Start the optimizer. By default it will try to reach a specific framerate
  75070. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  75071. */
  75072. start(): void;
  75073. private _checkCurrentState;
  75074. /**
  75075. * Release all resources
  75076. */
  75077. dispose(): void;
  75078. /**
  75079. * Helper function to create a SceneOptimizer with one single line of code
  75080. * @param scene defines the scene to work on
  75081. * @param options defines the options to use with the SceneOptimizer
  75082. * @param onSuccess defines a callback to call on success
  75083. * @param onFailure defines a callback to call on failure
  75084. * @returns the new SceneOptimizer object
  75085. */
  75086. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  75087. }
  75088. }
  75089. declare module BABYLON {
  75090. /**
  75091. * Class used to serialize a scene into a string
  75092. */
  75093. export class SceneSerializer {
  75094. /**
  75095. * Clear cache used by a previous serialization
  75096. */
  75097. static ClearCache(): void;
  75098. /**
  75099. * Serialize a scene into a JSON compatible object
  75100. * @param scene defines the scene to serialize
  75101. * @returns a JSON compatible object
  75102. */
  75103. static Serialize(scene: Scene): any;
  75104. /**
  75105. * Serialize a mesh into a JSON compatible object
  75106. * @param toSerialize defines the mesh to serialize
  75107. * @param withParents defines if parents must be serialized as well
  75108. * @param withChildren defines if children must be serialized as well
  75109. * @returns a JSON compatible object
  75110. */
  75111. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  75112. }
  75113. }
  75114. declare module BABYLON {
  75115. /**
  75116. * Class used to host texture specific utilities
  75117. */
  75118. export class TextureTools {
  75119. /**
  75120. * Uses the GPU to create a copy texture rescaled at a given size
  75121. * @param texture Texture to copy from
  75122. * @param width defines the desired width
  75123. * @param height defines the desired height
  75124. * @param useBilinearMode defines if bilinear mode has to be used
  75125. * @return the generated texture
  75126. */
  75127. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  75128. }
  75129. }
  75130. declare module BABYLON {
  75131. /**
  75132. * This represents the different options available for the video capture.
  75133. */
  75134. export interface VideoRecorderOptions {
  75135. /** Defines the mime type of the video. */
  75136. mimeType: string;
  75137. /** Defines the FPS the video should be recorded at. */
  75138. fps: number;
  75139. /** Defines the chunk size for the recording data. */
  75140. recordChunckSize: number;
  75141. /** The audio tracks to attach to the recording. */
  75142. audioTracks?: MediaStreamTrack[];
  75143. }
  75144. /**
  75145. * This can help with recording videos from BabylonJS.
  75146. * This is based on the available WebRTC functionalities of the browser.
  75147. *
  75148. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  75149. */
  75150. export class VideoRecorder {
  75151. private static readonly _defaultOptions;
  75152. /**
  75153. * Returns whether or not the VideoRecorder is available in your browser.
  75154. * @param engine Defines the Babylon Engine.
  75155. * @returns true if supported otherwise false.
  75156. */
  75157. static IsSupported(engine: Engine): boolean;
  75158. private readonly _options;
  75159. private _canvas;
  75160. private _mediaRecorder;
  75161. private _recordedChunks;
  75162. private _fileName;
  75163. private _resolve;
  75164. private _reject;
  75165. /**
  75166. * True when a recording is already in progress.
  75167. */
  75168. get isRecording(): boolean;
  75169. /**
  75170. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  75171. * @param engine Defines the BabylonJS Engine you wish to record.
  75172. * @param options Defines options that can be used to customize the capture.
  75173. */
  75174. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  75175. /**
  75176. * Stops the current recording before the default capture timeout passed in the startRecording function.
  75177. */
  75178. stopRecording(): void;
  75179. /**
  75180. * Starts recording the canvas for a max duration specified in parameters.
  75181. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  75182. * If null no automatic download will start and you can rely on the promise to get the data back.
  75183. * @param maxDuration Defines the maximum recording time in seconds.
  75184. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  75185. * @return A promise callback at the end of the recording with the video data in Blob.
  75186. */
  75187. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  75188. /**
  75189. * Releases internal resources used during the recording.
  75190. */
  75191. dispose(): void;
  75192. private _handleDataAvailable;
  75193. private _handleError;
  75194. private _handleStop;
  75195. }
  75196. }
  75197. declare module BABYLON {
  75198. /**
  75199. * Class containing a set of static utilities functions for screenshots
  75200. */
  75201. export class ScreenshotTools {
  75202. /**
  75203. * Captures a screenshot of the current rendering
  75204. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75205. * @param engine defines the rendering engine
  75206. * @param camera defines the source camera
  75207. * @param size This parameter can be set to a single number or to an object with the
  75208. * following (optional) properties: precision, width, height. If a single number is passed,
  75209. * it will be used for both width and height. If an object is passed, the screenshot size
  75210. * will be derived from the parameters. The precision property is a multiplier allowing
  75211. * rendering at a higher or lower resolution
  75212. * @param successCallback defines the callback receives a single parameter which contains the
  75213. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  75214. * src parameter of an <img> to display it
  75215. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  75216. * Check your browser for supported MIME types
  75217. */
  75218. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  75219. /**
  75220. * Captures a screenshot of the current rendering
  75221. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75222. * @param engine defines the rendering engine
  75223. * @param camera defines the source camera
  75224. * @param size This parameter can be set to a single number or to an object with the
  75225. * following (optional) properties: precision, width, height. If a single number is passed,
  75226. * it will be used for both width and height. If an object is passed, the screenshot size
  75227. * will be derived from the parameters. The precision property is a multiplier allowing
  75228. * rendering at a higher or lower resolution
  75229. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  75230. * Check your browser for supported MIME types
  75231. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  75232. * to the src parameter of an <img> to display it
  75233. */
  75234. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  75235. /**
  75236. * Generates an image screenshot from the specified camera.
  75237. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75238. * @param engine The engine to use for rendering
  75239. * @param camera The camera to use for rendering
  75240. * @param size This parameter can be set to a single number or to an object with the
  75241. * following (optional) properties: precision, width, height. If a single number is passed,
  75242. * it will be used for both width and height. If an object is passed, the screenshot size
  75243. * will be derived from the parameters. The precision property is a multiplier allowing
  75244. * rendering at a higher or lower resolution
  75245. * @param successCallback The callback receives a single parameter which contains the
  75246. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  75247. * src parameter of an <img> to display it
  75248. * @param mimeType The MIME type of the screenshot image (default: image/png).
  75249. * Check your browser for supported MIME types
  75250. * @param samples Texture samples (default: 1)
  75251. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  75252. * @param fileName A name for for the downloaded file.
  75253. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  75254. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  75255. */
  75256. 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;
  75257. /**
  75258. * Generates an image screenshot from the specified camera.
  75259. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75260. * @param engine The engine to use for rendering
  75261. * @param camera The camera to use for rendering
  75262. * @param size This parameter can be set to a single number or to an object with the
  75263. * following (optional) properties: precision, width, height. If a single number is passed,
  75264. * it will be used for both width and height. If an object is passed, the screenshot size
  75265. * will be derived from the parameters. The precision property is a multiplier allowing
  75266. * rendering at a higher or lower resolution
  75267. * @param mimeType The MIME type of the screenshot image (default: image/png).
  75268. * Check your browser for supported MIME types
  75269. * @param samples Texture samples (default: 1)
  75270. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  75271. * @param fileName A name for for the downloaded file.
  75272. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  75273. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  75274. * to the src parameter of an <img> to display it
  75275. */
  75276. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  75277. /**
  75278. * Gets height and width for screenshot size
  75279. * @private
  75280. */
  75281. private static _getScreenshotSize;
  75282. }
  75283. }
  75284. declare module BABYLON {
  75285. /**
  75286. * Interface for a data buffer
  75287. */
  75288. export interface IDataBuffer {
  75289. /**
  75290. * Reads bytes from the data buffer.
  75291. * @param byteOffset The byte offset to read
  75292. * @param byteLength The byte length to read
  75293. * @returns A promise that resolves when the bytes are read
  75294. */
  75295. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  75296. /**
  75297. * The byte length of the buffer.
  75298. */
  75299. readonly byteLength: number;
  75300. }
  75301. /**
  75302. * Utility class for reading from a data buffer
  75303. */
  75304. export class DataReader {
  75305. /**
  75306. * The data buffer associated with this data reader.
  75307. */
  75308. readonly buffer: IDataBuffer;
  75309. /**
  75310. * The current byte offset from the beginning of the data buffer.
  75311. */
  75312. byteOffset: number;
  75313. private _dataView;
  75314. private _dataByteOffset;
  75315. /**
  75316. * Constructor
  75317. * @param buffer The buffer to read
  75318. */
  75319. constructor(buffer: IDataBuffer);
  75320. /**
  75321. * Loads the given byte length.
  75322. * @param byteLength The byte length to load
  75323. * @returns A promise that resolves when the load is complete
  75324. */
  75325. loadAsync(byteLength: number): Promise<void>;
  75326. /**
  75327. * Read a unsigned 32-bit integer from the currently loaded data range.
  75328. * @returns The 32-bit integer read
  75329. */
  75330. readUint32(): number;
  75331. /**
  75332. * Read a byte array from the currently loaded data range.
  75333. * @param byteLength The byte length to read
  75334. * @returns The byte array read
  75335. */
  75336. readUint8Array(byteLength: number): Uint8Array;
  75337. /**
  75338. * Read a string from the currently loaded data range.
  75339. * @param byteLength The byte length to read
  75340. * @returns The string read
  75341. */
  75342. readString(byteLength: number): string;
  75343. /**
  75344. * Skips the given byte length the currently loaded data range.
  75345. * @param byteLength The byte length to skip
  75346. */
  75347. skipBytes(byteLength: number): void;
  75348. }
  75349. }
  75350. declare module BABYLON {
  75351. /**
  75352. * Class for storing data to local storage if available or in-memory storage otherwise
  75353. */
  75354. export class DataStorage {
  75355. private static _Storage;
  75356. private static _GetStorage;
  75357. /**
  75358. * Reads a string from the data storage
  75359. * @param key The key to read
  75360. * @param defaultValue The value if the key doesn't exist
  75361. * @returns The string value
  75362. */
  75363. static ReadString(key: string, defaultValue: string): string;
  75364. /**
  75365. * Writes a string to the data storage
  75366. * @param key The key to write
  75367. * @param value The value to write
  75368. */
  75369. static WriteString(key: string, value: string): void;
  75370. /**
  75371. * Reads a boolean from the data storage
  75372. * @param key The key to read
  75373. * @param defaultValue The value if the key doesn't exist
  75374. * @returns The boolean value
  75375. */
  75376. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  75377. /**
  75378. * Writes a boolean to the data storage
  75379. * @param key The key to write
  75380. * @param value The value to write
  75381. */
  75382. static WriteBoolean(key: string, value: boolean): void;
  75383. /**
  75384. * Reads a number from the data storage
  75385. * @param key The key to read
  75386. * @param defaultValue The value if the key doesn't exist
  75387. * @returns The number value
  75388. */
  75389. static ReadNumber(key: string, defaultValue: number): number;
  75390. /**
  75391. * Writes a number to the data storage
  75392. * @param key The key to write
  75393. * @param value The value to write
  75394. */
  75395. static WriteNumber(key: string, value: number): void;
  75396. }
  75397. }
  75398. declare module BABYLON {
  75399. /**
  75400. * Class used to record delta files between 2 scene states
  75401. */
  75402. export class SceneRecorder {
  75403. private _trackedScene;
  75404. private _savedJSON;
  75405. /**
  75406. * Track a given scene. This means the current scene state will be considered the original state
  75407. * @param scene defines the scene to track
  75408. */
  75409. track(scene: Scene): void;
  75410. /**
  75411. * Get the delta between current state and original state
  75412. * @returns a string containing the delta
  75413. */
  75414. getDelta(): any;
  75415. private _compareArray;
  75416. private _compareObjects;
  75417. private _compareCollections;
  75418. private static GetShadowGeneratorById;
  75419. /**
  75420. * Apply a given delta to a given scene
  75421. * @param deltaJSON defines the JSON containing the delta
  75422. * @param scene defines the scene to apply the delta to
  75423. */
  75424. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  75425. private static _ApplyPropertiesToEntity;
  75426. private static _ApplyDeltaForEntity;
  75427. }
  75428. }
  75429. declare module BABYLON {
  75430. /**
  75431. * A 3D trajectory consisting of an order list of vectors describing a
  75432. * path of motion through 3D space.
  75433. */
  75434. export class Trajectory {
  75435. private _points;
  75436. private readonly _segmentLength;
  75437. /**
  75438. * Serialize to JSON.
  75439. * @returns serialized JSON string
  75440. */
  75441. serialize(): string;
  75442. /**
  75443. * Deserialize from JSON.
  75444. * @param json serialized JSON string
  75445. * @returns deserialized Trajectory
  75446. */
  75447. static Deserialize(json: string): Trajectory;
  75448. /**
  75449. * Create a new empty Trajectory.
  75450. * @param segmentLength radius of discretization for Trajectory points
  75451. */
  75452. constructor(segmentLength?: number);
  75453. /**
  75454. * Get the length of the Trajectory.
  75455. * @returns length of the Trajectory
  75456. */
  75457. getLength(): number;
  75458. /**
  75459. * Append a new point to the Trajectory.
  75460. * NOTE: This implementation has many allocations.
  75461. * @param point point to append to the Trajectory
  75462. */
  75463. add(point: DeepImmutable<Vector3>): void;
  75464. /**
  75465. * Create a new Trajectory with a segment length chosen to make it
  75466. * probable that the new Trajectory will have a specified number of
  75467. * segments. This operation is imprecise.
  75468. * @param targetResolution number of segments desired
  75469. * @returns new Trajectory with approximately the requested number of segments
  75470. */
  75471. resampleAtTargetResolution(targetResolution: number): Trajectory;
  75472. /**
  75473. * Convert Trajectory segments into tokenized representation. This
  75474. * representation is an array of numbers where each nth number is the
  75475. * index of the token which is most similar to the nth segment of the
  75476. * Trajectory.
  75477. * @param tokens list of vectors which serve as discrete tokens
  75478. * @returns list of indices of most similar token per segment
  75479. */
  75480. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  75481. private static _forwardDir;
  75482. private static _inverseFromVec;
  75483. private static _upDir;
  75484. private static _fromToVec;
  75485. private static _lookMatrix;
  75486. /**
  75487. * Transform the rotation (i.e., direction) of a segment to isolate
  75488. * the relative transformation represented by the segment. This operation
  75489. * may or may not succeed due to singularities in the equations that define
  75490. * motion relativity in this context.
  75491. * @param priorVec the origin of the prior segment
  75492. * @param fromVec the origin of the current segment
  75493. * @param toVec the destination of the current segment
  75494. * @param result reference to output variable
  75495. * @returns whether or not transformation was successful
  75496. */
  75497. private static _transformSegmentDirToRef;
  75498. private static _bestMatch;
  75499. private static _score;
  75500. private static _bestScore;
  75501. /**
  75502. * Determine which token vector is most similar to the
  75503. * segment vector.
  75504. * @param segment segment vector
  75505. * @param tokens token vector list
  75506. * @returns index of the most similar token to the segment
  75507. */
  75508. private static _tokenizeSegment;
  75509. }
  75510. /**
  75511. * Class representing a set of known, named trajectories to which Trajectories can be
  75512. * added and using which Trajectories can be recognized.
  75513. */
  75514. export class TrajectoryClassifier {
  75515. private _maximumAllowableMatchCost;
  75516. private _vector3Alphabet;
  75517. private _levenshteinAlphabet;
  75518. private _nameToDescribedTrajectory;
  75519. /**
  75520. * Serialize to JSON.
  75521. * @returns JSON serialization
  75522. */
  75523. serialize(): string;
  75524. /**
  75525. * Deserialize from JSON.
  75526. * @param json JSON serialization
  75527. * @returns deserialized TrajectorySet
  75528. */
  75529. static Deserialize(json: string): TrajectoryClassifier;
  75530. /**
  75531. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  75532. * VERY naive, need to be generating these things from known
  75533. * sets. Better version later, probably eliminating this one.
  75534. * @returns auto-generated TrajectorySet
  75535. */
  75536. static Generate(): TrajectoryClassifier;
  75537. private constructor();
  75538. /**
  75539. * Add a new Trajectory to the set with a given name.
  75540. * @param trajectory new Trajectory to be added
  75541. * @param classification name to which to add the Trajectory
  75542. */
  75543. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  75544. /**
  75545. * Remove a known named trajectory and all Trajectories associated with it.
  75546. * @param classification name to remove
  75547. * @returns whether anything was removed
  75548. */
  75549. deleteClassification(classification: string): boolean;
  75550. /**
  75551. * Attempt to recognize a Trajectory from among all the classifications
  75552. * already known to the classifier.
  75553. * @param trajectory Trajectory to be recognized
  75554. * @returns classification of Trajectory if recognized, null otherwise
  75555. */
  75556. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  75557. }
  75558. }
  75559. declare module BABYLON {
  75560. /**
  75561. * An interface for all Hit test features
  75562. */
  75563. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  75564. /**
  75565. * Triggered when new babylon (transformed) hit test results are available
  75566. */
  75567. onHitTestResultObservable: Observable<T[]>;
  75568. }
  75569. /**
  75570. * Options used for hit testing
  75571. */
  75572. export interface IWebXRLegacyHitTestOptions {
  75573. /**
  75574. * Only test when user interacted with the scene. Default - hit test every frame
  75575. */
  75576. testOnPointerDownOnly?: boolean;
  75577. /**
  75578. * The node to use to transform the local results to world coordinates
  75579. */
  75580. worldParentNode?: TransformNode;
  75581. }
  75582. /**
  75583. * Interface defining the babylon result of raycasting/hit-test
  75584. */
  75585. export interface IWebXRLegacyHitResult {
  75586. /**
  75587. * Transformation matrix that can be applied to a node that will put it in the hit point location
  75588. */
  75589. transformationMatrix: Matrix;
  75590. /**
  75591. * The native hit test result
  75592. */
  75593. xrHitResult: XRHitResult | XRHitTestResult;
  75594. }
  75595. /**
  75596. * The currently-working hit-test module.
  75597. * Hit test (or Ray-casting) is used to interact with the real world.
  75598. * For further information read here - https://github.com/immersive-web/hit-test
  75599. */
  75600. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  75601. /**
  75602. * options to use when constructing this feature
  75603. */
  75604. readonly options: IWebXRLegacyHitTestOptions;
  75605. private _direction;
  75606. private _mat;
  75607. private _onSelectEnabled;
  75608. private _origin;
  75609. /**
  75610. * The module's name
  75611. */
  75612. static readonly Name: string;
  75613. /**
  75614. * The (Babylon) version of this module.
  75615. * This is an integer representing the implementation version.
  75616. * This number does not correspond to the WebXR specs version
  75617. */
  75618. static readonly Version: number;
  75619. /**
  75620. * Populated with the last native XR Hit Results
  75621. */
  75622. lastNativeXRHitResults: XRHitResult[];
  75623. /**
  75624. * Triggered when new babylon (transformed) hit test results are available
  75625. */
  75626. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  75627. /**
  75628. * Creates a new instance of the (legacy version) hit test feature
  75629. * @param _xrSessionManager an instance of WebXRSessionManager
  75630. * @param options options to use when constructing this feature
  75631. */
  75632. constructor(_xrSessionManager: WebXRSessionManager,
  75633. /**
  75634. * options to use when constructing this feature
  75635. */
  75636. options?: IWebXRLegacyHitTestOptions);
  75637. /**
  75638. * execute a hit test with an XR Ray
  75639. *
  75640. * @param xrSession a native xrSession that will execute this hit test
  75641. * @param xrRay the ray (position and direction) to use for ray-casting
  75642. * @param referenceSpace native XR reference space to use for the hit-test
  75643. * @param filter filter function that will filter the results
  75644. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  75645. */
  75646. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  75647. /**
  75648. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  75649. * @param event the (select) event to use to select with
  75650. * @param referenceSpace the reference space to use for this hit test
  75651. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  75652. */
  75653. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  75654. /**
  75655. * attach this feature
  75656. * Will usually be called by the features manager
  75657. *
  75658. * @returns true if successful.
  75659. */
  75660. attach(): boolean;
  75661. /**
  75662. * detach this feature.
  75663. * Will usually be called by the features manager
  75664. *
  75665. * @returns true if successful.
  75666. */
  75667. detach(): boolean;
  75668. /**
  75669. * Dispose this feature and all of the resources attached
  75670. */
  75671. dispose(): void;
  75672. protected _onXRFrame(frame: XRFrame): void;
  75673. private _onHitTestResults;
  75674. private _onSelect;
  75675. }
  75676. }
  75677. declare module BABYLON {
  75678. /**
  75679. * Options used for hit testing (version 2)
  75680. */
  75681. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  75682. /**
  75683. * Do not create a permanent hit test. Will usually be used when only
  75684. * transient inputs are needed.
  75685. */
  75686. disablePermanentHitTest?: boolean;
  75687. /**
  75688. * Enable transient (for example touch-based) hit test inspections
  75689. */
  75690. enableTransientHitTest?: boolean;
  75691. /**
  75692. * Offset ray for the permanent hit test
  75693. */
  75694. offsetRay?: Vector3;
  75695. /**
  75696. * Offset ray for the transient hit test
  75697. */
  75698. transientOffsetRay?: Vector3;
  75699. /**
  75700. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  75701. */
  75702. useReferenceSpace?: boolean;
  75703. /**
  75704. * Override the default entity type(s) of the hit-test result
  75705. */
  75706. entityTypes?: XRHitTestTrackableType[];
  75707. }
  75708. /**
  75709. * Interface defining the babylon result of hit-test
  75710. */
  75711. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  75712. /**
  75713. * The input source that generated this hit test (if transient)
  75714. */
  75715. inputSource?: XRInputSource;
  75716. /**
  75717. * Is this a transient hit test
  75718. */
  75719. isTransient?: boolean;
  75720. /**
  75721. * Position of the hit test result
  75722. */
  75723. position: Vector3;
  75724. /**
  75725. * Rotation of the hit test result
  75726. */
  75727. rotationQuaternion: Quaternion;
  75728. /**
  75729. * The native hit test result
  75730. */
  75731. xrHitResult: XRHitTestResult;
  75732. }
  75733. /**
  75734. * The currently-working hit-test module.
  75735. * Hit test (or Ray-casting) is used to interact with the real world.
  75736. * For further information read here - https://github.com/immersive-web/hit-test
  75737. *
  75738. * Tested on chrome (mobile) 80.
  75739. */
  75740. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  75741. /**
  75742. * options to use when constructing this feature
  75743. */
  75744. readonly options: IWebXRHitTestOptions;
  75745. private _tmpMat;
  75746. private _tmpPos;
  75747. private _tmpQuat;
  75748. private _transientXrHitTestSource;
  75749. private _xrHitTestSource;
  75750. private initHitTestSource;
  75751. /**
  75752. * The module's name
  75753. */
  75754. static readonly Name: string;
  75755. /**
  75756. * The (Babylon) version of this module.
  75757. * This is an integer representing the implementation version.
  75758. * This number does not correspond to the WebXR specs version
  75759. */
  75760. static readonly Version: number;
  75761. /**
  75762. * When set to true, each hit test will have its own position/rotation objects
  75763. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  75764. * the developers will clone them or copy them as they see fit.
  75765. */
  75766. autoCloneTransformation: boolean;
  75767. /**
  75768. * Triggered when new babylon (transformed) hit test results are available
  75769. * Note - this will be called when results come back from the device. It can be an empty array!!
  75770. */
  75771. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  75772. /**
  75773. * Use this to temporarily pause hit test checks.
  75774. */
  75775. paused: boolean;
  75776. /**
  75777. * Creates a new instance of the hit test feature
  75778. * @param _xrSessionManager an instance of WebXRSessionManager
  75779. * @param options options to use when constructing this feature
  75780. */
  75781. constructor(_xrSessionManager: WebXRSessionManager,
  75782. /**
  75783. * options to use when constructing this feature
  75784. */
  75785. options?: IWebXRHitTestOptions);
  75786. /**
  75787. * attach this feature
  75788. * Will usually be called by the features manager
  75789. *
  75790. * @returns true if successful.
  75791. */
  75792. attach(): boolean;
  75793. /**
  75794. * detach this feature.
  75795. * Will usually be called by the features manager
  75796. *
  75797. * @returns true if successful.
  75798. */
  75799. detach(): boolean;
  75800. /**
  75801. * Dispose this feature and all of the resources attached
  75802. */
  75803. dispose(): void;
  75804. protected _onXRFrame(frame: XRFrame): void;
  75805. private _processWebXRHitTestResult;
  75806. }
  75807. }
  75808. declare module BABYLON {
  75809. /**
  75810. * Configuration options of the anchor system
  75811. */
  75812. export interface IWebXRAnchorSystemOptions {
  75813. /**
  75814. * a node that will be used to convert local to world coordinates
  75815. */
  75816. worldParentNode?: TransformNode;
  75817. /**
  75818. * If set to true a reference of the created anchors will be kept until the next session starts
  75819. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  75820. */
  75821. doNotRemoveAnchorsOnSessionEnded?: boolean;
  75822. }
  75823. /**
  75824. * A babylon container for an XR Anchor
  75825. */
  75826. export interface IWebXRAnchor {
  75827. /**
  75828. * A babylon-assigned ID for this anchor
  75829. */
  75830. id: number;
  75831. /**
  75832. * Transformation matrix to apply to an object attached to this anchor
  75833. */
  75834. transformationMatrix: Matrix;
  75835. /**
  75836. * The native anchor object
  75837. */
  75838. xrAnchor: XRAnchor;
  75839. /**
  75840. * if defined, this object will be constantly updated by the anchor's position and rotation
  75841. */
  75842. attachedNode?: TransformNode;
  75843. }
  75844. /**
  75845. * An implementation of the anchor system for WebXR.
  75846. * For further information see https://github.com/immersive-web/anchors/
  75847. */
  75848. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  75849. private _options;
  75850. private _lastFrameDetected;
  75851. private _trackedAnchors;
  75852. private _referenceSpaceForFrameAnchors;
  75853. private _futureAnchors;
  75854. /**
  75855. * The module's name
  75856. */
  75857. static readonly Name: string;
  75858. /**
  75859. * The (Babylon) version of this module.
  75860. * This is an integer representing the implementation version.
  75861. * This number does not correspond to the WebXR specs version
  75862. */
  75863. static readonly Version: number;
  75864. /**
  75865. * Observers registered here will be executed when a new anchor was added to the session
  75866. */
  75867. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  75868. /**
  75869. * Observers registered here will be executed when an anchor was removed from the session
  75870. */
  75871. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  75872. /**
  75873. * Observers registered here will be executed when an existing anchor updates
  75874. * This can execute N times every frame
  75875. */
  75876. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  75877. /**
  75878. * Set the reference space to use for anchor creation, when not using a hit test.
  75879. * Will default to the session's reference space if not defined
  75880. */
  75881. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  75882. /**
  75883. * constructs a new anchor system
  75884. * @param _xrSessionManager an instance of WebXRSessionManager
  75885. * @param _options configuration object for this feature
  75886. */
  75887. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  75888. private _tmpVector;
  75889. private _tmpQuaternion;
  75890. private _populateTmpTransformation;
  75891. /**
  75892. * Create a new anchor point using a hit test result at a specific point in the scene
  75893. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  75894. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  75895. *
  75896. * @param hitTestResult The hit test result to use for this anchor creation
  75897. * @param position an optional position offset for this anchor
  75898. * @param rotationQuaternion an optional rotation offset for this anchor
  75899. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  75900. */
  75901. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  75902. /**
  75903. * Add a new anchor at a specific position and rotation
  75904. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  75905. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  75906. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  75907. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  75908. *
  75909. * @param position the position in which to add an anchor
  75910. * @param rotationQuaternion an optional rotation for the anchor transformation
  75911. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  75912. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  75913. */
  75914. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  75915. /**
  75916. * detach this feature.
  75917. * Will usually be called by the features manager
  75918. *
  75919. * @returns true if successful.
  75920. */
  75921. detach(): boolean;
  75922. /**
  75923. * Dispose this feature and all of the resources attached
  75924. */
  75925. dispose(): void;
  75926. protected _onXRFrame(frame: XRFrame): void;
  75927. /**
  75928. * avoiding using Array.find for global support.
  75929. * @param xrAnchor the plane to find in the array
  75930. */
  75931. private _findIndexInAnchorArray;
  75932. private _updateAnchorWithXRFrame;
  75933. private _createAnchorAtTransformation;
  75934. }
  75935. }
  75936. declare module BABYLON {
  75937. /**
  75938. * Options used in the plane detector module
  75939. */
  75940. export interface IWebXRPlaneDetectorOptions {
  75941. /**
  75942. * The node to use to transform the local results to world coordinates
  75943. */
  75944. worldParentNode?: TransformNode;
  75945. /**
  75946. * If set to true a reference of the created planes will be kept until the next session starts
  75947. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  75948. */
  75949. doNotRemovePlanesOnSessionEnded?: boolean;
  75950. }
  75951. /**
  75952. * A babylon interface for a WebXR plane.
  75953. * A Plane is actually a polygon, built from N points in space
  75954. *
  75955. * Supported in chrome 79, not supported in canary 81 ATM
  75956. */
  75957. export interface IWebXRPlane {
  75958. /**
  75959. * a babylon-assigned ID for this polygon
  75960. */
  75961. id: number;
  75962. /**
  75963. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  75964. */
  75965. polygonDefinition: Array<Vector3>;
  75966. /**
  75967. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  75968. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  75969. */
  75970. transformationMatrix: Matrix;
  75971. /**
  75972. * the native xr-plane object
  75973. */
  75974. xrPlane: XRPlane;
  75975. }
  75976. /**
  75977. * The plane detector is used to detect planes in the real world when in AR
  75978. * For more information see https://github.com/immersive-web/real-world-geometry/
  75979. */
  75980. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  75981. private _options;
  75982. private _detectedPlanes;
  75983. private _enabled;
  75984. private _lastFrameDetected;
  75985. /**
  75986. * The module's name
  75987. */
  75988. static readonly Name: string;
  75989. /**
  75990. * The (Babylon) version of this module.
  75991. * This is an integer representing the implementation version.
  75992. * This number does not correspond to the WebXR specs version
  75993. */
  75994. static readonly Version: number;
  75995. /**
  75996. * Observers registered here will be executed when a new plane was added to the session
  75997. */
  75998. onPlaneAddedObservable: Observable<IWebXRPlane>;
  75999. /**
  76000. * Observers registered here will be executed when a plane is no longer detected in the session
  76001. */
  76002. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  76003. /**
  76004. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  76005. * This can execute N times every frame
  76006. */
  76007. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  76008. /**
  76009. * construct a new Plane Detector
  76010. * @param _xrSessionManager an instance of xr Session manager
  76011. * @param _options configuration to use when constructing this feature
  76012. */
  76013. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  76014. /**
  76015. * detach this feature.
  76016. * Will usually be called by the features manager
  76017. *
  76018. * @returns true if successful.
  76019. */
  76020. detach(): boolean;
  76021. /**
  76022. * Dispose this feature and all of the resources attached
  76023. */
  76024. dispose(): void;
  76025. /**
  76026. * Check if the needed objects are defined.
  76027. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  76028. */
  76029. isCompatible(): boolean;
  76030. protected _onXRFrame(frame: XRFrame): void;
  76031. private _init;
  76032. private _updatePlaneWithXRPlane;
  76033. /**
  76034. * avoiding using Array.find for global support.
  76035. * @param xrPlane the plane to find in the array
  76036. */
  76037. private findIndexInPlaneArray;
  76038. }
  76039. }
  76040. declare module BABYLON {
  76041. /**
  76042. * Options interface for the background remover plugin
  76043. */
  76044. export interface IWebXRBackgroundRemoverOptions {
  76045. /**
  76046. * Further background meshes to disable when entering AR
  76047. */
  76048. backgroundMeshes?: AbstractMesh[];
  76049. /**
  76050. * flags to configure the removal of the environment helper.
  76051. * If not set, the entire background will be removed. If set, flags should be set as well.
  76052. */
  76053. environmentHelperRemovalFlags?: {
  76054. /**
  76055. * Should the skybox be removed (default false)
  76056. */
  76057. skyBox?: boolean;
  76058. /**
  76059. * Should the ground be removed (default false)
  76060. */
  76061. ground?: boolean;
  76062. };
  76063. /**
  76064. * don't disable the environment helper
  76065. */
  76066. ignoreEnvironmentHelper?: boolean;
  76067. }
  76068. /**
  76069. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  76070. */
  76071. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  76072. /**
  76073. * read-only options to be used in this module
  76074. */
  76075. readonly options: IWebXRBackgroundRemoverOptions;
  76076. /**
  76077. * The module's name
  76078. */
  76079. static readonly Name: string;
  76080. /**
  76081. * The (Babylon) version of this module.
  76082. * This is an integer representing the implementation version.
  76083. * This number does not correspond to the WebXR specs version
  76084. */
  76085. static readonly Version: number;
  76086. /**
  76087. * registered observers will be triggered when the background state changes
  76088. */
  76089. onBackgroundStateChangedObservable: Observable<boolean>;
  76090. /**
  76091. * constructs a new background remover module
  76092. * @param _xrSessionManager the session manager for this module
  76093. * @param options read-only options to be used in this module
  76094. */
  76095. constructor(_xrSessionManager: WebXRSessionManager,
  76096. /**
  76097. * read-only options to be used in this module
  76098. */
  76099. options?: IWebXRBackgroundRemoverOptions);
  76100. /**
  76101. * attach this feature
  76102. * Will usually be called by the features manager
  76103. *
  76104. * @returns true if successful.
  76105. */
  76106. attach(): boolean;
  76107. /**
  76108. * detach this feature.
  76109. * Will usually be called by the features manager
  76110. *
  76111. * @returns true if successful.
  76112. */
  76113. detach(): boolean;
  76114. /**
  76115. * Dispose this feature and all of the resources attached
  76116. */
  76117. dispose(): void;
  76118. protected _onXRFrame(_xrFrame: XRFrame): void;
  76119. private _setBackgroundState;
  76120. }
  76121. }
  76122. declare module BABYLON {
  76123. /**
  76124. * Options for the controller physics feature
  76125. */
  76126. export class IWebXRControllerPhysicsOptions {
  76127. /**
  76128. * Should the headset get its own impostor
  76129. */
  76130. enableHeadsetImpostor?: boolean;
  76131. /**
  76132. * Optional parameters for the headset impostor
  76133. */
  76134. headsetImpostorParams?: {
  76135. /**
  76136. * The type of impostor to create. Default is sphere
  76137. */
  76138. impostorType: number;
  76139. /**
  76140. * the size of the impostor. Defaults to 10cm
  76141. */
  76142. impostorSize?: number | {
  76143. width: number;
  76144. height: number;
  76145. depth: number;
  76146. };
  76147. /**
  76148. * Friction definitions
  76149. */
  76150. friction?: number;
  76151. /**
  76152. * Restitution
  76153. */
  76154. restitution?: number;
  76155. };
  76156. /**
  76157. * The physics properties of the future impostors
  76158. */
  76159. physicsProperties?: {
  76160. /**
  76161. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  76162. * Note that this requires a physics engine that supports mesh impostors!
  76163. */
  76164. useControllerMesh?: boolean;
  76165. /**
  76166. * The type of impostor to create. Default is sphere
  76167. */
  76168. impostorType?: number;
  76169. /**
  76170. * the size of the impostor. Defaults to 10cm
  76171. */
  76172. impostorSize?: number | {
  76173. width: number;
  76174. height: number;
  76175. depth: number;
  76176. };
  76177. /**
  76178. * Friction definitions
  76179. */
  76180. friction?: number;
  76181. /**
  76182. * Restitution
  76183. */
  76184. restitution?: number;
  76185. };
  76186. /**
  76187. * the xr input to use with this pointer selection
  76188. */
  76189. xrInput: WebXRInput;
  76190. }
  76191. /**
  76192. * Add physics impostor to your webxr controllers,
  76193. * including naive calculation of their linear and angular velocity
  76194. */
  76195. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  76196. private readonly _options;
  76197. private _attachController;
  76198. private _controllers;
  76199. private _debugMode;
  76200. private _delta;
  76201. private _headsetImpostor?;
  76202. private _headsetMesh?;
  76203. private _lastTimestamp;
  76204. private _tmpQuaternion;
  76205. private _tmpVector;
  76206. /**
  76207. * The module's name
  76208. */
  76209. static readonly Name: string;
  76210. /**
  76211. * The (Babylon) version of this module.
  76212. * This is an integer representing the implementation version.
  76213. * This number does not correspond to the webxr specs version
  76214. */
  76215. static readonly Version: number;
  76216. /**
  76217. * Construct a new Controller Physics Feature
  76218. * @param _xrSessionManager the corresponding xr session manager
  76219. * @param _options options to create this feature with
  76220. */
  76221. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  76222. /**
  76223. * @hidden
  76224. * enable debugging - will show console outputs and the impostor mesh
  76225. */
  76226. _enablePhysicsDebug(): void;
  76227. /**
  76228. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  76229. * @param xrController the controller to add
  76230. */
  76231. addController(xrController: WebXRInputSource): void;
  76232. /**
  76233. * attach this feature
  76234. * Will usually be called by the features manager
  76235. *
  76236. * @returns true if successful.
  76237. */
  76238. attach(): boolean;
  76239. /**
  76240. * detach this feature.
  76241. * Will usually be called by the features manager
  76242. *
  76243. * @returns true if successful.
  76244. */
  76245. detach(): boolean;
  76246. /**
  76247. * Get the headset impostor, if enabled
  76248. * @returns the impostor
  76249. */
  76250. getHeadsetImpostor(): PhysicsImpostor | undefined;
  76251. /**
  76252. * Get the physics impostor of a specific controller.
  76253. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  76254. * @param controller the controller or the controller id of which to get the impostor
  76255. * @returns the impostor or null
  76256. */
  76257. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  76258. /**
  76259. * Update the physics properties provided in the constructor
  76260. * @param newProperties the new properties object
  76261. */
  76262. setPhysicsProperties(newProperties: {
  76263. impostorType?: number;
  76264. impostorSize?: number | {
  76265. width: number;
  76266. height: number;
  76267. depth: number;
  76268. };
  76269. friction?: number;
  76270. restitution?: number;
  76271. }): void;
  76272. protected _onXRFrame(_xrFrame: any): void;
  76273. private _detachController;
  76274. }
  76275. }
  76276. declare module BABYLON {
  76277. /**
  76278. * A babylon interface for a "WebXR" feature point.
  76279. * Represents the position and confidence value of a given feature point.
  76280. */
  76281. export interface IWebXRFeaturePoint {
  76282. /**
  76283. * Represents the position of the feature point in world space.
  76284. */
  76285. position: Vector3;
  76286. /**
  76287. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  76288. */
  76289. confidenceValue: number;
  76290. }
  76291. /**
  76292. * The feature point system is used to detect feature points from real world geometry.
  76293. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  76294. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  76295. */
  76296. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  76297. private _enabled;
  76298. private _featurePointCloud;
  76299. /**
  76300. * The module's name
  76301. */
  76302. static readonly Name: string;
  76303. /**
  76304. * The (Babylon) version of this module.
  76305. * This is an integer representing the implementation version.
  76306. * This number does not correspond to the WebXR specs version
  76307. */
  76308. static readonly Version: number;
  76309. /**
  76310. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  76311. * Will notify the observers about which feature points have been added.
  76312. */
  76313. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  76314. /**
  76315. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  76316. * Will notify the observers about which feature points have been updated.
  76317. */
  76318. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  76319. /**
  76320. * The current feature point cloud maintained across frames.
  76321. */
  76322. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  76323. /**
  76324. * construct the feature point system
  76325. * @param _xrSessionManager an instance of xr Session manager
  76326. */
  76327. constructor(_xrSessionManager: WebXRSessionManager);
  76328. /**
  76329. * Detach this feature.
  76330. * Will usually be called by the features manager
  76331. *
  76332. * @returns true if successful.
  76333. */
  76334. detach(): boolean;
  76335. /**
  76336. * Dispose this feature and all of the resources attached
  76337. */
  76338. dispose(): void;
  76339. /**
  76340. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  76341. */
  76342. protected _onXRFrame(frame: XRFrame): void;
  76343. /**
  76344. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  76345. */
  76346. private _init;
  76347. }
  76348. }
  76349. declare module BABYLON {
  76350. /**
  76351. * Configuration interface for the hand tracking feature
  76352. */
  76353. export interface IWebXRHandTrackingOptions {
  76354. /**
  76355. * The xrInput that will be used as source for new hands
  76356. */
  76357. xrInput: WebXRInput;
  76358. /**
  76359. * Configuration object for the joint meshes
  76360. */
  76361. jointMeshes?: {
  76362. /**
  76363. * Should the meshes created be invisible (defaults to false)
  76364. */
  76365. invisible?: boolean;
  76366. /**
  76367. * A source mesh to be used to create instances. Defaults to a sphere.
  76368. * This mesh will be the source for all other (25) meshes.
  76369. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  76370. */
  76371. sourceMesh?: Mesh;
  76372. /**
  76373. * This function will be called after a mesh was created for a specific joint.
  76374. * Using this function you can either manipulate the instance or return a new mesh.
  76375. * When returning a new mesh the instance created before will be disposed
  76376. */
  76377. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  76378. /**
  76379. * Should the source mesh stay visible. Defaults to false
  76380. */
  76381. keepOriginalVisible?: boolean;
  76382. /**
  76383. * Scale factor for all instances (defaults to 2)
  76384. */
  76385. scaleFactor?: number;
  76386. /**
  76387. * Should each instance have its own physics impostor
  76388. */
  76389. enablePhysics?: boolean;
  76390. /**
  76391. * If enabled, override default physics properties
  76392. */
  76393. physicsProps?: {
  76394. friction?: number;
  76395. restitution?: number;
  76396. impostorType?: number;
  76397. };
  76398. /**
  76399. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  76400. */
  76401. handMesh?: AbstractMesh;
  76402. };
  76403. }
  76404. /**
  76405. * Parts of the hands divided to writs and finger names
  76406. */
  76407. export const enum HandPart {
  76408. /**
  76409. * HandPart - Wrist
  76410. */
  76411. WRIST = "wrist",
  76412. /**
  76413. * HandPart - The THumb
  76414. */
  76415. THUMB = "thumb",
  76416. /**
  76417. * HandPart - Index finger
  76418. */
  76419. INDEX = "index",
  76420. /**
  76421. * HandPart - Middle finger
  76422. */
  76423. MIDDLE = "middle",
  76424. /**
  76425. * HandPart - Ring finger
  76426. */
  76427. RING = "ring",
  76428. /**
  76429. * HandPart - Little finger
  76430. */
  76431. LITTLE = "little"
  76432. }
  76433. /**
  76434. * Representing a single hand (with its corresponding native XRHand object)
  76435. */
  76436. export class WebXRHand implements IDisposable {
  76437. /** the controller to which the hand correlates */
  76438. readonly xrController: WebXRInputSource;
  76439. /** the meshes to be used to track the hand joints */
  76440. readonly trackedMeshes: AbstractMesh[];
  76441. /**
  76442. * Hand-parts definition (key is HandPart)
  76443. */
  76444. handPartsDefinition: {
  76445. [key: string]: number[];
  76446. };
  76447. /**
  76448. * Populate the HandPartsDefinition object.
  76449. * This is called as a side effect since certain browsers don't have XRHand defined.
  76450. */
  76451. private generateHandPartsDefinition;
  76452. /**
  76453. * Construct a new hand object
  76454. * @param xrController the controller to which the hand correlates
  76455. * @param trackedMeshes the meshes to be used to track the hand joints
  76456. */
  76457. constructor(
  76458. /** the controller to which the hand correlates */
  76459. xrController: WebXRInputSource,
  76460. /** the meshes to be used to track the hand joints */
  76461. trackedMeshes: AbstractMesh[]);
  76462. /**
  76463. * Update this hand from the latest xr frame
  76464. * @param xrFrame xrFrame to update from
  76465. * @param referenceSpace The current viewer reference space
  76466. * @param scaleFactor optional scale factor for the meshes
  76467. */
  76468. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  76469. /**
  76470. * Get meshes of part of the hand
  76471. * @param part the part of hand to get
  76472. * @returns An array of meshes that correlate to the hand part requested
  76473. */
  76474. getHandPartMeshes(part: HandPart): AbstractMesh[];
  76475. /**
  76476. * Dispose this Hand object
  76477. */
  76478. dispose(): void;
  76479. }
  76480. /**
  76481. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  76482. */
  76483. export class WebXRHandTracking extends WebXRAbstractFeature {
  76484. /**
  76485. * options to use when constructing this feature
  76486. */
  76487. readonly options: IWebXRHandTrackingOptions;
  76488. private static _idCounter;
  76489. /**
  76490. * The module's name
  76491. */
  76492. static readonly Name: string;
  76493. /**
  76494. * The (Babylon) version of this module.
  76495. * This is an integer representing the implementation version.
  76496. * This number does not correspond to the WebXR specs version
  76497. */
  76498. static readonly Version: number;
  76499. /**
  76500. * This observable will notify registered observers when a new hand object was added and initialized
  76501. */
  76502. onHandAddedObservable: Observable<WebXRHand>;
  76503. /**
  76504. * This observable will notify its observers right before the hand object is disposed
  76505. */
  76506. onHandRemovedObservable: Observable<WebXRHand>;
  76507. private _hands;
  76508. /**
  76509. * Creates a new instance of the hit test feature
  76510. * @param _xrSessionManager an instance of WebXRSessionManager
  76511. * @param options options to use when constructing this feature
  76512. */
  76513. constructor(_xrSessionManager: WebXRSessionManager,
  76514. /**
  76515. * options to use when constructing this feature
  76516. */
  76517. options: IWebXRHandTrackingOptions);
  76518. /**
  76519. * Check if the needed objects are defined.
  76520. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  76521. */
  76522. isCompatible(): boolean;
  76523. /**
  76524. * attach this feature
  76525. * Will usually be called by the features manager
  76526. *
  76527. * @returns true if successful.
  76528. */
  76529. attach(): boolean;
  76530. /**
  76531. * detach this feature.
  76532. * Will usually be called by the features manager
  76533. *
  76534. * @returns true if successful.
  76535. */
  76536. detach(): boolean;
  76537. /**
  76538. * Dispose this feature and all of the resources attached
  76539. */
  76540. dispose(): void;
  76541. /**
  76542. * Get the hand object according to the controller id
  76543. * @param controllerId the controller id to which we want to get the hand
  76544. * @returns null if not found or the WebXRHand object if found
  76545. */
  76546. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  76547. /**
  76548. * Get a hand object according to the requested handedness
  76549. * @param handedness the handedness to request
  76550. * @returns null if not found or the WebXRHand object if found
  76551. */
  76552. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  76553. protected _onXRFrame(_xrFrame: XRFrame): void;
  76554. private _attachHand;
  76555. private _detachHand;
  76556. }
  76557. }
  76558. declare module BABYLON {
  76559. /**
  76560. * The motion controller class for all microsoft mixed reality controllers
  76561. */
  76562. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  76563. protected readonly _mapping: {
  76564. defaultButton: {
  76565. valueNodeName: string;
  76566. unpressedNodeName: string;
  76567. pressedNodeName: string;
  76568. };
  76569. defaultAxis: {
  76570. valueNodeName: string;
  76571. minNodeName: string;
  76572. maxNodeName: string;
  76573. };
  76574. buttons: {
  76575. "xr-standard-trigger": {
  76576. rootNodeName: string;
  76577. componentProperty: string;
  76578. states: string[];
  76579. };
  76580. "xr-standard-squeeze": {
  76581. rootNodeName: string;
  76582. componentProperty: string;
  76583. states: string[];
  76584. };
  76585. "xr-standard-touchpad": {
  76586. rootNodeName: string;
  76587. labelAnchorNodeName: string;
  76588. touchPointNodeName: string;
  76589. };
  76590. "xr-standard-thumbstick": {
  76591. rootNodeName: string;
  76592. componentProperty: string;
  76593. states: string[];
  76594. };
  76595. };
  76596. axes: {
  76597. "xr-standard-touchpad": {
  76598. "x-axis": {
  76599. rootNodeName: string;
  76600. };
  76601. "y-axis": {
  76602. rootNodeName: string;
  76603. };
  76604. };
  76605. "xr-standard-thumbstick": {
  76606. "x-axis": {
  76607. rootNodeName: string;
  76608. };
  76609. "y-axis": {
  76610. rootNodeName: string;
  76611. };
  76612. };
  76613. };
  76614. };
  76615. /**
  76616. * The base url used to load the left and right controller models
  76617. */
  76618. static MODEL_BASE_URL: string;
  76619. /**
  76620. * The name of the left controller model file
  76621. */
  76622. static MODEL_LEFT_FILENAME: string;
  76623. /**
  76624. * The name of the right controller model file
  76625. */
  76626. static MODEL_RIGHT_FILENAME: string;
  76627. profileId: string;
  76628. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  76629. protected _getFilenameAndPath(): {
  76630. filename: string;
  76631. path: string;
  76632. };
  76633. protected _getModelLoadingConstraints(): boolean;
  76634. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76635. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76636. protected _updateModel(): void;
  76637. }
  76638. }
  76639. declare module BABYLON {
  76640. /**
  76641. * The motion controller class for oculus touch (quest, rift).
  76642. * This class supports legacy mapping as well the standard xr mapping
  76643. */
  76644. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  76645. private _forceLegacyControllers;
  76646. private _modelRootNode;
  76647. /**
  76648. * The base url used to load the left and right controller models
  76649. */
  76650. static MODEL_BASE_URL: string;
  76651. /**
  76652. * The name of the left controller model file
  76653. */
  76654. static MODEL_LEFT_FILENAME: string;
  76655. /**
  76656. * The name of the right controller model file
  76657. */
  76658. static MODEL_RIGHT_FILENAME: string;
  76659. /**
  76660. * Base Url for the Quest controller model.
  76661. */
  76662. static QUEST_MODEL_BASE_URL: string;
  76663. profileId: string;
  76664. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  76665. protected _getFilenameAndPath(): {
  76666. filename: string;
  76667. path: string;
  76668. };
  76669. protected _getModelLoadingConstraints(): boolean;
  76670. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76671. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76672. protected _updateModel(): void;
  76673. /**
  76674. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  76675. * between the touch and touch 2.
  76676. */
  76677. private _isQuest;
  76678. }
  76679. }
  76680. declare module BABYLON {
  76681. /**
  76682. * The motion controller class for the standard HTC-Vive controllers
  76683. */
  76684. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  76685. private _modelRootNode;
  76686. /**
  76687. * The base url used to load the left and right controller models
  76688. */
  76689. static MODEL_BASE_URL: string;
  76690. /**
  76691. * File name for the controller model.
  76692. */
  76693. static MODEL_FILENAME: string;
  76694. profileId: string;
  76695. /**
  76696. * Create a new Vive motion controller object
  76697. * @param scene the scene to use to create this controller
  76698. * @param gamepadObject the corresponding gamepad object
  76699. * @param handedness the handedness of the controller
  76700. */
  76701. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  76702. protected _getFilenameAndPath(): {
  76703. filename: string;
  76704. path: string;
  76705. };
  76706. protected _getModelLoadingConstraints(): boolean;
  76707. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76708. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76709. protected _updateModel(): void;
  76710. }
  76711. }
  76712. declare module BABYLON {
  76713. /**
  76714. * A cursor which tracks a point on a path
  76715. */
  76716. export class PathCursor {
  76717. private path;
  76718. /**
  76719. * Stores path cursor callbacks for when an onchange event is triggered
  76720. */
  76721. private _onchange;
  76722. /**
  76723. * The value of the path cursor
  76724. */
  76725. value: number;
  76726. /**
  76727. * The animation array of the path cursor
  76728. */
  76729. animations: Animation[];
  76730. /**
  76731. * Initializes the path cursor
  76732. * @param path The path to track
  76733. */
  76734. constructor(path: Path2);
  76735. /**
  76736. * Gets the cursor point on the path
  76737. * @returns A point on the path cursor at the cursor location
  76738. */
  76739. getPoint(): Vector3;
  76740. /**
  76741. * Moves the cursor ahead by the step amount
  76742. * @param step The amount to move the cursor forward
  76743. * @returns This path cursor
  76744. */
  76745. moveAhead(step?: number): PathCursor;
  76746. /**
  76747. * Moves the cursor behind by the step amount
  76748. * @param step The amount to move the cursor back
  76749. * @returns This path cursor
  76750. */
  76751. moveBack(step?: number): PathCursor;
  76752. /**
  76753. * Moves the cursor by the step amount
  76754. * If the step amount is greater than one, an exception is thrown
  76755. * @param step The amount to move the cursor
  76756. * @returns This path cursor
  76757. */
  76758. move(step: number): PathCursor;
  76759. /**
  76760. * Ensures that the value is limited between zero and one
  76761. * @returns This path cursor
  76762. */
  76763. private ensureLimits;
  76764. /**
  76765. * Runs onchange callbacks on change (used by the animation engine)
  76766. * @returns This path cursor
  76767. */
  76768. private raiseOnChange;
  76769. /**
  76770. * Executes a function on change
  76771. * @param f A path cursor onchange callback
  76772. * @returns This path cursor
  76773. */
  76774. onchange(f: (cursor: PathCursor) => void): PathCursor;
  76775. }
  76776. }
  76777. declare module BABYLON {
  76778. /** @hidden */
  76779. export var blurPixelShader: {
  76780. name: string;
  76781. shader: string;
  76782. };
  76783. }
  76784. declare module BABYLON {
  76785. /** @hidden */
  76786. export var pointCloudVertexDeclaration: {
  76787. name: string;
  76788. shader: string;
  76789. };
  76790. }
  76791. // Mixins
  76792. interface Window {
  76793. mozIndexedDB: IDBFactory;
  76794. webkitIndexedDB: IDBFactory;
  76795. msIndexedDB: IDBFactory;
  76796. webkitURL: typeof URL;
  76797. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  76798. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  76799. WebGLRenderingContext: WebGLRenderingContext;
  76800. MSGesture: MSGesture;
  76801. CANNON: any;
  76802. AudioContext: AudioContext;
  76803. webkitAudioContext: AudioContext;
  76804. PointerEvent: any;
  76805. Math: Math;
  76806. Uint8Array: Uint8ArrayConstructor;
  76807. Float32Array: Float32ArrayConstructor;
  76808. mozURL: typeof URL;
  76809. msURL: typeof URL;
  76810. VRFrameData: any; // WebVR, from specs 1.1
  76811. DracoDecoderModule: any;
  76812. setImmediate(handler: (...args: any[]) => void): number;
  76813. }
  76814. interface HTMLCanvasElement {
  76815. requestPointerLock(): void;
  76816. msRequestPointerLock?(): void;
  76817. mozRequestPointerLock?(): void;
  76818. webkitRequestPointerLock?(): void;
  76819. /** Track wether a record is in progress */
  76820. isRecording: boolean;
  76821. /** Capture Stream method defined by some browsers */
  76822. captureStream(fps?: number): MediaStream;
  76823. }
  76824. interface CanvasRenderingContext2D {
  76825. msImageSmoothingEnabled: boolean;
  76826. }
  76827. interface MouseEvent {
  76828. mozMovementX: number;
  76829. mozMovementY: number;
  76830. webkitMovementX: number;
  76831. webkitMovementY: number;
  76832. msMovementX: number;
  76833. msMovementY: number;
  76834. }
  76835. interface Navigator {
  76836. mozGetVRDevices: (any: any) => any;
  76837. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76838. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76839. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76840. webkitGetGamepads(): Gamepad[];
  76841. msGetGamepads(): Gamepad[];
  76842. webkitGamepads(): Gamepad[];
  76843. }
  76844. interface HTMLVideoElement {
  76845. mozSrcObject: any;
  76846. }
  76847. interface Math {
  76848. fround(x: number): number;
  76849. imul(a: number, b: number): number;
  76850. }
  76851. interface WebGLRenderingContext {
  76852. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  76853. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  76854. vertexAttribDivisor(index: number, divisor: number): void;
  76855. createVertexArray(): any;
  76856. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  76857. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  76858. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  76859. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  76860. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  76861. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  76862. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  76863. // Queries
  76864. createQuery(): WebGLQuery;
  76865. deleteQuery(query: WebGLQuery): void;
  76866. beginQuery(target: number, query: WebGLQuery): void;
  76867. endQuery(target: number): void;
  76868. getQueryParameter(query: WebGLQuery, pname: number): any;
  76869. getQuery(target: number, pname: number): any;
  76870. MAX_SAMPLES: number;
  76871. RGBA8: number;
  76872. READ_FRAMEBUFFER: number;
  76873. DRAW_FRAMEBUFFER: number;
  76874. UNIFORM_BUFFER: number;
  76875. HALF_FLOAT_OES: number;
  76876. RGBA16F: number;
  76877. RGBA32F: number;
  76878. R32F: number;
  76879. RG32F: number;
  76880. RGB32F: number;
  76881. R16F: number;
  76882. RG16F: number;
  76883. RGB16F: number;
  76884. RED: number;
  76885. RG: number;
  76886. R8: number;
  76887. RG8: number;
  76888. UNSIGNED_INT_24_8: number;
  76889. DEPTH24_STENCIL8: number;
  76890. MIN: number;
  76891. MAX: number;
  76892. /* Multiple Render Targets */
  76893. drawBuffers(buffers: number[]): void;
  76894. readBuffer(src: number): void;
  76895. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  76896. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  76897. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  76898. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  76899. // Occlusion Query
  76900. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  76901. ANY_SAMPLES_PASSED: number;
  76902. QUERY_RESULT_AVAILABLE: number;
  76903. QUERY_RESULT: number;
  76904. }
  76905. interface WebGLProgram {
  76906. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  76907. }
  76908. interface EXT_disjoint_timer_query {
  76909. QUERY_COUNTER_BITS_EXT: number;
  76910. TIME_ELAPSED_EXT: number;
  76911. TIMESTAMP_EXT: number;
  76912. GPU_DISJOINT_EXT: number;
  76913. QUERY_RESULT_EXT: number;
  76914. QUERY_RESULT_AVAILABLE_EXT: number;
  76915. queryCounterEXT(query: WebGLQuery, target: number): void;
  76916. createQueryEXT(): WebGLQuery;
  76917. beginQueryEXT(target: number, query: WebGLQuery): void;
  76918. endQueryEXT(target: number): void;
  76919. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  76920. deleteQueryEXT(query: WebGLQuery): void;
  76921. }
  76922. interface WebGLUniformLocation {
  76923. _currentState: any;
  76924. }
  76925. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  76926. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  76927. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  76928. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  76929. interface WebGLRenderingContext {
  76930. readonly RASTERIZER_DISCARD: number;
  76931. readonly DEPTH_COMPONENT24: number;
  76932. readonly TEXTURE_3D: number;
  76933. readonly TEXTURE_2D_ARRAY: number;
  76934. readonly TEXTURE_COMPARE_FUNC: number;
  76935. readonly TEXTURE_COMPARE_MODE: number;
  76936. readonly COMPARE_REF_TO_TEXTURE: number;
  76937. readonly TEXTURE_WRAP_R: number;
  76938. readonly HALF_FLOAT: number;
  76939. readonly RGB8: number;
  76940. readonly RED_INTEGER: number;
  76941. readonly RG_INTEGER: number;
  76942. readonly RGB_INTEGER: number;
  76943. readonly RGBA_INTEGER: number;
  76944. readonly R8_SNORM: number;
  76945. readonly RG8_SNORM: number;
  76946. readonly RGB8_SNORM: number;
  76947. readonly RGBA8_SNORM: number;
  76948. readonly R8I: number;
  76949. readonly RG8I: number;
  76950. readonly RGB8I: number;
  76951. readonly RGBA8I: number;
  76952. readonly R8UI: number;
  76953. readonly RG8UI: number;
  76954. readonly RGB8UI: number;
  76955. readonly RGBA8UI: number;
  76956. readonly R16I: number;
  76957. readonly RG16I: number;
  76958. readonly RGB16I: number;
  76959. readonly RGBA16I: number;
  76960. readonly R16UI: number;
  76961. readonly RG16UI: number;
  76962. readonly RGB16UI: number;
  76963. readonly RGBA16UI: number;
  76964. readonly R32I: number;
  76965. readonly RG32I: number;
  76966. readonly RGB32I: number;
  76967. readonly RGBA32I: number;
  76968. readonly R32UI: number;
  76969. readonly RG32UI: number;
  76970. readonly RGB32UI: number;
  76971. readonly RGBA32UI: number;
  76972. readonly RGB10_A2UI: number;
  76973. readonly R11F_G11F_B10F: number;
  76974. readonly RGB9_E5: number;
  76975. readonly RGB10_A2: number;
  76976. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  76977. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  76978. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  76979. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  76980. readonly DEPTH_COMPONENT32F: number;
  76981. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  76982. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  76983. 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;
  76984. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  76985. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  76986. readonly TRANSFORM_FEEDBACK: number;
  76987. readonly INTERLEAVED_ATTRIBS: number;
  76988. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  76989. createTransformFeedback(): WebGLTransformFeedback;
  76990. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  76991. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  76992. beginTransformFeedback(primitiveMode: number): void;
  76993. endTransformFeedback(): void;
  76994. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  76995. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  76996. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  76997. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  76998. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  76999. }
  77000. interface ImageBitmap {
  77001. readonly width: number;
  77002. readonly height: number;
  77003. close(): void;
  77004. }
  77005. interface WebGLQuery extends WebGLObject {
  77006. }
  77007. declare var WebGLQuery: {
  77008. prototype: WebGLQuery;
  77009. new(): WebGLQuery;
  77010. };
  77011. interface WebGLSampler extends WebGLObject {
  77012. }
  77013. declare var WebGLSampler: {
  77014. prototype: WebGLSampler;
  77015. new(): WebGLSampler;
  77016. };
  77017. interface WebGLSync extends WebGLObject {
  77018. }
  77019. declare var WebGLSync: {
  77020. prototype: WebGLSync;
  77021. new(): WebGLSync;
  77022. };
  77023. interface WebGLTransformFeedback extends WebGLObject {
  77024. }
  77025. declare var WebGLTransformFeedback: {
  77026. prototype: WebGLTransformFeedback;
  77027. new(): WebGLTransformFeedback;
  77028. };
  77029. interface WebGLVertexArrayObject extends WebGLObject {
  77030. }
  77031. declare var WebGLVertexArrayObject: {
  77032. prototype: WebGLVertexArrayObject;
  77033. new(): WebGLVertexArrayObject;
  77034. };
  77035. // Type definitions for WebVR API
  77036. // Project: https://w3c.github.io/webvr/
  77037. // Definitions by: six a <https://github.com/lostfictions>
  77038. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  77039. interface VRDisplay extends EventTarget {
  77040. /**
  77041. * Dictionary of capabilities describing the VRDisplay.
  77042. */
  77043. readonly capabilities: VRDisplayCapabilities;
  77044. /**
  77045. * z-depth defining the far plane of the eye view frustum
  77046. * enables mapping of values in the render target depth
  77047. * attachment to scene coordinates. Initially set to 10000.0.
  77048. */
  77049. depthFar: number;
  77050. /**
  77051. * z-depth defining the near plane of the eye view frustum
  77052. * enables mapping of values in the render target depth
  77053. * attachment to scene coordinates. Initially set to 0.01.
  77054. */
  77055. depthNear: number;
  77056. /**
  77057. * An identifier for this distinct VRDisplay. Used as an
  77058. * association point in the Gamepad API.
  77059. */
  77060. readonly displayId: number;
  77061. /**
  77062. * A display name, a user-readable name identifying it.
  77063. */
  77064. readonly displayName: string;
  77065. readonly isConnected: boolean;
  77066. readonly isPresenting: boolean;
  77067. /**
  77068. * If this VRDisplay supports room-scale experiences, the optional
  77069. * stage attribute contains details on the room-scale parameters.
  77070. */
  77071. readonly stageParameters: VRStageParameters | null;
  77072. /**
  77073. * Passing the value returned by `requestAnimationFrame` to
  77074. * `cancelAnimationFrame` will unregister the callback.
  77075. * @param handle Define the hanle of the request to cancel
  77076. */
  77077. cancelAnimationFrame(handle: number): void;
  77078. /**
  77079. * Stops presenting to the VRDisplay.
  77080. * @returns a promise to know when it stopped
  77081. */
  77082. exitPresent(): Promise<void>;
  77083. /**
  77084. * Return the current VREyeParameters for the given eye.
  77085. * @param whichEye Define the eye we want the parameter for
  77086. * @returns the eye parameters
  77087. */
  77088. getEyeParameters(whichEye: string): VREyeParameters;
  77089. /**
  77090. * Populates the passed VRFrameData with the information required to render
  77091. * the current frame.
  77092. * @param frameData Define the data structure to populate
  77093. * @returns true if ok otherwise false
  77094. */
  77095. getFrameData(frameData: VRFrameData): boolean;
  77096. /**
  77097. * Get the layers currently being presented.
  77098. * @returns the list of VR layers
  77099. */
  77100. getLayers(): VRLayer[];
  77101. /**
  77102. * Return a VRPose containing the future predicted pose of the VRDisplay
  77103. * when the current frame will be presented. The value returned will not
  77104. * change until JavaScript has returned control to the browser.
  77105. *
  77106. * The VRPose will contain the position, orientation, velocity,
  77107. * and acceleration of each of these properties.
  77108. * @returns the pose object
  77109. */
  77110. getPose(): VRPose;
  77111. /**
  77112. * Return the current instantaneous pose of the VRDisplay, with no
  77113. * prediction applied.
  77114. * @returns the current instantaneous pose
  77115. */
  77116. getImmediatePose(): VRPose;
  77117. /**
  77118. * The callback passed to `requestAnimationFrame` will be called
  77119. * any time a new frame should be rendered. When the VRDisplay is
  77120. * presenting the callback will be called at the native refresh
  77121. * rate of the HMD. When not presenting this function acts
  77122. * identically to how window.requestAnimationFrame acts. Content should
  77123. * make no assumptions of frame rate or vsync behavior as the HMD runs
  77124. * asynchronously from other displays and at differing refresh rates.
  77125. * @param callback Define the eaction to run next frame
  77126. * @returns the request handle it
  77127. */
  77128. requestAnimationFrame(callback: FrameRequestCallback): number;
  77129. /**
  77130. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  77131. * Repeat calls while already presenting will update the VRLayers being displayed.
  77132. * @param layers Define the list of layer to present
  77133. * @returns a promise to know when the request has been fulfilled
  77134. */
  77135. requestPresent(layers: VRLayer[]): Promise<void>;
  77136. /**
  77137. * Reset the pose for this display, treating its current position and
  77138. * orientation as the "origin/zero" values. VRPose.position,
  77139. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  77140. * updated when calling resetPose(). This should be called in only
  77141. * sitting-space experiences.
  77142. */
  77143. resetPose(): void;
  77144. /**
  77145. * The VRLayer provided to the VRDisplay will be captured and presented
  77146. * in the HMD. Calling this function has the same effect on the source
  77147. * canvas as any other operation that uses its source image, and canvases
  77148. * created without preserveDrawingBuffer set to true will be cleared.
  77149. * @param pose Define the pose to submit
  77150. */
  77151. submitFrame(pose?: VRPose): void;
  77152. }
  77153. declare var VRDisplay: {
  77154. prototype: VRDisplay;
  77155. new(): VRDisplay;
  77156. };
  77157. interface VRLayer {
  77158. leftBounds?: number[] | Float32Array | null;
  77159. rightBounds?: number[] | Float32Array | null;
  77160. source?: HTMLCanvasElement | null;
  77161. }
  77162. interface VRDisplayCapabilities {
  77163. readonly canPresent: boolean;
  77164. readonly hasExternalDisplay: boolean;
  77165. readonly hasOrientation: boolean;
  77166. readonly hasPosition: boolean;
  77167. readonly maxLayers: number;
  77168. }
  77169. interface VREyeParameters {
  77170. /** @deprecated */
  77171. readonly fieldOfView: VRFieldOfView;
  77172. readonly offset: Float32Array;
  77173. readonly renderHeight: number;
  77174. readonly renderWidth: number;
  77175. }
  77176. interface VRFieldOfView {
  77177. readonly downDegrees: number;
  77178. readonly leftDegrees: number;
  77179. readonly rightDegrees: number;
  77180. readonly upDegrees: number;
  77181. }
  77182. interface VRFrameData {
  77183. readonly leftProjectionMatrix: Float32Array;
  77184. readonly leftViewMatrix: Float32Array;
  77185. readonly pose: VRPose;
  77186. readonly rightProjectionMatrix: Float32Array;
  77187. readonly rightViewMatrix: Float32Array;
  77188. readonly timestamp: number;
  77189. }
  77190. interface VRPose {
  77191. readonly angularAcceleration: Float32Array | null;
  77192. readonly angularVelocity: Float32Array | null;
  77193. readonly linearAcceleration: Float32Array | null;
  77194. readonly linearVelocity: Float32Array | null;
  77195. readonly orientation: Float32Array | null;
  77196. readonly position: Float32Array | null;
  77197. readonly timestamp: number;
  77198. }
  77199. interface VRStageParameters {
  77200. sittingToStandingTransform?: Float32Array;
  77201. sizeX?: number;
  77202. sizeY?: number;
  77203. }
  77204. interface Navigator {
  77205. getVRDisplays(): Promise<VRDisplay[]>;
  77206. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  77207. }
  77208. interface Window {
  77209. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  77210. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  77211. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  77212. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  77213. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  77214. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  77215. }
  77216. interface Gamepad {
  77217. readonly displayId: number;
  77218. }
  77219. /**
  77220. * Available session modes
  77221. */
  77222. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  77223. /**
  77224. * Reference space types
  77225. */
  77226. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  77227. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  77228. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  77229. /**
  77230. * Handedness types
  77231. */
  77232. type XRHandedness = "none" | "left" | "right";
  77233. /**
  77234. * InputSource target ray modes
  77235. */
  77236. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  77237. /**
  77238. * Eye types
  77239. */
  77240. type XREye = "none" | "left" | "right";
  77241. /**
  77242. * Type of XR events available
  77243. */
  77244. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  77245. type XRFrameRequestCallback = (time: DOMHighResTimeStamp, frame: XRFrame) => void;
  77246. type XRPlaneSet = Set<XRPlane>;
  77247. type XRAnchorSet = Set<XRAnchor>;
  77248. type XREventHandler = (callback: any) => void;
  77249. interface XRLayer extends EventTarget {}
  77250. interface XRSessionInit {
  77251. optionalFeatures?: string[];
  77252. requiredFeatures?: string[];
  77253. }
  77254. interface XRSessionEvent extends Event {
  77255. readonly session: XRSession;
  77256. }
  77257. interface XRSystem {
  77258. isSessionSupported: (sessionMode: XRSessionMode) => Promise<boolean>;
  77259. requestSession: (sessionMode: XRSessionMode, sessionInit?: any) => Promise<XRSession>;
  77260. }
  77261. interface XRViewport {
  77262. readonly x: number;
  77263. readonly y: number;
  77264. readonly width: number;
  77265. readonly height: number;
  77266. }
  77267. interface XRWebGLLayerInit {
  77268. antialias?: boolean;
  77269. depth?: boolean;
  77270. stencil?: boolean;
  77271. alpha?: boolean;
  77272. multiview?: boolean;
  77273. framebufferScaleFactor?: number;
  77274. }
  77275. declare class XRWebGLLayer {
  77276. static getNativeFramebufferScaleFactor(session: XRSession): number;
  77277. constructor(session: XRSession, context: WebGLRenderingContext | WebGL2RenderingContext, layerInit?: XRWebGLLayerInit);
  77278. readonly antialias: boolean;
  77279. readonly framebuffer: WebGLFramebuffer;
  77280. readonly framebufferWidth: number;
  77281. readonly framebufferHeight: number;
  77282. readonly ignoreDepthValues: boolean;
  77283. getViewport: (view: XRView) => XRViewport;
  77284. }
  77285. // tslint:disable-next-line no-empty-interface
  77286. interface XRSpace extends EventTarget {}
  77287. interface XRRenderState {
  77288. readonly baseLayer?: XRWebGLLayer;
  77289. readonly depthFar: number;
  77290. readonly depthNear: number;
  77291. readonly inlineVerticalFieldOfView?: number;
  77292. }
  77293. interface XRRenderStateInit extends XRRenderState {
  77294. baseLayer: XRWebGLLayer;
  77295. depthFar: number;
  77296. depthNear: number;
  77297. inlineVerticalFieldOfView?: number;
  77298. layers?: XRLayer[];
  77299. }
  77300. interface XRReferenceSpace extends XRSpace {
  77301. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  77302. onreset: XREventHandler;
  77303. }
  77304. interface XRBoundedReferenceSpace extends XRSpace {
  77305. readonly boundsGeometry: DOMPointReadOnly[];
  77306. }
  77307. interface XRInputSource {
  77308. readonly handedness: XRHandedness;
  77309. readonly targetRayMode: XRTargetRayMode;
  77310. readonly targetRaySpace: XRSpace;
  77311. readonly gripSpace?: XRSpace;
  77312. readonly gamepad?: Gamepad;
  77313. readonly profiles: Array<string>;
  77314. readonly hand?: XRHand;
  77315. }
  77316. interface XRPose {
  77317. readonly transform: XRRigidTransform;
  77318. readonly emulatedPosition: boolean;
  77319. }
  77320. interface XRFrame {
  77321. readonly session: XRSession;
  77322. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  77323. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  77324. // AR
  77325. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  77326. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  77327. // Anchors
  77328. trackedAnchors?: XRAnchorSet;
  77329. createAnchor?(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  77330. // Planes
  77331. worldInformation?: {
  77332. detectedPlanes?: XRPlaneSet;
  77333. };
  77334. // Hand tracking
  77335. getJointPose?(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  77336. }
  77337. interface XRInputSourceEvent extends Event {
  77338. readonly frame: XRFrame;
  77339. readonly inputSource: XRInputSource;
  77340. }
  77341. type XRInputSourceArray = XRInputSource[];
  77342. interface XRSession {
  77343. addEventListener(type: XREventType, listener: XREventHandler, options?: boolean | AddEventListenerOptions): void;
  77344. removeEventListener(type: XREventType, listener: XREventHandler, options?: boolean | EventListenerOptions): void;
  77345. /**
  77346. * Returns a list of this session's XRInputSources, each representing an input device
  77347. * used to control the camera and/or scene.
  77348. */
  77349. readonly inputSources: Array<XRInputSource>;
  77350. /**
  77351. * object which contains options affecting how the imagery is rendered.
  77352. * This includes things such as the near and far clipping planes
  77353. */
  77354. readonly renderState: XRRenderState;
  77355. readonly visibilityState: XRVisibilityState;
  77356. /**
  77357. * Removes a callback from the animation frame painting callback from
  77358. * XRSession's set of animation frame rendering callbacks, given the
  77359. * identifying handle returned by a previous call to requestAnimationFrame().
  77360. */
  77361. cancelAnimationFrame: (handle: number) => void;
  77362. /**
  77363. * Ends the WebXR session. Returns a promise which resolves when the
  77364. * session has been shut down.
  77365. */
  77366. end(): Promise<void>;
  77367. /**
  77368. * Schedules the specified method to be called the next time the user agent
  77369. * is working on rendering an animation frame for the WebXR device. Returns an
  77370. * integer value which can be used to identify the request for the purposes of
  77371. * canceling the callback using cancelAnimationFrame(). This method is comparable
  77372. * to the Window.requestAnimationFrame() method.
  77373. */
  77374. requestAnimationFrame: XRFrameRequestCallback;
  77375. /**
  77376. * Requests that a new XRReferenceSpace of the specified type be created.
  77377. * Returns a promise which resolves with the XRReferenceSpace or
  77378. * XRBoundedReferenceSpace which was requested, or throws a NotSupportedError if
  77379. * the requested space type isn't supported by the device.
  77380. */
  77381. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace | XRBoundedReferenceSpace>;
  77382. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  77383. onend: XREventHandler;
  77384. oninputsourceschange: XREventHandler;
  77385. onselect: XREventHandler;
  77386. onselectstart: XREventHandler;
  77387. onselectend: XREventHandler;
  77388. onsqueeze: XREventHandler;
  77389. onsqueezestart: XREventHandler;
  77390. onsqueezeend: XREventHandler;
  77391. onvisibilitychange: XREventHandler;
  77392. // hit test
  77393. requestHitTestSource?(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  77394. requestHitTestSourceForTransientInput?(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  77395. // legacy AR hit test
  77396. requestHitTest?(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  77397. // legacy plane detection
  77398. updateWorldTrackingState?(options: { planeDetectionState?: { enabled: boolean } }): void;
  77399. }
  77400. interface XRViewerPose extends XRPose {
  77401. readonly views: Array<XRView>;
  77402. }
  77403. declare class XRRigidTransform {
  77404. constructor(position?: DOMPointInit, direction?: DOMPointInit);
  77405. position: DOMPointReadOnly;
  77406. orientation: DOMPointReadOnly;
  77407. matrix: Float32Array;
  77408. inverse: XRRigidTransform;
  77409. }
  77410. interface XRView {
  77411. readonly eye: XREye;
  77412. readonly projectionMatrix: Float32Array;
  77413. readonly transform: XRRigidTransform;
  77414. readonly recommendedViewportScale?: number;
  77415. requestViewportScale(scale: number): void;
  77416. }
  77417. interface XRInputSourceChangeEvent extends Event {
  77418. session: XRSession;
  77419. removed: Array<XRInputSource>;
  77420. added: Array<XRInputSource>;
  77421. }
  77422. // Experimental/Draft features
  77423. declare class XRRay {
  77424. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  77425. origin: DOMPointReadOnly;
  77426. direction: DOMPointReadOnly;
  77427. matrix: Float32Array;
  77428. }
  77429. declare enum XRHitTestTrackableType {
  77430. "point",
  77431. "plane",
  77432. "mesh",
  77433. }
  77434. interface XRHitResult {
  77435. hitMatrix: Float32Array;
  77436. }
  77437. interface XRTransientInputHitTestResult {
  77438. readonly inputSource: XRInputSource;
  77439. readonly results: Array<XRHitTestResult>;
  77440. }
  77441. interface XRHitTestResult {
  77442. getPose(baseSpace: XRSpace): XRPose | undefined;
  77443. // When anchor system is enabled
  77444. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  77445. }
  77446. interface XRHitTestSource {
  77447. cancel(): void;
  77448. }
  77449. interface XRTransientInputHitTestSource {
  77450. cancel(): void;
  77451. }
  77452. interface XRHitTestOptionsInit {
  77453. space: XRSpace;
  77454. entityTypes?: Array<XRHitTestTrackableType>;
  77455. offsetRay?: XRRay;
  77456. }
  77457. interface XRTransientInputHitTestOptionsInit {
  77458. profile: string;
  77459. entityTypes?: Array<XRHitTestTrackableType>;
  77460. offsetRay?: XRRay;
  77461. }
  77462. interface XRAnchor {
  77463. anchorSpace: XRSpace;
  77464. delete(): void;
  77465. }
  77466. interface XRPlane {
  77467. orientation: "Horizontal" | "Vertical";
  77468. planeSpace: XRSpace;
  77469. polygon: Array<DOMPointReadOnly>;
  77470. lastChangedTime: number;
  77471. }
  77472. interface XRJointSpace extends XRSpace {}
  77473. interface XRJointPose extends XRPose {
  77474. radius: number | undefined;
  77475. }
  77476. interface XRHand extends Iterable<XRJointSpace> {
  77477. readonly length: number;
  77478. [index: number]: XRJointSpace;
  77479. readonly WRIST: number;
  77480. readonly THUMB_METACARPAL: number;
  77481. readonly THUMB_PHALANX_PROXIMAL: number;
  77482. readonly THUMB_PHALANX_DISTAL: number;
  77483. readonly THUMB_PHALANX_TIP: number;
  77484. readonly INDEX_METACARPAL: number;
  77485. readonly INDEX_PHALANX_PROXIMAL: number;
  77486. readonly INDEX_PHALANX_INTERMEDIATE: number;
  77487. readonly INDEX_PHALANX_DISTAL: number;
  77488. readonly INDEX_PHALANX_TIP: number;
  77489. readonly MIDDLE_METACARPAL: number;
  77490. readonly MIDDLE_PHALANX_PROXIMAL: number;
  77491. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  77492. readonly MIDDLE_PHALANX_DISTAL: number;
  77493. readonly MIDDLE_PHALANX_TIP: number;
  77494. readonly RING_METACARPAL: number;
  77495. readonly RING_PHALANX_PROXIMAL: number;
  77496. readonly RING_PHALANX_INTERMEDIATE: number;
  77497. readonly RING_PHALANX_DISTAL: number;
  77498. readonly RING_PHALANX_TIP: number;
  77499. readonly LITTLE_METACARPAL: number;
  77500. readonly LITTLE_PHALANX_PROXIMAL: number;
  77501. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  77502. readonly LITTLE_PHALANX_DISTAL: number;
  77503. readonly LITTLE_PHALANX_TIP: number;
  77504. }
  77505. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  77506. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  77507. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  77508. interface XRSession {
  77509. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  77510. }
  77511. interface XRFrame {
  77512. featurePointCloud? : Array<number>;
  77513. }
  77514. /**
  77515. * @ignore
  77516. */
  77517. declare module BABYLON.GLTF2.Exporter {
  77518. }
  77519. /**
  77520. * @ignore
  77521. */
  77522. declare module BABYLON.GLTF1 {
  77523. }
  77524. declare module BABYLON.GUI {
  77525. /**
  77526. * Class used to specific a value and its associated unit
  77527. */
  77528. export class ValueAndUnit {
  77529. /** defines the unit to store */
  77530. unit: number;
  77531. /** defines a boolean indicating if the value can be negative */
  77532. negativeValueAllowed: boolean;
  77533. private _value;
  77534. private _originalUnit;
  77535. /**
  77536. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  77537. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77538. */
  77539. ignoreAdaptiveScaling: boolean;
  77540. /**
  77541. * Creates a new ValueAndUnit
  77542. * @param value defines the value to store
  77543. * @param unit defines the unit to store
  77544. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  77545. */
  77546. constructor(value: number,
  77547. /** defines the unit to store */
  77548. unit?: number,
  77549. /** defines a boolean indicating if the value can be negative */
  77550. negativeValueAllowed?: boolean);
  77551. /** Gets a boolean indicating if the value is a percentage */
  77552. get isPercentage(): boolean;
  77553. /** Gets a boolean indicating if the value is store as pixel */
  77554. get isPixel(): boolean;
  77555. /** Gets direct internal value */
  77556. get internalValue(): number;
  77557. /**
  77558. * Gets value as pixel
  77559. * @param host defines the root host
  77560. * @param refValue defines the reference value for percentages
  77561. * @returns the value as pixel
  77562. */
  77563. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  77564. /**
  77565. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  77566. * @param value defines the value to store
  77567. * @param unit defines the unit to store
  77568. * @returns the current ValueAndUnit
  77569. */
  77570. updateInPlace(value: number, unit?: number): ValueAndUnit;
  77571. /**
  77572. * Gets the value accordingly to its unit
  77573. * @param host defines the root host
  77574. * @returns the value
  77575. */
  77576. getValue(host: AdvancedDynamicTexture): number;
  77577. /**
  77578. * Gets a string representation of the value
  77579. * @param host defines the root host
  77580. * @param decimals defines an optional number of decimals to display
  77581. * @returns a string
  77582. */
  77583. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  77584. /**
  77585. * Store a value parsed from a string
  77586. * @param source defines the source string
  77587. * @returns true if the value was successfully parsed
  77588. */
  77589. fromString(source: string | number): boolean;
  77590. private static _Regex;
  77591. private static _UNITMODE_PERCENTAGE;
  77592. private static _UNITMODE_PIXEL;
  77593. /** UNITMODE_PERCENTAGE */
  77594. static get UNITMODE_PERCENTAGE(): number;
  77595. /** UNITMODE_PIXEL */
  77596. static get UNITMODE_PIXEL(): number;
  77597. }
  77598. }
  77599. declare module BABYLON.GUI {
  77600. /**
  77601. * Define a style used by control to automatically setup properties based on a template.
  77602. * Only support font related properties so far
  77603. */
  77604. export class Style implements BABYLON.IDisposable {
  77605. private _fontFamily;
  77606. private _fontStyle;
  77607. private _fontWeight;
  77608. /** @hidden */
  77609. _host: AdvancedDynamicTexture;
  77610. /** @hidden */
  77611. _fontSize: ValueAndUnit;
  77612. /**
  77613. * BABYLON.Observable raised when the style values are changed
  77614. */
  77615. onChangedObservable: BABYLON.Observable<Style>;
  77616. /**
  77617. * Creates a new style object
  77618. * @param host defines the AdvancedDynamicTexture which hosts this style
  77619. */
  77620. constructor(host: AdvancedDynamicTexture);
  77621. /**
  77622. * Gets or sets the font size
  77623. */
  77624. get fontSize(): string | number;
  77625. set fontSize(value: string | number);
  77626. /**
  77627. * Gets or sets the font family
  77628. */
  77629. get fontFamily(): string;
  77630. set fontFamily(value: string);
  77631. /**
  77632. * Gets or sets the font style
  77633. */
  77634. get fontStyle(): string;
  77635. set fontStyle(value: string);
  77636. /** Gets or sets font weight */
  77637. get fontWeight(): string;
  77638. set fontWeight(value: string);
  77639. /** Dispose all associated resources */
  77640. dispose(): void;
  77641. }
  77642. }
  77643. declare module BABYLON.GUI {
  77644. /**
  77645. * Class used to transport BABYLON.Vector2 information for pointer events
  77646. */
  77647. export class Vector2WithInfo extends BABYLON.Vector2 {
  77648. /** defines the current mouse button index */
  77649. buttonIndex: number;
  77650. /**
  77651. * Creates a new Vector2WithInfo
  77652. * @param source defines the vector2 data to transport
  77653. * @param buttonIndex defines the current mouse button index
  77654. */
  77655. constructor(source: BABYLON.Vector2,
  77656. /** defines the current mouse button index */
  77657. buttonIndex?: number);
  77658. }
  77659. /** Class used to provide 2D matrix features */
  77660. export class Matrix2D {
  77661. /** Gets the internal array of 6 floats used to store matrix data */
  77662. m: Float32Array;
  77663. /**
  77664. * Creates a new matrix
  77665. * @param m00 defines value for (0, 0)
  77666. * @param m01 defines value for (0, 1)
  77667. * @param m10 defines value for (1, 0)
  77668. * @param m11 defines value for (1, 1)
  77669. * @param m20 defines value for (2, 0)
  77670. * @param m21 defines value for (2, 1)
  77671. */
  77672. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  77673. /**
  77674. * Fills the matrix from direct values
  77675. * @param m00 defines value for (0, 0)
  77676. * @param m01 defines value for (0, 1)
  77677. * @param m10 defines value for (1, 0)
  77678. * @param m11 defines value for (1, 1)
  77679. * @param m20 defines value for (2, 0)
  77680. * @param m21 defines value for (2, 1)
  77681. * @returns the current modified matrix
  77682. */
  77683. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  77684. /**
  77685. * Gets matrix determinant
  77686. * @returns the determinant
  77687. */
  77688. determinant(): number;
  77689. /**
  77690. * Inverses the matrix and stores it in a target matrix
  77691. * @param result defines the target matrix
  77692. * @returns the current matrix
  77693. */
  77694. invertToRef(result: Matrix2D): Matrix2D;
  77695. /**
  77696. * Multiplies the current matrix with another one
  77697. * @param other defines the second operand
  77698. * @param result defines the target matrix
  77699. * @returns the current matrix
  77700. */
  77701. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  77702. /**
  77703. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  77704. * @param x defines the x coordinate to transform
  77705. * @param y defines the x coordinate to transform
  77706. * @param result defines the target vector2
  77707. * @returns the current matrix
  77708. */
  77709. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  77710. /**
  77711. * Creates an identity matrix
  77712. * @returns a new matrix
  77713. */
  77714. static Identity(): Matrix2D;
  77715. /**
  77716. * Creates a translation matrix and stores it in a target matrix
  77717. * @param x defines the x coordinate of the translation
  77718. * @param y defines the y coordinate of the translation
  77719. * @param result defines the target matrix
  77720. */
  77721. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  77722. /**
  77723. * Creates a scaling matrix and stores it in a target matrix
  77724. * @param x defines the x coordinate of the scaling
  77725. * @param y defines the y coordinate of the scaling
  77726. * @param result defines the target matrix
  77727. */
  77728. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  77729. /**
  77730. * Creates a rotation matrix and stores it in a target matrix
  77731. * @param angle defines the rotation angle
  77732. * @param result defines the target matrix
  77733. */
  77734. static RotationToRef(angle: number, result: Matrix2D): void;
  77735. private static _TempPreTranslationMatrix;
  77736. private static _TempPostTranslationMatrix;
  77737. private static _TempRotationMatrix;
  77738. private static _TempScalingMatrix;
  77739. private static _TempCompose0;
  77740. private static _TempCompose1;
  77741. private static _TempCompose2;
  77742. /**
  77743. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  77744. * @param tx defines the x coordinate of the translation
  77745. * @param ty defines the y coordinate of the translation
  77746. * @param angle defines the rotation angle
  77747. * @param scaleX defines the x coordinate of the scaling
  77748. * @param scaleY defines the y coordinate of the scaling
  77749. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  77750. * @param result defines the target matrix
  77751. */
  77752. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  77753. }
  77754. }
  77755. declare module BABYLON.GUI {
  77756. /**
  77757. * Class used to store 2D control sizes
  77758. */
  77759. export class Measure {
  77760. /** defines left coordinate */
  77761. left: number;
  77762. /** defines top coordinate */
  77763. top: number;
  77764. /** defines width dimension */
  77765. width: number;
  77766. /** defines height dimension */
  77767. height: number;
  77768. /**
  77769. * Creates a new measure
  77770. * @param left defines left coordinate
  77771. * @param top defines top coordinate
  77772. * @param width defines width dimension
  77773. * @param height defines height dimension
  77774. */
  77775. constructor(
  77776. /** defines left coordinate */
  77777. left: number,
  77778. /** defines top coordinate */
  77779. top: number,
  77780. /** defines width dimension */
  77781. width: number,
  77782. /** defines height dimension */
  77783. height: number);
  77784. /**
  77785. * Copy from another measure
  77786. * @param other defines the other measure to copy from
  77787. */
  77788. copyFrom(other: Measure): void;
  77789. /**
  77790. * Copy from a group of 4 floats
  77791. * @param left defines left coordinate
  77792. * @param top defines top coordinate
  77793. * @param width defines width dimension
  77794. * @param height defines height dimension
  77795. */
  77796. copyFromFloats(left: number, top: number, width: number, height: number): void;
  77797. /**
  77798. * Computes the axis aligned bounding box measure for two given measures
  77799. * @param a Input measure
  77800. * @param b Input measure
  77801. * @param result the resulting bounding measure
  77802. */
  77803. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  77804. /**
  77805. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  77806. * @param transform the matrix to transform the measure before computing the AABB
  77807. * @param addX number to add to left
  77808. * @param addY number to add to top
  77809. * @param addWidth number to add to width
  77810. * @param addHeight number to add to height
  77811. * @param result the resulting AABB
  77812. */
  77813. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  77814. /**
  77815. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  77816. * @param transform the matrix to transform the measure before computing the AABB
  77817. * @param result the resulting AABB
  77818. */
  77819. transformToRef(transform: Matrix2D, result: Measure): void;
  77820. /**
  77821. * Check equality between this measure and another one
  77822. * @param other defines the other measures
  77823. * @returns true if both measures are equals
  77824. */
  77825. isEqualsTo(other: Measure): boolean;
  77826. /**
  77827. * Creates an empty measure
  77828. * @returns a new measure
  77829. */
  77830. static Empty(): Measure;
  77831. }
  77832. }
  77833. declare module BABYLON.GUI {
  77834. /**
  77835. * Interface used to define a control that can receive focus
  77836. */
  77837. export interface IFocusableControl {
  77838. /**
  77839. * Function called when the control receives the focus
  77840. */
  77841. onFocus(): void;
  77842. /**
  77843. * Function called when the control loses the focus
  77844. */
  77845. onBlur(): void;
  77846. /**
  77847. * Function called to let the control handle keyboard events
  77848. * @param evt defines the current keyboard event
  77849. */
  77850. processKeyboard(evt: KeyboardEvent): void;
  77851. /**
  77852. * Function called to get the list of controls that should not steal the focus from this control
  77853. * @returns an array of controls
  77854. */
  77855. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  77856. }
  77857. /**
  77858. * Class used to create texture to support 2D GUI elements
  77859. * @see https://doc.babylonjs.com/how_to/gui
  77860. */
  77861. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  77862. private _isDirty;
  77863. private _renderObserver;
  77864. private _resizeObserver;
  77865. private _preKeyboardObserver;
  77866. private _pointerMoveObserver;
  77867. private _pointerObserver;
  77868. private _canvasPointerOutObserver;
  77869. private _canvasBlurObserver;
  77870. private _background;
  77871. /** @hidden */
  77872. _rootContainer: Container;
  77873. /** @hidden */
  77874. _lastPickedControl: Control;
  77875. /** @hidden */
  77876. _lastControlOver: {
  77877. [pointerId: number]: Control;
  77878. };
  77879. /** @hidden */
  77880. _lastControlDown: {
  77881. [pointerId: number]: Control;
  77882. };
  77883. /** @hidden */
  77884. _capturingControl: {
  77885. [pointerId: number]: Control;
  77886. };
  77887. /** @hidden */
  77888. _shouldBlockPointer: boolean;
  77889. /** @hidden */
  77890. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  77891. /** @hidden */
  77892. _linkedControls: Control[];
  77893. private _isFullscreen;
  77894. private _fullscreenViewport;
  77895. private _idealWidth;
  77896. private _idealHeight;
  77897. private _useSmallestIdeal;
  77898. private _renderAtIdealSize;
  77899. private _focusedControl;
  77900. private _blockNextFocusCheck;
  77901. private _renderScale;
  77902. private _rootElement;
  77903. private _cursorChanged;
  77904. private _defaultMousePointerId;
  77905. /** @hidden */
  77906. _numLayoutCalls: number;
  77907. /** Gets the number of layout calls made the last time the ADT has been rendered */
  77908. get numLayoutCalls(): number;
  77909. /** @hidden */
  77910. _numRenderCalls: number;
  77911. /** Gets the number of render calls made the last time the ADT has been rendered */
  77912. get numRenderCalls(): number;
  77913. /**
  77914. * Define type to string to ensure compatibility across browsers
  77915. * Safari doesn't support DataTransfer constructor
  77916. */
  77917. private _clipboardData;
  77918. /**
  77919. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  77920. */
  77921. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  77922. /**
  77923. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  77924. */
  77925. onControlPickedObservable: BABYLON.Observable<Control>;
  77926. /**
  77927. * BABYLON.Observable event triggered before layout is evaluated
  77928. */
  77929. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77930. /**
  77931. * BABYLON.Observable event triggered after the layout was evaluated
  77932. */
  77933. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77934. /**
  77935. * BABYLON.Observable event triggered before the texture is rendered
  77936. */
  77937. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77938. /**
  77939. * BABYLON.Observable event triggered after the texture was rendered
  77940. */
  77941. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77942. /**
  77943. * Gets or sets a boolean defining if alpha is stored as premultiplied
  77944. */
  77945. premulAlpha: boolean;
  77946. /**
  77947. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  77948. * Useful when you want more antialiasing
  77949. */
  77950. get renderScale(): number;
  77951. set renderScale(value: number);
  77952. /** Gets or sets the background color */
  77953. get background(): string;
  77954. set background(value: string);
  77955. /**
  77956. * Gets or sets the ideal width used to design controls.
  77957. * The GUI will then rescale everything accordingly
  77958. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77959. */
  77960. get idealWidth(): number;
  77961. set idealWidth(value: number);
  77962. /**
  77963. * Gets or sets the ideal height used to design controls.
  77964. * The GUI will then rescale everything accordingly
  77965. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77966. */
  77967. get idealHeight(): number;
  77968. set idealHeight(value: number);
  77969. /**
  77970. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  77971. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77972. */
  77973. get useSmallestIdeal(): boolean;
  77974. set useSmallestIdeal(value: boolean);
  77975. /**
  77976. * Gets or sets a boolean indicating if adaptive scaling must be used
  77977. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77978. */
  77979. get renderAtIdealSize(): boolean;
  77980. set renderAtIdealSize(value: boolean);
  77981. /**
  77982. * Gets the ratio used when in "ideal mode"
  77983. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77984. * */
  77985. get idealRatio(): number;
  77986. /**
  77987. * Gets the underlying layer used to render the texture when in fullscreen mode
  77988. */
  77989. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  77990. /**
  77991. * Gets the root container control
  77992. */
  77993. get rootContainer(): Container;
  77994. /**
  77995. * Returns an array containing the root container.
  77996. * This is mostly used to let the Inspector introspects the ADT
  77997. * @returns an array containing the rootContainer
  77998. */
  77999. getChildren(): Array<Container>;
  78000. /**
  78001. * Will return all controls that are inside this texture
  78002. * @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
  78003. * @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
  78004. * @return all child controls
  78005. */
  78006. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  78007. /**
  78008. * Gets or sets the current focused control
  78009. */
  78010. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  78011. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  78012. /**
  78013. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  78014. */
  78015. get isForeground(): boolean;
  78016. set isForeground(value: boolean);
  78017. /**
  78018. * Gets or set information about clipboardData
  78019. */
  78020. get clipboardData(): string;
  78021. set clipboardData(value: string);
  78022. /**
  78023. * Creates a new AdvancedDynamicTexture
  78024. * @param name defines the name of the texture
  78025. * @param width defines the width of the texture
  78026. * @param height defines the height of the texture
  78027. * @param scene defines the hosting scene
  78028. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  78029. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  78030. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  78031. */
  78032. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number, invertY?: boolean);
  78033. /**
  78034. * Get the current class name of the texture useful for serialization or dynamic coding.
  78035. * @returns "AdvancedDynamicTexture"
  78036. */
  78037. getClassName(): string;
  78038. /**
  78039. * Function used to execute a function on all controls
  78040. * @param func defines the function to execute
  78041. * @param container defines the container where controls belong. If null the root container will be used
  78042. */
  78043. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  78044. private _useInvalidateRectOptimization;
  78045. /**
  78046. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  78047. */
  78048. get useInvalidateRectOptimization(): boolean;
  78049. set useInvalidateRectOptimization(value: boolean);
  78050. private _invalidatedRectangle;
  78051. /**
  78052. * Invalidates a rectangle area on the gui texture
  78053. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  78054. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  78055. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  78056. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  78057. */
  78058. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  78059. /**
  78060. * Marks the texture as dirty forcing a complete update
  78061. */
  78062. markAsDirty(): void;
  78063. /**
  78064. * Helper function used to create a new style
  78065. * @returns a new style
  78066. * @see https://doc.babylonjs.com/how_to/gui#styles
  78067. */
  78068. createStyle(): Style;
  78069. /**
  78070. * Adds a new control to the root container
  78071. * @param control defines the control to add
  78072. * @returns the current texture
  78073. */
  78074. addControl(control: Control): AdvancedDynamicTexture;
  78075. /**
  78076. * Removes a control from the root container
  78077. * @param control defines the control to remove
  78078. * @returns the current texture
  78079. */
  78080. removeControl(control: Control): AdvancedDynamicTexture;
  78081. /**
  78082. * Release all resources
  78083. */
  78084. dispose(): void;
  78085. private _onResize;
  78086. /** @hidden */
  78087. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  78088. /**
  78089. * Get screen coordinates for a vector3
  78090. * @param position defines the position to project
  78091. * @param worldMatrix defines the world matrix to use
  78092. * @returns the projected position
  78093. */
  78094. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  78095. private _checkUpdate;
  78096. private _clearMeasure;
  78097. private _render;
  78098. /** @hidden */
  78099. _changeCursor(cursor: string): void;
  78100. /** @hidden */
  78101. _registerLastControlDown(control: Control, pointerId: number): void;
  78102. private _doPicking;
  78103. /** @hidden */
  78104. _cleanControlAfterRemovalFromList(list: {
  78105. [pointerId: number]: Control;
  78106. }, control: Control): void;
  78107. /** @hidden */
  78108. _cleanControlAfterRemoval(control: Control): void;
  78109. /** Attach to all scene events required to support pointer events */
  78110. attach(): void;
  78111. /** @hidden */
  78112. private onClipboardCopy;
  78113. /** @hidden */
  78114. private onClipboardCut;
  78115. /** @hidden */
  78116. private onClipboardPaste;
  78117. /**
  78118. * Register the clipboard Events onto the canvas
  78119. */
  78120. registerClipboardEvents(): void;
  78121. /**
  78122. * Unregister the clipboard Events from the canvas
  78123. */
  78124. unRegisterClipboardEvents(): void;
  78125. /**
  78126. * Connect the texture to a hosting mesh to enable interactions
  78127. * @param mesh defines the mesh to attach to
  78128. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  78129. */
  78130. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  78131. /**
  78132. * Move the focus to a specific control
  78133. * @param control defines the control which will receive the focus
  78134. */
  78135. moveFocusToControl(control: IFocusableControl): void;
  78136. private _manageFocus;
  78137. private _attachToOnPointerOut;
  78138. private _attachToOnBlur;
  78139. /**
  78140. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  78141. * @param mesh defines the mesh which will receive the texture
  78142. * @param width defines the texture width (1024 by default)
  78143. * @param height defines the texture height (1024 by default)
  78144. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  78145. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  78146. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  78147. * @returns a new AdvancedDynamicTexture
  78148. */
  78149. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  78150. /**
  78151. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  78152. * In this mode the texture will rely on a layer for its rendering.
  78153. * This allows it to be treated like any other layer.
  78154. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  78155. * LayerMask is set through advancedTexture.layer.layerMask
  78156. * @param name defines name for the texture
  78157. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  78158. * @param scene defines the hsoting scene
  78159. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  78160. * @returns a new AdvancedDynamicTexture
  78161. */
  78162. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  78163. }
  78164. }
  78165. declare module BABYLON.GUI {
  78166. /**
  78167. * Root class used for all 2D controls
  78168. * @see https://doc.babylonjs.com/how_to/gui#controls
  78169. */
  78170. export class Control {
  78171. /** defines the name of the control */
  78172. name?: string | undefined;
  78173. /**
  78174. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  78175. */
  78176. static AllowAlphaInheritance: boolean;
  78177. private _alpha;
  78178. private _alphaSet;
  78179. private _zIndex;
  78180. /** @hidden */
  78181. _host: AdvancedDynamicTexture;
  78182. /** Gets or sets the control parent */
  78183. parent: BABYLON.Nullable<Container>;
  78184. /** @hidden */
  78185. _currentMeasure: Measure;
  78186. private _fontFamily;
  78187. private _fontStyle;
  78188. private _fontWeight;
  78189. private _fontSize;
  78190. private _font;
  78191. /** @hidden */
  78192. _width: ValueAndUnit;
  78193. /** @hidden */
  78194. _height: ValueAndUnit;
  78195. /** @hidden */
  78196. protected _fontOffset: {
  78197. ascent: number;
  78198. height: number;
  78199. descent: number;
  78200. };
  78201. private _color;
  78202. private _style;
  78203. private _styleObserver;
  78204. /** @hidden */
  78205. protected _horizontalAlignment: number;
  78206. /** @hidden */
  78207. protected _verticalAlignment: number;
  78208. /** @hidden */
  78209. protected _isDirty: boolean;
  78210. /** @hidden */
  78211. protected _wasDirty: boolean;
  78212. /** @hidden */
  78213. _tempParentMeasure: Measure;
  78214. /** @hidden */
  78215. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  78216. /** @hidden */
  78217. protected _cachedParentMeasure: Measure;
  78218. private _paddingLeft;
  78219. private _paddingRight;
  78220. private _paddingTop;
  78221. private _paddingBottom;
  78222. /** @hidden */
  78223. _left: ValueAndUnit;
  78224. /** @hidden */
  78225. _top: ValueAndUnit;
  78226. private _scaleX;
  78227. private _scaleY;
  78228. private _rotation;
  78229. private _transformCenterX;
  78230. private _transformCenterY;
  78231. /** @hidden */
  78232. _transformMatrix: Matrix2D;
  78233. /** @hidden */
  78234. protected _invertTransformMatrix: Matrix2D;
  78235. /** @hidden */
  78236. protected _transformedPosition: BABYLON.Vector2;
  78237. private _isMatrixDirty;
  78238. private _cachedOffsetX;
  78239. private _cachedOffsetY;
  78240. private _isVisible;
  78241. private _isHighlighted;
  78242. /** @hidden */
  78243. _linkedMesh: BABYLON.Nullable<BABYLON.TransformNode>;
  78244. private _fontSet;
  78245. private _dummyVector2;
  78246. private _downCount;
  78247. private _enterCount;
  78248. private _doNotRender;
  78249. private _downPointerIds;
  78250. protected _isEnabled: boolean;
  78251. protected _disabledColor: string;
  78252. protected _disabledColorItem: string;
  78253. /** @hidden */
  78254. protected _rebuildLayout: boolean;
  78255. /** @hidden */
  78256. _customData: any;
  78257. /** @hidden */
  78258. _isClipped: boolean;
  78259. /** @hidden */
  78260. _automaticSize: boolean;
  78261. /** @hidden */
  78262. _tag: any;
  78263. /**
  78264. * 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
  78265. */
  78266. uniqueId: number;
  78267. /**
  78268. * Gets or sets an object used to store user defined information for the node
  78269. */
  78270. metadata: any;
  78271. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  78272. isHitTestVisible: boolean;
  78273. /** Gets or sets a boolean indicating if the control can block pointer events */
  78274. isPointerBlocker: boolean;
  78275. /** Gets or sets a boolean indicating if the control can be focusable */
  78276. isFocusInvisible: boolean;
  78277. /**
  78278. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  78279. * 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
  78280. */
  78281. clipChildren: boolean;
  78282. /**
  78283. * Gets or sets a boolean indicating that control content must be clipped
  78284. * 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
  78285. */
  78286. clipContent: boolean;
  78287. /**
  78288. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  78289. */
  78290. useBitmapCache: boolean;
  78291. private _cacheData;
  78292. private _shadowOffsetX;
  78293. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  78294. get shadowOffsetX(): number;
  78295. set shadowOffsetX(value: number);
  78296. private _shadowOffsetY;
  78297. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  78298. get shadowOffsetY(): number;
  78299. set shadowOffsetY(value: number);
  78300. private _shadowBlur;
  78301. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  78302. get shadowBlur(): number;
  78303. set shadowBlur(value: number);
  78304. private _shadowColor;
  78305. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  78306. get shadowColor(): string;
  78307. set shadowColor(value: string);
  78308. /** Gets or sets the cursor to use when the control is hovered */
  78309. hoverCursor: string;
  78310. /** @hidden */
  78311. protected _linkOffsetX: ValueAndUnit;
  78312. /** @hidden */
  78313. protected _linkOffsetY: ValueAndUnit;
  78314. /** Gets the control type name */
  78315. get typeName(): string;
  78316. /**
  78317. * Get the current class name of the control.
  78318. * @returns current class name
  78319. */
  78320. getClassName(): string;
  78321. /**
  78322. * An event triggered when pointer wheel is scrolled
  78323. */
  78324. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  78325. /**
  78326. * An event triggered when the pointer move over the control.
  78327. */
  78328. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  78329. /**
  78330. * An event triggered when the pointer move out of the control.
  78331. */
  78332. onPointerOutObservable: BABYLON.Observable<Control>;
  78333. /**
  78334. * An event triggered when the pointer taps the control
  78335. */
  78336. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  78337. /**
  78338. * An event triggered when pointer up
  78339. */
  78340. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  78341. /**
  78342. * An event triggered when a control is clicked on
  78343. */
  78344. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  78345. /**
  78346. * An event triggered when pointer enters the control
  78347. */
  78348. onPointerEnterObservable: BABYLON.Observable<Control>;
  78349. /**
  78350. * An event triggered when the control is marked as dirty
  78351. */
  78352. onDirtyObservable: BABYLON.Observable<Control>;
  78353. /**
  78354. * An event triggered before drawing the control
  78355. */
  78356. onBeforeDrawObservable: BABYLON.Observable<Control>;
  78357. /**
  78358. * An event triggered after the control was drawn
  78359. */
  78360. onAfterDrawObservable: BABYLON.Observable<Control>;
  78361. /**
  78362. * An event triggered when the control has been disposed
  78363. */
  78364. onDisposeObservable: BABYLON.Observable<Control>;
  78365. /**
  78366. * Get the hosting AdvancedDynamicTexture
  78367. */
  78368. get host(): AdvancedDynamicTexture;
  78369. /** Gets or set information about font offsets (used to render and align text) */
  78370. get fontOffset(): {
  78371. ascent: number;
  78372. height: number;
  78373. descent: number;
  78374. };
  78375. set fontOffset(offset: {
  78376. ascent: number;
  78377. height: number;
  78378. descent: number;
  78379. });
  78380. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  78381. get alpha(): number;
  78382. set alpha(value: number);
  78383. /**
  78384. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  78385. */
  78386. get isHighlighted(): boolean;
  78387. set isHighlighted(value: boolean);
  78388. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  78389. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78390. */
  78391. get scaleX(): number;
  78392. set scaleX(value: number);
  78393. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  78394. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78395. */
  78396. get scaleY(): number;
  78397. set scaleY(value: number);
  78398. /** Gets or sets the rotation angle (0 by default)
  78399. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78400. */
  78401. get rotation(): number;
  78402. set rotation(value: number);
  78403. /** Gets or sets the transformation center on Y axis (0 by default)
  78404. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78405. */
  78406. get transformCenterY(): number;
  78407. set transformCenterY(value: number);
  78408. /** Gets or sets the transformation center on X axis (0 by default)
  78409. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78410. */
  78411. get transformCenterX(): number;
  78412. set transformCenterX(value: number);
  78413. /**
  78414. * Gets or sets the horizontal alignment
  78415. * @see https://doc.babylonjs.com/how_to/gui#alignments
  78416. */
  78417. get horizontalAlignment(): number;
  78418. set horizontalAlignment(value: number);
  78419. /**
  78420. * Gets or sets the vertical alignment
  78421. * @see https://doc.babylonjs.com/how_to/gui#alignments
  78422. */
  78423. get verticalAlignment(): number;
  78424. set verticalAlignment(value: number);
  78425. /**
  78426. * Gets or sets a fixed ratio for this control.
  78427. * When different from 0, the ratio is used to compute the "second" dimension.
  78428. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  78429. * second dimension is computed as first dimension * fixedRatio
  78430. */
  78431. fixedRatio: number;
  78432. private _fixedRatioMasterIsWidth;
  78433. /**
  78434. * Gets or sets control width
  78435. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78436. */
  78437. get width(): string | number;
  78438. set width(value: string | number);
  78439. /**
  78440. * Gets or sets the control width in pixel
  78441. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78442. */
  78443. get widthInPixels(): number;
  78444. set widthInPixels(value: number);
  78445. /**
  78446. * Gets or sets control height
  78447. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78448. */
  78449. get height(): string | number;
  78450. set height(value: string | number);
  78451. /**
  78452. * Gets or sets control height in pixel
  78453. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78454. */
  78455. get heightInPixels(): number;
  78456. set heightInPixels(value: number);
  78457. /** Gets or set font family */
  78458. get fontFamily(): string;
  78459. set fontFamily(value: string);
  78460. /** Gets or sets font style */
  78461. get fontStyle(): string;
  78462. set fontStyle(value: string);
  78463. /** Gets or sets font weight */
  78464. get fontWeight(): string;
  78465. set fontWeight(value: string);
  78466. /**
  78467. * Gets or sets style
  78468. * @see https://doc.babylonjs.com/how_to/gui#styles
  78469. */
  78470. get style(): BABYLON.Nullable<Style>;
  78471. set style(value: BABYLON.Nullable<Style>);
  78472. /** @hidden */
  78473. get _isFontSizeInPercentage(): boolean;
  78474. /** Gets or sets font size in pixels */
  78475. get fontSizeInPixels(): number;
  78476. set fontSizeInPixels(value: number);
  78477. /** Gets or sets font size */
  78478. get fontSize(): string | number;
  78479. set fontSize(value: string | number);
  78480. /** Gets or sets foreground color */
  78481. get color(): string;
  78482. set color(value: string);
  78483. /** Gets or sets z index which is used to reorder controls on the z axis */
  78484. get zIndex(): number;
  78485. set zIndex(value: number);
  78486. /** Gets or sets a boolean indicating if the control can be rendered */
  78487. get notRenderable(): boolean;
  78488. set notRenderable(value: boolean);
  78489. /** Gets or sets a boolean indicating if the control is visible */
  78490. get isVisible(): boolean;
  78491. set isVisible(value: boolean);
  78492. /** Gets a boolean indicating that the control needs to update its rendering */
  78493. get isDirty(): boolean;
  78494. /**
  78495. * Gets the current linked mesh (or null if none)
  78496. */
  78497. get linkedMesh(): BABYLON.Nullable<BABYLON.TransformNode>;
  78498. /**
  78499. * Gets or sets a value indicating the padding to use on the left of the control
  78500. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78501. */
  78502. get paddingLeft(): string | number;
  78503. set paddingLeft(value: string | number);
  78504. /**
  78505. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  78506. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78507. */
  78508. get paddingLeftInPixels(): number;
  78509. set paddingLeftInPixels(value: number);
  78510. /**
  78511. * Gets or sets a value indicating the padding to use on the right of the control
  78512. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78513. */
  78514. get paddingRight(): string | number;
  78515. set paddingRight(value: string | number);
  78516. /**
  78517. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  78518. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78519. */
  78520. get paddingRightInPixels(): number;
  78521. set paddingRightInPixels(value: number);
  78522. /**
  78523. * Gets or sets a value indicating the padding to use on the top of the control
  78524. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78525. */
  78526. get paddingTop(): string | number;
  78527. set paddingTop(value: string | number);
  78528. /**
  78529. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  78530. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78531. */
  78532. get paddingTopInPixels(): number;
  78533. set paddingTopInPixels(value: number);
  78534. /**
  78535. * Gets or sets a value indicating the padding to use on the bottom of the control
  78536. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78537. */
  78538. get paddingBottom(): string | number;
  78539. set paddingBottom(value: string | number);
  78540. /**
  78541. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  78542. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78543. */
  78544. get paddingBottomInPixels(): number;
  78545. set paddingBottomInPixels(value: number);
  78546. /**
  78547. * Gets or sets a value indicating the left coordinate of the control
  78548. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78549. */
  78550. get left(): string | number;
  78551. set left(value: string | number);
  78552. /**
  78553. * Gets or sets a value indicating the left coordinate in pixels of the control
  78554. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78555. */
  78556. get leftInPixels(): number;
  78557. set leftInPixels(value: number);
  78558. /**
  78559. * Gets or sets a value indicating the top coordinate of the control
  78560. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78561. */
  78562. get top(): string | number;
  78563. set top(value: string | number);
  78564. /**
  78565. * Gets or sets a value indicating the top coordinate in pixels of the control
  78566. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78567. */
  78568. get topInPixels(): number;
  78569. set topInPixels(value: number);
  78570. /**
  78571. * Gets or sets a value indicating the offset on X axis to the linked mesh
  78572. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78573. */
  78574. get linkOffsetX(): string | number;
  78575. set linkOffsetX(value: string | number);
  78576. /**
  78577. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  78578. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78579. */
  78580. get linkOffsetXInPixels(): number;
  78581. set linkOffsetXInPixels(value: number);
  78582. /**
  78583. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  78584. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78585. */
  78586. get linkOffsetY(): string | number;
  78587. set linkOffsetY(value: string | number);
  78588. /**
  78589. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  78590. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78591. */
  78592. get linkOffsetYInPixels(): number;
  78593. set linkOffsetYInPixels(value: number);
  78594. /** Gets the center coordinate on X axis */
  78595. get centerX(): number;
  78596. /** Gets the center coordinate on Y axis */
  78597. get centerY(): number;
  78598. /** Gets or sets if control is Enabled*/
  78599. get isEnabled(): boolean;
  78600. set isEnabled(value: boolean);
  78601. /** Gets or sets background color of control if it's disabled*/
  78602. get disabledColor(): string;
  78603. set disabledColor(value: string);
  78604. /** Gets or sets front color of control if it's disabled*/
  78605. get disabledColorItem(): string;
  78606. set disabledColorItem(value: string);
  78607. /**
  78608. * Creates a new control
  78609. * @param name defines the name of the control
  78610. */
  78611. constructor(
  78612. /** defines the name of the control */
  78613. name?: string | undefined);
  78614. /** @hidden */
  78615. protected _getTypeName(): string;
  78616. /**
  78617. * Gets the first ascendant in the hierarchy of the given type
  78618. * @param className defines the required type
  78619. * @returns the ascendant or null if not found
  78620. */
  78621. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  78622. /** @hidden */
  78623. _resetFontCache(): void;
  78624. /**
  78625. * Determines if a container is an ascendant of the current control
  78626. * @param container defines the container to look for
  78627. * @returns true if the container is one of the ascendant of the control
  78628. */
  78629. isAscendant(container: Control): boolean;
  78630. /**
  78631. * Gets coordinates in local control space
  78632. * @param globalCoordinates defines the coordinates to transform
  78633. * @returns the new coordinates in local space
  78634. */
  78635. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  78636. /**
  78637. * Gets coordinates in local control space
  78638. * @param globalCoordinates defines the coordinates to transform
  78639. * @param result defines the target vector2 where to store the result
  78640. * @returns the current control
  78641. */
  78642. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  78643. /**
  78644. * Gets coordinates in parent local control space
  78645. * @param globalCoordinates defines the coordinates to transform
  78646. * @returns the new coordinates in parent local space
  78647. */
  78648. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  78649. /**
  78650. * Move the current control to a vector3 position projected onto the screen.
  78651. * @param position defines the target position
  78652. * @param scene defines the hosting scene
  78653. */
  78654. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  78655. /**
  78656. * Will store all controls that have this control as ascendant in a given array
  78657. * @param results defines the array where to store the descendants
  78658. * @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
  78659. * @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
  78660. */
  78661. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  78662. /**
  78663. * Will return all controls that have this control as ascendant
  78664. * @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
  78665. * @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
  78666. * @return all child controls
  78667. */
  78668. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  78669. /**
  78670. * Link current control with a target mesh
  78671. * @param mesh defines the mesh to link with
  78672. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78673. */
  78674. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.TransformNode>): void;
  78675. /** @hidden */
  78676. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  78677. /** @hidden */
  78678. _offsetLeft(offset: number): void;
  78679. /** @hidden */
  78680. _offsetTop(offset: number): void;
  78681. /** @hidden */
  78682. _markMatrixAsDirty(): void;
  78683. /** @hidden */
  78684. _flagDescendantsAsMatrixDirty(): void;
  78685. /** @hidden */
  78686. _intersectsRect(rect: Measure): boolean;
  78687. /** @hidden */
  78688. protected invalidateRect(): void;
  78689. /** @hidden */
  78690. _markAsDirty(force?: boolean): void;
  78691. /** @hidden */
  78692. _markAllAsDirty(): void;
  78693. /** @hidden */
  78694. _link(host: AdvancedDynamicTexture): void;
  78695. /** @hidden */
  78696. protected _transform(context?: CanvasRenderingContext2D): void;
  78697. /** @hidden */
  78698. _renderHighlight(context: CanvasRenderingContext2D): void;
  78699. /** @hidden */
  78700. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  78701. /** @hidden */
  78702. protected _applyStates(context: CanvasRenderingContext2D): void;
  78703. /** @hidden */
  78704. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  78705. /** @hidden */
  78706. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78707. protected _evaluateClippingState(parentMeasure: Measure): void;
  78708. /** @hidden */
  78709. _measure(): void;
  78710. /** @hidden */
  78711. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78712. /** @hidden */
  78713. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78714. /** @hidden */
  78715. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78716. /** @hidden */
  78717. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  78718. private static _ClipMeasure;
  78719. private _tmpMeasureA;
  78720. private _clip;
  78721. /** @hidden */
  78722. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  78723. /** @hidden */
  78724. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78725. /**
  78726. * Tests if a given coordinates belong to the current control
  78727. * @param x defines x coordinate to test
  78728. * @param y defines y coordinate to test
  78729. * @returns true if the coordinates are inside the control
  78730. */
  78731. contains(x: number, y: number): boolean;
  78732. /** @hidden */
  78733. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78734. /** @hidden */
  78735. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  78736. /** @hidden */
  78737. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  78738. /** @hidden */
  78739. _onPointerOut(target: Control, pi: BABYLON.Nullable<BABYLON.PointerInfoBase>, force?: boolean): void;
  78740. /** @hidden */
  78741. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  78742. /** @hidden */
  78743. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi?: BABYLON.PointerInfoBase): void;
  78744. /** @hidden */
  78745. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  78746. /** @hidden */
  78747. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  78748. /** @hidden */
  78749. _onCanvasBlur(): void;
  78750. /** @hidden */
  78751. _processObservables(type: number, x: number, y: number, pi: BABYLON.PointerInfoBase, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78752. private _prepareFont;
  78753. /** Releases associated resources */
  78754. dispose(): void;
  78755. private static _HORIZONTAL_ALIGNMENT_LEFT;
  78756. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  78757. private static _HORIZONTAL_ALIGNMENT_CENTER;
  78758. private static _VERTICAL_ALIGNMENT_TOP;
  78759. private static _VERTICAL_ALIGNMENT_BOTTOM;
  78760. private static _VERTICAL_ALIGNMENT_CENTER;
  78761. /** HORIZONTAL_ALIGNMENT_LEFT */
  78762. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  78763. /** HORIZONTAL_ALIGNMENT_RIGHT */
  78764. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  78765. /** HORIZONTAL_ALIGNMENT_CENTER */
  78766. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  78767. /** VERTICAL_ALIGNMENT_TOP */
  78768. static get VERTICAL_ALIGNMENT_TOP(): number;
  78769. /** VERTICAL_ALIGNMENT_BOTTOM */
  78770. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  78771. /** VERTICAL_ALIGNMENT_CENTER */
  78772. static get VERTICAL_ALIGNMENT_CENTER(): number;
  78773. private static _FontHeightSizes;
  78774. /** @hidden */
  78775. static _GetFontOffset(font: string): {
  78776. ascent: number;
  78777. height: number;
  78778. descent: number;
  78779. };
  78780. /**
  78781. * Creates a stack panel that can be used to render headers
  78782. * @param control defines the control to associate with the header
  78783. * @param text defines the text of the header
  78784. * @param size defines the size of the header
  78785. * @param options defines options used to configure the header
  78786. * @returns a new StackPanel
  78787. * @ignore
  78788. * @hidden
  78789. */
  78790. static AddHeader: (control: Control, text: string, size: string | number, options: {
  78791. isHorizontal: boolean;
  78792. controlFirst: boolean;
  78793. }) => any;
  78794. /** @hidden */
  78795. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  78796. }
  78797. }
  78798. declare module BABYLON.GUI {
  78799. /**
  78800. * Root class for 2D containers
  78801. * @see https://doc.babylonjs.com/how_to/gui#containers
  78802. */
  78803. export class Container extends Control {
  78804. name?: string | undefined;
  78805. /** @hidden */
  78806. _children: Control[];
  78807. /** @hidden */
  78808. protected _measureForChildren: Measure;
  78809. /** @hidden */
  78810. protected _background: string;
  78811. /** @hidden */
  78812. protected _adaptWidthToChildren: boolean;
  78813. /** @hidden */
  78814. protected _adaptHeightToChildren: boolean;
  78815. /**
  78816. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  78817. */
  78818. logLayoutCycleErrors: boolean;
  78819. /**
  78820. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  78821. */
  78822. maxLayoutCycle: number;
  78823. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  78824. get adaptHeightToChildren(): boolean;
  78825. set adaptHeightToChildren(value: boolean);
  78826. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  78827. get adaptWidthToChildren(): boolean;
  78828. set adaptWidthToChildren(value: boolean);
  78829. /** Gets or sets background color */
  78830. get background(): string;
  78831. set background(value: string);
  78832. /** Gets the list of children */
  78833. get children(): Control[];
  78834. /**
  78835. * Creates a new Container
  78836. * @param name defines the name of the container
  78837. */
  78838. constructor(name?: string | undefined);
  78839. protected _getTypeName(): string;
  78840. _flagDescendantsAsMatrixDirty(): void;
  78841. /**
  78842. * Gets a child using its name
  78843. * @param name defines the child name to look for
  78844. * @returns the child control if found
  78845. */
  78846. getChildByName(name: string): BABYLON.Nullable<Control>;
  78847. /**
  78848. * Gets a child using its type and its name
  78849. * @param name defines the child name to look for
  78850. * @param type defines the child type to look for
  78851. * @returns the child control if found
  78852. */
  78853. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  78854. /**
  78855. * Search for a specific control in children
  78856. * @param control defines the control to look for
  78857. * @returns true if the control is in child list
  78858. */
  78859. containsControl(control: Control): boolean;
  78860. /**
  78861. * Adds a new control to the current container
  78862. * @param control defines the control to add
  78863. * @returns the current container
  78864. */
  78865. addControl(control: BABYLON.Nullable<Control>): Container;
  78866. /**
  78867. * Removes all controls from the current container
  78868. * @returns the current container
  78869. */
  78870. clearControls(): Container;
  78871. /**
  78872. * Removes a control from the current container
  78873. * @param control defines the control to remove
  78874. * @returns the current container
  78875. */
  78876. removeControl(control: Control): Container;
  78877. /** @hidden */
  78878. _reOrderControl(control: Control): void;
  78879. /** @hidden */
  78880. _offsetLeft(offset: number): void;
  78881. /** @hidden */
  78882. _offsetTop(offset: number): void;
  78883. /** @hidden */
  78884. _markAllAsDirty(): void;
  78885. /** @hidden */
  78886. protected _localDraw(context: CanvasRenderingContext2D): void;
  78887. /** @hidden */
  78888. _link(host: AdvancedDynamicTexture): void;
  78889. /** @hidden */
  78890. protected _beforeLayout(): void;
  78891. /** @hidden */
  78892. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78893. /** @hidden */
  78894. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  78895. protected _postMeasure(): void;
  78896. /** @hidden */
  78897. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  78898. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  78899. /** @hidden */
  78900. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78901. /** @hidden */
  78902. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78903. /** Releases associated resources */
  78904. dispose(): void;
  78905. }
  78906. }
  78907. declare module BABYLON.GUI {
  78908. /** Class used to create rectangle container */
  78909. export class Rectangle extends Container {
  78910. name?: string | undefined;
  78911. private _thickness;
  78912. private _cornerRadius;
  78913. /** Gets or sets border thickness */
  78914. get thickness(): number;
  78915. set thickness(value: number);
  78916. /** Gets or sets the corner radius angle */
  78917. get cornerRadius(): number;
  78918. set cornerRadius(value: number);
  78919. /**
  78920. * Creates a new Rectangle
  78921. * @param name defines the control name
  78922. */
  78923. constructor(name?: string | undefined);
  78924. protected _getTypeName(): string;
  78925. protected _localDraw(context: CanvasRenderingContext2D): void;
  78926. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78927. private _drawRoundedRect;
  78928. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  78929. }
  78930. }
  78931. declare module BABYLON.GUI {
  78932. /**
  78933. * Enum that determines the text-wrapping mode to use.
  78934. */
  78935. export enum TextWrapping {
  78936. /**
  78937. * Clip the text when it's larger than Control.width; this is the default mode.
  78938. */
  78939. Clip = 0,
  78940. /**
  78941. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  78942. */
  78943. WordWrap = 1,
  78944. /**
  78945. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  78946. */
  78947. Ellipsis = 2
  78948. }
  78949. /**
  78950. * Class used to create text block control
  78951. */
  78952. export class TextBlock extends Control {
  78953. /**
  78954. * Defines the name of the control
  78955. */
  78956. name?: string | undefined;
  78957. private _text;
  78958. private _textWrapping;
  78959. private _textHorizontalAlignment;
  78960. private _textVerticalAlignment;
  78961. private _lines;
  78962. private _resizeToFit;
  78963. private _lineSpacing;
  78964. private _outlineWidth;
  78965. private _outlineColor;
  78966. private _underline;
  78967. private _lineThrough;
  78968. /**
  78969. * An event triggered after the text is changed
  78970. */
  78971. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  78972. /**
  78973. * An event triggered after the text was broken up into lines
  78974. */
  78975. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  78976. /**
  78977. * Function used to split a string into words. By default, a string is split at each space character found
  78978. */
  78979. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  78980. /**
  78981. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  78982. */
  78983. get lines(): any[];
  78984. /**
  78985. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  78986. */
  78987. get resizeToFit(): boolean;
  78988. /**
  78989. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  78990. */
  78991. set resizeToFit(value: boolean);
  78992. /**
  78993. * Gets or sets a boolean indicating if text must be wrapped
  78994. */
  78995. get textWrapping(): TextWrapping | boolean;
  78996. /**
  78997. * Gets or sets a boolean indicating if text must be wrapped
  78998. */
  78999. set textWrapping(value: TextWrapping | boolean);
  79000. /**
  79001. * Gets or sets text to display
  79002. */
  79003. get text(): string;
  79004. /**
  79005. * Gets or sets text to display
  79006. */
  79007. set text(value: string);
  79008. /**
  79009. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  79010. */
  79011. get textHorizontalAlignment(): number;
  79012. /**
  79013. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  79014. */
  79015. set textHorizontalAlignment(value: number);
  79016. /**
  79017. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  79018. */
  79019. get textVerticalAlignment(): number;
  79020. /**
  79021. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  79022. */
  79023. set textVerticalAlignment(value: number);
  79024. /**
  79025. * Gets or sets line spacing value
  79026. */
  79027. set lineSpacing(value: string | number);
  79028. /**
  79029. * Gets or sets line spacing value
  79030. */
  79031. get lineSpacing(): string | number;
  79032. /**
  79033. * Gets or sets outlineWidth of the text to display
  79034. */
  79035. get outlineWidth(): number;
  79036. /**
  79037. * Gets or sets outlineWidth of the text to display
  79038. */
  79039. set outlineWidth(value: number);
  79040. /**
  79041. * Gets or sets a boolean indicating that text must have underline
  79042. */
  79043. get underline(): boolean;
  79044. /**
  79045. * Gets or sets a boolean indicating that text must have underline
  79046. */
  79047. set underline(value: boolean);
  79048. /**
  79049. * Gets or sets an boolean indicating that text must be crossed out
  79050. */
  79051. get lineThrough(): boolean;
  79052. /**
  79053. * Gets or sets an boolean indicating that text must be crossed out
  79054. */
  79055. set lineThrough(value: boolean);
  79056. /**
  79057. * Gets or sets outlineColor of the text to display
  79058. */
  79059. get outlineColor(): string;
  79060. /**
  79061. * Gets or sets outlineColor of the text to display
  79062. */
  79063. set outlineColor(value: string);
  79064. /**
  79065. * Creates a new TextBlock object
  79066. * @param name defines the name of the control
  79067. * @param text defines the text to display (emptry string by default)
  79068. */
  79069. constructor(
  79070. /**
  79071. * Defines the name of the control
  79072. */
  79073. name?: string | undefined, text?: string);
  79074. protected _getTypeName(): string;
  79075. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79076. private _drawText;
  79077. /** @hidden */
  79078. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79079. protected _applyStates(context: CanvasRenderingContext2D): void;
  79080. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  79081. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  79082. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  79083. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  79084. protected _renderLines(context: CanvasRenderingContext2D): void;
  79085. /**
  79086. * Given a width constraint applied on the text block, find the expected height
  79087. * @returns expected height
  79088. */
  79089. computeExpectedHeight(): number;
  79090. dispose(): void;
  79091. }
  79092. }
  79093. declare module BABYLON.GUI {
  79094. /**
  79095. * Class used to create 2D images
  79096. */
  79097. export class Image extends Control {
  79098. name?: string | undefined;
  79099. private _workingCanvas;
  79100. private _domImage;
  79101. private _imageWidth;
  79102. private _imageHeight;
  79103. private _loaded;
  79104. private _stretch;
  79105. private _source;
  79106. private _autoScale;
  79107. private _sourceLeft;
  79108. private _sourceTop;
  79109. private _sourceWidth;
  79110. private _sourceHeight;
  79111. private _svgAttributesComputationCompleted;
  79112. private _isSVG;
  79113. private _cellWidth;
  79114. private _cellHeight;
  79115. private _cellId;
  79116. private _populateNinePatchSlicesFromImage;
  79117. private _sliceLeft;
  79118. private _sliceRight;
  79119. private _sliceTop;
  79120. private _sliceBottom;
  79121. private _detectPointerOnOpaqueOnly;
  79122. private _imageDataCache;
  79123. /**
  79124. * BABYLON.Observable notified when the content is loaded
  79125. */
  79126. onImageLoadedObservable: BABYLON.Observable<Image>;
  79127. /**
  79128. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  79129. */
  79130. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  79131. /**
  79132. * Gets a boolean indicating that the content is loaded
  79133. */
  79134. get isLoaded(): boolean;
  79135. /**
  79136. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  79137. */
  79138. get populateNinePatchSlicesFromImage(): boolean;
  79139. set populateNinePatchSlicesFromImage(value: boolean);
  79140. /**
  79141. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  79142. * Beware using this as this will comsume more memory as the image has to be stored twice
  79143. */
  79144. get detectPointerOnOpaqueOnly(): boolean;
  79145. set detectPointerOnOpaqueOnly(value: boolean);
  79146. /**
  79147. * Gets or sets the left value for slicing (9-patch)
  79148. */
  79149. get sliceLeft(): number;
  79150. set sliceLeft(value: number);
  79151. /**
  79152. * Gets or sets the right value for slicing (9-patch)
  79153. */
  79154. get sliceRight(): number;
  79155. set sliceRight(value: number);
  79156. /**
  79157. * Gets or sets the top value for slicing (9-patch)
  79158. */
  79159. get sliceTop(): number;
  79160. set sliceTop(value: number);
  79161. /**
  79162. * Gets or sets the bottom value for slicing (9-patch)
  79163. */
  79164. get sliceBottom(): number;
  79165. set sliceBottom(value: number);
  79166. /**
  79167. * Gets or sets the left coordinate in the source image
  79168. */
  79169. get sourceLeft(): number;
  79170. set sourceLeft(value: number);
  79171. /**
  79172. * Gets or sets the top coordinate in the source image
  79173. */
  79174. get sourceTop(): number;
  79175. set sourceTop(value: number);
  79176. /**
  79177. * Gets or sets the width to capture in the source image
  79178. */
  79179. get sourceWidth(): number;
  79180. set sourceWidth(value: number);
  79181. /**
  79182. * Gets or sets the height to capture in the source image
  79183. */
  79184. get sourceHeight(): number;
  79185. set sourceHeight(value: number);
  79186. /** Indicates if the format of the image is SVG */
  79187. get isSVG(): boolean;
  79188. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  79189. get svgAttributesComputationCompleted(): boolean;
  79190. /**
  79191. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  79192. * @see https://doc.babylonjs.com/how_to/gui#image
  79193. */
  79194. get autoScale(): boolean;
  79195. set autoScale(value: boolean);
  79196. /** Gets or sets the streching mode used by the image */
  79197. get stretch(): number;
  79198. set stretch(value: number);
  79199. /** @hidden */
  79200. _rotate90(n: number, preserveProperties?: boolean): Image;
  79201. private _handleRotationForSVGImage;
  79202. private _rotate90SourceProperties;
  79203. /**
  79204. * Gets or sets the internal DOM image used to render the control
  79205. */
  79206. set domImage(value: HTMLImageElement);
  79207. get domImage(): HTMLImageElement;
  79208. private _onImageLoaded;
  79209. private _extractNinePatchSliceDataFromImage;
  79210. /**
  79211. * Gets or sets image source url
  79212. */
  79213. set source(value: BABYLON.Nullable<string>);
  79214. /**
  79215. * Checks for svg document with icon id present
  79216. */
  79217. private _svgCheck;
  79218. /**
  79219. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  79220. * given external svg file and icon id
  79221. */
  79222. private _getSVGAttribs;
  79223. /**
  79224. * Gets or sets the cell width to use when animation sheet is enabled
  79225. * @see https://doc.babylonjs.com/how_to/gui#image
  79226. */
  79227. get cellWidth(): number;
  79228. set cellWidth(value: number);
  79229. /**
  79230. * Gets or sets the cell height to use when animation sheet is enabled
  79231. * @see https://doc.babylonjs.com/how_to/gui#image
  79232. */
  79233. get cellHeight(): number;
  79234. set cellHeight(value: number);
  79235. /**
  79236. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  79237. * @see https://doc.babylonjs.com/how_to/gui#image
  79238. */
  79239. get cellId(): number;
  79240. set cellId(value: number);
  79241. /**
  79242. * Creates a new Image
  79243. * @param name defines the control name
  79244. * @param url defines the image url
  79245. */
  79246. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  79247. /**
  79248. * Tests if a given coordinates belong to the current control
  79249. * @param x defines x coordinate to test
  79250. * @param y defines y coordinate to test
  79251. * @returns true if the coordinates are inside the control
  79252. */
  79253. contains(x: number, y: number): boolean;
  79254. protected _getTypeName(): string;
  79255. /** Force the control to synchronize with its content */
  79256. synchronizeSizeWithContent(): void;
  79257. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79258. private _prepareWorkingCanvasForOpaqueDetection;
  79259. private _drawImage;
  79260. _draw(context: CanvasRenderingContext2D): void;
  79261. private _renderCornerPatch;
  79262. private _renderNinePatch;
  79263. dispose(): void;
  79264. /** STRETCH_NONE */
  79265. static readonly STRETCH_NONE: number;
  79266. /** STRETCH_FILL */
  79267. static readonly STRETCH_FILL: number;
  79268. /** STRETCH_UNIFORM */
  79269. static readonly STRETCH_UNIFORM: number;
  79270. /** STRETCH_EXTEND */
  79271. static readonly STRETCH_EXTEND: number;
  79272. /** NINE_PATCH */
  79273. static readonly STRETCH_NINE_PATCH: number;
  79274. }
  79275. }
  79276. declare module BABYLON.GUI {
  79277. /**
  79278. * Class used to create 2D buttons
  79279. */
  79280. export class Button extends Rectangle {
  79281. name?: string | undefined;
  79282. /**
  79283. * Function called to generate a pointer enter animation
  79284. */
  79285. pointerEnterAnimation: () => void;
  79286. /**
  79287. * Function called to generate a pointer out animation
  79288. */
  79289. pointerOutAnimation: () => void;
  79290. /**
  79291. * Function called to generate a pointer down animation
  79292. */
  79293. pointerDownAnimation: () => void;
  79294. /**
  79295. * Function called to generate a pointer up animation
  79296. */
  79297. pointerUpAnimation: () => void;
  79298. /**
  79299. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  79300. */
  79301. delegatePickingToChildren: boolean;
  79302. private _image;
  79303. /**
  79304. * Returns the image part of the button (if any)
  79305. */
  79306. get image(): BABYLON.Nullable<Image>;
  79307. private _textBlock;
  79308. /**
  79309. * Returns the image part of the button (if any)
  79310. */
  79311. get textBlock(): BABYLON.Nullable<TextBlock>;
  79312. /**
  79313. * Creates a new Button
  79314. * @param name defines the name of the button
  79315. */
  79316. constructor(name?: string | undefined);
  79317. protected _getTypeName(): string;
  79318. /** @hidden */
  79319. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  79320. /** @hidden */
  79321. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  79322. /** @hidden */
  79323. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  79324. /** @hidden */
  79325. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79326. /** @hidden */
  79327. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  79328. /**
  79329. * Creates a new button made with an image and a text
  79330. * @param name defines the name of the button
  79331. * @param text defines the text of the button
  79332. * @param imageUrl defines the url of the image
  79333. * @returns a new Button
  79334. */
  79335. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  79336. /**
  79337. * Creates a new button made with an image
  79338. * @param name defines the name of the button
  79339. * @param imageUrl defines the url of the image
  79340. * @returns a new Button
  79341. */
  79342. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  79343. /**
  79344. * Creates a new button made with a text
  79345. * @param name defines the name of the button
  79346. * @param text defines the text of the button
  79347. * @returns a new Button
  79348. */
  79349. static CreateSimpleButton(name: string, text: string): Button;
  79350. /**
  79351. * Creates a new button made with an image and a centered text
  79352. * @param name defines the name of the button
  79353. * @param text defines the text of the button
  79354. * @param imageUrl defines the url of the image
  79355. * @returns a new Button
  79356. */
  79357. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  79358. }
  79359. }
  79360. declare module BABYLON.GUI {
  79361. /**
  79362. * Class used to create a 2D stack panel container
  79363. */
  79364. export class StackPanel extends Container {
  79365. name?: string | undefined;
  79366. private _isVertical;
  79367. private _manualWidth;
  79368. private _manualHeight;
  79369. private _doNotTrackManualChanges;
  79370. /**
  79371. * Gets or sets a boolean indicating that layou warnings should be ignored
  79372. */
  79373. ignoreLayoutWarnings: boolean;
  79374. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  79375. get isVertical(): boolean;
  79376. set isVertical(value: boolean);
  79377. /**
  79378. * Gets or sets panel width.
  79379. * This value should not be set when in horizontal mode as it will be computed automatically
  79380. */
  79381. set width(value: string | number);
  79382. get width(): string | number;
  79383. /**
  79384. * Gets or sets panel height.
  79385. * This value should not be set when in vertical mode as it will be computed automatically
  79386. */
  79387. set height(value: string | number);
  79388. get height(): string | number;
  79389. /**
  79390. * Creates a new StackPanel
  79391. * @param name defines control name
  79392. */
  79393. constructor(name?: string | undefined);
  79394. protected _getTypeName(): string;
  79395. /** @hidden */
  79396. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79397. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79398. protected _postMeasure(): void;
  79399. }
  79400. }
  79401. declare module BABYLON.GUI {
  79402. /**
  79403. * Class used to represent a 2D checkbox
  79404. */
  79405. export class Checkbox extends Control {
  79406. name?: string | undefined;
  79407. private _isChecked;
  79408. private _background;
  79409. private _checkSizeRatio;
  79410. private _thickness;
  79411. /** Gets or sets border thickness */
  79412. get thickness(): number;
  79413. set thickness(value: number);
  79414. /**
  79415. * BABYLON.Observable raised when isChecked property changes
  79416. */
  79417. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  79418. /** Gets or sets a value indicating the ratio between overall size and check size */
  79419. get checkSizeRatio(): number;
  79420. set checkSizeRatio(value: number);
  79421. /** Gets or sets background color */
  79422. get background(): string;
  79423. set background(value: string);
  79424. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  79425. get isChecked(): boolean;
  79426. set isChecked(value: boolean);
  79427. /**
  79428. * Creates a new CheckBox
  79429. * @param name defines the control name
  79430. */
  79431. constructor(name?: string | undefined);
  79432. protected _getTypeName(): string;
  79433. /** @hidden */
  79434. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79435. /** @hidden */
  79436. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79437. /**
  79438. * Utility function to easily create a checkbox with a header
  79439. * @param title defines the label to use for the header
  79440. * @param onValueChanged defines the callback to call when value changes
  79441. * @returns a StackPanel containing the checkbox and a textBlock
  79442. */
  79443. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  79444. }
  79445. }
  79446. declare module BABYLON.GUI {
  79447. /**
  79448. * Class used to store key control properties
  79449. */
  79450. export class KeyPropertySet {
  79451. /** Width */
  79452. width?: string;
  79453. /** Height */
  79454. height?: string;
  79455. /** Left padding */
  79456. paddingLeft?: string;
  79457. /** Right padding */
  79458. paddingRight?: string;
  79459. /** Top padding */
  79460. paddingTop?: string;
  79461. /** Bottom padding */
  79462. paddingBottom?: string;
  79463. /** Foreground color */
  79464. color?: string;
  79465. /** Background color */
  79466. background?: string;
  79467. }
  79468. /**
  79469. * Class used to create virtual keyboard
  79470. */
  79471. export class VirtualKeyboard extends StackPanel {
  79472. /** BABYLON.Observable raised when a key is pressed */
  79473. onKeyPressObservable: BABYLON.Observable<string>;
  79474. /** Gets or sets default key button width */
  79475. defaultButtonWidth: string;
  79476. /** Gets or sets default key button height */
  79477. defaultButtonHeight: string;
  79478. /** Gets or sets default key button left padding */
  79479. defaultButtonPaddingLeft: string;
  79480. /** Gets or sets default key button right padding */
  79481. defaultButtonPaddingRight: string;
  79482. /** Gets or sets default key button top padding */
  79483. defaultButtonPaddingTop: string;
  79484. /** Gets or sets default key button bottom padding */
  79485. defaultButtonPaddingBottom: string;
  79486. /** Gets or sets default key button foreground color */
  79487. defaultButtonColor: string;
  79488. /** Gets or sets default key button background color */
  79489. defaultButtonBackground: string;
  79490. /** Gets or sets shift button foreground color */
  79491. shiftButtonColor: string;
  79492. /** Gets or sets shift button thickness*/
  79493. selectedShiftThickness: number;
  79494. /** Gets shift key state */
  79495. shiftState: number;
  79496. protected _getTypeName(): string;
  79497. private _createKey;
  79498. /**
  79499. * Adds a new row of keys
  79500. * @param keys defines the list of keys to add
  79501. * @param propertySets defines the associated property sets
  79502. */
  79503. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  79504. /**
  79505. * Set the shift key to a specific state
  79506. * @param shiftState defines the new shift state
  79507. */
  79508. applyShiftState(shiftState: number): void;
  79509. private _currentlyConnectedInputText;
  79510. private _connectedInputTexts;
  79511. private _onKeyPressObserver;
  79512. /** Gets the input text control currently attached to the keyboard */
  79513. get connectedInputText(): BABYLON.Nullable<InputText>;
  79514. /**
  79515. * Connects the keyboard with an input text control
  79516. *
  79517. * @param input defines the target control
  79518. */
  79519. connect(input: InputText): void;
  79520. /**
  79521. * Disconnects the keyboard from connected InputText controls
  79522. *
  79523. * @param input optionally defines a target control, otherwise all are disconnected
  79524. */
  79525. disconnect(input?: InputText): void;
  79526. private _removeConnectedInputObservables;
  79527. /**
  79528. * Release all resources
  79529. */
  79530. dispose(): void;
  79531. /**
  79532. * Creates a new keyboard using a default layout
  79533. *
  79534. * @param name defines control name
  79535. * @returns a new VirtualKeyboard
  79536. */
  79537. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  79538. }
  79539. }
  79540. declare module BABYLON.GUI {
  79541. /**
  79542. * Class used to create input text control
  79543. */
  79544. export class InputText extends Control implements IFocusableControl {
  79545. name?: string | undefined;
  79546. private _text;
  79547. private _placeholderText;
  79548. private _background;
  79549. private _focusedBackground;
  79550. private _focusedColor;
  79551. private _placeholderColor;
  79552. private _thickness;
  79553. private _margin;
  79554. private _autoStretchWidth;
  79555. private _maxWidth;
  79556. private _isFocused;
  79557. private _blinkTimeout;
  79558. private _blinkIsEven;
  79559. private _cursorOffset;
  79560. private _scrollLeft;
  79561. private _textWidth;
  79562. private _clickedCoordinate;
  79563. private _deadKey;
  79564. private _addKey;
  79565. private _currentKey;
  79566. private _isTextHighlightOn;
  79567. private _textHighlightColor;
  79568. private _highligherOpacity;
  79569. private _highlightedText;
  79570. private _startHighlightIndex;
  79571. private _endHighlightIndex;
  79572. private _cursorIndex;
  79573. private _onFocusSelectAll;
  79574. private _isPointerDown;
  79575. private _onClipboardObserver;
  79576. private _onPointerDblTapObserver;
  79577. /** @hidden */
  79578. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  79579. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  79580. promptMessage: string;
  79581. /** Force disable prompt on mobile device */
  79582. disableMobilePrompt: boolean;
  79583. /** BABYLON.Observable raised when the text changes */
  79584. onTextChangedObservable: BABYLON.Observable<InputText>;
  79585. /** BABYLON.Observable raised just before an entered character is to be added */
  79586. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  79587. /** BABYLON.Observable raised when the control gets the focus */
  79588. onFocusObservable: BABYLON.Observable<InputText>;
  79589. /** BABYLON.Observable raised when the control loses the focus */
  79590. onBlurObservable: BABYLON.Observable<InputText>;
  79591. /**Observable raised when the text is highlighted */
  79592. onTextHighlightObservable: BABYLON.Observable<InputText>;
  79593. /**Observable raised when copy event is triggered */
  79594. onTextCopyObservable: BABYLON.Observable<InputText>;
  79595. /** BABYLON.Observable raised when cut event is triggered */
  79596. onTextCutObservable: BABYLON.Observable<InputText>;
  79597. /** BABYLON.Observable raised when paste event is triggered */
  79598. onTextPasteObservable: BABYLON.Observable<InputText>;
  79599. /** BABYLON.Observable raised when a key event was processed */
  79600. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  79601. /** Gets or sets the maximum width allowed by the control */
  79602. get maxWidth(): string | number;
  79603. /** Gets the maximum width allowed by the control in pixels */
  79604. get maxWidthInPixels(): number;
  79605. set maxWidth(value: string | number);
  79606. /** Gets or sets the text highlighter transparency; default: 0.4 */
  79607. get highligherOpacity(): number;
  79608. set highligherOpacity(value: number);
  79609. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  79610. get onFocusSelectAll(): boolean;
  79611. set onFocusSelectAll(value: boolean);
  79612. /** Gets or sets the text hightlight color */
  79613. get textHighlightColor(): string;
  79614. set textHighlightColor(value: string);
  79615. /** Gets or sets control margin */
  79616. get margin(): string;
  79617. /** Gets control margin in pixels */
  79618. get marginInPixels(): number;
  79619. set margin(value: string);
  79620. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  79621. get autoStretchWidth(): boolean;
  79622. set autoStretchWidth(value: boolean);
  79623. /** Gets or sets border thickness */
  79624. get thickness(): number;
  79625. set thickness(value: number);
  79626. /** Gets or sets the background color when focused */
  79627. get focusedBackground(): string;
  79628. set focusedBackground(value: string);
  79629. /** Gets or sets the background color when focused */
  79630. get focusedColor(): string;
  79631. set focusedColor(value: string);
  79632. /** Gets or sets the background color */
  79633. get background(): string;
  79634. set background(value: string);
  79635. /** Gets or sets the placeholder color */
  79636. get placeholderColor(): string;
  79637. set placeholderColor(value: string);
  79638. /** Gets or sets the text displayed when the control is empty */
  79639. get placeholderText(): string;
  79640. set placeholderText(value: string);
  79641. /** Gets or sets the dead key flag */
  79642. get deadKey(): boolean;
  79643. set deadKey(flag: boolean);
  79644. /** Gets or sets the highlight text */
  79645. get highlightedText(): string;
  79646. set highlightedText(text: string);
  79647. /** Gets or sets if the current key should be added */
  79648. get addKey(): boolean;
  79649. set addKey(flag: boolean);
  79650. /** Gets or sets the value of the current key being entered */
  79651. get currentKey(): string;
  79652. set currentKey(key: string);
  79653. /** Gets or sets the text displayed in the control */
  79654. get text(): string;
  79655. set text(value: string);
  79656. /** Gets or sets control width */
  79657. get width(): string | number;
  79658. set width(value: string | number);
  79659. /**
  79660. * Creates a new InputText
  79661. * @param name defines the control name
  79662. * @param text defines the text of the control
  79663. */
  79664. constructor(name?: string | undefined, text?: string);
  79665. /** @hidden */
  79666. onBlur(): void;
  79667. /** @hidden */
  79668. onFocus(): void;
  79669. protected _getTypeName(): string;
  79670. /**
  79671. * Function called to get the list of controls that should not steal the focus from this control
  79672. * @returns an array of controls
  79673. */
  79674. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  79675. /** @hidden */
  79676. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  79677. /** @hidden */
  79678. private _updateValueFromCursorIndex;
  79679. /** @hidden */
  79680. private _processDblClick;
  79681. /** @hidden */
  79682. private _selectAllText;
  79683. /**
  79684. * Handles the keyboard event
  79685. * @param evt Defines the KeyboardEvent
  79686. */
  79687. processKeyboard(evt: KeyboardEvent): void;
  79688. /** @hidden */
  79689. private _onCopyText;
  79690. /** @hidden */
  79691. private _onCutText;
  79692. /** @hidden */
  79693. private _onPasteText;
  79694. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79695. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79696. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  79697. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  79698. protected _beforeRenderText(text: string): string;
  79699. dispose(): void;
  79700. }
  79701. }
  79702. declare module BABYLON.GUI {
  79703. /**
  79704. * Class used to create a 2D grid container
  79705. */
  79706. export class Grid extends Container {
  79707. name?: string | undefined;
  79708. private _rowDefinitions;
  79709. private _columnDefinitions;
  79710. private _cells;
  79711. private _childControls;
  79712. /**
  79713. * Gets the number of columns
  79714. */
  79715. get columnCount(): number;
  79716. /**
  79717. * Gets the number of rows
  79718. */
  79719. get rowCount(): number;
  79720. /** Gets the list of children */
  79721. get children(): Control[];
  79722. /** Gets the list of cells (e.g. the containers) */
  79723. get cells(): {
  79724. [key: string]: Container;
  79725. };
  79726. /**
  79727. * Gets the definition of a specific row
  79728. * @param index defines the index of the row
  79729. * @returns the row definition
  79730. */
  79731. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  79732. /**
  79733. * Gets the definition of a specific column
  79734. * @param index defines the index of the column
  79735. * @returns the column definition
  79736. */
  79737. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  79738. /**
  79739. * Adds a new row to the grid
  79740. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  79741. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  79742. * @returns the current grid
  79743. */
  79744. addRowDefinition(height: number, isPixel?: boolean): Grid;
  79745. /**
  79746. * Adds a new column to the grid
  79747. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  79748. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  79749. * @returns the current grid
  79750. */
  79751. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  79752. /**
  79753. * Update a row definition
  79754. * @param index defines the index of the row to update
  79755. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  79756. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  79757. * @returns the current grid
  79758. */
  79759. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  79760. /**
  79761. * Update a column definition
  79762. * @param index defines the index of the column to update
  79763. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  79764. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  79765. * @returns the current grid
  79766. */
  79767. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  79768. /**
  79769. * Gets the list of children stored in a specific cell
  79770. * @param row defines the row to check
  79771. * @param column defines the column to check
  79772. * @returns the list of controls
  79773. */
  79774. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  79775. /**
  79776. * Gets a string representing the child cell info (row x column)
  79777. * @param child defines the control to get info from
  79778. * @returns a string containing the child cell info (row x column)
  79779. */
  79780. getChildCellInfo(child: Control): string;
  79781. private _removeCell;
  79782. private _offsetCell;
  79783. /**
  79784. * Remove a column definition at specified index
  79785. * @param index defines the index of the column to remove
  79786. * @returns the current grid
  79787. */
  79788. removeColumnDefinition(index: number): Grid;
  79789. /**
  79790. * Remove a row definition at specified index
  79791. * @param index defines the index of the row to remove
  79792. * @returns the current grid
  79793. */
  79794. removeRowDefinition(index: number): Grid;
  79795. /**
  79796. * Adds a new control to the current grid
  79797. * @param control defines the control to add
  79798. * @param row defines the row where to add the control (0 by default)
  79799. * @param column defines the column where to add the control (0 by default)
  79800. * @returns the current grid
  79801. */
  79802. addControl(control: Control, row?: number, column?: number): Grid;
  79803. /**
  79804. * Removes a control from the current container
  79805. * @param control defines the control to remove
  79806. * @returns the current container
  79807. */
  79808. removeControl(control: Control): Container;
  79809. /**
  79810. * Creates a new Grid
  79811. * @param name defines control name
  79812. */
  79813. constructor(name?: string | undefined);
  79814. protected _getTypeName(): string;
  79815. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  79816. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79817. _flagDescendantsAsMatrixDirty(): void;
  79818. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  79819. /** Releases associated resources */
  79820. dispose(): void;
  79821. }
  79822. }
  79823. declare module BABYLON.GUI {
  79824. /** Class used to create color pickers */
  79825. export class ColorPicker extends Control {
  79826. name?: string | undefined;
  79827. private static _Epsilon;
  79828. private _colorWheelCanvas;
  79829. private _value;
  79830. private _tmpColor;
  79831. private _pointerStartedOnSquare;
  79832. private _pointerStartedOnWheel;
  79833. private _squareLeft;
  79834. private _squareTop;
  79835. private _squareSize;
  79836. private _h;
  79837. private _s;
  79838. private _v;
  79839. private _lastPointerDownID;
  79840. /**
  79841. * BABYLON.Observable raised when the value changes
  79842. */
  79843. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  79844. /** Gets or sets the color of the color picker */
  79845. get value(): BABYLON.Color3;
  79846. set value(value: BABYLON.Color3);
  79847. /**
  79848. * Gets or sets control width
  79849. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79850. */
  79851. get width(): string | number;
  79852. set width(value: string | number);
  79853. /**
  79854. * Gets or sets control height
  79855. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79856. */
  79857. get height(): string | number;
  79858. /** Gets or sets control height */
  79859. set height(value: string | number);
  79860. /** Gets or sets control size */
  79861. get size(): string | number;
  79862. set size(value: string | number);
  79863. /**
  79864. * Creates a new ColorPicker
  79865. * @param name defines the control name
  79866. */
  79867. constructor(name?: string | undefined);
  79868. protected _getTypeName(): string;
  79869. /** @hidden */
  79870. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79871. private _updateSquareProps;
  79872. private _drawGradientSquare;
  79873. private _drawCircle;
  79874. private _createColorWheelCanvas;
  79875. /** @hidden */
  79876. _draw(context: CanvasRenderingContext2D): void;
  79877. private _pointerIsDown;
  79878. private _updateValueFromPointer;
  79879. private _isPointOnSquare;
  79880. private _isPointOnWheel;
  79881. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79882. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  79883. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  79884. _onCanvasBlur(): void;
  79885. /**
  79886. * This function expands the color picker by creating a color picker dialog with manual
  79887. * color value input and the ability to save colors into an array to be used later in
  79888. * subsequent launches of the dialogue.
  79889. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  79890. * @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.
  79891. * @returns picked color as a hex string and the saved colors array as hex strings.
  79892. */
  79893. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  79894. pickerWidth?: string;
  79895. pickerHeight?: string;
  79896. headerHeight?: string;
  79897. lastColor?: string;
  79898. swatchLimit?: number;
  79899. numSwatchesPerLine?: number;
  79900. savedColors?: Array<string>;
  79901. }): Promise<{
  79902. savedColors?: string[];
  79903. pickedColor: string;
  79904. }>;
  79905. }
  79906. }
  79907. declare module BABYLON.GUI {
  79908. /** Class used to create 2D ellipse containers */
  79909. export class Ellipse extends Container {
  79910. name?: string | undefined;
  79911. private _thickness;
  79912. /** Gets or sets border thickness */
  79913. get thickness(): number;
  79914. set thickness(value: number);
  79915. /**
  79916. * Creates a new Ellipse
  79917. * @param name defines the control name
  79918. */
  79919. constructor(name?: string | undefined);
  79920. protected _getTypeName(): string;
  79921. protected _localDraw(context: CanvasRenderingContext2D): void;
  79922. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79923. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  79924. }
  79925. }
  79926. declare module BABYLON.GUI {
  79927. /**
  79928. * Class used to create a password control
  79929. */
  79930. export class InputPassword extends InputText {
  79931. protected _beforeRenderText(text: string): string;
  79932. }
  79933. }
  79934. declare module BABYLON.GUI {
  79935. /** Class used to render 2D lines */
  79936. export class Line extends Control {
  79937. name?: string | undefined;
  79938. private _lineWidth;
  79939. private _x1;
  79940. private _y1;
  79941. private _x2;
  79942. private _y2;
  79943. private _dash;
  79944. private _connectedControl;
  79945. private _connectedControlDirtyObserver;
  79946. /** Gets or sets the dash pattern */
  79947. get dash(): Array<number>;
  79948. set dash(value: Array<number>);
  79949. /** Gets or sets the control connected with the line end */
  79950. get connectedControl(): Control;
  79951. set connectedControl(value: Control);
  79952. /** Gets or sets start coordinates on X axis */
  79953. get x1(): string | number;
  79954. set x1(value: string | number);
  79955. /** Gets or sets start coordinates on Y axis */
  79956. get y1(): string | number;
  79957. set y1(value: string | number);
  79958. /** Gets or sets end coordinates on X axis */
  79959. get x2(): string | number;
  79960. set x2(value: string | number);
  79961. /** Gets or sets end coordinates on Y axis */
  79962. get y2(): string | number;
  79963. set y2(value: string | number);
  79964. /** Gets or sets line width */
  79965. get lineWidth(): number;
  79966. set lineWidth(value: number);
  79967. /** Gets or sets horizontal alignment */
  79968. set horizontalAlignment(value: number);
  79969. /** Gets or sets vertical alignment */
  79970. set verticalAlignment(value: number);
  79971. private get _effectiveX2();
  79972. private get _effectiveY2();
  79973. /**
  79974. * Creates a new Line
  79975. * @param name defines the control name
  79976. */
  79977. constructor(name?: string | undefined);
  79978. protected _getTypeName(): string;
  79979. _draw(context: CanvasRenderingContext2D): void;
  79980. _measure(): void;
  79981. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79982. /**
  79983. * Move one end of the line given 3D cartesian coordinates.
  79984. * @param position Targeted world position
  79985. * @param scene BABYLON.Scene
  79986. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  79987. */
  79988. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  79989. /**
  79990. * Move one end of the line to a position in screen absolute space.
  79991. * @param projectedPosition Position in screen absolute space (X, Y)
  79992. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  79993. */
  79994. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  79995. }
  79996. }
  79997. declare module BABYLON.GUI {
  79998. /**
  79999. * Class used to store a point for a MultiLine object.
  80000. * The point can be pure 2D coordinates, a mesh or a control
  80001. */
  80002. export class MultiLinePoint {
  80003. private _multiLine;
  80004. private _x;
  80005. private _y;
  80006. private _control;
  80007. private _mesh;
  80008. private _controlObserver;
  80009. private _meshObserver;
  80010. /** @hidden */
  80011. _point: BABYLON.Vector2;
  80012. /**
  80013. * Creates a new MultiLinePoint
  80014. * @param multiLine defines the source MultiLine object
  80015. */
  80016. constructor(multiLine: MultiLine);
  80017. /** Gets or sets x coordinate */
  80018. get x(): string | number;
  80019. set x(value: string | number);
  80020. /** Gets or sets y coordinate */
  80021. get y(): string | number;
  80022. set y(value: string | number);
  80023. /** Gets or sets the control associated with this point */
  80024. get control(): BABYLON.Nullable<Control>;
  80025. set control(value: BABYLON.Nullable<Control>);
  80026. /** Gets or sets the mesh associated with this point */
  80027. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  80028. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  80029. /** Resets links */
  80030. resetLinks(): void;
  80031. /**
  80032. * Gets a translation vector
  80033. * @returns the translation vector
  80034. */
  80035. translate(): BABYLON.Vector2;
  80036. private _translatePoint;
  80037. /** Release associated resources */
  80038. dispose(): void;
  80039. }
  80040. }
  80041. declare module BABYLON.GUI {
  80042. /**
  80043. * Class used to create multi line control
  80044. */
  80045. export class MultiLine extends Control {
  80046. name?: string | undefined;
  80047. private _lineWidth;
  80048. private _dash;
  80049. private _points;
  80050. private _minX;
  80051. private _minY;
  80052. private _maxX;
  80053. private _maxY;
  80054. /**
  80055. * Creates a new MultiLine
  80056. * @param name defines the control name
  80057. */
  80058. constructor(name?: string | undefined);
  80059. /** Gets or sets dash pattern */
  80060. get dash(): Array<number>;
  80061. set dash(value: Array<number>);
  80062. /**
  80063. * Gets point stored at specified index
  80064. * @param index defines the index to look for
  80065. * @returns the requested point if found
  80066. */
  80067. getAt(index: number): MultiLinePoint;
  80068. /** Function called when a point is updated */
  80069. onPointUpdate: () => void;
  80070. /**
  80071. * Adds new points to the point collection
  80072. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  80073. * @returns the list of created MultiLinePoint
  80074. */
  80075. add(...items: (AbstractMesh | Control | {
  80076. x: string | number;
  80077. y: string | number;
  80078. })[]): MultiLinePoint[];
  80079. /**
  80080. * Adds a new point to the point collection
  80081. * @param item defines the item (mesh, control or 2d coordiantes) to add
  80082. * @returns the created MultiLinePoint
  80083. */
  80084. push(item?: (AbstractMesh | Control | {
  80085. x: string | number;
  80086. y: string | number;
  80087. })): MultiLinePoint;
  80088. /**
  80089. * Remove a specific value or point from the active point collection
  80090. * @param value defines the value or point to remove
  80091. */
  80092. remove(value: number | MultiLinePoint): void;
  80093. /**
  80094. * Resets this object to initial state (no point)
  80095. */
  80096. reset(): void;
  80097. /**
  80098. * Resets all links
  80099. */
  80100. resetLinks(): void;
  80101. /** Gets or sets line width */
  80102. get lineWidth(): number;
  80103. set lineWidth(value: number);
  80104. set horizontalAlignment(value: number);
  80105. set verticalAlignment(value: number);
  80106. protected _getTypeName(): string;
  80107. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80108. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80109. _measure(): void;
  80110. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80111. dispose(): void;
  80112. }
  80113. }
  80114. declare module BABYLON.GUI {
  80115. /**
  80116. * Class used to create radio button controls
  80117. */
  80118. export class RadioButton extends Control {
  80119. name?: string | undefined;
  80120. private _isChecked;
  80121. private _background;
  80122. private _checkSizeRatio;
  80123. private _thickness;
  80124. /** Gets or sets border thickness */
  80125. get thickness(): number;
  80126. set thickness(value: number);
  80127. /** Gets or sets group name */
  80128. group: string;
  80129. /** BABYLON.Observable raised when isChecked is changed */
  80130. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  80131. /** Gets or sets a value indicating the ratio between overall size and check size */
  80132. get checkSizeRatio(): number;
  80133. set checkSizeRatio(value: number);
  80134. /** Gets or sets background color */
  80135. get background(): string;
  80136. set background(value: string);
  80137. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  80138. get isChecked(): boolean;
  80139. set isChecked(value: boolean);
  80140. /**
  80141. * Creates a new RadioButton
  80142. * @param name defines the control name
  80143. */
  80144. constructor(name?: string | undefined);
  80145. protected _getTypeName(): string;
  80146. _draw(context: CanvasRenderingContext2D): void;
  80147. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80148. /**
  80149. * Utility function to easily create a radio button with a header
  80150. * @param title defines the label to use for the header
  80151. * @param group defines the group to use for the radio button
  80152. * @param isChecked defines the initial state of the radio button
  80153. * @param onValueChanged defines the callback to call when value changes
  80154. * @returns a StackPanel containing the radio button and a textBlock
  80155. */
  80156. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  80157. }
  80158. }
  80159. declare module BABYLON.GUI {
  80160. /**
  80161. * Class used to create slider controls
  80162. */
  80163. export class BaseSlider extends Control {
  80164. name?: string | undefined;
  80165. protected _thumbWidth: ValueAndUnit;
  80166. private _minimum;
  80167. private _maximum;
  80168. private _value;
  80169. private _isVertical;
  80170. protected _barOffset: ValueAndUnit;
  80171. private _isThumbClamped;
  80172. protected _displayThumb: boolean;
  80173. private _step;
  80174. private _lastPointerDownID;
  80175. protected _effectiveBarOffset: number;
  80176. protected _renderLeft: number;
  80177. protected _renderTop: number;
  80178. protected _renderWidth: number;
  80179. protected _renderHeight: number;
  80180. protected _backgroundBoxLength: number;
  80181. protected _backgroundBoxThickness: number;
  80182. protected _effectiveThumbThickness: number;
  80183. /** BABYLON.Observable raised when the sldier value changes */
  80184. onValueChangedObservable: BABYLON.Observable<number>;
  80185. /** Gets or sets a boolean indicating if the thumb must be rendered */
  80186. get displayThumb(): boolean;
  80187. set displayThumb(value: boolean);
  80188. /** Gets or sets a step to apply to values (0 by default) */
  80189. get step(): number;
  80190. set step(value: number);
  80191. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  80192. get barOffset(): string | number;
  80193. /** Gets main bar offset in pixels*/
  80194. get barOffsetInPixels(): number;
  80195. set barOffset(value: string | number);
  80196. /** Gets or sets thumb width */
  80197. get thumbWidth(): string | number;
  80198. /** Gets thumb width in pixels */
  80199. get thumbWidthInPixels(): number;
  80200. set thumbWidth(value: string | number);
  80201. /** Gets or sets minimum value */
  80202. get minimum(): number;
  80203. set minimum(value: number);
  80204. /** Gets or sets maximum value */
  80205. get maximum(): number;
  80206. set maximum(value: number);
  80207. /** Gets or sets current value */
  80208. get value(): number;
  80209. set value(value: number);
  80210. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  80211. get isVertical(): boolean;
  80212. set isVertical(value: boolean);
  80213. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  80214. get isThumbClamped(): boolean;
  80215. set isThumbClamped(value: boolean);
  80216. /**
  80217. * Creates a new BaseSlider
  80218. * @param name defines the control name
  80219. */
  80220. constructor(name?: string | undefined);
  80221. protected _getTypeName(): string;
  80222. protected _getThumbPosition(): number;
  80223. protected _getThumbThickness(type: string): number;
  80224. protected _prepareRenderingData(type: string): void;
  80225. private _pointerIsDown;
  80226. /** @hidden */
  80227. protected _updateValueFromPointer(x: number, y: number): void;
  80228. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80229. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  80230. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  80231. _onCanvasBlur(): void;
  80232. }
  80233. }
  80234. declare module BABYLON.GUI {
  80235. /**
  80236. * Class used to create slider controls
  80237. */
  80238. export class Slider extends BaseSlider {
  80239. name?: string | undefined;
  80240. private _background;
  80241. private _borderColor;
  80242. private _thumbColor;
  80243. private _isThumbCircle;
  80244. protected _displayValueBar: boolean;
  80245. /** Gets or sets a boolean indicating if the value bar must be rendered */
  80246. get displayValueBar(): boolean;
  80247. set displayValueBar(value: boolean);
  80248. /** Gets or sets border color */
  80249. get borderColor(): string;
  80250. set borderColor(value: string);
  80251. /** Gets or sets background color */
  80252. get background(): string;
  80253. set background(value: string);
  80254. /** Gets or sets thumb's color */
  80255. get thumbColor(): string;
  80256. set thumbColor(value: string);
  80257. /** Gets or sets a boolean indicating if the thumb should be round or square */
  80258. get isThumbCircle(): boolean;
  80259. set isThumbCircle(value: boolean);
  80260. /**
  80261. * Creates a new Slider
  80262. * @param name defines the control name
  80263. */
  80264. constructor(name?: string | undefined);
  80265. protected _getTypeName(): string;
  80266. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80267. }
  80268. }
  80269. declare module BABYLON.GUI {
  80270. /** Class used to create a RadioGroup
  80271. * which contains groups of radio buttons
  80272. */
  80273. export class SelectorGroup {
  80274. /** name of SelectorGroup */
  80275. name: string;
  80276. private _groupPanel;
  80277. private _selectors;
  80278. private _groupHeader;
  80279. /**
  80280. * Creates a new SelectorGroup
  80281. * @param name of group, used as a group heading
  80282. */
  80283. constructor(
  80284. /** name of SelectorGroup */
  80285. name: string);
  80286. /** Gets the groupPanel of the SelectorGroup */
  80287. get groupPanel(): StackPanel;
  80288. /** Gets the selectors array */
  80289. get selectors(): StackPanel[];
  80290. /** Gets and sets the group header */
  80291. get header(): string;
  80292. set header(label: string);
  80293. /** @hidden */
  80294. private _addGroupHeader;
  80295. /** @hidden*/
  80296. _getSelector(selectorNb: number): StackPanel | undefined;
  80297. /** Removes the selector at the given position
  80298. * @param selectorNb the position of the selector within the group
  80299. */
  80300. removeSelector(selectorNb: number): void;
  80301. }
  80302. /** Class used to create a CheckboxGroup
  80303. * which contains groups of checkbox buttons
  80304. */
  80305. export class CheckboxGroup extends SelectorGroup {
  80306. /** Adds a checkbox as a control
  80307. * @param text is the label for the selector
  80308. * @param func is the function called when the Selector is checked
  80309. * @param checked is true when Selector is checked
  80310. */
  80311. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  80312. /** @hidden */
  80313. _setSelectorLabel(selectorNb: number, label: string): void;
  80314. /** @hidden */
  80315. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80316. /** @hidden */
  80317. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80318. /** @hidden */
  80319. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80320. }
  80321. /** Class used to create a RadioGroup
  80322. * which contains groups of radio buttons
  80323. */
  80324. export class RadioGroup extends SelectorGroup {
  80325. private _selectNb;
  80326. /** Adds a radio button as a control
  80327. * @param label is the label for the selector
  80328. * @param func is the function called when the Selector is checked
  80329. * @param checked is true when Selector is checked
  80330. */
  80331. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  80332. /** @hidden */
  80333. _setSelectorLabel(selectorNb: number, label: string): void;
  80334. /** @hidden */
  80335. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80336. /** @hidden */
  80337. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80338. /** @hidden */
  80339. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80340. }
  80341. /** Class used to create a SliderGroup
  80342. * which contains groups of slider buttons
  80343. */
  80344. export class SliderGroup extends SelectorGroup {
  80345. /**
  80346. * Adds a slider to the SelectorGroup
  80347. * @param label is the label for the SliderBar
  80348. * @param func is the function called when the Slider moves
  80349. * @param unit is a string describing the units used, eg degrees or metres
  80350. * @param min is the minimum value for the Slider
  80351. * @param max is the maximum value for the Slider
  80352. * @param value is the start value for the Slider between min and max
  80353. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  80354. */
  80355. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  80356. /** @hidden */
  80357. _setSelectorLabel(selectorNb: number, label: string): void;
  80358. /** @hidden */
  80359. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80360. /** @hidden */
  80361. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80362. /** @hidden */
  80363. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80364. }
  80365. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  80366. * @see https://doc.babylonjs.com/how_to/selector
  80367. */
  80368. export class SelectionPanel extends Rectangle {
  80369. /** name of SelectionPanel */
  80370. name: string;
  80371. /** an array of SelectionGroups */
  80372. groups: SelectorGroup[];
  80373. private _panel;
  80374. private _buttonColor;
  80375. private _buttonBackground;
  80376. private _headerColor;
  80377. private _barColor;
  80378. private _barHeight;
  80379. private _spacerHeight;
  80380. private _labelColor;
  80381. private _groups;
  80382. private _bars;
  80383. /**
  80384. * Creates a new SelectionPanel
  80385. * @param name of SelectionPanel
  80386. * @param groups is an array of SelectionGroups
  80387. */
  80388. constructor(
  80389. /** name of SelectionPanel */
  80390. name: string,
  80391. /** an array of SelectionGroups */
  80392. groups?: SelectorGroup[]);
  80393. protected _getTypeName(): string;
  80394. /** Gets the (stack) panel of the SelectionPanel */
  80395. get panel(): StackPanel;
  80396. /** Gets or sets the headerColor */
  80397. get headerColor(): string;
  80398. set headerColor(color: string);
  80399. private _setHeaderColor;
  80400. /** Gets or sets the button color */
  80401. get buttonColor(): string;
  80402. set buttonColor(color: string);
  80403. private _setbuttonColor;
  80404. /** Gets or sets the label color */
  80405. get labelColor(): string;
  80406. set labelColor(color: string);
  80407. private _setLabelColor;
  80408. /** Gets or sets the button background */
  80409. get buttonBackground(): string;
  80410. set buttonBackground(color: string);
  80411. private _setButtonBackground;
  80412. /** Gets or sets the color of separator bar */
  80413. get barColor(): string;
  80414. set barColor(color: string);
  80415. private _setBarColor;
  80416. /** Gets or sets the height of separator bar */
  80417. get barHeight(): string;
  80418. set barHeight(value: string);
  80419. private _setBarHeight;
  80420. /** Gets or sets the height of spacers*/
  80421. get spacerHeight(): string;
  80422. set spacerHeight(value: string);
  80423. private _setSpacerHeight;
  80424. /** Adds a bar between groups */
  80425. private _addSpacer;
  80426. /** Add a group to the selection panel
  80427. * @param group is the selector group to add
  80428. */
  80429. addGroup(group: SelectorGroup): void;
  80430. /** Remove the group from the given position
  80431. * @param groupNb is the position of the group in the list
  80432. */
  80433. removeGroup(groupNb: number): void;
  80434. /** Change a group header label
  80435. * @param label is the new group header label
  80436. * @param groupNb is the number of the group to relabel
  80437. * */
  80438. setHeaderName(label: string, groupNb: number): void;
  80439. /** Change selector label to the one given
  80440. * @param label is the new selector label
  80441. * @param groupNb is the number of the groupcontaining the selector
  80442. * @param selectorNb is the number of the selector within a group to relabel
  80443. * */
  80444. relabel(label: string, groupNb: number, selectorNb: number): void;
  80445. /** For a given group position remove the selector at the given position
  80446. * @param groupNb is the number of the group to remove the selector from
  80447. * @param selectorNb is the number of the selector within the group
  80448. */
  80449. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  80450. /** For a given group position of correct type add a checkbox button
  80451. * @param groupNb is the number of the group to remove the selector from
  80452. * @param label is the label for the selector
  80453. * @param func is the function called when the Selector is checked
  80454. * @param checked is true when Selector is checked
  80455. */
  80456. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  80457. /** For a given group position of correct type add a radio button
  80458. * @param groupNb is the number of the group to remove the selector from
  80459. * @param label is the label for the selector
  80460. * @param func is the function called when the Selector is checked
  80461. * @param checked is true when Selector is checked
  80462. */
  80463. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  80464. /**
  80465. * For a given slider group add a slider
  80466. * @param groupNb is the number of the group to add the slider to
  80467. * @param label is the label for the Slider
  80468. * @param func is the function called when the Slider moves
  80469. * @param unit is a string describing the units used, eg degrees or metres
  80470. * @param min is the minimum value for the Slider
  80471. * @param max is the maximum value for the Slider
  80472. * @param value is the start value for the Slider between min and max
  80473. * @param onVal is the function used to format the value displayed, eg radians to degrees
  80474. */
  80475. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  80476. }
  80477. }
  80478. declare module BABYLON.GUI {
  80479. /**
  80480. * Class used to hold a the container for ScrollViewer
  80481. * @hidden
  80482. */
  80483. export class _ScrollViewerWindow extends Container {
  80484. parentClientWidth: number;
  80485. parentClientHeight: number;
  80486. private _freezeControls;
  80487. private _parentMeasure;
  80488. private _oldLeft;
  80489. private _oldTop;
  80490. get freezeControls(): boolean;
  80491. set freezeControls(value: boolean);
  80492. private _bucketWidth;
  80493. private _bucketHeight;
  80494. private _buckets;
  80495. private _bucketLen;
  80496. get bucketWidth(): number;
  80497. get bucketHeight(): number;
  80498. setBucketSizes(width: number, height: number): void;
  80499. private _useBuckets;
  80500. private _makeBuckets;
  80501. private _dispatchInBuckets;
  80502. private _updateMeasures;
  80503. private _updateChildrenMeasures;
  80504. private _restoreMeasures;
  80505. /**
  80506. * Creates a new ScrollViewerWindow
  80507. * @param name of ScrollViewerWindow
  80508. */
  80509. constructor(name?: string);
  80510. protected _getTypeName(): string;
  80511. /** @hidden */
  80512. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80513. /** @hidden */
  80514. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  80515. private _scrollChildren;
  80516. private _scrollChildrenWithBuckets;
  80517. /** @hidden */
  80518. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  80519. protected _postMeasure(): void;
  80520. }
  80521. }
  80522. declare module BABYLON.GUI {
  80523. /**
  80524. * Class used to create slider controls
  80525. */
  80526. export class ScrollBar extends BaseSlider {
  80527. name?: string | undefined;
  80528. private _background;
  80529. private _borderColor;
  80530. private _tempMeasure;
  80531. /** Gets or sets border color */
  80532. get borderColor(): string;
  80533. set borderColor(value: string);
  80534. /** Gets or sets background color */
  80535. get background(): string;
  80536. set background(value: string);
  80537. /**
  80538. * Creates a new Slider
  80539. * @param name defines the control name
  80540. */
  80541. constructor(name?: string | undefined);
  80542. protected _getTypeName(): string;
  80543. protected _getThumbThickness(): number;
  80544. _draw(context: CanvasRenderingContext2D): void;
  80545. private _first;
  80546. private _originX;
  80547. private _originY;
  80548. /** @hidden */
  80549. protected _updateValueFromPointer(x: number, y: number): void;
  80550. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80551. }
  80552. }
  80553. declare module BABYLON.GUI {
  80554. /**
  80555. * Class used to create slider controls
  80556. */
  80557. export class ImageScrollBar extends BaseSlider {
  80558. name?: string | undefined;
  80559. private _backgroundBaseImage;
  80560. private _backgroundImage;
  80561. private _thumbImage;
  80562. private _thumbBaseImage;
  80563. private _thumbLength;
  80564. private _thumbHeight;
  80565. private _barImageHeight;
  80566. private _tempMeasure;
  80567. /** Number of 90° rotation to apply on the images when in vertical mode */
  80568. num90RotationInVerticalMode: number;
  80569. /**
  80570. * Gets or sets the image used to render the background for horizontal bar
  80571. */
  80572. get backgroundImage(): Image;
  80573. set backgroundImage(value: Image);
  80574. /**
  80575. * Gets or sets the image used to render the thumb
  80576. */
  80577. get thumbImage(): Image;
  80578. set thumbImage(value: Image);
  80579. /**
  80580. * Gets or sets the length of the thumb
  80581. */
  80582. get thumbLength(): number;
  80583. set thumbLength(value: number);
  80584. /**
  80585. * Gets or sets the height of the thumb
  80586. */
  80587. get thumbHeight(): number;
  80588. set thumbHeight(value: number);
  80589. /**
  80590. * Gets or sets the height of the bar image
  80591. */
  80592. get barImageHeight(): number;
  80593. set barImageHeight(value: number);
  80594. /**
  80595. * Creates a new ImageScrollBar
  80596. * @param name defines the control name
  80597. */
  80598. constructor(name?: string | undefined);
  80599. protected _getTypeName(): string;
  80600. protected _getThumbThickness(): number;
  80601. _draw(context: CanvasRenderingContext2D): void;
  80602. private _first;
  80603. private _originX;
  80604. private _originY;
  80605. /** @hidden */
  80606. protected _updateValueFromPointer(x: number, y: number): void;
  80607. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80608. }
  80609. }
  80610. declare module BABYLON.GUI {
  80611. /**
  80612. * Class used to hold a viewer window and sliders in a grid
  80613. */
  80614. export class ScrollViewer extends Rectangle {
  80615. private _grid;
  80616. private _horizontalBarSpace;
  80617. private _verticalBarSpace;
  80618. private _dragSpace;
  80619. private _horizontalBar;
  80620. private _verticalBar;
  80621. private _barColor;
  80622. private _barBackground;
  80623. private _barImage;
  80624. private _horizontalBarImage;
  80625. private _verticalBarImage;
  80626. private _barBackgroundImage;
  80627. private _horizontalBarBackgroundImage;
  80628. private _verticalBarBackgroundImage;
  80629. private _barSize;
  80630. private _window;
  80631. private _pointerIsOver;
  80632. private _wheelPrecision;
  80633. private _onWheelObserver;
  80634. private _clientWidth;
  80635. private _clientHeight;
  80636. private _useImageBar;
  80637. private _thumbLength;
  80638. private _thumbHeight;
  80639. private _barImageHeight;
  80640. private _horizontalBarImageHeight;
  80641. private _verticalBarImageHeight;
  80642. private _oldWindowContentsWidth;
  80643. private _oldWindowContentsHeight;
  80644. /**
  80645. * Gets the horizontal scrollbar
  80646. */
  80647. get horizontalBar(): ScrollBar | ImageScrollBar;
  80648. /**
  80649. * Gets the vertical scrollbar
  80650. */
  80651. get verticalBar(): ScrollBar | ImageScrollBar;
  80652. /**
  80653. * Adds a new control to the current container
  80654. * @param control defines the control to add
  80655. * @returns the current container
  80656. */
  80657. addControl(control: BABYLON.Nullable<Control>): Container;
  80658. /**
  80659. * Removes a control from the current container
  80660. * @param control defines the control to remove
  80661. * @returns the current container
  80662. */
  80663. removeControl(control: Control): Container;
  80664. /** Gets the list of children */
  80665. get children(): Control[];
  80666. _flagDescendantsAsMatrixDirty(): void;
  80667. /**
  80668. * Freezes or unfreezes the controls in the window.
  80669. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  80670. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  80671. */
  80672. get freezeControls(): boolean;
  80673. set freezeControls(value: boolean);
  80674. /** Gets the bucket width */
  80675. get bucketWidth(): number;
  80676. /** Gets the bucket height */
  80677. get bucketHeight(): number;
  80678. /**
  80679. * Sets the bucket sizes.
  80680. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  80681. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  80682. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  80683. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  80684. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  80685. * used), that's why it is not enabled by default.
  80686. * @param width width of the bucket
  80687. * @param height height of the bucket
  80688. */
  80689. setBucketSizes(width: number, height: number): void;
  80690. private _forceHorizontalBar;
  80691. private _forceVerticalBar;
  80692. /**
  80693. * Forces the horizontal scroll bar to be displayed
  80694. */
  80695. get forceHorizontalBar(): boolean;
  80696. set forceHorizontalBar(value: boolean);
  80697. /**
  80698. * Forces the vertical scroll bar to be displayed
  80699. */
  80700. get forceVerticalBar(): boolean;
  80701. set forceVerticalBar(value: boolean);
  80702. /**
  80703. * Creates a new ScrollViewer
  80704. * @param name of ScrollViewer
  80705. */
  80706. constructor(name?: string, isImageBased?: boolean);
  80707. /** Reset the scroll viewer window to initial size */
  80708. resetWindow(): void;
  80709. protected _getTypeName(): string;
  80710. private _buildClientSizes;
  80711. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80712. protected _postMeasure(): void;
  80713. /**
  80714. * Gets or sets the mouse wheel precision
  80715. * from 0 to 1 with a default value of 0.05
  80716. * */
  80717. get wheelPrecision(): number;
  80718. set wheelPrecision(value: number);
  80719. /** Gets or sets the scroll bar container background color */
  80720. get scrollBackground(): string;
  80721. set scrollBackground(color: string);
  80722. /** Gets or sets the bar color */
  80723. get barColor(): string;
  80724. set barColor(color: string);
  80725. /** Gets or sets the bar image */
  80726. get thumbImage(): Image;
  80727. set thumbImage(value: Image);
  80728. /** Gets or sets the horizontal bar image */
  80729. get horizontalThumbImage(): Image;
  80730. set horizontalThumbImage(value: Image);
  80731. /** Gets or sets the vertical bar image */
  80732. get verticalThumbImage(): Image;
  80733. set verticalThumbImage(value: Image);
  80734. /** Gets or sets the size of the bar */
  80735. get barSize(): number;
  80736. set barSize(value: number);
  80737. /** Gets or sets the length of the thumb */
  80738. get thumbLength(): number;
  80739. set thumbLength(value: number);
  80740. /** Gets or sets the height of the thumb */
  80741. get thumbHeight(): number;
  80742. set thumbHeight(value: number);
  80743. /** Gets or sets the height of the bar image */
  80744. get barImageHeight(): number;
  80745. set barImageHeight(value: number);
  80746. /** Gets or sets the height of the horizontal bar image */
  80747. get horizontalBarImageHeight(): number;
  80748. set horizontalBarImageHeight(value: number);
  80749. /** Gets or sets the height of the vertical bar image */
  80750. get verticalBarImageHeight(): number;
  80751. set verticalBarImageHeight(value: number);
  80752. /** Gets or sets the bar background */
  80753. get barBackground(): string;
  80754. set barBackground(color: string);
  80755. /** Gets or sets the bar background image */
  80756. get barImage(): Image;
  80757. set barImage(value: Image);
  80758. /** Gets or sets the horizontal bar background image */
  80759. get horizontalBarImage(): Image;
  80760. set horizontalBarImage(value: Image);
  80761. /** Gets or sets the vertical bar background image */
  80762. get verticalBarImage(): Image;
  80763. set verticalBarImage(value: Image);
  80764. private _setWindowPosition;
  80765. /** @hidden */
  80766. private _updateScroller;
  80767. _link(host: AdvancedDynamicTexture): void;
  80768. /** @hidden */
  80769. private _addBar;
  80770. /** @hidden */
  80771. private _attachWheel;
  80772. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  80773. /** Releases associated resources */
  80774. dispose(): void;
  80775. }
  80776. }
  80777. declare module BABYLON.GUI {
  80778. /** Class used to render a grid */
  80779. export class DisplayGrid extends Control {
  80780. name?: string | undefined;
  80781. private _cellWidth;
  80782. private _cellHeight;
  80783. private _minorLineTickness;
  80784. private _minorLineColor;
  80785. private _majorLineTickness;
  80786. private _majorLineColor;
  80787. private _majorLineFrequency;
  80788. private _background;
  80789. private _displayMajorLines;
  80790. private _displayMinorLines;
  80791. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  80792. get displayMinorLines(): boolean;
  80793. set displayMinorLines(value: boolean);
  80794. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  80795. get displayMajorLines(): boolean;
  80796. set displayMajorLines(value: boolean);
  80797. /** Gets or sets background color (Black by default) */
  80798. get background(): string;
  80799. set background(value: string);
  80800. /** Gets or sets the width of each cell (20 by default) */
  80801. get cellWidth(): number;
  80802. set cellWidth(value: number);
  80803. /** Gets or sets the height of each cell (20 by default) */
  80804. get cellHeight(): number;
  80805. set cellHeight(value: number);
  80806. /** Gets or sets the tickness of minor lines (1 by default) */
  80807. get minorLineTickness(): number;
  80808. set minorLineTickness(value: number);
  80809. /** Gets or sets the color of minor lines (DarkGray by default) */
  80810. get minorLineColor(): string;
  80811. set minorLineColor(value: string);
  80812. /** Gets or sets the tickness of major lines (2 by default) */
  80813. get majorLineTickness(): number;
  80814. set majorLineTickness(value: number);
  80815. /** Gets or sets the color of major lines (White by default) */
  80816. get majorLineColor(): string;
  80817. set majorLineColor(value: string);
  80818. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  80819. get majorLineFrequency(): number;
  80820. set majorLineFrequency(value: number);
  80821. /**
  80822. * Creates a new GridDisplayRectangle
  80823. * @param name defines the control name
  80824. */
  80825. constructor(name?: string | undefined);
  80826. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80827. protected _getTypeName(): string;
  80828. }
  80829. }
  80830. declare module BABYLON.GUI {
  80831. /**
  80832. * Class used to create slider controls based on images
  80833. */
  80834. export class ImageBasedSlider extends BaseSlider {
  80835. name?: string | undefined;
  80836. private _backgroundImage;
  80837. private _thumbImage;
  80838. private _valueBarImage;
  80839. private _tempMeasure;
  80840. get displayThumb(): boolean;
  80841. set displayThumb(value: boolean);
  80842. /**
  80843. * Gets or sets the image used to render the background
  80844. */
  80845. get backgroundImage(): Image;
  80846. set backgroundImage(value: Image);
  80847. /**
  80848. * Gets or sets the image used to render the value bar
  80849. */
  80850. get valueBarImage(): Image;
  80851. set valueBarImage(value: Image);
  80852. /**
  80853. * Gets or sets the image used to render the thumb
  80854. */
  80855. get thumbImage(): Image;
  80856. set thumbImage(value: Image);
  80857. /**
  80858. * Creates a new ImageBasedSlider
  80859. * @param name defines the control name
  80860. */
  80861. constructor(name?: string | undefined);
  80862. protected _getTypeName(): string;
  80863. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80864. }
  80865. }
  80866. declare module BABYLON.GUI {
  80867. /**
  80868. * Forcing an export so that this code will execute
  80869. * @hidden
  80870. */
  80871. const name = "Statics";
  80872. }
  80873. declare module BABYLON.GUI {
  80874. /**
  80875. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  80876. */
  80877. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  80878. /**
  80879. * Define the instrumented AdvancedDynamicTexture.
  80880. */
  80881. texture: AdvancedDynamicTexture;
  80882. private _captureRenderTime;
  80883. private _renderTime;
  80884. private _captureLayoutTime;
  80885. private _layoutTime;
  80886. private _onBeginRenderObserver;
  80887. private _onEndRenderObserver;
  80888. private _onBeginLayoutObserver;
  80889. private _onEndLayoutObserver;
  80890. /**
  80891. * Gets the perf counter used to capture render time
  80892. */
  80893. get renderTimeCounter(): BABYLON.PerfCounter;
  80894. /**
  80895. * Gets the perf counter used to capture layout time
  80896. */
  80897. get layoutTimeCounter(): BABYLON.PerfCounter;
  80898. /**
  80899. * Enable or disable the render time capture
  80900. */
  80901. get captureRenderTime(): boolean;
  80902. set captureRenderTime(value: boolean);
  80903. /**
  80904. * Enable or disable the layout time capture
  80905. */
  80906. get captureLayoutTime(): boolean;
  80907. set captureLayoutTime(value: boolean);
  80908. /**
  80909. * Instantiates a new advanced dynamic texture instrumentation.
  80910. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  80911. * @param texture Defines the AdvancedDynamicTexture to instrument
  80912. */
  80913. constructor(
  80914. /**
  80915. * Define the instrumented AdvancedDynamicTexture.
  80916. */
  80917. texture: AdvancedDynamicTexture);
  80918. /**
  80919. * Dispose and release associated resources.
  80920. */
  80921. dispose(): void;
  80922. }
  80923. }
  80924. declare module BABYLON.GUI {
  80925. /**
  80926. * Class used to load GUI via XML.
  80927. */
  80928. export class XmlLoader {
  80929. private _nodes;
  80930. private _nodeTypes;
  80931. private _isLoaded;
  80932. private _objectAttributes;
  80933. private _parentClass;
  80934. /**
  80935. * Create a new xml loader
  80936. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  80937. */
  80938. constructor(parentClass?: null);
  80939. private _getChainElement;
  80940. private _getClassAttribute;
  80941. private _createGuiElement;
  80942. private _parseGrid;
  80943. private _parseElement;
  80944. private _prepareSourceElement;
  80945. private _parseElementsFromSource;
  80946. private _parseXml;
  80947. /**
  80948. * Gets if the loading has finished.
  80949. * @returns whether the loading has finished or not
  80950. */
  80951. isLoaded(): boolean;
  80952. /**
  80953. * Gets a loaded node / control by id.
  80954. * @param id the Controls id set in the xml
  80955. * @returns element of type Control
  80956. */
  80957. getNodeById(id: string): any;
  80958. /**
  80959. * Gets all loaded nodes / controls
  80960. * @returns Array of controls
  80961. */
  80962. getNodes(): any;
  80963. /**
  80964. * Initiates the xml layout loading
  80965. * @param xmlFile defines the xml layout to load
  80966. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  80967. * @param callback defines the callback called on layout load.
  80968. */
  80969. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  80970. }
  80971. }
  80972. declare module BABYLON.GUI {
  80973. /**
  80974. * Class used to create containers for controls
  80975. */
  80976. export class Container3D extends Control3D {
  80977. private _blockLayout;
  80978. /**
  80979. * Gets the list of child controls
  80980. */
  80981. protected _children: Control3D[];
  80982. /**
  80983. * Gets the list of child controls
  80984. */
  80985. get children(): Array<Control3D>;
  80986. /**
  80987. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  80988. * This is helpful to optimize layout operation when adding multiple children in a row
  80989. */
  80990. get blockLayout(): boolean;
  80991. set blockLayout(value: boolean);
  80992. /**
  80993. * Creates a new container
  80994. * @param name defines the container name
  80995. */
  80996. constructor(name?: string);
  80997. /**
  80998. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  80999. * @returns the current container
  81000. */
  81001. updateLayout(): Container3D;
  81002. /**
  81003. * Gets a boolean indicating if the given control is in the children of this control
  81004. * @param control defines the control to check
  81005. * @returns true if the control is in the child list
  81006. */
  81007. containsControl(control: Control3D): boolean;
  81008. /**
  81009. * Adds a control to the children of this control
  81010. * @param control defines the control to add
  81011. * @returns the current container
  81012. */
  81013. addControl(control: Control3D): Container3D;
  81014. /**
  81015. * This function will be called everytime a new control is added
  81016. */
  81017. protected _arrangeChildren(): void;
  81018. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  81019. /**
  81020. * Removes a control from the children of this control
  81021. * @param control defines the control to remove
  81022. * @returns the current container
  81023. */
  81024. removeControl(control: Control3D): Container3D;
  81025. protected _getTypeName(): string;
  81026. /**
  81027. * Releases all associated resources
  81028. */
  81029. dispose(): void;
  81030. /** Control rotation will remain unchanged */
  81031. static readonly UNSET_ORIENTATION: number;
  81032. /** Control will rotate to make it look at sphere central axis */
  81033. static readonly FACEORIGIN_ORIENTATION: number;
  81034. /** Control will rotate to make it look back at sphere central axis */
  81035. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  81036. /** Control will rotate to look at z axis (0, 0, 1) */
  81037. static readonly FACEFORWARD_ORIENTATION: number;
  81038. /** Control will rotate to look at negative z axis (0, 0, -1) */
  81039. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  81040. }
  81041. }
  81042. declare module BABYLON.GUI {
  81043. /**
  81044. * Class used to manage 3D user interface
  81045. * @see https://doc.babylonjs.com/how_to/gui3d
  81046. */
  81047. export class GUI3DManager implements BABYLON.IDisposable {
  81048. private _scene;
  81049. private _sceneDisposeObserver;
  81050. private _utilityLayer;
  81051. private _rootContainer;
  81052. private _pointerObserver;
  81053. private _pointerOutObserver;
  81054. /** @hidden */
  81055. _lastPickedControl: Control3D;
  81056. /** @hidden */
  81057. _lastControlOver: {
  81058. [pointerId: number]: Control3D;
  81059. };
  81060. /** @hidden */
  81061. _lastControlDown: {
  81062. [pointerId: number]: Control3D;
  81063. };
  81064. /**
  81065. * BABYLON.Observable raised when the point picked by the pointer events changed
  81066. */
  81067. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  81068. /** @hidden */
  81069. _sharedMaterials: {
  81070. [key: string]: BABYLON.Material;
  81071. };
  81072. /** Gets the hosting scene */
  81073. get scene(): BABYLON.Scene;
  81074. /** Gets associated utility layer */
  81075. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  81076. /**
  81077. * Creates a new GUI3DManager
  81078. * @param scene
  81079. */
  81080. constructor(scene?: BABYLON.Scene);
  81081. private _handlePointerOut;
  81082. private _doPicking;
  81083. /**
  81084. * Gets the root container
  81085. */
  81086. get rootContainer(): Container3D;
  81087. /**
  81088. * Gets a boolean indicating if the given control is in the root child list
  81089. * @param control defines the control to check
  81090. * @returns true if the control is in the root child list
  81091. */
  81092. containsControl(control: Control3D): boolean;
  81093. /**
  81094. * Adds a control to the root child list
  81095. * @param control defines the control to add
  81096. * @returns the current manager
  81097. */
  81098. addControl(control: Control3D): GUI3DManager;
  81099. /**
  81100. * Removes a control from the root child list
  81101. * @param control defines the control to remove
  81102. * @returns the current container
  81103. */
  81104. removeControl(control: Control3D): GUI3DManager;
  81105. /**
  81106. * Releases all associated resources
  81107. */
  81108. dispose(): void;
  81109. }
  81110. }
  81111. declare module BABYLON.GUI {
  81112. /**
  81113. * Class used to transport BABYLON.Vector3 information for pointer events
  81114. */
  81115. export class Vector3WithInfo extends BABYLON.Vector3 {
  81116. /** defines the current mouse button index */
  81117. buttonIndex: number;
  81118. /**
  81119. * Creates a new Vector3WithInfo
  81120. * @param source defines the vector3 data to transport
  81121. * @param buttonIndex defines the current mouse button index
  81122. */
  81123. constructor(source: BABYLON.Vector3,
  81124. /** defines the current mouse button index */
  81125. buttonIndex?: number);
  81126. }
  81127. }
  81128. declare module BABYLON.GUI {
  81129. /**
  81130. * Class used as base class for controls
  81131. */
  81132. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  81133. /** Defines the control name */
  81134. name?: string | undefined;
  81135. /** @hidden */
  81136. _host: GUI3DManager;
  81137. private _node;
  81138. private _downCount;
  81139. private _enterCount;
  81140. private _downPointerIds;
  81141. private _isVisible;
  81142. /** Gets or sets the control position in world space */
  81143. get position(): BABYLON.Vector3;
  81144. set position(value: BABYLON.Vector3);
  81145. /** Gets or sets the control scaling in world space */
  81146. get scaling(): BABYLON.Vector3;
  81147. set scaling(value: BABYLON.Vector3);
  81148. /** Callback used to start pointer enter animation */
  81149. pointerEnterAnimation: () => void;
  81150. /** Callback used to start pointer out animation */
  81151. pointerOutAnimation: () => void;
  81152. /** Callback used to start pointer down animation */
  81153. pointerDownAnimation: () => void;
  81154. /** Callback used to start pointer up animation */
  81155. pointerUpAnimation: () => void;
  81156. /**
  81157. * An event triggered when the pointer move over the control
  81158. */
  81159. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  81160. /**
  81161. * An event triggered when the pointer move out of the control
  81162. */
  81163. onPointerOutObservable: BABYLON.Observable<Control3D>;
  81164. /**
  81165. * An event triggered when the pointer taps the control
  81166. */
  81167. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  81168. /**
  81169. * An event triggered when pointer is up
  81170. */
  81171. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  81172. /**
  81173. * An event triggered when a control is clicked on (with a mouse)
  81174. */
  81175. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  81176. /**
  81177. * An event triggered when pointer enters the control
  81178. */
  81179. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  81180. /**
  81181. * Gets or sets the parent container
  81182. */
  81183. parent: BABYLON.Nullable<Container3D>;
  81184. private _behaviors;
  81185. /**
  81186. * Gets the list of attached behaviors
  81187. * @see https://doc.babylonjs.com/features/behaviour
  81188. */
  81189. get behaviors(): BABYLON.Behavior<Control3D>[];
  81190. /**
  81191. * Attach a behavior to the control
  81192. * @see https://doc.babylonjs.com/features/behaviour
  81193. * @param behavior defines the behavior to attach
  81194. * @returns the current control
  81195. */
  81196. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  81197. /**
  81198. * Remove an attached behavior
  81199. * @see https://doc.babylonjs.com/features/behaviour
  81200. * @param behavior defines the behavior to attach
  81201. * @returns the current control
  81202. */
  81203. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  81204. /**
  81205. * Gets an attached behavior by name
  81206. * @param name defines the name of the behavior to look for
  81207. * @see https://doc.babylonjs.com/features/behaviour
  81208. * @returns null if behavior was not found else the requested behavior
  81209. */
  81210. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  81211. /** Gets or sets a boolean indicating if the control is visible */
  81212. get isVisible(): boolean;
  81213. set isVisible(value: boolean);
  81214. /**
  81215. * Creates a new control
  81216. * @param name defines the control name
  81217. */
  81218. constructor(
  81219. /** Defines the control name */
  81220. name?: string | undefined);
  81221. /**
  81222. * Gets a string representing the class name
  81223. */
  81224. get typeName(): string;
  81225. /**
  81226. * Get the current class name of the control.
  81227. * @returns current class name
  81228. */
  81229. getClassName(): string;
  81230. protected _getTypeName(): string;
  81231. /**
  81232. * Gets the transform node used by this control
  81233. */
  81234. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  81235. /**
  81236. * Gets the mesh used to render this control
  81237. */
  81238. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  81239. /**
  81240. * Link the control as child of the given node
  81241. * @param node defines the node to link to. Use null to unlink the control
  81242. * @returns the current control
  81243. */
  81244. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  81245. /** @hidden **/
  81246. _prepareNode(scene: BABYLON.Scene): void;
  81247. /**
  81248. * Node creation.
  81249. * Can be overriden by children
  81250. * @param scene defines the scene where the node must be attached
  81251. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  81252. */
  81253. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  81254. /**
  81255. * Affect a material to the given mesh
  81256. * @param mesh defines the mesh which will represent the control
  81257. */
  81258. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81259. /** @hidden */
  81260. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  81261. /** @hidden */
  81262. _onPointerEnter(target: Control3D): boolean;
  81263. /** @hidden */
  81264. _onPointerOut(target: Control3D): void;
  81265. /** @hidden */
  81266. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  81267. /** @hidden */
  81268. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  81269. /** @hidden */
  81270. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  81271. /** @hidden */
  81272. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  81273. /** @hidden */
  81274. _disposeNode(): void;
  81275. /**
  81276. * Releases all associated resources
  81277. */
  81278. dispose(): void;
  81279. }
  81280. }
  81281. declare module BABYLON.GUI {
  81282. /**
  81283. * Class used as a root to all buttons
  81284. */
  81285. export class AbstractButton3D extends Control3D {
  81286. /**
  81287. * Creates a new button
  81288. * @param name defines the control name
  81289. */
  81290. constructor(name?: string);
  81291. protected _getTypeName(): string;
  81292. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81293. }
  81294. }
  81295. declare module BABYLON.GUI {
  81296. /**
  81297. * Class used to create a button in 3D
  81298. */
  81299. export class Button3D extends AbstractButton3D {
  81300. /** @hidden */
  81301. protected _currentMaterial: BABYLON.Material;
  81302. private _facadeTexture;
  81303. private _content;
  81304. private _contentResolution;
  81305. private _contentScaleRatio;
  81306. /**
  81307. * Gets or sets the texture resolution used to render content (512 by default)
  81308. */
  81309. get contentResolution(): BABYLON.int;
  81310. set contentResolution(value: BABYLON.int);
  81311. /**
  81312. * Gets or sets the texture scale ratio used to render content (2 by default)
  81313. */
  81314. get contentScaleRatio(): number;
  81315. set contentScaleRatio(value: number);
  81316. protected _disposeFacadeTexture(): void;
  81317. protected _resetContent(): void;
  81318. /**
  81319. * Creates a new button
  81320. * @param name defines the control name
  81321. */
  81322. constructor(name?: string);
  81323. /**
  81324. * Gets or sets the GUI 2D content used to display the button's facade
  81325. */
  81326. get content(): Control;
  81327. set content(value: Control);
  81328. /**
  81329. * Apply the facade texture (created from the content property).
  81330. * This function can be overloaded by child classes
  81331. * @param facadeTexture defines the AdvancedDynamicTexture to use
  81332. */
  81333. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  81334. protected _getTypeName(): string;
  81335. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81336. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81337. /**
  81338. * Releases all associated resources
  81339. */
  81340. dispose(): void;
  81341. }
  81342. }
  81343. declare module BABYLON.GUI {
  81344. /**
  81345. * Abstract class used to create a container panel deployed on the surface of a volume
  81346. */
  81347. export abstract class VolumeBasedPanel extends Container3D {
  81348. private _columns;
  81349. private _rows;
  81350. private _rowThenColum;
  81351. private _orientation;
  81352. protected _cellWidth: number;
  81353. protected _cellHeight: number;
  81354. /**
  81355. * Gets or sets the distance between elements
  81356. */
  81357. margin: number;
  81358. /**
  81359. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  81360. * | Value | Type | Description |
  81361. * | ----- | ----------------------------------- | ----------- |
  81362. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  81363. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  81364. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  81365. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  81366. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  81367. */
  81368. get orientation(): number;
  81369. set orientation(value: number);
  81370. /**
  81371. * Gets or sets the number of columns requested (10 by default).
  81372. * The panel will automatically compute the number of rows based on number of child controls.
  81373. */
  81374. get columns(): BABYLON.int;
  81375. set columns(value: BABYLON.int);
  81376. /**
  81377. * Gets or sets a the number of rows requested.
  81378. * The panel will automatically compute the number of columns based on number of child controls.
  81379. */
  81380. get rows(): BABYLON.int;
  81381. set rows(value: BABYLON.int);
  81382. /**
  81383. * Creates new VolumeBasedPanel
  81384. */
  81385. constructor();
  81386. protected _arrangeChildren(): void;
  81387. /** Child classes must implement this function to provide correct control positioning */
  81388. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81389. /** Child classes can implement this function to provide additional processing */
  81390. protected _finalProcessing(): void;
  81391. }
  81392. }
  81393. declare module BABYLON.GUI {
  81394. /**
  81395. * Class used to create a container panel deployed on the surface of a cylinder
  81396. */
  81397. export class CylinderPanel extends VolumeBasedPanel {
  81398. private _radius;
  81399. /**
  81400. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  81401. */
  81402. get radius(): BABYLON.float;
  81403. set radius(value: BABYLON.float);
  81404. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81405. private _cylindricalMapping;
  81406. }
  81407. }
  81408. declare module BABYLON.GUI {
  81409. /** @hidden */
  81410. export var fluentVertexShader: {
  81411. name: string;
  81412. shader: string;
  81413. };
  81414. }
  81415. declare module BABYLON.GUI {
  81416. /** @hidden */
  81417. export var fluentPixelShader: {
  81418. name: string;
  81419. shader: string;
  81420. };
  81421. }
  81422. declare module BABYLON.GUI {
  81423. /** @hidden */
  81424. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  81425. INNERGLOW: boolean;
  81426. BORDER: boolean;
  81427. HOVERLIGHT: boolean;
  81428. TEXTURE: boolean;
  81429. constructor();
  81430. }
  81431. /**
  81432. * Class used to render controls with fluent desgin
  81433. */
  81434. export class FluentMaterial extends BABYLON.PushMaterial {
  81435. /**
  81436. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  81437. */
  81438. innerGlowColorIntensity: number;
  81439. /**
  81440. * Gets or sets the inner glow color (white by default)
  81441. */
  81442. innerGlowColor: BABYLON.Color3;
  81443. /**
  81444. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  81445. */
  81446. albedoColor: BABYLON.Color3;
  81447. /**
  81448. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  81449. */
  81450. renderBorders: boolean;
  81451. /**
  81452. * Gets or sets border width (default is 0.5)
  81453. */
  81454. borderWidth: number;
  81455. /**
  81456. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  81457. */
  81458. edgeSmoothingValue: number;
  81459. /**
  81460. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  81461. */
  81462. borderMinValue: number;
  81463. /**
  81464. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  81465. */
  81466. renderHoverLight: boolean;
  81467. /**
  81468. * Gets or sets the radius used to render the hover light (default is 1.0)
  81469. */
  81470. hoverRadius: number;
  81471. /**
  81472. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  81473. */
  81474. hoverColor: BABYLON.Color4;
  81475. /**
  81476. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  81477. */
  81478. hoverPosition: BABYLON.Vector3;
  81479. private _albedoTexture;
  81480. /** Gets or sets the texture to use for albedo color */
  81481. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  81482. /**
  81483. * Creates a new Fluent material
  81484. * @param name defines the name of the material
  81485. * @param scene defines the hosting scene
  81486. */
  81487. constructor(name: string, scene: BABYLON.Scene);
  81488. needAlphaBlending(): boolean;
  81489. needAlphaTesting(): boolean;
  81490. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81491. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81492. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81493. getActiveTextures(): BABYLON.BaseTexture[];
  81494. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81495. dispose(forceDisposeEffect?: boolean): void;
  81496. clone(name: string): FluentMaterial;
  81497. serialize(): any;
  81498. getClassName(): string;
  81499. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  81500. }
  81501. }
  81502. declare module BABYLON.GUI {
  81503. /**
  81504. * Class used to create a holographic button in 3D
  81505. */
  81506. export class HolographicButton extends Button3D {
  81507. private _backPlate;
  81508. private _textPlate;
  81509. private _frontPlate;
  81510. private _text;
  81511. private _imageUrl;
  81512. private _shareMaterials;
  81513. private _frontMaterial;
  81514. private _backMaterial;
  81515. private _plateMaterial;
  81516. private _pickedPointObserver;
  81517. private _tooltipFade;
  81518. private _tooltipTextBlock;
  81519. private _tooltipTexture;
  81520. private _tooltipMesh;
  81521. private _tooltipHoverObserver;
  81522. private _tooltipOutObserver;
  81523. private _disposeTooltip;
  81524. /**
  81525. * Rendering ground id of all the mesh in the button
  81526. */
  81527. set renderingGroupId(id: number);
  81528. get renderingGroupId(): number;
  81529. /**
  81530. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  81531. */
  81532. set tooltipText(text: BABYLON.Nullable<string>);
  81533. get tooltipText(): BABYLON.Nullable<string>;
  81534. /**
  81535. * Gets or sets text for the button
  81536. */
  81537. get text(): string;
  81538. set text(value: string);
  81539. /**
  81540. * Gets or sets the image url for the button
  81541. */
  81542. get imageUrl(): string;
  81543. set imageUrl(value: string);
  81544. /**
  81545. * Gets the back material used by this button
  81546. */
  81547. get backMaterial(): FluentMaterial;
  81548. /**
  81549. * Gets the front material used by this button
  81550. */
  81551. get frontMaterial(): FluentMaterial;
  81552. /**
  81553. * Gets the plate material used by this button
  81554. */
  81555. get plateMaterial(): BABYLON.StandardMaterial;
  81556. /**
  81557. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  81558. */
  81559. get shareMaterials(): boolean;
  81560. /**
  81561. * Creates a new button
  81562. * @param name defines the control name
  81563. */
  81564. constructor(name?: string, shareMaterials?: boolean);
  81565. protected _getTypeName(): string;
  81566. private _rebuildContent;
  81567. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81568. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  81569. private _createBackMaterial;
  81570. private _createFrontMaterial;
  81571. private _createPlateMaterial;
  81572. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  81573. /**
  81574. * Releases all associated resources
  81575. */
  81576. dispose(): void;
  81577. }
  81578. }
  81579. declare module BABYLON.GUI {
  81580. /**
  81581. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  81582. */
  81583. export class MeshButton3D extends Button3D {
  81584. /** @hidden */
  81585. protected _currentMesh: BABYLON.Mesh;
  81586. /**
  81587. * Creates a new 3D button based on a mesh
  81588. * @param mesh mesh to become a 3D button
  81589. * @param name defines the control name
  81590. */
  81591. constructor(mesh: BABYLON.Mesh, name?: string);
  81592. protected _getTypeName(): string;
  81593. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81594. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81595. }
  81596. }
  81597. declare module BABYLON.GUI {
  81598. /**
  81599. * Class used to create a container panel deployed on the surface of a plane
  81600. */
  81601. export class PlanePanel extends VolumeBasedPanel {
  81602. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81603. }
  81604. }
  81605. declare module BABYLON.GUI {
  81606. /**
  81607. * Class used to create a container panel where items get randomized planar mapping
  81608. */
  81609. export class ScatterPanel extends VolumeBasedPanel {
  81610. private _iteration;
  81611. /**
  81612. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  81613. */
  81614. get iteration(): BABYLON.float;
  81615. set iteration(value: BABYLON.float);
  81616. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81617. private _scatterMapping;
  81618. protected _finalProcessing(): void;
  81619. }
  81620. }
  81621. declare module BABYLON.GUI {
  81622. /**
  81623. * Class used to create a container panel deployed on the surface of a sphere
  81624. */
  81625. export class SpherePanel extends VolumeBasedPanel {
  81626. private _radius;
  81627. /**
  81628. * Gets or sets the radius of the sphere where to project controls (5 by default)
  81629. */
  81630. get radius(): BABYLON.float;
  81631. set radius(value: BABYLON.float);
  81632. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81633. private _sphericalMapping;
  81634. }
  81635. }
  81636. declare module BABYLON.GUI {
  81637. /**
  81638. * Class used to create a stack panel in 3D on XY plane
  81639. */
  81640. export class StackPanel3D extends Container3D {
  81641. private _isVertical;
  81642. /**
  81643. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  81644. */
  81645. get isVertical(): boolean;
  81646. set isVertical(value: boolean);
  81647. /**
  81648. * Gets or sets the distance between elements
  81649. */
  81650. margin: number;
  81651. /**
  81652. * Creates new StackPanel
  81653. * @param isVertical
  81654. */
  81655. constructor(isVertical?: boolean);
  81656. protected _arrangeChildren(): void;
  81657. }
  81658. }
  81659. declare module BABYLON {
  81660. /**
  81661. * Configuration for glTF validation
  81662. */
  81663. export interface IGLTFValidationConfiguration {
  81664. /**
  81665. * The url of the glTF validator.
  81666. */
  81667. url: string;
  81668. }
  81669. /**
  81670. * glTF validation
  81671. */
  81672. export class GLTFValidation {
  81673. /**
  81674. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  81675. */
  81676. static Configuration: IGLTFValidationConfiguration;
  81677. private static _LoadScriptPromise;
  81678. /**
  81679. * Validate a glTF asset using the glTF-Validator.
  81680. * @param data The JSON of a glTF or the array buffer of a binary glTF
  81681. * @param rootUrl The root url for the glTF
  81682. * @param fileName The file name for the glTF
  81683. * @param getExternalResource The callback to get external resources for the glTF validator
  81684. * @returns A promise that resolves with the glTF validation results once complete
  81685. */
  81686. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  81687. }
  81688. }
  81689. declare module BABYLON {
  81690. /**
  81691. * Mode that determines the coordinate system to use.
  81692. */
  81693. export enum GLTFLoaderCoordinateSystemMode {
  81694. /**
  81695. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  81696. */
  81697. AUTO = 0,
  81698. /**
  81699. * Sets the useRightHandedSystem flag on the scene.
  81700. */
  81701. FORCE_RIGHT_HANDED = 1
  81702. }
  81703. /**
  81704. * Mode that determines what animations will start.
  81705. */
  81706. export enum GLTFLoaderAnimationStartMode {
  81707. /**
  81708. * No animation will start.
  81709. */
  81710. NONE = 0,
  81711. /**
  81712. * The first animation will start.
  81713. */
  81714. FIRST = 1,
  81715. /**
  81716. * All animations will start.
  81717. */
  81718. ALL = 2
  81719. }
  81720. /**
  81721. * Interface that contains the data for the glTF asset.
  81722. */
  81723. export interface IGLTFLoaderData {
  81724. /**
  81725. * The object that represents the glTF JSON.
  81726. */
  81727. json: Object;
  81728. /**
  81729. * The BIN chunk of a binary glTF.
  81730. */
  81731. bin: Nullable<IDataBuffer>;
  81732. }
  81733. /**
  81734. * Interface for extending the loader.
  81735. */
  81736. export interface IGLTFLoaderExtension {
  81737. /**
  81738. * The name of this extension.
  81739. */
  81740. readonly name: string;
  81741. /**
  81742. * Defines whether this extension is enabled.
  81743. */
  81744. enabled: boolean;
  81745. /**
  81746. * Defines the order of this extension.
  81747. * The loader sorts the extensions using these values when loading.
  81748. */
  81749. order?: number;
  81750. }
  81751. /**
  81752. * Loader state.
  81753. */
  81754. export enum GLTFLoaderState {
  81755. /**
  81756. * The asset is loading.
  81757. */
  81758. LOADING = 0,
  81759. /**
  81760. * The asset is ready for rendering.
  81761. */
  81762. READY = 1,
  81763. /**
  81764. * The asset is completely loaded.
  81765. */
  81766. COMPLETE = 2
  81767. }
  81768. /** @hidden */
  81769. export interface IImportMeshAsyncOutput {
  81770. meshes: AbstractMesh[];
  81771. geometries: Geometry[];
  81772. particleSystems: IParticleSystem[];
  81773. skeletons: Skeleton[];
  81774. animationGroups: AnimationGroup[];
  81775. lights: Light[];
  81776. transformNodes: TransformNode[];
  81777. }
  81778. /** @hidden */
  81779. export interface IGLTFLoader extends IDisposable {
  81780. readonly state: Nullable<GLTFLoaderState>;
  81781. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  81782. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  81783. }
  81784. /**
  81785. * File loader for loading glTF files into a scene.
  81786. */
  81787. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  81788. /** @hidden */
  81789. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  81790. /** @hidden */
  81791. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  81792. /**
  81793. * Raised when the asset has been parsed
  81794. */
  81795. onParsedObservable: Observable<IGLTFLoaderData>;
  81796. private _onParsedObserver;
  81797. /**
  81798. * Raised when the asset has been parsed
  81799. */
  81800. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  81801. /**
  81802. * 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.
  81803. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  81804. * Defaults to true.
  81805. * @hidden
  81806. */
  81807. static IncrementalLoading: boolean;
  81808. /**
  81809. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  81810. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  81811. * @hidden
  81812. */
  81813. static HomogeneousCoordinates: boolean;
  81814. /**
  81815. * The coordinate system mode. Defaults to AUTO.
  81816. */
  81817. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  81818. /**
  81819. * The animation start mode. Defaults to FIRST.
  81820. */
  81821. animationStartMode: GLTFLoaderAnimationStartMode;
  81822. /**
  81823. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  81824. */
  81825. compileMaterials: boolean;
  81826. /**
  81827. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  81828. */
  81829. useClipPlane: boolean;
  81830. /**
  81831. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  81832. */
  81833. compileShadowGenerators: boolean;
  81834. /**
  81835. * Defines if the Alpha blended materials are only applied as coverage.
  81836. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  81837. * If true, no extra effects are applied to transparent pixels.
  81838. */
  81839. transparencyAsCoverage: boolean;
  81840. /**
  81841. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  81842. * Enabling will disable offline support and glTF validator.
  81843. * Defaults to false.
  81844. */
  81845. useRangeRequests: boolean;
  81846. /**
  81847. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  81848. */
  81849. createInstances: boolean;
  81850. /**
  81851. * 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.
  81852. */
  81853. alwaysComputeBoundingBox: boolean;
  81854. /**
  81855. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  81856. */
  81857. loadAllMaterials: boolean;
  81858. /**
  81859. * Function called before loading a url referenced by the asset.
  81860. */
  81861. preprocessUrlAsync: (url: string) => Promise<string>;
  81862. /**
  81863. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  81864. * 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, ...)
  81865. */
  81866. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  81867. private _onMeshLoadedObserver;
  81868. /**
  81869. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  81870. * 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, ...)
  81871. */
  81872. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  81873. /**
  81874. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  81875. */
  81876. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  81877. private _onTextureLoadedObserver;
  81878. /**
  81879. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  81880. */
  81881. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  81882. /**
  81883. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  81884. */
  81885. readonly onMaterialLoadedObservable: Observable<Material>;
  81886. private _onMaterialLoadedObserver;
  81887. /**
  81888. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  81889. */
  81890. set onMaterialLoaded(callback: (material: Material) => void);
  81891. /**
  81892. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  81893. */
  81894. readonly onCameraLoadedObservable: Observable<Camera>;
  81895. private _onCameraLoadedObserver;
  81896. /**
  81897. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  81898. */
  81899. set onCameraLoaded(callback: (camera: Camera) => void);
  81900. /**
  81901. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  81902. * For assets with LODs, raised when all of the LODs are complete.
  81903. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  81904. */
  81905. readonly onCompleteObservable: Observable<void>;
  81906. private _onCompleteObserver;
  81907. /**
  81908. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  81909. * For assets with LODs, raised when all of the LODs are complete.
  81910. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  81911. */
  81912. set onComplete(callback: () => void);
  81913. /**
  81914. * Observable raised when an error occurs.
  81915. */
  81916. readonly onErrorObservable: Observable<any>;
  81917. private _onErrorObserver;
  81918. /**
  81919. * Callback raised when an error occurs.
  81920. */
  81921. set onError(callback: (reason: any) => void);
  81922. /**
  81923. * Observable raised after the loader is disposed.
  81924. */
  81925. readonly onDisposeObservable: Observable<void>;
  81926. private _onDisposeObserver;
  81927. /**
  81928. * Callback raised after the loader is disposed.
  81929. */
  81930. set onDispose(callback: () => void);
  81931. /**
  81932. * Observable raised after a loader extension is created.
  81933. * Set additional options for a loader extension in this event.
  81934. */
  81935. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  81936. private _onExtensionLoadedObserver;
  81937. /**
  81938. * Callback raised after a loader extension is created.
  81939. */
  81940. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  81941. /**
  81942. * Defines if the loader logging is enabled.
  81943. */
  81944. get loggingEnabled(): boolean;
  81945. set loggingEnabled(value: boolean);
  81946. /**
  81947. * Defines if the loader should capture performance counters.
  81948. */
  81949. get capturePerformanceCounters(): boolean;
  81950. set capturePerformanceCounters(value: boolean);
  81951. /**
  81952. * Defines if the loader should validate the asset.
  81953. */
  81954. validate: boolean;
  81955. /**
  81956. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  81957. */
  81958. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  81959. private _onValidatedObserver;
  81960. /**
  81961. * Callback raised after a loader extension is created.
  81962. */
  81963. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  81964. private _loader;
  81965. private _progressCallback?;
  81966. private _requests;
  81967. private static magicBase64Encoded;
  81968. /**
  81969. * Name of the loader ("gltf")
  81970. */
  81971. name: string;
  81972. /** @hidden */
  81973. extensions: ISceneLoaderPluginExtensions;
  81974. /**
  81975. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  81976. */
  81977. dispose(): void;
  81978. /** @hidden */
  81979. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  81980. /** @hidden */
  81981. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  81982. /** @hidden */
  81983. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  81984. meshes: AbstractMesh[];
  81985. particleSystems: IParticleSystem[];
  81986. skeletons: Skeleton[];
  81987. animationGroups: AnimationGroup[];
  81988. }>;
  81989. /** @hidden */
  81990. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  81991. /** @hidden */
  81992. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  81993. /** @hidden */
  81994. canDirectLoad(data: string): boolean;
  81995. /** @hidden */
  81996. directLoad(scene: Scene, data: string): Promise<any>;
  81997. /**
  81998. * The callback that allows custom handling of the root url based on the response url.
  81999. * @param rootUrl the original root url
  82000. * @param responseURL the response url if available
  82001. * @returns the new root url
  82002. */
  82003. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  82004. /** @hidden */
  82005. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  82006. /**
  82007. * The loader state or null if the loader is not active.
  82008. */
  82009. get loaderState(): Nullable<GLTFLoaderState>;
  82010. /**
  82011. * Returns a promise that resolves when the asset is completely loaded.
  82012. * @returns a promise that resolves when the asset is completely loaded.
  82013. */
  82014. whenCompleteAsync(): Promise<void>;
  82015. /** @hidden */
  82016. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  82017. /** @hidden */
  82018. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  82019. private _onProgress;
  82020. private _validate;
  82021. private _getLoader;
  82022. private _parseJson;
  82023. private _unpackBinaryAsync;
  82024. private _unpackBinaryV1Async;
  82025. private _unpackBinaryV2Async;
  82026. private static _parseVersion;
  82027. private static _compareVersion;
  82028. private static readonly _logSpaces;
  82029. private _logIndentLevel;
  82030. private _loggingEnabled;
  82031. /** @hidden */
  82032. _log: (message: string) => void;
  82033. /** @hidden */
  82034. _logOpen(message: string): void;
  82035. /** @hidden */
  82036. _logClose(): void;
  82037. private _logEnabled;
  82038. private _logDisabled;
  82039. private _capturePerformanceCounters;
  82040. /** @hidden */
  82041. _startPerformanceCounter: (counterName: string) => void;
  82042. /** @hidden */
  82043. _endPerformanceCounter: (counterName: string) => void;
  82044. private _startPerformanceCounterEnabled;
  82045. private _startPerformanceCounterDisabled;
  82046. private _endPerformanceCounterEnabled;
  82047. private _endPerformanceCounterDisabled;
  82048. }
  82049. }
  82050. declare module BABYLON.GLTF1 {
  82051. /**
  82052. * Enums
  82053. * @hidden
  82054. */
  82055. export enum EComponentType {
  82056. BYTE = 5120,
  82057. UNSIGNED_BYTE = 5121,
  82058. SHORT = 5122,
  82059. UNSIGNED_SHORT = 5123,
  82060. FLOAT = 5126
  82061. }
  82062. /** @hidden */
  82063. export enum EShaderType {
  82064. FRAGMENT = 35632,
  82065. VERTEX = 35633
  82066. }
  82067. /** @hidden */
  82068. export enum EParameterType {
  82069. BYTE = 5120,
  82070. UNSIGNED_BYTE = 5121,
  82071. SHORT = 5122,
  82072. UNSIGNED_SHORT = 5123,
  82073. INT = 5124,
  82074. UNSIGNED_INT = 5125,
  82075. FLOAT = 5126,
  82076. FLOAT_VEC2 = 35664,
  82077. FLOAT_VEC3 = 35665,
  82078. FLOAT_VEC4 = 35666,
  82079. INT_VEC2 = 35667,
  82080. INT_VEC3 = 35668,
  82081. INT_VEC4 = 35669,
  82082. BOOL = 35670,
  82083. BOOL_VEC2 = 35671,
  82084. BOOL_VEC3 = 35672,
  82085. BOOL_VEC4 = 35673,
  82086. FLOAT_MAT2 = 35674,
  82087. FLOAT_MAT3 = 35675,
  82088. FLOAT_MAT4 = 35676,
  82089. SAMPLER_2D = 35678
  82090. }
  82091. /** @hidden */
  82092. export enum ETextureWrapMode {
  82093. CLAMP_TO_EDGE = 33071,
  82094. MIRRORED_REPEAT = 33648,
  82095. REPEAT = 10497
  82096. }
  82097. /** @hidden */
  82098. export enum ETextureFilterType {
  82099. NEAREST = 9728,
  82100. LINEAR = 9728,
  82101. NEAREST_MIPMAP_NEAREST = 9984,
  82102. LINEAR_MIPMAP_NEAREST = 9985,
  82103. NEAREST_MIPMAP_LINEAR = 9986,
  82104. LINEAR_MIPMAP_LINEAR = 9987
  82105. }
  82106. /** @hidden */
  82107. export enum ETextureFormat {
  82108. ALPHA = 6406,
  82109. RGB = 6407,
  82110. RGBA = 6408,
  82111. LUMINANCE = 6409,
  82112. LUMINANCE_ALPHA = 6410
  82113. }
  82114. /** @hidden */
  82115. export enum ECullingType {
  82116. FRONT = 1028,
  82117. BACK = 1029,
  82118. FRONT_AND_BACK = 1032
  82119. }
  82120. /** @hidden */
  82121. export enum EBlendingFunction {
  82122. ZERO = 0,
  82123. ONE = 1,
  82124. SRC_COLOR = 768,
  82125. ONE_MINUS_SRC_COLOR = 769,
  82126. DST_COLOR = 774,
  82127. ONE_MINUS_DST_COLOR = 775,
  82128. SRC_ALPHA = 770,
  82129. ONE_MINUS_SRC_ALPHA = 771,
  82130. DST_ALPHA = 772,
  82131. ONE_MINUS_DST_ALPHA = 773,
  82132. CONSTANT_COLOR = 32769,
  82133. ONE_MINUS_CONSTANT_COLOR = 32770,
  82134. CONSTANT_ALPHA = 32771,
  82135. ONE_MINUS_CONSTANT_ALPHA = 32772,
  82136. SRC_ALPHA_SATURATE = 776
  82137. }
  82138. /** @hidden */
  82139. export interface IGLTFProperty {
  82140. extensions?: {
  82141. [key: string]: any;
  82142. };
  82143. extras?: Object;
  82144. }
  82145. /** @hidden */
  82146. export interface IGLTFChildRootProperty extends IGLTFProperty {
  82147. name?: string;
  82148. }
  82149. /** @hidden */
  82150. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  82151. bufferView: string;
  82152. byteOffset: number;
  82153. byteStride: number;
  82154. count: number;
  82155. type: string;
  82156. componentType: EComponentType;
  82157. max?: number[];
  82158. min?: number[];
  82159. name?: string;
  82160. }
  82161. /** @hidden */
  82162. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  82163. buffer: string;
  82164. byteOffset: number;
  82165. byteLength: number;
  82166. byteStride: number;
  82167. target?: number;
  82168. }
  82169. /** @hidden */
  82170. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  82171. uri: string;
  82172. byteLength?: number;
  82173. type?: string;
  82174. }
  82175. /** @hidden */
  82176. export interface IGLTFShader extends IGLTFChildRootProperty {
  82177. uri: string;
  82178. type: EShaderType;
  82179. }
  82180. /** @hidden */
  82181. export interface IGLTFProgram extends IGLTFChildRootProperty {
  82182. attributes: string[];
  82183. fragmentShader: string;
  82184. vertexShader: string;
  82185. }
  82186. /** @hidden */
  82187. export interface IGLTFTechniqueParameter {
  82188. type: number;
  82189. count?: number;
  82190. semantic?: string;
  82191. node?: string;
  82192. value?: number | boolean | string | Array<any>;
  82193. source?: string;
  82194. babylonValue?: any;
  82195. }
  82196. /** @hidden */
  82197. export interface IGLTFTechniqueCommonProfile {
  82198. lightingModel: string;
  82199. texcoordBindings: Object;
  82200. parameters?: Array<any>;
  82201. }
  82202. /** @hidden */
  82203. export interface IGLTFTechniqueStatesFunctions {
  82204. blendColor?: number[];
  82205. blendEquationSeparate?: number[];
  82206. blendFuncSeparate?: number[];
  82207. colorMask: boolean[];
  82208. cullFace: number[];
  82209. }
  82210. /** @hidden */
  82211. export interface IGLTFTechniqueStates {
  82212. enable: number[];
  82213. functions: IGLTFTechniqueStatesFunctions;
  82214. }
  82215. /** @hidden */
  82216. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  82217. parameters: {
  82218. [key: string]: IGLTFTechniqueParameter;
  82219. };
  82220. program: string;
  82221. attributes: {
  82222. [key: string]: string;
  82223. };
  82224. uniforms: {
  82225. [key: string]: string;
  82226. };
  82227. states: IGLTFTechniqueStates;
  82228. }
  82229. /** @hidden */
  82230. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  82231. technique?: string;
  82232. values: string[];
  82233. }
  82234. /** @hidden */
  82235. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  82236. attributes: {
  82237. [key: string]: string;
  82238. };
  82239. indices: string;
  82240. material: string;
  82241. mode?: number;
  82242. }
  82243. /** @hidden */
  82244. export interface IGLTFMesh extends IGLTFChildRootProperty {
  82245. primitives: IGLTFMeshPrimitive[];
  82246. }
  82247. /** @hidden */
  82248. export interface IGLTFImage extends IGLTFChildRootProperty {
  82249. uri: string;
  82250. }
  82251. /** @hidden */
  82252. export interface IGLTFSampler extends IGLTFChildRootProperty {
  82253. magFilter?: number;
  82254. minFilter?: number;
  82255. wrapS?: number;
  82256. wrapT?: number;
  82257. }
  82258. /** @hidden */
  82259. export interface IGLTFTexture extends IGLTFChildRootProperty {
  82260. sampler: string;
  82261. source: string;
  82262. format?: ETextureFormat;
  82263. internalFormat?: ETextureFormat;
  82264. target?: number;
  82265. type?: number;
  82266. babylonTexture?: Texture;
  82267. }
  82268. /** @hidden */
  82269. export interface IGLTFAmbienLight {
  82270. color?: number[];
  82271. }
  82272. /** @hidden */
  82273. export interface IGLTFDirectionalLight {
  82274. color?: number[];
  82275. }
  82276. /** @hidden */
  82277. export interface IGLTFPointLight {
  82278. color?: number[];
  82279. constantAttenuation?: number;
  82280. linearAttenuation?: number;
  82281. quadraticAttenuation?: number;
  82282. }
  82283. /** @hidden */
  82284. export interface IGLTFSpotLight {
  82285. color?: number[];
  82286. constantAttenuation?: number;
  82287. fallOfAngle?: number;
  82288. fallOffExponent?: number;
  82289. linearAttenuation?: number;
  82290. quadraticAttenuation?: number;
  82291. }
  82292. /** @hidden */
  82293. export interface IGLTFLight extends IGLTFChildRootProperty {
  82294. type: string;
  82295. }
  82296. /** @hidden */
  82297. export interface IGLTFCameraOrthographic {
  82298. xmag: number;
  82299. ymag: number;
  82300. zfar: number;
  82301. znear: number;
  82302. }
  82303. /** @hidden */
  82304. export interface IGLTFCameraPerspective {
  82305. aspectRatio: number;
  82306. yfov: number;
  82307. zfar: number;
  82308. znear: number;
  82309. }
  82310. /** @hidden */
  82311. export interface IGLTFCamera extends IGLTFChildRootProperty {
  82312. type: string;
  82313. }
  82314. /** @hidden */
  82315. export interface IGLTFAnimationChannelTarget {
  82316. id: string;
  82317. path: string;
  82318. }
  82319. /** @hidden */
  82320. export interface IGLTFAnimationChannel {
  82321. sampler: string;
  82322. target: IGLTFAnimationChannelTarget;
  82323. }
  82324. /** @hidden */
  82325. export interface IGLTFAnimationSampler {
  82326. input: string;
  82327. output: string;
  82328. interpolation?: string;
  82329. }
  82330. /** @hidden */
  82331. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  82332. channels?: IGLTFAnimationChannel[];
  82333. parameters?: {
  82334. [key: string]: string;
  82335. };
  82336. samplers?: {
  82337. [key: string]: IGLTFAnimationSampler;
  82338. };
  82339. }
  82340. /** @hidden */
  82341. export interface IGLTFNodeInstanceSkin {
  82342. skeletons: string[];
  82343. skin: string;
  82344. meshes: string[];
  82345. }
  82346. /** @hidden */
  82347. export interface IGLTFSkins extends IGLTFChildRootProperty {
  82348. bindShapeMatrix: number[];
  82349. inverseBindMatrices: string;
  82350. jointNames: string[];
  82351. babylonSkeleton?: Skeleton;
  82352. }
  82353. /** @hidden */
  82354. export interface IGLTFNode extends IGLTFChildRootProperty {
  82355. camera?: string;
  82356. children: string[];
  82357. skin?: string;
  82358. jointName?: string;
  82359. light?: string;
  82360. matrix: number[];
  82361. mesh?: string;
  82362. meshes?: string[];
  82363. rotation?: number[];
  82364. scale?: number[];
  82365. translation?: number[];
  82366. babylonNode?: Node;
  82367. }
  82368. /** @hidden */
  82369. export interface IGLTFScene extends IGLTFChildRootProperty {
  82370. nodes: string[];
  82371. }
  82372. /** @hidden */
  82373. export interface IGLTFRuntime {
  82374. extensions: {
  82375. [key: string]: any;
  82376. };
  82377. accessors: {
  82378. [key: string]: IGLTFAccessor;
  82379. };
  82380. buffers: {
  82381. [key: string]: IGLTFBuffer;
  82382. };
  82383. bufferViews: {
  82384. [key: string]: IGLTFBufferView;
  82385. };
  82386. meshes: {
  82387. [key: string]: IGLTFMesh;
  82388. };
  82389. lights: {
  82390. [key: string]: IGLTFLight;
  82391. };
  82392. cameras: {
  82393. [key: string]: IGLTFCamera;
  82394. };
  82395. nodes: {
  82396. [key: string]: IGLTFNode;
  82397. };
  82398. images: {
  82399. [key: string]: IGLTFImage;
  82400. };
  82401. textures: {
  82402. [key: string]: IGLTFTexture;
  82403. };
  82404. shaders: {
  82405. [key: string]: IGLTFShader;
  82406. };
  82407. programs: {
  82408. [key: string]: IGLTFProgram;
  82409. };
  82410. samplers: {
  82411. [key: string]: IGLTFSampler;
  82412. };
  82413. techniques: {
  82414. [key: string]: IGLTFTechnique;
  82415. };
  82416. materials: {
  82417. [key: string]: IGLTFMaterial;
  82418. };
  82419. animations: {
  82420. [key: string]: IGLTFAnimation;
  82421. };
  82422. skins: {
  82423. [key: string]: IGLTFSkins;
  82424. };
  82425. currentScene?: Object;
  82426. scenes: {
  82427. [key: string]: IGLTFScene;
  82428. };
  82429. extensionsUsed: string[];
  82430. extensionsRequired?: string[];
  82431. buffersCount: number;
  82432. shaderscount: number;
  82433. scene: Scene;
  82434. rootUrl: string;
  82435. loadedBufferCount: number;
  82436. loadedBufferViews: {
  82437. [name: string]: ArrayBufferView;
  82438. };
  82439. loadedShaderCount: number;
  82440. importOnlyMeshes: boolean;
  82441. importMeshesNames?: string[];
  82442. dummyNodes: Node[];
  82443. forAssetContainer: boolean;
  82444. }
  82445. /** @hidden */
  82446. export interface INodeToRoot {
  82447. bone: Bone;
  82448. node: IGLTFNode;
  82449. id: string;
  82450. }
  82451. /** @hidden */
  82452. export interface IJointNode {
  82453. node: IGLTFNode;
  82454. id: string;
  82455. }
  82456. }
  82457. declare module BABYLON.GLTF1 {
  82458. /**
  82459. * Utils functions for GLTF
  82460. * @hidden
  82461. */
  82462. export class GLTFUtils {
  82463. /**
  82464. * Sets the given "parameter" matrix
  82465. * @param scene: the Scene object
  82466. * @param source: the source node where to pick the matrix
  82467. * @param parameter: the GLTF technique parameter
  82468. * @param uniformName: the name of the shader's uniform
  82469. * @param shaderMaterial: the shader material
  82470. */
  82471. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  82472. /**
  82473. * Sets the given "parameter" matrix
  82474. * @param shaderMaterial: the shader material
  82475. * @param uniform: the name of the shader's uniform
  82476. * @param value: the value of the uniform
  82477. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  82478. */
  82479. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  82480. /**
  82481. * Returns the wrap mode of the texture
  82482. * @param mode: the mode value
  82483. */
  82484. static GetWrapMode(mode: number): number;
  82485. /**
  82486. * Returns the byte stride giving an accessor
  82487. * @param accessor: the GLTF accessor objet
  82488. */
  82489. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  82490. /**
  82491. * Returns the texture filter mode giving a mode value
  82492. * @param mode: the filter mode value
  82493. */
  82494. static GetTextureFilterMode(mode: number): ETextureFilterType;
  82495. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  82496. /**
  82497. * Returns a buffer from its accessor
  82498. * @param gltfRuntime: the GLTF runtime
  82499. * @param accessor: the GLTF accessor
  82500. */
  82501. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  82502. /**
  82503. * Decodes a buffer view into a string
  82504. * @param view: the buffer view
  82505. */
  82506. static DecodeBufferToText(view: ArrayBufferView): string;
  82507. /**
  82508. * Returns the default material of gltf. Related to
  82509. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  82510. * @param scene: the Babylon.js scene
  82511. */
  82512. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  82513. private static _DefaultMaterial;
  82514. }
  82515. }
  82516. declare module BABYLON.GLTF1 {
  82517. /**
  82518. * Implementation of the base glTF spec
  82519. * @hidden
  82520. */
  82521. export class GLTFLoaderBase {
  82522. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  82523. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  82524. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  82525. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  82526. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  82527. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  82528. }
  82529. /**
  82530. * glTF V1 Loader
  82531. * @hidden
  82532. */
  82533. export class GLTFLoader implements IGLTFLoader {
  82534. static Extensions: {
  82535. [name: string]: GLTFLoaderExtension;
  82536. };
  82537. static RegisterExtension(extension: GLTFLoaderExtension): void;
  82538. state: Nullable<GLTFLoaderState>;
  82539. dispose(): void;
  82540. private _importMeshAsync;
  82541. /**
  82542. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  82543. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  82544. * @param scene the scene the meshes should be added to
  82545. * @param forAssetContainer defines if the entities must be stored in the scene
  82546. * @param data gltf data containing information of the meshes in a loaded file
  82547. * @param rootUrl root url to load from
  82548. * @param onProgress event that fires when loading progress has occured
  82549. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  82550. */
  82551. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  82552. private _loadAsync;
  82553. /**
  82554. * Imports all objects from a loaded gltf file and adds them to the scene
  82555. * @param scene the scene the objects should be added to
  82556. * @param data gltf data containing information of the meshes in a loaded file
  82557. * @param rootUrl root url to load from
  82558. * @param onProgress event that fires when loading progress has occured
  82559. * @returns a promise which completes when objects have been loaded to the scene
  82560. */
  82561. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  82562. private _loadShadersAsync;
  82563. private _loadBuffersAsync;
  82564. private _createNodes;
  82565. }
  82566. /** @hidden */
  82567. export abstract class GLTFLoaderExtension {
  82568. private _name;
  82569. constructor(name: string);
  82570. get name(): string;
  82571. /**
  82572. * Defines an override for loading the runtime
  82573. * Return true to stop further extensions from loading the runtime
  82574. */
  82575. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  82576. /**
  82577. * Defines an onverride for creating gltf runtime
  82578. * Return true to stop further extensions from creating the runtime
  82579. */
  82580. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  82581. /**
  82582. * Defines an override for loading buffers
  82583. * Return true to stop further extensions from loading this buffer
  82584. */
  82585. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  82586. /**
  82587. * Defines an override for loading texture buffers
  82588. * Return true to stop further extensions from loading this texture data
  82589. */
  82590. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82591. /**
  82592. * Defines an override for creating textures
  82593. * Return true to stop further extensions from loading this texture
  82594. */
  82595. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  82596. /**
  82597. * Defines an override for loading shader strings
  82598. * Return true to stop further extensions from loading this shader data
  82599. */
  82600. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  82601. /**
  82602. * Defines an override for loading materials
  82603. * Return true to stop further extensions from loading this material
  82604. */
  82605. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  82606. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  82607. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  82608. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  82609. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  82610. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  82611. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  82612. private static LoadTextureBufferAsync;
  82613. private static CreateTextureAsync;
  82614. private static ApplyExtensions;
  82615. }
  82616. }
  82617. declare module BABYLON.GLTF1 {
  82618. /** @hidden */
  82619. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  82620. private _bin;
  82621. constructor();
  82622. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  82623. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82624. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82625. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  82626. }
  82627. }
  82628. declare module BABYLON.GLTF1 {
  82629. /** @hidden */
  82630. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  82631. constructor();
  82632. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  82633. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  82634. private _loadTexture;
  82635. }
  82636. }
  82637. declare module BABYLON.GLTF2.Loader {
  82638. /**
  82639. * Loader interface with an index field.
  82640. */
  82641. export interface IArrayItem {
  82642. /**
  82643. * The index of this item in the array.
  82644. */
  82645. index: number;
  82646. }
  82647. /**
  82648. * Loader interface with additional members.
  82649. */
  82650. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  82651. /** @hidden */
  82652. _data?: Promise<ArrayBufferView>;
  82653. /** @hidden */
  82654. _babylonVertexBuffer?: Promise<VertexBuffer>;
  82655. }
  82656. /**
  82657. * Loader interface with additional members.
  82658. */
  82659. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  82660. }
  82661. /** @hidden */
  82662. export interface _IAnimationSamplerData {
  82663. input: Float32Array;
  82664. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  82665. output: Float32Array;
  82666. }
  82667. /**
  82668. * Loader interface with additional members.
  82669. */
  82670. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  82671. /** @hidden */
  82672. _data?: Promise<_IAnimationSamplerData>;
  82673. }
  82674. /**
  82675. * Loader interface with additional members.
  82676. */
  82677. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  82678. channels: IAnimationChannel[];
  82679. samplers: IAnimationSampler[];
  82680. /** @hidden */
  82681. _babylonAnimationGroup?: AnimationGroup;
  82682. }
  82683. /**
  82684. * Loader interface with additional members.
  82685. */
  82686. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  82687. /** @hidden */
  82688. _data?: Promise<ArrayBufferView>;
  82689. }
  82690. /**
  82691. * Loader interface with additional members.
  82692. */
  82693. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  82694. /** @hidden */
  82695. _data?: Promise<ArrayBufferView>;
  82696. /** @hidden */
  82697. _babylonBuffer?: Promise<Buffer>;
  82698. }
  82699. /**
  82700. * Loader interface with additional members.
  82701. */
  82702. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  82703. }
  82704. /**
  82705. * Loader interface with additional members.
  82706. */
  82707. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  82708. /** @hidden */
  82709. _data?: Promise<ArrayBufferView>;
  82710. }
  82711. /**
  82712. * Loader interface with additional members.
  82713. */
  82714. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  82715. }
  82716. /**
  82717. * Loader interface with additional members.
  82718. */
  82719. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  82720. }
  82721. /**
  82722. * Loader interface with additional members.
  82723. */
  82724. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  82725. baseColorTexture?: ITextureInfo;
  82726. metallicRoughnessTexture?: ITextureInfo;
  82727. }
  82728. /**
  82729. * Loader interface with additional members.
  82730. */
  82731. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  82732. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  82733. normalTexture?: IMaterialNormalTextureInfo;
  82734. occlusionTexture?: IMaterialOcclusionTextureInfo;
  82735. emissiveTexture?: ITextureInfo;
  82736. /** @hidden */
  82737. _data?: {
  82738. [babylonDrawMode: number]: {
  82739. babylonMaterial: Material;
  82740. babylonMeshes: AbstractMesh[];
  82741. promise: Promise<void>;
  82742. };
  82743. };
  82744. }
  82745. /**
  82746. * Loader interface with additional members.
  82747. */
  82748. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  82749. primitives: IMeshPrimitive[];
  82750. }
  82751. /**
  82752. * Loader interface with additional members.
  82753. */
  82754. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  82755. /** @hidden */
  82756. _instanceData?: {
  82757. babylonSourceMesh: Mesh;
  82758. promise: Promise<any>;
  82759. };
  82760. }
  82761. /**
  82762. * Loader interface with additional members.
  82763. */
  82764. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  82765. /**
  82766. * The parent glTF node.
  82767. */
  82768. parent?: INode;
  82769. /** @hidden */
  82770. _babylonTransformNode?: TransformNode;
  82771. /** @hidden */
  82772. _primitiveBabylonMeshes?: AbstractMesh[];
  82773. /** @hidden */
  82774. _babylonBones?: Bone[];
  82775. /** @hidden */
  82776. _numMorphTargets?: number;
  82777. }
  82778. /** @hidden */
  82779. export interface _ISamplerData {
  82780. noMipMaps: boolean;
  82781. samplingMode: number;
  82782. wrapU: number;
  82783. wrapV: number;
  82784. }
  82785. /**
  82786. * Loader interface with additional members.
  82787. */
  82788. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  82789. /** @hidden */
  82790. _data?: _ISamplerData;
  82791. }
  82792. /**
  82793. * Loader interface with additional members.
  82794. */
  82795. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  82796. }
  82797. /**
  82798. * Loader interface with additional members.
  82799. */
  82800. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  82801. /** @hidden */
  82802. _data?: {
  82803. babylonSkeleton: Skeleton;
  82804. promise: Promise<void>;
  82805. };
  82806. }
  82807. /**
  82808. * Loader interface with additional members.
  82809. */
  82810. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  82811. /** @hidden */
  82812. _textureInfo: ITextureInfo;
  82813. }
  82814. /**
  82815. * Loader interface with additional members.
  82816. */
  82817. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  82818. /** false or undefined if the texture holds color data (true if data are roughness, normal, ...) */
  82819. nonColorData?: boolean;
  82820. }
  82821. /**
  82822. * Loader interface with additional members.
  82823. */
  82824. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  82825. accessors?: IAccessor[];
  82826. animations?: IAnimation[];
  82827. buffers?: IBuffer[];
  82828. bufferViews?: IBufferView[];
  82829. cameras?: ICamera[];
  82830. images?: IImage[];
  82831. materials?: IMaterial[];
  82832. meshes?: IMesh[];
  82833. nodes?: INode[];
  82834. samplers?: ISampler[];
  82835. scenes?: IScene[];
  82836. skins?: ISkin[];
  82837. textures?: ITexture[];
  82838. }
  82839. }
  82840. declare module BABYLON.GLTF2 {
  82841. /**
  82842. * Interface for a glTF loader extension.
  82843. */
  82844. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  82845. /**
  82846. * Called after the loader state changes to LOADING.
  82847. */
  82848. onLoading?(): void;
  82849. /**
  82850. * Called after the loader state changes to READY.
  82851. */
  82852. onReady?(): void;
  82853. /**
  82854. * Define this method to modify the default behavior when loading scenes.
  82855. * @param context The context when loading the asset
  82856. * @param scene The glTF scene property
  82857. * @returns A promise that resolves when the load is complete or null if not handled
  82858. */
  82859. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  82860. /**
  82861. * Define this method to modify the default behavior when loading nodes.
  82862. * @param context The context when loading the asset
  82863. * @param node The glTF node property
  82864. * @param assign A function called synchronously after parsing the glTF properties
  82865. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  82866. */
  82867. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82868. /**
  82869. * Define this method to modify the default behavior when loading cameras.
  82870. * @param context The context when loading the asset
  82871. * @param camera The glTF camera property
  82872. * @param assign A function called synchronously after parsing the glTF properties
  82873. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  82874. */
  82875. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  82876. /**
  82877. * @hidden
  82878. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  82879. * @param context The context when loading the asset
  82880. * @param primitive The glTF mesh primitive property
  82881. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  82882. */
  82883. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  82884. /**
  82885. * @hidden
  82886. * Define this method to modify the default behavior when loading data for mesh primitives.
  82887. * @param context The context when loading the asset
  82888. * @param name The mesh name when loading the asset
  82889. * @param node The glTF node when loading the asset
  82890. * @param mesh The glTF mesh when loading the asset
  82891. * @param primitive The glTF mesh primitive property
  82892. * @param assign A function called synchronously after parsing the glTF properties
  82893. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  82894. */
  82895. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  82896. /**
  82897. * @hidden
  82898. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  82899. * @param context The context when loading the asset
  82900. * @param material The glTF material property
  82901. * @param assign A function called synchronously after parsing the glTF properties
  82902. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  82903. */
  82904. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  82905. /**
  82906. * Define this method to modify the default behavior when creating materials.
  82907. * @param context The context when loading the asset
  82908. * @param material The glTF material property
  82909. * @param babylonDrawMode The draw mode for the Babylon material
  82910. * @returns The Babylon material or null if not handled
  82911. */
  82912. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  82913. /**
  82914. * Define this method to modify the default behavior when loading material properties.
  82915. * @param context The context when loading the asset
  82916. * @param material The glTF material property
  82917. * @param babylonMaterial The Babylon material
  82918. * @returns A promise that resolves when the load is complete or null if not handled
  82919. */
  82920. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82921. /**
  82922. * Define this method to modify the default behavior when loading texture infos.
  82923. * @param context The context when loading the asset
  82924. * @param textureInfo The glTF texture info property
  82925. * @param assign A function called synchronously after parsing the glTF properties
  82926. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  82927. */
  82928. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82929. /**
  82930. * @hidden
  82931. * Define this method to modify the default behavior when loading textures.
  82932. * @param context The context when loading the asset
  82933. * @param texture The glTF texture property
  82934. * @param assign A function called synchronously after parsing the glTF properties
  82935. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  82936. */
  82937. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82938. /**
  82939. * Define this method to modify the default behavior when loading animations.
  82940. * @param context The context when loading the asset
  82941. * @param animation The glTF animation property
  82942. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  82943. */
  82944. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  82945. /**
  82946. * @hidden
  82947. * Define this method to modify the default behavior when loading skins.
  82948. * @param context The context when loading the asset
  82949. * @param node The glTF node property
  82950. * @param skin The glTF skin property
  82951. * @returns A promise that resolves when the load is complete or null if not handled
  82952. */
  82953. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  82954. /**
  82955. * @hidden
  82956. * Define this method to modify the default behavior when loading uris.
  82957. * @param context The context when loading the asset
  82958. * @param property The glTF property associated with the uri
  82959. * @param uri The uri to load
  82960. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  82961. */
  82962. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  82963. /**
  82964. * Define this method to modify the default behavior when loading buffer views.
  82965. * @param context The context when loading the asset
  82966. * @param bufferView The glTF buffer view property
  82967. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  82968. */
  82969. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  82970. /**
  82971. * Define this method to modify the default behavior when loading buffers.
  82972. * @param context The context when loading the asset
  82973. * @param buffer The glTF buffer property
  82974. * @param byteOffset The byte offset to load
  82975. * @param byteLength The byte length to load
  82976. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  82977. */
  82978. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  82979. }
  82980. }
  82981. declare module BABYLON.GLTF2 {
  82982. /**
  82983. * Helper class for working with arrays when loading the glTF asset
  82984. */
  82985. export class ArrayItem {
  82986. /**
  82987. * Gets an item from the given array.
  82988. * @param context The context when loading the asset
  82989. * @param array The array to get the item from
  82990. * @param index The index to the array
  82991. * @returns The array item
  82992. */
  82993. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  82994. /**
  82995. * Assign an `index` field to each item of the given array.
  82996. * @param array The array of items
  82997. */
  82998. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  82999. }
  83000. /**
  83001. * The glTF 2.0 loader
  83002. */
  83003. export class GLTFLoader implements IGLTFLoader {
  83004. /** @hidden */
  83005. _completePromises: Promise<any>[];
  83006. /** @hidden */
  83007. _forAssetContainer: boolean;
  83008. /** Storage */
  83009. _babylonLights: Light[];
  83010. /** @hidden */
  83011. _disableInstancedMesh: number;
  83012. private _disposed;
  83013. private _parent;
  83014. private _state;
  83015. private _extensions;
  83016. private _rootUrl;
  83017. private _fileName;
  83018. private _uniqueRootUrl;
  83019. private _gltf;
  83020. private _bin;
  83021. private _babylonScene;
  83022. private _rootBabylonMesh;
  83023. private _defaultBabylonMaterialData;
  83024. private static _RegisteredExtensions;
  83025. /**
  83026. * The default glTF sampler.
  83027. */
  83028. static readonly DefaultSampler: ISampler;
  83029. /**
  83030. * Registers a loader extension.
  83031. * @param name The name of the loader extension.
  83032. * @param factory The factory function that creates the loader extension.
  83033. */
  83034. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  83035. /**
  83036. * Unregisters a loader extension.
  83037. * @param name The name of the loader extension.
  83038. * @returns A boolean indicating whether the extension has been unregistered
  83039. */
  83040. static UnregisterExtension(name: string): boolean;
  83041. /**
  83042. * The loader state.
  83043. */
  83044. get state(): Nullable<GLTFLoaderState>;
  83045. /**
  83046. * The object that represents the glTF JSON.
  83047. */
  83048. get gltf(): IGLTF;
  83049. /**
  83050. * The BIN chunk of a binary glTF.
  83051. */
  83052. get bin(): Nullable<IDataBuffer>;
  83053. /**
  83054. * The parent file loader.
  83055. */
  83056. get parent(): GLTFFileLoader;
  83057. /**
  83058. * The Babylon scene when loading the asset.
  83059. */
  83060. get babylonScene(): Scene;
  83061. /**
  83062. * The root Babylon mesh when loading the asset.
  83063. */
  83064. get rootBabylonMesh(): Mesh;
  83065. /** @hidden */
  83066. constructor(parent: GLTFFileLoader);
  83067. /** @hidden */
  83068. dispose(): void;
  83069. /** @hidden */
  83070. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  83071. /** @hidden */
  83072. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  83073. private _loadAsync;
  83074. private _loadData;
  83075. private _setupData;
  83076. private _loadExtensions;
  83077. private _checkExtensions;
  83078. private _setState;
  83079. private _createRootNode;
  83080. /**
  83081. * Loads a glTF scene.
  83082. * @param context The context when loading the asset
  83083. * @param scene The glTF scene property
  83084. * @returns A promise that resolves when the load is complete
  83085. */
  83086. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  83087. private _forEachPrimitive;
  83088. private _getGeometries;
  83089. private _getMeshes;
  83090. private _getTransformNodes;
  83091. private _getSkeletons;
  83092. private _getAnimationGroups;
  83093. private _startAnimations;
  83094. /**
  83095. * Loads a glTF node.
  83096. * @param context The context when loading the asset
  83097. * @param node The glTF node property
  83098. * @param assign A function called synchronously after parsing the glTF properties
  83099. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  83100. */
  83101. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  83102. private _loadMeshAsync;
  83103. /**
  83104. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  83105. * @param context The context when loading the asset
  83106. * @param name The mesh name when loading the asset
  83107. * @param node The glTF node when loading the asset
  83108. * @param mesh The glTF mesh when loading the asset
  83109. * @param primitive The glTF mesh primitive property
  83110. * @param assign A function called synchronously after parsing the glTF properties
  83111. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  83112. */
  83113. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  83114. private _loadVertexDataAsync;
  83115. private _createMorphTargets;
  83116. private _loadMorphTargetsAsync;
  83117. private _loadMorphTargetVertexDataAsync;
  83118. private static _LoadTransform;
  83119. private _loadSkinAsync;
  83120. private _loadBones;
  83121. private _loadBone;
  83122. private _loadSkinInverseBindMatricesDataAsync;
  83123. private _updateBoneMatrices;
  83124. private _getNodeMatrix;
  83125. /**
  83126. * Loads a glTF camera.
  83127. * @param context The context when loading the asset
  83128. * @param camera The glTF camera property
  83129. * @param assign A function called synchronously after parsing the glTF properties
  83130. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  83131. */
  83132. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  83133. private _loadAnimationsAsync;
  83134. /**
  83135. * Loads a glTF animation.
  83136. * @param context The context when loading the asset
  83137. * @param animation The glTF animation property
  83138. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  83139. */
  83140. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  83141. /**
  83142. * @hidden Loads a glTF animation channel.
  83143. * @param context The context when loading the asset
  83144. * @param animationContext The context of the animation when loading the asset
  83145. * @param animation The glTF animation property
  83146. * @param channel The glTF animation channel property
  83147. * @param babylonAnimationGroup The babylon animation group property
  83148. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  83149. * @returns A void promise when the channel load is complete
  83150. */
  83151. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  83152. private _loadAnimationSamplerAsync;
  83153. private _loadBufferAsync;
  83154. /**
  83155. * Loads a glTF buffer view.
  83156. * @param context The context when loading the asset
  83157. * @param bufferView The glTF buffer view property
  83158. * @returns A promise that resolves with the loaded data when the load is complete
  83159. */
  83160. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  83161. private _loadAccessorAsync;
  83162. /** @hidden */
  83163. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  83164. private _loadIndicesAccessorAsync;
  83165. private _loadVertexBufferViewAsync;
  83166. private _loadVertexAccessorAsync;
  83167. private _loadMaterialMetallicRoughnessPropertiesAsync;
  83168. /** @hidden */
  83169. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  83170. private _createDefaultMaterial;
  83171. /**
  83172. * Creates a Babylon material from a glTF material.
  83173. * @param context The context when loading the asset
  83174. * @param material The glTF material property
  83175. * @param babylonDrawMode The draw mode for the Babylon material
  83176. * @returns The Babylon material
  83177. */
  83178. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  83179. /**
  83180. * Loads properties from a glTF material into a Babylon material.
  83181. * @param context The context when loading the asset
  83182. * @param material The glTF material property
  83183. * @param babylonMaterial The Babylon material
  83184. * @returns A promise that resolves when the load is complete
  83185. */
  83186. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  83187. /**
  83188. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  83189. * @param context The context when loading the asset
  83190. * @param material The glTF material property
  83191. * @param babylonMaterial The Babylon material
  83192. * @returns A promise that resolves when the load is complete
  83193. */
  83194. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  83195. /**
  83196. * Loads the alpha properties from a glTF material into a Babylon material.
  83197. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  83198. * @param context The context when loading the asset
  83199. * @param material The glTF material property
  83200. * @param babylonMaterial The Babylon material
  83201. */
  83202. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  83203. /**
  83204. * Loads a glTF texture info.
  83205. * @param context The context when loading the asset
  83206. * @param textureInfo The glTF texture info property
  83207. * @param assign A function called synchronously after parsing the glTF properties
  83208. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  83209. */
  83210. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  83211. /** @hidden */
  83212. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  83213. /** @hidden */
  83214. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void, textureLoaderOptions?: any): Promise<BaseTexture>;
  83215. private _loadSampler;
  83216. /**
  83217. * Loads a glTF image.
  83218. * @param context The context when loading the asset
  83219. * @param image The glTF image property
  83220. * @returns A promise that resolves with the loaded data when the load is complete
  83221. */
  83222. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  83223. /**
  83224. * Loads a glTF uri.
  83225. * @param context The context when loading the asset
  83226. * @param property The glTF property associated with the uri
  83227. * @param uri The base64 or relative uri
  83228. * @returns A promise that resolves with the loaded data when the load is complete
  83229. */
  83230. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  83231. /**
  83232. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  83233. * @param babylonObject the Babylon object with metadata
  83234. * @param pointer the JSON pointer
  83235. */
  83236. static AddPointerMetadata(babylonObject: {
  83237. metadata: any;
  83238. }, pointer: string): void;
  83239. private static _GetTextureWrapMode;
  83240. private static _GetTextureSamplingMode;
  83241. private static _GetTypedArrayConstructor;
  83242. private static _GetTypedArray;
  83243. private static _GetNumComponents;
  83244. private static _ValidateUri;
  83245. /** @hidden */
  83246. static _GetDrawMode(context: string, mode: number | undefined): number;
  83247. private _compileMaterialsAsync;
  83248. private _compileShadowGeneratorsAsync;
  83249. private _forEachExtensions;
  83250. private _applyExtensions;
  83251. private _extensionsOnLoading;
  83252. private _extensionsOnReady;
  83253. private _extensionsLoadSceneAsync;
  83254. private _extensionsLoadNodeAsync;
  83255. private _extensionsLoadCameraAsync;
  83256. private _extensionsLoadVertexDataAsync;
  83257. private _extensionsLoadMeshPrimitiveAsync;
  83258. private _extensionsLoadMaterialAsync;
  83259. private _extensionsCreateMaterial;
  83260. private _extensionsLoadMaterialPropertiesAsync;
  83261. private _extensionsLoadTextureInfoAsync;
  83262. private _extensionsLoadTextureAsync;
  83263. private _extensionsLoadAnimationAsync;
  83264. private _extensionsLoadSkinAsync;
  83265. private _extensionsLoadUriAsync;
  83266. private _extensionsLoadBufferViewAsync;
  83267. private _extensionsLoadBufferAsync;
  83268. /**
  83269. * Helper method called by a loader extension to load an glTF extension.
  83270. * @param context The context when loading the asset
  83271. * @param property The glTF property to load the extension from
  83272. * @param extensionName The name of the extension to load
  83273. * @param actionAsync The action to run
  83274. * @returns The promise returned by actionAsync or null if the extension does not exist
  83275. */
  83276. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  83277. /**
  83278. * Helper method called by a loader extension to load a glTF extra.
  83279. * @param context The context when loading the asset
  83280. * @param property The glTF property to load the extra from
  83281. * @param extensionName The name of the extension to load
  83282. * @param actionAsync The action to run
  83283. * @returns The promise returned by actionAsync or null if the extra does not exist
  83284. */
  83285. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  83286. /**
  83287. * Checks for presence of an extension.
  83288. * @param name The name of the extension to check
  83289. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  83290. */
  83291. isExtensionUsed(name: string): boolean;
  83292. /**
  83293. * Increments the indentation level and logs a message.
  83294. * @param message The message to log
  83295. */
  83296. logOpen(message: string): void;
  83297. /**
  83298. * Decrements the indentation level.
  83299. */
  83300. logClose(): void;
  83301. /**
  83302. * Logs a message
  83303. * @param message The message to log
  83304. */
  83305. log(message: string): void;
  83306. /**
  83307. * Starts a performance counter.
  83308. * @param counterName The name of the performance counter
  83309. */
  83310. startPerformanceCounter(counterName: string): void;
  83311. /**
  83312. * Ends a performance counter.
  83313. * @param counterName The name of the performance counter
  83314. */
  83315. endPerformanceCounter(counterName: string): void;
  83316. }
  83317. }
  83318. declare module BABYLON.GLTF2.Loader.Extensions {
  83319. /** @hidden */
  83320. interface IEXTLightsImageBased_LightImageBased {
  83321. _babylonTexture?: BaseTexture;
  83322. _loaded?: Promise<void>;
  83323. }
  83324. /**
  83325. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  83326. */
  83327. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  83328. /**
  83329. * The name of this extension.
  83330. */
  83331. readonly name: string;
  83332. /**
  83333. * Defines whether this extension is enabled.
  83334. */
  83335. enabled: boolean;
  83336. private _loader;
  83337. private _lights?;
  83338. /** @hidden */
  83339. constructor(loader: GLTFLoader);
  83340. /** @hidden */
  83341. dispose(): void;
  83342. /** @hidden */
  83343. onLoading(): void;
  83344. /** @hidden */
  83345. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  83346. private _loadLightAsync;
  83347. }
  83348. }
  83349. declare module BABYLON.GLTF2.Loader.Extensions {
  83350. /**
  83351. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  83352. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  83353. * !!! Experimental Extension Subject to Changes !!!
  83354. */
  83355. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  83356. /**
  83357. * The name of this extension.
  83358. */
  83359. readonly name: string;
  83360. /**
  83361. * Defines whether this extension is enabled.
  83362. */
  83363. enabled: boolean;
  83364. private _loader;
  83365. /** @hidden */
  83366. constructor(loader: GLTFLoader);
  83367. /** @hidden */
  83368. dispose(): void;
  83369. /** @hidden */
  83370. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83371. }
  83372. }
  83373. declare module BABYLON.GLTF2.Loader.Extensions {
  83374. /**
  83375. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  83376. */
  83377. export class EXT_texture_webp implements IGLTFLoaderExtension {
  83378. /** The name of this extension. */
  83379. readonly name: string;
  83380. /** Defines whether this extension is enabled. */
  83381. enabled: boolean;
  83382. private _loader;
  83383. /** @hidden */
  83384. constructor(loader: GLTFLoader);
  83385. /** @hidden */
  83386. dispose(): void;
  83387. /** @hidden */
  83388. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83389. }
  83390. }
  83391. declare module BABYLON.GLTF2.Loader.Extensions {
  83392. /**
  83393. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  83394. */
  83395. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  83396. /**
  83397. * The name of this extension.
  83398. */
  83399. readonly name: string;
  83400. /**
  83401. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  83402. */
  83403. dracoCompression?: DracoCompression;
  83404. /**
  83405. * Defines whether this extension is enabled.
  83406. */
  83407. enabled: boolean;
  83408. private _loader;
  83409. /** @hidden */
  83410. constructor(loader: GLTFLoader);
  83411. /** @hidden */
  83412. dispose(): void;
  83413. /** @hidden */
  83414. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  83415. }
  83416. }
  83417. declare module BABYLON.GLTF2.Loader.Extensions {
  83418. /**
  83419. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  83420. */
  83421. export class KHR_lights implements IGLTFLoaderExtension {
  83422. /**
  83423. * The name of this extension.
  83424. */
  83425. readonly name: string;
  83426. /**
  83427. * Defines whether this extension is enabled.
  83428. */
  83429. enabled: boolean;
  83430. private _loader;
  83431. private _lights?;
  83432. /** @hidden */
  83433. constructor(loader: GLTFLoader);
  83434. /** @hidden */
  83435. dispose(): void;
  83436. /** @hidden */
  83437. onLoading(): void;
  83438. /** @hidden */
  83439. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83440. }
  83441. }
  83442. declare module BABYLON.GLTF2.Loader.Extensions {
  83443. /**
  83444. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  83445. */
  83446. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  83447. /**
  83448. * The name of this extension.
  83449. */
  83450. readonly name: string;
  83451. /**
  83452. * Defines whether this extension is enabled.
  83453. */
  83454. enabled: boolean;
  83455. /**
  83456. * Defines a number that determines the order the extensions are applied.
  83457. */
  83458. order: number;
  83459. private _loader;
  83460. /** @hidden */
  83461. constructor(loader: GLTFLoader);
  83462. /** @hidden */
  83463. dispose(): void;
  83464. /** @hidden */
  83465. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83466. private _loadSpecularGlossinessPropertiesAsync;
  83467. }
  83468. }
  83469. declare module BABYLON.GLTF2.Loader.Extensions {
  83470. /**
  83471. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  83472. */
  83473. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  83474. /**
  83475. * The name of this extension.
  83476. */
  83477. readonly name: string;
  83478. /**
  83479. * Defines whether this extension is enabled.
  83480. */
  83481. enabled: boolean;
  83482. /**
  83483. * Defines a number that determines the order the extensions are applied.
  83484. */
  83485. order: number;
  83486. private _loader;
  83487. /** @hidden */
  83488. constructor(loader: GLTFLoader);
  83489. /** @hidden */
  83490. dispose(): void;
  83491. /** @hidden */
  83492. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83493. private _loadUnlitPropertiesAsync;
  83494. }
  83495. }
  83496. declare module BABYLON.GLTF2.Loader.Extensions {
  83497. /**
  83498. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_clearcoat/README.md)
  83499. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  83500. */
  83501. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  83502. /**
  83503. * The name of this extension.
  83504. */
  83505. readonly name: string;
  83506. /**
  83507. * Defines whether this extension is enabled.
  83508. */
  83509. enabled: boolean;
  83510. /**
  83511. * Defines a number that determines the order the extensions are applied.
  83512. */
  83513. order: number;
  83514. private _loader;
  83515. /** @hidden */
  83516. constructor(loader: GLTFLoader);
  83517. /** @hidden */
  83518. dispose(): void;
  83519. /** @hidden */
  83520. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83521. private _loadClearCoatPropertiesAsync;
  83522. }
  83523. }
  83524. declare module BABYLON.GLTF2.Loader.Extensions {
  83525. /**
  83526. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  83527. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  83528. * !!! Experimental Extension Subject to Changes !!!
  83529. */
  83530. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  83531. /**
  83532. * The name of this extension.
  83533. */
  83534. readonly name: string;
  83535. /**
  83536. * Defines whether this extension is enabled.
  83537. */
  83538. enabled: boolean;
  83539. /**
  83540. * Defines a number that determines the order the extensions are applied.
  83541. */
  83542. order: number;
  83543. private _loader;
  83544. /** @hidden */
  83545. constructor(loader: GLTFLoader);
  83546. /** @hidden */
  83547. dispose(): void;
  83548. /** @hidden */
  83549. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83550. private _loadSheenPropertiesAsync;
  83551. }
  83552. }
  83553. declare module BABYLON.GLTF2.Loader.Extensions {
  83554. /**
  83555. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  83556. * !!! Experimental Extension Subject to Changes !!!
  83557. */
  83558. export class KHR_materials_specular implements IGLTFLoaderExtension {
  83559. /**
  83560. * The name of this extension.
  83561. */
  83562. readonly name: string;
  83563. /**
  83564. * Defines whether this extension is enabled.
  83565. */
  83566. enabled: boolean;
  83567. /**
  83568. * Defines a number that determines the order the extensions are applied.
  83569. */
  83570. order: number;
  83571. private _loader;
  83572. /** @hidden */
  83573. constructor(loader: GLTFLoader);
  83574. /** @hidden */
  83575. dispose(): void;
  83576. /** @hidden */
  83577. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83578. private _loadSpecularPropertiesAsync;
  83579. }
  83580. }
  83581. declare module BABYLON.GLTF2.Loader.Extensions {
  83582. /**
  83583. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  83584. * !!! Experimental Extension Subject to Changes !!!
  83585. */
  83586. export class KHR_materials_ior implements IGLTFLoaderExtension {
  83587. /**
  83588. * Default ior Value from the spec.
  83589. */
  83590. private static readonly _DEFAULT_IOR;
  83591. /**
  83592. * The name of this extension.
  83593. */
  83594. readonly name: string;
  83595. /**
  83596. * Defines whether this extension is enabled.
  83597. */
  83598. enabled: boolean;
  83599. /**
  83600. * Defines a number that determines the order the extensions are applied.
  83601. */
  83602. order: number;
  83603. private _loader;
  83604. /** @hidden */
  83605. constructor(loader: GLTFLoader);
  83606. /** @hidden */
  83607. dispose(): void;
  83608. /** @hidden */
  83609. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83610. private _loadIorPropertiesAsync;
  83611. }
  83612. }
  83613. declare module BABYLON.GLTF2.Loader.Extensions {
  83614. /**
  83615. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  83616. * !!! Experimental Extension Subject to Changes !!!
  83617. */
  83618. export class KHR_materials_variants implements IGLTFLoaderExtension {
  83619. /**
  83620. * The name of this extension.
  83621. */
  83622. readonly name: string;
  83623. /**
  83624. * Defines whether this extension is enabled.
  83625. */
  83626. enabled: boolean;
  83627. private _loader;
  83628. private _variants?;
  83629. /** @hidden */
  83630. constructor(loader: GLTFLoader);
  83631. /** @hidden */
  83632. dispose(): void;
  83633. /**
  83634. * Gets the list of available variant names for this asset.
  83635. * @param rootMesh The glTF root mesh
  83636. * @returns the list of all the variant names for this model
  83637. */
  83638. static GetAvailableVariants(rootMesh: Mesh): string[];
  83639. /**
  83640. * Gets the list of available variant names for this asset.
  83641. * @param rootMesh The glTF root mesh
  83642. * @returns the list of all the variant names for this model
  83643. */
  83644. getAvailableVariants(rootMesh: Mesh): string[];
  83645. /**
  83646. * Select a variant given a variant name or a list of variant names.
  83647. * @param rootMesh The glTF root mesh
  83648. * @param variantName The variant name(s) to select.
  83649. */
  83650. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  83651. /**
  83652. * Select a variant given a variant name or a list of variant names.
  83653. * @param rootMesh The glTF root mesh
  83654. * @param variantName The variant name(s) to select.
  83655. */
  83656. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  83657. /**
  83658. * Reset back to the original before selecting a variant.
  83659. * @param rootMesh The glTF root mesh
  83660. */
  83661. static Reset(rootMesh: Mesh): void;
  83662. /**
  83663. * Reset back to the original before selecting a variant.
  83664. * @param rootMesh The glTF root mesh
  83665. */
  83666. reset(rootMesh: Mesh): void;
  83667. /**
  83668. * Gets the last selected variant name(s) or null if original.
  83669. * @param rootMesh The glTF root mesh
  83670. * @returns The selected variant name(s).
  83671. */
  83672. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  83673. /**
  83674. * Gets the last selected variant name(s) or null if original.
  83675. * @param rootMesh The glTF root mesh
  83676. * @returns The selected variant name(s).
  83677. */
  83678. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  83679. private static _GetExtensionMetadata;
  83680. /** @hidden */
  83681. onLoading(): void;
  83682. /** @hidden */
  83683. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  83684. }
  83685. }
  83686. declare module BABYLON.GLTF2.Loader.Extensions {
  83687. /**
  83688. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  83689. * !!! Experimental Extension Subject to Changes !!!
  83690. */
  83691. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  83692. /**
  83693. * The name of this extension.
  83694. */
  83695. readonly name: string;
  83696. /**
  83697. * Defines whether this extension is enabled.
  83698. */
  83699. enabled: boolean;
  83700. /**
  83701. * Defines a number that determines the order the extensions are applied.
  83702. */
  83703. order: number;
  83704. private _loader;
  83705. /** @hidden */
  83706. constructor(loader: GLTFLoader);
  83707. /** @hidden */
  83708. dispose(): void;
  83709. /** @hidden */
  83710. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83711. private _loadTransparentPropertiesAsync;
  83712. }
  83713. }
  83714. declare module BABYLON.GLTF2.Loader.Extensions {
  83715. /**
  83716. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  83717. */
  83718. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  83719. /**
  83720. * The name of this extension.
  83721. */
  83722. readonly name: string;
  83723. /**
  83724. * Defines whether this extension is enabled.
  83725. */
  83726. enabled: boolean;
  83727. /** @hidden */
  83728. constructor(loader: GLTFLoader);
  83729. /** @hidden */
  83730. dispose(): void;
  83731. }
  83732. }
  83733. declare module BABYLON.GLTF2.Loader.Extensions {
  83734. /**
  83735. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  83736. * !!! Experimental Extension Subject to Changes !!!
  83737. */
  83738. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  83739. /** The name of this extension. */
  83740. readonly name: string;
  83741. /** Defines whether this extension is enabled. */
  83742. enabled: boolean;
  83743. private _loader;
  83744. /** @hidden */
  83745. constructor(loader: GLTFLoader);
  83746. /** @hidden */
  83747. dispose(): void;
  83748. /** @hidden */
  83749. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83750. }
  83751. }
  83752. declare module BABYLON.GLTF2.Loader.Extensions {
  83753. /**
  83754. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  83755. */
  83756. export class KHR_texture_transform implements IGLTFLoaderExtension {
  83757. /**
  83758. * The name of this extension.
  83759. */
  83760. readonly name: string;
  83761. /**
  83762. * Defines whether this extension is enabled.
  83763. */
  83764. enabled: boolean;
  83765. private _loader;
  83766. /** @hidden */
  83767. constructor(loader: GLTFLoader);
  83768. /** @hidden */
  83769. dispose(): void;
  83770. /** @hidden */
  83771. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83772. }
  83773. }
  83774. declare module BABYLON.GLTF2.Loader.Extensions {
  83775. /**
  83776. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  83777. * !!! Experimental Extension Subject to Changes !!!
  83778. */
  83779. export class KHR_xmp implements IGLTFLoaderExtension {
  83780. /**
  83781. * The name of this extension.
  83782. */
  83783. readonly name: string;
  83784. /**
  83785. * Defines whether this extension is enabled.
  83786. */
  83787. enabled: boolean;
  83788. /**
  83789. * Defines a number that determines the order the extensions are applied.
  83790. */
  83791. order: number;
  83792. private _loader;
  83793. /** @hidden */
  83794. constructor(loader: GLTFLoader);
  83795. /** @hidden */
  83796. dispose(): void;
  83797. /**
  83798. * Called after the loader state changes to LOADING.
  83799. */
  83800. onLoading(): void;
  83801. }
  83802. }
  83803. declare module BABYLON.GLTF2.Loader.Extensions {
  83804. /**
  83805. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  83806. */
  83807. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  83808. /**
  83809. * The name of this extension.
  83810. */
  83811. readonly name: string;
  83812. /**
  83813. * Defines whether this extension is enabled.
  83814. */
  83815. enabled: boolean;
  83816. private _loader;
  83817. private _clips;
  83818. private _emitters;
  83819. /** @hidden */
  83820. constructor(loader: GLTFLoader);
  83821. /** @hidden */
  83822. dispose(): void;
  83823. /** @hidden */
  83824. onLoading(): void;
  83825. /** @hidden */
  83826. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  83827. /** @hidden */
  83828. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83829. /** @hidden */
  83830. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  83831. private _loadClipAsync;
  83832. private _loadEmitterAsync;
  83833. private _getEventAction;
  83834. private _loadAnimationEventAsync;
  83835. }
  83836. }
  83837. declare module BABYLON.GLTF2.Loader.Extensions {
  83838. /**
  83839. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  83840. */
  83841. export class MSFT_lod 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. /**
  83851. * Defines a number that determines the order the extensions are applied.
  83852. */
  83853. order: number;
  83854. /**
  83855. * Maximum number of LODs to load, starting from the lowest LOD.
  83856. */
  83857. maxLODsToLoad: number;
  83858. /**
  83859. * Observable raised when all node LODs of one level are loaded.
  83860. * The event data is the index of the loaded LOD starting from zero.
  83861. * Dispose the loader to cancel the loading of the next level of LODs.
  83862. */
  83863. onNodeLODsLoadedObservable: Observable<number>;
  83864. /**
  83865. * Observable raised when all material LODs of one level are loaded.
  83866. * The event data is the index of the loaded LOD starting from zero.
  83867. * Dispose the loader to cancel the loading of the next level of LODs.
  83868. */
  83869. onMaterialLODsLoadedObservable: Observable<number>;
  83870. private _loader;
  83871. private _bufferLODs;
  83872. private _nodeIndexLOD;
  83873. private _nodeSignalLODs;
  83874. private _nodePromiseLODs;
  83875. private _nodeBufferLODs;
  83876. private _materialIndexLOD;
  83877. private _materialSignalLODs;
  83878. private _materialPromiseLODs;
  83879. private _materialBufferLODs;
  83880. /** @hidden */
  83881. constructor(loader: GLTFLoader);
  83882. /** @hidden */
  83883. dispose(): void;
  83884. /** @hidden */
  83885. onReady(): void;
  83886. /** @hidden */
  83887. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  83888. /** @hidden */
  83889. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83890. /** @hidden */
  83891. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  83892. /** @hidden */
  83893. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  83894. /** @hidden */
  83895. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  83896. private _loadBufferLOD;
  83897. /**
  83898. * Gets an array of LOD properties from lowest to highest.
  83899. */
  83900. private _getLODs;
  83901. private _disposeTransformNode;
  83902. private _disposeMaterials;
  83903. }
  83904. }
  83905. declare module BABYLON.GLTF2.Loader.Extensions {
  83906. /** @hidden */
  83907. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  83908. readonly name: string;
  83909. enabled: boolean;
  83910. private _loader;
  83911. constructor(loader: GLTFLoader);
  83912. dispose(): void;
  83913. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83914. }
  83915. }
  83916. declare module BABYLON.GLTF2.Loader.Extensions {
  83917. /** @hidden */
  83918. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  83919. readonly name: string;
  83920. enabled: boolean;
  83921. private _loader;
  83922. constructor(loader: GLTFLoader);
  83923. dispose(): void;
  83924. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83925. }
  83926. }
  83927. declare module BABYLON.GLTF2.Loader.Extensions {
  83928. /**
  83929. * Store glTF extras (if present) in BJS objects' metadata
  83930. */
  83931. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  83932. /**
  83933. * The name of this extension.
  83934. */
  83935. readonly name: string;
  83936. /**
  83937. * Defines whether this extension is enabled.
  83938. */
  83939. enabled: boolean;
  83940. private _loader;
  83941. private _assignExtras;
  83942. /** @hidden */
  83943. constructor(loader: GLTFLoader);
  83944. /** @hidden */
  83945. dispose(): void;
  83946. /** @hidden */
  83947. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83948. /** @hidden */
  83949. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  83950. /** @hidden */
  83951. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  83952. }
  83953. }
  83954. declare module BABYLON {
  83955. /**
  83956. * Class reading and parsing the MTL file bundled with the obj file.
  83957. */
  83958. export class MTLFileLoader {
  83959. /**
  83960. * Invert Y-Axis of referenced textures on load
  83961. */
  83962. static INVERT_TEXTURE_Y: boolean;
  83963. /**
  83964. * All material loaded from the mtl will be set here
  83965. */
  83966. materials: StandardMaterial[];
  83967. /**
  83968. * This function will read the mtl file and create each material described inside
  83969. * This function could be improve by adding :
  83970. * -some component missing (Ni, Tf...)
  83971. * -including the specific options available
  83972. *
  83973. * @param scene defines the scene the material will be created in
  83974. * @param data defines the mtl data to parse
  83975. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  83976. * @param forAssetContainer defines if the material should be registered in the scene
  83977. */
  83978. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  83979. /**
  83980. * Gets the texture for the material.
  83981. *
  83982. * If the material is imported from input file,
  83983. * We sanitize the url to ensure it takes the textre from aside the material.
  83984. *
  83985. * @param rootUrl The root url to load from
  83986. * @param value The value stored in the mtl
  83987. * @return The Texture
  83988. */
  83989. private static _getTexture;
  83990. }
  83991. }
  83992. declare module BABYLON {
  83993. /**
  83994. * Options for loading OBJ/MTL files
  83995. */
  83996. type MeshLoadOptions = {
  83997. /**
  83998. * Defines if UVs are optimized by default during load.
  83999. */
  84000. OptimizeWithUV: boolean;
  84001. /**
  84002. * Defines custom scaling of UV coordinates of loaded meshes.
  84003. */
  84004. UVScaling: Vector2;
  84005. /**
  84006. * Invert model on y-axis (does a model scaling inversion)
  84007. */
  84008. InvertY: boolean;
  84009. /**
  84010. * Invert Y-Axis of referenced textures on load
  84011. */
  84012. InvertTextureY: boolean;
  84013. /**
  84014. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  84015. */
  84016. ImportVertexColors: boolean;
  84017. /**
  84018. * Compute the normals for the model, even if normals are present in the file.
  84019. */
  84020. ComputeNormals: boolean;
  84021. /**
  84022. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  84023. */
  84024. SkipMaterials: boolean;
  84025. /**
  84026. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  84027. */
  84028. MaterialLoadingFailsSilently: boolean;
  84029. };
  84030. /**
  84031. * OBJ file type loader.
  84032. * This is a babylon scene loader plugin.
  84033. */
  84034. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  84035. /**
  84036. * Defines if UVs are optimized by default during load.
  84037. */
  84038. static OPTIMIZE_WITH_UV: boolean;
  84039. /**
  84040. * Invert model on y-axis (does a model scaling inversion)
  84041. */
  84042. static INVERT_Y: boolean;
  84043. /**
  84044. * Invert Y-Axis of referenced textures on load
  84045. */
  84046. static get INVERT_TEXTURE_Y(): boolean;
  84047. static set INVERT_TEXTURE_Y(value: boolean);
  84048. /**
  84049. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  84050. */
  84051. static IMPORT_VERTEX_COLORS: boolean;
  84052. /**
  84053. * Compute the normals for the model, even if normals are present in the file.
  84054. */
  84055. static COMPUTE_NORMALS: boolean;
  84056. /**
  84057. * Defines custom scaling of UV coordinates of loaded meshes.
  84058. */
  84059. static UV_SCALING: Vector2;
  84060. /**
  84061. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  84062. */
  84063. static SKIP_MATERIALS: boolean;
  84064. /**
  84065. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  84066. *
  84067. * Defaults to true for backwards compatibility.
  84068. */
  84069. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  84070. /**
  84071. * Defines the name of the plugin.
  84072. */
  84073. name: string;
  84074. /**
  84075. * Defines the extension the plugin is able to load.
  84076. */
  84077. extensions: string;
  84078. /** @hidden */
  84079. obj: RegExp;
  84080. /** @hidden */
  84081. group: RegExp;
  84082. /** @hidden */
  84083. mtllib: RegExp;
  84084. /** @hidden */
  84085. usemtl: RegExp;
  84086. /** @hidden */
  84087. smooth: RegExp;
  84088. /** @hidden */
  84089. vertexPattern: RegExp;
  84090. /** @hidden */
  84091. normalPattern: RegExp;
  84092. /** @hidden */
  84093. uvPattern: RegExp;
  84094. /** @hidden */
  84095. facePattern1: RegExp;
  84096. /** @hidden */
  84097. facePattern2: RegExp;
  84098. /** @hidden */
  84099. facePattern3: RegExp;
  84100. /** @hidden */
  84101. facePattern4: RegExp;
  84102. /** @hidden */
  84103. facePattern5: RegExp;
  84104. private _forAssetContainer;
  84105. private _meshLoadOptions;
  84106. /**
  84107. * Creates loader for .OBJ files
  84108. *
  84109. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  84110. */
  84111. constructor(meshLoadOptions?: MeshLoadOptions);
  84112. private static get currentMeshLoadOptions();
  84113. /**
  84114. * Calls synchronously the MTL file attached to this obj.
  84115. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  84116. * Without this function materials are not displayed in the first frame (but displayed after).
  84117. * In consequence it is impossible to get material information in your HTML file
  84118. *
  84119. * @param url The URL of the MTL file
  84120. * @param rootUrl
  84121. * @param onSuccess Callback function to be called when the MTL file is loaded
  84122. * @private
  84123. */
  84124. private _loadMTL;
  84125. /**
  84126. * Instantiates a OBJ file loader plugin.
  84127. * @returns the created plugin
  84128. */
  84129. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  84130. /**
  84131. * If the data string can be loaded directly.
  84132. *
  84133. * @param data string containing the file data
  84134. * @returns if the data can be loaded directly
  84135. */
  84136. canDirectLoad(data: string): boolean;
  84137. /**
  84138. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  84139. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  84140. * @param scene the scene the meshes should be added to
  84141. * @param data the OBJ data to load
  84142. * @param rootUrl root url to load from
  84143. * @param onProgress event that fires when loading progress has occured
  84144. * @param fileName Defines the name of the file to load
  84145. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  84146. */
  84147. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  84148. meshes: AbstractMesh[];
  84149. particleSystems: IParticleSystem[];
  84150. skeletons: Skeleton[];
  84151. animationGroups: AnimationGroup[];
  84152. }>;
  84153. /**
  84154. * Imports all objects from the loaded OBJ data and adds them to the scene
  84155. * @param scene the scene the objects should be added to
  84156. * @param data the OBJ data to load
  84157. * @param rootUrl root url to load from
  84158. * @param onProgress event that fires when loading progress has occured
  84159. * @param fileName Defines the name of the file to load
  84160. * @returns a promise which completes when objects have been loaded to the scene
  84161. */
  84162. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  84163. /**
  84164. * Load into an asset container.
  84165. * @param scene The scene to load into
  84166. * @param data The data to import
  84167. * @param rootUrl The root url for scene and resources
  84168. * @param onProgress The callback when the load progresses
  84169. * @param fileName Defines the name of the file to load
  84170. * @returns The loaded asset container
  84171. */
  84172. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  84173. /**
  84174. * Read the OBJ file and create an Array of meshes.
  84175. * Each mesh contains all information given by the OBJ and the MTL file.
  84176. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  84177. *
  84178. * @param meshesNames
  84179. * @param scene Scene The scene where are displayed the data
  84180. * @param data String The content of the obj file
  84181. * @param rootUrl String The path to the folder
  84182. * @returns Array<AbstractMesh>
  84183. * @private
  84184. */
  84185. private _parseSolid;
  84186. }
  84187. }
  84188. declare module BABYLON {
  84189. /**
  84190. * STL file type loader.
  84191. * This is a babylon scene loader plugin.
  84192. */
  84193. export class STLFileLoader implements ISceneLoaderPlugin {
  84194. /** @hidden */
  84195. solidPattern: RegExp;
  84196. /** @hidden */
  84197. facetsPattern: RegExp;
  84198. /** @hidden */
  84199. normalPattern: RegExp;
  84200. /** @hidden */
  84201. vertexPattern: RegExp;
  84202. /**
  84203. * Defines the name of the plugin.
  84204. */
  84205. name: string;
  84206. /**
  84207. * Defines the extensions the stl loader is able to load.
  84208. * force data to come in as an ArrayBuffer
  84209. * we'll convert to string if it looks like it's an ASCII .stl
  84210. */
  84211. extensions: ISceneLoaderPluginExtensions;
  84212. /**
  84213. * Import meshes into a scene.
  84214. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  84215. * @param scene The scene to import into
  84216. * @param data The data to import
  84217. * @param rootUrl The root url for scene and resources
  84218. * @param meshes The meshes array to import into
  84219. * @param particleSystems The particle systems array to import into
  84220. * @param skeletons The skeletons array to import into
  84221. * @param onError The callback when import fails
  84222. * @returns True if successful or false otherwise
  84223. */
  84224. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  84225. /**
  84226. * Load into a scene.
  84227. * @param scene The scene to load into
  84228. * @param data The data to import
  84229. * @param rootUrl The root url for scene and resources
  84230. * @param onError The callback when import fails
  84231. * @returns true if successful or false otherwise
  84232. */
  84233. load(scene: Scene, data: any, rootUrl: string): boolean;
  84234. /**
  84235. * Load into an asset container.
  84236. * @param scene The scene to load into
  84237. * @param data The data to import
  84238. * @param rootUrl The root url for scene and resources
  84239. * @param onError The callback when import fails
  84240. * @returns The loaded asset container
  84241. */
  84242. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  84243. private _isBinary;
  84244. private _parseBinary;
  84245. private _parseASCII;
  84246. }
  84247. }
  84248. declare module BABYLON {
  84249. /**
  84250. * Class for generating OBJ data from a Babylon scene.
  84251. */
  84252. export class OBJExport {
  84253. /**
  84254. * Exports the geometry of a Mesh array in .OBJ file format (text)
  84255. * @param mesh defines the list of meshes to serialize
  84256. * @param materials defines if materials should be exported
  84257. * @param matlibname defines the name of the associated mtl file
  84258. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  84259. * @returns the OBJ content
  84260. */
  84261. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  84262. /**
  84263. * Exports the material(s) of a mesh in .MTL file format (text)
  84264. * @param mesh defines the mesh to extract the material from
  84265. * @returns the mtl content
  84266. */
  84267. static MTL(mesh: Mesh): string;
  84268. }
  84269. }
  84270. declare module BABYLON {
  84271. /** @hidden */
  84272. export var __IGLTFExporterExtension: number;
  84273. /**
  84274. * Interface for extending the exporter
  84275. * @hidden
  84276. */
  84277. export interface IGLTFExporterExtension {
  84278. /**
  84279. * The name of this extension
  84280. */
  84281. readonly name: string;
  84282. /**
  84283. * Defines whether this extension is enabled
  84284. */
  84285. enabled: boolean;
  84286. /**
  84287. * Defines whether this extension is required
  84288. */
  84289. required: boolean;
  84290. }
  84291. }
  84292. declare module BABYLON.GLTF2.Exporter {
  84293. /** @hidden */
  84294. export var __IGLTFExporterExtensionV2: number;
  84295. /**
  84296. * Interface for a glTF exporter extension
  84297. * @hidden
  84298. */
  84299. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  84300. /**
  84301. * Define this method to modify the default behavior before exporting a texture
  84302. * @param context The context when loading the asset
  84303. * @param babylonTexture The Babylon.js texture
  84304. * @param mimeType The mime-type of the generated image
  84305. * @returns A promise that resolves with the exported texture
  84306. */
  84307. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  84308. /**
  84309. * Define this method to get notified when a texture info is created
  84310. * @param context The context when loading the asset
  84311. * @param textureInfo The glTF texture info
  84312. * @param babylonTexture The Babylon.js texture
  84313. */
  84314. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  84315. /**
  84316. * Define this method to modify the default behavior when exporting texture info
  84317. * @param context The context when loading the asset
  84318. * @param meshPrimitive glTF mesh primitive
  84319. * @param babylonSubMesh Babylon submesh
  84320. * @param binaryWriter glTF serializer binary writer instance
  84321. * @returns nullable IMeshPrimitive promise
  84322. */
  84323. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  84324. /**
  84325. * Define this method to modify the default behavior when exporting a node
  84326. * @param context The context when exporting the node
  84327. * @param node glTF node
  84328. * @param babylonNode BabylonJS node
  84329. * @returns nullable INode promise
  84330. */
  84331. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  84332. [key: number]: number;
  84333. }): Promise<Nullable<INode>>;
  84334. /**
  84335. * Define this method to modify the default behavior when exporting a material
  84336. * @param material glTF material
  84337. * @param babylonMaterial BabylonJS material
  84338. * @returns nullable IMaterial promise
  84339. */
  84340. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  84341. /**
  84342. * Define this method to return additional textures to export from a material
  84343. * @param material glTF material
  84344. * @param babylonMaterial BabylonJS material
  84345. * @returns List of textures
  84346. */
  84347. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  84348. /** Gets a boolean indicating that this extension was used */
  84349. wasUsed: boolean;
  84350. /** Gets a boolean indicating that this extension is required for the file to work */
  84351. required: boolean;
  84352. /**
  84353. * Called after the exporter state changes to EXPORTING
  84354. */
  84355. onExporting?(): void;
  84356. }
  84357. }
  84358. declare module BABYLON.GLTF2.Exporter {
  84359. /**
  84360. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  84361. * @hidden
  84362. */
  84363. export class _GLTFMaterialExporter {
  84364. /**
  84365. * Represents the dielectric specular values for R, G and B
  84366. */
  84367. private static readonly _DielectricSpecular;
  84368. /**
  84369. * Allows the maximum specular power to be defined for material calculations
  84370. */
  84371. private static readonly _MaxSpecularPower;
  84372. /**
  84373. * Mapping to store textures
  84374. */
  84375. private _textureMap;
  84376. /**
  84377. * Numeric tolerance value
  84378. */
  84379. private static readonly _Epsilon;
  84380. /**
  84381. * Reference to the glTF Exporter
  84382. */
  84383. private _exporter;
  84384. constructor(exporter: _Exporter);
  84385. /**
  84386. * Specifies if two colors are approximately equal in value
  84387. * @param color1 first color to compare to
  84388. * @param color2 second color to compare to
  84389. * @param epsilon threshold value
  84390. */
  84391. private static FuzzyEquals;
  84392. /**
  84393. * Gets the materials from a Babylon scene and converts them to glTF materials
  84394. * @param scene babylonjs scene
  84395. * @param mimeType texture mime type
  84396. * @param images array of images
  84397. * @param textures array of textures
  84398. * @param materials array of materials
  84399. * @param imageData mapping of texture names to base64 textures
  84400. * @param hasTextureCoords specifies if texture coordinates are present on the material
  84401. */
  84402. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  84403. /**
  84404. * Makes a copy of the glTF material without the texture parameters
  84405. * @param originalMaterial original glTF material
  84406. * @returns glTF material without texture parameters
  84407. */
  84408. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  84409. /**
  84410. * Specifies if the material has any texture parameters present
  84411. * @param material glTF Material
  84412. * @returns boolean specifying if texture parameters are present
  84413. */
  84414. _hasTexturesPresent(material: IMaterial): boolean;
  84415. /**
  84416. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  84417. * @param babylonStandardMaterial
  84418. * @returns glTF Metallic Roughness Material representation
  84419. */
  84420. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  84421. /**
  84422. * Computes the metallic factor
  84423. * @param diffuse diffused value
  84424. * @param specular specular value
  84425. * @param oneMinusSpecularStrength one minus the specular strength
  84426. * @returns metallic value
  84427. */
  84428. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  84429. /**
  84430. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  84431. * @param glTFMaterial glTF material
  84432. * @param babylonMaterial Babylon material
  84433. */
  84434. private static _SetAlphaMode;
  84435. /**
  84436. * Converts a Babylon Standard Material to a glTF Material
  84437. * @param babylonStandardMaterial BJS Standard Material
  84438. * @param mimeType mime type to use for the textures
  84439. * @param images array of glTF image interfaces
  84440. * @param textures array of glTF texture interfaces
  84441. * @param materials array of glTF material interfaces
  84442. * @param imageData map of image file name to data
  84443. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84444. */
  84445. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84446. private _finishMaterial;
  84447. /**
  84448. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  84449. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  84450. * @param mimeType mime type to use for the textures
  84451. * @param images array of glTF image interfaces
  84452. * @param textures array of glTF texture interfaces
  84453. * @param materials array of glTF material interfaces
  84454. * @param imageData map of image file name to data
  84455. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84456. */
  84457. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84458. /**
  84459. * Converts an image typed array buffer to a base64 image
  84460. * @param buffer typed array buffer
  84461. * @param width width of the image
  84462. * @param height height of the image
  84463. * @param mimeType mimetype of the image
  84464. * @returns base64 image string
  84465. */
  84466. private _createBase64FromCanvasAsync;
  84467. /**
  84468. * Generates a white texture based on the specified width and height
  84469. * @param width width of the texture in pixels
  84470. * @param height height of the texture in pixels
  84471. * @param scene babylonjs scene
  84472. * @returns white texture
  84473. */
  84474. private _createWhiteTexture;
  84475. /**
  84476. * 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
  84477. * @param texture1 first texture to resize
  84478. * @param texture2 second texture to resize
  84479. * @param scene babylonjs scene
  84480. * @returns resized textures or null
  84481. */
  84482. private _resizeTexturesToSameDimensions;
  84483. /**
  84484. * Converts an array of pixels to a Float32Array
  84485. * Throws an error if the pixel format is not supported
  84486. * @param pixels - array buffer containing pixel values
  84487. * @returns Float32 of pixels
  84488. */
  84489. private _convertPixelArrayToFloat32;
  84490. /**
  84491. * Convert Specular Glossiness Textures to Metallic Roughness
  84492. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  84493. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  84494. * @param diffuseTexture texture used to store diffuse information
  84495. * @param specularGlossinessTexture texture used to store specular and glossiness information
  84496. * @param factors specular glossiness material factors
  84497. * @param mimeType the mime type to use for the texture
  84498. * @returns pbr metallic roughness interface or null
  84499. */
  84500. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  84501. /**
  84502. * Converts specular glossiness material properties to metallic roughness
  84503. * @param specularGlossiness interface with specular glossiness material properties
  84504. * @returns interface with metallic roughness material properties
  84505. */
  84506. private _convertSpecularGlossinessToMetallicRoughness;
  84507. /**
  84508. * Calculates the surface reflectance, independent of lighting conditions
  84509. * @param color Color source to calculate brightness from
  84510. * @returns number representing the perceived brightness, or zero if color is undefined
  84511. */
  84512. private _getPerceivedBrightness;
  84513. /**
  84514. * Returns the maximum color component value
  84515. * @param color
  84516. * @returns maximum color component value, or zero if color is null or undefined
  84517. */
  84518. private _getMaxComponent;
  84519. /**
  84520. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  84521. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84522. * @param mimeType mime type to use for the textures
  84523. * @param images array of glTF image interfaces
  84524. * @param textures array of glTF texture interfaces
  84525. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  84526. * @param imageData map of image file name to data
  84527. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84528. * @returns glTF PBR Metallic Roughness factors
  84529. */
  84530. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  84531. private _getGLTFTextureSampler;
  84532. private _getGLTFTextureWrapMode;
  84533. private _getGLTFTextureWrapModesSampler;
  84534. /**
  84535. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  84536. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84537. * @param mimeType mime type to use for the textures
  84538. * @param images array of glTF image interfaces
  84539. * @param textures array of glTF texture interfaces
  84540. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  84541. * @param imageData map of image file name to data
  84542. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84543. * @returns glTF PBR Metallic Roughness factors
  84544. */
  84545. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  84546. /**
  84547. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  84548. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84549. * @param mimeType mime type to use for the textures
  84550. * @param images array of glTF image interfaces
  84551. * @param textures array of glTF texture interfaces
  84552. * @param materials array of glTF material interfaces
  84553. * @param imageData map of image file name to data
  84554. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84555. */
  84556. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84557. private setMetallicRoughnessPbrMaterial;
  84558. private getPixelsFromTexture;
  84559. /**
  84560. * Extracts a texture from a Babylon texture into file data and glTF data
  84561. * @param babylonTexture Babylon texture to extract
  84562. * @param mimeType Mime Type of the babylonTexture
  84563. * @return glTF texture info, or null if the texture format is not supported
  84564. */
  84565. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  84566. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  84567. /**
  84568. * Builds a texture from base64 string
  84569. * @param base64Texture base64 texture string
  84570. * @param baseTextureName Name to use for the texture
  84571. * @param mimeType image mime type for the texture
  84572. * @param images array of images
  84573. * @param textures array of textures
  84574. * @param imageData map of image data
  84575. * @returns glTF texture info, or null if the texture format is not supported
  84576. */
  84577. private _getTextureInfoFromBase64;
  84578. }
  84579. }
  84580. declare module BABYLON {
  84581. /**
  84582. * Class for holding and downloading glTF file data
  84583. */
  84584. export class GLTFData {
  84585. /**
  84586. * Object which contains the file name as the key and its data as the value
  84587. */
  84588. glTFFiles: {
  84589. [fileName: string]: string | Blob;
  84590. };
  84591. /**
  84592. * Initializes the glTF file object
  84593. */
  84594. constructor();
  84595. /**
  84596. * Downloads the glTF data as files based on their names and data
  84597. */
  84598. downloadFiles(): void;
  84599. }
  84600. }
  84601. declare module BABYLON {
  84602. /**
  84603. * Holds a collection of exporter options and parameters
  84604. */
  84605. export interface IExportOptions {
  84606. /**
  84607. * Function which indicates whether a babylon node should be exported or not
  84608. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  84609. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  84610. */
  84611. shouldExportNode?(node: Node): boolean;
  84612. /**
  84613. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  84614. * @param metadata source metadata to read from
  84615. * @returns the data to store to glTF node extras
  84616. */
  84617. metadataSelector?(metadata: any): any;
  84618. /**
  84619. * The sample rate to bake animation curves
  84620. */
  84621. animationSampleRate?: number;
  84622. /**
  84623. * Begin serialization without waiting for the scene to be ready
  84624. */
  84625. exportWithoutWaitingForScene?: boolean;
  84626. /**
  84627. * Indicates if coordinate system swapping root nodes should be included in export
  84628. */
  84629. includeCoordinateSystemConversionNodes?: boolean;
  84630. }
  84631. /**
  84632. * Class for generating glTF data from a Babylon scene.
  84633. */
  84634. export class GLTF2Export {
  84635. /**
  84636. * Exports the geometry of the scene to .gltf file format asynchronously
  84637. * @param scene Babylon scene with scene hierarchy information
  84638. * @param filePrefix File prefix to use when generating the glTF file
  84639. * @param options Exporter options
  84640. * @returns Returns an object with a .gltf file and associates texture names
  84641. * as keys and their data and paths as values
  84642. */
  84643. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  84644. private static _PreExportAsync;
  84645. private static _PostExportAsync;
  84646. /**
  84647. * Exports the geometry of the scene to .glb file format asychronously
  84648. * @param scene Babylon scene with scene hierarchy information
  84649. * @param filePrefix File prefix to use when generating glb file
  84650. * @param options Exporter options
  84651. * @returns Returns an object with a .glb filename as key and data as value
  84652. */
  84653. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  84654. }
  84655. }
  84656. declare module BABYLON.GLTF2.Exporter {
  84657. /**
  84658. * @hidden
  84659. */
  84660. export class _GLTFUtilities {
  84661. /**
  84662. * Creates a buffer view based on the supplied arguments
  84663. * @param bufferIndex index value of the specified buffer
  84664. * @param byteOffset byte offset value
  84665. * @param byteLength byte length of the bufferView
  84666. * @param byteStride byte distance between conequential elements
  84667. * @param name name of the buffer view
  84668. * @returns bufferView for glTF
  84669. */
  84670. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  84671. /**
  84672. * Creates an accessor based on the supplied arguments
  84673. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  84674. * @param name The name of the accessor
  84675. * @param type The type of the accessor
  84676. * @param componentType The datatype of components in the attribute
  84677. * @param count The number of attributes referenced by this accessor
  84678. * @param byteOffset The offset relative to the start of the bufferView in bytes
  84679. * @param min Minimum value of each component in this attribute
  84680. * @param max Maximum value of each component in this attribute
  84681. * @returns accessor for glTF
  84682. */
  84683. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  84684. /**
  84685. * Calculates the minimum and maximum values of an array of position floats
  84686. * @param positions Positions array of a mesh
  84687. * @param vertexStart Starting vertex offset to calculate min and max values
  84688. * @param vertexCount Number of vertices to check for min and max values
  84689. * @returns min number array and max number array
  84690. */
  84691. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  84692. min: number[];
  84693. max: number[];
  84694. };
  84695. /**
  84696. * Converts a new right-handed Vector3
  84697. * @param vector vector3 array
  84698. * @returns right-handed Vector3
  84699. */
  84700. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  84701. /**
  84702. * Converts a Vector3 to right-handed
  84703. * @param vector Vector3 to convert to right-handed
  84704. */
  84705. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  84706. /**
  84707. * Converts a three element number array to right-handed
  84708. * @param vector number array to convert to right-handed
  84709. */
  84710. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  84711. /**
  84712. * Converts a new right-handed Vector3
  84713. * @param vector vector3 array
  84714. * @returns right-handed Vector3
  84715. */
  84716. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  84717. /**
  84718. * Converts a Vector3 to right-handed
  84719. * @param vector Vector3 to convert to right-handed
  84720. */
  84721. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  84722. /**
  84723. * Converts a three element number array to right-handed
  84724. * @param vector number array to convert to right-handed
  84725. */
  84726. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  84727. /**
  84728. * Converts a Vector4 to right-handed
  84729. * @param vector Vector4 to convert to right-handed
  84730. */
  84731. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  84732. /**
  84733. * Converts a Vector4 to right-handed
  84734. * @param vector Vector4 to convert to right-handed
  84735. */
  84736. static _GetRightHandedArray4FromRef(vector: number[]): void;
  84737. /**
  84738. * Converts a Quaternion to right-handed
  84739. * @param quaternion Source quaternion to convert to right-handed
  84740. */
  84741. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  84742. /**
  84743. * Converts a Quaternion to right-handed
  84744. * @param quaternion Source quaternion to convert to right-handed
  84745. */
  84746. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  84747. static _NormalizeTangentFromRef(tangent: Vector4): void;
  84748. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  84749. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  84750. }
  84751. }
  84752. declare module BABYLON.GLTF2.Exporter {
  84753. /**
  84754. * Converts Babylon Scene into glTF 2.0.
  84755. * @hidden
  84756. */
  84757. export class _Exporter {
  84758. /**
  84759. * Stores the glTF to export
  84760. */
  84761. _glTF: IGLTF;
  84762. /**
  84763. * Stores all generated buffer views, which represents views into the main glTF buffer data
  84764. */
  84765. _bufferViews: IBufferView[];
  84766. /**
  84767. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  84768. */
  84769. _accessors: IAccessor[];
  84770. /**
  84771. * Stores all the generated nodes, which contains transform and/or mesh information per node
  84772. */
  84773. _nodes: INode[];
  84774. /**
  84775. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  84776. */
  84777. private _scenes;
  84778. /**
  84779. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  84780. */
  84781. private _meshes;
  84782. /**
  84783. * Stores all the generated material information, which represents the appearance of each primitive
  84784. */
  84785. _materials: IMaterial[];
  84786. _materialMap: {
  84787. [materialID: number]: number;
  84788. };
  84789. /**
  84790. * Stores all the generated texture information, which is referenced by glTF materials
  84791. */
  84792. _textures: ITexture[];
  84793. /**
  84794. * Stores all the generated image information, which is referenced by glTF textures
  84795. */
  84796. _images: IImage[];
  84797. /**
  84798. * Stores all the texture samplers
  84799. */
  84800. _samplers: ISampler[];
  84801. /**
  84802. * Stores all the generated glTF skins
  84803. */
  84804. _skins: ISkin[];
  84805. /**
  84806. * Stores all the generated animation samplers, which is referenced by glTF animations
  84807. */
  84808. /**
  84809. * Stores the animations for glTF models
  84810. */
  84811. private _animations;
  84812. /**
  84813. * Stores the total amount of bytes stored in the glTF buffer
  84814. */
  84815. private _totalByteLength;
  84816. /**
  84817. * Stores a reference to the Babylon scene containing the source geometry and material information
  84818. */
  84819. _babylonScene: Scene;
  84820. /**
  84821. * Stores a map of the image data, where the key is the file name and the value
  84822. * is the image data
  84823. */
  84824. _imageData: {
  84825. [fileName: string]: {
  84826. data: Uint8Array;
  84827. mimeType: ImageMimeType;
  84828. };
  84829. };
  84830. protected _orderedImageData: Array<{
  84831. data: Uint8Array;
  84832. mimeType: ImageMimeType;
  84833. }>;
  84834. /**
  84835. * Stores a map of the unique id of a node to its index in the node array
  84836. */
  84837. _nodeMap: {
  84838. [key: number]: number;
  84839. };
  84840. /**
  84841. * Specifies if the source Babylon scene was left handed, and needed conversion.
  84842. */
  84843. _convertToRightHandedSystem: boolean;
  84844. /**
  84845. * Specifies if a Babylon node should be converted to right-handed on export
  84846. */
  84847. _convertToRightHandedSystemMap: {
  84848. [nodeId: number]: boolean;
  84849. };
  84850. _includeCoordinateSystemConversionNodes: boolean;
  84851. /**
  84852. * Baked animation sample rate
  84853. */
  84854. private _animationSampleRate;
  84855. private _options;
  84856. private _localEngine;
  84857. _glTFMaterialExporter: _GLTFMaterialExporter;
  84858. private _extensions;
  84859. private static _ExtensionNames;
  84860. private static _ExtensionFactories;
  84861. private _applyExtension;
  84862. private _applyExtensions;
  84863. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  84864. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  84865. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  84866. [key: number]: number;
  84867. }): Promise<Nullable<INode>>;
  84868. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  84869. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  84870. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  84871. private _forEachExtensions;
  84872. private _extensionsOnExporting;
  84873. /**
  84874. * Load glTF serializer extensions
  84875. */
  84876. private _loadExtensions;
  84877. /**
  84878. * Creates a glTF Exporter instance, which can accept optional exporter options
  84879. * @param babylonScene Babylon scene object
  84880. * @param options Options to modify the behavior of the exporter
  84881. */
  84882. constructor(babylonScene: Scene, options?: IExportOptions);
  84883. dispose(): void;
  84884. /**
  84885. * Registers a glTF exporter extension
  84886. * @param name Name of the extension to export
  84887. * @param factory The factory function that creates the exporter extension
  84888. */
  84889. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  84890. /**
  84891. * Un-registers an exporter extension
  84892. * @param name The name fo the exporter extension
  84893. * @returns A boolean indicating whether the extension has been un-registered
  84894. */
  84895. static UnregisterExtension(name: string): boolean;
  84896. /**
  84897. * Lazy load a local engine
  84898. */
  84899. _getLocalEngine(): Engine;
  84900. private reorderIndicesBasedOnPrimitiveMode;
  84901. /**
  84902. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  84903. * clock-wise during export to glTF
  84904. * @param submesh BabylonJS submesh
  84905. * @param primitiveMode Primitive mode of the mesh
  84906. * @param sideOrientation the winding order of the submesh
  84907. * @param vertexBufferKind The type of vertex attribute
  84908. * @param meshAttributeArray The vertex attribute data
  84909. * @param byteOffset The offset to the binary data
  84910. * @param binaryWriter The binary data for the glTF file
  84911. * @param convertToRightHandedSystem Converts the values to right-handed
  84912. */
  84913. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  84914. /**
  84915. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  84916. * clock-wise during export to glTF
  84917. * @param submesh BabylonJS submesh
  84918. * @param primitiveMode Primitive mode of the mesh
  84919. * @param sideOrientation the winding order of the submesh
  84920. * @param vertexBufferKind The type of vertex attribute
  84921. * @param meshAttributeArray The vertex attribute data
  84922. * @param byteOffset The offset to the binary data
  84923. * @param binaryWriter The binary data for the glTF file
  84924. * @param convertToRightHandedSystem Converts the values to right-handed
  84925. */
  84926. private reorderTriangleFillMode;
  84927. /**
  84928. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  84929. * clock-wise during export to glTF
  84930. * @param submesh BabylonJS submesh
  84931. * @param primitiveMode Primitive mode of the mesh
  84932. * @param sideOrientation the winding order of the submesh
  84933. * @param vertexBufferKind The type of vertex attribute
  84934. * @param meshAttributeArray The vertex attribute data
  84935. * @param byteOffset The offset to the binary data
  84936. * @param binaryWriter The binary data for the glTF file
  84937. * @param convertToRightHandedSystem Converts the values to right-handed
  84938. */
  84939. private reorderTriangleStripDrawMode;
  84940. /**
  84941. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  84942. * clock-wise during export to glTF
  84943. * @param submesh BabylonJS submesh
  84944. * @param primitiveMode Primitive mode of the mesh
  84945. * @param sideOrientation the winding order of the submesh
  84946. * @param vertexBufferKind The type of vertex attribute
  84947. * @param meshAttributeArray The vertex attribute data
  84948. * @param byteOffset The offset to the binary data
  84949. * @param binaryWriter The binary data for the glTF file
  84950. * @param convertToRightHandedSystem Converts the values to right-handed
  84951. */
  84952. private reorderTriangleFanMode;
  84953. /**
  84954. * Writes the vertex attribute data to binary
  84955. * @param vertices The vertices to write to the binary writer
  84956. * @param byteOffset The offset into the binary writer to overwrite binary data
  84957. * @param vertexAttributeKind The vertex attribute type
  84958. * @param meshAttributeArray The vertex attribute data
  84959. * @param binaryWriter The writer containing the binary data
  84960. * @param convertToRightHandedSystem Converts the values to right-handed
  84961. */
  84962. private writeVertexAttributeData;
  84963. /**
  84964. * Writes mesh attribute data to a data buffer
  84965. * Returns the bytelength of the data
  84966. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  84967. * @param meshAttributeArray Array containing the attribute data
  84968. * @param byteStride Specifies the space between data
  84969. * @param binaryWriter The buffer to write the binary data to
  84970. * @param convertToRightHandedSystem Converts the values to right-handed
  84971. */
  84972. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  84973. /**
  84974. * Writes mesh attribute data to a data buffer
  84975. * Returns the bytelength of the data
  84976. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  84977. * @param meshAttributeArray Array containing the attribute data
  84978. * @param byteStride Specifies the space between data
  84979. * @param binaryWriter The buffer to write the binary data to
  84980. * @param convertToRightHandedSystem Converts the values to right-handed
  84981. */
  84982. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  84983. /**
  84984. * Generates glTF json data
  84985. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  84986. * @param glTFPrefix Text to use when prefixing a glTF file
  84987. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  84988. * @returns json data as string
  84989. */
  84990. private generateJSON;
  84991. /**
  84992. * Generates data for .gltf and .bin files based on the glTF prefix string
  84993. * @param glTFPrefix Text to use when prefixing a glTF file
  84994. * @param dispose Dispose the exporter
  84995. * @returns GLTFData with glTF file data
  84996. */
  84997. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  84998. /**
  84999. * Creates a binary buffer for glTF
  85000. * @returns array buffer for binary data
  85001. */
  85002. private _generateBinaryAsync;
  85003. /**
  85004. * Pads the number to a multiple of 4
  85005. * @param num number to pad
  85006. * @returns padded number
  85007. */
  85008. private _getPadding;
  85009. /**
  85010. * @hidden
  85011. */
  85012. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  85013. /**
  85014. * Sets the TRS for each node
  85015. * @param node glTF Node for storing the transformation data
  85016. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  85017. * @param convertToRightHandedSystem Converts the values to right-handed
  85018. */
  85019. private setNodeTransformation;
  85020. private getVertexBufferFromMesh;
  85021. /**
  85022. * Creates a bufferview based on the vertices type for the Babylon mesh
  85023. * @param kind Indicates the type of vertices data
  85024. * @param componentType Indicates the numerical type used to store the data
  85025. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  85026. * @param binaryWriter The buffer to write the bufferview data to
  85027. * @param convertToRightHandedSystem Converts the values to right-handed
  85028. */
  85029. private createBufferViewKind;
  85030. /**
  85031. * Creates a bufferview based on the vertices type for the Babylon mesh
  85032. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  85033. * @param babylonMorphTarget the morph target to be exported
  85034. * @param binaryWriter The buffer to write the bufferview data to
  85035. * @param convertToRightHandedSystem Converts the values to right-handed
  85036. */
  85037. private setMorphTargetAttributes;
  85038. /**
  85039. * The primitive mode of the Babylon mesh
  85040. * @param babylonMesh The BabylonJS mesh
  85041. */
  85042. private getMeshPrimitiveMode;
  85043. /**
  85044. * Sets the primitive mode of the glTF mesh primitive
  85045. * @param meshPrimitive glTF mesh primitive
  85046. * @param primitiveMode The primitive mode
  85047. */
  85048. private setPrimitiveMode;
  85049. /**
  85050. * Sets the vertex attribute accessor based of the glTF mesh primitive
  85051. * @param meshPrimitive glTF mesh primitive
  85052. * @param attributeKind vertex attribute
  85053. * @returns boolean specifying if uv coordinates are present
  85054. */
  85055. private setAttributeKind;
  85056. /**
  85057. * Sets data for the primitive attributes of each submesh
  85058. * @param mesh glTF Mesh object to store the primitive attribute information
  85059. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  85060. * @param binaryWriter Buffer to write the attribute data to
  85061. * @param convertToRightHandedSystem Converts the values to right-handed
  85062. */
  85063. private setPrimitiveAttributesAsync;
  85064. /**
  85065. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  85066. * @param node The node to check
  85067. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  85068. */
  85069. private isBabylonCoordinateSystemConvertingNode;
  85070. /**
  85071. * Creates a glTF scene based on the array of meshes
  85072. * Returns the the total byte offset
  85073. * @param babylonScene Babylon scene to get the mesh data from
  85074. * @param binaryWriter Buffer to write binary data to
  85075. */
  85076. private createSceneAsync;
  85077. /**
  85078. * Creates a mapping of Node unique id to node index and handles animations
  85079. * @param babylonScene Babylon Scene
  85080. * @param nodes Babylon transform nodes
  85081. * @param binaryWriter Buffer to write binary data to
  85082. * @returns Node mapping of unique id to index
  85083. */
  85084. private createNodeMapAndAnimationsAsync;
  85085. /**
  85086. * Creates a glTF node from a Babylon mesh
  85087. * @param babylonMesh Source Babylon mesh
  85088. * @param binaryWriter Buffer for storing geometry data
  85089. * @param convertToRightHandedSystem Converts the values to right-handed
  85090. * @param nodeMap Node mapping of unique id to glTF node index
  85091. * @returns glTF node
  85092. */
  85093. private createNodeAsync;
  85094. /**
  85095. * Creates a glTF skin from a Babylon skeleton
  85096. * @param babylonScene Babylon Scene
  85097. * @param nodes Babylon transform nodes
  85098. * @param binaryWriter Buffer to write binary data to
  85099. * @returns Node mapping of unique id to index
  85100. */
  85101. private createSkinsAsync;
  85102. }
  85103. /**
  85104. * @hidden
  85105. *
  85106. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  85107. */
  85108. export class _BinaryWriter {
  85109. /**
  85110. * Array buffer which stores all binary data
  85111. */
  85112. private _arrayBuffer;
  85113. /**
  85114. * View of the array buffer
  85115. */
  85116. private _dataView;
  85117. /**
  85118. * byte offset of data in array buffer
  85119. */
  85120. private _byteOffset;
  85121. /**
  85122. * Initialize binary writer with an initial byte length
  85123. * @param byteLength Initial byte length of the array buffer
  85124. */
  85125. constructor(byteLength: number);
  85126. /**
  85127. * Resize the array buffer to the specified byte length
  85128. * @param byteLength
  85129. */
  85130. private resizeBuffer;
  85131. /**
  85132. * Get an array buffer with the length of the byte offset
  85133. * @returns ArrayBuffer resized to the byte offset
  85134. */
  85135. getArrayBuffer(): ArrayBuffer;
  85136. /**
  85137. * Get the byte offset of the array buffer
  85138. * @returns byte offset
  85139. */
  85140. getByteOffset(): number;
  85141. /**
  85142. * Stores an UInt8 in the array buffer
  85143. * @param entry
  85144. * @param byteOffset If defined, specifies where to set the value as an offset.
  85145. */
  85146. setUInt8(entry: number, byteOffset?: number): void;
  85147. /**
  85148. * Stores an UInt16 in the array buffer
  85149. * @param entry
  85150. * @param byteOffset If defined, specifies where to set the value as an offset.
  85151. */
  85152. setUInt16(entry: number, byteOffset?: number): void;
  85153. /**
  85154. * Gets an UInt32 in the array buffer
  85155. * @param entry
  85156. * @param byteOffset If defined, specifies where to set the value as an offset.
  85157. */
  85158. getUInt32(byteOffset: number): number;
  85159. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  85160. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  85161. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  85162. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  85163. /**
  85164. * Stores a Float32 in the array buffer
  85165. * @param entry
  85166. */
  85167. setFloat32(entry: number, byteOffset?: number): void;
  85168. /**
  85169. * Stores an UInt32 in the array buffer
  85170. * @param entry
  85171. * @param byteOffset If defined, specifies where to set the value as an offset.
  85172. */
  85173. setUInt32(entry: number, byteOffset?: number): void;
  85174. }
  85175. }
  85176. declare module BABYLON.GLTF2.Exporter {
  85177. /**
  85178. * @hidden
  85179. * Interface to store animation data.
  85180. */
  85181. export interface _IAnimationData {
  85182. /**
  85183. * Keyframe data.
  85184. */
  85185. inputs: number[];
  85186. /**
  85187. * Value data.
  85188. */
  85189. outputs: number[][];
  85190. /**
  85191. * Animation interpolation data.
  85192. */
  85193. samplerInterpolation: AnimationSamplerInterpolation;
  85194. /**
  85195. * Minimum keyframe value.
  85196. */
  85197. inputsMin: number;
  85198. /**
  85199. * Maximum keyframe value.
  85200. */
  85201. inputsMax: number;
  85202. }
  85203. /**
  85204. * @hidden
  85205. */
  85206. export interface _IAnimationInfo {
  85207. /**
  85208. * The target channel for the animation
  85209. */
  85210. animationChannelTargetPath: AnimationChannelTargetPath;
  85211. /**
  85212. * The glTF accessor type for the data.
  85213. */
  85214. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  85215. /**
  85216. * Specifies if quaternions should be used.
  85217. */
  85218. useQuaternion: boolean;
  85219. }
  85220. /**
  85221. * @hidden
  85222. * Utility class for generating glTF animation data from BabylonJS.
  85223. */
  85224. export class _GLTFAnimation {
  85225. /**
  85226. * @ignore
  85227. *
  85228. * Creates glTF channel animation from BabylonJS animation.
  85229. * @param babylonTransformNode - BabylonJS mesh.
  85230. * @param animation - animation.
  85231. * @param animationChannelTargetPath - The target animation channel.
  85232. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  85233. * @param useQuaternion - Specifies if quaternions are used.
  85234. * @returns nullable IAnimationData
  85235. */
  85236. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  85237. private static _DeduceAnimationInfo;
  85238. /**
  85239. * @ignore
  85240. * Create node animations from the transform node animations
  85241. * @param babylonNode
  85242. * @param runtimeGLTFAnimation
  85243. * @param idleGLTFAnimations
  85244. * @param nodeMap
  85245. * @param nodes
  85246. * @param binaryWriter
  85247. * @param bufferViews
  85248. * @param accessors
  85249. * @param convertToRightHandedSystem
  85250. * @param animationSampleRate
  85251. */
  85252. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  85253. [key: number]: number;
  85254. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  85255. /**
  85256. * @ignore
  85257. * Create individual morph animations from the mesh's morph target animation tracks
  85258. * @param babylonNode
  85259. * @param runtimeGLTFAnimation
  85260. * @param idleGLTFAnimations
  85261. * @param nodeMap
  85262. * @param nodes
  85263. * @param binaryWriter
  85264. * @param bufferViews
  85265. * @param accessors
  85266. * @param convertToRightHandedSystem
  85267. * @param animationSampleRate
  85268. */
  85269. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  85270. [key: number]: number;
  85271. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  85272. /**
  85273. * @ignore
  85274. * Create node and morph animations from the animation groups
  85275. * @param babylonScene
  85276. * @param glTFAnimations
  85277. * @param nodeMap
  85278. * @param nodes
  85279. * @param binaryWriter
  85280. * @param bufferViews
  85281. * @param accessors
  85282. * @param convertToRightHandedSystemMap
  85283. * @param animationSampleRate
  85284. */
  85285. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  85286. [key: number]: number;
  85287. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  85288. [nodeId: number]: boolean;
  85289. }, animationSampleRate: number): void;
  85290. private static AddAnimation;
  85291. /**
  85292. * Create a baked animation
  85293. * @param babylonTransformNode BabylonJS mesh
  85294. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  85295. * @param animationChannelTargetPath animation target channel
  85296. * @param minFrame minimum animation frame
  85297. * @param maxFrame maximum animation frame
  85298. * @param fps frames per second of the animation
  85299. * @param inputs input key frames of the animation
  85300. * @param outputs output key frame data of the animation
  85301. * @param convertToRightHandedSystem converts the values to right-handed
  85302. * @param useQuaternion specifies if quaternions should be used
  85303. */
  85304. private static _CreateBakedAnimation;
  85305. private static _ConvertFactorToVector3OrQuaternion;
  85306. private static _SetInterpolatedValue;
  85307. /**
  85308. * Creates linear animation from the animation key frames
  85309. * @param babylonTransformNode BabylonJS mesh
  85310. * @param animation BabylonJS animation
  85311. * @param animationChannelTargetPath The target animation channel
  85312. * @param frameDelta The difference between the last and first frame of the animation
  85313. * @param inputs Array to store the key frame times
  85314. * @param outputs Array to store the key frame data
  85315. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  85316. * @param useQuaternion Specifies if quaternions are used in the animation
  85317. */
  85318. private static _CreateLinearOrStepAnimation;
  85319. /**
  85320. * Creates cubic spline animation from the animation key frames
  85321. * @param babylonTransformNode BabylonJS mesh
  85322. * @param animation BabylonJS animation
  85323. * @param animationChannelTargetPath The target animation channel
  85324. * @param frameDelta The difference between the last and first frame of the animation
  85325. * @param inputs Array to store the key frame times
  85326. * @param outputs Array to store the key frame data
  85327. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  85328. * @param useQuaternion Specifies if quaternions are used in the animation
  85329. */
  85330. private static _CreateCubicSplineAnimation;
  85331. private static _GetBasePositionRotationOrScale;
  85332. /**
  85333. * Adds a key frame value
  85334. * @param keyFrame
  85335. * @param animation
  85336. * @param outputs
  85337. * @param animationChannelTargetPath
  85338. * @param basePositionRotationOrScale
  85339. * @param convertToRightHandedSystem
  85340. * @param useQuaternion
  85341. */
  85342. private static _AddKeyframeValue;
  85343. /**
  85344. * Determine the interpolation based on the key frames
  85345. * @param keyFrames
  85346. * @param animationChannelTargetPath
  85347. * @param useQuaternion
  85348. */
  85349. private static _DeduceInterpolation;
  85350. /**
  85351. * Adds an input tangent or output tangent to the output data
  85352. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  85353. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  85354. * @param outputs The animation data by keyframe
  85355. * @param animationChannelTargetPath The target animation channel
  85356. * @param interpolation The interpolation type
  85357. * @param keyFrame The key frame with the animation data
  85358. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  85359. * @param useQuaternion Specifies if quaternions are used
  85360. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  85361. */
  85362. private static AddSplineTangent;
  85363. /**
  85364. * Get the minimum and maximum key frames' frame values
  85365. * @param keyFrames animation key frames
  85366. * @returns the minimum and maximum key frame value
  85367. */
  85368. private static calculateMinMaxKeyFrames;
  85369. }
  85370. }
  85371. declare module BABYLON.GLTF2.Exporter {
  85372. /** @hidden */
  85373. export var textureTransformPixelShader: {
  85374. name: string;
  85375. shader: string;
  85376. };
  85377. }
  85378. declare module BABYLON.GLTF2.Exporter.Extensions {
  85379. /**
  85380. * @hidden
  85381. */
  85382. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  85383. private _recordedTextures;
  85384. /** Name of this extension */
  85385. readonly name: string;
  85386. /** Defines whether this extension is enabled */
  85387. enabled: boolean;
  85388. /** Defines whether this extension is required */
  85389. required: boolean;
  85390. /** Reference to the glTF exporter */
  85391. private _wasUsed;
  85392. constructor(exporter: _Exporter);
  85393. dispose(): void;
  85394. /** @hidden */
  85395. get wasUsed(): boolean;
  85396. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  85397. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  85398. /**
  85399. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  85400. * @param babylonTexture
  85401. * @param offset
  85402. * @param rotation
  85403. * @param scale
  85404. * @param scene
  85405. */
  85406. private _textureTransformTextureAsync;
  85407. }
  85408. }
  85409. declare module BABYLON.GLTF2.Exporter.Extensions {
  85410. /**
  85411. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  85412. */
  85413. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  85414. /** The name of this extension. */
  85415. readonly name: string;
  85416. /** Defines whether this extension is enabled. */
  85417. enabled: boolean;
  85418. /** Defines whether this extension is required */
  85419. required: boolean;
  85420. /** Reference to the glTF exporter */
  85421. private _exporter;
  85422. private _lights;
  85423. /** @hidden */
  85424. constructor(exporter: _Exporter);
  85425. /** @hidden */
  85426. dispose(): void;
  85427. /** @hidden */
  85428. get wasUsed(): boolean;
  85429. /** @hidden */
  85430. onExporting(): void;
  85431. /**
  85432. * Define this method to modify the default behavior when exporting a node
  85433. * @param context The context when exporting the node
  85434. * @param node glTF node
  85435. * @param babylonNode BabylonJS node
  85436. * @param nodeMap Node mapping of unique id to glTF node index
  85437. * @returns nullable INode promise
  85438. */
  85439. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  85440. [key: number]: number;
  85441. }): Promise<Nullable<INode>>;
  85442. }
  85443. }
  85444. declare module BABYLON.GLTF2.Exporter.Extensions {
  85445. /**
  85446. * @hidden
  85447. */
  85448. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  85449. /** Name of this extension */
  85450. readonly name: string;
  85451. /** Defines whether this extension is enabled */
  85452. enabled: boolean;
  85453. /** Defines whether this extension is required */
  85454. required: boolean;
  85455. /** Reference to the glTF exporter */
  85456. private _textureInfos;
  85457. private _exportedTextures;
  85458. private _wasUsed;
  85459. constructor(exporter: _Exporter);
  85460. dispose(): void;
  85461. /** @hidden */
  85462. get wasUsed(): boolean;
  85463. private _getTextureIndex;
  85464. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  85465. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  85466. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  85467. }
  85468. }
  85469. declare module BABYLON.GLTF2.Exporter.Extensions {
  85470. /**
  85471. * @hidden
  85472. */
  85473. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  85474. /** Name of this extension */
  85475. readonly name: string;
  85476. /** Defines whether this extension is enabled */
  85477. enabled: boolean;
  85478. /** Defines whether this extension is required */
  85479. required: boolean;
  85480. private _wasUsed;
  85481. constructor(exporter: _Exporter);
  85482. /** @hidden */
  85483. get wasUsed(): boolean;
  85484. dispose(): void;
  85485. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  85486. }
  85487. }
  85488. declare module BABYLON {
  85489. /**
  85490. * Class for generating STL data from a Babylon scene.
  85491. */
  85492. export class STLExport {
  85493. /**
  85494. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  85495. * @param meshes list defines the mesh to serialize
  85496. * @param download triggers the automatic download of the file.
  85497. * @param fileName changes the downloads fileName.
  85498. * @param binary changes the STL to a binary type.
  85499. * @param isLittleEndian toggle for binary type exporter.
  85500. * @returns the STL as UTF8 string
  85501. */
  85502. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  85503. }
  85504. }
  85505. declare module "babylonjs-gltf2interface" {
  85506. export = BABYLON.GLTF2;
  85507. }
  85508. /**
  85509. * Module for glTF 2.0 Interface
  85510. */
  85511. declare module BABYLON.GLTF2 {
  85512. /**
  85513. * The datatype of the components in the attribute
  85514. */
  85515. const enum AccessorComponentType {
  85516. /**
  85517. * Byte
  85518. */
  85519. BYTE = 5120,
  85520. /**
  85521. * Unsigned Byte
  85522. */
  85523. UNSIGNED_BYTE = 5121,
  85524. /**
  85525. * Short
  85526. */
  85527. SHORT = 5122,
  85528. /**
  85529. * Unsigned Short
  85530. */
  85531. UNSIGNED_SHORT = 5123,
  85532. /**
  85533. * Unsigned Int
  85534. */
  85535. UNSIGNED_INT = 5125,
  85536. /**
  85537. * Float
  85538. */
  85539. FLOAT = 5126,
  85540. }
  85541. /**
  85542. * Specifies if the attirbute is a scalar, vector, or matrix
  85543. */
  85544. const enum AccessorType {
  85545. /**
  85546. * Scalar
  85547. */
  85548. SCALAR = "SCALAR",
  85549. /**
  85550. * Vector2
  85551. */
  85552. VEC2 = "VEC2",
  85553. /**
  85554. * Vector3
  85555. */
  85556. VEC3 = "VEC3",
  85557. /**
  85558. * Vector4
  85559. */
  85560. VEC4 = "VEC4",
  85561. /**
  85562. * Matrix2x2
  85563. */
  85564. MAT2 = "MAT2",
  85565. /**
  85566. * Matrix3x3
  85567. */
  85568. MAT3 = "MAT3",
  85569. /**
  85570. * Matrix4x4
  85571. */
  85572. MAT4 = "MAT4",
  85573. }
  85574. /**
  85575. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  85576. */
  85577. const enum AnimationChannelTargetPath {
  85578. /**
  85579. * Translation
  85580. */
  85581. TRANSLATION = "translation",
  85582. /**
  85583. * Rotation
  85584. */
  85585. ROTATION = "rotation",
  85586. /**
  85587. * Scale
  85588. */
  85589. SCALE = "scale",
  85590. /**
  85591. * Weights
  85592. */
  85593. WEIGHTS = "weights",
  85594. }
  85595. /**
  85596. * Interpolation algorithm
  85597. */
  85598. const enum AnimationSamplerInterpolation {
  85599. /**
  85600. * The animated values are linearly interpolated between keyframes
  85601. */
  85602. LINEAR = "LINEAR",
  85603. /**
  85604. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  85605. */
  85606. STEP = "STEP",
  85607. /**
  85608. * The animation's interpolation is computed using a cubic spline with specified tangents
  85609. */
  85610. CUBICSPLINE = "CUBICSPLINE",
  85611. }
  85612. /**
  85613. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  85614. */
  85615. const enum CameraType {
  85616. /**
  85617. * A perspective camera containing properties to create a perspective projection matrix
  85618. */
  85619. PERSPECTIVE = "perspective",
  85620. /**
  85621. * An orthographic camera containing properties to create an orthographic projection matrix
  85622. */
  85623. ORTHOGRAPHIC = "orthographic",
  85624. }
  85625. /**
  85626. * The mime-type of the image
  85627. */
  85628. const enum ImageMimeType {
  85629. /**
  85630. * JPEG Mime-type
  85631. */
  85632. JPEG = "image/jpeg",
  85633. /**
  85634. * PNG Mime-type
  85635. */
  85636. PNG = "image/png",
  85637. }
  85638. /**
  85639. * The alpha rendering mode of the material
  85640. */
  85641. const enum MaterialAlphaMode {
  85642. /**
  85643. * The alpha value is ignored and the rendered output is fully opaque
  85644. */
  85645. OPAQUE = "OPAQUE",
  85646. /**
  85647. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  85648. */
  85649. MASK = "MASK",
  85650. /**
  85651. * 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)
  85652. */
  85653. BLEND = "BLEND",
  85654. }
  85655. /**
  85656. * The type of the primitives to render
  85657. */
  85658. const enum MeshPrimitiveMode {
  85659. /**
  85660. * Points
  85661. */
  85662. POINTS = 0,
  85663. /**
  85664. * Lines
  85665. */
  85666. LINES = 1,
  85667. /**
  85668. * Line Loop
  85669. */
  85670. LINE_LOOP = 2,
  85671. /**
  85672. * Line Strip
  85673. */
  85674. LINE_STRIP = 3,
  85675. /**
  85676. * Triangles
  85677. */
  85678. TRIANGLES = 4,
  85679. /**
  85680. * Triangle Strip
  85681. */
  85682. TRIANGLE_STRIP = 5,
  85683. /**
  85684. * Triangle Fan
  85685. */
  85686. TRIANGLE_FAN = 6,
  85687. }
  85688. /**
  85689. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  85690. */
  85691. const enum TextureMagFilter {
  85692. /**
  85693. * Nearest
  85694. */
  85695. NEAREST = 9728,
  85696. /**
  85697. * Linear
  85698. */
  85699. LINEAR = 9729,
  85700. }
  85701. /**
  85702. * Minification filter. All valid values correspond to WebGL enums
  85703. */
  85704. const enum TextureMinFilter {
  85705. /**
  85706. * Nearest
  85707. */
  85708. NEAREST = 9728,
  85709. /**
  85710. * Linear
  85711. */
  85712. LINEAR = 9729,
  85713. /**
  85714. * Nearest Mip-Map Nearest
  85715. */
  85716. NEAREST_MIPMAP_NEAREST = 9984,
  85717. /**
  85718. * Linear Mipmap Nearest
  85719. */
  85720. LINEAR_MIPMAP_NEAREST = 9985,
  85721. /**
  85722. * Nearest Mipmap Linear
  85723. */
  85724. NEAREST_MIPMAP_LINEAR = 9986,
  85725. /**
  85726. * Linear Mipmap Linear
  85727. */
  85728. LINEAR_MIPMAP_LINEAR = 9987,
  85729. }
  85730. /**
  85731. * S (U) wrapping mode. All valid values correspond to WebGL enums
  85732. */
  85733. const enum TextureWrapMode {
  85734. /**
  85735. * Clamp to Edge
  85736. */
  85737. CLAMP_TO_EDGE = 33071,
  85738. /**
  85739. * Mirrored Repeat
  85740. */
  85741. MIRRORED_REPEAT = 33648,
  85742. /**
  85743. * Repeat
  85744. */
  85745. REPEAT = 10497,
  85746. }
  85747. /**
  85748. * glTF Property
  85749. */
  85750. interface IProperty {
  85751. /**
  85752. * Dictionary object with extension-specific objects
  85753. */
  85754. extensions?: {
  85755. [key: string]: any;
  85756. };
  85757. /**
  85758. * Application-Specific data
  85759. */
  85760. extras?: any;
  85761. }
  85762. /**
  85763. * glTF Child of Root Property
  85764. */
  85765. interface IChildRootProperty extends IProperty {
  85766. /**
  85767. * The user-defined name of this object
  85768. */
  85769. name?: string;
  85770. }
  85771. /**
  85772. * Indices of those attributes that deviate from their initialization value
  85773. */
  85774. interface IAccessorSparseIndices extends IProperty {
  85775. /**
  85776. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  85777. */
  85778. bufferView: number;
  85779. /**
  85780. * The offset relative to the start of the bufferView in bytes. Must be aligned
  85781. */
  85782. byteOffset?: number;
  85783. /**
  85784. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  85785. */
  85786. componentType: AccessorComponentType;
  85787. }
  85788. /**
  85789. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  85790. */
  85791. interface IAccessorSparseValues extends IProperty {
  85792. /**
  85793. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  85794. */
  85795. bufferView: number;
  85796. /**
  85797. * The offset relative to the start of the bufferView in bytes. Must be aligned
  85798. */
  85799. byteOffset?: number;
  85800. }
  85801. /**
  85802. * Sparse storage of attributes that deviate from their initialization value
  85803. */
  85804. interface IAccessorSparse extends IProperty {
  85805. /**
  85806. * The number of attributes encoded in this sparse accessor
  85807. */
  85808. count: number;
  85809. /**
  85810. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  85811. */
  85812. indices: IAccessorSparseIndices;
  85813. /**
  85814. * 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
  85815. */
  85816. values: IAccessorSparseValues;
  85817. }
  85818. /**
  85819. * 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
  85820. */
  85821. interface IAccessor extends IChildRootProperty {
  85822. /**
  85823. * The index of the bufferview
  85824. */
  85825. bufferView?: number;
  85826. /**
  85827. * The offset relative to the start of the bufferView in bytes
  85828. */
  85829. byteOffset?: number;
  85830. /**
  85831. * The datatype of components in the attribute
  85832. */
  85833. componentType: AccessorComponentType;
  85834. /**
  85835. * Specifies whether integer data values should be normalized
  85836. */
  85837. normalized?: boolean;
  85838. /**
  85839. * The number of attributes referenced by this accessor
  85840. */
  85841. count: number;
  85842. /**
  85843. * Specifies if the attribute is a scalar, vector, or matrix
  85844. */
  85845. type: AccessorType;
  85846. /**
  85847. * Maximum value of each component in this attribute
  85848. */
  85849. max?: number[];
  85850. /**
  85851. * Minimum value of each component in this attribute
  85852. */
  85853. min?: number[];
  85854. /**
  85855. * Sparse storage of attributes that deviate from their initialization value
  85856. */
  85857. sparse?: IAccessorSparse;
  85858. }
  85859. /**
  85860. * Targets an animation's sampler at a node's property
  85861. */
  85862. interface IAnimationChannel extends IProperty {
  85863. /**
  85864. * The index of a sampler in this animation used to compute the value for the target
  85865. */
  85866. sampler: number;
  85867. /**
  85868. * The index of the node and TRS property to target
  85869. */
  85870. target: IAnimationChannelTarget;
  85871. }
  85872. /**
  85873. * The index of the node and TRS property that an animation channel targets
  85874. */
  85875. interface IAnimationChannelTarget extends IProperty {
  85876. /**
  85877. * The index of the node to target
  85878. */
  85879. node: number;
  85880. /**
  85881. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  85882. */
  85883. path: AnimationChannelTargetPath;
  85884. }
  85885. /**
  85886. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  85887. */
  85888. interface IAnimationSampler extends IProperty {
  85889. /**
  85890. * The index of an accessor containing keyframe input values, e.g., time
  85891. */
  85892. input: number;
  85893. /**
  85894. * Interpolation algorithm
  85895. */
  85896. interpolation?: AnimationSamplerInterpolation;
  85897. /**
  85898. * The index of an accessor, containing keyframe output values
  85899. */
  85900. output: number;
  85901. }
  85902. /**
  85903. * A keyframe animation
  85904. */
  85905. interface IAnimation extends IChildRootProperty {
  85906. /**
  85907. * An array of channels, each of which targets an animation's sampler at a node's property
  85908. */
  85909. channels: IAnimationChannel[];
  85910. /**
  85911. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  85912. */
  85913. samplers: IAnimationSampler[];
  85914. }
  85915. /**
  85916. * Metadata about the glTF asset
  85917. */
  85918. interface IAsset extends IChildRootProperty {
  85919. /**
  85920. * A copyright message suitable for display to credit the content creator
  85921. */
  85922. copyright?: string;
  85923. /**
  85924. * Tool that generated this glTF model. Useful for debugging
  85925. */
  85926. generator?: string;
  85927. /**
  85928. * The glTF version that this asset targets
  85929. */
  85930. version: string;
  85931. /**
  85932. * The minimum glTF version that this asset targets
  85933. */
  85934. minVersion?: string;
  85935. }
  85936. /**
  85937. * A buffer points to binary geometry, animation, or skins
  85938. */
  85939. interface IBuffer extends IChildRootProperty {
  85940. /**
  85941. * 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
  85942. */
  85943. uri?: string;
  85944. /**
  85945. * The length of the buffer in bytes
  85946. */
  85947. byteLength: number;
  85948. }
  85949. /**
  85950. * A view into a buffer generally representing a subset of the buffer
  85951. */
  85952. interface IBufferView extends IChildRootProperty {
  85953. /**
  85954. * The index of the buffer
  85955. */
  85956. buffer: number;
  85957. /**
  85958. * The offset into the buffer in bytes
  85959. */
  85960. byteOffset?: number;
  85961. /**
  85962. * The lenth of the bufferView in bytes
  85963. */
  85964. byteLength: number;
  85965. /**
  85966. * The stride, in bytes
  85967. */
  85968. byteStride?: number;
  85969. }
  85970. /**
  85971. * An orthographic camera containing properties to create an orthographic projection matrix
  85972. */
  85973. interface ICameraOrthographic extends IProperty {
  85974. /**
  85975. * The floating-point horizontal magnification of the view. Must not be zero
  85976. */
  85977. xmag: number;
  85978. /**
  85979. * The floating-point vertical magnification of the view. Must not be zero
  85980. */
  85981. ymag: number;
  85982. /**
  85983. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  85984. */
  85985. zfar: number;
  85986. /**
  85987. * The floating-point distance to the near clipping plane
  85988. */
  85989. znear: number;
  85990. }
  85991. /**
  85992. * A perspective camera containing properties to create a perspective projection matrix
  85993. */
  85994. interface ICameraPerspective extends IProperty {
  85995. /**
  85996. * The floating-point aspect ratio of the field of view
  85997. */
  85998. aspectRatio?: number;
  85999. /**
  86000. * The floating-point vertical field of view in radians
  86001. */
  86002. yfov: number;
  86003. /**
  86004. * The floating-point distance to the far clipping plane
  86005. */
  86006. zfar?: number;
  86007. /**
  86008. * The floating-point distance to the near clipping plane
  86009. */
  86010. znear: number;
  86011. }
  86012. /**
  86013. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  86014. */
  86015. interface ICamera extends IChildRootProperty {
  86016. /**
  86017. * An orthographic camera containing properties to create an orthographic projection matrix
  86018. */
  86019. orthographic?: ICameraOrthographic;
  86020. /**
  86021. * A perspective camera containing properties to create a perspective projection matrix
  86022. */
  86023. perspective?: ICameraPerspective;
  86024. /**
  86025. * Specifies if the camera uses a perspective or orthographic projection
  86026. */
  86027. type: CameraType;
  86028. }
  86029. /**
  86030. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  86031. */
  86032. interface IImage extends IChildRootProperty {
  86033. /**
  86034. * 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
  86035. */
  86036. uri?: string;
  86037. /**
  86038. * The image's MIME type
  86039. */
  86040. mimeType?: ImageMimeType;
  86041. /**
  86042. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  86043. */
  86044. bufferView?: number;
  86045. }
  86046. /**
  86047. * Material Normal Texture Info
  86048. */
  86049. interface IMaterialNormalTextureInfo extends ITextureInfo {
  86050. /**
  86051. * The scalar multiplier applied to each normal vector of the normal texture
  86052. */
  86053. scale?: number;
  86054. }
  86055. /**
  86056. * Material Occlusion Texture Info
  86057. */
  86058. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  86059. /**
  86060. * A scalar multiplier controlling the amount of occlusion applied
  86061. */
  86062. strength?: number;
  86063. }
  86064. /**
  86065. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  86066. */
  86067. interface IMaterialPbrMetallicRoughness {
  86068. /**
  86069. * The material's base color factor
  86070. */
  86071. baseColorFactor?: number[];
  86072. /**
  86073. * The base color texture
  86074. */
  86075. baseColorTexture?: ITextureInfo;
  86076. /**
  86077. * The metalness of the material
  86078. */
  86079. metallicFactor?: number;
  86080. /**
  86081. * The roughness of the material
  86082. */
  86083. roughnessFactor?: number;
  86084. /**
  86085. * The metallic-roughness texture
  86086. */
  86087. metallicRoughnessTexture?: ITextureInfo;
  86088. }
  86089. /**
  86090. * The material appearance of a primitive
  86091. */
  86092. interface IMaterial extends IChildRootProperty {
  86093. /**
  86094. * 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
  86095. */
  86096. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  86097. /**
  86098. * The normal map texture
  86099. */
  86100. normalTexture?: IMaterialNormalTextureInfo;
  86101. /**
  86102. * The occlusion map texture
  86103. */
  86104. occlusionTexture?: IMaterialOcclusionTextureInfo;
  86105. /**
  86106. * The emissive map texture
  86107. */
  86108. emissiveTexture?: ITextureInfo;
  86109. /**
  86110. * 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
  86111. */
  86112. emissiveFactor?: number[];
  86113. /**
  86114. * The alpha rendering mode of the material
  86115. */
  86116. alphaMode?: MaterialAlphaMode;
  86117. /**
  86118. * The alpha cutoff value of the material
  86119. */
  86120. alphaCutoff?: number;
  86121. /**
  86122. * Specifies whether the material is double sided
  86123. */
  86124. doubleSided?: boolean;
  86125. }
  86126. /**
  86127. * Geometry to be rendered with the given material
  86128. */
  86129. interface IMeshPrimitive extends IProperty {
  86130. /**
  86131. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  86132. */
  86133. attributes: {
  86134. [name: string]: number;
  86135. };
  86136. /**
  86137. * The index of the accessor that contains the indices
  86138. */
  86139. indices?: number;
  86140. /**
  86141. * The index of the material to apply to this primitive when rendering
  86142. */
  86143. material?: number;
  86144. /**
  86145. * The type of primitives to render. All valid values correspond to WebGL enums
  86146. */
  86147. mode?: MeshPrimitiveMode;
  86148. /**
  86149. * 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
  86150. */
  86151. targets?: {
  86152. [name: string]: number;
  86153. }[];
  86154. }
  86155. /**
  86156. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  86157. */
  86158. interface IMesh extends IChildRootProperty {
  86159. /**
  86160. * An array of primitives, each defining geometry to be rendered with a material
  86161. */
  86162. primitives: IMeshPrimitive[];
  86163. /**
  86164. * Array of weights to be applied to the Morph Targets
  86165. */
  86166. weights?: number[];
  86167. }
  86168. /**
  86169. * A node in the node hierarchy
  86170. */
  86171. interface INode extends IChildRootProperty {
  86172. /**
  86173. * The index of the camera referenced by this node
  86174. */
  86175. camera?: number;
  86176. /**
  86177. * The indices of this node's children
  86178. */
  86179. children?: number[];
  86180. /**
  86181. * The index of the skin referenced by this node
  86182. */
  86183. skin?: number;
  86184. /**
  86185. * A floating-point 4x4 transformation matrix stored in column-major order
  86186. */
  86187. matrix?: number[];
  86188. /**
  86189. * The index of the mesh in this node
  86190. */
  86191. mesh?: number;
  86192. /**
  86193. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  86194. */
  86195. rotation?: number[];
  86196. /**
  86197. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  86198. */
  86199. scale?: number[];
  86200. /**
  86201. * The node's translation along the x, y, and z axes
  86202. */
  86203. translation?: number[];
  86204. /**
  86205. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  86206. */
  86207. weights?: number[];
  86208. }
  86209. /**
  86210. * Texture sampler properties for filtering and wrapping modes
  86211. */
  86212. interface ISampler extends IChildRootProperty {
  86213. /**
  86214. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  86215. */
  86216. magFilter?: TextureMagFilter;
  86217. /**
  86218. * Minification filter. All valid values correspond to WebGL enums
  86219. */
  86220. minFilter?: TextureMinFilter;
  86221. /**
  86222. * S (U) wrapping mode. All valid values correspond to WebGL enums
  86223. */
  86224. wrapS?: TextureWrapMode;
  86225. /**
  86226. * T (V) wrapping mode. All valid values correspond to WebGL enums
  86227. */
  86228. wrapT?: TextureWrapMode;
  86229. }
  86230. /**
  86231. * The root nodes of a scene
  86232. */
  86233. interface IScene extends IChildRootProperty {
  86234. /**
  86235. * The indices of each root node
  86236. */
  86237. nodes: number[];
  86238. }
  86239. /**
  86240. * Joints and matrices defining a skin
  86241. */
  86242. interface ISkin extends IChildRootProperty {
  86243. /**
  86244. * 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
  86245. */
  86246. inverseBindMatrices?: number;
  86247. /**
  86248. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  86249. */
  86250. skeleton?: number;
  86251. /**
  86252. * 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)
  86253. */
  86254. joints: number[];
  86255. }
  86256. /**
  86257. * A texture and its sampler
  86258. */
  86259. interface ITexture extends IChildRootProperty {
  86260. /**
  86261. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  86262. */
  86263. sampler?: number;
  86264. /**
  86265. * The index of the image used by this texture
  86266. */
  86267. source: number;
  86268. }
  86269. /**
  86270. * Reference to a texture
  86271. */
  86272. interface ITextureInfo extends IProperty {
  86273. /**
  86274. * The index of the texture
  86275. */
  86276. index: number;
  86277. /**
  86278. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  86279. */
  86280. texCoord?: number;
  86281. }
  86282. /**
  86283. * The root object for a glTF asset
  86284. */
  86285. interface IGLTF extends IProperty {
  86286. /**
  86287. * An array of accessors. An accessor is a typed view into a bufferView
  86288. */
  86289. accessors?: IAccessor[];
  86290. /**
  86291. * An array of keyframe animations
  86292. */
  86293. animations?: IAnimation[];
  86294. /**
  86295. * Metadata about the glTF asset
  86296. */
  86297. asset: IAsset;
  86298. /**
  86299. * An array of buffers. A buffer points to binary geometry, animation, or skins
  86300. */
  86301. buffers?: IBuffer[];
  86302. /**
  86303. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  86304. */
  86305. bufferViews?: IBufferView[];
  86306. /**
  86307. * An array of cameras
  86308. */
  86309. cameras?: ICamera[];
  86310. /**
  86311. * Names of glTF extensions used somewhere in this asset
  86312. */
  86313. extensionsUsed?: string[];
  86314. /**
  86315. * Names of glTF extensions required to properly load this asset
  86316. */
  86317. extensionsRequired?: string[];
  86318. /**
  86319. * An array of images. An image defines data used to create a texture
  86320. */
  86321. images?: IImage[];
  86322. /**
  86323. * An array of materials. A material defines the appearance of a primitive
  86324. */
  86325. materials?: IMaterial[];
  86326. /**
  86327. * An array of meshes. A mesh is a set of primitives to be rendered
  86328. */
  86329. meshes?: IMesh[];
  86330. /**
  86331. * An array of nodes
  86332. */
  86333. nodes?: INode[];
  86334. /**
  86335. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  86336. */
  86337. samplers?: ISampler[];
  86338. /**
  86339. * The index of the default scene
  86340. */
  86341. scene?: number;
  86342. /**
  86343. * An array of scenes
  86344. */
  86345. scenes?: IScene[];
  86346. /**
  86347. * An array of skins. A skin is defined by joints and matrices
  86348. */
  86349. skins?: ISkin[];
  86350. /**
  86351. * An array of textures
  86352. */
  86353. textures?: ITexture[];
  86354. }
  86355. /**
  86356. * The glTF validation results
  86357. * @ignore
  86358. */
  86359. interface IGLTFValidationResults {
  86360. info: {
  86361. generator: string;
  86362. hasAnimations: boolean;
  86363. hasDefaultScene: boolean;
  86364. hasMaterials: boolean;
  86365. hasMorphTargets: boolean;
  86366. hasSkins: boolean;
  86367. hasTextures: boolean;
  86368. maxAttributesUsed: number;
  86369. primitivesCount: number
  86370. };
  86371. issues: {
  86372. messages: Array<string>;
  86373. numErrors: number;
  86374. numHints: number;
  86375. numInfos: number;
  86376. numWarnings: number;
  86377. truncated: boolean
  86378. };
  86379. mimeType: string;
  86380. uri: string;
  86381. validatedAt: string;
  86382. validatorVersion: string;
  86383. }
  86384. /**
  86385. * The glTF validation options
  86386. */
  86387. interface IGLTFValidationOptions {
  86388. /** Uri to use */
  86389. uri?: string;
  86390. /** Function used to load external resources */
  86391. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  86392. /** Boolean indicating that we need to validate accessor data */
  86393. validateAccessorData?: boolean;
  86394. /** max number of issues allowed */
  86395. maxIssues?: number;
  86396. /** Ignored issues */
  86397. ignoredIssues?: Array<string>;
  86398. /** Value to override severy settings */
  86399. severityOverrides?: Object;
  86400. }
  86401. /**
  86402. * The glTF validator object
  86403. * @ignore
  86404. */
  86405. interface IGLTFValidator {
  86406. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  86407. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  86408. }
  86409. /**
  86410. * Interfaces from the EXT_lights_image_based extension
  86411. */
  86412. /** @hidden */
  86413. interface IEXTLightsImageBased_LightReferenceImageBased {
  86414. light: number;
  86415. }
  86416. /** @hidden */
  86417. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  86418. intensity: number;
  86419. rotation: number[];
  86420. specularImageSize: number;
  86421. specularImages: number[][];
  86422. irradianceCoefficients: number[][];
  86423. }
  86424. /** @hidden */
  86425. interface IEXTLightsImageBased {
  86426. lights: IEXTLightsImageBased_LightImageBased[];
  86427. }
  86428. /**
  86429. * Interfaces from the EXT_mesh_gpu_instancing extension
  86430. * !!! Experimental Extension Subject to Changes !!!
  86431. */
  86432. /** @hidden */
  86433. interface IEXTMeshGpuInstancing {
  86434. mesh?: number;
  86435. attributes: { [name: string]: number };
  86436. }
  86437. /**
  86438. * Interfaces from the KHR_draco_mesh_compression extension
  86439. */
  86440. /** @hidden */
  86441. interface IKHRDracoMeshCompression {
  86442. bufferView: number;
  86443. attributes: { [name: string]: number };
  86444. }
  86445. /**
  86446. * Interfaces from the KHR_lights_punctual extension
  86447. */
  86448. /** @hidden */
  86449. const enum IKHRLightsPunctual_LightType {
  86450. DIRECTIONAL = "directional",
  86451. POINT = "point",
  86452. SPOT = "spot"
  86453. }
  86454. /** @hidden */
  86455. interface IKHRLightsPunctual_LightReference {
  86456. light: number;
  86457. }
  86458. /** @hidden */
  86459. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  86460. type: IKHRLightsPunctual_LightType;
  86461. color?: number[];
  86462. intensity?: number;
  86463. range?: number;
  86464. spot?: {
  86465. innerConeAngle?: number;
  86466. outerConeAngle?: number;
  86467. };
  86468. }
  86469. /** @hidden */
  86470. interface IKHRLightsPunctual {
  86471. lights: IKHRLightsPunctual_Light[];
  86472. }
  86473. /**
  86474. * Interfaces from the KHR_materials_clearcoat extension
  86475. * !!! Experimental Extension Subject to Changes !!!
  86476. */
  86477. /** @hidden */
  86478. interface IKHRMaterialsClearcoat {
  86479. clearcoatFactor: number;
  86480. clearcoatTexture: ITextureInfo;
  86481. clearcoatRoughnessFactor: number;
  86482. clearcoatRoughnessTexture: ITextureInfo;
  86483. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  86484. }
  86485. /**
  86486. * Interfaces from the KHR_materials_ior extension
  86487. * !!! Experimental Extension Subject to Changes !!!
  86488. */
  86489. /** @hidden */
  86490. interface IKHRMaterialsIor {
  86491. ior: number;
  86492. }
  86493. /**
  86494. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  86495. */
  86496. /** @hidden */
  86497. interface IKHRMaterialsPbrSpecularGlossiness {
  86498. diffuseFactor: number[];
  86499. diffuseTexture: ITextureInfo;
  86500. specularFactor: number[];
  86501. glossinessFactor: number;
  86502. specularGlossinessTexture: ITextureInfo;
  86503. }
  86504. /**
  86505. * Interfaces from the KHR_materials_sheen extension
  86506. * !!! Experimental Extension Subject to Changes !!!
  86507. */
  86508. /** @hidden */
  86509. interface IKHRMaterialsSheen {
  86510. sheenColorFactor?: number[];
  86511. sheenColorTexture?: ITextureInfo;
  86512. sheenRoughnessFactor?: number;
  86513. sheenRoughnessTexture?: ITextureInfo;
  86514. }
  86515. /**
  86516. * Interfaces from the KHR_materials_specular extension
  86517. * !!! Experimental Extension Subject to Changes !!!
  86518. */
  86519. /** @hidden */
  86520. interface IKHRMaterialsSpecular {
  86521. specularFactor: number;
  86522. specularColorFactor: number[];
  86523. specularTexture: ITextureInfo;
  86524. }
  86525. /**
  86526. * Interfaces from the KHR_materials_transmission extension
  86527. * !!! Experimental Extension Subject to Changes !!!
  86528. */
  86529. /** @hidden */
  86530. interface IKHRMaterialsTransmission {
  86531. transmissionFactor?: number;
  86532. transmissionTexture?: ITextureInfo;
  86533. }
  86534. /**
  86535. * Interfaces from the KHR_materials_variants extension
  86536. * !!! Experimental Extension Subject to Changes !!!
  86537. */
  86538. /** @hidden */
  86539. interface IKHRMaterialVariants_Mapping extends IProperty {
  86540. mappings: Array<{
  86541. variants: number[];
  86542. material: number;
  86543. }>;
  86544. }
  86545. /** @hidden */
  86546. interface IKHRMaterialVariants_Variant extends IProperty {
  86547. name: string;
  86548. }
  86549. /** @hidden */
  86550. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  86551. variants: Array<IKHRMaterialVariants_Variant>;
  86552. }
  86553. /**
  86554. * Interfaces from the KHR_texture_basisu extension
  86555. * !!! Experimental Extension Subject to Changes !!!
  86556. */
  86557. /** @hidden */
  86558. interface IKHRTextureBasisU {
  86559. source: number;
  86560. }
  86561. /**
  86562. * Interfaces from the EXT_texture_webp extension
  86563. */
  86564. /** @hidden */
  86565. interface IEXTTextureWebP {
  86566. source: number;
  86567. }
  86568. /**
  86569. * Interfaces from the KHR_texture_transform extension
  86570. */
  86571. /** @hidden */
  86572. interface IKHRTextureTransform {
  86573. offset?: number[];
  86574. rotation?: number;
  86575. scale?: number[];
  86576. texCoord?: number;
  86577. }
  86578. /**
  86579. * Interfaces from the KHR_xmp extension
  86580. * !!! Experimental Extension Subject to Changes !!!
  86581. */
  86582. /** @hidden */
  86583. interface IKHRXmp_Data {
  86584. [key: string]: unknown;
  86585. }
  86586. /** @hidden */
  86587. interface IKHRXmp_Gltf {
  86588. packets: IKHRXmp_Data[];
  86589. }
  86590. /** @hidden */
  86591. interface IKHRXmp_Node {
  86592. packet: number;
  86593. }
  86594. /**
  86595. * Interfaces from the MSFT_audio_emitter extension
  86596. */
  86597. /** @hidden */
  86598. interface IMSFTAudioEmitter_ClipReference {
  86599. clip: number;
  86600. weight?: number;
  86601. }
  86602. /** @hidden */
  86603. interface IMSFTAudioEmitter_EmittersReference {
  86604. emitters: number[];
  86605. }
  86606. /** @hidden */
  86607. const enum IMSFTAudioEmitter_DistanceModel {
  86608. linear = "linear",
  86609. inverse = "inverse",
  86610. exponential = "exponential",
  86611. }
  86612. /** @hidden */
  86613. interface IMSFTAudioEmitter_Emitter {
  86614. name?: string;
  86615. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  86616. refDistance?: number;
  86617. maxDistance?: number;
  86618. rolloffFactor?: number;
  86619. innerAngle?: number;
  86620. outerAngle?: number;
  86621. loop?: boolean;
  86622. volume?: number;
  86623. clips: IMSFTAudioEmitter_ClipReference[];
  86624. }
  86625. /** @hidden */
  86626. const enum IMSFTAudioEmitter_AudioMimeType {
  86627. WAV = "audio/wav",
  86628. }
  86629. /** @hidden */
  86630. interface IMSFTAudioEmitter_Clip extends IProperty {
  86631. uri?: string;
  86632. bufferView?: number;
  86633. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  86634. }
  86635. /** @hidden */
  86636. const enum IMSFTAudioEmitter_AnimationEventAction {
  86637. play = "play",
  86638. pause = "pause",
  86639. stop = "stop",
  86640. }
  86641. /** @hidden */
  86642. interface IMSFTAudioEmitter_AnimationEvent {
  86643. action: IMSFTAudioEmitter_AnimationEventAction;
  86644. emitter: number;
  86645. time: number;
  86646. startOffset?: number;
  86647. }
  86648. /**
  86649. * Interfaces from the MSFT_lod extension
  86650. */
  86651. /** @hidden */
  86652. interface IMSFTLOD {
  86653. ids: number[];
  86654. }
  86655. }
  86656. declare module BABYLON {
  86657. /** @hidden */
  86658. export var cellPixelShader: {
  86659. name: string;
  86660. shader: string;
  86661. };
  86662. }
  86663. declare module BABYLON {
  86664. /** @hidden */
  86665. export var cellVertexShader: {
  86666. name: string;
  86667. shader: string;
  86668. };
  86669. }
  86670. declare module BABYLON {
  86671. export class CellMaterial extends BABYLON.PushMaterial {
  86672. private _diffuseTexture;
  86673. diffuseTexture: BABYLON.BaseTexture;
  86674. diffuseColor: BABYLON.Color3;
  86675. _computeHighLevel: boolean;
  86676. computeHighLevel: boolean;
  86677. private _disableLighting;
  86678. disableLighting: boolean;
  86679. private _maxSimultaneousLights;
  86680. maxSimultaneousLights: number;
  86681. constructor(name: string, scene: BABYLON.Scene);
  86682. needAlphaBlending(): boolean;
  86683. needAlphaTesting(): boolean;
  86684. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86685. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86686. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86687. getAnimatables(): BABYLON.IAnimatable[];
  86688. getActiveTextures(): BABYLON.BaseTexture[];
  86689. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86690. dispose(forceDisposeEffect?: boolean): void;
  86691. getClassName(): string;
  86692. clone(name: string): CellMaterial;
  86693. serialize(): any;
  86694. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  86695. }
  86696. }
  86697. declare module BABYLON {
  86698. export class CustomShaderStructure {
  86699. FragmentStore: string;
  86700. VertexStore: string;
  86701. constructor();
  86702. }
  86703. export class ShaderSpecialParts {
  86704. constructor();
  86705. Fragment_Begin: string;
  86706. Fragment_Definitions: string;
  86707. Fragment_MainBegin: string;
  86708. Fragment_Custom_Diffuse: string;
  86709. Fragment_Before_Lights: string;
  86710. Fragment_Before_Fog: string;
  86711. Fragment_Custom_Alpha: string;
  86712. Fragment_Before_FragColor: string;
  86713. Vertex_Begin: string;
  86714. Vertex_Definitions: string;
  86715. Vertex_MainBegin: string;
  86716. Vertex_Before_PositionUpdated: string;
  86717. Vertex_Before_NormalUpdated: string;
  86718. Vertex_After_WorldPosComputed: string;
  86719. Vertex_MainEnd: string;
  86720. }
  86721. export class CustomMaterial extends BABYLON.StandardMaterial {
  86722. static ShaderIndexer: number;
  86723. CustomParts: ShaderSpecialParts;
  86724. _isCreatedShader: boolean;
  86725. _createdShaderName: string;
  86726. _customUniform: string[];
  86727. _newUniforms: string[];
  86728. _newUniformInstances: {
  86729. [name: string]: any;
  86730. };
  86731. _newSamplerInstances: {
  86732. [name: string]: BABYLON.Texture;
  86733. };
  86734. _customAttributes: string[];
  86735. FragmentShader: string;
  86736. VertexShader: string;
  86737. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  86738. ReviewUniform(name: string, arr: string[]): string[];
  86739. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  86740. constructor(name: string, scene: BABYLON.Scene);
  86741. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  86742. AddAttribute(name: string): CustomMaterial;
  86743. Fragment_Begin(shaderPart: string): CustomMaterial;
  86744. Fragment_Definitions(shaderPart: string): CustomMaterial;
  86745. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  86746. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  86747. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  86748. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  86749. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  86750. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  86751. Vertex_Begin(shaderPart: string): CustomMaterial;
  86752. Vertex_Definitions(shaderPart: string): CustomMaterial;
  86753. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  86754. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  86755. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  86756. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  86757. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  86758. }
  86759. }
  86760. declare module BABYLON {
  86761. export class ShaderAlebdoParts {
  86762. constructor();
  86763. Fragment_Begin: string;
  86764. Fragment_Definitions: string;
  86765. Fragment_MainBegin: string;
  86766. Fragment_Custom_Albedo: string;
  86767. Fragment_Before_Lights: string;
  86768. Fragment_Custom_MetallicRoughness: string;
  86769. Fragment_Custom_MicroSurface: string;
  86770. Fragment_Before_Fog: string;
  86771. Fragment_Custom_Alpha: string;
  86772. Fragment_Before_FragColor: string;
  86773. Vertex_Begin: string;
  86774. Vertex_Definitions: string;
  86775. Vertex_MainBegin: string;
  86776. Vertex_Before_PositionUpdated: string;
  86777. Vertex_Before_NormalUpdated: string;
  86778. Vertex_After_WorldPosComputed: string;
  86779. Vertex_MainEnd: string;
  86780. }
  86781. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  86782. static ShaderIndexer: number;
  86783. CustomParts: ShaderAlebdoParts;
  86784. _isCreatedShader: boolean;
  86785. _createdShaderName: string;
  86786. _customUniform: string[];
  86787. _newUniforms: string[];
  86788. _newUniformInstances: {
  86789. [name: string]: any;
  86790. };
  86791. _newSamplerInstances: {
  86792. [name: string]: BABYLON.Texture;
  86793. };
  86794. _customAttributes: string[];
  86795. FragmentShader: string;
  86796. VertexShader: string;
  86797. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  86798. ReviewUniform(name: string, arr: string[]): string[];
  86799. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  86800. constructor(name: string, scene: BABYLON.Scene);
  86801. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  86802. AddAttribute(name: string): PBRCustomMaterial;
  86803. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  86804. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  86805. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  86806. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  86807. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  86808. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  86809. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  86810. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  86811. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  86812. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  86813. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  86814. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  86815. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  86816. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  86817. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  86818. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  86819. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  86820. }
  86821. }
  86822. declare module BABYLON {
  86823. /** @hidden */
  86824. export var firePixelShader: {
  86825. name: string;
  86826. shader: string;
  86827. };
  86828. }
  86829. declare module BABYLON {
  86830. /** @hidden */
  86831. export var fireVertexShader: {
  86832. name: string;
  86833. shader: string;
  86834. };
  86835. }
  86836. declare module BABYLON {
  86837. export class FireMaterial extends BABYLON.PushMaterial {
  86838. private _diffuseTexture;
  86839. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86840. private _distortionTexture;
  86841. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86842. private _opacityTexture;
  86843. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86844. diffuseColor: BABYLON.Color3;
  86845. speed: number;
  86846. private _scaledDiffuse;
  86847. private _lastTime;
  86848. constructor(name: string, scene: BABYLON.Scene);
  86849. needAlphaBlending(): boolean;
  86850. needAlphaTesting(): boolean;
  86851. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86852. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86853. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86854. getAnimatables(): BABYLON.IAnimatable[];
  86855. getActiveTextures(): BABYLON.BaseTexture[];
  86856. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86857. getClassName(): string;
  86858. dispose(forceDisposeEffect?: boolean): void;
  86859. clone(name: string): FireMaterial;
  86860. serialize(): any;
  86861. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  86862. }
  86863. }
  86864. declare module BABYLON {
  86865. /** @hidden */
  86866. export var furPixelShader: {
  86867. name: string;
  86868. shader: string;
  86869. };
  86870. }
  86871. declare module BABYLON {
  86872. /** @hidden */
  86873. export var furVertexShader: {
  86874. name: string;
  86875. shader: string;
  86876. };
  86877. }
  86878. declare module BABYLON {
  86879. export class FurMaterial extends BABYLON.PushMaterial {
  86880. private _diffuseTexture;
  86881. diffuseTexture: BABYLON.BaseTexture;
  86882. private _heightTexture;
  86883. heightTexture: BABYLON.BaseTexture;
  86884. diffuseColor: BABYLON.Color3;
  86885. furLength: number;
  86886. furAngle: number;
  86887. furColor: BABYLON.Color3;
  86888. furOffset: number;
  86889. furSpacing: number;
  86890. furGravity: BABYLON.Vector3;
  86891. furSpeed: number;
  86892. furDensity: number;
  86893. furOcclusion: number;
  86894. furTexture: BABYLON.DynamicTexture;
  86895. private _disableLighting;
  86896. disableLighting: boolean;
  86897. private _maxSimultaneousLights;
  86898. maxSimultaneousLights: number;
  86899. highLevelFur: boolean;
  86900. _meshes: BABYLON.AbstractMesh[];
  86901. private _furTime;
  86902. constructor(name: string, scene: BABYLON.Scene);
  86903. get furTime(): number;
  86904. set furTime(furTime: number);
  86905. needAlphaBlending(): boolean;
  86906. needAlphaTesting(): boolean;
  86907. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86908. updateFur(): void;
  86909. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86910. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86911. getAnimatables(): BABYLON.IAnimatable[];
  86912. getActiveTextures(): BABYLON.BaseTexture[];
  86913. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86914. dispose(forceDisposeEffect?: boolean): void;
  86915. clone(name: string): FurMaterial;
  86916. serialize(): any;
  86917. getClassName(): string;
  86918. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  86919. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  86920. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  86921. }
  86922. }
  86923. declare module BABYLON {
  86924. /** @hidden */
  86925. export var gradientPixelShader: {
  86926. name: string;
  86927. shader: string;
  86928. };
  86929. }
  86930. declare module BABYLON {
  86931. /** @hidden */
  86932. export var gradientVertexShader: {
  86933. name: string;
  86934. shader: string;
  86935. };
  86936. }
  86937. declare module BABYLON {
  86938. export class GradientMaterial extends BABYLON.PushMaterial {
  86939. private _maxSimultaneousLights;
  86940. maxSimultaneousLights: number;
  86941. topColor: BABYLON.Color3;
  86942. topColorAlpha: number;
  86943. bottomColor: BABYLON.Color3;
  86944. bottomColorAlpha: number;
  86945. offset: number;
  86946. scale: number;
  86947. smoothness: number;
  86948. private _disableLighting;
  86949. disableLighting: boolean;
  86950. constructor(name: string, scene: BABYLON.Scene);
  86951. needAlphaBlending(): boolean;
  86952. needAlphaTesting(): boolean;
  86953. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86954. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86955. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86956. getAnimatables(): BABYLON.IAnimatable[];
  86957. dispose(forceDisposeEffect?: boolean): void;
  86958. clone(name: string): GradientMaterial;
  86959. serialize(): any;
  86960. getClassName(): string;
  86961. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  86962. }
  86963. }
  86964. declare module BABYLON {
  86965. /** @hidden */
  86966. export var gridPixelShader: {
  86967. name: string;
  86968. shader: string;
  86969. };
  86970. }
  86971. declare module BABYLON {
  86972. /** @hidden */
  86973. export var gridVertexShader: {
  86974. name: string;
  86975. shader: string;
  86976. };
  86977. }
  86978. declare module BABYLON {
  86979. /**
  86980. * The grid materials allows you to wrap any shape with a grid.
  86981. * Colors are customizable.
  86982. */
  86983. export class GridMaterial extends BABYLON.PushMaterial {
  86984. /**
  86985. * Main color of the grid (e.g. between lines)
  86986. */
  86987. mainColor: BABYLON.Color3;
  86988. /**
  86989. * Color of the grid lines.
  86990. */
  86991. lineColor: BABYLON.Color3;
  86992. /**
  86993. * The scale of the grid compared to unit.
  86994. */
  86995. gridRatio: number;
  86996. /**
  86997. * Allows setting an offset for the grid lines.
  86998. */
  86999. gridOffset: BABYLON.Vector3;
  87000. /**
  87001. * The frequency of thicker lines.
  87002. */
  87003. majorUnitFrequency: number;
  87004. /**
  87005. * The visibility of minor units in the grid.
  87006. */
  87007. minorUnitVisibility: number;
  87008. /**
  87009. * The grid opacity outside of the lines.
  87010. */
  87011. opacity: number;
  87012. /**
  87013. * Determine RBG output is premultiplied by alpha value.
  87014. */
  87015. preMultiplyAlpha: boolean;
  87016. private _opacityTexture;
  87017. opacityTexture: BABYLON.BaseTexture;
  87018. private _gridControl;
  87019. /**
  87020. * constructor
  87021. * @param name The name given to the material in order to identify it afterwards.
  87022. * @param scene The scene the material is used in.
  87023. */
  87024. constructor(name: string, scene: BABYLON.Scene);
  87025. /**
  87026. * Returns wehter or not the grid requires alpha blending.
  87027. */
  87028. needAlphaBlending(): boolean;
  87029. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  87030. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87031. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87032. /**
  87033. * Dispose the material and its associated resources.
  87034. * @param forceDisposeEffect will also dispose the used effect when true
  87035. */
  87036. dispose(forceDisposeEffect?: boolean): void;
  87037. clone(name: string): GridMaterial;
  87038. serialize(): any;
  87039. getClassName(): string;
  87040. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  87041. }
  87042. }
  87043. declare module BABYLON {
  87044. /** @hidden */
  87045. export var lavaPixelShader: {
  87046. name: string;
  87047. shader: string;
  87048. };
  87049. }
  87050. declare module BABYLON {
  87051. /** @hidden */
  87052. export var lavaVertexShader: {
  87053. name: string;
  87054. shader: string;
  87055. };
  87056. }
  87057. declare module BABYLON {
  87058. export class LavaMaterial extends BABYLON.PushMaterial {
  87059. private _diffuseTexture;
  87060. diffuseTexture: BABYLON.BaseTexture;
  87061. noiseTexture: BABYLON.BaseTexture;
  87062. fogColor: BABYLON.Color3;
  87063. speed: number;
  87064. movingSpeed: number;
  87065. lowFrequencySpeed: number;
  87066. fogDensity: number;
  87067. private _lastTime;
  87068. diffuseColor: BABYLON.Color3;
  87069. private _disableLighting;
  87070. disableLighting: boolean;
  87071. private _unlit;
  87072. unlit: boolean;
  87073. private _maxSimultaneousLights;
  87074. maxSimultaneousLights: number;
  87075. private _scaledDiffuse;
  87076. constructor(name: string, scene: BABYLON.Scene);
  87077. needAlphaBlending(): boolean;
  87078. needAlphaTesting(): boolean;
  87079. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87080. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87081. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87082. getAnimatables(): BABYLON.IAnimatable[];
  87083. getActiveTextures(): BABYLON.BaseTexture[];
  87084. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87085. dispose(forceDisposeEffect?: boolean): void;
  87086. clone(name: string): LavaMaterial;
  87087. serialize(): any;
  87088. getClassName(): string;
  87089. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  87090. }
  87091. }
  87092. declare module BABYLON {
  87093. /** @hidden */
  87094. export var mixPixelShader: {
  87095. name: string;
  87096. shader: string;
  87097. };
  87098. }
  87099. declare module BABYLON {
  87100. /** @hidden */
  87101. export var mixVertexShader: {
  87102. name: string;
  87103. shader: string;
  87104. };
  87105. }
  87106. declare module BABYLON {
  87107. export class MixMaterial extends BABYLON.PushMaterial {
  87108. /**
  87109. * Mix textures
  87110. */
  87111. private _mixTexture1;
  87112. mixTexture1: BABYLON.BaseTexture;
  87113. private _mixTexture2;
  87114. mixTexture2: BABYLON.BaseTexture;
  87115. /**
  87116. * Diffuse textures
  87117. */
  87118. private _diffuseTexture1;
  87119. diffuseTexture1: BABYLON.Texture;
  87120. private _diffuseTexture2;
  87121. diffuseTexture2: BABYLON.Texture;
  87122. private _diffuseTexture3;
  87123. diffuseTexture3: BABYLON.Texture;
  87124. private _diffuseTexture4;
  87125. diffuseTexture4: BABYLON.Texture;
  87126. private _diffuseTexture5;
  87127. diffuseTexture5: BABYLON.Texture;
  87128. private _diffuseTexture6;
  87129. diffuseTexture6: BABYLON.Texture;
  87130. private _diffuseTexture7;
  87131. diffuseTexture7: BABYLON.Texture;
  87132. private _diffuseTexture8;
  87133. diffuseTexture8: BABYLON.Texture;
  87134. /**
  87135. * Uniforms
  87136. */
  87137. diffuseColor: BABYLON.Color3;
  87138. specularColor: BABYLON.Color3;
  87139. specularPower: number;
  87140. private _disableLighting;
  87141. disableLighting: boolean;
  87142. private _maxSimultaneousLights;
  87143. maxSimultaneousLights: number;
  87144. constructor(name: string, scene: BABYLON.Scene);
  87145. needAlphaBlending(): boolean;
  87146. needAlphaTesting(): boolean;
  87147. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87148. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87149. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87150. getAnimatables(): BABYLON.IAnimatable[];
  87151. getActiveTextures(): BABYLON.BaseTexture[];
  87152. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87153. dispose(forceDisposeEffect?: boolean): void;
  87154. clone(name: string): MixMaterial;
  87155. serialize(): any;
  87156. getClassName(): string;
  87157. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  87158. }
  87159. }
  87160. declare module BABYLON {
  87161. /** @hidden */
  87162. export var normalPixelShader: {
  87163. name: string;
  87164. shader: string;
  87165. };
  87166. }
  87167. declare module BABYLON {
  87168. /** @hidden */
  87169. export var normalVertexShader: {
  87170. name: string;
  87171. shader: string;
  87172. };
  87173. }
  87174. declare module BABYLON {
  87175. export class NormalMaterial extends BABYLON.PushMaterial {
  87176. private _diffuseTexture;
  87177. diffuseTexture: BABYLON.BaseTexture;
  87178. diffuseColor: BABYLON.Color3;
  87179. private _disableLighting;
  87180. disableLighting: boolean;
  87181. private _maxSimultaneousLights;
  87182. maxSimultaneousLights: number;
  87183. constructor(name: string, scene: BABYLON.Scene);
  87184. needAlphaBlending(): boolean;
  87185. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  87186. needAlphaTesting(): boolean;
  87187. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87188. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87189. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87190. getAnimatables(): BABYLON.IAnimatable[];
  87191. getActiveTextures(): BABYLON.BaseTexture[];
  87192. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87193. dispose(forceDisposeEffect?: boolean): void;
  87194. clone(name: string): NormalMaterial;
  87195. serialize(): any;
  87196. getClassName(): string;
  87197. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  87198. }
  87199. }
  87200. declare module BABYLON {
  87201. /** @hidden */
  87202. export var shadowOnlyPixelShader: {
  87203. name: string;
  87204. shader: string;
  87205. };
  87206. }
  87207. declare module BABYLON {
  87208. /** @hidden */
  87209. export var shadowOnlyVertexShader: {
  87210. name: string;
  87211. shader: string;
  87212. };
  87213. }
  87214. declare module BABYLON {
  87215. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  87216. private _activeLight;
  87217. private _needAlphaBlending;
  87218. constructor(name: string, scene: BABYLON.Scene);
  87219. shadowColor: BABYLON.Color3;
  87220. needAlphaBlending(): boolean;
  87221. needAlphaTesting(): boolean;
  87222. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87223. get activeLight(): BABYLON.IShadowLight;
  87224. set activeLight(light: BABYLON.IShadowLight);
  87225. private _getFirstShadowLightForMesh;
  87226. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87227. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87228. clone(name: string): ShadowOnlyMaterial;
  87229. serialize(): any;
  87230. getClassName(): string;
  87231. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  87232. }
  87233. }
  87234. declare module BABYLON {
  87235. /** @hidden */
  87236. export var simplePixelShader: {
  87237. name: string;
  87238. shader: string;
  87239. };
  87240. }
  87241. declare module BABYLON {
  87242. /** @hidden */
  87243. export var simpleVertexShader: {
  87244. name: string;
  87245. shader: string;
  87246. };
  87247. }
  87248. declare module BABYLON {
  87249. export class SimpleMaterial extends BABYLON.PushMaterial {
  87250. private _diffuseTexture;
  87251. diffuseTexture: BABYLON.BaseTexture;
  87252. diffuseColor: BABYLON.Color3;
  87253. private _disableLighting;
  87254. disableLighting: boolean;
  87255. private _maxSimultaneousLights;
  87256. maxSimultaneousLights: number;
  87257. constructor(name: string, scene: BABYLON.Scene);
  87258. needAlphaBlending(): boolean;
  87259. needAlphaTesting(): boolean;
  87260. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87261. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87262. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87263. getAnimatables(): BABYLON.IAnimatable[];
  87264. getActiveTextures(): BABYLON.BaseTexture[];
  87265. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87266. dispose(forceDisposeEffect?: boolean): void;
  87267. clone(name: string): SimpleMaterial;
  87268. serialize(): any;
  87269. getClassName(): string;
  87270. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  87271. }
  87272. }
  87273. declare module BABYLON {
  87274. /** @hidden */
  87275. export var skyPixelShader: {
  87276. name: string;
  87277. shader: string;
  87278. };
  87279. }
  87280. declare module BABYLON {
  87281. /** @hidden */
  87282. export var skyVertexShader: {
  87283. name: string;
  87284. shader: string;
  87285. };
  87286. }
  87287. declare module BABYLON {
  87288. /**
  87289. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  87290. * @see https://doc.babylonjs.com/extensions/sky
  87291. */
  87292. export class SkyMaterial extends BABYLON.PushMaterial {
  87293. /**
  87294. * Defines the overall luminance of sky in interval ]0, 1[.
  87295. */
  87296. luminance: number;
  87297. /**
  87298. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  87299. */
  87300. turbidity: number;
  87301. /**
  87302. * Defines the sky appearance (light intensity).
  87303. */
  87304. rayleigh: number;
  87305. /**
  87306. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  87307. */
  87308. mieCoefficient: number;
  87309. /**
  87310. * Defines the amount of haze particles following the Mie scattering theory.
  87311. */
  87312. mieDirectionalG: number;
  87313. /**
  87314. * Defines the distance of the sun according to the active scene camera.
  87315. */
  87316. distance: number;
  87317. /**
  87318. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  87319. * "inclined".
  87320. */
  87321. inclination: number;
  87322. /**
  87323. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  87324. * an object direction and a reference direction.
  87325. */
  87326. azimuth: number;
  87327. /**
  87328. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  87329. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  87330. */
  87331. sunPosition: BABYLON.Vector3;
  87332. /**
  87333. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  87334. * .sunPosition property.
  87335. */
  87336. useSunPosition: boolean;
  87337. /**
  87338. * Defines an offset vector used to get a horizon offset.
  87339. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  87340. */
  87341. cameraOffset: BABYLON.Vector3;
  87342. private _cameraPosition;
  87343. /**
  87344. * Instantiates a new sky material.
  87345. * This material allows to create dynamic and texture free
  87346. * effects for skyboxes by taking care of the atmosphere state.
  87347. * @see https://doc.babylonjs.com/extensions/sky
  87348. * @param name Define the name of the material in the scene
  87349. * @param scene Define the scene the material belong to
  87350. */
  87351. constructor(name: string, scene: BABYLON.Scene);
  87352. /**
  87353. * Specifies if the material will require alpha blending
  87354. * @returns a boolean specifying if alpha blending is needed
  87355. */
  87356. needAlphaBlending(): boolean;
  87357. /**
  87358. * Specifies if this material should be rendered in alpha test mode
  87359. * @returns false as the sky material doesn't need alpha testing.
  87360. */
  87361. needAlphaTesting(): boolean;
  87362. /**
  87363. * Get the texture used for alpha test purpose.
  87364. * @returns null as the sky material has no texture.
  87365. */
  87366. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87367. /**
  87368. * Get if the submesh is ready to be used and all its information available.
  87369. * Child classes can use it to update shaders
  87370. * @param mesh defines the mesh to check
  87371. * @param subMesh defines which submesh to check
  87372. * @param useInstances specifies that instances should be used
  87373. * @returns a boolean indicating that the submesh is ready or not
  87374. */
  87375. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87376. /**
  87377. * Binds the submesh to this material by preparing the effect and shader to draw
  87378. * @param world defines the world transformation matrix
  87379. * @param mesh defines the mesh containing the submesh
  87380. * @param subMesh defines the submesh to bind the material to
  87381. */
  87382. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87383. /**
  87384. * Get the list of animatables in the material.
  87385. * @returns the list of animatables object used in the material
  87386. */
  87387. getAnimatables(): BABYLON.IAnimatable[];
  87388. /**
  87389. * Disposes the material
  87390. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  87391. */
  87392. dispose(forceDisposeEffect?: boolean): void;
  87393. /**
  87394. * Makes a duplicate of the material, and gives it a new name
  87395. * @param name defines the new name for the duplicated material
  87396. * @returns the cloned material
  87397. */
  87398. clone(name: string): SkyMaterial;
  87399. /**
  87400. * Serializes this material in a JSON representation
  87401. * @returns the serialized material object
  87402. */
  87403. serialize(): any;
  87404. /**
  87405. * Gets the current class name of the material e.g. "SkyMaterial"
  87406. * Mainly use in serialization.
  87407. * @returns the class name
  87408. */
  87409. getClassName(): string;
  87410. /**
  87411. * Creates a sky material from parsed material data
  87412. * @param source defines the JSON representation of the material
  87413. * @param scene defines the hosting scene
  87414. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  87415. * @returns a new sky material
  87416. */
  87417. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  87418. }
  87419. }
  87420. declare module BABYLON {
  87421. /** @hidden */
  87422. export var terrainPixelShader: {
  87423. name: string;
  87424. shader: string;
  87425. };
  87426. }
  87427. declare module BABYLON {
  87428. /** @hidden */
  87429. export var terrainVertexShader: {
  87430. name: string;
  87431. shader: string;
  87432. };
  87433. }
  87434. declare module BABYLON {
  87435. export class TerrainMaterial extends BABYLON.PushMaterial {
  87436. private _mixTexture;
  87437. mixTexture: BABYLON.BaseTexture;
  87438. private _diffuseTexture1;
  87439. diffuseTexture1: BABYLON.Texture;
  87440. private _diffuseTexture2;
  87441. diffuseTexture2: BABYLON.Texture;
  87442. private _diffuseTexture3;
  87443. diffuseTexture3: BABYLON.Texture;
  87444. private _bumpTexture1;
  87445. bumpTexture1: BABYLON.Texture;
  87446. private _bumpTexture2;
  87447. bumpTexture2: BABYLON.Texture;
  87448. private _bumpTexture3;
  87449. bumpTexture3: BABYLON.Texture;
  87450. diffuseColor: BABYLON.Color3;
  87451. specularColor: BABYLON.Color3;
  87452. specularPower: number;
  87453. private _disableLighting;
  87454. disableLighting: boolean;
  87455. private _maxSimultaneousLights;
  87456. maxSimultaneousLights: number;
  87457. constructor(name: string, scene: BABYLON.Scene);
  87458. needAlphaBlending(): boolean;
  87459. needAlphaTesting(): boolean;
  87460. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87461. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87462. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87463. getAnimatables(): BABYLON.IAnimatable[];
  87464. getActiveTextures(): BABYLON.BaseTexture[];
  87465. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87466. dispose(forceDisposeEffect?: boolean): void;
  87467. clone(name: string): TerrainMaterial;
  87468. serialize(): any;
  87469. getClassName(): string;
  87470. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  87471. }
  87472. }
  87473. declare module BABYLON {
  87474. /** @hidden */
  87475. export var triplanarPixelShader: {
  87476. name: string;
  87477. shader: string;
  87478. };
  87479. }
  87480. declare module BABYLON {
  87481. /** @hidden */
  87482. export var triplanarVertexShader: {
  87483. name: string;
  87484. shader: string;
  87485. };
  87486. }
  87487. declare module BABYLON {
  87488. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  87489. mixTexture: BABYLON.BaseTexture;
  87490. private _diffuseTextureX;
  87491. diffuseTextureX: BABYLON.BaseTexture;
  87492. private _diffuseTextureY;
  87493. diffuseTextureY: BABYLON.BaseTexture;
  87494. private _diffuseTextureZ;
  87495. diffuseTextureZ: BABYLON.BaseTexture;
  87496. private _normalTextureX;
  87497. normalTextureX: BABYLON.BaseTexture;
  87498. private _normalTextureY;
  87499. normalTextureY: BABYLON.BaseTexture;
  87500. private _normalTextureZ;
  87501. normalTextureZ: BABYLON.BaseTexture;
  87502. tileSize: number;
  87503. diffuseColor: BABYLON.Color3;
  87504. specularColor: BABYLON.Color3;
  87505. specularPower: number;
  87506. private _disableLighting;
  87507. disableLighting: boolean;
  87508. private _maxSimultaneousLights;
  87509. maxSimultaneousLights: number;
  87510. constructor(name: string, scene: BABYLON.Scene);
  87511. needAlphaBlending(): boolean;
  87512. needAlphaTesting(): boolean;
  87513. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87514. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87515. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87516. getAnimatables(): BABYLON.IAnimatable[];
  87517. getActiveTextures(): BABYLON.BaseTexture[];
  87518. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87519. dispose(forceDisposeEffect?: boolean): void;
  87520. clone(name: string): TriPlanarMaterial;
  87521. serialize(): any;
  87522. getClassName(): string;
  87523. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  87524. }
  87525. }
  87526. declare module BABYLON {
  87527. /** @hidden */
  87528. export var waterPixelShader: {
  87529. name: string;
  87530. shader: string;
  87531. };
  87532. }
  87533. declare module BABYLON {
  87534. /** @hidden */
  87535. export var waterVertexShader: {
  87536. name: string;
  87537. shader: string;
  87538. };
  87539. }
  87540. declare module BABYLON {
  87541. export class WaterMaterial extends BABYLON.PushMaterial {
  87542. renderTargetSize: BABYLON.Vector2;
  87543. private _bumpTexture;
  87544. bumpTexture: BABYLON.BaseTexture;
  87545. diffuseColor: BABYLON.Color3;
  87546. specularColor: BABYLON.Color3;
  87547. specularPower: number;
  87548. private _disableLighting;
  87549. disableLighting: boolean;
  87550. private _maxSimultaneousLights;
  87551. maxSimultaneousLights: number;
  87552. /**
  87553. * Defines the wind force.
  87554. */
  87555. windForce: number;
  87556. /**
  87557. * Defines the direction of the wind in the plane (X, Z).
  87558. */
  87559. windDirection: BABYLON.Vector2;
  87560. /**
  87561. * Defines the height of the waves.
  87562. */
  87563. waveHeight: number;
  87564. /**
  87565. * Defines the bump height related to the bump map.
  87566. */
  87567. bumpHeight: number;
  87568. /**
  87569. * Defines wether or not: to add a smaller moving bump to less steady waves.
  87570. */
  87571. private _bumpSuperimpose;
  87572. bumpSuperimpose: boolean;
  87573. /**
  87574. * Defines wether or not color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  87575. */
  87576. private _fresnelSeparate;
  87577. fresnelSeparate: boolean;
  87578. /**
  87579. * Defines wether or not bump Wwves modify the reflection.
  87580. */
  87581. private _bumpAffectsReflection;
  87582. bumpAffectsReflection: boolean;
  87583. /**
  87584. * Defines the water color blended with the refraction (near).
  87585. */
  87586. waterColor: BABYLON.Color3;
  87587. /**
  87588. * Defines the blend factor related to the water color.
  87589. */
  87590. colorBlendFactor: number;
  87591. /**
  87592. * Defines the water color blended with the reflection (far).
  87593. */
  87594. waterColor2: BABYLON.Color3;
  87595. /**
  87596. * Defines the blend factor related to the water color (reflection, far).
  87597. */
  87598. colorBlendFactor2: number;
  87599. /**
  87600. * Defines the maximum length of a wave.
  87601. */
  87602. waveLength: number;
  87603. /**
  87604. * Defines the waves speed.
  87605. */
  87606. waveSpeed: number;
  87607. /**
  87608. * 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.
  87609. */
  87610. waveCount: number;
  87611. /**
  87612. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  87613. * will avoid calculating useless pixels in the pixel shader of the water material.
  87614. */
  87615. disableClipPlane: boolean;
  87616. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  87617. private _mesh;
  87618. private _refractionRTT;
  87619. private _reflectionRTT;
  87620. private _reflectionTransform;
  87621. private _lastTime;
  87622. private _lastDeltaTime;
  87623. private _useLogarithmicDepth;
  87624. private _waitingRenderList;
  87625. private _imageProcessingConfiguration;
  87626. private _imageProcessingObserver;
  87627. /**
  87628. * Gets a boolean indicating that current material needs to register RTT
  87629. */
  87630. get hasRenderTargetTextures(): boolean;
  87631. /**
  87632. * Constructor
  87633. */
  87634. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  87635. get useLogarithmicDepth(): boolean;
  87636. set useLogarithmicDepth(value: boolean);
  87637. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  87638. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  87639. addToRenderList(node: any): void;
  87640. enableRenderTargets(enable: boolean): void;
  87641. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  87642. get renderTargetsEnabled(): boolean;
  87643. needAlphaBlending(): boolean;
  87644. needAlphaTesting(): boolean;
  87645. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87646. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87647. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87648. private _createRenderTargets;
  87649. getAnimatables(): BABYLON.IAnimatable[];
  87650. getActiveTextures(): BABYLON.BaseTexture[];
  87651. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87652. dispose(forceDisposeEffect?: boolean): void;
  87653. clone(name: string): WaterMaterial;
  87654. serialize(): any;
  87655. getClassName(): string;
  87656. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  87657. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  87658. }
  87659. }
  87660. declare module BABYLON {
  87661. /** @hidden */
  87662. export var asciiartPixelShader: {
  87663. name: string;
  87664. shader: string;
  87665. };
  87666. }
  87667. declare module BABYLON {
  87668. /**
  87669. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  87670. *
  87671. * It basically takes care rendering the font front the given font size to a texture.
  87672. * This is used later on in the postprocess.
  87673. */
  87674. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  87675. private _font;
  87676. private _text;
  87677. private _charSize;
  87678. /**
  87679. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  87680. */
  87681. get charSize(): number;
  87682. /**
  87683. * Create a new instance of the Ascii Art FontTexture class
  87684. * @param name the name of the texture
  87685. * @param font the font to use, use the W3C CSS notation
  87686. * @param text the caracter set to use in the rendering.
  87687. * @param scene the scene that owns the texture
  87688. */
  87689. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  87690. /**
  87691. * Gets the max char width of a font.
  87692. * @param font the font to use, use the W3C CSS notation
  87693. * @return the max char width
  87694. */
  87695. private getFontWidth;
  87696. /**
  87697. * Gets the max char height of a font.
  87698. * @param font the font to use, use the W3C CSS notation
  87699. * @return the max char height
  87700. */
  87701. private getFontHeight;
  87702. /**
  87703. * Clones the current AsciiArtTexture.
  87704. * @return the clone of the texture.
  87705. */
  87706. clone(): AsciiArtFontTexture;
  87707. /**
  87708. * Parses a json object representing the texture and returns an instance of it.
  87709. * @param source the source JSON representation
  87710. * @param scene the scene to create the texture for
  87711. * @return the parsed texture
  87712. */
  87713. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  87714. }
  87715. /**
  87716. * Option available in the Ascii Art Post Process.
  87717. */
  87718. export interface IAsciiArtPostProcessOptions {
  87719. /**
  87720. * The font to use following the w3c font definition.
  87721. */
  87722. font?: string;
  87723. /**
  87724. * The character set to use in the postprocess.
  87725. */
  87726. characterSet?: string;
  87727. /**
  87728. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  87729. * This number is defined between 0 and 1;
  87730. */
  87731. mixToTile?: number;
  87732. /**
  87733. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  87734. * This number is defined between 0 and 1;
  87735. */
  87736. mixToNormal?: number;
  87737. }
  87738. /**
  87739. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  87740. *
  87741. * Simmply add it to your scene and let the nerd that lives in you have fun.
  87742. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  87743. */
  87744. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  87745. /**
  87746. * The font texture used to render the char in the post process.
  87747. */
  87748. private _asciiArtFontTexture;
  87749. /**
  87750. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  87751. * This number is defined between 0 and 1;
  87752. */
  87753. mixToTile: number;
  87754. /**
  87755. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  87756. * This number is defined between 0 and 1;
  87757. */
  87758. mixToNormal: number;
  87759. /**
  87760. * Instantiates a new Ascii Art Post Process.
  87761. * @param name the name to give to the postprocess
  87762. * @camera the camera to apply the post process to.
  87763. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  87764. */
  87765. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  87766. }
  87767. }
  87768. declare module BABYLON {
  87769. /** @hidden */
  87770. export var digitalrainPixelShader: {
  87771. name: string;
  87772. shader: string;
  87773. };
  87774. }
  87775. declare module BABYLON {
  87776. /**
  87777. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  87778. *
  87779. * It basically takes care rendering the font front the given font size to a texture.
  87780. * This is used later on in the postprocess.
  87781. */
  87782. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  87783. private _font;
  87784. private _text;
  87785. private _charSize;
  87786. /**
  87787. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  87788. */
  87789. get charSize(): number;
  87790. /**
  87791. * Create a new instance of the Digital Rain FontTexture class
  87792. * @param name the name of the texture
  87793. * @param font the font to use, use the W3C CSS notation
  87794. * @param text the caracter set to use in the rendering.
  87795. * @param scene the scene that owns the texture
  87796. */
  87797. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  87798. /**
  87799. * Gets the max char width of a font.
  87800. * @param font the font to use, use the W3C CSS notation
  87801. * @return the max char width
  87802. */
  87803. private getFontWidth;
  87804. /**
  87805. * Gets the max char height of a font.
  87806. * @param font the font to use, use the W3C CSS notation
  87807. * @return the max char height
  87808. */
  87809. private getFontHeight;
  87810. /**
  87811. * Clones the current DigitalRainFontTexture.
  87812. * @return the clone of the texture.
  87813. */
  87814. clone(): DigitalRainFontTexture;
  87815. /**
  87816. * Parses a json object representing the texture and returns an instance of it.
  87817. * @param source the source JSON representation
  87818. * @param scene the scene to create the texture for
  87819. * @return the parsed texture
  87820. */
  87821. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  87822. }
  87823. /**
  87824. * Option available in the Digital Rain Post Process.
  87825. */
  87826. export interface IDigitalRainPostProcessOptions {
  87827. /**
  87828. * The font to use following the w3c font definition.
  87829. */
  87830. font?: string;
  87831. /**
  87832. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  87833. * This number is defined between 0 and 1;
  87834. */
  87835. mixToTile?: number;
  87836. /**
  87837. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  87838. * This number is defined between 0 and 1;
  87839. */
  87840. mixToNormal?: number;
  87841. }
  87842. /**
  87843. * DigitalRainPostProcess helps rendering everithing in digital rain.
  87844. *
  87845. * Simmply add it to your scene and let the nerd that lives in you have fun.
  87846. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  87847. */
  87848. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  87849. /**
  87850. * The font texture used to render the char in the post process.
  87851. */
  87852. private _digitalRainFontTexture;
  87853. /**
  87854. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  87855. * This number is defined between 0 and 1;
  87856. */
  87857. mixToTile: number;
  87858. /**
  87859. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  87860. * This number is defined between 0 and 1;
  87861. */
  87862. mixToNormal: number;
  87863. /**
  87864. * Instantiates a new Digital Rain Post Process.
  87865. * @param name the name to give to the postprocess
  87866. * @camera the camera to apply the post process to.
  87867. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  87868. */
  87869. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  87870. }
  87871. }
  87872. declare module BABYLON {
  87873. /** @hidden */
  87874. export var brickProceduralTexturePixelShader: {
  87875. name: string;
  87876. shader: string;
  87877. };
  87878. }
  87879. declare module BABYLON {
  87880. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  87881. private _numberOfBricksHeight;
  87882. private _numberOfBricksWidth;
  87883. private _jointColor;
  87884. private _brickColor;
  87885. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87886. updateShaderUniforms(): void;
  87887. get numberOfBricksHeight(): number;
  87888. set numberOfBricksHeight(value: number);
  87889. get numberOfBricksWidth(): number;
  87890. set numberOfBricksWidth(value: number);
  87891. get jointColor(): BABYLON.Color3;
  87892. set jointColor(value: BABYLON.Color3);
  87893. get brickColor(): BABYLON.Color3;
  87894. set brickColor(value: BABYLON.Color3);
  87895. /**
  87896. * Serializes this brick procedural texture
  87897. * @returns a serialized brick procedural texture object
  87898. */
  87899. serialize(): any;
  87900. /**
  87901. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  87902. * @param parsedTexture defines parsed texture data
  87903. * @param scene defines the current scene
  87904. * @param rootUrl defines the root URL containing brick procedural texture information
  87905. * @returns a parsed Brick Procedural BABYLON.Texture
  87906. */
  87907. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  87908. }
  87909. }
  87910. declare module BABYLON {
  87911. /** @hidden */
  87912. export var cloudProceduralTexturePixelShader: {
  87913. name: string;
  87914. shader: string;
  87915. };
  87916. }
  87917. declare module BABYLON {
  87918. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  87919. private _skyColor;
  87920. private _cloudColor;
  87921. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87922. updateShaderUniforms(): void;
  87923. get skyColor(): BABYLON.Color4;
  87924. set skyColor(value: BABYLON.Color4);
  87925. get cloudColor(): BABYLON.Color4;
  87926. set cloudColor(value: BABYLON.Color4);
  87927. /**
  87928. * Serializes this cloud procedural texture
  87929. * @returns a serialized cloud procedural texture object
  87930. */
  87931. serialize(): any;
  87932. /**
  87933. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  87934. * @param parsedTexture defines parsed texture data
  87935. * @param scene defines the current scene
  87936. * @param rootUrl defines the root URL containing cloud procedural texture information
  87937. * @returns a parsed Cloud Procedural BABYLON.Texture
  87938. */
  87939. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  87940. }
  87941. }
  87942. declare module BABYLON {
  87943. /** @hidden */
  87944. export var fireProceduralTexturePixelShader: {
  87945. name: string;
  87946. shader: string;
  87947. };
  87948. }
  87949. declare module BABYLON {
  87950. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  87951. private _time;
  87952. private _speed;
  87953. private _autoGenerateTime;
  87954. private _fireColors;
  87955. private _alphaThreshold;
  87956. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87957. updateShaderUniforms(): void;
  87958. render(useCameraPostProcess?: boolean): void;
  87959. static get PurpleFireColors(): BABYLON.Color3[];
  87960. static get GreenFireColors(): BABYLON.Color3[];
  87961. static get RedFireColors(): BABYLON.Color3[];
  87962. static get BlueFireColors(): BABYLON.Color3[];
  87963. get autoGenerateTime(): boolean;
  87964. set autoGenerateTime(value: boolean);
  87965. get fireColors(): BABYLON.Color3[];
  87966. set fireColors(value: BABYLON.Color3[]);
  87967. get time(): number;
  87968. set time(value: number);
  87969. get speed(): BABYLON.Vector2;
  87970. set speed(value: BABYLON.Vector2);
  87971. get alphaThreshold(): number;
  87972. set alphaThreshold(value: number);
  87973. /**
  87974. * Serializes this fire procedural texture
  87975. * @returns a serialized fire procedural texture object
  87976. */
  87977. serialize(): any;
  87978. /**
  87979. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  87980. * @param parsedTexture defines parsed texture data
  87981. * @param scene defines the current scene
  87982. * @param rootUrl defines the root URL containing fire procedural texture information
  87983. * @returns a parsed Fire Procedural BABYLON.Texture
  87984. */
  87985. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  87986. }
  87987. }
  87988. declare module BABYLON {
  87989. /** @hidden */
  87990. export var grassProceduralTexturePixelShader: {
  87991. name: string;
  87992. shader: string;
  87993. };
  87994. }
  87995. declare module BABYLON {
  87996. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  87997. private _grassColors;
  87998. private _groundColor;
  87999. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88000. updateShaderUniforms(): void;
  88001. get grassColors(): BABYLON.Color3[];
  88002. set grassColors(value: BABYLON.Color3[]);
  88003. get groundColor(): BABYLON.Color3;
  88004. set groundColor(value: BABYLON.Color3);
  88005. /**
  88006. * Serializes this grass procedural texture
  88007. * @returns a serialized grass procedural texture object
  88008. */
  88009. serialize(): any;
  88010. /**
  88011. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  88012. * @param parsedTexture defines parsed texture data
  88013. * @param scene defines the current scene
  88014. * @param rootUrl defines the root URL containing grass procedural texture information
  88015. * @returns a parsed Grass Procedural BABYLON.Texture
  88016. */
  88017. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  88018. }
  88019. }
  88020. declare module BABYLON {
  88021. /** @hidden */
  88022. export var marbleProceduralTexturePixelShader: {
  88023. name: string;
  88024. shader: string;
  88025. };
  88026. }
  88027. declare module BABYLON {
  88028. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  88029. private _numberOfTilesHeight;
  88030. private _numberOfTilesWidth;
  88031. private _amplitude;
  88032. private _jointColor;
  88033. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88034. updateShaderUniforms(): void;
  88035. get numberOfTilesHeight(): number;
  88036. set numberOfTilesHeight(value: number);
  88037. get amplitude(): number;
  88038. set amplitude(value: number);
  88039. get numberOfTilesWidth(): number;
  88040. set numberOfTilesWidth(value: number);
  88041. get jointColor(): BABYLON.Color3;
  88042. set jointColor(value: BABYLON.Color3);
  88043. /**
  88044. * Serializes this marble procedural texture
  88045. * @returns a serialized marble procedural texture object
  88046. */
  88047. serialize(): any;
  88048. /**
  88049. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  88050. * @param parsedTexture defines parsed texture data
  88051. * @param scene defines the current scene
  88052. * @param rootUrl defines the root URL containing marble procedural texture information
  88053. * @returns a parsed Marble Procedural BABYLON.Texture
  88054. */
  88055. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  88056. }
  88057. }
  88058. declare module BABYLON {
  88059. /** @hidden */
  88060. export var normalMapProceduralTexturePixelShader: {
  88061. name: string;
  88062. shader: string;
  88063. };
  88064. }
  88065. declare module BABYLON {
  88066. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  88067. private _baseTexture;
  88068. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88069. updateShaderUniforms(): void;
  88070. render(useCameraPostProcess?: boolean): void;
  88071. resize(size: any, generateMipMaps: any): void;
  88072. get baseTexture(): BABYLON.Texture;
  88073. set baseTexture(texture: BABYLON.Texture);
  88074. /**
  88075. * Serializes this normal map procedural texture
  88076. * @returns a serialized normal map procedural texture object
  88077. */
  88078. serialize(): any;
  88079. /**
  88080. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  88081. * @param parsedTexture defines parsed texture data
  88082. * @param scene defines the current scene
  88083. * @param rootUrl defines the root URL containing normal map procedural texture information
  88084. * @returns a parsed Normal Map Procedural BABYLON.Texture
  88085. */
  88086. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  88087. }
  88088. }
  88089. declare module BABYLON {
  88090. /** @hidden */
  88091. export var perlinNoiseProceduralTexturePixelShader: {
  88092. name: string;
  88093. shader: string;
  88094. };
  88095. }
  88096. declare module BABYLON {
  88097. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  88098. time: number;
  88099. timeScale: number;
  88100. translationSpeed: number;
  88101. private _currentTranslation;
  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. /**
  88107. * Serializes this perlin noise procedural texture
  88108. * @returns a serialized perlin noise procedural texture object
  88109. */
  88110. serialize(): any;
  88111. /**
  88112. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  88113. * @param parsedTexture defines parsed texture data
  88114. * @param scene defines the current scene
  88115. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  88116. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  88117. */
  88118. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  88119. }
  88120. }
  88121. declare module BABYLON {
  88122. /** @hidden */
  88123. export var roadProceduralTexturePixelShader: {
  88124. name: string;
  88125. shader: string;
  88126. };
  88127. }
  88128. declare module BABYLON {
  88129. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  88130. private _roadColor;
  88131. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88132. updateShaderUniforms(): void;
  88133. get roadColor(): BABYLON.Color3;
  88134. set roadColor(value: BABYLON.Color3);
  88135. /**
  88136. * Serializes this road procedural texture
  88137. * @returns a serialized road procedural texture object
  88138. */
  88139. serialize(): any;
  88140. /**
  88141. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  88142. * @param parsedTexture defines parsed texture data
  88143. * @param scene defines the current scene
  88144. * @param rootUrl defines the root URL containing road procedural texture information
  88145. * @returns a parsed Road Procedural BABYLON.Texture
  88146. */
  88147. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  88148. }
  88149. }
  88150. declare module BABYLON {
  88151. /** @hidden */
  88152. export var starfieldProceduralTexturePixelShader: {
  88153. name: string;
  88154. shader: string;
  88155. };
  88156. }
  88157. declare module BABYLON {
  88158. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  88159. private _time;
  88160. private _alpha;
  88161. private _beta;
  88162. private _zoom;
  88163. private _formuparam;
  88164. private _stepsize;
  88165. private _tile;
  88166. private _brightness;
  88167. private _darkmatter;
  88168. private _distfading;
  88169. private _saturation;
  88170. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88171. updateShaderUniforms(): void;
  88172. get time(): number;
  88173. set time(value: number);
  88174. get alpha(): number;
  88175. set alpha(value: number);
  88176. get beta(): number;
  88177. set beta(value: number);
  88178. get formuparam(): number;
  88179. set formuparam(value: number);
  88180. get stepsize(): number;
  88181. set stepsize(value: number);
  88182. get zoom(): number;
  88183. set zoom(value: number);
  88184. get tile(): number;
  88185. set tile(value: number);
  88186. get brightness(): number;
  88187. set brightness(value: number);
  88188. get darkmatter(): number;
  88189. set darkmatter(value: number);
  88190. get distfading(): number;
  88191. set distfading(value: number);
  88192. get saturation(): number;
  88193. set saturation(value: number);
  88194. /**
  88195. * Serializes this starfield procedural texture
  88196. * @returns a serialized starfield procedural texture object
  88197. */
  88198. serialize(): any;
  88199. /**
  88200. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  88201. * @param parsedTexture defines parsed texture data
  88202. * @param scene defines the current scene
  88203. * @param rootUrl defines the root URL containing startfield procedural texture information
  88204. * @returns a parsed Starfield Procedural BABYLON.Texture
  88205. */
  88206. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  88207. }
  88208. }
  88209. declare module BABYLON {
  88210. /** @hidden */
  88211. export var woodProceduralTexturePixelShader: {
  88212. name: string;
  88213. shader: string;
  88214. };
  88215. }
  88216. declare module BABYLON {
  88217. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  88218. private _ampScale;
  88219. private _woodColor;
  88220. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88221. updateShaderUniforms(): void;
  88222. get ampScale(): number;
  88223. set ampScale(value: number);
  88224. get woodColor(): BABYLON.Color3;
  88225. set woodColor(value: BABYLON.Color3);
  88226. /**
  88227. * Serializes this wood procedural texture
  88228. * @returns a serialized wood procedural texture object
  88229. */
  88230. serialize(): any;
  88231. /**
  88232. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  88233. * @param parsedTexture defines parsed texture data
  88234. * @param scene defines the current scene
  88235. * @param rootUrl defines the root URL containing wood procedural texture information
  88236. * @returns a parsed Wood Procedural BABYLON.Texture
  88237. */
  88238. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  88239. }
  88240. }